Post tutorial RSS Doom Source Code Tutorial 6

Not really a source code tutorial. Today we will further explore the definitions files in doom.

Posted by on - Basic Client Side Coding

Tutorial 6
Game: Doom1, Doom2.
Level: Basic.
Objective: Modify the definitions files (defs files).
Resources required: Text editor, duh....defs files (doomsday or risen3d).
Introduction: We have used this technique for the past few tutorials in order to explain how the weapons worked in the game and how to modify them. As an absolute beginner, you must have realized by now, having browsed through them a number of times, how important they are. These files contain message text, numbers, values, structures and pointers to data in the Iwad file that the game needs to run. The data in these files get loaded into memory when doom starts up. Therefore changing the content or data in these files can affect many aspects of the game play. Generally speaking it is not recommended to alter the data in these files directly unless you know exactly what you are doing, as corrupting these files can lead to crashes and erratic game behavior. However studying the content of defs files and experimenting with them provides an excellent learning resource and gives the beginner an insight into many aspects of game programming and design, and hey it is absolutely free! The files we will examine today are the ones that affect player interaction and game play. The rest you can explore on your own as you get the hang of it I am sure. But remember; always make a back up copy before you do any experimenting.
Procedure:
1. Using notepad++ (or your favorite text editor) open the defs file "Values.ded", you'll find it inside the Snowberry doomsday 1.9.0 beta 6.9 game launcher folder. Other versions may differ from this to some extent. This file is used to initialize the values of the player's health, armor and ammo as well as what weapons he owns when he enters the level. It also gives control over the health and armor limits, even for cheat codes (if you want to do extreme cheating!), and what type of ammo is assigned to each weapon and how much each shot uses up. You can also set the upper limits for these items. Let's have a look at the first few blocks.My comments are shown in red.

Player {
Health = "100"; ← Initial health.
Max Health = "100"; ← Maximum health.
Health Limit = "200"; ← Absolute health limit.
God Health = "100"; ← Health when god mode is activated.
Green Armor = "100";
Blue Armor = "200";
IDFA Armor = "200"; ← Armor given when the IDFA cheat is activated.
IDKFA Armor = "200"; ← Armor given when the IDKFA cheat is activated.
Max Ammo {
Clip = "200"; ← Maximum bullets
Shell = "50"; ← Maximum shells
Cell = "300"; ← Maximum cells
Misl = "50"; ← Maximum rockets
};

Clip Ammo {
Clip = "10"; ← clip bonus
Shell = "4"; ← shells bonus
Cell = "20"; ← cells bonus
Misl = "1"; ← rocket bonus
};

Init Ammo {
Clip = "50"; ← player starts with only 50 bullets, no other ammo.
Shell = "0";
Cell = "0";
Misl = "0";
};

2.So set initial health to "30" if you want your player to start the game half-dead or do the opposite and make him a super player with an initial value of say 150 or whatever; but be careful here when playing with these figures as there are obviously certain constraints and limits set by the game as you can see. For example if you set the initial health to 150 ,and the value of Absolute Health limit to 120, then as soon as you pick up a health bonus in the game, your health will not increase as you'd expect but will immediately drop back to 120. How much ammo picked up for each individual weapon while you play the game is also set here in the "Clip Ammo" block. Notice that your initial ammo is set to just 50 bullets in the next block with no shells or missiles (you would be tempted to change that, wouldn't you?). Upper limits for all your ammo is set in duh... Max Ammo, just experiment with these figures and observe what happens, and you will soon get the hang of it.
3.Finally the next 9 blocks in the file under Weapon Info are used to set the states values for each weapon. I am showing below just the first 3.

Weapon Info {
0 { ← 0 for Fist
Type = "noammo";
Up = "PUNCHUP";
Down = "PUNCHDOWN";
Ready = "PUNCH";
Atk = "PUNCH1";
Flash = "NULL";
Owned = "1";
Static = "0";
};

1 { ← Pistol
Type = "clip"; ← if you wish, change ammo type for the pistol here.
Per shot = "1"; ← set this to "0" if you want infinite ammo
Up = "PISTOLUP";
Down = "PISTOLDOWN";
Ready = "PISTOL";
Atk = "PISTOL1";
Flash = "PISTOLFLASH";
Owned = "1";
Static = "0";
};

2 { ← Shotgun
Type = "shell";
Per shot = "1";
Up = "SGUNUP";
Down = "SGUNDOWN";
Ready = "SGUN";
Atk = "SGUN1";
Flash = "SGUNFLASH1";
Owned = "0"; ← set this to "1" for this weapon to be always possessed by player.
Static = "0";
};

4.Here you have the chance of selecting which or how many guns your player carries or owns when he enters the game by setting the "owned" parameter to either "1" or" 0" .Also you can modify ammo usage by setting the "Per shot" value to any reasonable value, so instead of your BFG consuming 40 cells each time you fire it, economize on that by reducing it to 5 cells for example, a very useful cheat for hard levels. You can also set any weapon to have an infinite ammo cheat by setting the Per shot parameter to "0". You would be happy to know now that you may change the ammo type. Your sniper rifle in tutorial 4 can be set to use bullets (clip) instead of shells.
5.Next let's have a look at another important defs file, Text.ded. In this one you'll find all the text messages in the game. Each message has an ID and a text string .Needless to say it is very easy to modify. Have a go. Change the message (in line 160) from "Picked up a health bonus." to " Yuk, I hate the taste of medicine. "

Text {
ID = "GOTMEGA";
Text = "Picked up the MegaArmor!";
}

Text {
ID = "GOTHTHBONUS";
Text = "Picked up a health bonus.";
}

Text {
ID = "GOTARMBONUS";
Text = "Picked up an armor bonus.";
}

6.At this stage I recommend that you take your time to read through and study the most important file of them all, Objects.ded (in Risen3d it is split into separate files). We have already done all the previous work using this file. It is a huge resource of vital data and you can learn a lot from it. We will come back to this one when we study monsters and enemies in Doom in a future tutorial.

Probably all this talk about making easy mods using just a simple text editor like the humble notepad, and with absolutely no need for any knowledge of C or compilers, made you drool all over your keyboard with excitement. I am afraid, there is a downside to things here. You see, unless you are using a specially adapted port like zdoom or its derivatives, this method brings along a number of disadvantages of its own. There are a lot of unusual effects and brilliant modifications you may want to make, especially those that have a substantial impact on the game play, can only be achieved through actual source code programming and nothing else. Besides, suppose you wanted to distribute a mod that you've made this way to other players or friends, then you have to distribute the appropriate edited "def " files that go with it and make sure the end users place these files in the right folder or your mod won't work. Also there are other pitfalls like recording a demo. It is well known that recording demos in Doom and playing them back can sometimes be a temperamental business and you may get weird effects if you do that with a directly edited defs file. Also what works for 2D sprites may not work well for 3D models. In addition, certain data are re-modified back to their original set values from within the doom.exe file no matter what you do to that data in the defs files, try increasing the speed of the imp fire ball for example. You may ask the question now: why bother then? The answer is covering this subject now, as I said earlier and in my humble opinion, lays down the foundations for the absolute beginner, shows him the basics and gives him an insight into how certain aspects in Doom work, as we saw in tutorials 3 and 4. It also provides a simple way to make some modifications to the game for those that cannot digest programming in C.

In closing this chapter, we will soon show how to modify these files the right way; from within the source code.
Enough for now.
See you next time.
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.