Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
MajorRawne

Monster HP

Recommended Posts

Hi all, I've been battling through Resurgence for a /Newstuff review and have noticed something odd about the monsters.

The megawad is extremely tough so I'm using savestates, which I wouldn't normally do, so I have tended to fight the same enemies over and over. I've noticed that if an Imp takes two shotgun blasts to kill - even with a direct hit - if I then get killed, reload the saved state and fight the same Imp again, it still needs two shotgun hits to kill. It doesn't matter whether I hit it dead on or just wing the bastard. If the next Imp only took one hit the first time around, it always dies in one hit in subsequent encounters, even if I only clip it.

Is there some kind of randomised or fixed element to the health of each monster when a map is loaded? I have tested this numerous times with other Imps in other maps from the same megawad and always get the same results.

Share this post


Link to post

I do know that Doom's Psuedo Random Number Generator is determined by player inputs, so as to allow demos to always have the same outcome by only recording/playing back what the player does.

Share this post


Link to post

Depends on the port you're using I guess. Maybe in some ABCDoom the power of your next shot is predetermined.

Share this post


Link to post

Doom randomness seems not to be in real time, so, yes, when you load a game, the random numbers will apparently be the same. For example, if you save at MAP30 level start, Icon of Sin will spawn the same monsters every time you load it.

Share this post


Link to post
Darch said:

For example, if you save at MAP30 level start, Icon of Sin will spawn the same monsters every time you load it.

That's right, I've experienced it while trying to beat Epic 2. I kept dying and reloading the game during the IOS fight, and the IOS kept generating monsters always in the same order - and quite a few of them were pain elementals. -_-

Share this post


Link to post

If you want to change the RNG outcome each time you load, try doing something different -shooting at something else, using weapons that "consume" a lot of RNG values -the SSG consumes at least 200 each time you shoot it- or simply moving in a different direction and causing different monsters to attack you in different order is enough.

If as soon as you load a saved game you do the exact same things you did after you saved, then of course you will see the same "monster HP" and behavior again and again. After all, that's how demo recording works. Because, what is a demo, if not a savegame loaded at the very start of a level, with a specific starting RNG, and a canned set of (player) actions? Same player actions -> same game actions. That's how it works in Doom.

Share this post


Link to post
Maes said:

Same player actions -> same game actions. That's how it works in Doom.

That's how we did map30 co-op tyson with xepop :-)

Share this post


Link to post

Aren't there generally enough calls to P_Random going on in the background (other monsters moving around, etc) that it would be pretty difficult to get the same damage values after reloading a save? Unless you really are firing on the same tic each time.

Share this post


Link to post
Linguica said:

Aren't there generally enough calls to P_Random going on in the background (other monsters moving around, etc) that it would be pretty difficult to get the same damage values after reloading a save? Unless you really are firing on the same tic each time.



Depends on the engine you use. If it still only has the simple vanilla RNG, yes, but if you use something that separates RNGs and does a bad job seeding them it'll be dead easy to get the exact same outcome each time.

Share this post


Link to post

I've also found it works on the player too. For example, on Resurgence map 20, I saved not knowing a hell knight fireball was inches away from the back of my head. every time it connects is does exactly the same damage; the same occurs when I was fist-fighting a baron. Every single time he got a hit in, it took me to 15% health, with no variations. It seems that each actual hit has a predetermined damage value. Even if the attack misses, the next attack of that type which hits, does that damage.

This isn't RNG, this is kismet!

Share this post


Link to post

Noticed something similar very recently:

Every time I start Memento Mori map21 pistol start the shotgunner on the left shoots first and if he doesn't miss or I don't take cover I ALWAYS take 9% damage (unless I move right in front of his face when it's always 33% damage). This changes if I start shooting with the pistol before picking up the shotgun and there's more stuff possible to predict here with 100% accuracy depending on player actions. To what extent exactly is the Doom's pseudoRNG predictable?!

This was with GLBoom-plus -complevel 2 but works the same in original EXE. Also, works exactly this way only on skill 4, when I tried other skills I immediately got different values (I didn't bother checking predictability with them, though.)

Share this post


Link to post

One can easily observe Vanilla Doom's RNG at the start of any map where bad guys are immediately alerted.

Plutonia's first map and TNT map31 are two fine test cases; if the player never moves (thus the exact same calls to P_RANDOM are made each time) the chaingunner and shotgun guy's respectively, will always behave identically.

Share this post


Link to post

I wonder why this is such a surprise: this is what holds Doom demos together and allows them to run exactly the same* on different machines, and even across different source ports, as long as they replicate the RNG (and other stuff) faithfully.

* OK, there are some very rare, extremely technical exceptions.

Share this post


Link to post
Maes said:

I wonder why this is such a surprise: this is what holds Doom demos together and allows them to run exactly the same* on different machines, and even across different source ports, as long as they replicate the RNG (and other stuff) faithfully.

It relies on the fact that Doom's RNG apparently always starts on the same value. That's not such a matter of course when a person thinks about it. A rational implementation would perhaps save the last random value from previous game and continue from there. This saved value could affect demo recording and playback as well, so that it would still run exactly the same on different machines and ports. But no, Doom maps play always the same each time you try it with the same input even in singleplayer, when no demo is being recorded or played.

Share this post


Link to post

It could randomize the seed and save the value in the demo, right?

Share this post


Link to post
scifista42 said:

But no, Doom maps play always the same each time you try it with the same input even in singleplayer, when no demo is being recorded or played.


The RNG is "reset" each time a new game is started or the player idclevs to a map (more technically, the index to the 256 "random" value table is set to zero).

There are only two exceptions to that: when playing several maps in a row, the RNG is not reset between maps. This also holds for multi-map demos. Of course, then the outcome of ALL maps depends on the "history" of the previous maps, so RNG behavior must be spot-on accurate.

Also, the RNG's table index IS among the information that is saved and restored even in vanilla savegames, so if you save in a bad spot... ;-)

Share this post


Link to post
Maes said:

Also, the RNG's table index IS among the information that is saved and restored even in vanilla savegames, so if you save in a bad spot... ;-)

Vanilla saves exact RNG index, but doesn't save targets of the monsters. Understandable from a coder's standpoint (too much work, too much data to be saved), yet interesting. :P

Share this post


Link to post
scifista42 said:

Vanilla saves exact RNG index, but doesn't save targets of the monsters. Understandable from a coder's standpoint (too much work, too much data to be saved), yet interesting. :P


It is possible to at least partially reconstruct the targets with some load-time reasoning, though, since the actual pointers are saved to disk, and because the thinkers are in a doubly-linked list and each saved thinker is referenced at least once (most of them by at least two others).

It's not even computationally difficult or sophisticated to do, but if Doom's coders were too lazy to implement a hashtable for lump name searching, they were probably too lazy to implement one for the reconstruction mechanism, too ;-)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×