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

fix: electrosense CBM's voltmeter can be used in advanced deconstruction #5744

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

chaosvolt
Copy link
Member

@chaosvolt chaosvolt commented Nov 20, 2024

Checklist

Required

Optional

Purpose of change

Now that we have a case where the voltmeter's actually being used as a tool, it'd be good to extend the voltmeter function of the electrosense CBM to be usable for that too.

As a side bonus it comes with taking us another step closer to being able to do more with JSONized bionic functions.

Describe the solution

C++ changes:

  1. In bionics.cpp, set it so that electrosense's voltmeter uses a different fake item specified below. Nothing really changes with this in how the bionic works when activated, but good for consistency and for later plans I had in mind involving JSONization of activating bionics.
  2. In character.cpp, updated Character::use_charges to handle charge use when drawing on electrosenses' voltmeter as a tool.
  3. In crafting.cpp, set Character::crafting_inventory so that the check for bionic fake items looks for static fake items that lack the BIONIC_TOGGLED flag, instead of demanding the bionic can't be toggle-able AT ALL. This is needed so that the electrosense's voltmeter function still allows being activated to access the voltmeter's use action without the presence of act_cost breaking its fake_item, but as a side benefit this will allow us to assign fake items to any bionic with existing hardcoded on-activate effects if desired, and potentially allow for JSONizing on-activate bionics by one day letting them just access a fake item's use action info.
  4. In visitable.cpp, updated visitable<Character>::charges_of and visitable<Character>::amount_of to take electrosense voltmeter into account.

JSON changes:

  1. Defined a fake item for electrosense to use that draws from bionic power. Counts as a substitute tool for the voltmeter.
  2. Gave the electrosense bionic's voltmeter function the integrated voltmeter as fake_item, so it can be used as one for tool purposes (like deconstructing high-voltage electronics).

Describe alternatives you've considered

Reworking voltmeters to need power to activate at some point in the future. This can probably wait until after Kheir's joule rework.

Testing

  1. Checked affected JSON files for syntax and lint errors.
  2. Compiled and load-tested.
  3. Gave myself bionic power and electrosense CBM. Confirmed it still works as expected when activated, and that it counts as a voltmeter for the purpose of deconstructing a plutonium generator.
  4. Confirmed electrosense lets me deconstruct a plutonium generated, and it drains 10 kj as expected.
  5. Confirmed if I don't have enough bionic power I can't attempt the deconstruct, and that nothing weird happens if I leave hydraulic muscles running while I deconstruct stuff.
  6. Re-tested as a razor boy, confirmed I still have razors for the sake of butchering and dissecting.
  7. Tested installing a bionic blade on a normal character, confirmed that toggling it on still works and that I don't gain access to its cutting quality unless it's deployed, as before.
  8. Checked affected C++ files for astyle.

Additional context

One thing I could follow up on this with would be taking advantage of now being able to assign fake items to activatable bionics and defining a fake item that'd allow dielectric capacitance to serve as a substitute for rubber gloves in the relevant crafting requirement, though this might require me to build up more support for charge consumption of JSONized bionic fake items.

@github-actions github-actions bot added src changes related to source code. JSON related to game datas in JSON format. labels Nov 20, 2024
@chaosvolt chaosvolt merged commit dd898d0 into cataclysmbnteam:main Nov 20, 2024
12 checks passed
@chaosvolt chaosvolt deleted the voltmeter-cbm-fix branch November 20, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants