MorphActor

From ZDoom Wiki
Jump to navigation Jump to search

int MorphActor (int tid [, str playerclass [, str monsterclass [, int duration [, int style [, str morphflash [, str unmorphflash]]]]]])

Usage

This function and its complement UnMorphActor give the ACS coder direct access to the engine's morph subsystem, instead of having to strategically place DECORATE items and suchlike.

Parameters

  • tid: The actor(s) to morph. The activator is used if this parameter is zero.
  • playerclass: Defines what class to morph a player into.
  • monsterclass: Defines what class to morph a monster into.
  • duration: Defines the duration of the morphing effects.
  • style: Defines the behaviour of the morphing effects.
  • morphflash: Defines the effect flash actor to spawn when the player morphs. If omitted, the game's default teleport fog is used.
  • unmorphflash: Defines the effect flash actor to spawn when the player unmorphs. If omitted, the game's default teleport fog is used.

This function does honor the MRF_WHENINVULNERABLE flag when used on a player, provided that player is also the activator of the function.

Except for tid, the parameters are the same special properties defined by the MorphProjectile class. They are summarised above; for full details and additional notes, please refer to the MorphProjectile class.

Note: for versions of ACC older than 1.58, all optional arguments must be treated as mandatory. Specify 0 for unused integer arguments and "" for unused string arguments.


Return value

The return value is the number of actors successfully morphed. This also means that for TID = 0, it is also a boolean (0 = failed, 1 = succeeded).

Examples

The following example assumes that a cyberdemon with the DONTMORPH actor flag disabled has a TID of one. The function call turns it into a pitiful little puppy demon, so you can kill him with ease!

Note that the Demon's DECORATE code is reproduced from gzdoom.pk3 because the engine currently requires that all morphed monsters must inherit the MorphedMonster class, and multiple inheritance is not supported; at the moment, you cannot arbitrarily morph one kind of monster into another.

script 1 (void)
{
    MorphActor(1, "", "MorphDemon", 1048576, 0, "", "");
}
actor MorphableCyberDemon : Cyberdemon replaces Cyberdemon
{
    -DONTMORPH // The cyberdemon has this flag set, by default. The flag needs to be cleared so the monster can morph.
}

actor MorphDemon : MorphedMonster
{
    Game Doom
    Health 150
    PainChance 180
    Speed 10
    Radius 30
    Height 56
    Mass 400
    Monster
    +FLOORCLIP
    SeeSound "demon/sight"
    AttackSound "demon/melee"
    PainSound "demon/pain"
    DeathSound "demon/death"
    ActiveSound "demon/active"
    Obituary "%o was killed by a dem... cyberd... well, by something anyway"
    States
    {
    Spawn:
        SARG AB 10 A_Look
        Loop
    See:
        SARG AABBCCDD 2 Fast A_Chase
        Loop
    Melee:
        SARG EF 8 Fast A_FaceTarget
        SARG G 8 Fast A_SargAttack
        Goto See
    Pain:
        SARG H 2 Fast
        SARG H 2 Fast A_Pain
        Goto See
    Death:
        SARG I 8
        SARG J 8 A_Scream
        SARG K 4
        SARG L 4 A_NoBlocking
        SARG M 4
        SARG N -1
        Stop
    Raise:
        SARG N 5
        SARG MLKJI 5
        Goto See
    }
}