Results 1 to 6 of 6

Thread: Reflection/Simba Finding/Clicking Objects

  1. #1
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Reflection/Simba Finding/Clicking Objects

    I'm tired, it's late.

    How do I correctly implement finding an object and then clicking it?

    Simba Code:
    program FightCaveRunner;
    {$DEFINE SMART}
    {$i SRL/SRL.scar}
    {$i Reflection/Reflection.simba}

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

      with Players[0] do
      begin
        Name := '';
        Pass := '';
        Nick := 'ake';
        Active:=True;
      end;
    end;

    var
      playerAtCaves : boolean;
      tmp : integer;



    Procedure atCaves;
    begin
      if (DistanceFrom(Tile(2438, 5168)) < 6) then
      begin
        writeln('We''re at the caves!');
        playerAtCaves := True;
      end else
      begin
        writeln('looks like we''re not at the caves');
        playerAtCaves := False;
      end;
    end;

    Procedure findCaveEntrace;
    var
     entrance: TNPCArray;
     cavePoint: TPoint;

    Begin

     // tmp := GetObjectAt(Point(2439,5167),0).ID;
     // writeln(tmp);//    Gets object ID at a certain point
      entrance := SortNPCs(GetNPCs(9356));
      cavePoint := Tile(2439,5167);
      Mouse(cavePoint.x, cavePoint.y, 10, 10, False);


    End;


     {
      Notes for me!

      ID:   9356 should be the entrace
      writeln('Object ID:'+ GetObjectAt(Point(2438,5167),0).ID);    Gets object ID at a certain point



    }


    Procedure MainLoop;
    Begin
      Smart_Signed := true;
      Smart_Server := 34;
      Smart_SuperDetail := false;
      SetupSRL;
      DeclarePlayers;
      LoginPlayer;
      findCaveEntrace;
      //writeln(GetMyPos);
      //wait(3000);
      //writeln(GetMyPos);
    end;

    begin
      MainLoop;
    end.

    Why is this not working?
    Thanks <3
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  2. #2
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    It's not working for several reasons
    • The "CavePoint" you've designated is the Reflection tile, not the onscreen coordinate. Use TileToMS or TileToMSEx to make an onscreen coordinate from a TTile.
    • There's no point in using a TNPCArray if you already know the tile.
    • Are you sure it's an NPC? I'm pretty sure the cave entrance would be an Object (TRSObject).


    Simba Code:
    function EnterCave: Boolean;
    var
      i: Integer;
      Objs: TRSObjectArray;
      Pt: TPoint;
    begin
      if not(LoggedIn) then
        Exit;
      Objs := SortObjects(GetObjectsByID(9356, OBJECT_TYPE_INTERACTABLE,10));
      for i := 0 to High(Objs) do
      begin
        if (Objs[i].Tile <> Tile(2439, 5167)) then
          Continue;
        if not(TileOnMS(Objs[i].Tile, 0)) then   //May have to use Objs[i].RealTile instead
          if not(WalkToTile(Objs[i].Tile, 2, 0)) then
            Continue;
        Pt := TileToMS(Objs[i].Tile, 0);
        MMouse(Pt.x - 10, Pt.y - 10, 20, 20);
        if R_WaitUptextMulti(['your uptexts here'], 900) then
        begin
          Wait(50 + Random(80));
          ClickMouse2(False);
          Wait(50 + Random(80));
          Result := r_WaitOptionMulti(['your choose options here'], 900);
        end;
        if Result then
          Break;
      end;
      for i := 0 to High(Objs) do    //
        Objs[i] := NULL_RSOBJECT;    //These 3 lines should prevent memory leaks
      SetLength(Objs, 0);            //
    end;

  3. #3
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah sorry, I totally forgot about objects!

    I'm reasonably new to reflection, and I didn't know how each 'thing' (entity?) was treated.

    I'm gonna copy/paste (edit uptext etc) to suit my needs, then i'll credit you if that's alright?
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  4. #4
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by 05hartor View Post
    Yeah sorry, I totally forgot about objects!

    I'm reasonably new to reflection, and I didn't know how each 'thing' (entity?) was treated.

    I'm gonna copy/paste (edit uptext etc) to suit my needs, then i'll credit you if that's alright?
    Sure, but read through the code and make sure you understand it, you need to know arrays to properly use reflection.

  5. #5
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm pretty good with Java/C++/Python so I know how Arrays work, I think i'm about there when it comes to the reflection arrays.

    I'm presuming that 'High(array)' in a loop will do it until the last array object?
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  6. #6
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    That's correct, "0 to High" just iterates through each array value and performs the procedure. Also, you should take a look through this tutorial, it is good for people who are beginning to learn reflection.

    http://villavu.com/forum/showthread.php?t=59400

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
  •