-
Notifications
You must be signed in to change notification settings - Fork 254
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: power armor actually benefits from advanced UPS efficiency, adjust efficiency ratio #4842
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…st efficiency ratio
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. |
Co-Authored-By: KheirFerrum <102964889+KheirFerrum@users.noreply.github.com>
And thanks to Kheir for figuring out the problems, it seems to work now. Will re-mark as ready after I finish updating the PR OP. |
KheirFerrum
reviewed
Jun 20, 2024
Co-Authored-By: KheirFerrum <102964889+KheirFerrum@users.noreply.github.com>
scarf005
approved these changes
Jun 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Checklist
Required
main
so it won't cause conflict when updatingmain
branch later.Purpose of change
This fixes a flaw I found with the advanced UPS not gaining any benefit when used with light power armor like it does for other items, and along the way I ended up deciding to make the efficiency multiplier used elsewhere by advanced UPS a little neater.
On further testing it was found that this mainly applies to power draw values that demand an odd number of charges, which is why light power armor was most strongly affected by this. @KheirFerrum provided a proper fix for that that compensates for odd-number charge consumption when using advanced UPS.
Fixes #3765
Describe the solution
Character::consume_remote_fuel
to consume 0.5x charges when using advanced UPS, instead of a janky 0.6x.Character::use_charges
, provided by Kheir. Basically, because it's being fed a rawint
for how much power it needs to consume from the UPS, it can't gracefully handle cutting the power draw in half in those cases, and that's quite a big difference considering with UPS use each charge is a full kilojoule. Kheir's function checks if the power draw would be an odd number and applies a reduction 50% of the time so that net behavior over a long period of time will match expected results you'd get if power draw was an even number.Character::process_items
as well.ranged::gunmode_checks_weapon
to definedadv_ups_drain
as half that ofups_drain
visitable<inventory>::charges_of
andvisitable<Character>::charges_of
to use new multiplier for advanced UPS.Describe alternatives you've considered
Banging the code against a rock until every single power-related function and all battery JSON has been converted to properly deal in joules instead of kJ. We'll probably have to suffer than someday anyway if we ever JSONize UPS items...
Testing
Power draw is weird and random, so exact matches to expected average aren't as important as confirming the difference exists.
Comparison of UPS items after 5 minutes of light power armor+helm use each:
![image](https://private-user-images.githubusercontent.com/11582235/341573564-5867eaba-980a-43d7-a95f-15ddcf64a465.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwMTEwNjMsIm5iZiI6MTcyMDAxMDc2MywicGF0aCI6Ii8xMTU4MjIzNS8zNDE1NzM1NjQtNTg2N2VhYmEtOTgwYS00M2Q3LWE5NWYtMTVkZGNmNjRhNDY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAzVDEyNDYwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE0Yjk1MDZiYzE0NTM5MjViOGQ0YmNmZTkxMzBmMTA4ZGYyZjYzNjM4MDYzYjRhZWI0OWFiMmI1MTViYzIyYjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.cf0twT5JRuIh2jN4WeSkb1flXE4VMXDCOMYuIamd8aA)
Modified 3-kW heavy power armor test results:
![image](https://private-user-images.githubusercontent.com/11582235/341573538-d04f9de0-63a6-407a-b1d0-a1d1f20519c7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwMTEwNjMsIm5iZiI6MTcyMDAxMDc2MywicGF0aCI6Ii8xMTU4MjIzNS8zNDE1NzM1MzgtZDA0ZjlkZTAtNjNhNi00MDdhLWIxZDAtYTFkMWYyMDUxOWM3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAzVDEyNDYwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViZGMzYzUzMjUxN2M5NDYxOGExYzVkMzE2Y2FkZTA3NmNmM2I4ZTBiOGZkZWI3YjExYzk5Zjg2NmUxYmMzM2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.P44HdfKXtwNLnIiQHyjdM2MCisHwZ0S0MdNtnV4q9dE)
Laser pistol message:
![image](https://private-user-images.githubusercontent.com/11582235/341504034-31e08cf0-24f7-48d0-82dc-134f9de45086.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwMTEwNjMsIm5iZiI6MTcyMDAxMDc2MywicGF0aCI6Ii8xMTU4MjIzNS8zNDE1MDQwMzQtMzFlMDhjZjAtMjRmNy00OGQwLTgyZGMtMTM0ZjlkZTQ1MDg2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAzVDEyNDYwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI1ZWJlM2IzZmM1MDlkNDg5YWQ1ZmE5MzYwMTdlM2MyMTIzOGMzYzY0MDgzYzMwMGVhY2NmY2Y5N2FjY2U4NTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.igX8uPVEQF2ulSJfgX2K1BZNKTgIMChBR64fA3fGkBA)
Additional context
At some point I want to unhardcode UPS items outright which will mean a JSONized efficiency rating for each item, which means the current hacks will likely need to be replaced with something that can handle it better. That might even require an outright overhaul of power draw code,
use_charges_if_avail
, or more to behave more sanely, I don't know.