Jump to content

[LE] Need this damage script to affect enemies, not only the player.


JPTR1

Recommended Posts

Hello,

i would need a reliable triggerzone(firetrap) to kill an NPC, no matter which Level, which resistences, it has.

If i use the "DB10FireDamageTriggerBox" for example, its not able to kill my enemy at high levels, and on low levels it dies to fast, same for the player.

 

Now i found this script, seems to have a constant percentage damage output, ignoring armor and resistences, which is perfect, but it only affects the player.

Is there any chance to let this script affect the NPC only and ignore the player?

 

 

Scriptname MansionLightDamageScript extends ObjectReference
{the trigger that deals damage to the player if they are in the light}

; false = minimum damage
; true = maximum damage
BOOL PROPERTY maxDmg AUTO
EFFECTSHADER PROPERTY effect AUTO

INT INTRIGGER=0


EVENT ONTRIGGERENTER(objectreference ref)

IF(ref as ACTOR == game.getPlayer())

INTRIGGER += 1

effect.play(game.getPlayer())

while(INTRIGGER > 0)
IF(maxDMG)
game.getPlayer().damageAV("health", (game.getPlayer().getBaseAV("health") * 0.2))

ELSEIF(maxDMG == FALSE)
game.getPlayer().damageAV("health", (game.getPlayer().getBaseAV("health") * 0.05))

ENDIF

utility.wait(0.5)
endWHILE

effect.stop(game.getPlayer())

ENDIF

ENDEVENT


EVENT ONTRIGGERLEAVE(objectreference ref)

IF(ref as ACTOR == game.getPlayer())
INTRIGGER -= 1

ENDIF

ENDEVENT

 

Edited by JPTR1
Link to comment
Share on other sites

jptLightDamageTriggerScript

 

Scriptname jptLightDamageTriggerScript extends ObjectReference
{trigger that deals damage to any actor if they are in the light}
; https://forums.nexusmods.com/index.php?/topic/10771768-need-this-damage-script-to-affect-enemies-not-only-the-player/

  EffectShader PROPERTY effect auto        ; shader effect to play
  Bool         PROPERTY maxDmg auto        ; [default=False], minimum damage, set TRUE for maximum damage

  FormList PROPERTY ActorList auto         ; a new created formlist with CreationKit to check for multiple actors in a light triggerbox
  Bool bRunning                            ; [default=False]

; -- EVENTs --

EVENT OnCellAttach()
    bRunning = TRUE            ; *T*
    gotoState("Action")                ; ### STATE ###
    RegisterForSingleUpdate(1.0)
ENDEVENT


EVENT OnCellDetach()
    bRunning = False          ; ***
    UnRegisterForUpdate()
    gotoState("")                    ; ### STATE ###
    ActorList.Revert()    ; clear any script added entry
ENDEVENT

;==========================
State Action
;===========
EVENT OnUpdate()
    WHILE (bRunning)                                        ; outer loop
        int i = 0
        WHILE (i < ActorList.GetSize())                 ; inner loop
            actor aRef = ActorList.GetAt(i) as Actor
            IF ( aRef )
                float f = aRef.GetBaseActorValue("health")
                IF ( maxDMG )
                    f = f * 0.2
                ELSE
                    f = f * 0.05
                ENDIF
                aRef.DamageActorValue("health", f)
            ENDIF
            i = i + 1
        ENDWHILE                                        ; i*
        Utility.Wait(0.5)    ; cooldown time
    ENDWHILE                                                ; o*
ENDEVENT


EVENT OnTriggerEnter(ObjectReference triggerRef)
IF (triggerRef as Actor)
    ; https://www.creationkit.com/index.php?title=AddForm_-_FormList
    
    Effect.Play(triggerRef)
    ActorList.AddForm(triggerRef as Form)
ENDIF
ENDEVENT


EVENT OnTriggerLeave(ObjectReference triggerRef)
IF (triggerRef as Actor)
    ; https://www.creationkit.com/index.php?title=RemoveAddedForm_-_FormList

    ActorList.RemoveAddedForm(triggerRef as Form)
    Effect.Stop(triggerRef)
ENDIF
ENDEVENT
;=======
endState

 

 

 

Keep in mind this is a concept. You have to try it is working for your purpose!

 

And you have to create an empty formlist with the creation kit, that can be used to fill the script property ActorList !!

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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