Jump to content

[LE] Help with a script


Recommended Posts

Hi! I've recently found and edited a script, which should place a shade upon Targets death. The problem is that it places two shades instead of one. I think that the problem may be related to placeatme, but im not sure.

 

Scriptname DrainShadeSCRIPT extends ActiveMagicEffect  


ACTORBASE PROPERTY necroLord AUTO
EXPLOSION PROPERTY necroExplosion AUTO


; //////////
; //ASH PILE VARIABLES
; //////////
float property fDelay = 0.75 auto
{time to wait before Spawning Ash Pile}
float property fDelayEnd = 1.75 auto
{time to wait before Removing Base Actor}
float property ShaderDuration = 0.00 auto
{Duration of Effect Shader.}
Activator property pDefaultAshPile1 auto
{The object we use as a pile.}
Bool property bSetAlphaZero = True auto
{The Effect Shader we want.}
FormList Property pDisintegrationMainImmunityList auto
{If the target is in this list, they will not be disintegrated.}


race VictimRace
ACTOR victim
bool TargetIsImmune = True


EVENT onEffectStart(Actor akTarget, Actor akCaster)
victim = akTarget


endEVENT


EVENT onDying(ACTOR akkiller)
victim.placeAtMe(necroExplosion)
createAshPile()
utility.wait(0.1)
victim.placeactoratme(necrolord, 1)


endEVENT


FUNCTION createAshPile()


; //check to see if the target is in the immunity list
IF(pDisintegrationMainImmunityList == none)
TargetIsImmune = False
ELSE
ActorBase VictimBase = victim.GetBaseObject() as ActorBase
VictimRace = VictimBase.GetRace()


IF(pDisintegrationMainImmunityList.hasform(VictimRace) || pDisintegrationMainImmunityList.hasform(VictimBase))
TargetIsImmune = True
ELSE
TargetIsImmune = False
ENDIF
ENDIF


; //if the target is not immune, disintegrate them
IF(TargetIsImmune == False)
;  debug.trace("victim just died")




victim.kill(game.getPlayer())
victim.SetCriticalStage(victim.CritStage_DisintegrateStart)


victim.SetAlpha (0.0,True)


; //attach the ash pile
victim.AttachAshPile(pDefaultAshPile1)


utility.wait(fDelayEnd)
IF(bSetAlphaZero == True)
victim.SetAlpha (0.0,True)
ENDIF
victim.SetCriticalStage(victim.CritStage_DisintegrateEnd)
ENDIF


endFUNCTION

 

Link to comment
Share on other sites

First of all you are not playing a "Shader" but placing an explosion.

Second you have 2 different explosions and only 1 'Explosion Property'.

If you want just 1 explosion, then remove 1 from the script.


* If (necrolord, 1) is an explosion.


* Some (few) explosions by nature play twice, Bang... BANG !.


victim.placeAtMe(necroExplosion)

createAshPile()

utility.wait(0.1)

victim.placeactoratme(necrolord, 1)


I hope it helps.

Edited by maxarturo
Link to comment
Share on other sites

 

First of all you are not playing a "Shader" but placing an explosion.
Second you have 2 different explosions and only 1 'Explosion Property'.
If you want just 1 explosion, then remove 1 from the script.
* If (necrolord, 1) is an explosion.
* Some (few) explosions by nature play twice, Bang... BANG !.
victim.placeAtMe(necroExplosion)
createAshPile()
utility.wait(0.1)
victim.placeactoratme(necrolord, 1)
I hope it helps.

 

Nah, not that's not what i mean. By "shade" i mean an npc, like a Corrupted Shade in Kilkreath.

Link to comment
Share on other sites

If you're getting 2 NPC's, it makes me think that the Event OnDying is running twice. If this is the case, you can try putting a bool check in the script like so.

 

Bool RunCheck = False

EVENT onDying(ACTOR akkiller)
    If RunCheck == False
        RunCheck = True
        victim.placeAtMe(necroExplosion)
        createAshPile()
        utility.wait(0.1)
        victim.placeactoratme(necrolord, 1)
    Endif
endEVENT
Link to comment
Share on other sites

Aaaa ok, so this line:

victim.placeactoratme(necrolord, 1)

Is your actor.


Replace it with:

victim.PlaceActorAtMe(necrolord)


A better way to script this is to:

victim.PlaceActorAtMe(necrolord, 2).StartCombat(Game.GetPlayer())


Here is the link to the function so you can understad it better:



Be sure that you don't have assigned the "necrolord" actor in both of your properties that have the "PlaceAtMe", but if you use the function i posted above ( PlaceActorAtMe() ) this won't happen.


Have a happy modding.

Edited by maxarturo
Link to comment
Share on other sites

At first if you create your own mod, which means you won't overwrite an existing script, use a unique name for that script. Because all scripts share the same folder !!!

What I understand with your issue:

 

retDrainShadeSCRIPT

 

Scriptname retDrainShadeSCRIPT extends ActiveMagicEffect  
; https://forums.nexusmods.com/index.php?/topic/8959193-help-with-a-script/

; retton wrote: "place a shade upon Targets death, problem is that it places two shades instead of one"

  ActorBase PROPERTY necroLord      auto        ; fill by CK with right base object
  Explosion PROPERTY necroExplosion auto        ; fill with proper exlosion

  Activator PROPERTY pDefaultAshPile1 auto      ; {The object we use as a pile.}

  FormList  PROPERTY ImmunityList auto
    {If the target is in this list, they will not be disintegrated.}

  Float PROPERTY fDelay    = 0.75 auto          ; {time to wait before Spawning Ash Pile}
  Float PROPERTY fDelayEnd = 1.75 auto          ; {time to wait before Removing Base Actor}

  Bool PROPERTY bSetAlphaToZeroEarly auto       ; [default=False]
      {Use this if we want to make the actor invisible, somewhere before race change is done.}

  Bool PROPERTY bSetAlphaZero = TRUE auto       ; set TRUE as default, switch actor on/off by using Alpha

  Actor victim


; -- EVENTs -- 3   ; see vanilla script "magicAttachAshPileOnDeath.psc"

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
    victim = akTarget                           ; make target persistence for a while
ENDEVENT


EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
;;;    victim = None                            ; remove persistence
ENDEVENT


EVENT OnDying(Actor akKiller)
IF ( victim )
    createAshPile()
ENDIF
ENDEVENT


; -- FUNCTION --

;-----------------------
FUNCTION createAshPile()
;-----------------------
; (1) check to see, if target is in the immunity list

    IF ( ImmunityList )        ; ok we have a valid formlist
        IF ImmunityList.HasForm(victim.GetBaseObject())
            RETURN    ; - STOP -    baseObject for this target was found, is immune
        ENDIF
;        ----------------------
        IF ImmunityList.HasForm(victim.GetRace() as Form)
            RETURN    ;  - STOP -    race of this target was found, is immune
        ENDIF
;        -----------------------
    ENDIF

; (2) target is not immune, disintegrate them

;*;    victim.Kill( Game.GetPlayer() )          ; actor should be already dead, do not kill again

    victim.SetCriticalStage(victim.CritStage_DisintegrateStart)        ; >> START
;-------------------------------------------
    victim.PlaceAtMe(necroExplosion)            ; do explosion to mask race change, instead of shaderFX

    IF ( bSetAlphaToZeroEarly )            ; == TRUE
        victim.SetAlpha(0.0, TRUE)
    ENDIF

    Utility.Wait(fDelay)                        ; wait before
    victim.AttachAshPile(pDefaultAshPile1)      ; attach the ashpile
    Utility.Wait(fDelayEnd)                     ; wait after

    IF ( bSetAlphaZero )                   ; == TRUE
        victim.SetAlpha(0.0, TRUE)
    ENDIF
;-------------------------------------------
    victim.SetCriticalStage(victim.CritStage_DisintegrateEnd)          ; << END

    Utility.Wait(0.1)
    victim.PlaceActorAtMe(necrolord, 1)         ; place a new actor (non-persistent) with actorbase "necrolord" near the ashpile
    victim = None
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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