Results 1 to 6 of 6

Thread: ddtm

  1. #1
    Join Date
    Dec 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default ddtm

    gave up on radial walking because ddtm walking was better .

    but that didn't work out for me aswell...

    here's the script
    Simba Code:
    Program New;
    {$i SRL/SRL.simba}

    var
    Inventory:TBoxArray;

    function ExplodeBox(bx: TBox; rows, columns: integer): TBoxArray;
    var
      r, c, w, h, ew, eh, ow, oh, i, x, y: integer;
    begin
      if ((rows > 0) and (columns > 0) and (bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2)) then
      begin
        w := ((bx.X2 - bx.X1) + 1);
        h := ((bx.Y2 - bx.Y1) + 1);
        if (rows < 1) then
          rows := 1
        else
          if (rows > h) then
            rows := h;
        if (columns < 1) then
          columns := 1
        else
          if (columns > w) then
            columns := w;
        w := (w div columns);
        h := (h div rows);
        ew := (((bx.X2 - bx.X1) + 1) - (w * columns));
        eh := (((bx.Y2 - bx.Y1) + 1) - (h * rows));
        SetLength(Result, (rows * columns));
        y := bx.Y1;
        for r := 0 to (rows - 1) do
        begin
          x := bx.X1;
          if ((eh > 0) and (r < eh)) then
            oh := 1
          else
            oh := 0;
          for c := 0 to (columns - 1) do
          begin
            if ((ew > 0) and (c < ew)) then
              ow := 1
            else
              ow := 0;
            i := ((r * columns) + c);
            Result[i].X1 := x;
            Result[i].X2 := (x + (w - 1) + ow);
            Result[i].Y1 := y;
            Result[i].Y2 := (y + (h - 1) + oh);
            x := (Result[i].X2 + 1);
          end;
          y := (Result[i].Y2 + 1);
        end;
      end else
        SetLength(Result, 0);
    end;

    procedure RSPS_SetInventory;
    begin
    Inventory := ExplodeBox(IntToBox(549, 206, 733, 465), 7, 4);
     end;

     function rsps_slotFull(slot:Integer):Boolean;
    var
      x, y:Integer;
    begin
      if FindColor(x, y, 65536, Inventory[slot].x1, Inventory[slot].y1, Inventory[slot].x2, Inventory[slot].y2) then
        result := true;
    end;

    function rsps_Invcount:Integer;
    var
      i:Integer;
    begin
     for i := 0 to high(Inventory) do
      begin
        if rsps_slotFull(i) then
          result := result + 1;
      end;
    end;

    function RSPS_InvFull:Boolean;
    begin
      result := (rsps_invcount = 28);
    end;

    Function RSPS_GetUpText: String;
    Var
      WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
    Begin
      WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPS');
      BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPS');
      YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPS');
      OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPS');
      FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
      FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
      Result:=FoundText;
    End;

    function LoadAllDTMWalks(WalkNumber: Integer): Integer;
    var
      dtmMainPoint: TDTMPointDef;
      dtmSubPoints: array[0..3] of TDTMPointDef;
      TempTDTM: TDTM;
    begin
      case WalkNumber of
        1: begin
         dtmMainPoint.x := 863;
      dtmMainPoint.y := 206;
      dtmMainPoint.AreaSize := 0;
      dtmMainPoint.AreaShape := 0;
      dtmMainPoint.Color := 6712945;
      dtmMainPoint.Tolerance := 0;

      dtmSubPoints[0].x := 863;
      dtmSubPoints[0].y := 206;
      dtmSubPoints[0].AreaSize := 0;
      dtmSubPoints[0].AreaShape := 0;
      dtmSubPoints[0].Color := 6712945;
      dtmSubPoints[0].Tolerance := 0;

      dtmSubPoints[1].x := 882;
      dtmSubPoints[1].y := 195;
      dtmSubPoints[1].AreaSize := 0;
      dtmSubPoints[1].AreaShape := 0;
      dtmSubPoints[1].Color := 7513283;
      dtmSubPoints[1].Tolerance := 0;

      dtmSubPoints[2].x := 858;
      dtmSubPoints[2].y := 184;
      dtmSubPoints[2].AreaSize := 0;
      dtmSubPoints[2].AreaShape := 0;
      dtmSubPoints[2].Color := 8001204;
      dtmSubPoints[2].Tolerance := 0;

      dtmSubPoints[3].x := 844;
      dtmSubPoints[3].y := 194;
      dtmSubPoints[3].AreaSize := 0;
      dtmSubPoints[3].AreaShape := 0;
      dtmSubPoints[3].Color := 4408393;
      dtmSubPoints[3].Tolerance := 0;

      TempTDTM.MainPoint := dtmMainPoint;
      TempTDTM.SubPoints := dtmSubPoints;
      Result := AddDTM(TempTDTM);
    end;
    end;
    end;

    function WalkToPlace: Boolean;
    var
      WalkDTM: integer; // Calls the WalkDTM making walking simpler.
    begin
      WalkDTM := LoadAllDTMWalks(1); //Load which DDTM you want to find.
      if FindDTM(WalkDTM, X, Y, MMx1,MMy1,MMx2,MMy2) then // Find the DDTM using Find DTM
      begin
        Mouse(X, Y, 3, 3, True);
        WriteLn('Walk Main 1. - Complete.');
        FFlag(0);
        Result := True; // If succesfully finds it will click it and wait to flag is gone.
      end else // else it will do this...
        if RadialWalk(FindFallyRoadColor, 300, 220, 55, 1, 1) then
        begin
          Writeln(' Walk Backup 1. - Complete.');
          Result := True; //Will look for this if DDTM fails, if this fails then logsout, but you can change that.
        end else
        begin
          Result := False;// cant find the backup goes here...
          Writeln(' Walk Backup 1. - Failed. Logging Out.');
          FreeDTM(WalkDTM); // FREEs the DDTM so you dont have a memory overload :P
          if not (Result) then //if doesnt get results does this
          begin
            Logout; // logs out.
          end;
        end;
    end;

    procedure Walk;
    begin
      if RSPS_invFull; then
      WalkToPlace;
    end;




    function MyRoadColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);

      if not (FindColorsTolerance(arP, 6515310, MMX1, MMY1, MMX2, MMY2, 0)) then
      begin
        //Writeln('Failed to find the 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
        Result := arC[i];
        //Writeln('AutoColor = ' + IntToStr(arC[i]));
        Break;
      end;

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

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

    function StallColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.05, 0.09);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 10728640, MSX1, MSY1, MSX2, MSY2, 16);
      if (Length(arP) = 0) then
      begin
        //Writeln('Failed to find the 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
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 27.16) and (X <= 67.46) and (Y >= 27.98) and (Y <= 70.66) and (Z >= 20.78) and (Z <= 71.06) then
        begin
          Result := arC[i];
          //Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

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

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

    function FindObjTPA2(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: string): Boolean;
    var
      I, tCTS: Integer;
      myPoint: TPoint;
      Points: TPointArray;
      aPoints: T2DPointArray;
    begin
      Result := False;

      tCTS := GetColorToleranceSpeed;
      CTS := Integer(CTS * 9 mod 3 <> 0);
      ColorToleranceSpeed(CTS);
      FindColorsSpiralTolerance(X, Y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
      if Length(Points) = 0 then
      begin
        //writeln('findObjTPA(): Found no colors.... exiting');
        ColorToleranceSpeed(tCTS);
        Exit;
      end;
      ColorToleranceSpeed(1);
      aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
      SetLength(Points, 0);
      for I := 0 to High(aPoints) do
      begin
        if Length(aPoints[i]) < minCount then
          Continue;
        myPoint := MiddleTPA(aPoints[i]);
        MMouse(myPoint.X, myPoint.Y, 0, 0);
        wait(100 + random(50));

        if (pos(upText, RSPS_GetUptext) > 0) then
        begin
          //writeln('findObjTPA(): We found the object!');
          GetMousePos(X, Y);
          Result := True;
          ColorToleranceSpeed(tCTS);
          Exit;
        end else
          //writeln('findObjTPA(): Did not find the uptext... :<');
      end;
      ColorToleranceSpeed(tCTS);
    end;


    procedure Steal;
    var
      X, Y: Integer;
    begin
      repeat
      if FindObjTPA2(X, Y, StallColor, 5, 1, 41, 21, 23, 'em') then
        clickMouse2(MOUSE_LEFT);
      until(RSPS_InvFull);
    end;

    procedure Walk;
    begin
    if RSPS_InvFull then
    RadialWalk(MyRoadColor, 325, 300, 31, 1, 0);
    end;


    begin
      RSPS_SetInventory;
      Writeln(RSPS_GetUpText);
      MouseSpeed := 12;
      Steal();
      Writeln('Inventory count: ' + ToStr(rsps_Invcount));
      if (rsps_invFull) then
        Writeln('Inventory Full!');
      walk;
    end.





    and this is my error

    problem 1.jpg
    problem 2.jpg


    idk why i always keep getting errors. i have still much to learn i guess?

  2. #2
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    declare x and y in your local variables.

    var
    x, y: Integer;

    for DDTM's :
    Mainpoint size 1 and tolerance 255
    Subpoints size 3-4 and tolerance 30-40

    Pick like 3-5 subpoints

    experiment till u get a good one

    Creds to DannyRS for this wonderful sig!

  3. #3
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    Quote Originally Posted by hete taart View Post
    gave up on radial walking because ddtm walking was better .

    but that didn't work out for me aswell...

    here's the script



    you don't have x or y declared as a variable inside that function.


    Simba Code:
    Program New;
    {$i SRL/SRL.simba}

    var
    Inventory:TBoxArray;

    function ExplodeBox(bx: TBox; rows, columns: integer): TBoxArray;
    var
      r, c, w, h, ew, eh, ow, oh, i, x, y: integer;
    begin
      if ((rows > 0) and (columns > 0) and (bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2)) then
      begin
        w := ((bx.X2 - bx.X1) + 1);
        h := ((bx.Y2 - bx.Y1) + 1);
        if (rows < 1) then
          rows := 1
        else
          if (rows > h) then
            rows := h;
        if (columns < 1) then
          columns := 1
        else
          if (columns > w) then
            columns := w;
        w := (w div columns);
        h := (h div rows);
        ew := (((bx.X2 - bx.X1) + 1) - (w * columns));
        eh := (((bx.Y2 - bx.Y1) + 1) - (h * rows));
        SetLength(Result, (rows * columns));
        y := bx.Y1;
        for r := 0 to (rows - 1) do
        begin
          x := bx.X1;
          if ((eh > 0) and (r < eh)) then
            oh := 1
          else
            oh := 0;
          for c := 0 to (columns - 1) do
          begin
            if ((ew > 0) and (c < ew)) then
              ow := 1
            else
              ow := 0;
            i := ((r * columns) + c);
            Result[i].X1 := x;
            Result[i].X2 := (x + (w - 1) + ow);
            Result[i].Y1 := y;
            Result[i].Y2 := (y + (h - 1) + oh);
            x := (Result[i].X2 + 1);
          end;
          y := (Result[i].Y2 + 1);
        end;
      end else
        SetLength(Result, 0);
    end;

    procedure RSPS_SetInventory;
    begin
    Inventory := ExplodeBox(IntToBox(549, 206, 733, 465), 7, 4);
     end;

     function rsps_slotFull(slot:Integer):Boolean;
    var
      x, y:Integer;
    begin
      if FindColor(x, y, 65536, Inventory[slot].x1, Inventory[slot].y1, Inventory[slot].x2, Inventory[slot].y2) then
        result := true;
    end;

    function rsps_Invcount:Integer;
    var
      i:Integer;
    begin
     for i := 0 to high(Inventory) do
      begin
        if rsps_slotFull(i) then
          result := result + 1;
      end;
    end;

    function RSPS_InvFull:Boolean;
    begin
      result := (rsps_invcount = 28);
    end;

    Function RSPS_GetUpText: String;
    Var
      WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
    Begin
      WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPS');
      BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPS');
      YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPS');
      OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPS');
      FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
      FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
      Result:=FoundText;
    End;

    function LoadAllDTMWalks(WalkNumber: Integer): Integer;
    var
      dtmMainPoint: TDTMPointDef;
      dtmSubPoints: array[0..3] of TDTMPointDef;
      TempTDTM: TDTM;
    begin
      case WalkNumber of
        1: begin
         dtmMainPoint.x := 863;
      dtmMainPoint.y := 206;
      dtmMainPoint.AreaSize := 0;
      dtmMainPoint.AreaShape := 0;
      dtmMainPoint.Color := 6712945;
      dtmMainPoint.Tolerance := 0;

      dtmSubPoints[0].x := 863;
      dtmSubPoints[0].y := 206;
      dtmSubPoints[0].AreaSize := 0;
      dtmSubPoints[0].AreaShape := 0;
      dtmSubPoints[0].Color := 6712945;
      dtmSubPoints[0].Tolerance := 0;

      dtmSubPoints[1].x := 882;
      dtmSubPoints[1].y := 195;
      dtmSubPoints[1].AreaSize := 0;
      dtmSubPoints[1].AreaShape := 0;
      dtmSubPoints[1].Color := 7513283;
      dtmSubPoints[1].Tolerance := 0;

      dtmSubPoints[2].x := 858;
      dtmSubPoints[2].y := 184;
      dtmSubPoints[2].AreaSize := 0;
      dtmSubPoints[2].AreaShape := 0;
      dtmSubPoints[2].Color := 8001204;
      dtmSubPoints[2].Tolerance := 0;

      dtmSubPoints[3].x := 844;
      dtmSubPoints[3].y := 194;
      dtmSubPoints[3].AreaSize := 0;
      dtmSubPoints[3].AreaShape := 0;
      dtmSubPoints[3].Color := 4408393;
      dtmSubPoints[3].Tolerance := 0;

      TempTDTM.MainPoint := dtmMainPoint;
      TempTDTM.SubPoints := dtmSubPoints;
      Result := AddDTM(TempTDTM);
    end;
    end;
    end;

    function WalkToPlace: Boolean;
    var
      WalkDTM: integer; // Calls the WalkDTM making walking simpler.
    x,y:integer;//************added this***********
    begin
      WalkDTM := LoadAllDTMWalks(1); //Load which DDTM you want to find.
      if FindDTM(WalkDTM, X, Y, MMx1,MMy1,MMx2,MMy2) then // Find the DDTM using Find DTM
      begin
        Mouse(X, Y, 3, 3, True);
        WriteLn('Walk Main 1. - Complete.');
        FFlag(0);
        Result := True; // If succesfully finds it will click it and wait to flag is gone.
      end else // else it will do this...
        if RadialWalk(FindFallyRoadColor, 300, 220, 55, 1, 1) then  //********you might need to change this to myroadcolor***************
        begin
          Writeln(' Walk Backup 1. - Complete.');
          Result := True; //Will look for this if DDTM fails, if this fails then logsout, but you can change that.
        end else
        begin
          Result := False;// cant find the backup goes here...
          Writeln(' Walk Backup 1. - Failed. Logging Out.');
          FreeDTM(WalkDTM); // FREEs the DDTM so you dont have a memory overload :P
          if not (Result) then //if doesnt get results does this
          begin
            Logout; // logs out.
          end;
        end;
    end;

    procedure Walk;
    begin
      if RSPS_invFull; then
      WalkToPlace;
    end;




    function MyRoadColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);

      if not (FindColorsTolerance(arP, 6515310, MMX1, MMY1, MMX2, MMY2, 0)) then
      begin
        //Writeln('Failed to find the 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
        Result := arC[i];
        //Writeln('AutoColor = ' + IntToStr(arC[i]));
        Break;
      end;

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

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

    function StallColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.05, 0.09);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 10728640, MSX1, MSY1, MSX2, MSY2, 16);
      if (Length(arP) = 0) then
      begin
        //Writeln('Failed to find the 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
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 27.16) and (X <= 67.46) and (Y >= 27.98) and (Y <= 70.66) and (Z >= 20.78) and (Z <= 71.06) then
        begin
          Result := arC[i];
          //Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

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

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

    function FindObjTPA2(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: string): Boolean;
    var
      I, tCTS: Integer;
      myPoint: TPoint;
      Points: TPointArray;
      aPoints: T2DPointArray;
    begin
      Result := False;

      tCTS := GetColorToleranceSpeed;
      CTS := Integer(CTS * 9 mod 3 <> 0);
      ColorToleranceSpeed(CTS);
      FindColorsSpiralTolerance(X, Y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
      if Length(Points) = 0 then
      begin
        //writeln('findObjTPA(): Found no colors.... exiting');
        ColorToleranceSpeed(tCTS);
        Exit;
      end;
      ColorToleranceSpeed(1);
      aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
      SetLength(Points, 0);
      for I := 0 to High(aPoints) do
      begin
        if Length(aPoints[i]) < minCount then
          Continue;
        myPoint := MiddleTPA(aPoints[i]);
        MMouse(myPoint.X, myPoint.Y, 0, 0);
        wait(100 + random(50));

        if (pos(upText, RSPS_GetUptext) > 0) then
        begin
          //writeln('findObjTPA(): We found the object!');
          GetMousePos(X, Y);
          Result := True;
          ColorToleranceSpeed(tCTS);
          Exit;
        end else
          //writeln('findObjTPA(): Did not find the uptext... :<');
      end;
      ColorToleranceSpeed(tCTS);
    end;


    procedure Steal;
    var
      X, Y: Integer;
    begin
      repeat
      if FindObjTPA2(X, Y, StallColor, 5, 1, 41, 21, 23, 'em') then
        clickMouse2(MOUSE_LEFT);
      until(RSPS_InvFull);
    end;

    procedure Walk;
    begin
    if RSPS_InvFull then
    RadialWalk(MyRoadColor, 325, 300, 31, 1, 0);
    end;


    begin
      RSPS_SetInventory;
      Writeln(RSPS_GetUpText);
      MouseSpeed := 12;
      Steal();
      Writeln('Inventory count: ' + ToStr(rsps_Invcount));
      if (rsps_invFull) then
        Writeln('Inventory Full!');
      walk;
    end.

  4. #4
    Join Date
    Dec 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    ok ty alot so i changed that but now i got the following error

    script:

    Simba Code:
    Program New;
    {$i SRL/SRL.simba}

    var
    Inventory:TBoxArray;

    function ExplodeBox(bx: TBox; rows, columns: integer): TBoxArray;
    var
      r, c, w, h, ew, eh, ow, oh, i, x, y: integer;
    begin
      if ((rows > 0) and (columns > 0) and (bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2)) then
      begin
        w := ((bx.X2 - bx.X1) + 1);
        h := ((bx.Y2 - bx.Y1) + 1);
        if (rows < 1) then
          rows := 1
        else
          if (rows > h) then
            rows := h;
        if (columns < 1) then
          columns := 1
        else
          if (columns > w) then
            columns := w;
        w := (w div columns);
        h := (h div rows);
        ew := (((bx.X2 - bx.X1) + 1) - (w * columns));
        eh := (((bx.Y2 - bx.Y1) + 1) - (h * rows));
        SetLength(Result, (rows * columns));
        y := bx.Y1;
        for r := 0 to (rows - 1) do
        begin
          x := bx.X1;
          if ((eh > 0) and (r < eh)) then
            oh := 1
          else
            oh := 0;
          for c := 0 to (columns - 1) do
          begin
            if ((ew > 0) and (c < ew)) then
              ow := 1
            else
              ow := 0;
            i := ((r * columns) + c);
            Result[i].X1 := x;
            Result[i].X2 := (x + (w - 1) + ow);
            Result[i].Y1 := y;
            Result[i].Y2 := (y + (h - 1) + oh);
            x := (Result[i].X2 + 1);
          end;
          y := (Result[i].Y2 + 1);
        end;
      end else
        SetLength(Result, 0);
    end;

    procedure RSPS_SetInventory;
    begin
    Inventory := ExplodeBox(IntToBox(549, 206, 733, 465), 7, 4);
     end;

     function rsps_slotFull(slot:Integer):Boolean;
    var
      x, y:Integer;
    begin
      if FindColor(x, y, 65536, Inventory[slot].x1, Inventory[slot].y1, Inventory[slot].x2, Inventory[slot].y2) then
        result := true;
    end;

    function rsps_Invcount:Integer;
    var
      i:Integer;
    begin
     for i := 0 to high(Inventory) do
      begin
        if rsps_slotFull(i) then
          result := result + 1;
      end;
    end;

    function RSPS_InvFull:Boolean;
    begin
      result := (rsps_invcount = 28);
    end;

    Function RSPS_GetUpText: String;
    Var
      WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
    Begin
      WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPS');
      BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPS');
      YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPS');
      OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPS');
      FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
      FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
      Result:=FoundText;
    End;

    function LoadAllDTMWalks(WalkNumber: Integer): Integer;
    var
      dtmMainPoint: TDTMPointDef;
      dtmSubPoints: array[0..3] of TDTMPointDef;
      TempTDTM: TDTM;
    begin
      case WalkNumber of
        1: begin
         dtmMainPoint.x := 863;
      dtmMainPoint.y := 206;
      dtmMainPoint.AreaSize := 0;
      dtmMainPoint.AreaShape := 0;
      dtmMainPoint.Color := 6712945;
      dtmMainPoint.Tolerance := 0;

      dtmSubPoints[0].x := 863;
      dtmSubPoints[0].y := 206;
      dtmSubPoints[0].AreaSize := 0;
      dtmSubPoints[0].AreaShape := 0;
      dtmSubPoints[0].Color := 6712945;
      dtmSubPoints[0].Tolerance := 0;

      dtmSubPoints[1].x := 882;
      dtmSubPoints[1].y := 195;
      dtmSubPoints[1].AreaSize := 0;
      dtmSubPoints[1].AreaShape := 0;
      dtmSubPoints[1].Color := 7513283;
      dtmSubPoints[1].Tolerance := 0;

      dtmSubPoints[2].x := 858;
      dtmSubPoints[2].y := 184;
      dtmSubPoints[2].AreaSize := 0;
      dtmSubPoints[2].AreaShape := 0;
      dtmSubPoints[2].Color := 8001204;
      dtmSubPoints[2].Tolerance := 0;

      dtmSubPoints[3].x := 844;
      dtmSubPoints[3].y := 194;
      dtmSubPoints[3].AreaSize := 0;
      dtmSubPoints[3].AreaShape := 0;
      dtmSubPoints[3].Color := 4408393;
      dtmSubPoints[3].Tolerance := 0;

      TempTDTM.MainPoint := dtmMainPoint;
      TempTDTM.SubPoints := dtmSubPoints;
      Result := AddDTM(TempTDTM);
    end;
    end;
    end;

    function WalkToPlace: Boolean;
    var
      WalkDTM, x, y: integer; // Calls the WalkDTM making walking simpler.
      aFound: extended;
    begin
      WalkDTM := LoadDTMWalk(1); //Load which DDTM you want to find.
      if FindDTMRotated(WalkDTM, X, Y, MMx1,MMy1,MMx2,MMy2, -Pi/2, Pi/2, Pi/30, aFound) then // Find the DDTM using Find DTM
      begin
        Mouse(X, Y, 3, 3, True);
        FFlag(0);
        WriteDebug('Thief Point 1 done');
      end else // else it will do this...
        WriteDebug('failed find');
          end;
        end;
    end;






    function MyRoadColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);

      if not (FindColorsTolerance(arP, 6515310, MMX1, MMY1, MMX2, MMY2, 0)) then
      begin
        //Writeln('Failed to find the 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
        Result := arC[i];
        //Writeln('AutoColor = ' + IntToStr(arC[i]));
        Break;
      end;

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

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

    function StallColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.05, 0.09);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 10728640, MSX1, MSY1, MSX2, MSY2, 16);
      if (Length(arP) = 0) then
      begin
        //Writeln('Failed to find the 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
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 27.16) and (X <= 67.46) and (Y >= 27.98) and (Y <= 70.66) and (Z >= 20.78) and (Z <= 71.06) then
        begin
          Result := arC[i];
          //Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

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

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

    function FindObjTPA2(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: string): Boolean;
    var
      I, tCTS: Integer;
      myPoint: TPoint;
      Points: TPointArray;
      aPoints: T2DPointArray;
    begin
      Result := False;

      tCTS := GetColorToleranceSpeed;
      CTS := Integer(CTS * 9 mod 3 <> 0);
      ColorToleranceSpeed(CTS);
      FindColorsSpiralTolerance(X, Y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
      if Length(Points) = 0 then
      begin
        //writeln('findObjTPA(): Found no colors.... exiting');
        ColorToleranceSpeed(tCTS);
        Exit;
      end;
      ColorToleranceSpeed(1);
      aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
      SetLength(Points, 0);
      for I := 0 to High(aPoints) do
      begin
        if Length(aPoints[i]) < minCount then
          Continue;
        myPoint := MiddleTPA(aPoints[i]);
        MMouse(myPoint.X, myPoint.Y, 0, 0);
        wait(100 + random(50));

        if (pos(upText, RSPS_GetUptext) > 0) then
        begin
          //writeln('findObjTPA(): We found the object!');
          GetMousePos(X, Y);
          Result := True;
          ColorToleranceSpeed(tCTS);
          Exit;
        end else
          //writeln('findObjTPA(): Did not find the uptext... :<');
      end;
      ColorToleranceSpeed(tCTS);
    end;


    procedure Steal;
    var
      X, Y: Integer;
    begin
      repeat
      if FindObjTPA2(X, Y, StallColor, 5, 1, 41, 21, 23, 'em') then
        clickMouse2(MOUSE_LEFT);
      until(RSPS_InvFull);
    end;

    procedure Walk;
    begin
    if RSPS_InvFull then
    RadialWalk(MyRoadColor, 325, 300, 31, 1, 0);
    end;


    begin
      RSPS_SetInventory;
      Writeln(RSPS_GetUpText);
      MouseSpeed := 12;
      Steal();
      Writeln('Inventory count: ' + ToStr(rsps_Invcount));
      if (rsps_invFull) then
        Writeln('Inventory Full!');
      walk;
    end.


    problem 3.jpg
    problem 4.jpg

  5. #5
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by hete taart View Post
    ok ty alot so i changed that but now i got the following error

    script:

    Simba Code:
    Program New;
    {$i SRL/SRL.simba}

    var
    Inventory:TBoxArray;

    function ExplodeBox(bx: TBox; rows, columns: integer): TBoxArray;
    var
      r, c, w, h, ew, eh, ow, oh, i, x, y: integer;
    begin
      if ((rows > 0) and (columns > 0) and (bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2)) then
      begin
        w := ((bx.X2 - bx.X1) + 1);
        h := ((bx.Y2 - bx.Y1) + 1);
        if (rows < 1) then
          rows := 1
        else
          if (rows > h) then
            rows := h;
        if (columns < 1) then
          columns := 1
        else
          if (columns > w) then
            columns := w;
        w := (w div columns);
        h := (h div rows);
        ew := (((bx.X2 - bx.X1) + 1) - (w * columns));
        eh := (((bx.Y2 - bx.Y1) + 1) - (h * rows));
        SetLength(Result, (rows * columns));
        y := bx.Y1;
        for r := 0 to (rows - 1) do
        begin
          x := bx.X1;
          if ((eh > 0) and (r < eh)) then
            oh := 1
          else
            oh := 0;
          for c := 0 to (columns - 1) do
          begin
            if ((ew > 0) and (c < ew)) then
              ow := 1
            else
              ow := 0;
            i := ((r * columns) + c);
            Result[i].X1 := x;
            Result[i].X2 := (x + (w - 1) + ow);
            Result[i].Y1 := y;
            Result[i].Y2 := (y + (h - 1) + oh);
            x := (Result[i].X2 + 1);
          end;
          y := (Result[i].Y2 + 1);
        end;
      end else
        SetLength(Result, 0);
    end;

    procedure RSPS_SetInventory;
    begin
    Inventory := ExplodeBox(IntToBox(549, 206, 733, 465), 7, 4);
     end;

     function rsps_slotFull(slot:Integer):Boolean;
    var
      x, y:Integer;
    begin
      if FindColor(x, y, 65536, Inventory[slot].x1, Inventory[slot].y1, Inventory[slot].x2, Inventory[slot].y2) then
        result := true;
    end;

    function rsps_Invcount:Integer;
    var
      i:Integer;
    begin
     for i := 0 to high(Inventory) do
      begin
        if rsps_slotFull(i) then
          result := result + 1;
      end;
    end;

    function RSPS_InvFull:Boolean;
    begin
      result := (rsps_invcount = 28);
    end;

    Function RSPS_GetUpText: String;
    Var
      WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
    Begin
      WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPS');
      BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPS');
      YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPS');
      OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPS');
      FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
      FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
      FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
      Result:=FoundText;
    End;

    function LoadAllDTMWalks(WalkNumber: Integer): Integer;
    var
      dtmMainPoint: TDTMPointDef;
      dtmSubPoints: array[0..3] of TDTMPointDef;
      TempTDTM: TDTM;
    begin
      case WalkNumber of
        1: begin
         dtmMainPoint.x := 863;
      dtmMainPoint.y := 206;
      dtmMainPoint.AreaSize := 0;
      dtmMainPoint.AreaShape := 0;
      dtmMainPoint.Color := 6712945;
      dtmMainPoint.Tolerance := 0;

      dtmSubPoints[0].x := 863;
      dtmSubPoints[0].y := 206;
      dtmSubPoints[0].AreaSize := 0;
      dtmSubPoints[0].AreaShape := 0;
      dtmSubPoints[0].Color := 6712945;
      dtmSubPoints[0].Tolerance := 0;

      dtmSubPoints[1].x := 882;
      dtmSubPoints[1].y := 195;
      dtmSubPoints[1].AreaSize := 0;
      dtmSubPoints[1].AreaShape := 0;
      dtmSubPoints[1].Color := 7513283;
      dtmSubPoints[1].Tolerance := 0;

      dtmSubPoints[2].x := 858;
      dtmSubPoints[2].y := 184;
      dtmSubPoints[2].AreaSize := 0;
      dtmSubPoints[2].AreaShape := 0;
      dtmSubPoints[2].Color := 8001204;
      dtmSubPoints[2].Tolerance := 0;

      dtmSubPoints[3].x := 844;
      dtmSubPoints[3].y := 194;
      dtmSubPoints[3].AreaSize := 0;
      dtmSubPoints[3].AreaShape := 0;
      dtmSubPoints[3].Color := 4408393;
      dtmSubPoints[3].Tolerance := 0;

      TempTDTM.MainPoint := dtmMainPoint;
      TempTDTM.SubPoints := dtmSubPoints;
      Result := AddDTM(TempTDTM);
    end;
    end;
    end;

    function WalkToPlace: Boolean;
    var
      WalkDTM, x, y: integer; // Calls the WalkDTM making walking simpler.
      aFound: extended;
    begin
      WalkDTM := LoadDTMWalk(1); //Load which DDTM you want to find.
      if FindDTMRotated(WalkDTM, X, Y, MMx1,MMy1,MMx2,MMy2, -Pi/2, Pi/2, Pi/30, aFound) then // Find the DDTM using Find DTM
      begin
        Mouse(X, Y, 3, 3, True);
        FFlag(0);
        WriteDebug('Thief Point 1 done');
      end else // else it will do this...
        WriteDebug('failed find');
          end;
        end;
    end;






    function MyRoadColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);

      if not (FindColorsTolerance(arP, 6515310, MMX1, MMY1, MMX2, MMY2, 0)) then
      begin
        //Writeln('Failed to find the 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
        Result := arC[i];
        //Writeln('AutoColor = ' + IntToStr(arC[i]));
        Break;
      end;

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

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

    function StallColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.05, 0.09);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 10728640, MSX1, MSY1, MSX2, MSY2, 16);
      if (Length(arP) = 0) then
      begin
        //Writeln('Failed to find the 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
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 27.16) and (X <= 67.46) and (Y >= 27.98) and (Y <= 70.66) and (Z >= 20.78) and (Z <= 71.06) then
        begin
          Result := arC[i];
          //Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

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

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

    function FindObjTPA2(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: string): Boolean;
    var
      I, tCTS: Integer;
      myPoint: TPoint;
      Points: TPointArray;
      aPoints: T2DPointArray;
    begin
      Result := False;

      tCTS := GetColorToleranceSpeed;
      CTS := Integer(CTS * 9 mod 3 <> 0);
      ColorToleranceSpeed(CTS);
      FindColorsSpiralTolerance(X, Y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
      if Length(Points) = 0 then
      begin
        //writeln('findObjTPA(): Found no colors.... exiting');
        ColorToleranceSpeed(tCTS);
        Exit;
      end;
      ColorToleranceSpeed(1);
      aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
      SetLength(Points, 0);
      for I := 0 to High(aPoints) do
      begin
        if Length(aPoints[i]) < minCount then
          Continue;
        myPoint := MiddleTPA(aPoints[i]);
        MMouse(myPoint.X, myPoint.Y, 0, 0);
        wait(100 + random(50));

        if (pos(upText, RSPS_GetUptext) > 0) then
        begin
          //writeln('findObjTPA(): We found the object!');
          GetMousePos(X, Y);
          Result := True;
          ColorToleranceSpeed(tCTS);
          Exit;
        end else
          //writeln('findObjTPA(): Did not find the uptext... :<');
      end;
      ColorToleranceSpeed(tCTS);
    end;


    procedure Steal;
    var
      X, Y: Integer;
    begin
      repeat
      if FindObjTPA2(X, Y, StallColor, 5, 1, 41, 21, 23, 'em') then
        clickMouse2(MOUSE_LEFT);
      until(RSPS_InvFull);
    end;

    procedure Walk;
    begin
    if RSPS_InvFull then
    RadialWalk(MyRoadColor, 325, 300, 31, 1, 0);
    end;


    begin
      RSPS_SetInventory;
      Writeln(RSPS_GetUpText);
      MouseSpeed := 12;
      Steal();
      Writeln('Inventory count: ' + ToStr(rsps_Invcount));
      if (rsps_invFull) then
        Writeln('Inventory Full!');
      walk;
    end.


    problem 3.jpg
    problem 4.jpg
    you need to declare your dtm and you need to remove some end; of problem 3

  6. #6
    Join Date
    Dec 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    ok so now it compiles and stuff but when eventually my inv is full i am getting the weirdest error i ever got it opens a new script (not even mine and shows me the following error.

    problem 5.jpg
    problem 6.jpg

    what does this suppose to mean ?

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
  •