here they are:
the "follow"
- Spoiler
- With npc(sysval(Param1))
If ( Char(1).x - .x)^2 < ( Char(2).x - .x)^2 then
If Char(1).x - .x > 0 then
.facing =0
else
.facing =1
End if
Else
If Char(2).x - .x > 0 then
.facing =0
else
.facing =1
End if
End if
the "flee":
- Spoiler
- With npc(sysval(Param1))
If ( Char(1).x - .x)^2 < ( Char(2).x - .x)^2 then
If Char(1).x - .x > 0 then
.facing =1
else
.facing =0
End if
Else
If Char(2).x - .x > 0 then
.facing =1
else
.facing =0
End if
End if
now, let me explain how they are working
first, the script determine wich player's the nearest from the npc then it'll change the npc's facing so the npc will always "walk" in the character's direction (or the opposite direction in the "flee" script
I should also mention the two problems with this script:
1- it only check the X axis of the player so it's not the best for a level with many height
2- if the player stand on or under the npc, the npc became a little glitchy
I hope this can be usefull ^^