Jump to content

[LE] Need help with a script that checks actors race


Recommended Posts

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 Actor

VisualEffect Property DLC2BurntSprigganParticlesE Auto
float Property baseGlow = 0.25 Auto
Race Property SprigganBurntRace Auto

auto state alive
Event onLoad()
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")
EndEvent
endState

state dead
;do nothing
endState

 

 

 

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

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

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

I have changed the script as follows and it seems to work as intended. Hopefully everything is correct:

 

 

Scriptname DLC2BurntSprigganFXScript extends Actor

VisualEffect Property DLC2BurntSprigganParticlesE Auto
float Property baseGlow = 0.25 Auto
Race Property SprigganBurntRace Auto

auto state alive
Event onLoad()
If Self.GetRace() == SprigganBurntRace
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
endif
Endevent

Event OnGetUp(ObjectReference akFurniture);ambush wake up
If Self.GetRace() == SprigganBurntRace
DLC2BurntSprigganParticlesE.play(self, -1)
self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)
endif
EndEvent


Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
If Self.GetRace() == SprigganBurntRace
self.SetSubGraphFloatVariable("fDampRate", 0.6)
self.SetSubGraphFloatVariable("ftoggleblend", 1.0)
utility.wait(0.25)
self.SetSubGraphFloatVariable("fDampRate", 0.05)
self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)
endif
EndEvent



Event OnAnimationEvent(ObjectReference akSource, string asEventName)
If Self.GetRace() == SprigganBurntRace
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
endIf
EndEvent

Event onDying(actor myKiller)
If Self.GetRace() == SprigganBurntRace
DLC2BurntSprigganParticlesE.stop(self)
goToState("dead")
endif
EndEvent
endState

state dead
;do nothing
endState

 

 

Thank you very much to both of you!

Link to comment
Share on other sites

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 Auto
float Property baseGlow = 0.25 Auto
Race 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")
EndEvent
endState
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 nothing
endState

Link to comment
Share on other sites

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

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

  • Recently Browsing   0 members

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