-
Notifications
You must be signed in to change notification settings - Fork 272
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
refactor: Energy Rework #5259
base: main
Are you sure you want to change the base?
refactor: Energy Rework #5259
Conversation
Procrastinated long enough. This commit is mainly proof of concept, it makes batteries type: BATTERY instead of type magazine and has them store energy as units::energy instead of charges. `ammo_consume` is a hack for me to play with, which confirms that power is being drawn correctly when it is called. The bionic scanner is sort of necessary at the moment for testing purposes. Next step is to convert energy using functions over from charge usage.
@@ -576,7 +576,6 @@ | |||
"target": "bionic_scanner_on", | |||
"msg": "You start scanning for bionics.", | |||
"active": true, | |||
"need_charges": 1, |
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.
Removing this will if I recall let you turn it on even when it has zero power? Unless 1 is a default in the code already.
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.
Necessary while I'm testing, since batteries don't have charges in the rework. There's not a whole lot of point in reviewing my work at this stage, it's very preliminary.
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.
Ah, aight. Hope it goes well then. :D
Add and convert most of the power handling code. Need to update `has_energy()` and `use_energy()` pending an understanding of `visitable.cpp` code.
Finishes all the power draw code, so items that consume power via power draw will now consume power properly. Next up is the ability to load batteries, unload batteries, and use magazines alongside batteries.
Autofix has formatted code style violation in this PR. I edit commits locally (e.g: git, github desktop) and want to keep autofix
I do not want the automated commit
If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT. |
Allow you to reload batteries into an item, add migration of batteries to new system. Lay down early framework for gun power draw system. Energy Rework Part 3 Allow you to reload batteries into an item, add migration of batteries to new system. Lay down early framework for gun power draw system.
45e1a1b
to
b70c8f2
Compare
`iuse_actor.cpp` use functions now return charges to be used and energy to be used as appropriate. Updates partially some of the jsons that use batteries as ammo
13a13e6
to
7ecabae
Compare
Partially updates the iuse.cpp action. Fixes up the things the merge fucks in the code.
…eirFerrum/Cataclysm-BN into The-BIG-FUCKING-energy-rework
Continue work on iuse.cpp Note, check up on pet food, it used to consume charges from via code instead of the return function. Must confirm if that will still work.
Starting with some macros, it's working alright. Updated the firework iuse actions to use the new transforms, removed the `taser2` iuse. Remind myself to update the hand crank to actually recharge batteries after I'm done here.
098444c
to
bafda51
Compare
No need to bother calculating energy/units remaining if the value to compare against is 0, should save on processing time.
Checklist
Required
main
so it won't cause conflict when updatingmain
branch later.Optional
doc/
folder.lang/bn_extract_json_strings.sh
script if it does not support them yet.Purpose of change
Basically, make batteries use discrete charges in the form of
units::energy
instead of charges, which will allow us to makepower_draw
behaviour less cursed and in general make code that handles power more reliable.Describe the solution
This PR isn't functional at the moment, I'm partway through a lot of infrastructure reworking but I can at least confirm that most of the sections I've changed thus far work the way I expect them to.
Right now it's mainly visual, with batteries being able to store charges as
units::energy
, display them when loaded, etc. Theammo_consume()
function written for it is placeholder and will be converted toenergy_consume()
in the near future.Describe alternatives you've considered
power_draw
codeTesting
Additional context