Vader666 Posted October 11, 2016 Posted October 11, 2016 Hi, Im trying to get a Script to work that should call a Property when a specific MagicEffect is applied to an Actor through a Potion. The Problem is everything i tried lead me either to compile errors or a Script that does nothing... Basically my Script looks like this : Scriptname MyScript extends Actor Function RegisterForMagicEffectApplyEvent(ScriptObject akTarget, ScriptObject akCasterFilter = None, Form akEffectFilter = None, \ bool abMatch = true) native Event OnMagicEffectApply(ObjectReference akTarget, ObjectReference akCaster, MagicEffect akEffect) Game.Getplayer().Playidle(MyAnimation) EndEvent Idle Property MyAnimation Auto Const What i ( mainly ) dont get is, how do i Register for a specific MagicEffect ? Trying even things like this : ; Register for when the player has any effects applied to him RegisterForMagicEffectApplyEvent(Game.GetPlayer()) Leads to " (4,33) no viable alternative at input '(' " Then how do i let the OnMagicEffectApply know which Actor is the target ? Is it just Event OnMagicEffectApply(ObjectReference akTarget, ObjectReference akCaster, MagicEffect akEffect) akTarget = Game.Getplayer() Game.Getplayer().Playidle(MyAnimation) EndEvent ? The akEffect could stay none i guess, because i (will) Register(ed) for a specific MagicEffect ? And finally to which object should i attach the Script ? the Player, the MagicEffect or somewhere completly different ? I don´t get the whole concept of this stuff...
ag12 Posted October 12, 2016 Posted October 12, 2016 Hi, Im trying to get a Script to work that should call a Property when a specific MagicEffect is applied to an Actor through a Potion. The Problem is everything i tried lead me either to compile errors or a Script that does nothing... Basically my Script looks like this : Scriptname MyScript extends Actor Function RegisterForMagicEffectApplyEvent(ScriptObject akTarget, ScriptObject akCasterFilter = None, Form akEffectFilter = None, \ bool abMatch = true) native Event OnMagicEffectApply(ObjectReference akTarget, ObjectReference akCaster, MagicEffect akEffect) Game.Getplayer().Playidle(MyAnimation) EndEvent Idle Property MyAnimation Auto Const What i ( mainly ) dont get is, how do i Register for a specific MagicEffect ? Trying even things like this : ; Register for when the player has any effects applied to him RegisterForMagicEffectApplyEvent(Game.GetPlayer()) Leads to " (4,33) no viable alternative at input '(' " Then how do i let the OnMagicEffectApply know which Actor is the target ? Is it just Event OnMagicEffectApply(ObjectReference akTarget, ObjectReference akCaster, MagicEffect akEffect) akTarget = Game.Getplayer() Game.Getplayer().Playidle(MyAnimation) EndEvent ? The akEffect could stay none i guess, because i (will) Register(ed) for a specific MagicEffect ? And finally to which object should i attach the Script ? the Player, the MagicEffect or somewhere completly different ? I don´t get the whole concept of this stuff... Is there anything that keeps you from running a script on the potion instead? I personally would prefer it that way. http://www.creationkit.com/fallout4/index.php?title=OnEffectStart_-_ActiveMagicEffect Idle Property myAnimation Auto Event OnEffectStart(Actor akTarget, Actor akCaster) if akTarget == Game.GetPlayer() akTarget.PlayIdle(myAnimation) endif endEvent Create a new MagicEffect, set it to script and add that code snipped from above to it's script. Then create your potion and add the MagicEffect that you just created. Don't forget to set the property myAnimation to whatever Idle you want to play. This is by far the better solution, because it runs only once and precisely when needed -> at the moment the potion is being drunken and the Effect is applied. You version, even if I were to correct the scripting errors, is like building a radar station to find something when the thing you're trying to find has a tracker that you can use. However, your script doesn't compile, because you're calling a function in the void. You can only call functions inside Events. For testing purposes, you could call your Register function inside Event OnInit(), which runs when the script is first initialized. Still, you'd need to recall the Register on quite some occasions, like loading games etc. So please try to use a MagicEffect instead of the complicated heavier workload way. And keep in mind: functions can't be called in the Void. Also, an Event returns parameters. You don't want to write the parameters inside an event, you'll want to read them.
Vader666 Posted October 12, 2016 Author Posted October 12, 2016 Is there anything that keeps you from running a script on the potion instead? The Scripts dropdown menu in the potion form stays completly blank, the button next to it does nothing. Im not sure if i set up the Potion in a wrong way or whatever is causing this. I will look at this again, this would be definitly a better way to do it. Event OnEffectStart This changes everything... i was searching the CK wiki for like 5 hours, how did i miss that... In the meantime i found out that doing it with a Holotape / Terminal is by far not that complicated than i tought, therfore i got it working this way. Anyway i will take a look at this stuff again Thanks !
Recommended Posts
Archived
This topic is now archived and is closed to further replies.