[not a bug] NPC RunAwayFrom bug?

Bug Reports relating to the 097 core are moved to this forum once solved.

Moderator: POL Developer

Locked
guniu
New User
Posts: 6
Joined: Sat Nov 29, 2008 11:50 am

[not a bug] NPC RunAwayFrom bug?

Post by guniu » Sat Nov 29, 2008 2:43 pm

Hi,
I'm not sure if it's a bug, but i noticed that RunAwayFrom(Self()) or RunAwayFromLocation(Self().x, Self().y) aren't working properly.
When using this function, npc does a move toward (x, y+1) field.
Ok. Now, lets block this field, so npc can't go there. This time npc goes to (x-1, y+1) field. Block this one too, and npc goes to (x+1, y+1) field. Block again, and npc goes to (x-1, y). If we block this one, npc will go to (x+1, y). Again, block, and npc lands on (x-1, y-1). Once more, block this field, and npc goes to (x+1, y-1). And the last one, block (x+1, y-1) field and npc... does nothing. He still has (x, y-1) field open, but he doesn't move there. Why?

PS. Just to be clear, I don't need help solving problem with this, because it's easy. I'm just reporting a bug - if it is a bug. If not, then 'it wasn't me' :P

Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Re: NPC RunAwayFrom bug?

Post by Luth » Sun Nov 30, 2008 1:54 pm

All movement must be in one of eight directions. When running away from an object, it is running away from a position in the facing direction of the object from the npc. If the object is (W)est of the npc, then it will run in the opposite, (E)ast direction. However, in what direction is Self from Self? (N)orth? (S)outh? It's an undefined direction, a zero-length vector, and therefore cannot be mapped to one of the eight valid directions. To handle this no-direction problem, we use a default direction of (N)orth, and attempt to run away from that, which means the NPC will run (S)outh. If (S)outh is blocked, and UseAdjustments is enabled, then the NPC will try to go any way except the one way that takes him in the exact opposite direction of where he wants to go. In this case, since the NPC wants to run away from default (N)orth, that is the one direction he will not attempt to run to.

I hope that explains things a little bit, if nothing else. :)

Locked