Post tutorial RSS Doom Source Code Tutorial 5

Power-up your bullet weapons Part 2. In this tutorial we will convert the shotgun into a machine gun

Posted by on - Basic Client Side Coding

Tutorial 5
Game: Doom1, Doom2.
Level: Basic.
Objective: Modify the shotgun using definitions (defs) files.
Resources required: Text editor, defs files (doomsday, without 3d models).
Introduction: Welcome to the second half of modding the bullet weapons in Doom. This time we will turn the shotgun into a machine gun using the same techniques we learned in the previous sessions. It is also a good opportunity to show how the shotgun works in detail.
Procedure:
1. Using your favorite text editor, open up your objects.ded file you found in the doomsday game folder as described in part 1 and go to the shotgun attack states as shown below, it should start at line 3647 ,here I am displaying the corresponding sprite frame that goes with each state:

State {
ID = "SGUN1";
Sprite = "SHTG";
Frame = 0; see Fig.1 below
Tics = 3;
Next state = "SGUN2";
}

Fig.1 SHTGA0

State {
ID = "SGUN2";
Sprite = "SHTG";
Frame = 0; see Fig.2 below
Tics = 7;
Action = "A_FireShotgun";
Now jump to state: "SGUNFLASH1" , all the way down, and then come back here!
Next state = "SGUN3";
}

Fig.2 SHTGA0

State {
ID = "SGUN3";
Sprite = "SHTG";
Frame = 1; see Fig.3 below
Tics = 5;
Next state = "SGUN4";
}

Fig.3 SHTGB0

State {
ID = "SGUN4";
Sprite = "SHTG";
Frame = 2; see Fig.4 below
Tics = 5;
Next state = "SGUN5";
}

Fig.4 SHTGC0
State {
ID = "SGUN5";
Sprite = "SHTG";
Frame = 3; see Fig.5 below
Tics = 4;
Next state = "SGUN6";
}

Fig.5 SHTGD0

State {
ID = "SGUN6";
Sprite = "SHTG";
Frame = 2; see Fig.6 below
Tics = 5;
Next state = "SGUN7";
}

Fig.6 SHTGC0

State {
ID = "SGUN7";
Sprite = "SHTG";
Frame = 1; see Fig.7 below
Tics = 5;
Next state = "SGUN8";
}

Fig.7 SHTGB0

State {
ID = "SGUN8";
Sprite = "SHTG";
Frame = 0; see Fig.8 below
Tics = 3;
Next state = "SGUN9";
}

Fig.8 SHTGA0

State {
ID = "SGUN9";
Sprite = "SHTG";
Frame = 0; see Fig.9 below
Tics = 7;
Action = "A_ReFire";
Next state = "SGUN";
}

Fig.9 SHTGA0

State {
ID = "SGUNFLASH1";
Sprite = "SHTF";
Frame = 0; see Fig.10 below
Flags = fullbright;
Tics = 4;
Action = "A_Light1"; ← display bright gun flash on surroundings, intensity 1.
Next state = "SGUNFLASH2";
}

Fig.10 SHTFA0

State {
ID = "SGUNFLASH2";
Sprite = "SHTF";
Frame = 1; see Fig11 below
Flags = fullbright;
Tics = 3;
Action = "A_Light2"; ← display bright gun flash on surroundings, intensity 2.
Next state = "LIGHTDONE";
}


Fig.11 SHTFB0

State {
ID = "LIGHTDONE"; ← now we are going to extinguish the gun flash.
Sprite = "SHTG";
Frame = 4; ← dummy frame, there is nothing to display here, Tics = 0.
Tics = 0;
Action = "A_Light0"; ← turn off flash, return to normal light level.
Next state = "NULL"; ← this means return; next state is "SGUN3", go all the way back up
}

2. These sprites were extracted from the doom.wad data file; notice the numbering scheme for the sprites: SHT refers to the shotgun weapon, G means Gun sprite, F means flash sprite; the letters at the end A, B, C ... refer to the frame number. So SHTGA0 denotes the first gun sprite frame for the shotgun, SHTFB0 refers to the second flash sprite for the same. For simplicity, please note we are not using 3D models in this mod.
3. The shotgun animation operates in the same way we described for the chain gun in the previous tutorials. If things are not clear here just take a quick look back through tutorial 3.The only difference is that we have two consecutive flash states that light-up the level during the firing stage, giving 2 levels of brightness at the locality of the player before it terminates by "NULL". The animation sequence jumps to these two states from within the action function call "A_FireShotgun" as detailed in tutorial 3, the rest is self-explanatory.
4. Now back to our work. We need first to know how to remove the pump action re-loading sequence for our sniper rifle mod as described in part 1 of this session. This can be done very easily. Just carefully examine the animation sequence above. You will see 5 frames used for re-loading the gun. They start at state SGUN3 and end at SGUN7 .With a total tic rate of 24; they are the primary reason why the shotgun is so slow to use. All what we need to do here is simply disable all these 5 frames by setting their tic values to 0, each and every one of them. Use your text editor to do that and save your file. When you start your game, you'll notice that the pump action has completely gone and the rifle is much faster to re-load.
5. Finally we want to convert our shotty into a rapid action machine gun. Again we will disable all the re-loading frames as in 4 above, and further, we will speed up the firing by reducing the tics rate in states SGUN1, SGUN8 and SGUN9 down to 1 tic. Try it now.
6. If you want to be more adventurous or dying for even a faster machine gun, reduce the tics in state SGUN2, the one that calls the firing action. This will give you extra speed but note, you may need to make the total tics here equal to the sum of the two flash states' tics or your firing animation may look a bit untidy (Tip: set SGUN2 to 3 tics, SGUNFLASH1 to 2 tics and SGUNFLASH2 to 1 tic). Play with the figures to your heart content!
7. As for accuracy, you have the choice of either opting for real machine gun action by leaving the original shotgun source code untouched and make a fast lead sprayer, or keep the changes we've made for the sniper rifle and have both power and precision.
That's it for today.
Bye now.
Adam.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.