Author Topic: Making NPC speak while walking between waypoints.  (Read 613 times)

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Making NPC speak while walking between waypoints.
« Reply #15 on: November 23, 2015, 10:33:22 am »


               

 

...Why ANIMATION_LOOPING_TALK_NORMAL is stopping? Can it continue while the NPCs are interacting?

 

ActionPlayAnimation has a third parameter which defaults to 1 second for looping animations.

 

If you want the animation to play indefinitely, try


const float  FOREVER  = 1000000000000.0;  // 1 trillion seconds = about 5000 years of gameplay
 
void main()
{
  ActionPlayAnimation(ANIMATION_LOOPING_TALK_NORMAL, 1.0, FOREVER);
}

When you want to stop the animation, tell the NPC to ClearAllActions().

 

Getting an NPC to do two things simultaneously is tricky, because they only have one action queue, so, in principle, they only do one thing at a time.

 

There are workarounds, though.

 

If I remember correctly, an NPC can SpeakString while animating (or doing some other action), because SpeakString is not an action, is not queued, and happens immediately.

 

Caveat:


   Spoiler
   

 

Another workaround is to use a conversation. Starting a conversation is an action, so that has to happen first, but once the conversation is running, the NPCs can do almost any action you like, either through script or the PlayAnimation feature of the conversation line, as long as they remain within about 10m of the player.

 

Yet another option is to use invisible objects. You can use an invisible "controller" placeable to assign commands to the NPCs in a scene, to achieve complete control over the sequence of events. Also, an invisible object at the NPC's location can do things while the NPC is busy.

 

As Baaleos said, DelayCommand is a useful way to control timing. The only snag is that it's difficult to know in advance how long actions will take, so you end up tweaking the duration of each delay until the results look right.

 

To avoid that problem, you can make one NPC the "leader". For example, if Jill is the leader, ActionMoveToObject(oJack) followed by ActionDoCommand(AssignCommand(oJack... will cause Jack to do something when, and only when, Jill has finishing walking towards him. This is ideal, because you don't need to know any timings in advance, but if the scenario is very complicated, DelayCommand is probably easier.


               
               

               
            

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
Making NPC speak while walking between waypoints.
« Reply #16 on: November 25, 2015, 10:45:58 pm »


               

5000 years of gameplay



That would be enough..  ':mellow:'


 


I like that "leader" solution. It's genius. ActionDoCommand(AssignCommand()) is something I've never done but I will now, because I really hate tweaking timings, and this idea is very very good.


 



Another workaround is to use a conversation.



So something like AssignCommand(oNPC, SpeakString()) would work parallel to a talking animation?