2022-02-05 01:35:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 8 Static Encounter
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <inheritdoc cref="EncounterStatic"/>
|
|
|
|
|
public sealed record EncounterStatic8a(GameVersion Version) : EncounterStatic(Version), IAlpha
|
|
|
|
|
{
|
|
|
|
|
public bool[]? Mastery;
|
|
|
|
|
public override int Generation => 8;
|
|
|
|
|
|
|
|
|
|
public byte HeightScalar { get; }
|
|
|
|
|
public byte WeightScalar { get; }
|
|
|
|
|
public bool IsAlpha { get; set; }
|
2022-04-23 04:11:11 +00:00
|
|
|
|
public EncounterStatic8aCorrelation Method { get; init; }
|
2022-02-05 01:35:15 +00:00
|
|
|
|
|
|
|
|
|
public bool HasFixedHeight => HeightScalar != NoScalar;
|
|
|
|
|
public bool HasFixedWeight => WeightScalar != NoScalar;
|
|
|
|
|
private const byte NoScalar = 0;
|
|
|
|
|
|
|
|
|
|
public EncounterStatic8a(ushort species, ushort form, byte level, byte h = NoScalar, byte w = NoScalar) : this(GameVersion.PLA)
|
|
|
|
|
{
|
|
|
|
|
Species = species;
|
|
|
|
|
Form = form;
|
|
|
|
|
Level = level;
|
|
|
|
|
HeightScalar = h;
|
|
|
|
|
WeightScalar = w;
|
|
|
|
|
Shiny = Shiny.Never;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyDetails(sav, criteria, pk);
|
2022-02-23 07:18:10 +00:00
|
|
|
|
if (pk is IScaledSize s)
|
|
|
|
|
{
|
|
|
|
|
if (HasFixedHeight)
|
|
|
|
|
s.HeightScalar = HeightScalar;
|
|
|
|
|
if (HasFixedWeight)
|
|
|
|
|
s.WeightScalar = WeightScalar;
|
|
|
|
|
if (pk is IScaledSizeValue v)
|
|
|
|
|
{
|
|
|
|
|
v.ResetHeight();
|
|
|
|
|
v.ResetWeight();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-05 01:35:15 +00:00
|
|
|
|
|
|
|
|
|
if (IsAlpha && pk is IAlpha a)
|
|
|
|
|
a.IsAlpha = true;
|
|
|
|
|
|
|
|
|
|
if (pk is PA8 pa)
|
|
|
|
|
{
|
2022-04-23 04:11:11 +00:00
|
|
|
|
if (pa.AlphaMove != 0)
|
|
|
|
|
pk.PushMove(pa.AlphaMove);
|
2022-02-05 01:35:15 +00:00
|
|
|
|
pa.SetMasteryFlags();
|
|
|
|
|
pa.HeightScalarCopy = pa.HeightScalar;
|
|
|
|
|
}
|
2022-02-05 23:57:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetPINGA(PKM pk, EncounterCriteria criteria)
|
|
|
|
|
{
|
2022-02-21 01:59:48 +00:00
|
|
|
|
var para = GetParams();
|
2022-04-23 04:11:11 +00:00
|
|
|
|
var (_, slotSeed) = Overworld8aRNG.ApplyDetails(pk, criteria, para, IsAlpha);
|
|
|
|
|
// We don't override LevelMin, so just handle the two species cases.
|
|
|
|
|
if (Species == (int)Core.Species.Zorua)
|
|
|
|
|
pk.CurrentLevel = pk.Met_Level = Overworld8aRNG.GetRandomLevel(slotSeed, 26, 28);
|
|
|
|
|
else if (Species == (int)Core.Species.Phione)
|
|
|
|
|
pk.CurrentLevel = pk.Met_Level = Overworld8aRNG.GetRandomLevel(slotSeed, 33, 36);
|
|
|
|
|
|
|
|
|
|
if (Method == EncounterStatic8aCorrelation.Fixed)
|
|
|
|
|
pk.EncryptionConstant = Util.Rand32();
|
2022-02-05 01:35:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ApplyDetailsBall(PKM pk) => pk.Ball = Gift ? Ball : (int)Core.Ball.LAPoke;
|
|
|
|
|
|
2022-04-24 04:33:17 +00:00
|
|
|
|
public override bool IsMatchExact(PKM pkm, IDexLevel evo)
|
2022-02-05 01:35:15 +00:00
|
|
|
|
{
|
|
|
|
|
if (!base.IsMatchExact(pkm, evo))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (pkm is IScaledSize s)
|
|
|
|
|
{
|
|
|
|
|
if (HasFixedHeight && s.HeightScalar != HeightScalar)
|
|
|
|
|
return false;
|
|
|
|
|
if (HasFixedWeight && s.WeightScalar != WeightScalar)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pkm is IAlpha a && a.IsAlpha != IsAlpha)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override EncounterMatchRating GetMatchRating(PKM pkm)
|
2022-02-07 00:14:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (!IsForcedMasteryCorrect(pkm))
|
|
|
|
|
return EncounterMatchRating.PartialMatch;
|
|
|
|
|
|
|
|
|
|
var result = GetMatchRatingInternal(pkm);
|
|
|
|
|
var orig = base.GetMatchRating(pkm);
|
|
|
|
|
return result > orig ? result : orig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private EncounterMatchRating GetMatchRatingInternal(PKM pkm)
|
2022-02-05 01:35:15 +00:00
|
|
|
|
{
|
|
|
|
|
if (Shiny != Shiny.Random && !Shiny.IsValid(pkm))
|
|
|
|
|
return EncounterMatchRating.DeferredErrors;
|
|
|
|
|
if (Gift && pkm.Ball != Ball)
|
|
|
|
|
return EncounterMatchRating.DeferredErrors;
|
|
|
|
|
|
|
|
|
|
var orig = base.GetMatchRating(pkm);
|
|
|
|
|
if (orig is not EncounterMatchRating.Match)
|
|
|
|
|
return orig;
|
|
|
|
|
|
|
|
|
|
if (IsAlpha && pkm is PA8 { AlphaMove: 0 })
|
|
|
|
|
return EncounterMatchRating.Deferred;
|
|
|
|
|
|
|
|
|
|
return EncounterMatchRating.Match;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsForcedMasteryCorrect(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (Mastery is not { } m)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (Species == (int)Core.Species.Kricketune && Level == 12)
|
|
|
|
|
{
|
2022-03-06 20:01:47 +00:00
|
|
|
|
if (pkm is PA8 { AlphaMove: not (ushort)Move.FalseSwipe })
|
2022-02-05 01:35:15 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pkm is not IMoveShop8Mastery p)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < m.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!m[i])
|
|
|
|
|
continue;
|
|
|
|
|
var move = Moves[i];
|
2022-03-06 20:01:47 +00:00
|
|
|
|
var index = p.MoveShopPermitIndexes.IndexOf((ushort)move);
|
2022-02-05 01:35:15 +00:00
|
|
|
|
if (index == -1)
|
|
|
|
|
continue; // manually mastered for encounter, not a tutor
|
|
|
|
|
if (!p.GetMasteredRecordFlag(index))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-02-21 01:59:48 +00:00
|
|
|
|
|
|
|
|
|
private OverworldParam8a GetParams()
|
|
|
|
|
{
|
|
|
|
|
var pt = PersonalTable.LA;
|
|
|
|
|
var entry = pt.GetFormEntry(Species, Form);
|
|
|
|
|
var gender = (byte)entry.Gender;
|
|
|
|
|
return new OverworldParam8a
|
|
|
|
|
{
|
|
|
|
|
IsAlpha = IsAlpha,
|
2022-03-01 06:46:59 +00:00
|
|
|
|
FlawlessIVs = FlawlessIVCount,
|
2022-02-21 01:59:48 +00:00
|
|
|
|
Shiny = Shiny,
|
|
|
|
|
RollCount = 1, // Everything is shiny locked anyways
|
|
|
|
|
GenderRatio = gender,
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-02-05 01:35:15 +00:00
|
|
|
|
}
|
2022-04-23 04:11:11 +00:00
|
|
|
|
|
|
|
|
|
public enum EncounterStatic8aCorrelation : byte
|
|
|
|
|
{
|
|
|
|
|
WildGroup,
|
|
|
|
|
Fixed,
|
|
|
|
|
}
|