mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-02 16:59:15 +00:00
88830e0d00
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now. Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes. Adds functionality for Batch Editor commands to `>`, `<` and <=/>= TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants. Main window has a new layout to account for DPI scaling (8 point grid) Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724) Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720) Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714) Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691) Added: Properties for ribbon/mark count (closes #3659) Fixed: Traded SV eggs are now checked correctly (closes #3692)
120 lines
4.4 KiB
C#
120 lines
4.4 KiB
C#
using System;
|
|
using static PKHeX.Core.Encounters8Nest;
|
|
using static PKHeX.Core.AbilityPermission;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Generation 8 Nest Encounter (Raid)
|
|
/// </summary>
|
|
/// <inheritdoc cref="EncounterStatic"/>
|
|
public abstract record EncounterStatic8Nest<T>(GameVersion Version) : EncounterStatic(Version), IGigantamaxReadOnly, IDynamaxLevelReadOnly where T : EncounterStatic8Nest<T>
|
|
{
|
|
public sealed override int Generation => 8;
|
|
public override EntityContext Context => EntityContext.Gen8;
|
|
public static Func<PKM, T, bool>? VerifyCorrelation { private get; set; }
|
|
public static Action<PKM, T, EncounterCriteria>? GenerateData { private get; set; }
|
|
|
|
public bool CanGigantamax { get; init; }
|
|
public byte DynamaxLevel { get; init; }
|
|
public override int Location { get => SharedNest; init { } }
|
|
|
|
public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
|
{
|
|
if (pk is PK8 d && d.DynamaxLevel < DynamaxLevel)
|
|
return false;
|
|
|
|
// Required Ability
|
|
if (Ability == OnlyHidden && pk.AbilityNumber != 4)
|
|
return false; // H
|
|
|
|
if (Version != GameVersion.SWSH && pk.Version != (int)Version && pk.Met_Location != SharedNest)
|
|
return false;
|
|
|
|
if (VerifyCorrelation != null && !VerifyCorrelation(pk, (T)this))
|
|
return false;
|
|
|
|
if (pk is IRibbonSetMark8 { HasMarkEncounter8: true })
|
|
return false;
|
|
if (pk.Species == (int)Core.Species.Shedinja && pk is IRibbonSetAffixed { AffixedRibbon: >= (int)RibbonIndex.MarkLunchtime })
|
|
return false;
|
|
|
|
return base.IsMatchExact(pk, evo);
|
|
}
|
|
|
|
protected sealed override EncounterMatchRating IsMatchDeferred(PKM pk)
|
|
{
|
|
if (Ability != Any12H)
|
|
{
|
|
// HA-Only is a strict match. Ability Capsule and Patch can potentially change these.
|
|
var num = pk.AbilityNumber;
|
|
if (num == 4)
|
|
{
|
|
if (Ability is not OnlyHidden && !AbilityVerifier.CanAbilityPatch(8, PersonalTable.SWSH.GetFormEntry(Species, Form), pk.Species))
|
|
return EncounterMatchRating.DeferredErrors;
|
|
}
|
|
else if (Ability.IsSingleValue(out int index) && 1 << index != num) // Fixed regular ability
|
|
{
|
|
if (Ability is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(8, PersonalTable.SWSH.GetFormEntry(Species, Form)))
|
|
return EncounterMatchRating.DeferredErrors;
|
|
}
|
|
}
|
|
|
|
return base.IsMatchDeferred(pk);
|
|
}
|
|
|
|
protected override bool IsMatchPartial(PKM pk)
|
|
{
|
|
if (pk is PK8 and IGigantamax g && g.CanGigantamax != CanGigantamax && !g.CanToggleGigantamax(pk.Species, pk.Form, Species, Form))
|
|
return true;
|
|
if (Species == (int)Core.Species.Alcremie && pk is IFormArgument { FormArgument: not 0 })
|
|
return true;
|
|
if (Species == (int)Core.Species.Runerigus && pk is IFormArgument { FormArgument: not 0 })
|
|
return true;
|
|
|
|
switch (Shiny)
|
|
{
|
|
case Shiny.Never when pk.IsShiny:
|
|
case Shiny.Always when !pk.IsShiny:
|
|
return true;
|
|
}
|
|
|
|
return base.IsMatchPartial(pk);
|
|
}
|
|
|
|
protected override void ApplyDetails(ITrainerInfo tr, EncounterCriteria criteria, PKM pk)
|
|
{
|
|
base.ApplyDetails(tr, criteria, pk);
|
|
if (GenerateData == null)
|
|
pk.SetRandomEC();
|
|
}
|
|
|
|
protected sealed override void SetPINGA(PKM pk, EncounterCriteria criteria)
|
|
{
|
|
if (GenerateData != null)
|
|
{
|
|
GenerateData(pk, (T)this, criteria);
|
|
return;
|
|
}
|
|
|
|
base.SetPINGA(pk, criteria);
|
|
if (Species == (int) Core.Species.Toxtricity)
|
|
{
|
|
while (true)
|
|
{
|
|
var result = EvolutionMethod.GetAmpLowKeyResult(pk.Nature);
|
|
if (result == pk.Form)
|
|
break;
|
|
pk.Nature = Util.Rand.Next(25);
|
|
}
|
|
|
|
// Might be originally generated with a Neutral nature, then above logic changes to another.
|
|
// Realign the stat nature to Serious mint.
|
|
if (pk.Nature != pk.StatNature && ((Nature)pk.StatNature).IsNeutral())
|
|
pk.StatNature = (int)Nature.Serious;
|
|
}
|
|
var pid = pk.PID;
|
|
RaidRNG.ForceShinyState(pk, Shiny == Shiny.Always, ref pid);
|
|
pk.PID = pid;
|
|
}
|
|
}
|