GetActorValuePercentage - Actor
Revision as of 10:12, 27 July 2014 by imported>Terra Nova2
Member of: Actor Script
Gets the specified actor value from the actor as a percentage of its maximum value (from 0 to 1).
Syntax
float Function GetActorValuePercentage(string asValueName) native
float Function GetAVPercentage(string asValueName)
return GetActorValuePercentage(asValueName)
EndFunction
Parameters
- asValueName: The name of the actor value to get the value of. Actor Value List
Return Value
The value of the requested actor value as a percentage of its maximum value. If 0, then the actor value is at its minimum. If 1, then the actor value is at its maximum.
Examples
Get the total (max) VALUE of a stat AFTER buffs are calculated:
; returns Actor's total possible stat value (after buffs)
; stat 1 = health, stat 2 = magicka, stat 3 = stamina
float Function GetBuffedActorValue(Actor starget, int stat)
if stat == 1
return (starget.GetActorValue("Health") / starget.GetActorValuePercentage("Health"))
elseif stat == 2
return (starget.GetActorValue("Magicka") / starget.GetActorValuePercentage("Magicka"))
elseif stat == 3
return (starget.GetActorValue("Stamina") / starget.GetActorValuePercentage("Stamina"))
endif
EndFunction
; add the above function to your script then call it on an actor,
; for example to get the player's max health value after buffs:
float thbuffed = GetBuffedActorValue(Game.GetPlayer(),1)
Debug.Notification("Players max buffed health = "+thbuffed)
Get a percent of the total (max) value of a stat AFTER buffs are calculated:
; returns requested percent of Actor's total possible stat value after buffs.
; stat 1 = health, stat 2 = magicka, stat 3 = stamina
; percent must be in decimal form, ie 25%: percent = 0.25, 100%: percent = 1, etc.
float Function TStatPV(Actor starget, float percent, int stat)
if stat == 1
return ((starget.GetActorValue("Health") / starget.GetActorValuePercentage("Health")) * percent)
elseif stat == 2
return ((starget.GetActorValue("Magicka") / starget.GetActorValuePercentage("Magicka")) * percent)
elseif stat == 3
return ((starget.GetActorValue("Stamina") / starget.GetActorValuePercentage("Stamina")) * percent)
endif
EndFunction
; add the above function to your script then call it on an actor,
; for example to get 20% of the player's max health value after buffs:
float phbuffed = TStatPV(Game.GetPlayer(),0.20,1)
Debug.Notification("20% of players max buffed health = "+phbuffed)
; Obtain the player's current health percentage value
float playersHealth = Game.GetPlayer().GetActorValuePercentage("health")
if (playersHealth > 0.5)
Debug.Trace("The player has over half their health left")
endIf
; Obtain Bob's current health actor value
float bobsHealth = Bob.GetAVPercentage("Health")
if (bobsHealth < 0.1)
Debug.Trace("Bob has less then 10% health remaining")
endIf
Notes
- The examples concerning calculations after buffs maybe off. The second one with getting the percents is definitely not right. More testing needed. --