Results 1 to 6 of 6

Thread: Multiple instances of ACA as well as the usage of TPAS

  1. #1
    Join Date
    Jun 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Multiple instances of ACA as well as the usage of TPAS

    Alright, i'm not sure how many of you read my last thread on other issues, but this all revolves around a script for the troll invasion minigame.

    I've got it to the point where I use atpas to locate and start the minigame as well as target the monsters, as well as target the table (The script is actually quite functional),but here is my actual question. Being new to this language and what not, I ended up making a separate function for each color (the aca) and separate functions for using tpas (which they obviously all have to do different stuff) BUT should I be/is it possible to combine these things to have less redundant script? OR is it acceptable to do them separately (In tutorials, they always name the ACA function to the color they are doing for each one, but im not sure if this a dumbed down way of showing it, or if it is the standard)

    As in, can i combine all the different colors i want into one ACA function, and is it possible to do that same thing with tpas?


    Bonus question:
    I have a bit of experience in VB,autoit,and DM (Its a game making language), but idk, certain pieces of the syntax don't feel like they flow well for me. My question is, how would i make it if say, I search for a guy using the spiral technique (its used in most scripts i've used as learning material), how do i say, if after a certain amount of time he cant be found switch to another method of finding him? I tried just throwing an else in there like most languages, but it doesn't seem to work that way

  2. #2
    Join Date
    May 2012
    Location
    Texas
    Posts
    365
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes, you can split them up here is an example
    http://villavu.com/forum/showthread....highlight=Iron
    Pretty sure this script uses a generic function to find object which you can pass info like Tolerance/Color/Hmod/Smod through to find various objects
    Mostly Inactive, School

  3. #3
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Quote Originally Posted by Shanked View Post

    As in, can i combine all the different colors i want into one ACA function, and is it possible to do that same thing with tpas?
    Here's a function that Runaway made. It loads details such as colour and tolerance depending on which item/object you want to look for:
    Simba Code:
    function FindObject(Which: String): Boolean;
    var                              
      TPA1, TPA2, RTPA: TPointArray;
      Color, Tol: TIntegerArray;  
      Dist, nCTS, cts, i: Integer;
      ATPA: T2DPointArray;
      Option, Uptext: String;
    begin
      case Lowercase(Which) of
        'rock':
        begin
          nCTS := 3;
          Color := [3162221, 3764098];
          Tol := [5, 5];
          Dist := 10;
          Uptext := 'ron ore';
          Option := 'ine';
        end;
        'dooratbank':
        begin
          nCTS := 3;
          Color := [9541015, 13160145];
          Tol := [10, 10];
          Dist := 10;
          Uptext := 'yster';
          Option := 'xit';
        end;
        'dooratmine':
        begin
          nCTS := 3;
          Color := [2109405, 6383205];
          Tol := [10, 5];
          Dist := 10;
          Uptext := 'yster';
          Option := 'nter';
        end;
        'dbox':
        begin
          nCTS := 3;
          Color := [6521749, 6647669];
          Tol := [3, 3];
          Dist := 20;
          Uptext := 'box';
          Option := 't B';
        end;
      end;
      Result := False;
      cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(nCTS);
      FindColorsTolerance(TPA1, Color[0], MSX1, MSY1, MSX2, MSY2, Tol[0]);
      RAaSTPAEx(TPA1,3,3);
      FindColorsTolerance(TPA2, Color[1], MSX1, MSY1, MSX2, MSY2, Tol[1]);
      RAaSTPAEx(TPA2,3,3);

      RTPA := AND_TPA(TPA1,TPA2,0,Dist);

      if Length(RTPA) = 0 then
      begin
        writeln('Didn''t find '+Which+' colors.');
        ColorToleranceSpeed(cts);
        Inc(F); //F for Failure
        if F >= 10 then
        begin
          Writeln('We failed too many times, logging out and back in to change the colors.');
          Disguise('Reset in progess');
          ExitToLobby;
          Wait(15000 + Random(5000));
          F := 0;
          LoginPlayer;
        end;
        Exit;
      end;
      ColorToleranceSpeed(cts);
      ATPA := SplitTPAEx(RTPA, 15, 15);

      if (Length(ATPA) > 0) then
      begin
    //  SortATPASize(ATPA, true); /
        SortATPAFrom(ATPA, Point(MSCX, MSCY));
      end else
        Exit;
      SMART_ClearCanvas;
      Proggy;
      for i:= 0 to high(ATPA) do
      begin
        Antirandoms;
        SMART_DebugTPA(False, ATPA[i]);
        MMouse(MiddleTPA(ATPA[i]).x, MiddleTPA(ATPA[i]).y, 5, 5);
        if (WaitUptext(Uptext, 300 + Random(100))) then
        begin
          ClickMouse2(mouse_right);
          if WaitOption(Option, 600) then
          begin
            Result := True;
            Exit;
          end;
        end;
      end;
    end;


    As for you bonus question.
    Simba Code:
    Procedure HowManyTimes;
    var
      Attempts: Integer;
    begin
      repeat
        Inc(Attempts); // Increases Attempts by 1
        FindGuy;
      until (Attempts = 7) // repeat until you've tried 7 times
    end;

  4. #4
    Join Date
    Jun 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    so when implementing something like with the example made by Runaway, I wouldn't even need to use ACA to function my colors anymore? Just find a few unique colors and plug it in to an extent? So basically I would use ACA to find out all the color numbers to paint my target, but instead of writing the function with it just use those numbers right?

  5. #5
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Yes you can do this, you could make the colours and uptext parameters in the function so each time you call it you can use different ones (depending on what you are trying to find)

    The Function would then look something like this:
    Simba Code:
    function FindObject(var fx, fy: Integer; Uptexts : array of String; Colour, Tolerance : integer; Hue, Sat : extended): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Hue, Sat);

      if not(FindColorsTolerance(arP, Colour, MSX1, MSY1, MSX2, MSY2, Tolerance)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 95.03) and (X <= 95.07) and (Y >= 99.98) and (Y <= 100.02) and (Z >= 108.86) and (Z <= 108.90) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;

      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);

      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (WaitUpTextMulti(Uptexts, 20+Random(300))) then
        begin;
          Result := True;
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;

      GetMousePos(fx, fy);
    end;

    However it would be even better if you wrote your own universal object finding function

  6. #6
    Join Date
    Jun 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This is also very true, thanks to all three of you for the very constructive feedback. Do keep in mind though, this is going to be my very first script for this language and I definitely didn't tackle something too easy :P

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
  •