Fixes quivers not consuming charges. #34290
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY: None
Fixes #32320.
This is what happens in the save from the linked issue:
g->u.ammo_location
has anitem_location
that points to the nearby stack of arrows (when loading the save, the arrows are right next to the player character within a heap of items).When firing the bow, the game uses
g->u.ammo_location
(as it is currently valid). This actually consumes the charges from that stack. The arrows in the quiver are not used as the arrows stack on the ground is enough. This may easily appear as if the firing had not consumed any ammo at all. (It actually does, I checked the stack on the ground after firing).What is a bug is this:
ammo_location
is used without accessibility check. It works, even when the location is far away (as long as it's inside the reality bubble).g->u.ammo_location
can be set via reloading the bow (this seems to be the intended behavior) or via changing the "attack mode of the wielded item" (F
). The user may have accidentally selected that item stack nearby as their preferred ammo location.I added some code to ensure the item from
ammo_location
is at least adjacent to the acting avatar.