Jump to content

Home

[K1] ActionRandomWalk Woes


e-varmint

Recommended Posts

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?

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...