CL9 randomizer mechanisms

There are many ways to add randomized elements to a DooM map, such that monster/item placement, teleport destinations, or even the geometry itself is different each time the map is played. If you're targeting cl11 or cl21, the RandomJump, LineEffect and Spawn codepointers basically have all your bases covered. In contrast, if you're targeting cl2, your only option is monster behaviors. That is, mechanisms based around monster pathing or damage rolls. For the Boom-heads out there there's another viable source of randomness in the idle frame offsets that are applied to every map object the first time the map is loaded.

In order to prevent dormant enemies from idling in lockstep with each other, the game applies a random offset to the first state of each object. For example, consider a zombieman, with its 2 idle states each of which are 6 frames. Upon starting the map, the duration of the first state for each zombieman is reduced by random amount between 0-5 (the first state can never be skipped entirely). This applies to all objects, enemies, powerups, decorations, it's all the same under the hood.

So how to use this? One simple idea is to create a decoration object that exists as solid and blocking for a randomly-determined amount of time before poofing out of existence. So if you have, say, 4 voodoos scrolling down a closet, each blocked by one of these objects, they're 'competing' for who's blocker will randomly expire first, and thus which actions get triggered first. This can easily be adapted to shuffle items to random locations:

A more complicated implementation I came up with is to have these 4 voodoos, and then add a mechanic such that if they don't get unblocked by a certain fixed amount of time, then they stay permanently blocked. The result can be interpreted as a 4-bit binary digit, where a "0" is a voodoo that never got unblocked, and a "1" is a voodoo that got unblocked and was able to trigger its actions. I made a secondary mechanism to "interpret" the result, such that for each possibility 1 specific voodoo doll (out of the 16 total) would advance forward and the rest would not move. Here are some demo wads: rng_tests.zip

rng_test_1.wad - a simple item shuffler.

rng_test_2b.wad - a "1 out of 6" random chooser. uses the more complicated mechanism.

Note: these only work in cl9 and above, as cl2 rng is seeded and will give the same result every time.

GrainOfSalt and I used these mechanisms in our halloween maps this year in order to randomize weapon and key placements, but if you're reading this then you probably know that already: wormwood5.zip

0 comments:

Post a Comment

Post a Comment