GetSpecies

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.

name GetSpecies ()

Usage

This returns the species of the calling actor.

Return value

The species of the actor, as a name. If the actor does not have a species defined or the species is set to None, the return value is determined like the following:

  • If the calling actor is a monster, the function goes up the inheritance chain of the actor's class, stopping at the first class encountered which has a non-monster parent class. This class's name serves as both the return value and the species of the actor.
  • If the calling actor is not a monster, its class's name serves as the return value as well as its species.

Examples

Every tic, this former human checks if its target is an imp, and if it is, executes some code.

class ImpChecker : ZombieMan
{
    override void Tick () // See ZScript virtual functions.
    {
        if (target && target.GetSpecies() == "DoomImp")
        {
            // Do something - for example, have an enemy act differently to different targets.
        }

        Super.Tick();
    }     
}