A_Lower
action void A_Lower(int lowerspeed = 6)
Usage
This function must be called in a weapon's Deselect state sequence. It should not be used anywhere else. It is responsible for lowering the weapon until it is off the screen and for selecting another weapon when it is done.
Each time the function is called, the weapon moves further down the screen until it has reached the fully lowered position. Therefore, if the function is called multiple times per tic, the weapon will be lowered faster, but this should not be done intentionally (instead, the lowerspeed argument should be used to change the speed).
| Warning: Do not call this function repeatedly in the same state inside another function, anonymous or otherwise. All calls to A_Lower are executed fully inside the other function, even if the weapon has reached its ready position, resulting in unwanted side effects. |
Parameters
- int lowerspeed
- How much the weapon is lowered by. Default is 6.
Examples
Here is an example of a basic Deselect state that makes use of this function to move the weapon down towards the lowered position and then select a new weapon:
Deselect: SHTG A 1 A_Lower; Loop;
This will lower the weapon down off the screen when a new weapon is selected. Once it has reached the fully lowered position, A_Lower will change to the new weapon that was selected.
This weapon lowers from view twice as fast as normal:
Deselect: FAST A 1 A_Lower(12); Loop;
ZScript definition
| Note: The ZScript definition below is for reference and may be different in the current version of UZDoom. The most up-to-date version of this code can be found on UZDoom GitHub. |
action void A_Lower(int lowerspeed = 6)
{
let player = player;
if (null == player)
{
return;
}
if (null == player.ReadyWeapon)
{
player.mo.BringUpWeapon();
return;
}
let psp = player.GetPSprite(PSP_WEAPON);
if (!psp) return;
if (Alternative || player.cheats & CF_INSTANTWEAPSWITCH)
{
psp.y = WEAPONBOTTOM;
}
else
{
psp.y += lowerspeed;
}
if (psp.y < WEAPONBOTTOM)
{ // Not lowered all the way yet
return;
}
ResetPSprite(psp);
if (player.playerstate == PST_DEAD)
{ // Player is dead, so don't bring up a pending weapon
// Player is dead, so keep the weapon off screen
player.SetPsprite(PSP_FLASH, null);
psp.SetState(player.ReadyWeapon.FindState('DeadLowered'));
return;
}
// [RH] Clear the flash state. Only needed for Strife.
player.SetPsprite(PSP_FLASH, null);
player.mo.BringUpWeapon ();
return;
}

