SRL Archive - Newly Added to Reflection

New GroundItems.scar functions.


mormonman

2009-08-01 00:48:44

Ok, so I added 3 new functions and they need explanations.


function FindGroundItem(var Itemx : TGroundItem; ID, maxSL : Integer) : Boolean

This is a simple, easy-to-use version of FindGroundItems. It only uses one ID and it returns the closest item with that ID.

Example:

procedure PickupBones;
var
S : TGroundItem;
T : TPoint;
begin
if FindGroundItem(S, BonesID, 15{on minimap}) then
begin
if not TileOnMS(S.Tile, 1) then
begin
T := S.Tile;
WalkToTile(T, 1, 1);
end;
if TileOnMS(S.Tile, 1) then
begin
T := S.MS;
Mouse(T.X, T.Y, 10, 10, False);
R_ChooseOption('Pickup');//I don't know if that is even what it is...
end;
end;
end;

function FindGroundItemsInBox(var Items : TGroundItemArray; IDs : TIntegerArray; Box : TBox) : Boolean

This function is for those areas that you know that the drops will always be in the same box.(Example: Drops from Ogres in King Lathas' Training Ground)
I made this because I don't want to search tiles that I know what have the items on them. Note: Does not sort them closest to farthest.

Here is how I use it:

function GetTiles: TPointArray;
var
T: TGroundItemArray;
i, L, Hi: Integer;
begin
if FindGroundItemsInBox(T, [5321, 987, 985, 5300, 5295], IntToBox(2523, 3373, 2533, 3377)) then
begin
Hi := High(T);
for i := 0 to Hi do
if TileOnMS(T[i].Tile, 1) then
begin
SetArrayLength(Result, L + 1);
Result[L] := T[i].Tile;
Inc(L);
end;
end;
end;

procedure DebugGroundItems(Dist : Integer);

This is a debugging procedure that will tell you how many items were found, the ID of the items, and the tile they are on within the distance defined by Dist. Very useful for scripters.

Example:

program New;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Reflection/Reflection.scar}

begin
Smart_Server := 70;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
DebugGroundItems(15{again... on minimap});
end.

Thanks, and have fun xD

marpis

2009-08-01 02:10:49


T := TileToMM(S.Tile);
WalkToTile(T, 1, 1);

should be just


WalkToTile(T, 1, 1);
or

T := TileToMM(S.Tile);
MouseFlag(T.x, T.y, 2, 2, 0);

????????

mormonman

2009-08-01 02:49:43

No, because I was setting T to S.Tile … it should be

T := S.Tile;
WalkToTile(T, 1, 1)

senrath

2009-08-01 03:03:38

You don't need the TileToMS anyway, as the TGroundItem already contains the coordinates needed in its MS property.

mormonman

2009-08-01 03:21:38

I wrote that function on the forums very quickly… gosh…

senrath

2009-08-01 03:26:44

Sorry, I wasn't trying to be rude, just helpful.

Perfect_Coder

2009-08-11 10:42:06

Thank you for additions.
Now I can use FindGroundItemsInBox with my own location info (character position) to get items that have dropped on previous target by using box with location.x-1, location.y-1 to location x+1,location y+1.

Thank you very much