Results 1 to 5 of 5

Thread: FindAndAttachPickHead.

  1. #1
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default FindAndAttachPickHead.

    SCAR Code:
    Function FindnAttHead(ThePick: String; Weilded: Boolean): Boolean;
    Var
      head: Tpoint;
      TPA: TPointArray;
      Optionz: TVariantArray;
      ATPA: Array of TPointArray;
      CTS, I, CurrTab, x, y, heady, stick, pick: Integer;
    begin                            //8286806 //7826257
      heady := DTMFromString('78DA637465626078C280022CBD4318FE03694' +
           '620FE0F048C164035CF19D000231209A4BD816A6E1150E349A439' +
           '0F09A87125AC060093D70CE0');
      Stick := DTMFromString('78DA63B465626078CA8002F415D818FE03694' +
           '620FE0F048CF64035F718D000231209A46D806ADE1050630154F3' +
           '89801A67A09A9B04D4B800D5DCC2AF060022960C39');
      Pick := DTMFromString('78DA63B461626078C1800274E55919FE03694' +
           '620FE0F048C264035B719D000231209A403806A1E125003B2EB06' +
           '0135DE40357708A8B104AAF9845F0D00183E0C34');
      CurrTab := GetCurrentTab;
      case Lowercase(ThePick) of
        'steel': Optionz := ([ 0.25, 0.05, 5855840, 9 ]);
        'bronze': Optionz := ([ 0.05, 0.01, 2110788, 9 ]);
        'iron': Optionz := ([ 0.12, 0.04, 5263445, 17 ]);
        'mith': Optionz := ([ 0.10, 0.02, 5979710, 11 ]);
        'rune': Optionz := ([ 0.00, 0.05, 8812891, 13 ]);
        'addy': Optionz := ([ 0.10, 0.03, 5136717, 9 ]);
      end;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Optionz[0], Optionz[1]);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, Optionz[2] , MSX1, MSY1, MSX2, MSY2, Optionz[3]);
      ColorToleranceSpeed(CTS);
      ATPA := TPAToATPAEx(TPA, 2, 2);
      For I := 0 to High(ATPA) do
      begin
        MiddleTPAEx(ATPA[i], head.x, head.y);
        MMouse(head.x, head.y, 2, 2);
        wait(100+random(100));
        If(IsUpTextMultiCustom(['ake', 'ick', 'ead'])) then
        begin
          GetMousePos(head.x, head.y);
          Mouse(head.x, head.y, 0, 0, true);
          flag;
          wait(200+random(200));
          if Weilded then
          begin
            gametab(5);
            wait(100);
            mmouse(585, 303, 10, 10);
            wait(100);
            if isuptext('ick') then
            begin
              getmousepos(x, y);
              mouse(x, y, 0, 0, true);
              gametab(4);
            end;
          end;
          gametab(4);
          if findDTm(Heady, x, y, MIX1, MIY1, MIX2, MIY2)then
          begin
            mouse(x, y, 4, 4, true);
            wait(100);
            if findDTm(stick, x, y, MIX1, MIY1, MIX2, MIY2)then
            begin
              mouse(x, y, 2 ,2, true);
              wait(200);
              if findDTm(pick, x, y, MIX1, MIY1, MIX2, MIY2)then
              begin
                result := true;
                FreeDTM(pick);
                FreeDTM(heady);
                FreeDTM(stick);
                exit;
              end;
            end else
            begin
              writeln('Couldn''t find stick');
              FreeDTM(pick);
              FreeDTM(heady);
              FreeDTM(stick);
              exit;
            end;
          end else
          begin
            writeln('Couldtn''t find head of pick');
            FreeDTM(pick);
            FreeDTM(heady);
            FreeDTM(stick);
            exit;
          end;
        end;
      end;
      Writeln('Couldn''t attatch head of pick and stick together!');
      FreeDTM(pick);
      FreeDTM(heady);
      FreeDTM(stick);
    end;
    It works FLAWLESSLY for me. Try it?, rate hate?
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  2. #2
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    You should definitely use a try/finally block in your for loop so you can exit out and still free all of your DTMs. And maybe a little more randomization please?

    Edit: Here's what I mean about the try/finally block:
    SCAR Code:
    begin
      For I := 0 to High(ATPA) do
      try
        ...
          if findDTm(Heady, x, y, MIX1, MIY1, MIX2, MIY2)then
          begin
            mouse(x, y, 4, 4, true);
            wait(100);
            if findDTm(stick, x, y, MIX1, MIY1, MIX2, MIY2)then
            begin
              mouse(x, y, 2 ,2, true);
              wait(200);
              if findDTm(pick, x, y, MIX1, MIY1, MIX2, MIY2)then
                result := true;
            end;
          end;
        end;
      finally
        FreeDTM(pick);
        FreeDTM(heady);
        FreeDTM(stick);
      end;
      Writeln('Couldn''t attatch head of pick and stick together!');
    end;
    Or whatever variation of that you'd like.

  3. #3
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No need to do this:
    SCAR Code:
    FreeDTM(pick);
            FreeDTM(heady);
            FreeDTM(stick);
    In every end else, just free them at the end.


  4. #4
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by Cazax View Post
    No need to do this:
    SCAR Code:
    FreeDTM(pick);
            FreeDTM(heady);
            FreeDTM(stick);
    In every end else, just free them at the end.
    I use exit; though
    I just took this out of one of my scripts and made it universal.
    Here is the original:
    SCAR Code:
    Function FindHead(var head: Tpoint): Boolean;
    Var
      CTS, I: Integer;
      TPA: TPointArray;
      ATPA: Array of TPointArray;
      Optionz: TVariantArray;
    begin                            //8286806 //7826257
      case Lowercase(ThePick) of
        'steel': Optionz := ([ 0.25, 0.05, 5855840, 9 ]);
        'bronz': Optionz := ([ 0.05, 0.01, 2110788, 9 ]);
        'iron': Optionz := ([ 0.12, 0.04, 5263445, 17 ]);
        'mith': Optionz := ([ 0.10, 0.02, 5979710, 11 ]);
        'rune': Optionz := ([ 0.00, 0.05, 8812891, 13 ]);
        'addy': Optionz := ([ 0.10, 0.03, 5136717, 9 ]);
      end;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Optionz[0], Optionz[1]);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, Optionz[2] , MSX1, MSY1, MSX2, MSY2, Optionz[3]);
      ColorToleranceSpeed(CTS);
      ATPA := TPAToATPAEx(TPA, 2, 2);
      For I := 0 to High(ATPA) do
      begin
        MiddleTPAEx(ATPA[i], head.x, head.y);
        MMouse(head.x, head.y, 2, 2);
        wait(100+random(100));
        If(IsUpTextMultiCustom(['ake', 'ick', 'ead'])) then
        begin
          Result := True;
          GetMousePos(head.x, head.y);
          Break;
        end;
      end;
    end;
    and the stuff in a procedure I used to pick it up;
    SCAR Code:
    if FindHead(head1)then
          begin
            mouse(head1.x, head1.y, 0, 0, false);
            Chooseoption('ake');
            SafeFlag;
            wait(500+random(300));
            if FindDTM(Head, x, y, mix1, miy1, mix2, miy2)then
            begin
              mouse(x, y, 3, 3, true);
              if FindDTM(Stick, x, y, MIX1, MIY1, MIX2, MIY2)then
              begin
                mouse(x, y, 3, 3, true);
                inc(headsrepaired);
                If Players[CurrentPlayer].Booleans[0] then
                  if FindDTM(Pick, x,y, MIX1, MIY1,MIX2, MIY2)then
                    mouse(x, y, 4, 4, true);
                exit;
              end else
              begin
                FindDTM(Head, x, y, MIX1, MIY1, MIX2, MIY2)
                mouse(x, y, 3, 3, true);
              end;
            end else
            begin
              ndbug('Didnt find pick head');
              goto This;
            end;
          end else
          begin
            ndbug('Error: Didn''t find pick head on ground!');
            Goto This;
          end;
        end else Goto This;
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  5. #5
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    SCAR Code:
    begin
      try wait(1);
      code
      code
      code
      code
      exit
      finally
        FreeDTM(wahtever)
      end;
    end;
    even if you exit it'll still free them

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

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
  •