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]]]]]])
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]]]]]]]]]) (New from 2.8.1)

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 pointer they have. See actor pointers for more information.
  • xofs: 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.
  • yofs: 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.
  • zofs: 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 offset to add after the calling actor sets its angle to the reference actor's angle.
  • flags:
Flags that affect the behavior:
  • WARPF_ABSOLUTEOFFSET — Do not apply the angle to the xyofs.
  • WARPF_ABSOLUTEANGLE — Use the angle parameter as an absolute angle (not an offset).
  • WARPF_ABSOLUTEPOSITION (New from 2.8.1) — 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.
  • WARPF_USECALLERANGLE — Use the calling actor's angle instead of the reference actor's. The angle parameter changes as such: it will add itself to the caller's angle and cause it to orbit around the reference. The greater the number in angle, the faster it will orbit.
  • 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. This flag ignores all other flags and properties, including but not limited to pitch and angle changes, with the exception of WARPF_NOCHECKPOSITION, which is not recommended for use with this flag due to forcing success upon the test.
  • WARPF_BOB (New from 2.8.1) — Gets the float bob offsets of the targeted actor and offsets it to follow with it.
  • WARPF_MOVEPTR (New from 2.8.1) - The target does the warping instead of the calling actor, and all the flags apply. The calling actor is still responsible for performing a state jump and determining success, however.
  • WARPF_USETID (New from 2.8.1) — If set, the first parameter changes to accept a tid instead of an actor pointer.
  • WARPF_COPYVELOCITY (New from 2.8.1) - Copies the exact velocity of the actor, which is relative only to the target's own, regardless of what angle the warped actor receives.
  • WARPF_COPYPITCH (New from 2.8.1) - Gains the same pitch as the target, and then adds pitch after it, if any.
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.
  • heightoffset: A multiplier for the target's height. This allows for further adjustment to the calling actor's zofs by way of adding the result of multiplying the target's height by the passed value to the zofs. Default is 0. (New from 2.8.1)
  • radiusoffset: A multiplier for the target's radius. Similar to heightoffset but using radius instead. (New from 2.8.1)
  • pitch: The amount of pitch to add to the offset, negative values aim the actor higher while positive will lower it. Unlike angle, this is NOT copied unless WARPF_COPYPITCH is specified for compatibility purposes. (New from 2.8.1)

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.

Note: Jump functions perform differently inside of Anonymous Functions. (development version a399f40 only)

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.