Jump to content

Script that triggers an animation


Recommended Posts

 

 

I have wrote a script real fast, See if this works

 

 

Scriptname useAnimationOnPotionSCRIPT Extends ObjectReference

import game

import utility

import debug

 

Actor Property PlayerREF Auto

Idle Property AnimationToPlay Auto

 

Event OnActivate(ObjectReference akActionRef)

ÃÂ if(akActionRef == PlayerREF)

ÃÂ ÃÂ ÃÂ InputEnableLayer movementLayer = InputEnableLayer.Create()

ÃÂ ÃÂ ÃÂ wait(5.0) ;Wait a few seconds to make sure player has left inventory

ÃÂ ÃÂ ÃÂ movementLayer.EnableMovement(false)

ÃÂ ÃÂ ÃÂ PlayerREF.PlayIdle(AnimationToPlay)

ÃÂ ÃÂ ÃÂ wait(1)

ÃÂ ÃÂ ÃÂ movementLayer.EnableMovement(true)

ÃÂ ÃÂ ÃÂ PlayerREF.RemoveItem(self, 1) ;remove 1 potion from player inventory

ÃÂ endIf

EndEvent

ÃÂ

 

 

ÃÂ

No that, won't work. You cannot attach script directly on potion. You need to atach following script on magic effect that you then add to this potion.

ÃÂ

ÃÂ

This will do what you want. Create a new magic effect with Effect Archetype - Script, Casting type of Fire and Forget and Delivery - self. Then add new script on it and paste following script there.

Idle property myanimation Auto
Potion property mypotion Auto

Event Oneffectstart (actor akTarget, actor akCaster)
    akTarget.additem(mypotion,1,true)
    If(akTarget == game.getPlayer())
       utility.wait(1.0)
       akTarget.PlayIdle(myanimation)
     EndIf
EndEvent
Don't forget to fill myanimation and mypotion properties with needed idle and potion forms.

Then open your potioin and add that magic effect there. That's all.

Mine will work I specifically said you can change parts of it to make it work for a potion. I just didnt have time to do a full testing with magic effects. I maybe had like 5 minutes to make the script before I had to leave

 

 

Author said that he's not familiar with papyrus, so he cannot change parts of your code. It has wrong event and extra stuff which isn't needed, such as utility.wait, as playidle forces pipboy to close. Also if author calls animation file directly, that inputenablelayer is not needed as he can block player movement while animation is playing by calling dyn_activation, instead of dyn_activationAllowMovement anim event.

Edited by shavkacagarikia
Link to comment
Share on other sites

Thank you DarkWolfModding and

shavkacagarikia

I have two questions though:

 

1. Should I add the Idle to HumanRaceSubGraphData (Like weapon animations?) and if the answer is yes which category is for potions?Idle?

 

2. Is there a way to not specify the name of the potion in the script properties? because I want to attach my animation to 108 different potions and making 108 magic effects takes a lot of time.

 

Edit:

OK, adding it to the race menu didn't do anything

Edited by meysamkhr
Link to comment
Share on other sites

Thank youÃÂ ÃÂ DarkWolfModdingÃÂ ÃÂ ÃÂ ÃÂ andÃÂ ÃÂ shavkacagarikia

I have two questions though:

ÃÂ

1. Should I add the Idle to HumanRaceSubGraphData (Like weapon animations?) and if the answer is yes which category is for potions?Idle?

ÃÂ

2. Is there a way to not specify the name of the potion in the script properties? because I want to attach my animation to 108 different potions and making 108 magic effects takes a lot of time.

1) No, you add idle inside idle animations. That menu can be found under gameplay/animations. I suppose your idle is 3rd person, so look for raider root behavior graph, expand it, then add new child inside Loose section. Give it id, choose needed .hkx animation file and for anim event choose dyn_activation or dyn_activationAllowMovement if you want player to be able to move while idle is playing.

 

2) That potion property and line in script makes sure that you never ran out of the potion. If you don't specify the potion name in script then potion will be consumed on use like vanilla potions.

Edited by shavkacagarikia
Link to comment
Share on other sites

 

Thank youÃÂ ÃÂ DarkWolfModdingÃÂ ÃÂ ÃÂ ÃÂ andÃÂ ÃÂ shavkacagarikia

I have two questions though:

ÃÂ

1. Should I add the Idle to HumanRaceSubGraphData (Like weapon animations?) and if the answer is yes which category is for potions?Idle?

ÃÂ

2. Is there a way to not specify the name of the potion in the script properties? because I want to attach my animation to 108 different potions and making 108 magic effects takes a lot of time.

1) No, you add idle inside idle animations. That menu can be found under gameplay/animations. I suppose your idle is 3rd person, so look for raider root behavior graph, expand it, then add new child inside Loose section. Give it id, choose needed .hkx animation file and for anim event choose dyn_activation or dyn_activationAllowMovement if you want player to be able to move while idle is playing.

 

2) That potion property and line in script makes sure that you never ran out of the potion. If you don't specify the potion name in script then potion will be consumed on use like vanilla potions.

 

 

Thanks I thought Idle animations is a normal category in the CK (just like FO4 Edit) :)

 

My potions are consumable (Canteens)

Link to comment
Share on other sites

 

Â

Thank youÃÃÂ ÃÃÂ DarkWolfModdingÃÃÂ ÃÃÂ ÃÃÂ ÃÃÂ andÃÃÂ ÃÃÂ shavkacagarikia

I have two questions though:

ÃÃÂ

1. Should I add the Idle to HumanRaceSubGraphData (Like weapon animations?) and if the answer is yes which category is for potions?Idle?

ÃÃÂ

2. Is there a way to not specify the name of the potion in the script properties? because I want to attach my animation to 108 different potions and making 108 magic effects takes a lot of time.

1) No, you add idle inside idle animations. That menu can be found under gameplay/animations. I suppose your idle is 3rd person, so look for raider root behavior graph, expand it, then add new child inside Loose section. Give it id, choose needed .hkx animation file and for anim event choose dyn_activation or dyn_activationAllowMovement if you want player to be able to move while idle is playing.

 

2) That potion property and line in script makes sure that you never ran out of the potion. If you don't specify the potion name in script then potion will be consumed on use like vanilla potions.

Â

Â

Thanks I thought Idle animations is a normal category in the CK (just like FO4 Edit) :)

Â

My potions are consumable (Canteens)

If they are consumables, you can remove that Potion property and additem lines.

 

I don't use FO4 edit so don't know what you mean by idle animations is a normal category

Link to comment
Share on other sites

  • Recently Browsing   0 members

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