SetStateLabel
bool SetStateLabel(statelabel st, bool nofunction = false)
Usage
Forcefully sets the calling actor's State to the specified state sequence. Same as SetState, except the first argument is the name of a state sequence (like "Spawn") rather than a state pointer.
Note: This is NOT a state jump function, and it should not be called from inside a state/anonymous function. It's meant to be called from outside of states. For state jumps, use return FindState("<State label>") in actors, or return ResolveState("<State label>") in weapons.
Parameters
- statelabel st
- The name of a state sequence, like "Spawn".
- bool nofunction
- If the first state in the defined state label has a function attached, passing
true
to this argument will force that function to not be called.
Return values
Returns true if the state was successfully modified.
ZScript definition
Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub. |
bool SetStateLabel(statelabel st, bool nofunction = false)
{
return SetState(FindState(st), nofunction);
}
Examples
This version of Doom Imp's fireball after existing for 10 tics will move from Spawn state sequence to the Plasma state sequence, which makes it look like the PlasmaBall:
class FakePlasmaBall : DoomImpBall
{
override void Tick()
{
super.Tick();
// Check if age is above 10 tics and the actor is currently
// in its spawn state sequence:
if (GetAge() > 10 && InStateSequence(curstate, spawnstate))
{
SetStateLabel("Plasma");
}
}
States
{
Plasma:
PLSS AB 5 bright;
loop;
}
}
Used in the example:
Note: spawnstate
is an Actor field that contains a pointer to the first state in their Spawn state sequence. It's the same as FindState("Spawn")
.