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

Slightly smarter AI w/ barrels

Recommended Posts

I guess this goes in source ports, because it would require engine code changes I believe.

My idea is to have a distance & target priority select for monsters when the player is near a barrel. If you're near a barrel, the monster should target that instead of you. I guess it could factor in sector size, barrel distance and nearby monsters, so that a monster will shoot you (instead of the barrel) if his fellow monsters are close to the barrel as well.

The logic would have to do a few checks and do some sort of prioritization.

-If sector size is less than xx = yes (so that monsters won't target the barrel in a large room so you have space to escape)
-If my demon homies are near the barrel AND the player = no
-If barrel distance >=64(e.g) = yes

*edit/addition* OR another idea, is to flag the barrel as "explosive" if the player is near within a certain distance, and the monster would prioritize that. Another way to code it possibly...

I'm not a programmer but I can't imagine this is too hard to code, one thing that might stand out is having the selective timer run only on nearby enemies, so that a map full of 200 monsters aren't all calculating the routine at the same time.

Good idea with lots of consideration? Yes/No?

*edit #2* You could probably make it REALLY cheap and unfair if it calculated acceleration towards nearby barrels, so that it subtracts the player distance from the barrel position (possibly factoring in player speed) and if you are getting closer it will target that to try and time when you are closest to it.

Share this post


Link to post

Sector size =/= room size. More or less map detail would change the behavior. Also, monster projectiles are pretty slow, whereas the player's are fast, so I'm not sure how effective it would be with non-hitscanners with the default speeds. It'd sure make -fast more even more of a threat.

Share this post


Link to post

I guess then you could forget room size and then just calculate distance from barrel and hope for the best.

I guess the easiest way to do this might be just to flag nearby barrels as "explosive" (whatever you want to call being an active target for the enemy) or make it have the same flag as the player, similar to how monsters "wake up" when you are within a certain distance if they aren't facing you.

Sodaholic said:

Sector size =/= room size. More or less map detail would change the behavior.

Share this post


Link to post

If the monster is a hitscanner and a barrel is close to a player and there is line of sight to the barrel then shoot the barrel with a 50% chance.

Although former humans would have a hard time exploding a barrel with their puny pistols.

Share this post


Link to post
Lvangundy said:

Good idea with lots of consideration? Yes/No?

I never directly addressed this, my apologies. Yes, I think it's a good idea. Only real snag I can think of is the slowness of the fireballs, as I mentioned earlier. Of course, the distance calculation could also try to take into account the time needed to reach the barrel, and not to bother if it's over a certain amount of predicted time.

On the other hand, you may wish to factor barrel health in the equation. An imp fireball is unlikely to take out a fully "healthy" barrel, so perhaps monsters targeting it to at least weaken it might be worth it.

Share this post


Link to post

Or rely on a hitscanner's inaccuracy to hit a nearby barrel instead of the player. You may also want to muck around with damagetypes, so the barrel gets killed more easily by enemy fire.

Share this post


Link to post

While not a direct implementation at all, I'd love to try scripting something like this into a ZDoom map at some point. Might be a good way to make fully-human custom enemies seem a bit less uncanny-valley in the AI 'verse.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×