CanResurrect

From ZDoom Wiki
Jump to navigation Jump to search

virtual bool CanResurrect (Actor other, bool passive)

Usage

Called in the actor resurrection code, and serves as an additional condition to pass for the resurrection process to succeed. In the chain of conditions, it is called last, once for the "resurrectee" (the actor being resurrected) and another for the "raiser" (the actor doing the act of resurrection). In the event an actor is resurrecting itself, i.e. it is both the resurrectee and raiser, the function is only called once.

Parameters

  • other: a pointer to the raiser or resurrectee, depending on the passive parameter.
  • passive: if this is false, other points to the resurrectee, otherwise it points to the raiser.

Return value

The return value is a boolean that is used to mark the success or failure of the check. In the case the function is called twice, once for each of the actors involved, both calls need to return true for the resurrection process to succeed. If at least one of the calls returns false, the resurrection process as a whole fails.

Predefined functionality

If not overridden, all the function does is return true.

Examples

If it is low on health, this archvile can only resurrect "low-level" monsters.

class ExampleArchvile : Archvile
{
    override bool CanResurrect (Actor other, bool passive)
    {
        if (!passive)
        {
            return (health >= SpawnHealth() / 3 || other.SpawnHealth() <= 200);
        }

        return true;
    }
}

See also