Swap rand call order, rename as overload

This commit is contained in:
Kurt 2020-01-22 19:04:20 -08:00
parent ba5cc26e83
commit 467045e95c
2 changed files with 7 additions and 4 deletions

View File

@ -390,8 +390,8 @@ public override PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria)
SetEggMetData(pk);
pk.CurrentFriendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship;
pk.HeightScalar = PokeSizeExtensions.GetRandomPokeSize();
pk.WeightScalar = PokeSizeExtensions.GetRandomPokeSize();
pk.HeightScalar = PokeSizeExtensions.GetRandomScalar();
pk.WeightScalar = PokeSizeExtensions.GetRandomScalar();
pk.RefreshChecksum();
return pk;

View File

@ -38,10 +38,13 @@ public static int GetRandomScalar(this PokeSize size)
PokeSize.AV => (Util.Rand.Next(0xA0) + 0x30),
PokeSize.L => (Util.Rand.Next(0x20) + 0xD0),
PokeSize.XL => (Util.Rand.Next(0x10) + 0xF0),
_ => GetRandomPokeSize() // Official code sums two randoms for triangular distribution.
_ => GetRandomScalar()
};
}
public static int GetRandomPokeSize() => Util.Rand.Next(0x80) + Util.Rand.Next(0x81);
/// <summary>
/// Gets a random size scalar with a triangular distribution (copying official implementation).
/// </summary>
public static int GetRandomScalar() => Util.Rand.Next(0x81) + Util.Rand.Next(0x80);
}
}