Skip to content

Comments

Fixed issue with damage reduction imporoperly displaying in the Mechbay#218

Merged
CptMoore merged 4 commits intoBattletechModders:masterfrom
Vek17:master
Aug 5, 2024
Merged

Fixed issue with damage reduction imporoperly displaying in the Mechbay#218
CptMoore merged 4 commits intoBattletechModders:masterfrom
Vek17:master

Conversation

@Vek17
Copy link
Contributor

@Vek17 Vek17 commented Aug 4, 2024

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.

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} %"));
Copy link
Member

Choose a reason for hiding this comment

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

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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));

Copy link
Member

@CptMoore CptMoore Aug 5, 2024

Choose a reason for hiding this comment

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

Looks much better, implement that, squash everything and I'll merge

thx

Vek17 and others added 3 commits August 4, 2024 18:58
Co-authored-by: CptMoore <39010654+CptMoore@users.noreply.github.com>
Co-authored-by: CptMoore <39010654+CptMoore@users.noreply.github.com>
@CptMoore CptMoore merged commit 3a5fab1 into BattletechModders:master Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants