Author Topic: ClearAllActions() doesn't cancel WalkWayPoints()  (Read 388 times)

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
ClearAllActions() doesn't cancel WalkWayPoints()
« on: December 23, 2015, 11:38:17 pm »


               

I have a patrolling guard and I want to make him stop walking his waypoints when I talk to another NPC.


 


The following doesn't seem to do anything. The guard stops for a moment but after that he continues following his waypoints.



AssignCommand(oGuard, ClearAllActions())

I've tried also adding this:



AssignCommand(oGuard, ClearAllActions(TRUE));
SetLocalInt(oGuard, "DONTWALK", 1);

and in the Guard OnHeartbeat I added the DONTWALK check into the condition:



// If we have the 'constant' waypoints flag set, walk to the next
// waypoint.

else if ( GetWalkCondition(NW_WALK_FLAG_CONSTANT) && GetLocalInt(OBJECT_SELF, "DONTWALK") != 1 )
{
   WalkWayPoints();
}

But it still doesn't make him stop.


 


Is there a good way to make an NPC stop walking his waypoints?



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
ClearAllActions() doesn't cancel WalkWayPoints()
« Reply #1 on: December 24, 2015, 01:40:55 am »


               

there is an OnEnd and OnCancel event in each conversation - this is by default set to a script that forces WalkWaypoints()


 


check the conversation, if yu remove these scripts it should stop



               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
ClearAllActions() doesn't cancel WalkWayPoints()
« Reply #2 on: December 24, 2015, 01:47:00 am »


               

You could try altering the walk condition entirely.  WalkWayPoints is getting called from multiple AI scripts, not just OnHeartbeat.  OnPerception (nw_c2_default2) has a direct call to it as well.

 

From the WalkWayPoints info:
 



// Now, each time this function is called, the caller

// will move to their next waypoint. The OnHeartbeat and

// OnPerception scripts have been modified to call this


// function as appropriate.

 



 



#include "nw_i0_generic"


 

// Set a given condition

void SetWalkCondition(int nCondition, int bValid=TRUE, object oCreature=OBJECT_SELF)

 

Granted, I've never used that function, so I can't say exactly how it's used.  The Lexicon didn't seem to have anything on it either, but a little trial and error should get it for you.  My best guess for your guard would be:

SetWalkCondition(NW_WALK_FLAG_CONSTANT, FALSE, oGuard);


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
ClearAllActions() doesn't cancel WalkWayPoints()
« Reply #3 on: December 24, 2015, 07:50:42 am »


               

there is an OnEnd and OnCancel event in each conversation - this is by default set to a script that forces WalkWaypoints()
 
check the conversation, if yu remove these scripts it should stop

That affects the NPC who is in conversation, not third parties, such as the guard in this example.

Failed.Bard's suggestion is worth trying. If that doesn't work, change the OnHeartbeat and OnPerception scripts on the guard so that when they have a local variable set, walkwaypoints() is not called. (In principal, OnSpawn should be changed, too, but that's probably not an issue here, as the guard has already spawned).
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ClearAllActions() doesn't cancel WalkWayPoints()
« Reply #4 on: December 24, 2015, 03:23:04 pm »


               

Or use AWW (see sig) and pause or disable the guard's waypoint walking  '<img'>


 


I don't recall off-hand if the constant walk condition will do it. Hazy recollection says it serves a slightly different purpose, though. Editing the scripts is probably needed.   



               
               

               
            

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
ClearAllActions() doesn't cancel WalkWayPoints()
« Reply #5 on: December 24, 2015, 04:49:46 pm »


               

Thanks for pointing me the OnPerception script.


 


I added a condition in there and it seems to be working.



if (!IsInConversation(OBJECT_SELF && GetLocalInt(OBJECT_SELF, "DONTWALK") != 1))

@meaglyn


I saw your signature and I'm thinking of implementing your scripts in a future project. Seems very useful!