TheDarkArchon presents:
SOC Enemies 101
This tutorial assumes you know the basics of WAD manipulation and have your enemy sprites already in your WAD with sprite names F001. You'll need an unzipped copy of the source code as well. For the tutorial, I will create a crawla clone with 2 health.
Create a blank SOC file as described in the SOC editor, and point the source part of the main SOC editor window to the <sourcedir>/src directory, where <sourcedir> is the location of the source code.
Once you have done this, open your blank SOC and open state editor (Edit States button). Scroll down to state 1352 which is the first unused state. This will be used as your monsters first state, which is used for your enemy looking out for players to attack.
First, look at the sprite drop-down box. Here is the sprite box, where you define the sprite for this frame. I'm using sprites F001, the first unused sprite slot. Ignore the SPR_ suffix: This is only an internal thing.
Next is the frame. The frame is the particular image is shown. Each number corresponds with a letter, starting with A which corresponds to 0, then to B which coreesponds to 1 and so on. The rotation number does not get taken into account here: That's handled automatically by the engine.
Next is the tics box, which defines how long a particular frame will last. Tics is the timing unit in SRB2, where 35 tics = 1 second. For a look state, such as what we're working with right now, this will alter how long an enemy will take to react to the sight of a player.
The next thing is the "Function to Call" box. This box will decide what the enemy will do on this frame. For looking out frames, you use A_Look, which tells your enemy to look out for the player.
Now, next is the next state box. Point this to frame 1353.
Now save your changes by clicking the "save state" button and click state 1353 and set the same settings as above but for the next frame, point back to frame 1352. This is to overcome a limitation in the Doom engine.
Next, click on state 1354. This will be your first state for when your enemy is persuing a player. All the boxes are used the same as before, but have the frame call the function "A_Chase". A_Chase moves the enemy towards the player. The distance the monster moves when this function is called is defined by the enemies speed property which will be explained later. Remember to point to your next chasing frame after this and to make your last chasing frame.