Jump to content

Activator animations


Recommended Posts

Hi people, I have a little problem with activators. I'm making a mod that adds craftable cloud containers, which can be accessed from everywhere. I made an activator with a trunk model, and added this script to it:

Scriptname SharedContainerScript extends ObjectReference

ObjectReference property LinkedChest auto mandatory

Event OnActivate(ObjectReference Activator)
	BlockActivation(true)
	PlayAnimationAndWait("open","done")
	LinkedChest.Activate(Game.GetPlayer())
	PlayAnimationAndWait("close","done")
	BlockActivation(false)
EndEvent

When I activate it, it should play an openning animation, then open the container inventory, and then play the closing animation. However, it doesn't work that way. When I activate it, the container inventory appears inmediately, while the activator plays the the openning animation. I need to activate it again for it to play the closing animation. This is the default activator behavior (they work as toggled switches) but I want to override it with my script. What am I doing wrong?

Link to comment
Share on other sites

Bump. I still couldn't find a solution. I tried using "opened" and "closed" instead of "done". I also tried using MyActivator.PlayAnimationAndWait(), but nothing works. For some reason the game is ignoring the PlayAnimationAndWait line. Any ideas?

Link to comment
Share on other sites

You will want to check to see if your PlayAnimationAndWait lines return true or false. Something like this:

 

Scriptname SharedContainerScript extends ObjectReference

ObjectReference property LinkedChest auto mandatory

Event OnActivate(ObjectReference Activator)
	BlockActivation(true)
	if (PlayAnimationAndWait("open","done") == true)
		RegisterForMenuOpenCloseEvent("ContainerMenu")
		LinkedChest.Activate(Game.GetPlayer())
	else
		; something went wrong here, activate anyway.
		LinkedChest.Activate(Game.GetPlayer())
	endif
	BlockActivation(false)
EndEvent

Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening)
	if (asMenuName== "ContainerMenu")
		if (abOpening == false)
			PlayAnimationAndWait("close","done")
		endif
	endif
endEvent
Link to comment
Share on other sites

I tried adding that conditional block, but it always returns false. Something must be wrong with the parameters. Isn't there a way to see animation event names for all the game models? The creation kit has a window called "Animations", but it only shows character animations... I opened the trunk model in NifScope, and there three nodes (or whatever they are called): "Open", "Close" and "Openclose". I guess those are the animations, but they don't work anyway.

Link to comment
Share on other sites

I tried adding that conditional block, but it always returns false. Something must be wrong with the parameters. Isn't there a way to see animation event names for all the game models? The creation kit has a window called "Animations", but it only shows character animations... I opened the trunk model in NifScope, and there three nodes (or whatever they are called): "Open", "Close" and "Openclose". I guess those are the animations, but they don't work anyway.

My guess would be you want them to match the case of the animation names / strings. So "Open" instead of "open".
Link to comment
Share on other sites

I tried that, but it didn't work. Apparently, it's not taking "open" and "close" as valid animation events. I also tried this legacy function, PlayGamebryoAnimation, which uses nif based animation names, but it has another problem. Once the animation ends, it freezes, and won't play any other animation. I'm running out of ideas :confused:

Link to comment
Share on other sites

AFAIK a NIF needs to have a BehaviorGraph (BGED) if you want to use PlayAnimantion(AndWait). If this is missing only PlayGamebryoAnimation will work.

You will find the animation names in the NIF too. Open the NiControllermanager section. There shoul be at least one NiControllerSequence section. The fist TXT entry (Name) is the name of the animation.

Anyway, is there a reason to use an Activatior instead of a container? Yust curious ;-)

 

(Edit:) There is not neccessarily a NiControllermanager section if the NIF has a BGED. Maybe you will find the anim-names in the Behavior Graph File.

Edited by deadbeeftffn
Link to comment
Share on other sites

I couldn't find anything like a BehaviorGraph, this nif only has a NiControllermanager. I tried using PlayGamebryoAnimation like this:

Scriptname SharedContainerScript extends ObjectReference

ObjectReference property LinkedChest auto mandatory

Event OnActivate(ObjectReference Activator)
	BlockActivation(true)
	If self.PlayGamebryoAnimation("open", abStartOver = true)
		Utility.Wait(1)
	EndIf
	LinkedChest.Activate(Game.GetPlayer())
	If self.PlayGamebryoAnimation("close", abStartOver = true)
		Utility.Wait(0.5)
	EndIf
	BlockActivation(false)
EndEvent

But it doesn't work. When I activate the trunk, it plays the open animation, but freezes there, and won't play any other animation until I reset it with disable/enable. I tried many combinations of parameters, with startover = true, easeintime = 1.0, etc, but nothing works. I guess that function is deprecated in Fallout 4, or perhaps this game just hates me. I can't belive it's so hard to do something so simple. I would leave it without animation, but I don't even know how to do that, because if I don't add any animation function, the trunk works like a toggled switch (it opens the first time I activate it, and closes the next time). This is getting on my nerves.

About your question, I need it to be an activator because the real container is hidden in a closed cell. This allows me to build many fake chest activators, and all of them will open the same shared inventory.

Link to comment
Share on other sites

I didn't find a solution either. :sad: The close anim won't play. I've used PlayGamebryoAnimation() in some mods and it works fine. Don't know, if it is deprecated though.

However, i found a different approach to implement this "my container is everywhere". It uses standard containers (with additional keyword) and doesn't need a hidden one. The contents will be copied to the container nearest to the player.

Sine this is your idea, i will not publish this mod :no: Let me know, if you want the source.

Link to comment
Share on other sites

Yeah, I don't know why that function is not working. It works only the first time it's executed, but after that, it throws this error in the papyrus log:

 

[ (0019D36B)].ObjectReference.PlayGamebryoAnimation() - "<native>" Line ?
(0019D36B): has no 3d and cannot have an animation played on it.

No idea why, but I'm giving up on it. If your method with keywords works then go ahead and publish it. This was mostly for personal use, since I always play in survival, and it's kinda tedious having to move to the settlement with all my stuff.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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