|Note: This feature is for ZScript only.|
States are what store information about the current animation and logical state of an Actor or overlay. A state is not the entire sequence of a label but the single frame that defines what something is doing at that very moment. For instance:
Fire: PISG A 4; PISG B 6 A_FirePistol; PISG C 4; PISG B 5 A_ReFire; Goto Ready;
In the above case, there's not one state, but four. PISG A, B, C, and then B again all define separate states. They are all combined under one state sequence with the first being given the state label Fire. This also applies for stacked frames:
Ready: WEAP AAA 4 A_WeaponReady; WEAP BCB 4 A_WeaponReady; Loop;
The above has six states, WEAP A, A, A, B, C, and B. When using a function like ResolveState, the state returned is the one defined at the given label. For instance, calling ResolveState("Fire") would return the state PISG A 4;
An Actor or PSprite's state can be gotten at any time via its CurState variable e.g. myActor.CurState
Note: All fields are defined as readonly.
- State NextState - Stores a pointer to the next state in the sequence. If null, the Actor/PSprite is set to terminate after this state.
- int sprite - The index of the sprite to use for this state. This is the same as GetSpriteIndex() with the name of the sprite the state uses. This has a few notable base values:
- 0 - Sprite is set to TNT1
- 1 - State is set to be fixed i.e. doesn't change sprite or frame
- 2 - Sprite is set to use the same sprite as the previous state
- int16 Tics - The base duration of the state measured in tics.
- uint16 TicRange - If non-zero, defines a random range for the duration. This is done via Tics + Random2[StateTics]() % (TicRange + 1)
- uint8 Frame - The frame id to use for this state e.g. A = 0, B = 1, etc.
- uint8 UseFlags - Defines where the state can be used e.g. in weapon overlays, in CustomInventory overlays, etc.
- int Misc1 - The x offset to give an overlay via the Offset keyword.
- int Misc2 - The y offset to give an overlay via the Offset keyword.
- uint16 bSlow - The state is marked with the Slow keyword.
- uint16 bFast - The state is marked with the Fast keyword.
- bool bFullbright - The state is marked with the Bright keyword.
- bool bNoDelay - The state is marked with the NoDelay keyword.
- bool bSameFrame - The state uses the same frame as the previous state.
- bool bCanRaise - The state is marked with the CanRaise keyword.
- bool bDehacked - The state has been replaced via DeHackEd.
- int DistanceTo(State other)
- bool ValidateSpriteFrame()
- TextureID, bool, Vector2 GetSpriteTexture(int rotation, int skin = 0, Vector2 scale = (0,0))
- bool InStateSequence(State base)