Using yours as a base I set up the following. However the Action Stack/Queue is still not clearing when from the ClearAllActions. What happens is that I tell the Test NPC to move North and she does. However when I tell her to move South, she moves South for a moment but then tries to move North and then tries to move South, etc. I moved a ClearAllActions to the beginning of each directional script but that was not helpful either.
void MoveNorth(object oNPC);
void MoveNorthEast(object oNPC);
void MoveEast(object oNPC);
void MoveSouthEast(object oNPC);
void MoveSouth(object oNPC);
void MoveSouthWest(object oNPC);
void MoveWest(object oNPC);
void MoveNorthWest(object oNPC);
void Halt(object oNPC);
void main(int dir)
{
object oNPC = GetObjectByTag("nx2_merris");
switch (dir)
{
case 0:
MoveNorth(oNPC);
break;
case 1:
MoveNorthEast(oNPC);
break;
case 2:
MoveEast(oNPC);
break;
case 3:
MoveSouthEast(oNPC);
break;
case 4:
MoveSouth(oNPC);
break;
case 5:
MoveSouthWest(oNPC);
break;
case 6:
MoveWest(oNPC);
break;
case 7:
MoveNorthWest(oNPC);
break;
case 8:
Halt(oNPC);
break;
}
}
void MoveNorth(object oNPC)
{
ClearAllActions();
object oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "move") != 1 )
{
vector vPos = GetPosition(oNPC);
vPos.y += 10.f;
location lDest = Location(GetArea(oNPC), vPos, 90.f);
lDest = CalcSafeLocation(oNPC, lDest, 1.f, TRUE, FALSE);
ClearAllActions();
ActionMoveToLocation(lDest);
DelayCommand(3.f, MoveNorth(oNPC)); // recurse
}
}
void MoveNorthEast(object oNPC)
{
}
void MoveEast(object oNPC)
{
ClearAllActions();
object oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "move") != 1 )
{
vector vPos = GetPosition(oNPC);
vPos.x += 10.f;
location lDest = Location(GetArea(oNPC), vPos, 0.f);
lDest = CalcSafeLocation(oNPC, lDest, 1.f, TRUE, FALSE);
ClearAllActions();
ActionMoveToLocation(lDest);
DelayCommand(3.f, MoveEast(oNPC)); // recurse
}
}
void MoveSouthEast(object oNPC)
{
}
void MoveSouth(object oNPC)
{
ClearAllActions();
object oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "move") != 1 )
{
vector vPos = GetPosition(oNPC);
vPos.y -= 10.f;
location lDest = Location(GetArea(oNPC), vPos, 270.f);
lDest = CalcSafeLocation(oNPC, lDest, 1.f, TRUE, FALSE);
ClearAllActions();
ActionMoveToLocation(lDest);
DelayCommand(3.f, MoveSouth(oNPC)); // recurse
}
}
void MoveSouthWest(object oNPC)
{
}
void MoveWest(object oNPC)
{
ClearAllActions();
object oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "move") != 1 )
{
vector vPos = GetPosition(oNPC);
vPos.x -= 10.f;
location lDest = Location(GetArea(oNPC), vPos, 180.f);
lDest = CalcSafeLocation(oNPC, lDest, 1.f, TRUE, FALSE);
ClearAllActions();
ActionMoveToLocation(lDest);
DelayCommand(3.f, MoveWest(oNPC)); // recurse
}
}
void MoveNorthWest(object oNPC)
{
}
void Halt(object oNPC)
{
vector vPos = GetPosition(oNPC);
vPos.x = 0.f;
vPos.y = 0.f;
location lDest = Location(GetArea(oNPC), vPos, 0.f);
lDest = CalcSafeLocation(oNPC, lDest, 1.f, TRUE, FALSE);
ClearAllActions();
}