wolfenstein

Every actor in Wolfenstein 3D exists in one state at every point in time. This state changes variously to change the actor's status.

"Actor" here refers mainly to enemies, though other objects such as projectiles fall under the same category.

Possible states

Specific actors only

State definition

A state is declared to exist in the source code, mainly in WL_ACT2.C. This is done with the extern command. After that, it is described in greater detail with the statetype command. For an abridged example, here are the declarations and definitions of two of a Guard's states - Stand and Path.

extern	statetype s_grdstand;

extern	statetype s_grdpath1;
extern	statetype s_grdpath1s;
extern	statetype s_grdpath2;
extern	statetype s_grdpath3;
extern	statetype s_grdpath3s;
extern	statetype s_grdpath4;

statetype s_grdstand	= {true,SPR_GRD_S_1,0,T_Stand,NULL,&s_grdstand};

statetype s_grdpath1 	= {true,SPR_GRD_W1_1,20,T_Path,NULL,&s_grdpath1s};
statetype s_grdpath1s 	= {true,SPR_GRD_W1_1,5,NULL,NULL,&s_grdpath2};
statetype s_grdpath2 	= {true,SPR_GRD_W2_1,15,T_Path,NULL,&s_grdpath3};
statetype s_grdpath3 	= {true,SPR_GRD_W3_1,20,T_Path,NULL,&s_grdpath3s};
statetype s_grdpath3s 	= {true,SPR_GRD_W3_1,5,NULL,NULL,&s_grdpath4};
statetype s_grdpath4 	= {true,SPR_GRD_W4_1,15,T_Path,NULL,&s_grdpath1};

The parameters appear to be, in order:

  1. Whether the state has individual sprites for rotation or not; non-rotatable states (like shooting or dying) always show a sprite facing the player.
  2. Name of sprite which applies during this state (a sprite may apply to multiple states); for rotatable states that's the sprite facing the player, the rotated sprite will then be picked during runtime
  3. Length of state, in tics (zero tics is infinite state)
  4. Functions to perform during this state
  5. Functions to perform, or audio to play, during this state
  6. The state that should follow this state

Trivia

References

  1. WOLFSRC/WL_ACT2.C from the Wolfenstein 3D source code on github.com, line 398
  2. WOLFSRC/WL_ACT2.C from the Wolfenstein 3D source code on github.com, line 545
  3. WOLFSRC/WL_ACT2.C from the Wolfenstein 3D source code on github.com, line 611