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.


tested in chocolate doom by creating a shortcut with a target field that looks like: “chocolate-doom.exe” -deh clovr.deh

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.

Alright. Now let's get complicated. We want him to explode when he dies and shoot mancubus fireballs at the same time. I'm not going to make any new sprites, so we'll swipe some exploding sprites from barrels. That would be BEXPC, BEXPD, and BEXPE. We'll head over to his entry in the “Things” section and remove his explode state since he's going to explode every time now, and his raise state since he'll no longer have a body.
We'll also need 4 actions for this, scream, fall, fatattack3, explode. In his typical death he already has scream and fall, so we need two actionable states. We'll swipe those from the “SS Nazi” chase states. No one will notice.
The states we're stealing are 734 and 735, but we can't just take them, we need to shift the SS Nazi's states around a little to free them up. Otherwise the SS will just explode when they chase you since they'll be sharing explosion states with the Former Humans.

So select state 733, after filtering for the SS Nazi, and change it's “Next state” to the first SS Nazi chase state (728). Then change it's sprite to the next walking sprite of the SS Nazi (SSVD) and the duration of states 732 and 733 to 6. It's a little hacky, but now when the SS nazi goes through it's chase cycle it'll at least cycle properly. Though the last two frames of animation will be chunkier in motion since they're not distributed across 4 states anymore, only 2. I hope that makes sense.
We're also going to change state 735's next state to 192. You can now find the stolen SS Nazis states in the filter under “Unused”.
It's often much easier to steal entire enemies and redistribute their states as you see fit. The SS Nazi is a go-to because it's only used in the secret maps, and rarely used in custom maps.

Now we redirect the Former Human (remember it's called “trooper” here) to use those stolen states. Set state 191's “next state” to 734, then refresh the list. You'll notice the new states show up under the original Former Human's states. So now it goes 191→734→735→192, even if they appear out of order. Finally we're going to change state 192's “Next state” to 0. We could just end it at 735, really, but if I were making this with bespoke sprites I'd want a little extra explosion puff on the end.

OKAY. So we're going to change the sprites for the states. 191 will be BEXPC, 734 will be BEXPD, and 735 will be BEXPE, and 192 will also be BEXPE.

OKAY OKAY. Now we change the actions. 734 gets “Explode”, and 735 gets “FatAttack3”. And change the durations to 5 to match the other death frames. You can change multiple states at once by shift+selecting them. You can only have one action per state, so if you want these actions to happen closer together you need to make the duration on one of them shorter. All you need now is to change the sprites for the arachnotron projectile, if you want them to match the players plasma rifle. Find it in the “Sprite” window, and replace the sprites and frames for each state. The in-air sprites start with PLSS, and the exploding ones start with PLSE. You should be able to do this yourself now.

OKAY OKAY OKAY. That's it! Now they fire plasma, drop plasma rifles, explode when they die (which tends to kill the other former humans around them), and fire off fireballs as they explode. LAST THING. Go to the “Trooper” (Former human) in the “Things” window and find the “Sounds” section therein. You'll see one that says “Death”. Change that to “82” - that's the sound for a barrel explosion.

That's really it now. If you want to see the .deh file I ended up with here you go:

Hope this helped.