Moveset generator tweaks, dexnav move logic

This commit is contained in:
Kurt 2021-01-30 10:15:38 -08:00
parent 1e86fdcea8
commit 4f7faf9c85
4 changed files with 46 additions and 6 deletions

View file

@ -79,6 +79,19 @@ namespace PKHeX.Core
if (encounter is IRelearn r && r.Relearn.Count > 0) if (encounter is IRelearn r && r.Relearn.Count > 0)
return r.Relearn; return r.Relearn;
if (enc is EncounterSlot6AO {CanDexNav: true} dn)
{
var moves = legal.Info.Moves;
for (int i = 0; i < moves.Length; i++)
{
if (moves[i].Valid)
continue;
var move = legal.pkm.GetMove(i);
if (dn.CanBeDexNavMove(move))
return new[] { move, 0, 0, 0 };
}
}
return m; return m;
} }
} }

View file

@ -23,8 +23,7 @@ namespace PKHeX.Core
var pk6 = (PK6)pk; var pk6 = (PK6)pk;
if (CanDexNav) if (CanDexNav)
{ {
var baseSpec = EvoBase.GetBaseSpecies(pk); var eggMoves = GetDexNavMoves();
var eggMoves = MoveEgg.GetEggMoves(pk.PersonalInfo, baseSpec.Species, baseSpec.Form, Version, 6);
if (eggMoves.Length > 0) if (eggMoves.Length > 0)
pk6.RelearnMove1 = eggMoves[Util.Rand.Next(eggMoves.Length)]; pk6.RelearnMove1 = eggMoves[Util.Rand.Next(eggMoves.Length)];
} }
@ -45,5 +44,18 @@ namespace PKHeX.Core
} }
protected override HiddenAbilityPermission IsHiddenAbilitySlot() => CanDexNav || Area.Type == SlotType.Horde ? HiddenAbilityPermission.Possible : HiddenAbilityPermission.Never; protected override HiddenAbilityPermission IsHiddenAbilitySlot() => CanDexNav || Area.Type == SlotType.Horde ? HiddenAbilityPermission.Possible : HiddenAbilityPermission.Never;
private int[] GetDexNavMoves()
{
var et = EvolutionTree.GetEvolutionTree(6);
var sf = et.GetBaseSpeciesForm(Species, Form);
return MoveEgg.GetEggMoves(6, sf & 0x7FF, sf >> 11, Version);
}
public bool CanBeDexNavMove(int move)
{
var baseEgg = GetDexNavMoves();
return System.Array.IndexOf(baseEgg, move) >= 0;
}
} }
} }

View file

@ -189,7 +189,7 @@ namespace PKHeX.Core
return moves; return moves;
} }
private static IEnumerable<IEncounterable> GetPossibleOfType(PKM pk, IReadOnlyCollection<int> needs, GameVersion version, EncounterOrder type, IReadOnlyList<EvoCriteria> chain) private static IEnumerable<IEncounterable> GetPossibleOfType(PKM pk, IReadOnlyList<int> needs, GameVersion version, EncounterOrder type, IReadOnlyList<EvoCriteria> chain)
{ {
return type switch return type switch
{ {
@ -340,7 +340,7 @@ namespace PKHeX.Core
/// <param name="needs">Moves which cannot be taught by the player.</param> /// <param name="needs">Moves which cannot be taught by the player.</param>
/// <param name="chain">Origin possible evolution chain</param> /// <param name="chain">Origin possible evolution chain</param>
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns> /// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
private static IEnumerable<EncounterSlot> GetSlots(PKM pk, IReadOnlyCollection<int> needs, IReadOnlyList<EvoCriteria> chain) private static IEnumerable<EncounterSlot> GetSlots(PKM pk, IReadOnlyList<int> needs, IReadOnlyList<EvoCriteria> chain)
{ {
var slots = EncounterSlotGenerator.GetPossible(pk, chain); var slots = EncounterSlotGenerator.GetPossible(pk, chain);
foreach (var slot in slots) foreach (var slot in slots)
@ -354,7 +354,10 @@ namespace PKHeX.Core
continue; continue;
} }
if (slot is IMoveset m && needs.Except(m.Moves).Any()) if (slot is IMoveset m && !needs.Except(m.Moves).Any())
yield return slot;
if (needs.Count == 1 && slot is EncounterSlot6AO {CanDexNav: true} dn && dn.CanBeDexNavMove(needs[0]))
yield return slot; yield return slot;
} }
} }

View file

@ -231,6 +231,18 @@ namespace PKHeX.Core
yield return s; yield return s;
} }
public int GetBaseSpeciesForm(int species, int form, int skip = 0)
{
var chain = GetEvolutionsAndPreEvolutions(species, form);
foreach (var c in chain)
{
if (skip == 0)
return c;
skip--;
}
return species | (form << 11);
}
/// <summary> /// <summary>
/// Gets all species the <see cref="species"/>-<see cref="form"/> can evolve from, yielded in order of increasing evolution stage. /// Gets all species the <see cref="species"/>-<see cref="form"/> can evolve from, yielded in order of increasing evolution stage.
/// </summary> /// </summary>