User Tools

Site Tools


tutorials:modding:dehacked

This is an old revision of the document!


DeHackEd

DeHackEd is an ancient and antiquated means to edit the behavior of items and monsters in Doom. It's severely limited, but most source ports are fully or mostly compatible with it all the way down to vanilla (if you hack the vanilla exe that is, hence the name deHACKed).

The gist is this - Doom monsters, weapons, and items (“Things”) update their behavior every tic of game logic. 35 tics per second. So if you make a rabbit thing and want it to jump up every 2 seconds you set it's jumping “State” to happen every 70 tics. Every state has a set amount of time it runs for before moving onto the next state. With dehacked you can tell the thing what order to run it's states in, and for how long, and you can attach “Actions” to those states. Like firing a fireball or whatever.
You are limited in what you can do by Doom's available actions, the various flags for the things, and how you order the states, but if you're tricky you can accomplish more than you may think.

The info you need to specify for each state would be:
Sprite
Animation frame of that sprite
The next state this object goes to
Duration of this state in tics (35 per second)
Action this state will execute (fireball, chase, die, etc)
Additionally there are flags for objects that control things like collisions, whether the thing flies, some palette swapping, etc.

Only certain states can have actions, and once you've used those up that's it. You can't add more with vanilla DeHackEd. Also if you try to use an action state with no action it crashes in vanilla.

States can be changed when an event occurs on the object as well. For example, when a monster in doom is pained by chaingun fire, it enters it's “pain” state. Or if it dies it enters it's death state, which runs through it's death animation, each frame of that animation being a subsequent state itself.

Certain features are hardcoded to certain things. You can't make an imp drop health, for instance. But you could replace all the information of a former human with the information of an imp, and replace all the information of a clip (that the former human normally drops) with the information of a medkit. Then you have an imp that drops medkits. But you lose your former human. You could replace the original imp with the former humans info/logic, but it still wouldn't drop clips.

Speaking of pickups: Those things are hardcoded to give you an item based on the first 4 characters of their sprite name. So an object with the sprite “CLIPA” will give you a clip. And so will “CLIPB”, and “CLIPC” etc. So you could have some variety in your pickups visually if you want. The only thing you can change in regard to ammo pickups really is how much it gives you and what your total ammo capacity is. Same with health. I'm sure there are limitations on this, but I don't have much experience with it.

OKAY. Now that the overview is done and expectations are tempered… Onto the program we're using for editing a dehacked file (.deh): WhackEd.

Whacked is a windowed program, so you have windows for the various areas of control dehacked gives you.
Things - List of things, their IDs, attributes (height, speed, etc), starting states for their spawn/pain etc, flags (flying, collision etc).
States - Where you manage the ordering of states, choose the action for each state, sprites and so on.
Sounds - Lets you change some sound settings.
Weapons - Change the raise/lower/firing states of weapons, and what ammo they use.
Ammo - Where you choose the amount of ammo pickups give you and max possible ammo.
Strings - Level names, intermission texts, etc.
Cheats - Change cheat codes. Some ports don't like this, and some people don't either.
Misc - Max health, armor classes, other things.
Par Times - I have no idea.

OKAY. So that's the program. What do we make then… Something simple, but illustrative of the utility of DeHackEd…

Let's make former humans shoot plasma and when they die they explode… into mancubus fireballs maybe. This should illustrate strengths and weaknesses in dehacked.

First we're going to select our version of Doom, and our IWAD. Doom 1.9 (use this for doom 2 also), doom2.wad.

Next we check out the trooper using the filters in the state window. Here we hit our first limitation already. You can't use player projectiles for enemies. But, what we can do is change an enemy projectile to act the same as a player projectile. The Arachnotron's projectile is close enough that it won't fuck too much up. Go to the “States” window, filter for “trooper” (the former human), and find his firing “state”. The states are numbered, and his firing state is 185. Replace that states action with “BspiAttack” (baby spider attack).

At this point you already have a former human firing an arachnotron's plasma ball instead of bullets. But he'll still drop a clip which is a bit off.

So we'll filter for the Plasma Rifle (at the top of the states window), and take note of the sprite it uses. Remember that the first 4 characters in a sprite name determine what it does when you pick it up.

It's sprite “PLAS” frame 0. So we'll filter for “Ammo Clip” and change it's sprite to “PLAS” frame 0. Now they will drop Plasma Rifles when they die and fire arachnotron shots. The pickup ammo for the Plasma Rifle is twice that of the cell ammo, so obviously this is pretty unbalanced if the weakest enemy is dropping absurd amounts of plasma ammo. Let's try to balance this a little bit… Go to the weapons window and change the pickup amount to 2. Now cells will give you 2 ammo, and rifles will give you 4.

WIP.

tutorials/modding/dehacked.1726089792.txt.gz · Last modified: 2024/09/11 21:23 by A User Not Logged in