Jump to content

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


Recommended Posts

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.

 

I set up a new quest with a reference alias for the actor only and put my script on the alias. I then in my other quest which contains the entire dialogue for the race changes, I tried to start and stop the new quest as you suggested, but nothing works. I tried several conditions on the dialogue lines as well I added a code fragment that should start and stop the quest, but nothing works. How do I start and stop the new quest? Starting the new quest via console has also no effect. What I'm doing wrong?

Edited by Wahnfried1883
Link to comment
Share on other sites

Yes, I tested it on a new game (and a saved game that has never seen the mod before). Nothing works. I created a new quest, without any other conditions/quest stages etc, this time "start game enabled" and created the .seq file but to no avail. The script on the alias simply doesn't work. Do I have to change something in my script because it's an Actor Script?

Edited by Wahnfried1883
Link to comment
Share on other sites

If you're going to use it on an ability you need to use the target actor instead of self, like so:

 

 

 

Scriptname DLC2BurntSprigganFXScript extends ActiveMagicEffect
VisualEffect Property DLC2BurntSprigganParticlesE Auto
float Property baseGlow = 0.25 Auto
Race Property SprigganBurntRace Auto
Actor Target
auto state alive
Event OnEffectStart(Actor akTarget, Actor akCaster)
Target = akTarget
RegisterForAnimationEvent(akTarget, "MLh_SpellFire_Event")
if (akTarget.GetSleepState() == 3);hide glow for ambush
akTarget.SetSubGraphFloatVariable("ftoggleblend", 0.0)
else ;no ambush
DLC2BurntSprigganParticlesE.play(akTarget, -1)
akTarget.SetSubGraphFloatVariable("ftoggleblend", baseGlow)
endif
Endevent
Event OnGetUp(ObjectReference akFurniture);ambush wake up
If Target.GetRace() == SprigganBurntRace
DLC2BurntSprigganParticlesE.play(Target, -1)
Target.SetSubGraphFloatVariable("ftoggleblend", baseGlow)
endif
EndEvent
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
Target.SetSubGraphFloatVariable("fDampRate", 0.6)
Target.SetSubGraphFloatVariable("ftoggleblend", 1.0)
utility.wait(0.25)
Target.SetSubGraphFloatVariable("fDampRate", 0.05)
Target.SetSubGraphFloatVariable("ftoggleblend", baseGlow)
EndEvent
Event OnAnimationEvent(ObjectReference akSource, string asEventName)
if (akSource == Target) && (asEventName == "MLh_SpellFire_Event")
Target.SetSubGraphFloatVariable("fDampRate", 0.6)
Target.SetSubGraphFloatVariable("ftoggleblend", 1.0)
;DLC2BurntSprigganParticlesE.play(Target, 0.25)
utility.wait(0.4)
Target.SetSubGraphFloatVariable("fDampRate", 0.05)
Target.SetSubGraphFloatVariable("ftoggleblend", baseGlow)
endIf
EndEvent
Event onDying(actor myKiller)
DLC2BurntSprigganParticlesE.stop(Target)
goToState("dead")
EndEvent
endState
state dead
;do nothing
endState

If you're using it on a reference alias, you would use self.GetActorRef() instead of self.
Link to comment
Share on other sites

From time to time its a good idea to go a step back.

 

The scriptname you posted

Scriptname DLC2BurntSprigganFXScript extends Actor

looks like from dragonborn DLC2, but the original is that:

 

log file errors was that

 

[12/15/2013 - 09:47:12PM] error: Unable to call Is3DLoaded
- no native object bound to the script object, or object is of incorrect type
stack:
[<NULL form> (0303A5F7)].DLC2BurtSpigganFXScript.Is3DLoaded() - "<native>" Line ?
[<NULL form> (0303A5F7)].DLC2BurtSpigganFXScript.OnGetUp() - "DLC2BurtSpigganFXScript.psc" Line ?
[12/15/2013 - 09:47:12PM] warning: Assigning None to a non-object variable named "::temp6"
stack:
[<NULL form> (0303A5F7)].DLC2BurtSpigganFXScript.OnGetUp() - "DLC2BurtSpigganFXScript.psc" Line ?

 

 

 

DLC2BurtSpigganFXScript

 

Scriptname DLC2BurtSpigganFXScript extends Actor


VisualEffect Property DLC2BurntSprigganParticlesE Auto
float Property baseGlow = 0.25 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

 

 

 

As you can see it was a typo in the original DLC2 script. I assume you play with Skyrim LE (32-bit) and not with Skyrim SE (64-bit), because you posted your question to the Skyrim forum.

I think the next script code could help. Keep in mind it's essential to have an unique and easy to undertsand scriptname.

 

wafDLC2BurntSpigganFXActorScript

 

Scriptname wafDLC2BurntSpigganFXActorScript extends Actor
; https://forums.nexusmods.com/index.php?/topic/9354838-need-help-with-a-script-that-checks-actors-race/

  VisualEffect PROPERTY DLC2BurntSprigganParticlesE auto
  Float        PROPERTY baseGlow = 0.25             auto

  Race PROPERTY SprigganBurntRace auto        ; *** added for this new script, has to be filled by CK


; -- FUNCTION --

FUNCTION myF_SubGraph(Float f)
;-----------------------------
    self.SetSubGraphFloatVariable("fDampRate", 0.6)
    self.SetSubGraphFloatVariable("ftoggleblend", 1.0)
    Utility.Wait(f)
    self.SetSubGraphFloatVariable("fDampRate", 0.05)
    self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)

IF (self.GetState() == "busy")
    gotoState("alive")                ; ### STATE ###    OnDying() is not called
ENDIF
ENDFUNCTION


; -- EVENTs --

EVENT OnInit()  ; *** added for this script
    race r = self.GetRace()
    Debug.Trace("OnInit(" + r + ") - is called for actor " +self)                        ; info only

    IF (r == SprigganBurntRace)
        gotoState("alive")            ; ### STATE ###
    ELSE
        gotoState("Halt")            ; ### STATE ###    new state to avoid any visual trouble
;;;        DLC2BurntSprigganParticlesE.stop(self)
;;;        UnRegisterForAnimationEvent(self, "MLh_SpellFire_Event")
    ENDIF
ENDEVENT


EVENT OnRaceSwitchComplete()  ; *** added for this script
    race r = self.GetRace()
    Debug.Trace("OnRaceSwitchComplete(" + r + ") - is called for actor " +self)            ; info only

    IF (r == SprigganBurntRace)
        gotoState("alive")            ; ### STATE ###
    ELSE
        gotoState("Halt")            ; ### STATE ###    new state to avoid any visual trouble
        DLC2BurntSprigganParticlesE.stop(self)
        UnRegisterForAnimationEvent(self, "MLh_SpellFire_Event")
    ENDIF
ENDEVENT

;======================================
state Halt  ; *** added for this script
;=========
endState


EVENT OnDying(Actor akKiller)
    gotoState("dead")                ; ### STATE ###
    DLC2BurntSprigganParticlesE.stop(self)
    UnRegisterForAnimationEvent(self, "MLh_SpellFire_Event")
ENDEVENT


;======================================
auto state alive
;===============
EVENT OnReset()        ; Added by ReDragon 2015, to see what is happen here
    Debug.Trace(self+" OnReset() - has been reached..")
ENDEVENT


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 OnAnimationEvent(ObjectReference akSource, String asEventName)
IF (asEventName == "MLh_SpellFire_Event")
ELSE
    RETURN    ; - STOP -    wrong event name
ENDIF
;---------------------
IF (akSource == (self as ObjectReference))
    gotoState("busy")                ; ### STATE ###
    myF_SubGraph(0.4)
ENDIF
ENDEVENT


EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProj, Bool b1, Bool b2, Bool b3, Bool b4)
    gotoState("busy")                ; ### STATE ###
    myF_SubGraph(0.25)
ENDEVENT


EVENT OnGetUp(ObjectReference akFurniture)                ; ambush wake up
IF self.GetBaseObject()
ELSE
    gotoState("dead")                ; ### STATE ###
    Debug.Trace("DLC2BurtSprigganFX: OnGetUp() - Error: RefID is invalid..  selfActor = " +self+ ", furniture = " +akFurniture)
    RETURN    ; - STOP -
ENDIF
;---------------------
IF self.IsDisabled()
    RETURN    ; - STOP -    should not be awaken
ENDIF
;---------------------
;;;IF self.Is3DLoaded()                                    ; ### UDBP 1.0.2 ### 3D load check
    DLC2BurntSprigganParticlesE.play(self, -1)
    self.SetSubGraphFloatVariable("ftoggleblend", baseGlow)
;;;ENDIF
ENDEVENT
;=======
endState


;======================================
state busy
;=========
endState


;======================================
state dead
;=========
EVENT OnDying(Actor akKiller)
ENDEVENT
;=======
endState

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Thanks for the hint. Yes, I'm fiddling around with the original script and I had the intention to change the script name for my mod anyway. Actually, I'm playing with Skyrim SE 64-Bit, and I accidently posted in the wrong forum. I don't know if there is a way to move topics...

 

I'll try your script out. Many thanks for your help!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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