meysamkhr Posted July 10, 2017 Share Posted July 10, 2017 (edited) 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) EndIfEndEvent I don't know what the heck I'm doing, I just want to add my animation to my new potion, Help. Edited July 10, 2017 by meysamkhr Link to comment Share on other sites More sharing options...
DarkWolfModding Posted July 10, 2017 Share Posted July 10, 2017 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 usewait(1.0) This will wait one second real time. Also I would use import statements to reduce your code writing Scriptname xxxx extends xxxxImport gameImport utilityImport 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 More sharing options...
meysamkhr Posted July 10, 2017 Author Share Posted July 10, 2017 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 AutoPlayerRef.playIdle(X)Event Oneffectstart (actor akTarget, actor akCaster) If(akTarget == game.getPlayer()) utility.wait(1.0) akTarget.PlayIdle(X) EndIfEndEvent Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 10, 2017 Share Posted July 10, 2017 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 AutoPlayerRef.playIdle(X) Event Oneffectstart (actor akTarget, actor akCaster) If(akTarget == game.getPlayer()) utility.wait(1.0) akTarget.PlayIdle(X) EndIfEndEvent ...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 More sharing options...
meysamkhr Posted July 10, 2017 Author Share Posted July 10, 2017 (edited) 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 AutoPlayerRef.playIdle(X) Event Oneffectstart (actor akTarget, actor akCaster) If(akTarget == game.getPlayer()) utility.wait(1.0) akTarget.PlayIdle(X) EndIfEndEvent ...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 July 10, 2017 by meysamkhr Link to comment Share on other sites More sharing options...
DarkWolfModding Posted July 10, 2017 Share Posted July 10, 2017 I have wrote a script real fast, See if this works Scriptname useAnimationOnPotionSCRIPT Extends ObjectReferenceimport gameimport utilityimport debugActor Property PlayerREF AutoIdle Property AnimationToPlay AutoEvent 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 endIfEndEvent Link to comment Share on other sites More sharing options...
DarkWolfModding Posted July 10, 2017 Share Posted July 10, 2017 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 More sharing options...
DarkWolfModding Posted July 10, 2017 Share Posted July 10, 2017 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 More sharing options...
shavkacagarikia Posted July 10, 2017 Share Posted July 10, 2017 I have wrote a script real fast, See if this works Scriptname useAnimationOnPotionSCRIPT Extends ObjectReferenceimport gameimport utilityimport debug Actor Property PlayerREF AutoIdle 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 endIfEndEvent 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 More sharing options...
DarkWolfModding Posted July 10, 2017 Share Posted July 10, 2017 I have wrote a script real fast, See if this works Scriptname useAnimationOnPotionSCRIPT Extends ObjectReferenceimport gameimport utilityimport debug Actor Property PlayerREF AutoIdle 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ÃÂ endIfEndEventÃÂ ÃÂ 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 More sharing options...
Recommended Posts