A_Warp

From ZDoom Wiki
Jump to: navigation, search

state, bool A_Warp (int ptr_destination [, float xofs [, float yofs [, float zofs [, float angle [, int flags [, state success_state [, float heightoffset [, float radiusoffset [, float pitch]]]]]]]]])

Usage

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: Moves the calling actor to the specified actor pointer. See actor pointers for more information.
  • xofs: Specifies how far forward/backward in front/behind of the warped-to actor the warping actor will appear. Positive numbers are further forward, and negative numbers will go backward.
  • yofs: Specifies how far to the side the warping actor will appear to the warped-to. Positive numbers are further to the right, while negative numbers spawn them more to the left.
  • zofs: Specifies how far upward the warping actor will appear to the warped-to actor. Positive numbers are further upward, while negative means under the actor and possibly into the ground.
  • angle: Specifies an offset from the warped-to actor's angle to set the warping actor's angle to. Default (zero) is to just use the warped-to actor's angle exactly.
  • flags:
Flags that affect the behavior:
  • WARPF_ABSOLUTEOFFSET — By default the xofs and yofs parameters apply the warped-to actor's angle; this flag disables this behaviour.
  • WARPF_ABSOLUTEANGLE — Use the angle parameter as an absolute angle, instead of an offset.
  • WARPF_ABSOLUTEPOSITION — Treat x, y and z offset parameters as absolute coordinates for the warping actor's position, instead of being relative to the warped-to actor's. This flag overrides WARPF_ABSOLUTEOFFSET, but can still add the z offset of floorz when used with WARPF_TOFLOOR.
  • WARPF_USECALLERANGLE — Use the warping actor's angle instead of the warped-to actor's. The angle parameter will instead add itself to the warping's angle and cause it to orbit around the warped-to actor's. The greater the angle parameter, the faster it will orbit.
  • WARPF_NOCHECKPOSITION — Blindly accept any resultant position, instead of checking for the warp being a valid movement.
  • WARPF_STOP — Reduce warping actor's velocity to 0 when the move is completed, similar to A_Stop.
  • WARPF_TOFLOOR — Makes the zofs parameter relative to the floor, rather than relative to the warped-to actor.
  • WARPF_TESTONLY — Does not perform any warping, but still jumps to the success state if it is able to warp. This flag ignores all other flags and properties, including but not limited to pitch and angle changes, with the exception of WARPF_NOCHECKPOSITION which always jumps to the success state.
  • WARPF_BOB — Makes the warping actor's floatbob phase follow the warped-to actor's.
  • WARPF_MOVEPTR - The target is set to warp instead of the calling actor. The calling actor is still responsible for performing a state jump and determining success, however.
  • WARPF_USETID — If set, the first parameter changes to accept a tid instead of an actor pointer.
  • WARPF_COPYVELOCITY - Copies the warped-to actor's velocity exactly, regardless of how the warping actor is moving.
  • WARPF_COPYPITCH - Copies the warped-to actor's pitch, and then adds the pitch parameter to it.
Flags to customize appearance of the warp:
  • WARPF_INTERPOLATE — Keeps the warping actor's default interpolation data.
  • WARPF_WARPINTERPOLATION — Modify interpolation data with the vector PlayerNewPosition - PlayerOldPosition.
  • WARPF_COPYINTERPOLATION — Copies the warped-to actor's interpolation data, allowing the warping actor to mimic it.
  • success_state: An optional state to jump to if the warp succeeds.
  • heightoffset: Adds the warped-to actor's height multiplied by heightoffset to the zofs parameter. Default is 0.
  • radiusoffset: Adds the warped-to actor's radius multiplied by radiusoffset to the xofs and yofs parameters. Default is 0.
  • pitch: With WARPF_COPYPITCH, this parameter works exactly as angle, but with pitch instead. Without WARPF_COPYPITCH, this parameter merely adds to the warping actor's pitch.

Note: If the actor being warped to does not exist or has stopped existing, and the success state is defined, it will always 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.

Note: Jump functions perform differently inside of anonymous functions.

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 warp to, target is what to go for, in this case, since a projectile's target is usually the actor which fires it.