SRL Archive - OSR Help

Determining which way an NPC is facing


levunit

2014-12-13 15:38:58

Is there any way to figure out which direction an NPC is facing easily?

I did come up with a method that checks the tile the NPC is on before and after a certain interval, because they are constantly moving, but it doesn't seem accurate enough, due to the fact that the NPC could take 2 steps forward, then 1 back, and it'll think it's in the opposite direction lol.

Any information/help would be appreciated.

Brandon

2014-12-13 15:57:06

From: levunit
Is there any way to figure out which direction an NPC is facing easily?

I did come up with a method that checks the tile the NPC is on before and after a certain interval, because they are constantly moving, but it doesn't seem accurate enough, due to the fact that the NPC could take 2 steps forward, then 1 back, and it'll think it's in the opposite direction lol.

Any information/help would be appreciated.





Entity: au
-------------------------------

Orientation -> as * -1263281545


Check the orientation field if using Reflection.. Otherwise you're going to have a hard time doing it with colour..

Lipcot

2014-12-13 15:57:32

look for a color inside your ATPA that's only on the front part of the NPC ?

levunit

2014-12-13 16:41:35

From: Brandon

Entity: au
-------------------------------

Orientation -> as * -1263281545


Check the orientation field if using Reflection.. Otherwise you're going to have a hard time doing it with colour..


This seems to be what I'm looking for. Could you give a simple example that I could work off of?
I assume I'd have to use smartgetfield but I'm lost from that point.

Kyle

2014-12-13 17:04:29

From: levunit
This seems to be what I'm looking for. Could you give a simple example that I could work off of?
I assume I'd have to use smartgetfield but I'm lost from that point.


I'll be adding it to the Npc record on the new reflection include. I just need to finish up my Hook updater and I will devote all my time to the include. I hope to have everything done by the end of my winter break in 3 weeks..

Frement

2014-12-13 17:05:53

Old code:
function R_GetNPCOrientation(Index: Integer): Integer;
var
NPCNode: Integer;
begin
NPCNode:= SmartGetFieldArrayObject(SmartCurrentTarget, 0, client_npcs, Index);
Result := Floor((SmartGetFieldInt(SmartCurrentTarget, NPCNode, Actor_orientation) * Actor_orientation_Multiplier / 2048.0) * 360.0);
SmartFreeObject(SmartCurrentTarget, NPCNode);
end;

levunit

2014-12-13 22:30:41

From: Frement
Old code:
function R_GetNPCOrientation(Index: Integer): Integer;
var
NPCNode: Integer;
begin
NPCNode:= SmartGetFieldArrayObject(SmartCurrentTarget, 0, client_npcs, Index);
Result := Floor((SmartGetFieldInt(SmartCurrentTarget, NPCNode, Actor_orientation) * Actor_orientation_Multiplier / 2048.0) * 360.0);
SmartFreeObject(SmartCurrentTarget, NPCNode);
end;


Thanks, added it to R_GetTNPC and it works like a charm. And elfyyy, I'm looking forward to the new include. :)