Sunday, August 2, 2009

Some guidelines on ObHack hacking

Since there is some interest in ObHack still, even though I've stopped work on it myself, I'll give people some guidelines for modifying ObHack.

ObHack is a C++ frontend; all the C++ code does is display the GUI and physically write the wad file. The lion's share of ObHack code is written in a language popular with game designers called LUA, a straightforward language that is a lot cleaner and maintainable than C.

The only time the C++ code needs to be modified is if one wishes to change the options seen in the GUI, or one wishes to change the version number of ObHack reported in the wad files created.

For people who aren't comfortable with C++, no big deal. Just change the LUA scripts (indeed, my earliest releases of ObHack were Oblige with just the scripts modified).

What ObHack does is first plan the level to be built. ObHack decides how many "quests" are there; a quest is going down a path until you're in a room with a small podium and a goody on the podium like a key, weapon, or power-up (a quest can also end with a switch that opens a door or to the exit that takes us to the next level). ObHack decides how many key quests to make, how many and what type of weapon and power-up quests there are, whether a given quest is secret, etc. ObHack also decides how long a quest should be at this point (how long the path we go down until we find the desired item is), and where the player starts on the map.

Once ObHack decides the quests to make, ObHack then sets up a square grid and decides how the squares are connected to each other, whether a given square is indoor or outdoors, etc. (Quests are marked with the type of scenery a place has, whether it's indoors or outdoors and what the floor, walls, etc. look like) Should ObHack not be able to make an exit quest or a key quest for a given locked door, ObHack will try again; if we can't make the quest as long as we wanted, ObHack will make the quest shorter, etc. ObHack also decides the average elevation of a given square at this point.

Each one of these squares is the size of a "room". ObHack also, at this point, decides to have "scenic" squares which you can not enter (nor can monsters enter) but add some scenery (this is why you see things like cages without monsters in them; that's a cage put in a scenic square).

Once the arrangement of rooms is done, ObHack then uses builder.lua to build the map. It is at this point that ObHack places ammo, health, armor (that isn't a goody at the end of a quest), and monsters. In addition, ObHack adds stairs, platforms, and scenery to levels (prefabs like the fountain, the pillars, and what not). Should ObHack not be able to place a stair in a level, ObHack will try redrawing the level again (starting from scratch with the planner) until ObHack has a level it is satisfied with.

Once that is done, ObHack converts the level in to a Doom wad, writes the wad, and the C++ code uses glbsp to make the wad have a node tree and be playable in Doom/Heretic.

So, for people who want to further develop ObHack, this should give people a starting point. LUA is really easy to program; don't let the C++ code scare you. The LUA code is a little messy at times, and, to be honest, I don't have time to really help people understand the code.

If anyone wants to continue working on ObHack and maintain the code, let me know. It's a lot of work, but you will have the satisfaction of having a Doom random map generator you have complete control over.