zscript-doc/api/actor/State.md

120 lines
2.7 KiB
Markdown
Raw Normal View History

2018-12-29 16:05:19 -08:00
# State
Represents a state on an `Actor` or `StateProvider`. Data in `State` is
read-only and is copied as needed to its respective locations for modification,
as it is merely a look into the global constant state table.
2018-12-29 16:05:19 -08:00
```
struct State
{
readonly uint8 Frame;
readonly State NextState;
readonly int Sprite;
readonly int16 Tics;
readonly int Misc1;
readonly int Misc2;
readonly uint16 TicRange;
readonly uint8 UseFlags;
2019-08-14 01:31:50 -07:00
readonly bool bCanRaise;
readonly bool bDeHackEd;
readonly bool bFast;
readonly bool bFullBright;
readonly bool bNoDelay;
readonly bool bSameFrame;
readonly bool bSlow;
2018-12-29 16:05:19 -08:00
2018-12-29 20:04:32 -08:00
int DistanceTo(State other);
bool InStateSequence(State base);
2018-12-29 16:05:19 -08:00
bool ValidateSpriteFrame();
textureid, bool, vector2 GetSpriteTexture(int rotation, int skin = 0, vector2 scale = (0, 0));
}
```
2019-08-14 03:31:41 -07:00
### `Frame`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
The sprite frame of this state.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `NextState`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
A pointer to the next state in the global state table.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `Sprite`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
The sprite ID of this state.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `Tics`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
The number of game ticks this state lasts.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `Misc1`, `Misc2`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
Primarily used in DeHackEd compatibility. Don't use this.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `TicRange`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
The maximum amount of tics to add for random tic durations, or `0` if the
duration is not random. For example, `TNT1 A random(5, 7)` would have a `Tics`
value of `5` and a `TicRange` of `2`.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `UseFlags`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
The scope of this state. See *Action Scoping*. Can have any of the
`DefaultStateUsage` flags.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `bCanRaise`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
State has the `CanRaise` flag, allowing `A_VileChase` to target this actor for
healing without entering an infinitely long state.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `bDeHackEd`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
`true` if the state has been modified by DeHackEd.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `bFast`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
State has the `Fast` flag, halving the duration when fast monsters is enabled.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `bFullBright`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
State has the `Bright` flag, making it fully bright regardless of other
lighting conditions.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `bNoDelay`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
State has the `NoDelay` flag, forcing the associated action function to be run
if the actor is in its first tic.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `bSameFrame`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
`true` if the state's frame is to be kept from the last frame used, i.e., is
`#`.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `bSlow`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
State has the `Slow` flag, doubling the duration when slow monsters is enabled.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `DistanceTo`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
Returns the offset between this state and `other` in the global frame table.
Only works if both states are owned by the same actor.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `InStateSequence`
2018-12-29 20:04:32 -08:00
2019-08-14 03:31:41 -07:00
Returns `true` if this state is within a contiguous state sequence beginning
with `base`.
2018-12-29 20:04:32 -08:00
2019-08-14 03:31:41 -07:00
### `ValidateSpriteFrame`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
Returns `true` if the sprite frame actually exists.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `GetSpriteTexture`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
Returns the texture, if the texture should be flipped horizontally, and scaling
of this state's sprite. Scaling will return `scale` unless `skin` is nonzero.
`skin` determines the player skin used.
2018-12-29 16:05:19 -08:00
<!-- EOF -->