FR/LG VC: handle TM/Tutors

Select a primary/secondary source verifier for better learn indication; not really worth doing this in mainline.
This commit is contained in:
Kurt 2026-02-28 15:09:59 -06:00
parent 2939bfae48
commit b93d57cc9a
2 changed files with 47 additions and 6 deletions

View File

@ -152,22 +152,36 @@ private static void CheckNX(Span<MoveResult> result, ReadOnlySpan<ushort> curren
var lg = LearnSource3LG.Instance;
var lp = lg[species];
var isFireRed = pk.Version == GameVersion.FR;
ILearnSource<PersonalInfo3> primaryLS = isFireRed ? fr : lg;
ILearnSource<PersonalInfo3> secondaryLS = !isFireRed ? fr : lg;
var primaryPI = isFireRed ? fp : lp;
var secondaryPI = !isFireRed ? fp : lp;
var primaryEnv = isFireRed ? LearnEnvironment.FR : LearnEnvironment.LG;
for (int i = result.Length - 1; i >= 0; i--)
{
if (result[i].Valid)
continue;
// Level Up moves are different for each game, but TM/HM is shared (use Emerald).
// Level Up moves are different for each game, but TM/HM is shared.
var move = current[i];
var chk = fr.GetCanLearn(pk, fp, evo, move, types & (MoveSourceType.LevelUp | MoveSourceType.AllTutors));
var chk = primaryLS.GetCanLearn(pk, primaryPI, evo, move, types);
if (chk != default)
{
result[i] = new(chk, (byte)stage, Context);
continue;
}
chk = lg.GetCanLearn(pk, lp, evo, move, types & MoveSourceType.LevelUp); // Tutors same as FR
chk = secondaryLS.GetCanLearn(pk, secondaryPI, evo, move, types & MoveSourceType.LevelUp); // Tutors same as FR
if (chk != default)
{
result[i] = new(chk, (byte)stage, Context);
continue;
}
// Tutors are indexes 0-14, same as Emerald.
if (LearnSource3E.GetIsTutorFRLG(evo.Species, move))
result[i] = new(new(LearnMethod.Tutor, primaryEnv));
}
}
@ -196,6 +210,10 @@ private static void GetAllMoves(Span<bool> result, PKM pk, EvoCriteria evo, Move
{
LearnSource3FR.Instance.GetAllMoves(result, pk, evo, types);
LearnSource3LG.Instance.GetAllMoves(result, pk, evo, types & (MoveSourceType.LevelUp));
// Tutors are indexes 0-14, same as Emerald.
if (types.HasFlag(MoveSourceType.EnhancedTutor))
LearnSource3E.GetAllTutorMovesFRLG(result, evo.Species);
return;
}
LearnSource3E.Instance.GetAllMoves(result, pk, evo, types);

View File

@ -144,10 +144,33 @@ public void GetAllMoves(Span<bool> result, PKM pk, EvoCriteria evo, MoveSourceTy
}
}
// TODO RSE VC: Remove these.
internal static bool GetIsTutorFRLG(ushort species, ushort move)
{
var info = Personal[species];
var index = Tutor_E.IndexOf(move);
if ((uint)index >= 15)
return false;
return info.TypeTutors[index];
}
internal static void GetAllTutorMovesFRLG(Span<bool> result, ushort species)
{
var pi = Personal[species];
var flags = pi.TypeTutors;
var moves = Tutor_E;
for (int i = 0; i < 15; i++)
{
if (flags[i])
result[moves[i]] = true;
}
}
private static ReadOnlySpan<ushort> Tutor_E =>
[
005, 014, 025, 034, 038, 068, 069, 102, 118, 135,
138, 086, 153, 157, 164, 223, 205, 244, 173, 196,
203, 189, 008, 207, 214, 129, 111, 009, 007, 210,
// Introduced in FR/LG
005, 014, 025, 034, 038, 068, 069, 102, 118, 135, 138, 086, 153, 157, 164,
// Introduced in Emerald
223, 205, 244, 173, 196, 203, 189, 008, 207, 214, 129, 111, 009, 007, 210,
];
}