Results 1 to 5 of 5

Thread: FindObjEx Error

  1. #1
    Join Date
    Mar 2012
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Exclamation FindObjEx Error

    Quote Originally Posted by masterBB View Post
    A lot of functions that requires a box to search in need the following parameters; xs, ys ,xe and ye(x start, y start, x end and y end). For some reason it starts to look 5 pixels above the client, but I don't see you use any function that requires a search box, like FindColors or such. Maybe it is a mistake in FindObjectCustom?

    These lines can be removed as they aren't used: x:=MSX1;
    y:=MSY1;

    edit:
    Could you replace FindObjectEx in Srl/srl/Object.simba with the following code, and post here if the debug tells you something new?
    Simba Code:
    function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
        Tol, Step, xs, ys, xe, ye: Integer): Boolean;
    var
      CurX, CurY, a, b, c, i: Integer;
      Start: Boolean;
    begin
      for b := 0 to (GetArrayLength(Color)-1) do
      begin
        if (FindColorSpiralTolerance(cx, cy, color[b], xs, ys, xe, ye, Tol)) then
        begin
          Start := True;
          Break;
        end;
      end;
      if (Start) then
      begin
        CurX := Round((xs + xe) div 2);
        CurY := Round((ys + ye) div 2) - Step;
        i := 1;
        repeat
          for c := 1 to i do
          begin
            case a of
              0: begin  //To allow for beginning offset and loop
                   a := a + 1;
                   i := 0;
                   CurY := CurY + Step;
                 end;
              1: CurX := CurX + Step;
              2: CurY := CurY - Step;
              3: CurX := CurX - Step;
              4: CurY := CurY + Step;
            end;
            if (CurX >= xs) and (CurX <= xe) and (CurY >= ys) and (CurY <= ye) then
            begin
              try
                for b := 0 to (GetArrayLength(Color)-1) do
                begin
                  if (CurY-(Step div 2) < 0)then
                    writeln('Fast tell everyone the FindObjectCustom function is bad');
                  if (FindColorTolerance(cx, cy, Color[b], CurX-(Step div 2), CurY-(Step div 2), CurX+(Step div 2), CurY+(Step div 2), Tol)) then
                  begin
                    MMouse(cx, cy, 3, 3);
                    If (WaitUptextMulti(Text, 300)) then
                    begin
                      GetMousePos(cx, cy);
                      Result := True;
                      Exit;
                    end;
                  end;
                end;
              except
              end;
            end;
          end;
          a := a + 1;
          if a mod 5 = 0 then a := 1;
          if (a = 1) or (a = 3) then i := i + 1;
        until (Result) or ((CurX > xe) and (CurY > ye))
      end;
    end;


    I am getting another error, I replaced the FindObjEx file as stated above.
    It was working for a few minutes, I didn't even edit it. Also I am not using DTMs or Bitmap.

    if FindObjEx(x, y, ['ake', 'hide'], [LootColors], 15, 50, 1, 5, 689, 390) then

    is hightlighted

    DebugBox

    Code:
    SRL Compiled in 16 msec
    SMART Initialized.
    Loaded: Server 14, Members: True, Signed: True, Super Detail: False.
    Error: Exception: Type Mismatch at line 69
    The following DTMs were not freed: [SRL - Lamp bitmap, 1]
    The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]



    Simba Code:
    program Tester; //Warning: This is only for testing
    {$DEFINE SMART} //Very Little Antibans
    {$i SRL/srl.simba}
    {.include SRL/SRL/Skill/Fighting.simba}

    var
    LootCount : Integer;
    LootColors :TIntegerArray;

    procedure SetUpScript;
        begin
        LootColors := [15001839, 15330547, 15725050, 15658745, 15790587,15921917];
        ClearDebug;
        Smart_Server := 14;
        Smart_Members := True;
        Smart_Signed := True;
        Smart_SuperDetail := False;
        activateclient;
        SetupSRL;
       end;

    Procedure Looter;
          var
          x, y:Integer;
          begin
             //If FindObjCustom(x,y,['ake', 'hide'],[LootColors],3) then
             if FindObjEx(x, y, ['ake', 'hide'], [LootColors], 15, 50, 1, 5, 689, 390)   then
                  GetMousePos(x, y);
                  Mouse(x, y, 5, 5, false);
                  if WaitOptionMulti(['Take Cowhide', 'ake C'], 200) then
              begin
                  LootCount := LootCount + 1;
                  wait(200);
              end;
          end;



    begin
         SetUpScript;
         Looter;
         end.

    Hope its easy to read and I tried to make it nice and neat.

    Thanks

  2. #2
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Remove the square brackets around [LoopColours] in the if..then statement.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  3. #3
    Join Date
    Mar 2012
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Smile

    Quote Originally Posted by Daniel View Post
    Remove the square brackets around [LoopColours] in the if..then statement.
    Thanks, its working now.

    I am so happy, I have the script killing cows and picking up loot.

    Just one thing with the loot, if there is other loot that I don't want it to pick up it keeps checking and ignoring the new loot with the cow hide. some times not all.

    Is there a code to pick up loot closest to the player.

    Thanks for all the help

  4. #4
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Could use findcolorspiral starts in and goes out.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  5. #5
    Join Date
    Mar 2012
    Posts
    426
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

    Default

    Quote Originally Posted by SamSatanas View Post
    Thanks, its working now.

    I am so happy, I have the script killing cows and picking up loot.

    Just one thing with the loot, if there is other loot that I don't want it to pick up it keeps checking and ignoring the new loot with the cow hide. some times not all.

    Is there a code to pick up loot closest to the player.

    Thanks for all the help
    Ok, you could use a function like the following:

    Simba Code:
    Function FindCowHide(x, y: Integer): Boolean;

    Var
    CTS, I: Integer;
    TPA: TPointArray;
    ATPA: Array of TPointArray;

    Begin
      Area1 := IntToBox(X1,Y1,X2,Y2);
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(Hue, Sat);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, X1, Y1, X2, Y2, Tol);
      ColorToleranceSpeed(CTS);
      TPA:= TPAFromBox(Area1));
      ATPA := TPAToATPAEx(TPA, 30, 30);

      For I := 0 To High(ATPA) Do
      Begin
        MiddleTPAEx(ATPA[i], x, y);
        MMouse(x, y, 0, 0);
        If(WaitUpTextMulti([MultiStrings],800)) Then
        Begin
          Result := True;
          GetMousePos(x, y);
          Break;
        End;
      End;
    End;

    So in (Area1 := IntoToBox(X1,Y1,X2,Y2)), you want to put in the coordinates of the upper left and and lower right corner of a box that is around your character. You determine how big you want that box to be. The function will then take the colors it found and delete the ones in the TPA that are outside of that box. So then it will only check for uptext on the objects that are within your box. This should cut down on your function varying out to objects that are further away choosing those over the ones closest to you. Shoot me a pm if you need any further help or clarification.
    Last edited by iBlank; 05-02-2012 at 04:58 AM.

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
  •