Results 1 to 7 of 7

Thread: Looting with reflection?

  1. #1
    Join Date
    Aug 2014
    Posts
    93
    Mentioned
    2 Post(s)
    Quoted
    36 Post(s)

    Default Looting with reflection?

    Working on a private script atm but cant get the looting to work..
    Hope to get it working so i can release combat scripts later on for public.

    Can anyone give me a example on how to loot with reflection?

    Many thanks.
    -Baws.

  2. #2
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Iterate the ground items and pick up the ones you want.
    There used to be something meaningful here.

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Yea, I'm not familiar with the OSR-reflection include but pretty much what you would do is get the TGroundItemArray and loop through it, give me a second i'll write up some code

    EDIT:

    Simba Code:
    {$DEFINE SMART8}
    {$I SRL-OSR/SRL.Simba}
    {$i SRL-OSR/SRL/Reflection/Reflection.simba}

    procedure lootItems(ID, dist:integer;name:string);
    var
      items:TGroundItemArray;
      i:integer;
    begin
      items := r_getGroundItemsDistance(dist);
      for i := 0 to high(items) do
        if (items[i].ID = ID) then
        begin
          r_interactTile(items[i].Tile, name);
          break;
        end;
    end;

    begin
      lootItems(993, 5, 'Take Coins');
    end.

    There could be more fails safes to be added, but this is a starting point let me know if it works

  4. #4
    Join Date
    Aug 2014
    Posts
    93
    Mentioned
    2 Post(s)
    Quoted
    36 Post(s)

    Default

    Quote Originally Posted by Robert View Post
    Yea, I'm not familiar with the OSR-reflection include but pretty much what you would do is get the TGroundItemArray and loop through it, give me a second i'll write up some code

    EDIT:

    Simba Code:
    {$DEFINE SMART8}
    {$I SRL-OSR/SRL.Simba}
    {$i SRL-OSR/SRL/Reflection/Reflection.simba}

    procedure lootItems(ID, dist:integer;name:string);
    var
      items:TGroundItemArray;
      i:integer;
    begin
      items := r_getGroundItemsDistance(dist);
      for i := 0 to high(items) do
        if (items[i].ID = ID) then
        begin
          r_interactTile(items[i].Tile, name);
          break;
        end;
    end;

    begin
      lootItems(993, 5, 'Take Coins');
    end.

    There could be more fails safes to be added, but this is a starting point let me know if it works
    Many thanks, will try this when im at home.

    Edit: working perfect! Many thanks, is there also a way possible to right click and select correct ID (if have more items on top) and also repeat the looting until it has all items it needed from ground?

    Its the last part of code i need, I barly use Reflection for things, so im new to it.
    Last edited by Rare Scripts; 12-12-2014 at 12:16 PM.

  5. #5
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Using Robert's example, here's what you could do:
    Simba Code:
    procedure lootItems(ID, dist:integer;name:string);
    var
      items:TGroundItemArray;
      i:integer;
      BreakLoop:boolean;
    begin
      repeat
        items := r_getGroundItemsDistance(dist);
        for i := 0 to high(items) do
        begin
          if (items[i].ID = ID) then
          begin
            BreakLoop := False;
            r_interactTile(items[i].Tile, name);
            break;
          end;
          BreakLoop := True;
        end;
      until(BreakLoop);
    end;

    Of course within the first loop you'll want to put some failsafes (timers, loggedin check, randoms checker).

    Edit:
    By the way, that's untested as I don't use reflection. The logic seems fine to me but if you don't understand what I did just ask me here.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  6. #6
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Simba Code:
    procedure lootItems(Dist: Integer; IDs: TIntegerArray; Names: TStringArray);
    var
      items:TGroundItemArray;
      i:integer;
    begin
      items := r_getGroundItemsDistance(dist);
      for i := 0 to high(items) do
        if InIntArray(IDs, Items.ID) then
          r_interactTile(items[i].Tile, Names[I]);
    end;

    lootItems(25, [995, 318], ['Take Coins', 'Take Lobster']);

    • Will pick-up all selected items in order(if in the same pile)
    • IDs and Names must be in the same order, as in example.
    • Happy bottin





  7. #7
    Join Date
    Aug 2014
    Posts
    93
    Mentioned
    2 Post(s)
    Quoted
    36 Post(s)

    Default

    Many thanks all!


    EDIT:

    Quote Originally Posted by Fitta View Post
    Simba Code:
    procedure lootItems(Dist: Integer; IDs: TIntegerArray; Names: TStringArray);
    var
      items:TGroundItemArray;
      i:integer;
    begin
      items := r_getGroundItemsDistance(dist);
      for i := 0 to high(items) do
        if InIntArray(IDs, Items.ID) then
          r_interactTile(items[i].Tile, Names[I]);
    end;

    lootItems(25, [995, 318], ['Take Coins', 'Take Lobster']);

    • Will pick-up all selected items in order(if in the same pile)
    • IDs and Names must be in the same order, as in example.
    • Happy bottin

    give me error:

    [Error] C:\..... - Baws Scripts.....simba(442:30): Semicolon (';') expected at line 443


    EDIT 1:

    Somethimes it has another item (in case, diffrent unid herbs (all other ID)) on top, how do i make it right click to loot?
    Last edited by Rare Scripts; 12-12-2014 at 03:48 PM.

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
  •