Misc tweaks, fix slot8b ball

Fix Slot8b fallback ball not being Poké (was 0).

Swap eevee & none move sentinels; branch-if-zero easier for compiler.

Lift EV-any-above100 to be checked first; fetching personal and getting EXP is slower than checking 6 indexes in stack. Both branches would check. Most pokemon won't have EVs >100 as users flip through boxes in gen3/4.
This commit is contained in:
Kurt 2023-10-02 20:54:17 -07:00
parent e58a1565ad
commit 965039e258
4 changed files with 14 additions and 9 deletions

View file

@ -75,7 +75,7 @@ public sealed record EncounterSlot8b(EncounterArea8b Parent, ushort Species, byt
Met_Level = LevelMin,
Version = (byte)Version,
MetDate = EncounterDate.GetDateSwitch(),
Ball = (byte)GetRequiredBall(),
Ball = (byte)GetRequiredBall(Ball.Poke),
Language = lang,
OT_Name = tr.OT,

View file

@ -143,7 +143,7 @@ public sealed record EncounterSlot9(EncounterArea9 Parent, ushort Species, byte
if (form < EncounterUtil1.FormDynamic)
return form;
if (form == EncounterUtil1.FormVivillon)
return 18; // Fancy Vivillon
return Vivillon3DS.FancyFormID; // Fancy Vivillon
// flagged as totally random
return (byte)Util.Rand.Next(PersonalTable.SV[Species].FormCount);
}

View file

@ -17,7 +17,7 @@ internal static class EvolutionRestrictions
/// </summary>
private static ushort GetSpeciesEvolutionMove(ushort species) => species switch
{
(int)Eevee => 0,
(int)Eevee => EEVEE,
(int)MimeJr => (int)Mimic,
(int)Bonsly => (int)Mimic,
(int)Aipom => (int)DoubleHit,
@ -35,7 +35,8 @@ internal static class EvolutionRestrictions
_ => NONE,
};
private const ushort NONE = ushort.MaxValue;
private const ushort NONE = 0;
private const ushort EEVEE = ushort.MaxValue;
private static ReadOnlySpan<ushort> EeveeFairyMoves => new ushort[]
{
@ -63,7 +64,7 @@ internal static class EvolutionRestrictions
var move = GetSpeciesEvolutionMove(enc.Species);
if (move is NONE)
return true; // not a move evolution
if (move == 0)
if (move is EEVEE)
return species != (int)Sylveon || IsValidEvolutionWithMoveSylveon(pk, enc, info);
if (!IsMoveSlotAvailable(info.Moves))
return false;

View file

@ -51,17 +51,21 @@ public sealed class EffortValueVerifier : Verifier
private void VerifyGainedEVs34(LegalityAnalysis data, IEncounterTemplate enc, Span<int> evs, PKM pk)
{
bool anyAbove100 = evs.Find(static ev => ev > vitaMax) != default;
if (!anyAbove100)
return;
if (enc.LevelMin == 100) // only true for Gen4 and Format=4
{
// Cannot EV train at level 100 -- Certain events are distributed at level 100.
if (evs.Find(static ev => ev > vitaMax) != default) // EVs can only be increased by vitamins to a max of 100.
data.AddLine(GetInvalid(LEffortCap100));
// EVs can only be increased by vitamins to a max of 100.
data.AddLine(GetInvalid(LEffortCap100));
}
else // check for gained EVs without gaining EXP -- don't check gen5+ which have wings to boost above 100.
else // Check for gained EVs without gaining EXP -- don't check gen5+ which have wings to boost above 100.
{
var growth = PersonalTable.HGSS[enc.Species].EXPGrowth;
var baseEXP = Experience.GetEXP(enc.LevelMin, growth);
if (baseEXP == pk.EXP && evs.Find(static ev => ev > vitaMax) != default)
if (baseEXP == pk.EXP)
data.AddLine(GetInvalid(string.Format(LEffortUntrainedCap, vitaMax)));
}
}