A_CheckForResurrection

From ZDoom Wiki
Jump to navigation Jump to search

bool A_CheckForResurrection ()
bool A_CheckForResurrection [(State state [, Sound snd])] (New from 4.7.0)


Note: starting with GZDoom 4.7.0, this function is no longer fully supported by DECORATE. If used from DECORATE, it is to be called without passing any parameters to it. Consider switching to ZScript to fully utilize this function.

Usage

Checks for a revivable corpse. If the calling actor comes into contact with one, it resurrects the actor in question, provided the actor being revived can actually be resurrected. The outcome of CanResurrect is another determining factor in the success or failure of an actor's resurrection.

Parameters

  • state: a pointer to the state to enter. Passing null defaults to the Heal state. If the Heal state does not exist, no state is entered. Default is null.
  • snd: the sound to play. The sound is played by the resurrected actor on the body (CHAN_BODY) channel with idle (ATTN_IDLE) attenuation. Passing 0 or an invalid sound name defaults to "vile/raise" as the sound to play. Default is 0.

Return value

The function returns true if the actor is resurrected successfully, otherwise it returns false.

Examples

This mysterious barrel wanders around. If it stumbles upon a corpse, it revives it, then it explodes.

class SentientBarrel : ExplosiveBarrel
{
    Default
    {
        Speed 6;
    }

    States
    {
    Spawn:
        BAR1 AB 6
        {
            if (!A_CheckForResurrection(FindState("Rise"), "grunt/pain"))
            {
                A_Wander();
            }
        }
        Loop;

    Rise:
        BAR1 ABABABABABABABABAB 2;
        BAR1 A -1 A_Die;
        Stop;
    }
}