Closed RenechCDDA closed 1 week ago
Hmm looks like this will cause an intermittent test failure. Let's hold off on merging this until I can resolve that.
That was simple enough to resolve, just allowed them to throw if they had backups of the weapon they were throwing. So a NPC with a bag of rocks will leave the last one to bash your skull in with, but throw the rest if possible. Will also work if the NPC has a bag of throwing axes, or javelins, or something strange like that.
Summary
Bugfixes "NPCs won't throw their last, best weapon"
Purpose of change
NPCs still trying to throw good melee weapons in some circumstances...
Fixes #71526
I assume closes #73480
Describe the solution
Dissect npc::wield_better_weapon() into its constituent evaluation and iteration parts so it can be reused elsewhere
When NPC is deciding to throw a weapon, check if this is their best weapon. If it is, rate it as unavailable for throwing purposes.
Describe alternatives you've considered
This doesn't try to cover some situation where the NPC MUST throw their only item to survive, but I don't consider that very likely?
Testing
Loaded the save from #71526 and run towards the bandits, got a hatchet and baseball bat thrown at me. Applied PR, tried again, nothing is thrown. Bandit with a glock still shoots me on approach in both circumstances.
Ran [npc_ai] and [npc_attack] tests locally, passed.
Mergers, reviewers, everyone else: Some additional manual testing around grenades/thrown weapons would be nice
Additional context