MSFD Determining and changing Health, Magicka, Fatigue
Get/Mod/SetHealth
Get/Mod/SetMagicka
Get/Mod/SetFatigue
These return, change or set the vital functions of the PC. For NPC and the player the Get functions will report the current health/magicka/fatigue. GetHealth also works on weapons / armor, but only returns the maximum health. No function is known that reports current item health (Forum info/Mana User).
Special use with ModStat only:
ModCurrentHealth, var_float
ModCurrentMagicka, var_float
ModCurrentFatigue, var_float
While ModHealth changes both the maximum and the current health of an Actor for the same amount (e.g. even a healthy Actor would be affected), ModCurrentHealth affects only the current health and can not set health above the original maximum health value for that Actor (so doing ModCurrentHealth, 10000 to an Actor with 70 Health and a current health of 35 would set Health to 70 – Doing ModHealth, 10000 would set him to 10035 health).
Changing Health:
SetHealth affects the object, not just a reference. If you use SetHealth from a global script on a non-unique ID, it will apply to all instances of the object that the player has not encountered yet (but if the player has already encountered that reference, it won't be affected). If SetHealth is used from a targeted script on a non-unique ID, it will have much the same effect as a global script but will also affect the script's target, even if the player has encountered it already. ModCurrentHealth is the reverse: it affects the reference rather than the object. SetHealth in the console window with a reference selected will also affect only that reference.
Note that the same does not apply to other derived attributes: If you place a new reference, Fatigue will be at editor level, and Magicka will be auto-calculated from Intelligence (regardless of editor level).
GetHealthGetRatio (returns float)
This function returns the health ratio of the Actor as a float value from 0 to 1, e.g. 1 means 100% health, 0.9 means 90% health and 0 means, well, dead I guess. This replaces the erroneously listed function GetHealthRatio listed in the original helpfile.
If you want to know an Actors maximum health (Remember, GetHealth returns your current health points) you can use this:
Float MaxHealth
Float CurrentHealthRatio
Set CurrentHealthRatio to ( "Actor ID"->GetHealthGetRatio )
if ( CurrentHealthRatio > 0 )
Set MaxHealth to ( ("Actor ID"->GetHealth ) / CurrentHealthRatio )
else
Set MaxHealth to 0
endif