SRL Archive - Reflection Development

WalkToNPC();


**BANNED The Man

2011-01-27 17:23:52

It will walk to the NPC desired.
Even if it isn't on the minimap.
It can be a maximum of 30 tiles away at the moment, can easily be edited to suffice more.

Function WalkToNPC(NPCID, Randomness, FlagD:Integer):Boolean;
var
NPCVariable : TNPC;
NPCTile, PlayerTile, NewTile : TTile;
begin
Result := False;
NPCVariable := FindNPC(NPCID);
NPCTile := NPCVariable.Tile;
PlayerTile := GetMyPos;
if TileOnMM(NPCTile.Tile) then
Result := WalkToTile(tile(NPCTile.Tile), Randomness, FlagD)
else
if Distance(PlayerTile.x, PlayerTile.y, NPCTile.x, NPCTile.y) =< 30 then
begin
NewTile := MiddleTPA([point(PlayerTile.x, PlayerTile.y), point(NPCTile.x, NPCtile.y)]);
if WalkToTile(tile(NewTile.x, NewTile.y), Randomness, FlagD then
Result := WalkToTile(tile(NPCTile.Tile), Randomness, FlagD);
end;
end;

I need feedback to see whether a larger distance is needed/wanted, so it will walk more tiles.
And also, this gives me a reasonable base for a World Walker, or maybe not? :P

Hope you like it :)

-Boom

lordsaturn

2011-01-27 17:36:07

MyTile.y


Whos function are you copying? :)

Gu3st...

2011-01-27 17:36:21

If you want to add support for NPCs that's more than 30 tiles away, then make a variable that holds information about what angle the user has to walk in if it want to get to the NPC, and walk until that NPC is visible

From: lordsaturn
Whos function are you copying? :)
That was from msn. I helped him with Distance, and he probably forgot to change MyTile into PlayerTile :)

**BANNED The Man

2011-01-27 17:39:16

From: lordsaturn
Whos function are you copying? :)

Nobodys..

From: Zyt3x
If you want to add support for NPCs that's more than 30 tiles away, then make a variable that holds information about what angle the user has to walk in if it want to get to the NPC, and walk until that NPC is visible

That was from msn. I helped him with Distance, and he probably forgot to change MyTile into PlayerTile :)


Yeah ^ lol I had major problems getting my head round that :P

-Boom

mormonman

2011-01-27 17:47:46

From: Zyt3x
If you want to add support for NPCs that's more than 30 tiles away, then make a variable that holds information about what angle the user has to walk in if it want to get to the NPC, and walk until that NPC is visible

That was from msn. I helped him with Distance, and he probably forgot to change MyTile into PlayerTile :)


R_WebWalk();

That's besides the point.

Haven't we tried to keep functions like this out of reflection because it should be done by the scripter?

Bad Boy JH

2011-02-05 08:36:26

perhaps a:
distance(MyPos.x, MyPos.y, NPCPos.x, NPCPos.y) / radius of minimap
round that up.
get a point that is 1/X (X is the number we just rounded up) of the way there…
then 2/X…..
and then WalkPath…those tiles

That will allow any distance, but will screw up when there is a large obstacle in the way.
if Distance > ArbitraryAmount then R_WebWalk