Use precompiled rand for honeytree rand level

Add note that No Guard works the same as Illuminate and Arena Trap.
This commit is contained in:
Kurt 2024-03-12 00:46:52 -05:00
parent 819f6009bf
commit a62e169258
2 changed files with 17 additions and 3 deletions

View file

@ -65,6 +65,7 @@ public static class MethodJ
private static bool IsFeebasChance(uint rand) => (rand >> 15) == 1;
private static uint GetNature(uint rand) => rand / 0xA3Eu;
public static uint GetHoneyTreeLevel(uint rand) => 5 + (rand / 0x1745); // 5957; rand(11) using the pre-compiled rand function.
/// <summary>
/// Gets the first possible origin seed and lead for the input encounter &amp; constraints.
@ -105,6 +106,13 @@ public static class MethodJ
// D/P/Pt don't update the rod rate boost for Suction Cups or Sticky Hold correctly.
return IsFishPossible(enc.Type, ref result.Seed);
}
if (enc.Type is HoneyTree)
{
// Doesn't actually consume the Encounter Slot call, we return true when comparing ESV.
// Roll forward once here rather than add a branch in each method.
ref var seed = ref result.Seed;
seed = LCRNG.Next(seed);
}
// Can sweet scent trigger.
return true;
}
@ -122,6 +130,12 @@ public static class MethodJ
}
return IsFishPossible(enc.Type, ref result);
}
if (enc.Type is HoneyTree)
{
// Doesn't actually consume the Encounter Slot call, we return true when comparing ESV.
// Roll forward once here rather than add a branch in each method.
result = LCRNG.Next(result);
}
// Can sweet scent trigger.
return true;
}
@ -414,9 +428,9 @@ public static class MethodJ
return slot == enc.SlotNumber;
}
private static bool IsLevelValid<T>(T enc, byte min, byte max, byte format, uint u16LevelRand) where T : ILevelRange
private static bool IsLevelValid<T>(T enc, byte min, byte max, byte format, uint u16LevelRand) where T : IEncounterSlot4
{
var level = GetExpectedLevel(enc, u16LevelRand);
var level = enc.Type is HoneyTree ? GetHoneyTreeLevel(u16LevelRand) : GetExpectedLevel(enc, u16LevelRand);
return IsOriginalLevelValid(min, max, format, level);
}

View file

@ -27,7 +27,7 @@ public enum LeadRequired : byte
/// <summary> <see cref="Ability.Intimidate"/> or <see cref="Ability.KeenEye"/> failed to activate. </summary>
IntimidateKeenEyeFail,
/// <summary> <see cref="Ability.Illuminate"/> or <see cref="Ability.ArenaTrap"/> </summary>
/// <summary> <see cref="Ability.Illuminate"/> or <see cref="Ability.ArenaTrap"/> or <see cref="Ability.NoGuard"/> </summary>
Illuminate,
/// <summary> <see cref="Ability.SuctionCups"/> or <see cref="Ability.StickyHold"/> </summary>
SuctionCups,