Jump to content

Need object for health tracking system


Seren4XX

Recommended Posts

Might wanna use OnHit() instead of OnUpdate(). OnHit() is triggered by pretty much everything except fall damage. Should provide you with something more reliable than OnUpdate(). Once the player receives the spell, register for update to check when his health is above the threshold.

 

Something like this:

 

 

 

Scriptname NingheimDivineInterventionScript extends Actor ;or Quest hidden or ActiveMagicEffect? I believe this is right. I tried all three anyway.

;Quest  Property aaaNingheimHealthTrackingQuest Auto ;Only use if Quest is necessary to function <-Never used this
Spell   Property NingheimDivineIntervention Auto ; A shield + shock cloak spell
Spell   Property abDI Auto ; The ability I use to see if the script executes
Float   Property healthThreshold = 0.25 Auto
Sound   Property activationBlast Auto ; Just sound
Sound   Property deactivationNotice Auto ; Just sound
String  playerRace
Float   playerHealthPercent ; Will store current player health in percentages
Actor   player

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
 bool abBashAttack, bool abHitBlocked)

       playerHealthPercent = player.GetAVPercentage("Health") ;Should give a value between 0.0 and 1.0
       playerRace = player.GetRace()

       ; Check whether health is below set threshold, check if the race is correct and check whether combat is actually initialized
       If(playerHealthPercent <= healthThreshold && (playerRace == "NingheimRace" || playerRace == "NingheimRaceVampire") && player.IsInCombat())
               If player.HasSpell(NingheimDivineIntervention) == 0
                       player.AddSpell(NingheimDivineIntervention)
                       player.EquipSpell(NingheimDivineIntervention, 2) ; I give the player a choice whether to let the power activate as it only works once a day
                       activationBlast.Play(player)
                       Debug.Notification("Divine Intervention has come " + playerRace) ; Just a test thing

                       RegisterForSingleUpdate(1.0) ; Check wen we get our health back
               endIf
      endif
       

endEvent

Event OnUpdate()

       playerHealthPercent = player.GetAVPercentage("Health") ;Should give a value between 0.0 and 1.0
       playerRace = player.GetRace()

       If(playerHealthPercent > healthThreshold && (playerRace == "NingheimRace" || playerRace == "NingheimRaceVampire") && !player.IsInCombat() && player.HasSpell(NingheimDivineIntervention))
               player.RemoveSpell(NingheimDivineIntervention)
               deactivationNotice.Play(player)
               Debug.Notification("Divine Intervention has passed" + playerRace)
       else        
              RegisterForSingleUpdate(1.0) ; Causes the script to loop another time
       endif
       ;Debug.Trace("Going for another update-pass. Conditions checked.")
               
endEvent

 

 

 

You might want to take an extra look if I've made something wrong.

Link to comment
Share on other sites

Thanks a lot for the help, guys!

 

After looking at T3nd0's script for the Dark Elf Ancestor spell and going through your tips I got the script to actually execute and it now works as I had intended. :) If anyone is curious as to how I got it to work and what the script looks like now, let me know and I'll post it here.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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