tase
Recruit
Game version: e1.2.0 (present in previous version too)
Not a straight crash, but an issue that can cause crashes in the future.
I.e a bandit party template with 4 stacks, its first three stacks having a min of 0, possibly leading to parties with 0 units, which causes a crash when interacting with them.
Anyway, anything in the party template beyond the 3rd stack is ignored.
MobileParty.cs
I can't assume why it was done like this. A more flexible implementation would look like this.
I've tested this implementation with Harmony and it had the desired effect.
Not a straight crash, but an issue that can cause crashes in the future.
I.e a bandit party template with 4 stacks, its first three stacks having a min of 0, possibly leading to parties with 0 units, which causes a crash when interacting with them.
Anyway, anything in the party template beyond the 3rd stack is ignored.
MobileParty.cs
C#:
private void FillPartyStacks(PartyTemplateObject pt, PartyTypeEnum partyType, int troopNumberLimit = -1)
{
switch (partyType)
{
case PartyTypeEnum.Bandit:
{
(...random numbers f, f2, f3 generated...)
AddElementToMemberRoster(pt.Stacks[0].Character, MBRandom.RoundRandomized(f));
if (pt.Stacks.Count > 1)
{
AddElementToMemberRoster(pt.Stacks[1].Character, MBRandom.RoundRandomized(f2));
}
if (pt.Stacks.Count > 2)
{
AddElementToMemberRoster(pt.Stacks[2].Character, MBRandom.RoundRandomized(f3));
}
return;
}
(...)
I can't assume why it was done like this. A more flexible implementation would look like this.
C#:
(...)
case PartyTypeEnum.Bandit:
{
var gameProcess = MiscHelper.GetGameProcess();
var num = 0.33f + 0.67f * gameProcess;
var num2 = MBRandom.RandomInt(2);
var num3 = (num2 == 0) ? MBRandom.RandomFloat : (MBRandom.RandomFloat * MBRandom.RandomFloat * MBRandom.RandomFloat * 4f);
var num4 = (num2 == 0) ? (num3 * 0.8f + 0.2f) : (1f + num3);
foreach(var stack in pt.Stacks)
{
var randomFloat = MBRandom.RandomFloat;
float f = ((float)stack.MinValue + num * num4 * randomFloat * (float)(stack.MaxValue - stack.MinValue));
AddElementToMemberRoster(stack.Character, MBRandom.RoundRandomized(f));
}
return;
}
(...)
I've tested this implementation with Harmony and it had the desired effect.
Last edited: