Jump to content

Track health and add spell at certain point for new race


Seren4XX

Recommended Posts

Hello,

 

currently I am in the process of creating a custom race (Preview 1, Preview 2) and for it I wish to create a spell that can only be used when the player's health is below 25% or some other number (what number isn't important for my problem). I have tried several things to get it to work, but my knowledge of applying scripts just isn't good enough.

 

What I would like to have is a system that constantly monitors the player's health and when it is below a certain percentage (25%) I want a spell to be added and I want it removed when the player's health is back up (probably with a check whether combat is still engaged, but that's a detail I can script myself).

The problem is that I can't find anything that can be used to let the script be run constantly. From what I've seen before I'd probably need a Quest for it, but I can't find out how that would work.

 

Here's the simple system I'm trying to implement in pseudo-code:

Scriptname NewCustomRaceSpecial extends ObjectReference

//variables required to monitor player here
Actor 	player
Spell 	MyNewSpell
String 	playerRace
float 	playerHealth
float 	healthThreshold

while monitoring health{
if(player.getRace == MyNewRace && playerHealth <= healthThreshold && !player.hasSpell(MyNewSpell) && player.IsInCombat()){ //The following function is available for actorhealth: player.GetActorValuePercentage("Health")
	player.addSpell(MyNewSpell);
}
elseif(player.getRace == MyNewRace && player.hasSpell(MyNewSpell) && playerHealth > healthThreshold && !player.IsInCombat()){
	player.removeSpell(MyNewSpell);
}
}

 

Aside from the script there must be an object (probably Quest) it is tied to so it can get real-time information on the player's health. In case you can't help, but know of a mod that does something based on the player's current health please post a link and I can probably dissect it to know how I can solve my problem.

 

Thanks in advance!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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