Fixed issue with damage reduction imporoperly displaying in the Mechbay#218
Merged
CptMoore merged 4 commits intoBattletechModders:masterfrom Aug 5, 2024
Merged
Fixed issue with damage reduction imporoperly displaying in the Mechbay#218CptMoore merged 4 commits intoBattletechModders:masterfrom
CptMoore merged 4 commits intoBattletechModders:masterfrom
Conversation
CptMoore
requested changes
Aug 4, 2024
| var value = DamageReductionMultiplierAll(mechDef); | ||
| tooltipData.dataList.Add("<u>" + Strings.T("Damage Reduction") + "</u>", Strings.T("{0} %", value)); | ||
| var value = 1 - DamageReductionMultiplierAll(mechDef); | ||
| tooltipData.dataList.Add("<u>" + Strings.T("Damage Reduction") + "</u>", Strings.T($"{value * 100} %")); |
Member
There was a problem hiding this comment.
Suggested change
| tooltipData.dataList.Add("<u>" + Strings.T("Damage Reduction") + "</u>", Strings.T($"{value * 100} %")); | |
| tooltipData.dataList.Add("<u>" + Strings.T("Damage Reduction") + "</u>", Strings.T("{0} %", percent)); |
going through string.T formatting should in theory allow internationalization on the string.. in this case the percent sign and the whitepace in between...
Contributor
Author
There was a problem hiding this comment.
Doing it this way
var reduction = 1 - DamageReductionMultiplierAll(mechDef);
var percent = (int)(reduction * 100);
tooltipData.dataList.Add("<u>" + Strings.T("Damage Reduction") + "</u>", Strings.T("{0} %", percent));Results in floating point errors with some reduction values that will cause incorrect reduction to display (EX: in a 0.8 damage reduction test I had this display as 19% damage reduction). I recommend not doing an integer conversion and using standard percent numeric formatting to handle this instead.
var reduction = 1 - DamageReductionMultiplierAll(mechDef);
tooltipData.dataList.Add("<u>" + Strings.T("Damage Reduction") + "</u>", Strings.T("{0:P0}", reduction));
Member
There was a problem hiding this comment.
Looks much better, implement that, squash everything and I'll merge
thx
Co-authored-by: CptMoore <39010654+CptMoore@users.noreply.github.com>
Co-authored-by: CptMoore <39010654+CptMoore@users.noreply.github.com>
This file contains hidden or 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
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.
The durability stat was incorrectly handling damage reduction resulting in it decreasing both the displayed amount of armor and the durability value in the tooltip.
Additionally damage reduction was not being displayed at all.
These changes now allow damage reduction effects on the mech to properly increase the displayed durability, and displays the damage reduction % as part of the durability breakdown. Damage reduction no longer modifies the displayed armor value.