ResolveState

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


Actor

clearscope native state ResolveState(statelabel st)

Usage

Obtains a pointer to the first Actor state in the specified state sequence. This can be returned in an anonymous function or a function that returns a state.

In contrast to FindState, this is context-aware, which mainly means that it can be called just as ResolveState, without any prefixes, not only in actors, but also in Weapon. (In contrast, FindState must be called as invoker.FindState from weapon states or action functions). That said, ResolveState is not limited to weapons and can be safely used on any actor.

Parameters

  • statelabel st
The name of the state sequence, such as "Ready", "Fire", etc.

Examples

This version of the Pistol not only fires on the very first tic of Fire, but also lets the player manually refire by tapping (but not holding) the fire button anywhere during the PISG CCCBBBAAA part of the animation:

class FastPistol : Pistol
{
	States
	{
	Fire:
		PISG B 3 A_FirePistol;
		PISG C 3;
		PISG CCCBBBAAA 1
		{
			// Check the player is pressing the Fire button now
			// but wasn't pressing it during the previous tic:
			if (player.cmd.buttons & BT_ATTACK && !(player.oldbuttons & BT_ATTACK))
			{
				// If so, go back to Fire:
				return ResolveState("Fire");
			}
			// Otherwise continue (and go to Ready):
			return ResolveState(null);
		}
		Goto Ready;
	Flash:
		// This has to be modified in order to
		// match the new duration of the main
		// attack frame:
		PISF A 3 Bright A_Light1;
		Goto LightDone;
	}
}

Note, if you want to completely disable autofiring, you will also need to add Weapon.NOAUTOFIRE flag.

See also