A_Warp

From ZDoom Wiki
Jump to: navigation, search

A_Warp(int ptr_destination, float x-offset, float y-offset, float z-offset, float angle, int flags , state success_state)

This command is considered an extension of A_Fire, with more versatility and flexible actor controls. Unlike A_Fire, it does not require an actor to be visible like the Archvile's fire attack, and these can be used with actor pointers.

Parameters

  • ptr_destination: Teleports the calling actor to the pointer they have. See actor pointers for more information.
  • x-offset: Specifies how far forward/backward in front/behind of the pointed actor the calling actor will appear. Positive numbers result in the actor spawning in front, and behind for negative.
  • y-offset: Specifies how far to the side the calling actor will appear to the pointer. Positive numbers are further to the pointer actor's right, while negative numbers spawn them more to the left.
  • z-offset: Specifies how high off the ground to appear. Positive numbers mean a higher altitude, negative means under the pointer and possibly into the ground.
  • angle: Specifies the angle at which the actor will appear in relation to the pointer.
  • flags:
Flags that affect the behaviour:
  • WARPF_ABSOLUTEOFFSET — Do not apply the angle to the xy-offset.
  • WARPF_ABSOLUTEANGLE — Use the angle parameter as an absolute angle (not an offset).
  • WARPF_ABSOLUTEPOSITION — Treat x, y and z offset parameters as absolute coordinates for the calling actor's position, instead of being relative to the pointer actor's. This flag overrides WARPF_ABSOLUTEOFFSET, but can still add the z offset of floorz when used with WARPF_TOFLOOR.(development version 68a5db3 only)
  • WARPF_USECALLERANGLE — Use the caller's angle as a base for the angle parameter (Default is to use the reference actor).
  • WARPF_NOCHECKPOSITION — Blindly accept any resultant position.
  • WARPF_STOP — Reduce caller velocity to 0 when the move is completed.
  • WARPF_TOFLOOR — Set caller z relative to floor z where teleported to, instead of relative to reference actor.
  • WARPF_TESTONLY — Does not warp the actor, but still allows it to jump to the success state if it were to warp. This is useful for checking things and causing chains to occur, such as with inventory items.
Flags to customize appearance of the warp:
  • WARPF_INTERPOLATE — Keep old interpolation data (make it appear as if actor moved from its previous location).
  • WARPF_WARPINTERPOLATION — Modify interpolation data with the vector PlayerNewPosition - PlayerOldPosition.
  • WARPF_COPYINTERPOLATION — Copies the actor's interpolation data for itself, allowing the actor to mimic the pointer closely.
  • success_state: An optional state to jump to in the event of success.

NOTE: If the actor being orbited stops existing, and the success state is defined, it will ultimately fail to jump. Even if success state is left undefined, though, it will fail to move at all. The success state can be useful for getting rid of orbiting/external actors when the main actor is no longer being used.

Examples

The following example is a replication of A_Fire:

A_Warp(AAPTR_TRACER, 24, 0, 0, 0, WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)


A useful application of this function is to have "orbiters". This example baron has a projectile circulating it all the time.

ACTOR SpecialBaronOfHell : BaronOfHell
{
  States
  {
  Spawn:
    BOSS A 0 NoDelay A_CustomMissile("OrbitBall", 32, 0, 0, CMF_AIMDIRECTION)
  Idle:
    Goto Super::Spawn
  }
}

ACTOR OrbitBall
{
  RenderStyle "Add"
  Translation "0:255=%[0,0,0]:[0.93,2,0.87]" // Makes it green-colored
  +MISSILE
  +NOINTERACTION

  var int user_angle; // See user variables

  States
  {
  Spawn:
    BAL1 A 1 Bright NoDelay A_Warp(AAPTR_TARGET, 32, 0, 32, user_angle, WARPF_ABSOLUTEANGLE|WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
    TNT1 A 0 A_SetUserVar("user_angle", user_angle + 8)
    Loop
  }
}

When choosing the pointer for the function, i.e, the actor the projectile should orbit, target is what to go for, in this case, since a projectile's target is usually the actor which fires it.