Wahnfried1883 Posted December 2, 2020 Share Posted December 2, 2020 Hi, I created an actor which can change its race via dialogue. Now I want to use a script on this actor which only fires when a specific race is set. This is the script which is working so far: Scriptname DLC2BurntSprigganFXScript extends ActorVisualEffect Property DLC2BurntSprigganParticlesE Autofloat Property baseGlow = 0.25 AutoRace Property SprigganBurntRace Autoauto state aliveEvent onLoad()RegisterForAnimationEvent(self, "MLh_SpellFire_Event")if (self.GetSleepState() == 3);hide glow for ambushself.SetSubGraphFloatVariable("ftoggleblend", 0.0)else ;no ambushDLC2BurntSprigganParticlesE.play(self, -1)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)endifEndeventEvent OnGetUp(ObjectReference akFurniture);ambush wake upDLC2BurntSprigganParticlesE.play(self, -1)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)EndEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)self.SetSubGraphFloatVariable("fDampRate", 0.6)self.SetSubGraphFloatVariable("ftoggleblend", 1.0)utility.wait(0.25)self.SetSubGraphFloatVariable("fDampRate", 0.05)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)EndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)if (akSource == self) && (asEventName == "MLh_SpellFire_Event")self.SetSubGraphFloatVariable("fDampRate", 0.6)self.SetSubGraphFloatVariable("ftoggleblend", 1.0);DLC2BurntSprigganParticlesE.play(self, 0.25)utility.wait(0.4)self.SetSubGraphFloatVariable("fDampRate", 0.05)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)endIfEndEventEvent onDying(actor myKiller)DLC2BurntSprigganParticlesE.stop(self)goToState("dead")EndEventendStatestate dead;do nothingendState What do I have to change so that the script fires only when a specific race is set? I tried something with the "GetRace()" function but I don't know where to put it and how. Any help is appreciated! Link to comment Share on other sites More sharing options...
dylbill Posted December 2, 2020 Share Posted December 2, 2020 (edited) For the Events that you want to fire only for your specific race, you put the condition If Self.GetRace() == SprigganBurntRace. Another way to do it, is if you want the entire script to only run if the actor is a certain race, you can use state changes, maybe on the OnLoad event. Event OnLoad() If Self.GetRace() == SprigganBurntRace GoToState("ActiveScript") Else GoToState("InactiveScript") EndIf EndEvent You would put that event in both the ActiveScript and InactiveScript states. Edited December 2, 2020 by dylbill Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 2, 2020 Share Posted December 2, 2020 Alternatively, set up a dedicated quest with a reference alias for the actor. Have the race specific code on the reference alias script. Start and stop said quest whenever the actor's race is changed via dialog. Link to comment Share on other sites More sharing options...
dylbill Posted December 2, 2020 Share Posted December 2, 2020 (edited) A third way, is if your actor dynamically changes race even when it's loaded, is you can put a new Spell Ability on your actor with the condition GetRace == SprigganBurntRace and put your script on that Abilities magic effect using the OnEffectStart event rather than the OnLoad event. That way, the script will run whenever it changes to the SprigganBurntRace. Edited December 2, 2020 by dylbill Link to comment Share on other sites More sharing options...
Wahnfried1883 Posted December 2, 2020 Author Share Posted December 2, 2020 I have changed the script as follows and it seems to work as intended. Hopefully everything is correct: Scriptname DLC2BurntSprigganFXScript extends ActorVisualEffect Property DLC2BurntSprigganParticlesE Autofloat Property baseGlow = 0.25 AutoRace Property SprigganBurntRace Autoauto state aliveEvent onLoad()If Self.GetRace() == SprigganBurntRaceRegisterForAnimationEvent(self, "MLh_SpellFire_Event")if (self.GetSleepState() == 3);hide glow for ambushself.SetSubGraphFloatVariable("ftoggleblend", 0.0)else ;no ambushDLC2BurntSprigganParticlesE.play(self, -1)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)endifendifEndeventEvent OnGetUp(ObjectReference akFurniture);ambush wake upIf Self.GetRace() == SprigganBurntRaceDLC2BurntSprigganParticlesE.play(self, -1)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)endifEndEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)If Self.GetRace() == SprigganBurntRaceself.SetSubGraphFloatVariable("fDampRate", 0.6)self.SetSubGraphFloatVariable("ftoggleblend", 1.0)utility.wait(0.25)self.SetSubGraphFloatVariable("fDampRate", 0.05)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)endifEndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)If Self.GetRace() == SprigganBurntRaceif (akSource == self) && (asEventName == "MLh_SpellFire_Event")self.SetSubGraphFloatVariable("fDampRate", 0.6)self.SetSubGraphFloatVariable("ftoggleblend", 1.0);DLC2BurntSprigganParticlesE.play(self, 0.25)utility.wait(0.4)self.SetSubGraphFloatVariable("fDampRate", 0.05)self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)endifendIfEndEventEvent onDying(actor myKiller)If Self.GetRace() == SprigganBurntRaceDLC2BurntSprigganParticlesE.stop(self)goToState("dead")endifEndEventendStatestate dead;do nothingendState Thank you very much to both of you! Link to comment Share on other sites More sharing options...
dylbill Posted December 2, 2020 Share Posted December 2, 2020 While that will work, it's not very performance friendly, because you're still checking for race for every one of those events. If you want to use the state change method, it would look something like this: Scriptname DLC2BurntSprigganFXScript extends Actor VisualEffect Property DLC2BurntSprigganParticlesE Autofloat Property baseGlow = 0.25 AutoRace Property SprigganBurntRace Auto Auto State Waiting Event onLoad() Utility.Wait(1) If Self.GetRace() == SprigganBurntRace GoToState("aliveActive") Else GoToState("aliveInactive") Endif EndEvent EndState state aliveActive Event OnUnload() GoToState("Waiting") EndEvent Event OnBeginState() RegisterForAnimationEvent(self, "MLh_SpellFire_Event") if (self.GetSleepState() == 3);hide glow for ambush self.SetSubGraphFloatVariable("ftoggleblend", 0.0) else ;no ambush DLC2BurntSprigganParticlesE.play(self, -1) self.SetSubGraphFloatVariable("ftoggleblend", baseGlow) endif Endevent Event OnGetUp(ObjectReference akFurniture);ambush wake up DLC2BurntSprigganParticlesE.play(self, -1) self.SetSubGraphFloatVariable("ftoggleblend", baseGlow) EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) self.SetSubGraphFloatVariable("fDampRate", 0.6) self.SetSubGraphFloatVariable("ftoggleblend", 1.0) utility.wait(0.25) self.SetSubGraphFloatVariable("fDampRate", 0.05) self.SetSubGraphFloatVariable("ftoggleblend", baseGlow) EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) if (akSource == self) && (asEventName == "MLh_SpellFire_Event") self.SetSubGraphFloatVariable("fDampRate", 0.6) self.SetSubGraphFloatVariable("ftoggleblend", 1.0) ;DLC2BurntSprigganParticlesE.play(self, 0.25) utility.wait(0.4) self.SetSubGraphFloatVariable("fDampRate", 0.05) self.SetSubGraphFloatVariable("ftoggleblend", baseGlow) endif EndEvent Event onDying(actor myKiller) DLC2BurntSprigganParticlesE.stop(self) goToState("dead") EndEventendState State aliveInactive Event OnUnload() GoToState("Waiting") EndEvent Event OnBeginState() UnRegisterForAnimationEvent(self, "MLh_SpellFire_Event") EndEvent Event OnGetUp(ObjectReference akFurniture) EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked) EndEvent Event OnAnimationEvent(ObjectReference akSource, String asEventName) EndEvent Event OnDying(actor myKiller) GoToState("dead") EndEvent EndState state dead;do nothingendState Link to comment Share on other sites More sharing options...
Wahnfried1883 Posted December 2, 2020 Author Share Posted December 2, 2020 I tried your script as you suggested and it works like a charm. Again, thanks for your help! Link to comment Share on other sites More sharing options...
dylbill Posted December 2, 2020 Share Posted December 2, 2020 No problem, happy modding! Link to comment Share on other sites More sharing options...
Wahnfried1883 Posted December 2, 2020 Author Share Posted December 2, 2020 (edited) @ dylbill Hm, after some testing with your script, I found out that the animation events will stop when I switch to another race first and then back to the desired spriggan race. What could be wrong? Edited December 2, 2020 by Wahnfried1883 Link to comment Share on other sites More sharing options...
Wahnfried1883 Posted December 2, 2020 Author Share Posted December 2, 2020 A third way, is if your actor dynamically changes race even when it's loaded, is you can put a new Spell Ability on your actor with the condition GetRace == SprigganBurntRace and put your script on that Abilities magic effect using the OnEffectStart event rather than the OnLoad event. That way, the script will run whenever it changes to the SprigganBurntRace. So, I tried the method above and created a Spell Ability but I don't know how to set up the OnEffectStart event rather than the OnLoadEvent on the Magic Effect. As soon as I change that the original script extends ActiveMagicEffect, the script won't compile anymore... Link to comment Share on other sites More sharing options...
Recommended Posts