Jump to content

Script that triggers an animation


Recommended Posts

I'm trying to make a potion trigger an animation (like stimpak does)

 

After going through hundreds of pages dedicated to scripts I managed to write this script but it wont's even save without an error (I would like to stick to animating but engine limitations (or just my limited knowledge of the engine.))

 

 

Event Oneffectstart (actor akTarget, actor akCaster)

If(akTarget == game.getPlayer())

utility.wait(0.2f)

akTarget.PlayIdle(XXXX)

EndIf

EndEvent

 

 

I don't know what the heck I'm doing, I just want to add my animation to my new potion, Help.

Edited by meysamkhr
Link to comment
Share on other sites

You could try adding a property for the player and then trigger the play idle on the player.

 

Actor property PlayerREF Auto

 

PlayerREF.playIdle(xxxx)

 

When adding properties you need to go into the properties dialogue in the script in ck and click auto fill to auto fill the player property

 

Also for the wait statement I use

wait(1.0)

 

This will wait one second real time.

 

Also I would use import statements to reduce your code writing

 

Scriptname xxxx extends xxxx

Import game

Import utility

Import debug

 

If you do those 3 import statements you can write code like this 'notification("xxxx")' instead of the 'debug.notification("xxxx")'

Link to comment
Share on other sites

Thank you for the reply, though there seem to be a problem in this line "PlayerRef.playIdle(X)" (no viable alternative at input '.')

 


Actor property PlayerREF Auto
PlayerRef.playIdle(X)


Event Oneffectstart (actor akTarget, actor akCaster)
If(akTarget == game.getPlayer())
utility.wait(1.0)
akTarget.PlayIdle(X)
EndIf
EndEvent

Link to comment
Share on other sites

Thank you for the reply, though there seem to be a problem in this line "PlayerRef.playIdle(X)" (no viable alternative at input '.')

 

Actor property PlayerREF Auto

PlayerRef.playIdle(X)

 

 

Event Oneffectstart (actor akTarget, actor akCaster)

If(akTarget == game.getPlayer())

utility.wait(1.0)

akTarget.PlayIdle(X)

EndIf

EndEvent

 

...Why are you calling Game.GetPlayer()? You've already got PlayerRef; a player property is 100x faster than using Game.GetPlayer().

 

And why are you calling PlayIdle() outside of the event?

Link to comment
Share on other sites

 

Thank you for the reply, though there seem to be a problem in this line "PlayerRef.playIdle(X)" (no viable alternative at input '.')

 

Actor property PlayerREF Auto

PlayerRef.playIdle(X)

 

 

Event Oneffectstart (actor akTarget, actor akCaster)

If(akTarget == game.getPlayer())

utility.wait(1.0)

akTarget.PlayIdle(X)

EndIf

EndEvent

 

...Why are you calling Game.GetPlayer()? You've already got PlayerRef; a player property is 100x faster than using Game.GetPlayer().

 

And why are you calling PlayIdle() outside of the event?

 

 

Cause I don't know what I'm doing. I just want to add my animations to the game. for weapon animations you can add them without scripts but I want them to play after using a potion.

 

It would've been nice if there was an assign animation thingy, but it has to be extra hard otherwise it's not fun. (or maybe there is an assign animation button that I don't know about somewhere)

Edited by meysamkhr
Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

I also wrote that script extremely fast cuz I had to go somewhere.

 

If you wanna see any syntax and how to use them go here. it's basically the api page for papyrus.

 

https://www.creationkit.com/fallout4/index.php?title=Category:Papyrus

Link to comment
Share on other sites

Attach that script to the potion object itself and when you activate the object it will activate.

 

I mainly do a event that I know works and how to activate said script first to make sure the code is working fine then I change the event later

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

  • Recently Browsing   0 members

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