bool A_Overlay (int layer, state st = "", bool nooverride = false)
A_Overlay
Availability
ZandroX only. Does not exist in Zandronum 3.2. Behaviour follows GZDoom's DECORATE
A_Overlay.Works in netgames. A player's client runs its own layers and takes each layer's jumps from the server — see Psprite layers.
Returns whether it set the layer, as UZDoom's does:
falsewith no player attached or whennooverridekept a layer already there, soif (A_Overlay(5, "Scope", true))in a{ }block runs only the first time.
Usage
Places a psprite on the given layer, starting it at state st, creating
the layer if it does not exist yet. This is the function that makes every other one in the
family useful: nothing else creates a layer.
Before this, a weapon had exactly two sprites available to it — itself and its flash — so an extra hand, a scope, a shell ejecting, or a second gun had to be animated into the weapon's own sprite sheet, frame by frame, multiplying the art for every combination.
The overlay runs its own state sequence, independently of the weapon's. When that sequence
reaches Stop, the layer removes itself.
Calling A_Overlay on a layer that already exists replaces its state, restarting it at
st — unless nooverride is set.
Only the player's psprites are affected, so this does nothing when called from an actor with no player attached. A player class may call it from its own states: such a layer runs the player class's states and outlives weapon changes (see Psprite layers).
Parameters
-
int layerThe layer id to place the sprite on. Any integer, though ids
2and up or-2and down are recommended to stay clear of the reserved ones; see Psprite layers for those and for what the sign and magnitude mean for draw order.0means the layer whose state is currently executing, letting an overlay replace its own state chain. If nothing is executing on a layer, the call does nothing. -
state stThe state to start the layer at. Defaults to none — and calling
A_Overlaywith no state removes the layer, which is the explicit counterpart to letting it run toStop. -
bool nooverrideWhen
true, do nothing if the layer already exists and currently has a state. Use it to start an overlay that must not be restarted while it is still playing — a reload animation triggered from aA_WeaponReadyloop, for example. Default isfalse.A layer that exists but has already ended its state chain does not count as occupied, so
nooverridewill still start it.
Examples
A pistol that ejects a spent casing on a layer of its own. The casing animation is 6 tics long
and plays out on layer 5, in front of the weapon (id 1) but behind the flash (id 1000),
while the weapon's own states carry straight on to the refire check — the two run at the same
time, which is the whole point.
Stop at the end of the Casing sequence is what removes layer 5; without it the layer would
linger on its last frame forever.
ACTOR CasingPistol : Pistol
{
States
{
Fire:
PISG A 4
PISG B 6 A_FirePistol
PISG B 0 A_Overlay(5, "Casing")
PISG C 4
PISG B 5 A_ReFire
Goto Ready
Casing:
CASE ABC 2
Stop
Flash:
PISF A 7 Bright A_Light1
Goto LightDone
}
}
A scope overlay that must not restart while it is already showing. Layer -2 draws behind the
weapon, so the scope body sits under the gun. nooverride means holding the alt-fire button
down re-enters this state every tic without ever resetting the scope's fade-in.
AltFire:
PISG A 1 A_Overlay(-2, "Scope", true)
PISG A 1 A_ReFire
Goto Ready
Scope:
SCOP BCDE 2
SCOP E -1
Stop
Note the SCOP E -1: an infinite duration keeps the layer alive until something removes it —
here, the weapon being switched away, or an explicit
A_ClearOverlays.
See also
- Psprite layers — the layer model, draw order, and lifetime rules
- A_ClearOverlays — remove layers by range
- OverlayID — the calling layer's id
- A_OverlayFlags, A_OverlayOffset, A_OverlayScale, A_OverlayAlpha, A_OverlayRenderStyle