A_SetHealth
Jump to navigation
Jump to search
native void A_SetHealth(int health, int ptr = AAPTR_DEFAULT)
Usage
Sets the actor's health to health. There are several rules to keep in mind:
- This modifies health directly. For the PlayerPawn class, who differentiate between current health and max health, this will modify their base health value, which is not the same as healing. For healing, use GiveBody.
- Conversely, this cannot be used to deal damage: this isn't an attack, it doesn't have a source. For attacks, use DamageMobj or one of the damage-related functions such as A_DamageSelf.
- This function cannot kill an actor: if the defined health is 0 or less, it will set the actor's health to 1 instead. For killing an actor, use A_Die, or damage functions.
Parameters
- int health
- The health value to set for the actor. Values below 1 will be interpreted as 1.
- int pointer
- A DECORATE AAPTR* pointer. Default is AAPTR_DEFAULT, which corresponds to the calling actor. In ZScript, the function can be prefixed with a ZScript pointer instead to modify whom it affects.
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. |