Cataclysm-dda: NPC companions don't fight intelligently; will melee until death

Created on 27 Dec 2016  路  14Comments  路  Source: CleverRaven/Cataclysm-DDA

As you can imagine, it makes keeping them alive considerably difficult, besides being a bit unrealistic. Would probably work best as a combat option.

<Enhancement / Feature> <Suggestion / Discussion> NPC / Factions

Most helpful comment

If player characters health < X, attempt to retreat from hostiles. if hostiles outrun player, attempt to continue fighting.

The problem is, retreat where? Towards player or away from some monster?
Also, retreat isn't always an option. Running away from faster enemies doesn't work, except to regroup with the player. So running away should be limited to player-owned NPCs.

Typically the player wants the NPC to run as in:

  • Closely follow the player when running - this could be simply done by NPC staying closer. That 6 tile distance is too much in most cases anyway.
  • Run as fast as the player. That's harder because it would require rewriting running (it's hardcoded for player right now), but it's not a lot of work. Three options here:

    • Run when player runs. Hacky, but practical.

    • Run when distance exceeds some threshold. Would make the NPC lag behind, but wouldn't be hacky.

    • Always run when there are dangerous monsters in sight. Probably not a good option, because NPCs have no memory.

  • Disengage from combat. This one isn't easy. But it could probably be solved by making the NPC approximate where the most dangerous monsters are concentrated and stay on the opposite side of player. That is, if hulk is on player's south, try to be on player's north (possibly with some minor offset, to avoid being on one line).

All 14 comments

I agree that they should have an option to "Flee if you feel that your life is in danger!" but I can imagine it would be somewhat difficult to implement as well. But as a side note you can set their combat options (even while they are getting pummeled) to "don't fight unless your life depends on it." Often they are being grabbed or too surrounded to even move, but on occasion they will break combat and follow you.

Combining #20782 with this one.

From that issue:

The player [is] capable of intelligently smacking zombies and taking a step back to avoid getting hit in melee (especially if a Zombie Brute/Hulk is around), but NPCs aren't. This frequently leads to bite wounds... or even death. Making NPC AI capable of hit and run attacks would be a welcome improvement.

This would absolutely help out with the issue here. NPCs right now just "brute force" melee combat. Having a cautious AI that engages and disengages and is willing to leave combat is the ideal.

Also see #19798 and #14888

Yeah there are a lot of issues with AI. That said, I still think that this one is the biggest - the other two affect their combat prowess, while this one makes it impossible to even keep them alive.

Can't they use a variant of the hit and run feature from coyotes and cougars?

Hit and run is pretty terrible and would not work for NPCs. You'd need to micro them hard. And that's even before factoring in grabs, which suck.

@Coolthulhu @RogueYun

Super Simple Implementation that would suck:

If player characters health < X, attempt to retreat from hostiles. if hostiles outrun player, attempt to continue fighting.

Better, more complex implementation:

Some sort of "fear factor" where certain types of monster inspire certain types of fear and a players resistance to fear are based on certain factors.

Perhaps a NPCs resistance to fear can be based off factors such as their equipment level (What weapons and armor they're holding), how much damage they've sustained, how much pain they are in, how many friendlies they have nearby, and their experience/skill level.

Certain traits could also be used to effect this.

Fool Hardy: NPC less likely to run away when damaged
Coward: NPC more likely to run away when faced with many enemies.

If player characters health < X, attempt to retreat from hostiles. if hostiles outrun player, attempt to continue fighting.

The problem is, retreat where? Towards player or away from some monster?
Also, retreat isn't always an option. Running away from faster enemies doesn't work, except to regroup with the player. So running away should be limited to player-owned NPCs.

Typically the player wants the NPC to run as in:

  • Closely follow the player when running - this could be simply done by NPC staying closer. That 6 tile distance is too much in most cases anyway.
  • Run as fast as the player. That's harder because it would require rewriting running (it's hardcoded for player right now), but it's not a lot of work. Three options here:

    • Run when player runs. Hacky, but practical.

    • Run when distance exceeds some threshold. Would make the NPC lag behind, but wouldn't be hacky.

    • Always run when there are dangerous monsters in sight. Probably not a good option, because NPCs have no memory.

  • Disengage from combat. This one isn't easy. But it could probably be solved by making the NPC approximate where the most dangerous monsters are concentrated and stay on the opposite side of player. That is, if hulk is on player's south, try to be on player's north (possibly with some minor offset, to avoid being on one line).

Each of these and some more. And call a factor that pick one - temper.

Adding courage/cowardice parameters until the system is shown to work will only make it harder to get it to actually work.

Closing as per lack of discussion.

@Night-Pryanik

I might be biased since I opened it, but I think this issue is too important to just close. It's literally a blocking issue when it comes to NPC companions being able to stay alive at all.

@Night-Pryanik

This one doesn't seem worth closing. There is plenty of discussion that's been had and many different way's to implement.

We need someone who can/will implement it.

If the bounty program is still online, this is one worth considering putting over there along with other things related to AI improvement in general.

@Coolthulhu referred to another important issue: NPCs still don't run. If I remember correctly that's because the run mode is hacky and hard coded.

Just because it would help if it were implemented doesn't mean the issue needs to stay open.

You cant fix this issue without rewriting npc ai, as such having a bunch of individual issues outlining shortcomings of the current system doesnt get us any closer to working npc ai.

See https://github.com/CleverRaven/Cataclysm-DDA/projects/17 for a start at such a rewrite.

Was this page helpful?
0 / 5 - 0 ratings