PDA

View Full Version : [K1] ActionRandomWalk Woes


e-varmint
12-21-2007, 09:38 PM
I have several Sith soldiers that use the following On Heartbeat script:

void main()
{
AssignCommand(OBJECT_SELF,ActionRandomWalk());
}

The problem is: They keep walking away during combat. Then they attack some more. Then they ActionRandomWalk. And on and on........

Is there some way to turn off the ActionRandomWalk, or should I use the script as an On Spawn, or something?

darthriddick
12-21-2007, 10:08 PM
you might try changing it using the "On attack" or something.
sorry I'm probably not the best help you can get. XP

stoffe
12-22-2007, 07:31 AM
I have several Sith soldiers that use the following On Heartbeat script:

void main()
{
AssignCommand(OBJECT_SELF,ActionRandomWalk());
}

The problem is: They keep walking away during combat. Then they attack some more. Then they ActionRandomWalk. And on and on........

Is there some way to turn off the ActionRandomWalk, or should I use the script as an On Spawn, or something?

ActionRandomWalk is a looping action, it will stay in the action queue (and make the NPC wander around randomly) until it is cleared out. Outside combat you're filling up the action queue of the NPC with those actions every 3 seconds. In combat the combat AI will clear the action queue every now and then, flushing out the RandomWalk action. But since your script runs as heartbeat a new one will be added every 3 seconds in combat as well.

You need to add condition checks to make sure new RandomWalk actions are not queued while the NPC is in combat or conversation. Something like this:


#include "k_inc_generic"

void main() {
if (!GN_GetSpawnInCondition(SW_FLAG_AI_OFF)
&& (GetCurrentAction(OBJECT_SELF) != ACTION_MOVETOPOINT)
&& !GetIsInCombat()
&& !GetIsInConversation(OBJECT_SELF)
&& !GN_GetIsFighting(OBJECT_SELF))
{
ActionRandomWalk();
}
}


(Also you don't need to assign the command since the NPC is already the one running the script.)

e-varmint
12-22-2007, 11:15 AM
Thanks, Stoffe!