I am trying to do something very simple, but the timing for NPC action queues doesn’t work the way I thought it did. I want to have an NPC walk to a spot, wait a few seconds, play a visual effect on him, then have him disappear about 2.5 seconds later.
Here is the segment of code that is supposed to do this
// We're done here. Walk the NPC to the sextant and get rid of him AssignCommand(oNPC, ActionMoveToLocation(GetLocation(oSextant),FALSE)); AssignCommand(oNPC, ActionWait(3.0f)); AssignCommand(oNPC, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), oNPC)); AssignCommand(oNPC, DestroyObject(oNPC, 2.5f));
Note that it doesn’t always take the NPC the same amount of time to get to his destination, so it’s not quite just a matter of playing with the timing.
But, this isn’t working the way I want. Instead of waiting until the NPC gets to his destination and then playing 3 seconds later, the effect plays almost immediately. The NPC also disappears too soon - seemingly the 2.5 second timer starting before he gets to his destination.
So, to be clear, I want the other events (the played effect and the disappearance) to NOT start until the NPC has gotten to his destination and then waited 3 seconds. Apparently, just adding those things to his action queue isn’t the right way to do this. I was hoping to accomplish this without kludging together a bunch of silly scripts triggered by other events (e.g. draw a trigger at the NPC’s destination and don’t start the effect and destroy sequence until he triggers that OnEnter event).
Is there a nice way to do this that takes advantage of the NPC’s event queue?