So I am modding some troops and wanted to try and extend the amount of tiers but in doing this, alongside other modders, I have come across the issue in the title.
that could be what it isHave you changed PartyTroopUpgradeModel by any chance? If I read the code correctly, this is happening because upgrade cost is 0xp for a troop. This would be considered a bug during our development so crash is preferable in these cases(Having 0xp required for upgrading)
But still, we can fix this. In the meantime you can give at least 1xp required for upgrading.
Also, I don't see the connection with TroopUpgradeTracker.CalculateReadyToUpgradeSafe() with this callstack. But the same issue(0xp required) might be causing the crash there ?
DefaultPartyTroopUpgradeModel.GetXpCostForUpgrade()
.CharacterHelper.GetCharacterTier
and change 7 to the highest troop tier in your mod.[HarmonyPatch(typeof(CharacterHelper), "GetCharacterTier")]
public static bool Prefix(CharacterObject character, ref int __result)
{
if (character.IsHero)
{
__result = 0;
}
__result = Math.Min(Math.Max(MathF.Ceiling(((float)character.Level - 5f) / 5f), 0), 10);
return false;
}
Joining a battle with of about 1000 troops, the same crash occurs on auto resolve and trying to play the battle. Although sometimes I were able to fight till reinforcements from the allied army spawn(800 battle size allows me to join the battle before crash, but game crashes anyway on reinforcements spawning). Last time I fixed this issue by deleting some looters upgrade paths.Does it also throw "Attempted to divide by 0"? What were you doing when the crash occurred?
You will have to patchJoining a battle with of about 1000 troops, the same crash occurs on auto resolve and trying to play the battle. Although sometimes I were able to fight till reinforcements from the allied army spawn(800 battle size allows me to join the battle before crash, but game crashes anyway on reinforcements spawning). Last time I fixed this issue by deleting some looters upgrade paths.
CharacterHelper.GetCharacterTier()
to match your number of troop tiers.Sorry for the silly question, but can I do it on the custom troop XML? Or where do I edit that?You will have to patchCharacterHelper.GetCharacterTier()
to match your number of troop tiers.
You edit it in Visual Studio by applying a Harmony prefix to it returning false and replacing it with your own code.Sorry for the silly question, but can I do it on the custom troop XML? Or where do I edit that?