SRL Archive - OSR Help

Trying reflection for the fist time.


Tickyy

2014-06-26 09:06:22

So yeah, not really my first time, but the only time i used reflection was for the walking part.

anyway, so what i need is:

There's an item(one or many) somewhere visible in mm(or mainscreen), click to the nearest one using Main screen(if not shown in main… use mm), then take it.

1) Is it possible to make something like this?
2) Can someone show me for each part which function/procedure i need to use.

Thanks.

Dervish

2014-06-26 14:48:38

Explore the reflection include.

What I found so far :

    function R_GetAllGroundItems: TGroundItemArray;

Gets all ground items in players current region.

Then you need something to sort the found items by distance, look at how it's done for NPCs :

function R_SortNPCs(NPCs: TNPCArray): TNPCArray;
var
i,i2, L: integer;
tpa: TPointArray;
begin
L := GetArrayLength(NPCs);
if L < 1 then begin;
Result := NPCs;
exit;
end;
SetArrayLength(TPA, L);
SetArrayLength(Result, L);
for i := 0 to L-1 do
TPA[i] := NPCs[i].Tile;
SortTPAFrom(TPA, R_GetTileGlobal);
for i := 0 to L-1 do
for i2 := 0 to L-1 do
if (TPA[i].x=NPCs[i2].Tile.x) and (TPA[i].y=NPCs[i2].Tile.y) then
Result[i] := NPCs[i2];
end;

Also filter the array for the item you want by going through the array, removing the GroundItems you don't want be it by name or by ID.

Then walk to the tile using the MapWalk.simba include file, and finally use something like R_InteractTile to pick up the item :).

Reflection makes life so simple <3.