A_Raise

From ZDoom Wiki
Jump to navigation Jump to search
Note: This function should not be confused with the resurrection functions which have similar naming.
DoomWiki.org
For more information on this article, visit the A_Raise page on the Doom Wiki.


Weapon

action void A_Raise(int raisespeed = 6)

Usage

This function must be called in a weapon's Select state sequence. It should not be used anywhere else. It is responsible for raising the weapon and for entering the Ready state sequence when it is done.

Each time the function is called, the weapon moves further up the screen as it approaches the ready position. You can therefore make a weapon raise faster than the default by calling the function more than once within the same tic, or by passing the desired speed directly.


Warning: Do not call this function repeatedly in the same state inside another function, anonymous or otherwise. All calls to A_Raise are executed fully inside the other function, even if the weapon has reached its ready position, resulting in unwanted side effects.


Parameters

  • int raisespeed
How much the weapon is raised by. Default is 6.

Examples

Here is an example of a basic Select state that makes use of this function to bring the weapon up to the ready position:

Select:
   SHTG A 1 A_Raise;
   Loop;

This will raise the weapon up from the bottom of the screen when it is selected. Once it has reached the ready position, A_Raise will automatically jump to the Ready state.


This weapon raises into view twice as fast as normal:

Select:
   FAST A 1 A_Raise(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_Raise(int raisespeed = 6)
	{
		let player = player;

		if (null == player)
		{
			return;
		}
		if (player.PendingWeapon != WP_NOCHANGE)
		{
			player.mo.DropWeapon();
			return;
		}
		if (player.ReadyWeapon == null)
		{
			return;
		}
		let psp = player.GetPSprite(PSP_WEAPON);
		if (!psp) return;

		if (psp.y <= WEAPONBOTTOM)
		{
			ResetPSprite(psp);
		}
		psp.y -= raisespeed;
		if (psp.y > WEAPONTOP)
		{ // Not raised all the way yet
			return;
		}
		psp.y = WEAPONTOP;

		psp.SetState(player.ReadyWeapon.GetReadyState());
		return;
	}

See also