Skip to content

Commit

Permalink
Fix some gen4 fish slot check inaccuracies
Browse files Browse the repository at this point in the history
Pt doesn't do Sticky Hold/Suction Cups right for fishing (not just D/P)
HGSS has a follower boost that is now implemented
lol at my GetSuperRod comparing range wrong for slot4

For HGSS follower boost, don't bother indicating differently even though it's not entirely transparent. We just assume the most permissive case (+50) even though people looking to replicate in-game might not have >= 250 friendship.
  • Loading branch information
kwsch committed Mar 12, 2024
1 parent 4435f03 commit 819f600
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 34 deletions.
31 changes: 2 additions & 29 deletions PKHeX.Core/Legality/RNG/ClassicEra/Gen4/MethodJ.cs
Expand Up @@ -102,10 +102,8 @@ private static bool CheckEncounterActivation<T>(T enc, ref LeadSeed result)
if (!IsValidCoronetB1F(s4, ref result.Seed))
return false;
}
// D/P don't reference Suction Cups or Sticky Hold.
return enc is IVersion { Version: Pt }
? IsFishPossible(enc.Type, ref result.Seed, ref result.Lead)
: IsFishPossible(enc.Type, ref result.Seed);
// D/P/Pt don't update the rod rate boost for Suction Cups or Sticky Hold correctly.
return IsFishPossible(enc.Type, ref result.Seed);
}
// Can sweet scent trigger.
return true;
Expand Down Expand Up @@ -471,31 +469,6 @@ private static bool IsFishPossible(SlotType4 encType, ref uint seed)
return false;
}

private static bool IsFishPossible(SlotType4 encType, ref uint seed, ref LeadRequired lead)
{
var rodRate = GetRodRate(encType);
var u16 = seed >> 16;
var roll = u16 / 656;
if (roll < rodRate)
{
seed = LCRNG.Prev(seed);
return true;
}

if (lead != None)
return false;

// Suction Cups / Sticky Hold
if (roll < rodRate * 2)
{
seed = LCRNG.Prev(seed);
lead = SuctionCups;
return true;
}

return false;
}

private static byte GetRodRate(SlotType4 type) => type switch
{
Old_Rod => 25,
Expand Down
17 changes: 13 additions & 4 deletions PKHeX.Core/Legality/RNG/ClassicEra/Gen4/MethodK.cs
Expand Up @@ -498,12 +498,16 @@ private static bool IsFishPossible(SlotType4 encType, ref uint seed, ref LeadReq
var rodRate = GetRodRate(encType);
var u16 = seed >> 16;
var roll = u16 % 100;
if (roll < rodRate)

// HG/SS: Lead (Following) Pokémon with >= 250 adds +50 to the rate. Assume the best case.
rodRate += 50; // This happens before Suction Cups / Sticky Hold, can be compounded.
if (roll < rodRate) // This will always succeed for Good/Super rod due to the base+bonus being >=100
{
seed = LCRNG.Prev(seed);
return true;
}

// Old Rod might reach here (75% < 100%)
if (lead != None)
return false;

Expand All @@ -514,20 +518,25 @@ private static bool IsFishPossible(SlotType4 encType, ref uint seed, ref LeadReq
lead = SuctionCups;
return true;
}

return false;
}

// Lead is something else, and cannot be changed. Does the same as the above method without a ref LeadRequired.
private static bool IsFishPossible(SlotType4 encType, ref uint seed)
{
var rate = GetRodRate(encType);
var rodRate = GetRodRate(encType);
var u16 = seed >> 16;
var roll = u16 % 100;
if (roll < rate)

// HG/SS: Lead (Following) Pokémon with >= 250 adds +50 to the rate. Assume the best case.
rodRate += 50; // This happens before Suction Cups / Sticky Hold, can be compounded.
if (roll < rodRate) // This will always succeed for Good/Super rod due to the base+bonus being >=100
{
seed = LCRNG.Prev(seed);
return true;
}

// Old Rod might reach here (75% < 100%)
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion PKHeX.Core/Legality/RNG/ClassicEra/Gen4/SlotMethodK.cs
Expand Up @@ -59,7 +59,7 @@ public static class SlotMethodK
< 70 => 1, // 40,69 (30%)
< 85 => 2, // 70,84 (15%)
< 95 => 3, // 85,94 (10%)
99 => 4, // 95 ( 5%)
<100 => 4, // 95 ( 5%)
_ => Invalid,
};

Expand Down

0 comments on commit 819f600

Please sign in to comment.