Make an enemy react to seeing another enemy attacked?
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Make an enemy react to seeing another enemy attacked?
I think that this is probably way more complicated than Doom's AI can cope with and therefore it probably can't be done but I'll ask anyway...
Is there a way to make a deaf enemy react to seeing another enemy get attacked via its decorate (ie map and scripting independent)?
We've all seen the situation:- You peer round a corner and can just see the edge of an enemy. You shoot him and he goes down. Then you walk around the corner fully and find that one or more of the enemy's friends were also there. They "saw" their friend gunned down in cold blood but did not react and even seem surprised that you are there at all.
In my own mods, I occasionally set up pairs of enemies. eg, in the base section of my Burghead mod, there were guards in alcoves at either side of a corridor facing each other. Each one was given a special that set the other in the pair on a short patrol path out of their alcove and into the corridor. Thus, killing one made the other step forward and see the player.
What I would like to do is to set up a generic monster replacer (ie one that is not tied to specific maps or scripts) that would mean any monster seeing a monster die (or even in their pain state?) would be sent to their see state and start wandering towards the player.
Any thoughts on how such a thing might be achieved or is it just too difficult?
Is there a way to make a deaf enemy react to seeing another enemy get attacked via its decorate (ie map and scripting independent)?
We've all seen the situation:- You peer round a corner and can just see the edge of an enemy. You shoot him and he goes down. Then you walk around the corner fully and find that one or more of the enemy's friends were also there. They "saw" their friend gunned down in cold blood but did not react and even seem surprised that you are there at all.
In my own mods, I occasionally set up pairs of enemies. eg, in the base section of my Burghead mod, there were guards in alcoves at either side of a corridor facing each other. Each one was given a special that set the other in the pair on a short patrol path out of their alcove and into the corridor. Thus, killing one made the other step forward and see the player.
What I would like to do is to set up a generic monster replacer (ie one that is not tied to specific maps or scripts) that would mean any monster seeing a monster die (or even in their pain state?) would be sent to their see state and start wandering towards the player.
Any thoughts on how such a thing might be achieved or is it just too difficult?
Re: Make an enemy react to seeing another enemy attacked?
The only thing I can think of along these lines is putting A_AlertMonsters in pain and death states. That might not be what you have in mind, though.
- Sergeant_Mark_IV
- Posts: 812
- Joined: Wed Feb 02, 2011 12:44 pm
- Location: United Communist Nazi Republic Dictactorship of Banana Land (Brazil)
Re: Make an enemy react to seeing another enemy attacked?
A_AlertMonsters can't alert deaf enemies as far I know.
The only thing I can think about it, is causing the attacked monster to cause a radius damage with the desired area, and minor damage, and make this damage type only damage the monster that is intended to go help his friend, and give him a maximum pain chance for that damage type. So, when he takes this minor damage, he will wake up and go attack the player.
EDIT: But maybe this can cause them to infight. I don't know.
EDIT2: Make the monster spawn a dummy actor to cause the area damage, instead having to cause the damage himself. This will prevent monster infight.
The only thing I can think about it, is causing the attacked monster to cause a radius damage with the desired area, and minor damage, and make this damage type only damage the monster that is intended to go help his friend, and give him a maximum pain chance for that damage type. So, when he takes this minor damage, he will wake up and go attack the player.
EDIT: But maybe this can cause them to infight. I don't know.
EDIT2: Make the monster spawn a dummy actor to cause the area damage, instead having to cause the damage himself. This will prevent monster infight.
Re: Make an enemy react to seeing another enemy attacked?
That might work but I reckon it would mean that when you were fighting hordes of monsters, every now and again one would just fall over without being hit due to all his buddies around him throwing out damage. Also, monsters will tend to have lower hitpoints every now and again when you encounter them.
I guess it would also need a custom pain state too to prevent constant yells of pain.
I guess it would also need a custom pain state too to prevent constant yells of pain.
Re: Make an enemy react to seeing another enemy attacked?
"Deaf" is a bit of a misnomer. They do react to sound in that when they hear a sound, they get a full 360-degree sight range (for the purposes of activating), but don't activate. It's more like they hear it, but choose not to act, which might still fit here. Those who know this tidbit of information refer to the flag as ambush.Sergeant_Mark_IV wrote:A_AlertMonsters can't alert deaf enemies as far I know.

Re: Make an enemy react to seeing another enemy attacked?
You know, that might work - or at least go some way towards what I want. Ideally, I'd want the enemies to start wandering towards the player when their buddy dies but becoming alert and ready to deal with the player might work.
Mind you, in most cases, I suspect that's what they are doing anyway - having already been alerted by the player's weapon fire.
Mind you, in most cases, I suspect that's what they are doing anyway - having already been alerted by the player's weapon fire.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Make an enemy react to seeing another enemy attacked?
The amazing DavidPH recently submitted a patch for A_AlertMonsters to have a limited radius.
Keep in mind that this isn't limited to DooM. Morrowind characters too are completely oblivious (*snerk*) to someone you kill from out of sight.
Keep in mind that this isn't limited to DooM. Morrowind characters too are completely oblivious (*snerk*) to someone you kill from out of sight.

Re: Make an enemy react to seeing another enemy attacked?
The limited range thing would be nice. That way it would be easy to set a reasonable distance for enemies to react to a "seen" death. I guess that what I would really need is another extension to A_AlertMonsters that meant "Alert Monsters as if they have seen the player/target". That plus a limited range would be perfect. I wonder if such a thing would even be possible?
Re: Make an enemy react to seeing another enemy attacked?
"Alert and clear AMBUSH tags"?Enjay wrote:I wonder if such a thing would even be possible?
- DonaldDuck
- Posts: 69
- Joined: Sat Jun 11, 2011 6:57 am
Re: Make an enemy react to seeing another enemy attacked?
I'm not sure if i understand, but why dont you try something like this, e.g.:
(I'm sorry, I can't test, I'm on my iPhone)
(I'm sorry, I can't test, I'm on my iPhone)
Code: Select all
actor ZombiemanTwo : Zombieman replaces Zombieman
{
states
{
Spawn:
POSS A 0 A_JumpIfInventory("AlertX",1,"See")
POSS A 5 A_Look
POSS B 0 A_JumpIfInventory("AlertX",1,"See")
POSS B 5 A_Look
loop
Death:
POSS H 5
POSS I 5 A_Scream
POSS I 0 A_GiveInventory("AlertX",1)
POSS J 5 A_NoBlocking
POSS K 5
POSS L -1
stop
}
}
actor AlertX : Inventory
{
Inventory.Amount 1
Inventory.Maxamount 1
}
Re: Make an enemy react to seeing another enemy attacked?
That wouldn't work because the dying actor would need to be able to give the AlertX actor to any enemies that saw it die/within a certain distance of it and there isn't a way of doing that (that I know of). I think all your code does is have the dying actor give itself an AlertX as it dies.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Make an enemy react to seeing another enemy attacked?
Also, jumping to See does nothing useful without a valid Target. (What you get is the dreaded "undefined behavior".)
- Squishybrick
- Posts: 190
- Joined: Sat Jan 22, 2011 7:11 pm
Re: Make an enemy react to seeing another enemy attacked?
What I did to fix that problem of yours was make every linedef in the entire map soundproof, and make non-soundproof bubbles wherever there are monsters, so that you can use the alert thing in the monster's pain state and he'll only alert monsters within that bubble of non-soundproof sectors...
Kinda makes me think of "There I Fixed It", but doom-style.. XD
But hey, it worked for my needs, so I thought I'd tell ya.
Kinda makes me think of "There I Fixed It", but doom-style.. XD
But hey, it worked for my needs, so I thought I'd tell ya.
Last edited by Squishybrick on Mon Jul 04, 2011 6:08 pm, edited 1 time in total.
Re: Make an enemy react to seeing another enemy attacked?
That would work for a specific map but I was rather hoping for a map independent solution.
- Squishybrick
- Posts: 190
- Joined: Sat Jan 22, 2011 7:11 pm
Re: Make an enemy react to seeing another enemy attacked?
Okay, then make "Sound projectiles" that shoot out from every direction of the monster whenever it hits it's painstate that forces a special silent pain state in other monsters that wakes them up, like this..
You can add more angled shots for a finer spray of sound, and with this you can customise a sound projectile for each monster, making one scream "louder" than others..
Not to mention with the bouncy flag, they'll be able to bounce off walls n' such, to even further accurately emulate sound waves..
Does that solve your problem?
Heck, you could even go all-out and cut out the pain sound from the monster, and stick it ON the projectile, so it literally sounded like you could hear the sound travelling past you and filling the room, which would then allow you to more-accurately dictate the range of the sound by how long it lasted and how loud it was.
Code: Select all
Sound
{
Damage 0
Speed 30
+FORCEPAIN
+INVISIBLE
+THATFLAGTHATMAKESITBOUNCEOFFSTUFF
DamageType Sound
States
Spawn:
PROJ A 20 <-- ("Range" of sound dictated here)
Goto Death
Death:
PROJ A 0
stop
}
OtherMonster
{
States
pain:
MONS C 4 A_Pain
MONS C 0 A_CustomMissile ("Sound", 20, 0, 0, 2, 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 45, 2, 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 90, 2 , 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 125, 2, 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 170, 2, 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 225, 2, 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 270, 2, 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 315, 2, 0)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 0, 2, 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 45, 2, 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 90, 2 , 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 125, 2, 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 170, 2, 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 225, 2, 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 270, 2, 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 315, 2, 30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 0, 2, -30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 45, 2, -30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 90, 2 , -30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 125, 2, -30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 170, 2, -30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 225, 2, -30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 270, 2, -30)
MONS C 0 A_CustomMissile ("Sound", 20, 0, 315, 2, -30)
[Rinse and repeat till you have a fine sphere of projectiles]
pain.sound:
MONS A 1
Goto See
}
Not to mention with the bouncy flag, they'll be able to bounce off walls n' such, to even further accurately emulate sound waves..
Does that solve your problem?
Heck, you could even go all-out and cut out the pain sound from the monster, and stick it ON the projectile, so it literally sounded like you could hear the sound travelling past you and filling the room, which would then allow you to more-accurately dictate the range of the sound by how long it lasted and how loud it was.