In Progress Number of sacrificed troops incorrectly affected by tactics skill.

Users who are viewing this thread

Version number
1.6.2
Branch
Beta
Modded/unmodded
No, I didn't use any mods.

Marek15

Veteran
Summary:
The number of troops sacrificed when trying to escape from battle increases with high tactics skill instead of decreasing. For example a sacrifice of 36 troops at 0 tactics would become 84 troops at 300 tactics.
Also the number of troops sacrificed when breaking into or out of a siege is not affected by the tactics skill.

This is caused by bad math in "DefaultTroopSacrificeModel.cs". Specifically methods "GetNumberOfTroopsSacrificedForTryingToGetAway" and "GetLostTroopCount".
To fix this replace these lines of code:
Code:
//GetNumberOfTroopsSacrificedForTryingToGetAway
      SkillHelper.AddSkillBonusForCharacter(DefaultSkills.Tactics, DefaultSkillEffects.TacticsTroopSacrificeReduction, CharacterObject.PlayerCharacter, ref stat1, -1, true, 0);
      ExplainedNumber stat2 = new ExplainedNumber((float) Math.Max(((double) ofRegularMembers * Math.Pow((double) Math.Min(val1, 3f), 1.3) * 0.1 / (2.0 / (2.0 + ((double) stat1.ResultNumber - 1.0) * 10.0)) + 5.0).Round(), 1), false, (TextObject) null);
     
//GetLostTroopCount
      ExplainedNumber stat1 = new ExplainedNumber(0.01f, false, (TextObject) null);
      SkillHelper.AddSkillBonusForCharacter(DefaultSkills.Tactics, DefaultSkillEffects.TacticsTroopSacrificeReduction, CharacterObject.PlayerCharacter, ref stat1, -1, true, 0);
      float num2 = stat1.ResultNumber - 0.01f;
With this:
Code:
//GetNumberOfTroopsSacrificedForTryingToGetAway
      SkillHelper.AddSkillBonusForCharacter(DefaultSkills.Tactics, DefaultSkillEffects.TacticsTroopSacrificeReduction, CharacterObject.PlayerCharacter, ref stat1, -1, false, 0);
      ExplainedNumber stat2 = new ExplainedNumber((float) Math.Max(((double) ofRegularMembers * Math.Pow((double) Math.Min(val1, 3f), 1.3) * 0.1 * (double) stat1.ResultNumber + 5.0).Round(), 1), false, (TextObject) null);
     
//GetLostTroopCount
      ExplainedNumber stat1 = new ExplainedNumber(1f, false, (TextObject) null);
      SkillHelper.AddSkillBonusForCharacter(DefaultSkills.Tactics, DefaultSkillEffects.TacticsTroopSacrificeReduction, CharacterObject.PlayerCharacter, ref stat1, -1, true, 0);
      float num2 = stat1.ResultNumber - 1f;
 

uçanbiblo

Community Support
Community Support
M&BWBWF&SNWVC
Hello, i have forwarded the issue to the QA team. Thank you for reporting it in and for your time.
 

Marek15

Veteran
The recent hotfix (28/09) did not fully solve the issue.
While the number of sacrificed troops does decrease with higher skill, because of bad math it reduces the number by 100% when the tactics skill is above 200.
Code:
//GetNumberOfTroopsSacrificedForTryingToGetAway

//This math is bad
      ExplainedNumber stat2 = new ExplainedNumber((float) Math.Max(((double) ofRegularMembers * Math.Pow((double) Math.Min(val1, 3f), 1.3) * 0.1 / (2.0 / (2.0 + ((double) stat1.ResultNumber - 1.0) * 10.0)) + 5.0).Round(), 1), false, (TextObject) null);

//Replace with this
      ExplainedNumber stat2 = new ExplainedNumber((float) Math.Max(((double) ofRegularMembers * Math.Pow((double) Math.Min(val1, 3f), 1.3) * 0.1 * (double) stat1.ResultNumber + 5.0).Round(), 1), false, (TextObject) null);
 
Top Bottom