A Warp: Difference between revisions

m (removing new tags from 2.6.0)
 
(30 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:A_Warp}}
'''A_Warp'''(int ''ptr_destination'', float ''x-offset'', float ''y-offset'', float ''z-offset'', float ''angle'', int ''flags'' , state ''success_state'')
'''[[Classes:Actor|Actor]]'''


action native state, bool '''A_Warp'''(int ''ptr_destination'', double ''xofs'' = 0, double ''yofs'' = 0, double ''zofs'' = 0, double ''angle'' = 0, int ''flags'' = 0, statelabel ''success_state'' = null, double ''heightoffset'' = 0, double ''radiusoffset'' = 0, double ''pitch'' = 0)
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]].


==Usage==
''ptr_destination'': Teleports the calling actor to the pointer they have. See [[Actor pointers]] for more information.<br>
Warps the calling actor (by default) to the specified actor pointer. Originally designed as a more versatile analog to [[A_Fire]] (used by [[Classes:ArchvileFire|Arch-Vile flame]]).
''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.<br>
''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.<br>
''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.<br>
''angle'': Specifies the angle at which the actor will appear in relation to the pointer.<br>
''flags'':<br>
Flags that affect the behaviour


For a [[ZScript]]-only version that takes a proper [[Actor_pointer#ZScript|ZScript actor pointer]] instead of an AAPTR constant, see {{function|Warp (ZScript)}}.
* ''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_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.


===Parameters===
Flags to customize appearance of the warp
*'''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:
:*{{c|WARPF_ABSOLUTEOFFSET}} — By default the ''xofs'' and ''yofs'' parameters apply the warped-to actor's angle; this flag disables this behaviour.
:*{{c|WARPF_ABSOLUTEANGLE}} — Use the angle parameter as an absolute angle, instead of an offset.
:*{{c|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.
:*{{c|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. <!-- This looks really amusing in-game. -->
:*{{c|WARPF_NOCHECKPOSITION}} — Blindly accept any resultant position, instead of checking for the warp being a valid movement.
:*{{c|WARPF_STOP}} — Reduce warping actor's velocity to 0 when the move is completed, similar to A_Stop.
:*{{c|WARPF_TOFLOOR}} — Makes the ''zofs'' parameter relative to the floor, rather than relative to the warped-to actor.
:*{{c|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.
:*{{c|WARPF_BOB}} — Makes the warping actor's {{Flag|FLOATBOB|floatbob}} phase follow the warped-to actor's.
:*{{c|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.
:*{{c|WARPF_USETID}} — If set, the first parameter changes to accept a {{c|[[TID|tid]]}} instead of an actor pointer.
:*{{c|WARPF_COPYVELOCITY}} — Copies the warped-to actor's velocity exactly, regardless of how the warping actor is moving.
:*{{c|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'': Keep old interpolation data (make it appear as if actor moved from its previous location)
:*{{c|WARPF_INTERPOLATE}} — Keeps the warping actor's default interpolation data.
* ''WARPF_WARPINTERPOLATION'': Modify interpolation data with the vector PlayerNewPosition - PlayerOldPosition.
:*{{c|WARPF_WARPINTERPOLATION}} — Modify interpolation data with the vector PlayerNewPosition - PlayerOldPosition. <!-- TODO: what the hell? -->
* ''WARPF_COPYINTERPOLATION'': Copies the actor's interpolation data for itself, allowing the actor to mimic the pointer closely.
:*{{c|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 in the event of success.
*'''success_state''': An optional state to jump to if the warp succeeds.
*'''heightoffset''': Adds the warped-to actor's {{Property|Height|height}} multiplied by ''heightoffset'' to the ''zofs'' parameter. Default is 0.
*'''radiusoffset''': Adds the warped-to actor's {{Property|Radius|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.
A replication of [[A_Fire]] would be similar to this:<br>
{{JumpNotice}}


===Return values===
'''A_Warp(AAPTR_TRACER, 24, 0, 0, 0, WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)'''
{{ZScriptNote}}
[[category:Decorate Missile movement functions]]{{DEFAULTSORT:Warp}}
This function has 2 return values:
# ''state'' — The state to jump to, if <code>success_state</code> was defined and the jump is possible.
# ''bool'' — Returns true if the warping succeeded. Warping may fail if the {{c|WARPF_NOCHECKPOSITION}} flag is ''not'' passed and there's no space for the warped actor to move.

==Examples==
The following example is a replication of [[A_Fire]]:<br>
[[A_Warp]]({{const|AAPTR_TRACER}}, 24, 0, 0, 0, {{const|WARPF_NOCHECKPOSITION}}|{{const|WARPF_INTERPOLATE}})


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

ACTOR SpecialBaronOfHell : {{Class|BaronOfHell}}
{
States
{
Spawn:
BOSS A 0 [[actor states#NoDelay|NoDelay]] [[A_CustomMissile]]("OrbitBall", 32, 0, 0, {{const|CMF_AIMDIRECTION}})
Idle:
Goto Super::Spawn
}
}
ACTOR OrbitBall
{
{{Property|RenderStyle}} "Add"
{{Property|Translation}} "0:255=%[0,0,0]:[0.93,2,0.87]" // Makes it green-colored
+{{Flag|MISSILE}}
+{{Flag|NOINTERACTION}}
var int user_angle; // See [[user variable]]s
States
{
Spawn:
BAL1 A 1 [[actor states#Bright|Bright]] [[actor states#NoDelay|NoDelay]] [[A_Warp]]({{const|AAPTR_TARGET}}, 32, 0, 32, user_angle, {{const|WARPF_ABSOLUTEANGLE}}|{{const|WARPF_NOCHECKPOSITION}}|{{const|WARPF_INTERPOLATE}})
TNT1 A 0 [[A_SetUserVar]]("user_angle", user_angle + 8)
Loop
}
}

When choosing the [[actor pointer|pointer]] for the function, i.e, the actor the projectile should warp to, {{c|target}} is what to go for, in this case, since a projectile's target is usually the actor which fires it.
[[category:Decorate Missile movement functions]][[category:Decorate Jump functions]]{{DEFAULTSORT:Warp}}

Latest revision as of 10:05, 13 October 2025

Actor

action native state, bool A_Warp(int ptr_destination, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, statelabel success_state = null, double heightoffset = 0, double radiusoffset = 0, double pitch = 0)

Usage

Warps the calling actor (by default) to the specified actor pointer. Originally designed as a more versatile analog to A_Fire (used by Arch-Vile flame).

For a ZScript-only version that takes a proper ZScript actor pointer instead of an AAPTR constant, see Warp (ZScript).

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.


Return values

Note: This feature is for ZScript only.

This function has 2 return values:

  1. state — The state to jump to, if success_state was defined and the jump is possible.
  2. bool — Returns true if the warping succeeded. Warping may fail if the WARPF_NOCHECKPOSITION flag is not passed and there's no space for the warped actor to move.

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.