Animation breaking behaviour

Yesterday I discussed with @Lance_Botelle an issue I had in a scene in my upcoming module. I managed to solve it in my own way but I’m still not sure what was causing the odd behaviour.

So, the scene goes like this:

  1. The PC and the companion are sitting down at a table having a conversation.
  2. At the last node of the conversation both are jumped to two separate waypoints near each other in the same area (one waypoint for the PC and another for the companion)
  3. At these two waypoints the PC and the companion starts to dance. The PC dances without problems but the companion starts to dance and after 1-2 seconds does a weird “jerky” move and stops dancing.

The way I eventually solved all this was to dismiss the companion from the party and then everything worked as it should.

What would cause the ending/interupting of the dance animation like this? At first I thought it had something to do with my use of ClearAllActions, but that wasn’t it. My theory at the moment is that maybe the companion starts dancing and then notices that she is not close enough to the PC, and adjusts herself, thus ending/interupting the animation.

Any thoughts on this?

@andgalf

As I mentioned in our chat, I think it could be to do with a script response from elsewhere… related to companions in this case. You could try commenting out each script attached to the companion to test any input they may be having.

Eg Stop the heartbeat script from running first and test, onperceived next, etc. Once/if you find a script that is affecting it, narrow down the code in that script some more.

EDIT: Also test SetCutSceneMode on your companions too. (I’ll PM you.)

1 Like

One thing I’m wondering about this…IF this is the case, why does everything work when removing the companion from the party? I mean, if it’s the hearbeat script of the companion (I use only the stock companion scripts for all the companions slots) then removing the companion from the party should have no effect, or could it?

Interesting…I kind of did what you suggested. I tested with removing the gb_comp_heart from the hearbeat slot of the companion. Then I tested the whole thing twice, and now she doesn’t stop dancing. So apparently there is something in the heartbeat script that makes her stop the dancing animation.

Now, I could do things the hard way and really try and test different things in the heartbeat script. But I’m thinking of instead (since I’m lazy) copying the script and adding a local int to it. If this int is activated then don’t do the heartbeat script at all (do a “return” so to speak). I would just add this local int before the dancing and then remove it after the dancing is done.

EDIT: Before doing anything I took a look at the gb_comp_heart that is running the gb_assoc_heart script. In that script there’s a line that I’m curious about, that maybe has something to do with this:

		if(!bIsScouting && !GetAssociateState(NW_ASC_MODE_STAND_GROUND) && !GetAssociateState(NW_ASC_MODE_PUPPET) &&
	        (GetNumActions(OBJECT_SELF) == 0) && !GetIsFighting(OBJECT_SELF) &&
	        (GetDistanceToObject(HenchGetFollowLeader()) > GetFollowDistance()))
	    {
	        ClearAllActions();
	        HenchFollowLeader();
	    }

I don’t know if an animation like this is considered an action by the game. If it isn’t then, maybe the companion clears all actions and follows the leader here since he’s maybe a tiny bit far away (they are still pretty close to each other but maybe it’s just a tiny bit too far away).

EDIT: In any case, for me the solution was to do a local int that I checked for in the beginning of the heartbeat script. If that local int doesn’t exist the script runs as normal, but if it’s TRUE (or 1) the script isn’t running. Just to be sure I tested it, and there appears to be no problems.

1 Like

another option: temporarily remove the Co’s HB script

SetEventHandler(oCo, CREATURE_SCRIPT_ON_HEARTBEAT, "noscript");

add it back later.

1 Like

This is almost certainly it … It’s another reason I ended rewriting every companion script and applying my own, not too dissimilar to what @kevL_s suggests by temporarily removing, only I completely altered it. :wink:

At least you are now aware just how much companion OC scripts can have an impact.

EDIT: Just read your PM about trying CutsceneMode on a companion … oh well. :wink: BUT, as you say the …

!GetAssociateState(NW_ASC_MODE_PUPPET) 

… is a conditional test, then you could always turn the companion PUPPET MODE during its dance routine. You would have to remember to turn it off again, just like you do the SetCutsceneMode setting.

1 Like

I don’t know how to do this. Probably something a bit too advanced for me.

not really. It’s just another command in the sequence of things …

eg → near the top of the script that ends the dialog and starts them dancing, run that function with the Companion passed in for oObject. Then figure roughly how long their dance will take, lets say 10 seconds. So at the bottom of that same script, do →

DelayCommand(10.0, SetEventHandler(oCo, CREATURE_SCRIPT_ON_HEARTBEAT, "gb_comp_heart"));

(or if you know that another script is going to run after the dance, run the function there without a delay)

3 Likes

Alright, that sounds really simple then. Should I have “noscript” there in that function? I mean, if I have no script called “noscript” won’t the game crash then? Or maybe I should have a script called “noscript” that is empty?

the game won’t crash if there is no script / iirc

you could alternately use a blank string "" as the argument, and for the HB-slot that’s probably the best way to go – but i tend to use ‘noscript’ or ‘blank’ or ‘supercalafradgalistic’ etc.

Because … if the OnDialog slot has "" it fires a default script. Using a non-blank string bypasses that hardcoded behavior. And am thinking it might happen on other AI-events, eg the OnHb

 
Or you could even use your hb-script with the ‘bypass’ int if you named it gb_comp_heart_bypass for example (but that would defeat the pseudo-happiness of not having a rather arbitrary nss/ncs floating about, imo)

 
[edit]
i suggest "noscript" with no script

2 Likes

Ok. Noted.

@kevL_s - At first I thought not to change how I did things since I felt lazy, but now I realized I want to use this same companion in another scene with an animation. For that your solution works best, I believe. Also I might the first scene (the dancing) with another companion, and then I don’t need another separate hb script for that companion if I use your solution.
So I’ll use the SetEventHandler and “noscript” with no script.

1 Like