-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Npc attack #47562
Npc attack #47562
Conversation
I have been contemplating how to have a monster not use a particular option unless pressed - something more than "only do it every X turns". Possibly dependent on Anger above starting and Morale below starting? |
Need to add virtual destructor to other classes as well. |
i really don't understand why exactly |
blergh, i've run both the astyle and json linting tools from VS but they didn't do it (for the json.. turns out i ran astyle on the wrong branch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good and I didn't see any structural problems in the code. @Aivean should probably look over it for performance improvements but I'll leave that to his expertise.
Submission wise, I think a bunch of this can be broken into separate PRs for easier review. There's a lot of generic infrastructure work before you get into actually implementing the changes to the NPC AI. Normally, I wouldn't make such an issue about it, but this is such a large PR that it usefully could be trimmed.
160adaa
to
7582750
Compare
e4725fe
to
b706c3a
Compare
please excuse the individual commits for now, i'm trying to do miniscule changes to fix up the error messages in order to squash them into the correct commit later. |
11f8b39
to
a3ed94b
Compare
ac1984a
to
c8f13cf
Compare
This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there: https://discourse.cataclysmdda.org/t/magiclysm-a-total-fantasy-overhaul/20612/512 |
98ff3ce
to
c4e247d
Compare
This implements a class that owns all of the logic for an npc evaluating the best weapon to use in the moment.
This reverts commit 8d721b4.
Summary
Features "Implement new logic for NPCs to choose their attacks"
Purpose of change
We've been wanting to improve the npc ai, but afaik noone wanted to carry that torch. so here i am! :D
Describe the solution
requires #47207 as it has commits from this PR to break it up a bit.
implement a new
npc_attack
class with child classes for the different styles of attacks. in this PR, that ismelee
,gun
,throw
, andactivate_item
. throw has a fairly basic implementation because i needed the npc to understand that grenades needed to be thrown, and the activate item attack is for feature parity with npcs using grenades. Unfortunately, it looks pretty involved to properly estimate when it's a good idea to throw a grenade, so the likelyhood of an npc throwing a grenade is "not unless i'm surrounded, can't run, and there's no other option". grenades will have to be their own PR.add a new method in npc to evaluate all of its possible attack options and save the
npc_attack
and its data (callednpc_attack_effectiveness
) into the ai_cache. then just activate it via npc_attack::use.Describe alternatives you've considered
Watching npcs throw their pants at zombies
Testing
i'm writing some tests, and additionally i have run some live tests where i equipped an npc with a specific item and watched what they did with it. i can confirm that they throw items, use attack spells, fire guns, and use melee weapons. they also use grenades if their surrounded and are naked! (if they don't choose to run away first)
I'm drafting this to get it out in the open for some code review, though i'm pretty aware that i'm not done writing up the tests.
Additional context
follow ups should be, in no particular order: