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.
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.
Iterate the ground items and pick up the ones you want.
There used to be something meaningful here.
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.
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..."
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
Last edited by Rare Scripts; 12-12-2014 at 03:48 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)