SRL Archive - Newly Added to Reflection

FindFreeNCPEx


mormonman

2009-08-01 02:23:15

So many people were wondering why FindFreeNPC didn't work for larger NPCs? Well the answer is that they occupy more than one tile and require the TTile functions. I have no clue why this hasn't already been added to the svn, but here it is.

Function FindFreeNPCEx(TheVar: Variant; var NPC: TNPCEx) : Boolean;

It is wonderful, and it will work for any NPC.

TNPCEx is slightly different from TNPC. Instead of using TPoints for TNPCEx.Tile, It uses the type TTile. Long explanation short: TTiles store the exact location of whatever the thing is, TPoints just store the rounded off tiles. (TTile is an extended)
Whenever you want to use the TTile to click onscreen YOU MUST ROUND THEM!!!

Example usage:

function Find : Boolean;//from my script
var
T : TTile;
Mino : TNPCEx;
x, y, ID : Integer;
begin
if not LoggedIn then Exit;
if FindFreeNPCEx(4406, Mino) then
begin
if not TileOnMSEx(Mino.Tile, 0){must use Ex versions of Tile conversions} then WalkToTile(Mino.MM, 1, 1){can still use walktotile if you use the TNPCEx.MM}
else
begin
T := Mino.MS;
MMouse(Round(T.x), Round(T.y), 5, 5);
GetMousePos(x, y);
Result := IsUptext('inota');
if Result then Mouse(x, y, 0, 0, True) else
if OptionExists('Attack') then Result := R_ChooseOption('Attack');
end;
end;
end;

I think I covered everything…
One more thread to make :D

mormonman

2009-08-01 02:47:51

I snuffed some stuff on the commit… everyone should re-update!