A_Teleport

From ZDoom Wiki
Jump to navigation Jump to search

state, bool A_Teleport [(string teleportstate [, string targettype [, string fogtype [, int flags [, float mindist [, float maxdist [, pointer ptr]]]]]])]

Note: Jump functions perform differently inside of anonymous functions.

Usage

Attempts to teleport the actor to a SpecialSpot-derived actor that is at least mindist away and at most maxdist away. If maxdist is 0, there is no maximum distance limit. If successful, an actor of type fogtype is spawned at the old location and calling actor is placed in the state indicated by teleportstate. If a spot is obscured by a ceiling or a floor, it will adjust the actor's z position to not be blocked if possible.

Note that despite requiring an actor at the target location, this function can be used in a monster without a specially prepared field. It should be possible, for instance, for that monster to drop SpecialSpot-derived actors around (possibly with a timed life) to teleport to later.

Parameters

  • teleportstate: The state in which the actor should go after teleporting. If the actor does not have this state, or an empty string ("") is given, "Teleport" is assumed. If the actor does not have a Teleport state either, depending on the flags below, the default behavior resorts to no teleportation or state jump occurring.
  • targettype: The type of the target. This needs to be an actor type derived from SpecialSpot. By default, BossSpot is used.
  • fogtype: The actor to spawn at the position being left. By default, TeleportFog is used. To disable, use None or the flags below.
  • flags: The following flags can be combined by using the | character between the constant names:
    • TF_TELEFRAG — Telefrag: Allow telefrag in order to teleport.
    • TF_RANDOMDECIDE — Random decision: Randomly choose not to teleport based on current health ratio, like A_Srcr2Decide:
Health fraction Teleportation chance
8/8 or more 0%
7/8 6.25%
6/8 12.5%
4/8 25%
1/8 46.875%
Less than 1/8 75%
  • TF_FORCED: Forces the teleportation regardless of anything blocking it.
  • TF_KEEPVELOCITY: By default, the function stops all movement. This allows the calling actor to keep moving after teleporting.
  • TF_KEEPANGLE: By default, the function will make the actor face the same direction as the SpecialSpot it teleports to. This flag lets the actor keep their angle.
  • TF_KEEPORIENTATION: Implies TF_KEEPVELOCITY and TF_KEEPANGLE. This is the same as putting in TF_KEEPVELOCITY|TF_KEEPANGLE.
  • TF_USESPOTZ: By default, the teleporting actor's z position is set to the floor. This flag prevents grounding so they can teleport into the air.
  • TF_NOSRCFOG: The calling actor will not spawn teleport fog at the old location they teleport away from.
  • TF_NODESTFOG: The calling actor will not spawn teleport fog at their arriving destination.
  • TF_NOFOG: Implies TF_NOSRCFOG and TF_NODESTFOG flags. This is the same as putting in TF_NOSRCFOG|TF_NODESTFOG.
  • TF_USEACTORFOG: Uses the fogs defined in TeleFogSourceType and TeleFogDestType property fields.
  • TF_NOJUMP: The actor will not jump after teleporting, and they no longer require a state to jump. This is especially useful for CustomInventory items to prevent breaking actors during an important state transition. If used, it is recommended to set the teleportstate to 'None'.
  • TF_OVERRIDE: If set, actors with the NOTELEPORT flag set can teleport, still.
  • TF_SENSITIVEZ: Actors will fail to teleport instead of having their z positions adjusted to make up for floors or ceilings blocking the way.
  • mindist: The actor must be this distance away in order to teleport. The default value is 0.
  • maxdist: The actor must be within this distance in order to teleport. The default value is 0 (unlimited range).
  • ptr: Determines who will be teleported. Defaults to AAPTR_DEFAULT (self). Jumping and TF_NOJUMP are limited to the caller only, while everything else will affect the pointer instead.

Examples

The following is a variant of the Doom imp, a monster that will randomly teleport around a room, firing at you. It uses A_Jump to decide a certain chance of it triggering A_Teleport, causing it to teleport to a random "ImpSpot" (a variant of BossSpot), in its attack state.

actor TeleportImp : DoomImp 601
{
  States
  {
  Spawn:
    TROO AB 10 A_Look
    Loop
  See:
    TROO AABBCCDD 3 A_Chase
    TROO A 0 A_Jump(200, "See")
    TROO A 0 A_Teleport("Missile", "ImpSpot")
    Loop
  Melee:
  Missile:
    TROO EF 8 A_FaceTarget
    TROO G 6 A_TroopAttack
    Goto See
  }
}

This is the SpecialSpot used for the monster to teleport to randomly.

actor ImpSpot : SpecialSpot 600
{
  +INVISIBLE
}