Make an enemy react to seeing another enemy attacked?

Archive of the old editing forum
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.
User avatar
Enjay
 
 
Posts: 27140
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Make an enemy react to seeing another enemy attacked?

Post by Enjay »

With a bit of tweaking it might. An enemy that gets killed quickly (eg Zombieman) may die in a single shot and never go into its pain state. So it would need to throw the sound projectiles around in its death state too. Also, I think the enemy would need to spawn another actor to shoot out the "sound" projectiles to prevent the enemies targeting the pained enemy as Sergeant_Mark_IV mentioned. It might make sense to use a ripping projectile too.

It's still not as neat as something like this though:

Code: Select all

MONS C 0 A_AlertMonsters (256, AlertDeaf)
But unless that gets added, I guess the sound projectile option is the best suggestion so far. Thanks.
User avatar
Squishybrick
Posts: 190
Joined: Sat Jan 22, 2011 7:11 pm

Re: Make an enemy react to seeing another enemy attacked?

Post by Squishybrick »

Details details, but I deal with common problems like this all the time and I seem to be good at facing them with insanely imaginative ways of dealing with them..

Your welcome.. ..

.. ... Wait... I helped someone?... *jaw drops*

Somebody check the temperature in the underworld please...
User avatar
Blox
Posts: 3728
Joined: Wed Sep 22, 2010 9:35 am
Location: Apathetic Limbo

Re: Make an enemy react to seeing another enemy attacked?

Post by Blox »

Enjay wrote: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.
You would indeed need a custom Painstate, as for the problem with monsters taking damage ..
HealThing(1) is the solution, if the monster always entered the special Painstate when being hit.

Because it doesn't matter whenever it's hit once, or ten times in the same tic. It'll still heal the amount of times it gets hit.

Hm, as for canceling damage after the monster is activated (Even temporarily).. You could give them a PowerProtection item with the special Damagetype set to 0, though I doubt it would work.

Though I guess this is a pretty hacky way to do it. :P
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Make an enemy react to seeing another enemy attacked?

Post by Ghastly »

Blox wrote:HealThing(1) is the solution, if the monster always entered the special Painstate when being hit.

Because it doesn't matter whenever it's hit once, or ten times in the same tic. It'll still heal the amount of times it gets hit.
What if it has one health left?

Alternatively, +ForcePain.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Make an enemy react to seeing another enemy attacked?

Post by FDARI »

I think FORCEPAIN flag and 0 damage should work, as long as the actor doesn't have some feature that causes processing to end before forcepain is checked (damangefactors among other things, might have such an effect; http://forum.zdoom.org/viewtopic.php?f=2&t=28962).

The only remaining problem is that whatever the actor was previously doing, it will now be in its painstate. You can interrupt attacks that way, and when a horde of enemies is aware of you, and you gun down just one of them, that might be an undesirable bonus.
User avatar
Enjay
 
 
Posts: 27140
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Make an enemy react to seeing another enemy attacked?

Post by Enjay »

FDARI wrote:The only remaining problem is that whatever the actor was previously doing, it will now be in its painstate. You can interrupt attacks that way, and when a horde of enemies is aware of you, and you gun down just one of them, that might be an undesirable bonus.
Hmmm, yes, that is an important drawback. Even with a very short custom pain state specific to the damage type, the monster will get interrupted. This is irrelevant in the situation that this is designed to cope with (a not yet awake enemy waking due to seeing his buddy die) but it would potentially be a problem when fighting a horde. Every time one of the horde died, they would send out a bunch of sound projectiles and interrupt any other monster in range of the projectiles. This could be a considerable drawback in some games because it could well alter the difficulty of such fights significantly. Indeed, the "sonic grenade" in my Burghead mod uses a very similar system to "stun" enemies with the express purpose of making a fight easier. :?
User avatar
Squishybrick
Posts: 190
Joined: Sat Jan 22, 2011 7:11 pm

Re: Make an enemy react to seeing another enemy attacked?

Post by Squishybrick »

I'm suffering from the same problem with my stealth dampener and the ninjas, it auto-activates thier special painstates making them visible, but it has to hurt them for 1
HP.. But I didn't know about healthing, that solves MY problem..
EDIT: Wait, there is no healthing.. ... Hmmm... Well I'd rather not use the forcepain technique for this specific problem, so I'll just have to let this slide and hope
nobody abuses it in my mod.

What I did to counter that problem was make this monster's custom painstate act like a chunk of his see state, so even if he was being bombarded with it, he would
still act like he was attacking you, but to discourage the player from trying to "Stun" the ninja with the dampener, it makes the ninja's skip a frame or 2, making them
sort've half-teleport towards you, and since they're fast melee-ers, it makes for an effective deterrent. You could use a slightly different method, but I agree this is
a sticky predicament..

You guys look like your getting your hands dirty so I'll leave you
to investigate on your own.. I'm definetly interested in this thread because the solution may help me out as well..
User avatar
Blox
Posts: 3728
Joined: Wed Sep 22, 2010 9:35 am
Location: Apathetic Limbo

Re: Make an enemy react to seeing another enemy attacked?

Post by Blox »

The solution to the +FORCEPAIN problem, namely the constant interruptions, would be to use A_ChangeFlag("FORCEPAIN",0) in the See state.
Then, when it falls back to the "Spawn" state, reverse it. (A_ChangeFlag("FORCEPAIN",1) asdffff

And if healing fails, try DamageThing(-1), though that probably wouldn't work well either. Experiment!

Hackity hack hack!

Edit: Well, it's been a while. It'd be possible to use single-damage projectiles if PowerUps worked for monsters.
Last edited by Blox on Wed Jul 06, 2011 4:00 am, edited 1 time in total.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Make an enemy react to seeing another enemy attacked?

Post by FDARI »

FORCEPAIN is not set on the victim, but on the puff or projectile (the damage source). Somebody once suggested something like A_GiveRadius to give an item (custom inventory) to all actors in a radius, that could execute some code. That would not be particularly good for state-jumps, but still it opens some new avenues. The suggesting entity did not desire an ACS-variant with way more flexibility, which is what I'd prefer. I think ACS with that kind of extension could help you. I also have a feeling that even functional code might get WFDS'ed. I'd just do my best and see what the devs think. If I can do it at all.

There is no good and tidy way of informing the environment of what is going on.
Spoiler: Essentially a feature suggestion
Locked

Return to “Editing (Archive)”