Has anyone made a mod where enemies take cover?

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
el armadillo2
Posts: 148
Joined: Fri Nov 11, 2016 9:45 am

Has anyone made a mod where enemies take cover?

Post by el armadillo2 »

Not sure if this is possible, but i'm curious if anyone has attenpted this.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Caligari87 »

Hideous Destructor does, in a fashion. Monsters will sometimes try to move toward your flanks, or will retreat when they are hurt or need to reload, for example. Someone else posted an AI experiment a while ago with a shotgunner that could run out of shells, and wouldn't reload until he'd safely broken line-of-sight with the player. It's certainly possible, with clever scripting.

8-)
User avatar
Rachael
Posts: 13558
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Rachael »

Caligari87 wrote: Someone else posted an AI experiment a while ago with a shotgunner that could run out of shells, and wouldn't reload until he'd safely broken line-of-sight with the player. It's certainly possible, with clever scripting.
I believe that's what Kinsie did in JPF.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Matt »

Caligari87 wrote:Hideous Destructor does, in a fashion. Monsters will sometimes try to move toward your flanks, or will retreat when they are hurt or need to reload, for example. Someone else posted an AI experiment a while ago with a shotgunner that could run out of shells, and wouldn't reload until he'd safely broken line-of-sight with the player. It's certainly possible, with clever scripting.

8-)
To clarify, HD monsters don't look for cover, they just move randomly to try to get out of your line of fire.

The reloading-only-out-of-sight thing can be done relatively easily, but I see too many maps where at least one of the following apply:
1. the shotgunner is in a spot where it can't do anything to break LOS (pillar, cage, big open arena, etc.)
2. there's at least one other monster that can shoot at the player and create a distraction, during which the shotgunner's time is better spent reloading so it can eventually return the favour when that monster eventually has to reload (or die and wait for the healer imp)

Was it you or Josh who had that thing where the monster will check line of fire/sight with its target at 8 points around it, then move towards one where there is no line?
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Caligari87 »

The initial implementation was mine, where enemies would simply path toward the last point the player was seen instead of the player's current pos (and clear their target if they're out of LoS too long). Josh then expanded on it to create a "searching" system where the initial node spawns several more for the monster to try and investigate in sequence. That's in UaS currently.

Alternatively maybe you're referring to my AI proposal to have monsters set goals for cover or other goals by shooting traces or spawning "imaginary" wandering copies of themselves. I never put down any code for that.

8-)
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Matt »

Caligari87 wrote:Alternatively maybe you're referring to my AI proposal to have monsters set goals for cover or other goals by shooting traces or spawning "imaginary" wandering copies of themselves. I never put down any code for that.

8-)
That was it. Not ruling out the possibility of stealing that idea in the unforeseen future!
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Tormentor667 »

Blade of Agony
User avatar
Kinsie
Posts: 7399
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Kinsie »

Rachael wrote:
Caligari87 wrote: Someone else posted an AI experiment a while ago with a shotgunner that could run out of shells, and wouldn't reload until he'd safely broken line-of-sight with the player. It's certainly possible, with clever scripting.
I believe that's what Kinsie did in JPF.
Effectively! Basically, Shotgun Guys spawn with a "magazine" variable initialized to a random number between 0 and, say, 8, that goes down every time they shoot. If they try to shoot with their magazine at 0, they make a comical "CLICK" sound, freak out, turn on the FRIGHTENED flag, and enter a new state where they don't attack and are constantly checking that they're out of the LOS of any players. Once they're out of sight, they start very loudly reloading, resetting their magazine variable, and returning to normal behavior.

There are probably cleaner/better ways to implement it, code-wise, as it still uses a lot of DECORATE-style logic, but it's pretty readable and works fine in-game, which are the two most important things.
Tormentor667 wrote:Blade of Agony
I feel like this thread is more for discussing how mods have implemented such functionality, rather than just hurling out a name and running.
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by Tormentor667 »

Kinsie wrote:I feel like this thread is more for discussing how mods have implemented such functionality, rather than just hurling out a name and running.
Well, I thought it was exactly that :)
el armadillo2
Posts: 148
Joined: Fri Nov 11, 2016 9:45 am

Re: Has anyone made a mod where enemies take cover?

Post by el armadillo2 »

Tormentor667 wrote:
Kinsie wrote:I feel like this thread is more for discussing how mods have implemented such functionality, rather than just hurling out a name and running.
Well, I thought it was exactly that :)
Both.
User avatar
AFADoomer
Posts: 1324
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: Has anyone made a mod where enemies take cover?

Post by AFADoomer »

In Blade of Agony the standard Nazi-type actors have rudimentary handling for something like this...

They don't really intelligently take cover, they just dodge left or right. The dodging is initiated during the See state when certain conditions are met (a timer countdown between dodges, an optional cap on the total number of dodges allowed, and a random number check). When the conditions are met, an internal function checks to see which side (the actor's left or right) has a farther valid movement distance available, then the actor changes to a state that looks like they are rolling sideways and moves in that direction. They're also invulnerable during the "roll" sequence, so that they actually can get away from you (plus then we don't have to make rolling death sprites...).

A second feature that I recently implemented (it's not in the Chapter 2 release version) is that enemies will actively run away from thrown grenades. Every 10-15 ticks (it's randomized so they don't all check at once), the actor checks to see if it's in range of any grenade actors (for performance reasons, the base grenade actor that is inherited from by every grenade in game is set up with a specific STATNUM). If so, the actor turns frightened and increases its move speed by 1-2 (and the custom chase function makes them run away without firing if they're running from a grenade). Once the grenade explodes, the actor's behavior returns to normal.

You can see all of the code for this here. There's a lot of other code there, too, though (stealth/visibility handling, medic corpse finding and healing, goal seeking, etc.). *I* think the code is relatively logical, but I wrote most of it, so... Feel free to ask if you have questions.
Post Reply

Return to “General”