mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-07 23:08:47 -05:00
Merge pull request #1013 from javierhimura/master
Safari ball and sport ball checking
This commit is contained in:
@@ -499,7 +499,7 @@ private CheckResult verifyEncounterEvent()
|
||||
private CheckResult verifyEncounterEgg()
|
||||
{
|
||||
// Check Species
|
||||
if (Legal.NoHatchFromEgg.Contains(pkm.Species) && (pkm.GenNumber != 4 || pkm.Species == 490))
|
||||
if ((Legal.NoHatchFromEgg.Contains(pkm.Species) && pkm.Species != 490) || (pkm.GenNumber != 4 && pkm.Species == 490))
|
||||
return new CheckResult(Severity.Invalid, V50, CheckIdentifier.Encounter);
|
||||
|
||||
switch (pkm.GenNumber)
|
||||
@@ -791,6 +791,7 @@ private CheckResult verifyEncounterG3Transfer()
|
||||
CheckResult InvalidTransferResult = null;
|
||||
CheckResult EggResult = null;
|
||||
CheckResult G3Result = null;
|
||||
object G3Encounter = null;
|
||||
bool WasEgg = Legal.getWasEgg23(pkm) && !Legal.NoHatchFromEgg.Contains(pkm.Species);
|
||||
if (WasEgg)
|
||||
{
|
||||
@@ -804,20 +805,30 @@ private CheckResult verifyEncounterG3Transfer()
|
||||
InvalidTransferResult = new CheckResult(Severity.Invalid, V60, CheckIdentifier.Encounter);
|
||||
if (pkm.Format != 4 && pkm.Met_Location != 30001)
|
||||
InvalidTransferResult = new CheckResult(Severity.Invalid, V61, CheckIdentifier.Encounter);
|
||||
|
||||
|
||||
if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm)))
|
||||
{
|
||||
G3Result = verifyEncounterStatic();
|
||||
if (G3Result?.Valid ?? false)
|
||||
G3Encounter = EncounterMatch;
|
||||
}
|
||||
|
||||
if (G3Result !=null)
|
||||
if (G3Result != null)
|
||||
{
|
||||
EncounterMatch = null; // Reset Encounter Object, test for remaining encounters
|
||||
if (null != (EncounterMatch = Legal.getValidWildEncounters(pkm)))
|
||||
{
|
||||
G3Result = verifyEncounterWild();
|
||||
if (G3Result?.Valid ?? false)
|
||||
G3Encounter = EncounterMatch;
|
||||
}
|
||||
|
||||
if (null != (EncounterMatch = Legal.getValidIngameTrade(pkm)))
|
||||
{
|
||||
G3Result = verifyEncounterTrade();
|
||||
if (G3Result?.Valid ?? false)
|
||||
G3Encounter = EncounterMatch;
|
||||
}
|
||||
}
|
||||
|
||||
// Check events after static, to match Mew/Deoxys static encounters
|
||||
@@ -838,19 +849,25 @@ private CheckResult verifyEncounterG3Transfer()
|
||||
// Even if EggResult is not returned WasEgg is keep true to check in verifymoves first the
|
||||
// non egg encounter moves and after that egg encounter moves, because there is no way to tell
|
||||
// what of the two encounters was the real origin
|
||||
if (EggResult != null && G3Result!=null)
|
||||
if (EggResult != null && G3Result != null)
|
||||
{
|
||||
// keep the valid encounter, also if both are valid returns non egg information, because
|
||||
// there is more data in the pokemon to found normal encounter
|
||||
if (EggResult.Valid && !G3Result.Valid)
|
||||
{
|
||||
G3Result = EggResult;
|
||||
G3Encounter = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (G3Result?.Valid ?? false)
|
||||
EncounterMatch = G3Encounter;
|
||||
|
||||
// No gen 3 result
|
||||
if (G3Result == null)
|
||||
{
|
||||
// Return both errors, invalid transfer and not a valid encounter found in G3
|
||||
return InvalidTransferResult != null?
|
||||
return InvalidTransferResult != null ?
|
||||
new CheckResult(Severity.Invalid, V80 + Environment.NewLine + InvalidTransferResult.Comment, CheckIdentifier.Encounter)
|
||||
: new CheckResult(Severity.Invalid, V80, CheckIdentifier.Encounter);
|
||||
}
|
||||
@@ -1315,7 +1332,11 @@ private void verifyBall()
|
||||
|
||||
if (EncounterIsMysteryGift)
|
||||
{
|
||||
verifyBallEquals(((MysteryGift)EncounterMatch).Ball);
|
||||
if (pkm.Species == 490 && pkm.Gen4 && ((MysteryGift)EncounterMatch).Ball == 0)
|
||||
// there is no ball data in Manaphy Mystery Gift
|
||||
verifyBallEquals(4); // Pokeball
|
||||
else
|
||||
verifyBallEquals(((MysteryGift)EncounterMatch).Ball);
|
||||
return;
|
||||
}
|
||||
if (EncounterType == typeof (EncounterLink))
|
||||
@@ -1352,8 +1373,17 @@ private void verifyBall()
|
||||
}
|
||||
if (EncounterType == typeof (EncounterSlot[]))
|
||||
{
|
||||
EncounterSlot[] enc = EncounterMatch as EncounterSlot[];
|
||||
|
||||
if (pkm.Met_Location == 30016 && pkm.Gen7) // Poké Pelago
|
||||
verifyBallEquals(4); // Pokeball
|
||||
// For gen3/4 safari zones and BCC getValidWildEncounters already filter to not return
|
||||
// mixed possible encounters between safari, BCC and other encounters
|
||||
// That means is the first encounter is not safari then there is no safari encounter in the array
|
||||
else if (3 <= pkm.GenNumber && pkm.GenNumber <= 4 && Legal.IsSafariSlot(enc.First().Type))
|
||||
verifyBallEquals(5); // Safariball
|
||||
else if (pkm.GenNumber == 4 && pkm.HGSS && enc.First().Type == SlotType.BugContest)
|
||||
verifyBallEquals(0x18); // Sportball
|
||||
else
|
||||
verifyBallEquals(Legal.getWildBalls(pkm));
|
||||
return;
|
||||
@@ -2176,6 +2206,7 @@ private void verifyMisc()
|
||||
}
|
||||
if (pkm.FatefulEncounter)
|
||||
AddLine(Severity.Invalid, V325, CheckIdentifier.Fateful);
|
||||
|
||||
if (pkm.Format == 5)
|
||||
{
|
||||
var enc = EncounterMatch as EncounterStatic;
|
||||
|
||||
@@ -1215,7 +1215,7 @@ private static IEnumerable<MysteryGift> getMatchingPCD(PKM pkm, IEnumerable<Myst
|
||||
if (pkm.Species == 490 && (pkm.WasEgg || pkm.IsEgg)) // Manaphy
|
||||
{
|
||||
int loc = pkm.IsEgg ? pkm.Met_Location : pkm.Egg_Location;
|
||||
bool valid = loc == 2001; // Link Trade Egg
|
||||
bool valid = loc == 2002; // Link Trade Egg
|
||||
valid |= loc == 3001 && !pkm.IsShiny; // Ranger & notShiny
|
||||
if (valid)
|
||||
validPCD.Add(new PGT { Data = { [0] = 7, [8] = 1 } });
|
||||
@@ -1749,7 +1749,7 @@ internal static int getMaxLevelGeneration(PKM pkm)
|
||||
internal static int getMaxLevelGeneration(PKM pkm, int generation)
|
||||
{
|
||||
if (!pkm.InhabitedGeneration(generation))
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
if (pkm.Format <= 2)
|
||||
{
|
||||
@@ -1772,7 +1772,11 @@ internal static int getMaxLevelGeneration(PKM pkm, int generation)
|
||||
internal static int getMinLevelEncounter(PKM pkm)
|
||||
{
|
||||
if (pkm.Format == 3 && pkm.WasEgg)
|
||||
// Only for gen 3 pokemon in format 3, after transfer to gen 4 it should return transfer level
|
||||
return 5;
|
||||
if (pkm.Format == 4 && pkm.GenNumber == 4 && pkm.WasEgg)
|
||||
// Only for gen 4 pokemon in format 4, after transfer to gen 5 it should return transfer level
|
||||
return 1;
|
||||
return pkm.HasOriginalMetLocation ? pkm.Met_Level : getMaxLevelGeneration(pkm);
|
||||
}
|
||||
internal static int getMinLevelGeneration(PKM pkm)
|
||||
@@ -2286,6 +2290,9 @@ private static IEnumerable<int> getValidMoves(PKM pkm, GameVersion Version, DexL
|
||||
if (FormChangeMoves.Contains(species)) // Deoxys & Shaymin & Giratina (others don't have extra but whatever)
|
||||
{
|
||||
int formcount = pkm.PersonalInfo.FormeCount;
|
||||
if (species == 386 && pkm.Format == 3)
|
||||
// In gen 3 deoxys has different forms depending on the current game, in personal info there is no alter form info
|
||||
formcount = 4;
|
||||
for (int i = 0; i < formcount; i++)
|
||||
r.AddRange(getMoves(pkm, species, vs.First().Level, i, moveTutor, Version, LVL, Tutor, Machine, MoveReminder, RemoveTransferHM, Generation));
|
||||
if (Relearn) r.AddRange(pkm.RelearnMoves);
|
||||
|
||||
@@ -408,7 +408,7 @@ private static IEnumerable<EncounterSlot> getSlots4_G_TimeReplace(byte[] data, r
|
||||
continue;
|
||||
|
||||
var slot = GrassSlots[slotnums[j]].Clone();
|
||||
slot.Species = j;
|
||||
slot.Species = species;
|
||||
slot.Type = t;
|
||||
slots.Add(slot);
|
||||
}
|
||||
|
||||
@@ -438,7 +438,6 @@ public static partial class Legal
|
||||
new EncounterStatic { Species = 487, Level = 47, Location = 117, Version = GameVersion.Pt, Form = 1, }, //Giratina @ Distortion World
|
||||
new EncounterStatic { Species = 487, Level = 47, Location = 062, Version = GameVersion.Pt, Form = 0, }, //Giratina @ Turnback Cave
|
||||
//Event
|
||||
new EncounterStatic { Species = 490, Level = 01, EggLocation = 3001, Fateful = true, Gift = true }, //Manaphy from Pokemon Ranger
|
||||
new EncounterStatic { Species = 491, Level = 40, Location = 079, Version = GameVersion.DP,}, //Darkrai @ Newmoon Island
|
||||
new EncounterStatic { Species = 491, Level = 50, Location = 079, Version = GameVersion.Pt,}, //Darkrai @ Newmoon Island
|
||||
new EncounterStatic { Species = 492, Form = 0, Level = 30, Location = 063, Fateful = true,}, //Shaymin @ Flower Paradise (Unreleased in Diamond and Pearl)
|
||||
@@ -507,7 +506,7 @@ public static partial class Legal
|
||||
new EncounterStatic { Gift = true, Species = 023, Level = 15, Location = 131, Version = GameVersion.HG }, // Ekans
|
||||
new EncounterStatic { Gift = true, Species = 027, Level = 15, Location = 131, Version = GameVersion.SS }, // Sandshrew
|
||||
new EncounterStatic { Gift = true, Species = 147, Level = 15, Location = 131 }, // Dratini
|
||||
//Team_Rocket_HQ Trap Floor
|
||||
// Team Rocket HQ Trap Floor
|
||||
// new EncounterStatic { Species = 101, Level = 23, Location = 213, }, // Electrode Overlaps stationary
|
||||
new EncounterStatic { Species = 100, Level = 23, Location = 213, }, // Voltorb
|
||||
new EncounterStatic { Species = 074, Level = 23, Location = 213, }, // Geodude
|
||||
|
||||
Reference in New Issue
Block a user