Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Field Researcher
Original Poster
#1 Old 28th Mar 2021 at 5:55 PM Last edited by lizcandor : 30th Mar 2021 at 1:48 PM.
Default CLIP file script events
I have another animation question!

Does anyone know how script events associated with animations work, or know of a mod I could look into for an example? I've only been able to reach a very general understanding of them by looking at EA's CLIP files in s3pe, so I can't figure out why the script events for an animation I'm trying to convert don't seem to be working like they do in the original version (the sound event works, but the script events seem to do nothing, and I think them failing is causing the interaction this animation is part of to repeat itself).

[Edit:] Have to update my question - I realized the converted animation doesn't play all the way through even with the events removed, so maybe the problem isn't that the events are broken but that the animation fails before it gets to them. I'm not sure how to debug an animation, though? All I can tell from playing it in-game (using the method from the coding snippets thread) is that it starts to play and then doesn't finish.
Advertisement
Senior Moderator
staff: senior moderator
#2 Old 30th Mar 2021 at 10:13 PM Last edited by zoe22 : 30th Mar 2021 at 10:31 PM.
I used script events for my washboard actually, so I might be able to help.
I did think about doing some kind of tutorial/info on it because I think there is very little out there, but I haven't been able to yet.

If the problem is with the animation though, I'm not totally sure what would be happening there. I would think that if there was a problem with it, it just wouldn't play rather than failing halfway.
Is it just one animation? Have you made sure it works in Blender and/or with the pose player mod?

It has been a while since I did it but this is all I think there is to adding a script event:
For the CLIP, add a Script event. The only thing that needs to be changed is the id and timecode.
Id is the hexadecimal version of what you use in the code. The EA interactions seem to use 101, 102 etc... but I don't know if there is a reason for that :p
Timecode is when in the interaction you want it to happen, so 0 for the beginning.

In the code, use 
Code:
AddOneShotScriptEventHandler(103u, OnAnimationEvent);
Where 103 is the in your clip (but in the clip it's the hex of that), and OnAnimationEvent is the function where you put what should happen.

The function should be something like:
Code:
private void OnAnimationEvent(StateMachineClient smc, IEvent evt)
{
//blah
}
and you can get the event id by doing evt.EventId so you could have multiple script events use the same function and just check which event it is. I think I got this from the hamper code (getting and putting away clothes)

And I think that's it...
(I realise you probably worked that out, but just in case, and in case someone else is wondering :P)
If you're using PlaySoloAnimation, I wonder if that's why the event wouldn't work, because maybe you need a StateMachineThingy? Not sure though, and that's if the issue isn't the animation itself of course.
Field Researcher
Original Poster
#3 Old 31st Mar 2021 at 12:18 AM Last edited by lizcandor : 31st Mar 2021 at 12:38 AM.
A tutorial on this would be awesome! I've just been digging through the archives trying to understand what people were doing in conversations from like 2013 Super educational eventually, but slow

Quote: Originally posted by zoe22
Id is the hexadecimal version of what you use in the code

Ohh, I was wondering why the Ids were different between the code and the CLIP! I've just been using the same ones as in the EA version, since I didn't understand enough to change anything.

I'm using PlaySoloAnimation when I try to test the animation by itself, and a state machine for the actual interaction - with PlaySoloAnimation, the sim starts to move into the right pose and then goes back to normal, and with the state machine it seems like the animation just gets totally skipped (I don't know if it's relevant, but the animation is really just a pose with events attached, it's the pose sims lie in while the Reaper turns them into a ghost).

The converted version looks correct in Blender, and it plays (stretched but otherwise fine) when I just export the original CLIP and then import that into my mod's package without changing anything but the name. But if I either convert it properly in Blender so it doesn't stretch, or just import the adult animation straight from the original CLIP onto the child rig and then export the "converted" pose from Blender without any changes but the name, it no longer plays. So it seems like it's probably at the Blender import/export stage that something's going wrong? I'll try the import/export with no actual changes thing on the adult rig too to see if it's something about the child rig in particular. [Edit:] Confirmed it's not just the child rig, going through Blender without changing anything breaks the adult animation as well.
Senior Moderator
staff: senior moderator
#4 Old 31st Mar 2021 at 1:22 PM
Quote:
the animation is really just a pose with events attached, it's the pose sims lie in while the Reaper turns them into a ghost  
The issue might then be that because it's just a keyframe, it's only playing so fast you can't even really see it? Unless you've made it longer like an animation with just the same positions all the way through?

Though one thing you might want to do is just check that the ulong value you use for the event id (so like 103u in the example I sent above) has the correct hexadecimal version in the CLIP, only because I noticed that one of the events for the hamper actually had the wrong event id in the code/clip so the event would never actually take place (though in the case of the hamper it wasn't an important event so either they never noticed it was wrong, or they didn't care :P) but maybe the one you copied from might have an issue like this.
Also you could try using a longer animation that you know plays normally, so you can verify that the actual script event thing is set up and working properly, and it's only the corpse pose/animation that needs to be fixed. 

If you want to send the package/some of the code and I could have a look and see if I can figure it out? But if you're having issues with the animation, then I think it would probably most helpful to try a different one, to make sure the event is actually working, and then go from there.
I do wonder though if events would even work with PlaySoloAnimation, because I think that AddOneShotScriptEventHandler(...) is probably related to the StateMachine, so that's also something to consider I guess :P
Field Researcher
Original Poster
#5 Old 31st Mar 2021 at 5:42 PM
Quote: Originally posted by zoe22
The issue might then be that because it's just a keyframe, it's only playing so fast you can't even really see it? Unless you've made it longer like an animation with just the same positions all the way through?

That was it! I just tried extending the pose with extra keyframes, and the animation sequence plays like it should now! The IK chains got a little weird but that should be fixable. Thank you!

I'm surprised using just one keyframe wasn't working here when it wasn't a problem for the other one-pose stage of the death sequence - maybe that's because the other pose didn't have any timed events attached, so it didn't matter? I also wonder now how the timing information got removed from this animation; it must happen on importing to Blender, but I don't get why.
Senior Moderator
staff: senior moderator
#6 Old 1st Apr 2021 at 8:23 PM
Maybe the events need to have enough time to trigger for them to happen?
Not sure if this is what you mean, but when you import a new clip, it does lose all events I believe :P

Glad it works though!
Back to top