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

P_NoiseAlert()

Recommended Posts

I'm poking around the Doom source code and I see the following:

// P_NoiseAlert
// If a monster yells at a player,
// it will alert other monsters to the player.
//
void
P_NoiseAlert
( mobj_t*	target,
  mobj_t*	emmiter )
[etc...]
And I was like "wait what? That doesn't happen." So I poke around a bit and I notice that the only place P_NoiseAlert is called is within P_FireWeapon, where both "target" and "emmiter" (sic) are set to the player firing a gun, as per normal.

So it seems clear that they intended to code in behavior where a monster's alert noise would basically act as a player gunshot noise and could cascade to wake up more monsters. That's the only reason for P_NoiseAlert to be able to have a separate "target" (presumably a player) and "emmiter" (presumably some other monster making its wake-up noise).

So I guess it's possible that Carmack simply forgot to call P_NoiseAlert() inside A_Look() (which I think is the function that makes a monster wake up), but that seems sloppy and not characteristic of him. It seems more likely that he implemented it, but then it turned out to suck because a monster waking up and alerting other monsters ended up recursively waking up every other monster in the level or something.

Has anyone ever tried "re"-implementing this feature to see what happens?

Share this post


Link to post

Neat find.

It probably was a deliberate omission and not just forgetfulness. It would most likely recursively wake many more monsters than intended even with the use of block sound flags on linedefs. Perhaps it would be a more viable feature if monster roars were absolutely blocked by any sound blocking lines, rather than two in succession as is the default behavior. That would allow the other monsters in the immediate area to get pissed off without suffering a recursive effect.

From a game design perspective, it wouldn't be terribly detrimental as the player is likely to start shooting anyway once a monster is alerted to his presence. And of course, monsters flagged to ambush would wait until the player comes into visible range regardless of this scrapped behavior being in or not.

Share this post


Link to post

I believe that this feature has been removed because of negative effect on game's perfomance (especially on big maps)

Share this post


Link to post

Cool hack.

cybermind said:

I believe that this feature has been removed because of negative effect on game's perfomance (especially on big maps)

I can buy that too. As soon as one monster sees you he wakes up all his buddies, which is probably bad for performance in 1993 on a 486. It might also be the case that it subverts the "sound cannot cross this line" flag.

Share this post


Link to post

It could have worked meaningfully if the monster only alerted monsters in its line of sight (360° around).

But I realize that sound propagation code works in a completely different way.

Share this post


Link to post

Nice find. Another possible explanation for removing it is, as usual, laziness. I can imagine they ran into scenarios where they wanted a monster to see you and come after you, but other monsters kept waking up, ruining the intended placement and grouping in corners. And maybe placing enough sound blocking lines everywhere or adding a "mute" flag was too much bother. Basically, Doom AI works best when it's hardcore dumb and this is a possible step towards smart retards thinking themselves into failure.

Share this post


Link to post

I noticed that a long time ago. It's clearly a left-over feature from development that represented a discarded idea, as you posit.

Share this post


Link to post

Yes, a very cool find! I am actually amazed at how 'clean' the Doom source really is. It is as if Carmack knew what he wanted the game to do, and then wrote the code. No huge chunks of commented-out code, none of this trial-and-error mess, just pretty straight forward stuff.

What does everyone else think about this? I know that I'd have to try everything 10 different ways until I was satisfied :)

Share this post


Link to post

Maybe the source got cleaned up during the development of the patches after the release and then before getting published.

During the actual development it was probably just a mess.

Share this post


Link to post

The source was actually cleaned up and refactored somewhat by Bernd Kremier (sp) prior to release. It actually caused some problems because some of the stuff he did broke demo compatibility. It also kind of sucks that we don't have the "real" source code for historical purposes.

As for commented-out code, there is some. I noticed some commented out stuff for some of the more hardcore math calculations, and there's stuff like the unfinished sliding door code.

Share this post


Link to post

Not to mention the complete removal of DoomEd sources because he couldn't get NeXT filenames to work properly.

f) DoomEd
The NeXTStep DoomEd sources in the dump were
garbled (filenames - prolly an issue of ISO9660
with or w/o extensions). Somehow Bear never got
around to send me a list of the correct filenames,
and I won't bother guessing without a NeXT box
at hand.

There is a plethora of useful editors
for DOOM. I suggest using DEU for X11.

Share this post


Link to post

Guess that guy got trusted with the source and thought he'd make it his bitch.

Share this post


Link to post
VGA said:

Guess that guy got trusted with the source and thought he'd make it his bitch.

Actually he was planning to write a book about it. Never happened, though.

Share this post


Link to post

P_NoiseAlert does very little by itself, actually. All it does is setting a global variable "soundtarget" (which is what is actually used as a target for angered monsters), and calls P_RecursiveSound, which does all the recursive sector-by-sector sound propagation.

I presume the only real reason for separating emitter and target, is that in Doom there are virtual sound emitter objects which are not thinkers or do not stick around long enough, so the source of a sound itself might not be targettable. An example of such sources are doors and crushers, and exploding barrels/rockets.

This would allow monsters to wake up on other events (e.g. the sound of a barrel or rocket explosion in a sector away from the player), and/or to target something arbitrary upon some sound-generating event like a platform being lowered, which could indicate an intrusion.

This could be used as a base for a scripting subsystem and setting up more complex behaviors in a map (for example, it would allow waking monsters up without firing, by setting up a new type of sector special, e.g. "PlatformRaiseWithAlertingNoise", which is probably what id had in mind at some point).

A more complex behavior would be the ability to set waypoint targets, e.g. an alert causing monsters to simply seek (without necessarily attacking) a noise source, causing them to muster at a specified point after an "alarm" had been set off.

Share this post


Link to post

Didn't Carmack give Killough and maybe some of the other Boom guys access to the original source for reference purposes?

Share this post


Link to post

I will admit, I've always wished monster noises would alert other monsters. It seems weird sometimes when a monster will open fire on me, and a monster next to him will just stand there if his back is turned until I open fire. I always figured the reason it wasn't done like that, though, was because it would set off unintended chain reactions of an entire level full of monsters being woken up at the same time. And then you'd have problems of the monsters all coming to look for the player, abandoning their posts and leaving rooms empty - making for a really intense first battle but then leaving the rest of the map barren lol.

Share this post


Link to post
Guest Unregistered account

Amazing find! This would probably work better if the monsters' alert sounds only reached a certain radius + only woke up monsters in their line of view.

But yeah, I am glad John removed it. Makes stealthily sneaking around monsters so much easier.


geekmarine said:

I will admit, I've always wished monster noises would alert other monsters. It seems weird sometimes when a monster will open fire on me, and a monster next to him will just stand there if his back is turned until I open fire.


Actually, that would probably work pretty well, if the "sound radius" (there's probably a technical term but I've never delved within the code of Doom) was super-small, so the gunshot could only alert monsters almost right next to them. Maybe?

Share this post


Link to post
Jonathan said:

Didn't Carmack give Killough and maybe some of the other Boom guys access to the original source for reference purposes?

I have heard about that rumor before. Does this mean that Boom has been derived from a different version of the source code than all the other early ports?

Share this post


Link to post

Indeed http://www.doomworld.com/10years/ports/ports01_2.php

As mentioned earlier, changes made to DOOM in both the original Linux porting process as well as during Bernd Kreimeier's editing had left a number of problems in the source, especially for demo and map compatibility. Although it was unknown to the community for several years, it was later revealed that John Carmack gave the BOOM team limited, temporary access to the original DOS DOOM source, in part to help remedy these problems. So BOOM is actually a hybrid between DosDOOM v0.2 and the original MS-DOS DOOM source.

Share this post


Link to post

Quake does something similar. When a monster sees another monster getting angry at a player, it will get angry too.

But this system replaces alerting by noise instead of complementing it.

Share this post


Link to post
Linguica said:

BTW if anybody wants to ask who my source was for that information, it was Lee Killough. Unfortunately I believe the document where he revealed this information was his infamous whyiquitdoom.txt, which he later took down and regularly requests to be taken down from the Internet if it is re-uploaded.

Share this post


Link to post

LOL, I just Googled 'lee killough "why i quit doom"' and the only thing on Google about it is an IRC log where I say I still have that file. Sorry past me, I didn't hold on to it I guess!

Share this post


Link to post

Yeah, that's where I remember it from. I can't remember family birthdays, but I can remember the contents of ragequit screeds I read fifteen years ago. Thanks brain!

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
×