CleverRaven / CleverRaven/Cataclysm-DDA
Move as many AI actions as possible to an actor, not character, level, and define availability in species.json and monster definitions
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 13.2k
- Forks
- 4.6k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 205
Description
Is your feature request related to a problem? Please describe.
Currently, NPC behaviour and monster behaviour is basically completely different, and neither are very smart. NPCs are really dumb in some of the situations monsters do better (attack selection eg) and monsters behave clearly like zombies, charging in with no regard for their own health. This becomes an issue as we wish to depict smarter monsters, like mi-go and ferals. Also, now that we have the option of talking monsters, it would be very nice to be able to change some NPCs (free merchant guards eg) to monsters so that they would draw less processor power and have access to some neat functions like patrol.
Describe the solution you'd like
Without knowing anything about the underlying code, it seems to me that a lot of our AI routines should be abstracted a bit more and run at an actor level, not a character/monster one. for example, both NPCs and monsters should be able to investigate sounds. The details of how they do this should be largely the same regardless. If there are specifics (perception, traits, factional affiliation) that are lacked at the monster level, we should just add pseudo-stats for those for monsters.
The way I imagine this working is that we'd list available AI routines in species definitions, potentially along with any details for them, like snippets the actor says when engaging it along with volume and percent chance for saying a snippet. Sometimes we would define pseudo-attributes here if needed. We may want to allow access to this same thing at a monster level, or alternatively we could create new species to allow specifics, so smart_zombie would be a subspecies of zombie with a few different AI options.
We could, instead, have a new JSON element for AI_behaviour that lists available AI functions and is defined at a monster level, so zombies would get "AI_behaviour": "zombie_classic", while necromancers would get "zombie_smart". This is maybe a better option, but more work.
Some AI features that should be moved out like htis
- investigation of sounds
- patrol zones
- processing friendly fire risk
- pathfinding? this is almost certainly a can of worms, but is there any reason we can't make monsters pathfind the same as NPCs?
- Driving. NPCs should be able to use autodrive to drive, and when they can, some ferals could as well.
Some AI features that could be added inside a framework like this
- taking cover when under fire
- hiding when injured/frightened
- searching for an unseen attacker when injured
- choosing a more effective attack when a previous attack failed
- choosing attacks at all, I'm looking at you monsters
- climbing things
- ignoring non-threatening targets
- going for weakest targets
- recognizing when someone is acting threatening without attacking, eg taking your stuff or brandishing a weapon
- noticing when you're too far from home chasing an enemy, and choosing to return home instead of continuing
- noticing when you are outnumbered/outmatched, and choosing to flee
Describe alternatives you've considered
We could continue as we're doing, there's no real harm to it. I am not even sure if monsters and NPCs are similar enough to justify trying to merge their AI like this. I am sure it requires refactoring some stuff, and it may be that that stuff is better not refactored... or maybe, by putting them under one roof, it will be easier to work on some of the basic combat AI stuff.
Additional context
Note that I am only talking about short term/combat AI and behaviour here. Larger scale NPC behaviour trees should not be abstracted to this level. Monsters should always represent short-term encounters and don't need to process their long term goals and needs. That is the major difference between the two. However, in a fight, a smart feral or a mi-go doesn't need to have a whole different intelligence framework from an npc.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files, tests, or entry points are named. Start by locating the separate NPC and monster short-term AI implementations, then trace how species.json and monster definitions currently describe behavior. Done would require an agreed actor-level design, shared behavior coverage, and a defined way to express availability and related data in those definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, json
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100