GetMaxHealth
Jump to navigation
Jump to search
virtual clearscope int GetMaxHealth(bool withupgrades = false) const
Usage
Retrieves the spawn health of the calling actor. For regular actors, this behaves exactly like the SpawnHealth function.
PlayerPawn actors override it to add special behaviors if withupgrades is true
.
Parameters
- bool withupgrades
- If
true
and the calling actor is a PlayerPawn, the values ofbonushealth
andstamina
fields are added on top of MaxHealth. - If the calling actor is not a PlayerPawn, this is ignored.
Return value
- int - The health the actor spawns with, as an integer.
Examples
Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated. |
ZScript definition
virtual clearscope int GetMaxHealth(bool withupgrades = false) const // this only exists to make checks for player health easier so they can avoid the type check and just call this method.
{
return SpawnHealth();
}
PlayerPawn's version:
override int GetMaxHealth(bool withupgrades) const
{
int ret = MaxHealth > 0? MaxHealth : ((Level.compatflags & COMPATF_DEHHEALTH)? 100 : deh.MaxHealth);
if (withupgrades) ret += stamina + BonusHealth;
return ret;
}