GiveBody

From ZDoom Wiki
Jump to: navigation, search

bool GiveBody (int num [, int max])

Usage

Heals the calling actor. This function does nothing if the actor is dead.

Parameters

  • num: the amount by which to heal, which is in the range of -65536 and 65536. If this is a negative value, it acts as a percentage by which the actor's health is set to if its health as a percentage is below that value. If it is positive, the actor's health is increased by that value; in this case, the HealthFactor skill property is taken into account when determining the final amount, but only if the actor to heal is a player. If the final amount results in less than 1, it is set to 1.
  • max: the maximum value the actor's health can reach when healed. This is only relevant if the actor to heal is a player actor and num is positive. If this is 0, the actor is healed up to its maximum health, otherwise if it is positive, it is healed up to that value, disregarding its maximum health. Non-player actors are healed up to their spawn health, and as such, this parameter is ignored for them. Default is 0.

Return value

Returns true if the actor is successfully healed, otherwise it returns false.

Examples

Assuming the player's maximum health is 200, this item sets their health to 50 points (which equals to 25% of their maximum health) upon pickup, but only if it is lower than that. If it is equal or higher, healing fails, and thus the item is not picked up.

class HealthPack : CustomInventory
{
    Default
    {
        Inventory.PickupMessage "Picked up a health pack.";
    }

    States
    {
    Spawn:
        STIM A -1;
        Stop;

    Pickup:
        TNT1 A 0 GiveBody(-25);
        Stop;
    }
}