saltyhotdog / BattletechIssueTracker

Public issue tracker to communicate with modders and HBS.
MIT License
6 stars 0 forks source link

Priority Salvage reward of more than 7 breaks UI; calculation of UI displayed salvage incorrect #6

Open mpstark opened 6 years ago

mpstark commented 6 years ago

Describe the problem The end-of-mission salvage screen only has seven slots for priority salvage, and thus if a contract rewards eight or more pieces of priority salvage, the player is unable to continue past this screen and is forced into reloading a save from before contract was negotiated. A picture of this situation occurring is here.

Using the default values from SimGameConstants.json -- "MaxSalvagePotential": 32 and "PrioritySalvageModifier": 0.25, this could potentially affect the vanilla game (i.e .25 * 32 = 8), though I've never seen a contract reward more than 6 pieces of priority salvage. Modding these values or more importantly the contracts themselves easily makes this number very achievable.

There are two approaches to fixing this issue:

Since without the Unity project or perhaps an in-depth knowledge of how to affect UI at runtime, I will work through the first solution.

Provide an example of the code where the problem occurs Salvage appears to be calculated in several spots. The one that controls the actual salvage generated on mission end is the property Contract.FinalPrioritySalvageCount set in Contract.GenerateSalvage.

this.FinalSalvageCount = num7;
this.FinalPrioritySalvageCount = Mathf.FloorToInt((float)num7 * constants.Salvage.PrioritySalvageModifier);

There are several places in the UI where it is also calculated.

Interestingly enough, all of the UI calculations do not use the correct value PrioritySalvageModifier, they all instead incorrectly divide by 4 instead, leading to the wrong salvage results displayed if PrioritySalvageModifier is changed.

This is SGContractsListItem.Init's handling of salvage calculation, which is representative of the other UI calculations:

int num = contract.SalvagePotential + this.simState.Constants.Finances.ContractFloorSalvageBonus;
int num2 = Mathf.FloorToInt((float)num / 4f);
this.setFieldText(this.contractMaxSalvage, string.Format("{0} / {1}", num2, num));
int num3 = Mathf.FloorToInt(contract.Override.negotiatedSalvage * (float)contract.SalvagePotential) + this.simState.Constants.Finances.ContractFloorSalvageBonus;
int num4 = Mathf.FloorToInt((float)num3 / 4f);
this.setFieldText(this.contractSalvage, string.Format("{0} / {1}", num4, num3));

Provide an example of your proposed solution Modify Contract.FinalPrioritySalvageCount set in Contract.GenerateSalvage to:

this.FinalPrioritySalvageCount = Math.Min(7, Mathf.FloorToInt((float)num7 * constants.Salvage.PrioritySalvageModifier));

Modify all UI references to match, example of new SGContractsListItem.Init:

int num = contract.SalvagePotential + this.simState.Constants.Finances.ContractFloorSalvageBonus;
int num2 = Math.Min(7, Mathf.FloorToInt((float)num * sim.Constants.Salvage.PrioritySalvageModifier));
this.setFieldText(this.contractMaxSalvage, string.Format("{0} / {1}", num2, num));
int num3 = Mathf.FloorToInt(contract.Override.negotiatedSalvage * (float)contract.SalvagePotential) + this.simState.Constants.Finances.ContractFloorSalvageBonus;
int num4 = Math.Min(7, Mathf.FloorToInt((float)num3 * sim.Constants.Salvage.PrioritySalvageModifier));
this.setFieldText(this.contractSalvage, string.Format("{0} / {1}", num4, num3));

Leave any additional comments here Obviously, the proposed solution is a stopgap to provide for a UI problem, though in doing so, a problem with UI calculations of salvage was revealed. Fixing the UI to allow for arbitrary numbers of priority salvage might also not be feasible as well, in which this solution would work.

Morphyum commented 6 years ago

I don't feel this is sev2 since you cant reach that number without modding, i recomend sev3

caardappel-hbs commented 6 years ago

Forwarded to Sim UX team for assessment.