Skip to content
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

Misc repair kit draws ammo from nearby player #73129

Merged
merged 3 commits into from
May 7, 2024

Conversation

RonaldCoppieters
Copy link
Contributor

@RonaldCoppieters RonaldCoppieters commented Apr 19, 2024

Summary

Bugfixes "Misc repair kit draws ammo from around player and inventory, opposed to an internal ammunition pocket."

Purpose of change

Closes issue #71090, following suggestions by AnotherSeawhite in #72774. Note that this PR does not yet allow for selecting between different ammo types or item types like the suggestion describes, but this could be tweaked in the future.

This behaviour could eventually be expanded to sewing kits and such. It only requires that the "USES_NEARBY_AMMO" flag is added and the pocket removed in the item's JSON.

Describe the solution

The magazine pocket has been removed from the item. The flag "USES_NEARBY_AMMO" was added that searches for the default ammo type within the player's crafting inventory.

Note: I'm tweaking the string that says "Charges: [ammo]/[capacity]" to say "Charges: [ammo]" using regex in src/activity_handlers.cpp:2573, because I didn't want to mess with the translations, but a cleaner edit would probably just be to add a translation for a string without the "/[capacity]" part. (Edit: No longer the case)

Describe alternatives you've considered

The whole "repair_item" logic could probably do with a rework where it no longer relies on the ammo system, but this PR is a band-aid solution to get the item working again at the very least.

Testing

Tested on the latest build if a damaged weapon can be repaired using nearby duct tape, if the duct tape was consumed, and that it still disallows repair if no duct tape is around. Behaviour could possibly be weird in cases where the ammo disappears from within the player's reach during the few seconds of repair, like when materials are stolen by an NPC and such. In this case it might still attempt a repair at no cost, but this hasn't been tested.

An old save was loaded. It will throw errors on existing repair kits that a pocket cannot be found for the duct tape and any duct tape inside existing repair kits will be lost as a result, but nothing major beyond that.

Additional context

is-71090-001
is-71090-002
is-71090-003
is-71090-004
is-71090-005
is-71090-006

Copy link
Contributor

You are creating a pull request with the master branch as the head branch. This is likely a mistake unless you really know what you are doing. You may read https://docs.github.com/en/get-started/quickstart/contributing-to-projects#creating-a-branch-to-work-on for a typical workflow of contributing to a project on GitHub.

@github-actions github-actions bot added [JSON] Changes (can be) made in JSON Spawn Creatures, items, vehicles, locations appearing on map [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) new contributor labels Apr 19, 2024
src/activity_handlers.cpp Outdated Show resolved Hide resolved
src/activity_handlers.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Apr 19, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Apr 20, 2024
src/activity_handlers.cpp Outdated Show resolved Hide resolved
src/activity_handlers.cpp Outdated Show resolved Hide resolved
src/activity_handlers.cpp Outdated Show resolved Hide resolved
Copy link
Member

@anothersimulacrum anothersimulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good at a glance overall.

src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
@esotericist
Copy link
Contributor

@RonaldCoppieters
hello, is there a reason you're closing and force-pushing an empty commit? is there a problem with the solution you were attempting?

@RonaldCoppieters
Copy link
Contributor Author

@esotericist No. Just a wrong command.

@esotericist
Copy link
Contributor

@esotericist No. Just a wrong command.

okay, good. this PR looked promising, so i was worried for a moment.

src/item.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the astyled astyled PR, label is assigned by github actions label Apr 22, 2024
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Apr 23, 2024
Copy link
Member

@RenechCDDA RenechCDDA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built locally, didn't find any issues with it.

@Maleclypse
Copy link
Member

Sorry this ended up sitting so long. I've rebased it to fix the conflicts and hopefully it will pass tests and I didn't mess anything up.

@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 3, 2024
data/json/flags.json Outdated Show resolved Hide resolved
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions and removed json-styled JSON lint passed, label assigned by github actions labels May 4, 2024
@I-am-Erk I-am-Erk merged commit 6e767b2 into CleverRaven:master May 7, 2024
20 of 26 checks passed
@I-am-Erk
Copy link
Member

I-am-Erk commented May 7, 2024

This looks good to me. I'm not super familiar with the items code so let's hope I haven't doomed us all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON new contributor Spawn Creatures, items, vehicles, locations appearing on map
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants