Results 1 to 6 of 6

Thread: Chat.simba addition: Crafting options

  1. #1
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default Chat.simba addition: Crafting options

    I've been working on some functions lately to handle the crafting menu. It's very similar to ChooseOption in that it grabs the option text and parses through it for the desired string. I put it through some testing and everything seems to be working fast and efficient

    Simba Code:
    function CraftingScreen: Boolean;
    begin
      Result := CountColorTolerance(1131144, MCX1, MCY1, MCX2, MCY2, 3) >= 100;
    end;

    function ScrollCraftingMenu(Left: Boolean): Boolean;
    var
      Box: TBox;
      P: TPoint;
      t: Integer;
    begin
      Result := False;
      if not CraftingScreen then
        Exit;
      case Left of
        True: P := Point(12, 394);
        False: P := Point(493, 394);
      end;
      Box := IntToBox(P.x, P.y, P.x + 12, P.y + 69);
      Result := WaitColor(P.x, P.y, 791065, 1, 100);
      if not Result then
        Exit;
      MouseTBox(Box, mouse_move);
      MarkTime(t);
      while not SimilarColors(GetColor(P.x, P.y), 1446924, 1) and (TimeFromMark(t) < 2000) do
        Wait(100+Random(50));
    end;

    function GetCraftingOptions(var Options: TStringArray; var Points: TPointArray): Integer;
    var
      aTPA: T2DPointArray;
      TPA: TPointArray;
      Bounds: TBox;
      P: TPoint;
      lTPA, i: Integer;
    begin
      Result := 0;
      if not CraftingScreen then
        Exit;
      SetLength(Options, 0);
      SetLength(Points, 0);
      FindColorsTolerance(TPA, 2070783, MCX1, MCY1 + 40, MCX2, MCY2, 0);
      if (Length(TPA) < 1) then
        Exit;
      aTPA := SplitTPAEx(TPA, 15, 10);
      SortATPAFromMidPoint(aTPA, Point(MCX1, MCCY));
      lTPA := Length(aTPA);
      SetLength(Options, lTPA);
      SetLength(Points, lTPA);
      for i := 0 to (lTPA - 1) do
      begin
        Bounds := GetTPABounds(aTPA[i]);
        P := MiddleTPA(aTPA[i]);
        Options[i] := GetTextAtExWrap(Bounds.x1, Bounds.y1, Bounds.x2, Bounds.y2, 0, 4, 2, 2070783, 0, statChars);
        Points[i] := Point(P.x, P.y - 15);
        if (Options[i] <> '') then
          Inc(Result);
      end;
    end;

    function CraftingOptionMulti(Text: TStringArray; Scroll: Boolean): Boolean;
    var
      Options: TStringArray;
      Points: TPointArray;
      Box: TBox;
      M: TPoint;
      hOption, hText, t, i, ii: Integer;
      Left: Boolean;
    begin
      Result := False;
      if not CraftingScreen then
        Exit;
      hText := High(Text);
      t := 0;
      repeat
        if InRange(t, 1, 2) and Scroll then
        begin
          case t of
            1: Left := True;
            2: Left := False;
          end;
          ScrollCraftingMenu(Left);
        end;
        GetCraftingOptions(Options, Points);
        if (Length(Options) < 1) then
          Exit;
        hOption := High(Options);
        for i := 0 to hText do
        begin
          for ii := 0 to hOption do
          begin
            if (Pos(Text[i], Options[ii]) <> 0) then
            begin
              Result := True;
              Box := IntToBox(Points[ii].x - 15, Points[ii].y - 15, Points[ii].x + 15, Points[ii].y + 15);
              GetMousePos(M.x, M.y);
              if PointInBox(M, Box) then
                ClickMouse2(mouse_left)
              else
                MouseTBox(Box, mouse_left);
              Wait(500+Random(250));
              Exit;
            end;
          end;
        end;
        if not Scroll then
          Exit;
        Inc(t);
      until(t > 2);
    end;

    function CraftingOption(Text: String; Scroll: Boolean): Boolean;
    begin
      Result := CraftingOptionMulti([Text], Scroll);
    end;

    function WaitCraftingOptionMulti(Time: Integer; Text: TStringArray; Scroll: Boolean): Boolean;
    var
      t: Integer;
    begin
      Result := False;
      MarkTime(t);
      while not Result and (TimeFromMark(t) < Time) do
        Result := CraftingOptionMulti(Text, Scroll);
    end;

    function WaitCraftingOption(Time: Integer; Text: String; Scroll: Boolean): Boolean;
    begin
      Result := WaitCraftingOptionMulti(Time, [Text], Scroll);
    end;

  2. #2
    Join Date
    Jun 2008
    Location
    United States
    Posts
    818
    Mentioned
    60 Post(s)
    Quoted
    90 Post(s)

    Default

    Looks neat, you should check out kanah's "The Pot Maker" I believe he wrote many of the same functions already.
    [10/14/13:19:03] <BenLand100> this is special relatively, just cleverly disguised with yachts

  3. #3
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    I believe the crafting chat options could possibly be renamed, since so many other skills use the same interface (at least I think they all matched up). I.E. using clay to make urns, you get a lot of options, as well as fletching, firemaking, and some other skills too I believe.

    Nonetheless, nice work on these additions!

  4. #4
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by euphemism View Post
    Looks neat, you should check out kanah's "The Pot Maker" I believe he wrote many of the same functions already.
    I was unaware someone had already attempted this! Although his is rather... messy

    Quote Originally Posted by Le Jingle View Post
    I believe the crafting chat options could possibly be renamed, since so many other skills use the same interface (at least I think they all matched up). I.E. using clay to make urns, you get a lot of options, as well as fletching, firemaking, and some other skills too I believe.

    Nonetheless, nice work on these additions!
    Thanks! I've been trying to figure out what it's name is, but I've checked everywhere and there's nothing on the main site or wiki about it. Although I believe it's referred to as the "Crafting interface" since the right-click menu option to enter the interface is "Craft" (Like logs, gems, etc).

  5. #5
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Perhaps you might suggest these being added to SRL's crafting.simba branch; those poor skill files never receive any attention.

    Very good job, Runaway.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  6. #6
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Perhaps you might suggest these being added to SRL's crafting.simba branch; those poor skill files never receive any attention.

    Very good job, Runaway.
    Thanks!

    I was thinking crafting.simba at first, but I ended up with chat.simba because the crafting interface is used in 8 (I think?) different skills and utilizes the chat box globals. I was trying to find something for it in Misc but nothing in there worked Although, I've never organized an official include so I'm not the one to make the decision anyways. Whatever works for the SRL team works for me; I just think these functions are useful enough to be included somewhere

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •