Jump to content

SKSE - Register Custom Animation Events


Recommended Posts

View File

INTRODUCTION

 

This SKSE plugin allows registering custom animation events on ObjectReferences.
Pretty much like the existing Form.RegisterForAnimationEvent, but not limited to
the vanilla animation events.

 

I might need to run papyrus code triggered by animations called from arbitrary
mods. I thought it was not possible registering custom animations, until I found
these amazing work: https://github.com/towawot/DLL-GunsmithSystem

 

================================================================================

 

INSTALLATION

 

Copy the contents of the Data folder into Skyrim\Data
Or use any mod manager.

 

================================================================================

 

USAGE

 

Register animation events, for a specific object reference or globally.
For example:

 

; registers the animation only for the player
RCAE.RegisterForAnimEventOnRef(Game.GetPlayer(), "MyAnimationEvent")

 

; registers another animation for any character
RCAE.RegisterForAnimEvent("AnotherSexyAnimation")

 

Then an OnAnimationEventEX callback event is called whenever a reference plays
the registered animation event. This event has some restrictions, read the notes

 

Event OnAnimationEventEX(ObjectReference akSource, string asEventName)
if akSource == Game.GetPlayer() && asEventName == "MyAnimationEvent"
...
endIf
EndEvent

 

================================================================================

 

NOTES

 

- Won't work on ObjectReferences that are not actors. I think it could, but
currently is hardcoded just for actors (NPC or player)

 

- The OnAnimation Event callback only seems to work when its script points to
the player character. Actually I'm not sure on this.
I've successfully tested the callback on ReferenceAlias and ActiveMagicEffect
scripts, both pointing to the player.
The callback is not called if it's on a quest script, neither on a NPC's
ActiveMagicEffect.
I think this is because the player character is being used as a base object when
the SKSE plugin sends the event to Papyrus.

 

- The stuff registered is stored in memory and is lost when the game is closed

 

================================================================================

 

CREDITS

 

- towawot for https://github.com/towawot/DLL-GunsmithSystem

 

- himika for https://github.com/himika/libSKSE

 

- SKSE Team for http://skse.silverlock.org/

================================================================================

CHANGE LOG

v02: Added thread safety
v01: Initial release


 

Link to comment

Thank you for this. I will become handy.

 

When you, in your notes, say: "The callback is not called if it's on a quest script, neither on a NPC's ActiveMagicEffect"

It means that for NPCs it is called only for scripts attached to Actors or ObjectReferences or ReferenceAliases?

 

 

Link to comment

The OnAnimationEventEX is not fired unless it is in a script pointing to the player, which is not the case on quest scripts or NPC's activemagiceffects.

 

So you need a ReferenceAlias script pointing to the player, or something like that, or the OnAnimationEventEX won't be called.

The event triggers for any NPC that performs the registered animation.

Link to comment

Cool - but I need two events : one when an animation starts and the second (more important) when the animation has finished.


And a suggestion for a very cool enhancement:

Add the functionality to pass a global variable that is set to 1 (true) if the event has fired

 

Because then we can use it in scene and package action conditions to wait until an animation has started / finished

(I know - can be done by modder in script, but is a very frequent use case)

Link to comment

Um, I think I misunderstood but does this kind of help during the NSAP Object Animations(Throne,Chair and the like in MCM) ?

 

I am not a modder so yeah I dont really know.

 

No. That will not help.

 

The stickiness of AnimObjects is a different matter.

 

B3lisario plug-in is a way to get a script event when an animation event is fired.

 

With FNIS 5+, you can add to the HKX animation events.

And I am checking if, when such animation plays, and the anim event is supposed to be fired, then the mod event is sent.

 

For a very first test, on the player it works just fine.

But I am not able (yet) to catch the events for a NPC.

 

Probably I need to develop a "manager script", attached to the player, to keep track of events sent for other NPCs.

Link to comment

 

Um, I think I misunderstood but does this kind of help during the NSAP Object Animations(Throne,Chair and the like in MCM) ?

 

I am not a modder so yeah I dont really know.

 

No. That will not help.

 

The stickiness of AnimObjects is a different matter.

 

B3lisario plug-in is a way to get a script event when an animation event is fired.

 

With FNIS 5+, you can add to the HKX animation events.

And I am checking if, when such animation plays, and the anim event is supposed to be fired, then the mod event is sent.

 

For a very first test, on the player it works just fine.

But I am not able (yet) to catch the events for a NPC.

 

Probably I need to develop a "manager script", attached to the player, to keep track of events sent for other NPCs.

 

 

I see, that's quite interesting.

Link to comment

This might be not what most of ppl. want to hear. Hope you are planning to add some thread safety as I noticed global variables in the code

Thanks for noticing the problem.

I've added some ICriticalSection things

Please let me know if this would be safe enough.

Link to comment

 

This might be not what most of ppl. want to hear. Hope you are planning to add some thread safety as I noticed global variables in the code

Thanks for noticing the problem.

I've added some ICriticalSection things

Please let me know if this would be safe enough.

 

Thanks, it looks safe enough

Link to comment
  • 2 weeks later...

Well there is a mod I want to try out that requires this mod. So to install you just use MO or NMM and that's it? Just making sure since there is no install instructions listed.

 

There's also some files outside the Data directory as well, so should MO users be setting "DATA" as the data directory during installation, or instead simply click "ok" and set the mod to "ignore missing data"?

Link to comment
  • 2 weeks later...
  • 2 months later...

I'm not sure if I've properly reported this behavior here, but in case I didn't -- my khajiit SoS addon schlongs catch the SOS animation events so as to swap genital meshes. I don't touch the page up/down keybindings at all. Nonetheless, for some reason, my mod breaks page up/down in the console. SOS of course uses those to control schlongs--but they only break when my mod is catching the events. I have no idea why this is happening or even how to start looking--maybe you can figure out what's going on on your end.

Link to comment
  • 1 year later...
  • 4 months later...
  • 1 month later...
  • 2 months later...

Not too sure if this is still in development, though the Hoodie Schlong and so does the SOSFloppy mod use it, but after disabling the SOSFloppy mod from using the RCAE and me manually removing the dll from the plugins folder, the 1 second freeze of the game at random times (~10 seconds) vanished, a shame as I was hoping it would work, but it seems to be behind the times for current mods, or the other mod was causing grief with it.  Hopefully someone is still around that works on this code, can look into this.

 

GuruSR.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use