Results 1 to 6 of 6

Thread: TPAs

  1. #1
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default TPAs

    This is my first time using tpas for object finding, and for some reason it isn't working for portal finding. Thing is, it doesn't even try to find the portal, it just quits.
    SCAR Code:
    program New;
    {.include SRL\SRL\Misc\Smart.scar}
    {.include srl/srl.scar}
    var
    x, y, i: integer;

    const
      LoadsToDo = 50;
      SmartWorld= 44;  //Smart World?
      SignedC= False;  //Use signed client?
      Team= 'blue';

    Procedure DeclarePlayers;
    begin
      HowManyPlayers:= 1;
      CurrentPlayer:= 0;
      NumberOfPlayers(HowManyPlayers);

      Players[0].Name:= '';
      Players[0].Pass:= '';
      Players[0].Nick:= '';
      Players[0].Active:= True;
    end;

    procedure FindNormalRandom;
    begin
      LampSkill := 'strength';
      if FindNormalRandoms then UseRewardBox;
      solvesrlrandoms:=true;
    end;

    procedure AntiBan;
    begin
      case random(80) of
      0: MouseBox(MSX1, MSY1, MSX2, MSY2,3);
      1: RandomMovement;
      2: RandomRClick;
      3: BoredHuman;
      4: PickUpMouse;
      5: SleepAndMoveMouse(50);
      6: HoverSkill('random', false);
      7: Exit;
      end;
    end;

    function OpenBankChest: boolean;
    var
    tpa : TPointArray;
    begin
      MakeCompass('S');
      SetAngle(True);
      Findcolorstolerance(TPA, 4676201, msx1, msy2, msx2, msy2, 10);
      if Length(tpa) = 0 then FindColorsTolerance(tpa, 8750479, MSX1, MSY1, MSX2, MSY2, 10);
      for i:= 0 to high(tpa) do
      begin
        MMouse(tpa[i].x, tpa[i].y,0,0);
        if IsUpTextMultiCustom(['ank','hest']) then
        begin
          Result := True;
          GetMousePos(x,y);
          Mouse(x, y, 0, 0, True);
          Exit;
        end;
      end;
    end;

    function EnterWaitingRoom: boolean;
    var
    tpa : TPointArray;
    begin
      case (Team) of
      'blue':
      begin
        Findcolorstolerance(TPA, 4935303, msx1, msy2, msx2, msy2, 50);
        if Length(tpa) = 0 then FindColorsTolerance(tpa, 14647666, MSX1, MSY1, MSX2, MSY2, 10);
        for i:= 0 to high(tpa) do
        begin
          MMouse(tpa[i].x, tpa[i].y,0,0);
          if IsUpTextMultiCustom(['lue','arrier']) then
          begin
            Result := True;
            GetMousePos(x,y);
            Mouse(x, y, 0, 0, True);
            Flag;
            if FindBlackChatMessage('non') then
            begin
              Writeln('You cannot take non-combat items to Soul Wars; Terminating.');
              LogOut;
              TerminateScript;
            end;
            if FindNPCChatText('rogress', nothing) then
            begin
              FindNPCChatText('ontinue', ClickLeft);
              Wait(500+random(500));
              FindNPCChatText('nter', ClickLeft);
            end;
            if FindNPCChatText('lmost', nothing) then
            begin
              FindNPCChatText('ontinue', ClickLeft);
              Wait(500+random(500));
              FindNPCChatText('aiting', ClickLeft);
            end;
            if FindNPCChatText('eft', nothing) then
            begin
              Writeln('We cannot continue because you have left your last game.');
              LogOut;
              TerminateScript;
            end;
            Exit;
          end;
        end;
      end;
      'red':
        begin
          Findcolorstolerance(TPA, 4739780, msx1, msy2, msx2, msy2, 10);
          if Length(tpa) = 0 then FindColorsTolerance(tpa, 14803711, MSX1, MSY1, MSX2, MSY2, 10);
          for i:= 0 to high(tpa) do
          begin
            MMouse(tpa[i].x, tpa[i].y,0,0);
            if IsUpTextMultiCustom(['ed','arrier']) then
            begin
              Result := True;
              GetMousePos(x,y);
              Mouse(x, y, 0, 0, True);
              Flag;
              if FindBlackChatMessage('non') then
              begin
                Writeln('You cannot take non-combat items to Soul Wars; Terminating.');
                LogOut;
                TerminateScript;
              end;
              if FindNPCChatText('rogress', nothing) then
              begin
                FindNPCChatText('ontinue', ClickLeft);
                Wait(500+random(500));
                FindNPCChatText('nter', ClickLeft);
              end;
              if FindNPCChatText('lmost', nothing) then
              begin
                FindNPCChatText('ontinue', ClickLeft);
                Wait(500+random(500));
                FindNPCChatText('aiting', ClickLeft);
              end;
              if FindNPCChatText('eft', nothing) then
              begin
                Writeln('We cannot continue because you have left your last game.');
                LogOut;
                TerminateScript;
              end;
              Exit;
            end;
          end;
        end;
      end;
    end;

    procedure WalkToChest;
    begin
      if FindSymbol(x, y, 'bank') then Mouse(x, y, 5, 5, True) else
      if FindSymbol(x, y, 'minigame') then
      begin
        MakeCompass('W');
        Fflag(random(10));
      end;
    end;

    function DetectedCape: boolean;
    begin
      if WearingItem(2) then
      begin
        TakeOff(2);
        Result := True;
      end;
    end;

    function SWRoadColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      R, G, B: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.53, 0.17);

      FindColorsSpiralTolerance(MMCX, MMCY, arP, 6122868, MMX1, MMY1, MMX2, MMY2, 5);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the road color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

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

      for i := 0 to arL do
      begin
        ColorToRGB(arC[i], R, G, B);

        if (R >= 102) and (R <= 131) and (G >= 96) and (G <= 123) and (B >= 81) and (B <= 104) then
        begin
          ColorToXYZ(arC[i], X, Y, Z);

          if (X >= 11.37) and (X <= 18.39) and (Y >= 12.02) and (Y <= 19.41) and (Z >= 9.68) and (Z <= 15.58) then
          begin
            Result := arC[i];
            Writeln('RoadColor = ' + IntToStr(arC[i]));
            Break;
          end;
        end;
      end;

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

      if (i = arL + 1) then
        Writeln('Failed in finding the color.');
    end;

    function FindLavaColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      R, G, B: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.59, 0.38);

      FindColorsSpiralTolerance(MMCX, MMCY, arP, 1749715, MMX1, MMY1, MMX2, MMY2, 3);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the lava color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

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

      for i := 0 to arL do
      begin
        ColorToRGB(arC[i], R, G, B);

        if (R >= 199) and (R <= 223) and (G >= 150) and (G <= 205) and (B >= 23) and (B <= 29) then
        begin
          ColorToXYZ(arC[i], X, Y, Z);

          if (X >= 35.04) and (X <= 50.73) and (Y >= 34.47) and (Y <= 58.19) and (Z >= 5.71) and (Z <= 9.61) then
          begin
            Result := arC[i];
            Writeln('Lava Color = ' + IntToStr(arC[i]));
            Break;
          end;
        end;
      end;

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

      if (i = arL + 1) then
        Writeln('Failed in finding the lava color.');
    end;

    function FindPortalColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      R, G, B: Integer;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);
      FindColorsSpiralTolerance(MMCX, MMCY, arP, 224, MMX1, MMY1, MMX2, MMY2, 15);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(1, 2);
        Exit;
      end;
      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);
      for i := 0 to arL do
      begin
        ColorToRGB(arC[i], R, G, B);
        if (R >= 200) and (R <= 254) and (G >= 0) and (G <= 0) and (B >= 0) and (B <= 0) then
        begin
          Result := arC[i];
          Writeln('Portal Color = ' + IntToStr(arC[i]));
          Break;
        end;
      end;
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      if (i = arL + 1) then
        Writeln('Portal Color Failed.');
    end;

    function ChestWalk: boolean;
    begin
      case (Team) of
      'red': begin RadialWalk(FindPortalColor, 180, 0, 65, -1, -1); MakeCompass('E'); FFlag(random(20)); Result:= True; end;

      'blue': begin RadialWalk(FindPortalColor, 150, 190, 65, -1, -1); MakeCompass('W'); FFlag(random(20)); Result:= True; end;
      end;
    end;

    procedure BankItems;
    begin
      WalkToChest;
      FFlag(random(10));
      Writeln('We have arrived at the banking chest.');
      if OpenBankChest then
      begin
        Writeln('We found the bank chest!');
        wait(5000+random(5000));
        if BankScreen then
        begin
          Writeln('I think we just found the banking screen.');
          DepositAll;
          CloseWindow;
          wait(1000+random(1000));
          MakeCompass('N');
         if (ChestWalk) then Writeln('We have clicked near the portal region.') else
         begin
            Writeln('We couldn''t walk back to the portal area, so we are terminating.');
            Wait(1000+random(500));
            LogOut;
            TerminateScript;
          end;
        end else
        begin
          Writeln('Something went Wrong! We couldn''t find the bankscreen!');
          TerminateScript;
        end;
      end else
      begin
        Writeln('We couldn''t open the bank chest.');
        TerminateScript;
      end;
    end;

    function InRoom: Boolean;
    var
    TPA: TPointArray;
    begin
      case (Team) of
      'blue':
            if not Findcolorstolerance(TPA, FindLavaColor, mmx1, mmy2, mmx2, mmy2, 10) then Result := True;
      'red':
            if not Findcolorstolerance(TPA, FindWaterColor, mmx1, mmy2, mmx2, mmy2, 10) then Result := True;
      end;
    end;

    procedure WalkInRoom;
    begin
      Writeln('We are walking inside the Waiting room');
      case (Team) of
      'red': RadialWalk(FindLavaColor, 270, 280, 65, -1, -1);
      'blue': RadialWalk(FindWaterColor, 270, 280, 65, -1, -1);
      end;
    end;

    begin
      Smart_Server:= (SmartWorld);
      Smart_Members:= True;
      Smart_Signed:= (SignedC);
      Smart_SuperDetail:= false;
      SetupSRL;
      ActivateClient;
      DeclarePlayers;
      LogInPlayer;
      Wait(10000+random(25000));
      SetRun(True);
      repeat
        if (DetectedCape) then BankItems else
        begin
          SetAngle(False);
          case (Team) of
          'red': MakeCompass('W');
          'blue': MakeCompass('E');
          end;
          if (ChestWalk) then Writeln('We have arrived near the WaitingRoom barrier');
        end;
        if (InRoom) then
        begin
          Writeln('We are entering the '+ (Team) +' team.');
          if (EnterWaitingRoom) then WalkInRoom;
        end;
      until (True);
    end.

  2. #2
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I think you have to declare i as the highest index, or change mmouse to normal x/y coords.

    Edit: For your chest walk function, you could also do Function ChestWalk(Team: string): boolean;
    Then use it like if ChestWalk('blue') then blah. Or whatever
    Last edited by Smarter Child; 08-13-2009 at 07:11 AM.

  3. #3
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Unfortunately, even though i changed Mmouse to normal x,y Coords, It still never tried and returned "Could not find the barrier" It happened with F.C's script too, when i tried it a few weeks ago.

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Sooo..exactly what function is giving you problems then?

    Try to be more specific when you ask for help.

  5. #5
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    It was a simple mistake. I've been making many of those lately.

  6. #6
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    No worries, it happens to the best of us

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
  •