GetReplacement

From ZDoom Wiki
Jump to navigation Jump to search


Actor

native static class<Actor> GetReplacement (class<Actor> cls)
native clearscope static class<Actor> GetReplacement (class<Actor> cls) (New from 4.11.1)

Usage

Gets the actor class which replaces the specified actor class. The class the function gets is the last class in the replacement chain, not the direct replacement. For instance, if cls is being replaced by DoomImp, and DoomImp itself is being replaced by Revenant, then it is Revenant which serves as the replacement, and thus what the function gets.

Parameters

  • cls: the actor class to get its replacement.

Return value

The actor class which replaces the specified actor class, as a class pointer. If the specified class has no replacement, it itself is returned.

Examples

On pickup, this item gives the player a security armor and whatever item that is replacing the soulsphere, which in this case Soulsphere2.

class SomeItem : CustomInventory
{
    States
    {
    Spawn:
        SOUL ABCD 6 Bright;
        Loop;

    Pickup:
        TNT1 A 0
        {
            class<Actor> rep = GetReplacement("Soulsphere");
            A_GiveInventory((class<Inventory>)(rep));
            A_GiveInventory("GreenArmor");
        }
        Stop;
    }
}

class Soulsphere2 : Soulsphere replaces Soulsphere
{
    Default
    {
        Inventory.Amount 75;
    }
}

See also