CanResurrect

From ZDoom Wiki
Jump to navigation Jump to search


Actor

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

  • Actor other
A pointer to the raiser or resurrectee, depending on the passive parameter.
  • bool passive
If this is false, other points to raiser; otherwise it points to the resurrectee.

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

Example of active mode: this ArchVile is low on health, it can only resurrect "low-level" monsters (those with default health 200 or lower):

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

Example of passive mode: this Zombieman cannot be resurrected if it was gibbed:

class ZombiemanTest : Zombieman
{
	override bool CanResurrect(Actor other, bool passive)
	{
		if (passive && self.health <= self.GetGibHealth())
		{
			return false;
		}
		return Super.CanResurrect(other, passive);
	}
}

See also