misc tweaks

pull out transfer locations to const references
add vc2 & crown beast/celebi met location suggesting
add vc2 crystal sensitive detection
add 2 more usum trainer stats (thanks holla!)
This commit is contained in:
Kurt 2017-11-22 21:45:30 -08:00
parent 4bbe586981
commit b8a5657d5a
16 changed files with 73 additions and 47 deletions

View file

@ -386,7 +386,7 @@ namespace PKHeX.Core
#endregion
}
public static void SetItemDataSource(bool HaX, int MaxItemID, IEnumerable<ushort> allowed, int generation, GameVersion game, GameStrings s)
public static void SetItemDataSource(int MaxItemID, IEnumerable<ushort> allowed, int generation, GameVersion game, GameStrings s, bool HaX = false)
{
string[] items = s.GetItemStrings(generation, game);
ItemDataSource = Util.GetCBList(items, (allowed == null || HaX ? Enumerable.Range(0, MaxItemID) : allowed.Select(i => (int) i)).ToArray());
@ -478,14 +478,14 @@ namespace PKHeX.Core
// Currently on a future game, return corresponding list for generation
if (Version <= GameVersion.CXD && SaveFormat == 4)
return MetGen4.Where(loc => loc.Value == 0x37) // Pal Park to front
return MetGen4.Where(loc => loc.Value == Legal.Transfer3) // Pal Park to front
.Concat(MetGen4.Take(4))
.Concat(MetGen4.Skip(4).Where(loc => loc.Value != 0x37)).ToList();
.Concat(MetGen4.Skip(4).Where(loc => loc.Value != Legal.Transfer3)).ToList();
if (Version < GameVersion.X && SaveFormat >= 5) // PokéTransfer to front
return MetGen5.Where(loc => loc.Value == 30001)
return MetGen5.Where(loc => loc.Value == Legal.Transfer4)
.Concat(MetGen5.Take(3))
.Concat(MetGen5.Skip(3).Where(loc => loc.Value != 30001)).ToList();
.Concat(MetGen5.Skip(3).Where(loc => loc.Value != Legal.Transfer4)).ToList();
return MetGen6;
}

View file

@ -732,9 +732,9 @@ namespace PKHeX.Core
private void VerifyTransferLegalityG3()
{
if (pkm.Format == 4 && pkm.Met_Location != 0x37) // Pal Park
if (pkm.Format == 4 && pkm.Met_Location != Legal.Transfer3) // Pal Park
AddLine(Severity.Invalid, V60, CheckIdentifier.Encounter);
if (pkm.Format != 4 && pkm.Met_Location != 30001)
if (pkm.Format != 4 && pkm.Met_Location != Legal.Transfer4)
AddLine(Severity.Invalid, V61, CheckIdentifier.Encounter);
}
private void VerifyTransferLegalityG4()
@ -747,13 +747,13 @@ namespace PKHeX.Core
switch (pkm.Species)
{
case 251: // Celebi
if (loc != 30010 && loc != 30011) // unused || used
if (loc != Legal.Transfer4_CelebiUnused && loc != Legal.Transfer4_CelebiUsed)
AddLine(Severity.Invalid, V351, CheckIdentifier.Encounter);
break;
case 243: // Raikou
case 244: // Entei
case 245: // Suicune
if (loc != 30012 && loc != 30013) // unused || used
if (loc != Legal.Transfer4_CrownUnused && loc != Legal.Transfer4_CrownUsed)
AddLine(Severity.Invalid, V351, CheckIdentifier.Encounter);
break;
default:

View file

@ -1507,7 +1507,7 @@ namespace PKHeX.Core
Ability = TransferSpeciesDefaultAbility_1.Contains(species) ? 1 : 4, // Hidden by default, else first
Shiny = species == 151 ? (bool?)false : null,
Fateful = species == 151,
Location = 30013,
Location = Transfer1,
EggLocation = 0,
IV3 = true,
Level = pkmMetLevel,
@ -1523,7 +1523,7 @@ namespace PKHeX.Core
Ability = TransferSpeciesDefaultAbility_2.Contains(species) ? 1 : 4, // Hidden by default, else first
Shiny = species == 151 || species == 251 ? (bool?)false : null,
Fateful = species == 151 || species == 251,
Location = 30017,
Location = Transfer2,
EggLocation = 0,
IV3 = true,
Level = pkmMetLevel,

View file

@ -83,18 +83,18 @@ namespace PKHeX.Core
case 3:
return pkm.FRLG ? 146 /* Four Island */ : 32; // Route 117
case 4:
return 0x37; // Pal Park
return Legal.Transfer3; // Pal Park
default:
return 30001; // Transporter
return Legal.Transfer4; // Transporter
}
case GameVersion.D:
case GameVersion.P:
case GameVersion.Pt:
return pkm.Format > 4 ? 30001 /* Transporter */ : 4; // Solaceon Town
return pkm.Format > 4 ? Legal.Transfer4 /* Transporter */ : 4; // Solaceon Town
case GameVersion.HG:
case GameVersion.SS:
return pkm.Format > 4 ? 30001 /* Transporter */ : 182; // Route 34
return pkm.Format > 4 ? Legal.Transfer4 /* Transporter */ : 182; // Route 34
case GameVersion.B:
case GameVersion.W:
@ -118,22 +118,27 @@ namespace PKHeX.Core
return -1;
}
/// <summary>
/// Gets the correct Met location for the origin game.
/// Gets the correct Transfer Met location for the origin game.
/// </summary>
/// <remarks>
/// Returns -1 if the met location is not overriden with a transfer location
/// </remarks>
private static int GetSuggestedTransferLocation(PKM pkm)
{
// Return one of legal hatch locations for game
if (pkm.HasOriginalMetLocation)
return -1;
if (pkm.VC1)
return 30013;
return Legal.Transfer1;
if (pkm.VC2)
return Legal.Transfer2;
if (pkm.Format == 4) // Pal Park
return 0x37;
if (pkm.Format == 5) // Transporter
return 30001;
return Legal.Transfer3;
if (pkm.Format >= 5) // Transporter
{
return pkm.Gen4 && pkm.FatefulEncounter && Legal.CrownBeasts.Contains(pkm.Species)
? (pkm.Species == 251 ? Legal.Transfer4_CelebiUnused : Legal.Transfer4_CrownUnused) // Celebi : Beast
: Legal.Transfer4; // Pokétransfer (not Crown)
}
return -1;
}
}

View file

@ -407,21 +407,23 @@ namespace PKHeX.Core
public static List<EvolutionSet> GetArray(byte[] data)
{
var evos = new List<EvolutionSet>();
for (int i = 0; i <= Legal.MaxSpeciesIndex_4_HGSSPt; i++)
const int bpe = 6; // bytes per evolution entry
const int entries = 7; // 7 * 6 = 42, + 2 alignment bytes
const int size = 44; // bytes per species entry
int count = data.Length / size;
for (int i = 0; i < count; i++)
{
/* 44 bytes per species,
* for every species 7 evolutions with 6 bytes per evolution,
* last 2 bytes of every specie is padding*/
int offset = i * 44;
int offset = i * size;
var m_list = new List<EvolutionMethod>();
for (int j = 0; j < 7; j++)
for (int j = 0; j < entries; j++)
{
EvolutionMethod m = GetMethod(data, offset);
if (m != null)
m_list.Add(m);
else
break;
offset += 6;
offset += bpe;
}
evos.Add(new EvolutionSet4 { PossibleEvolutions = m_list.ToArray() });
}

View file

@ -9,6 +9,10 @@ namespace PKHeX.Core
internal const int MaxMoveID_1 = 165;
internal const int MaxItemID_1 = 255;
internal const int MaxAbilityID_1 = 0;
/// <summary>
/// Generation 1 -> Generation 7 Transfer Location (Kanto)
/// </summary>
public const int Transfer1 = 30013;
internal static readonly ushort[] Pouch_Items_RBY =
{

View file

@ -9,7 +9,11 @@ namespace PKHeX.Core
internal const int MaxMoveID_2 = 251;
internal const int MaxItemID_2 = 255;
internal const int MaxAbilityID_2 = 0;
/// <summary>
/// Generation 2 -> Generation 7 Transfer Location (Johto)
/// </summary>
public const int Transfer2 = 30017;
internal static readonly ushort[] Pouch_Items_GSC = {
3, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 57, 60, 62, 63, 64, 65, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 117, 118, 119, 121, 122, 123, 124, 125, 126, 131, 132, 138, 139, 140, 143, 144, 146, 150, 151, 152, 156, 158, 163, 167, 168, 169, 170, 172, 173, 174, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189
};

View file

@ -11,6 +11,10 @@ namespace PKHeX.Core
internal const int MaxItemID_3 = 374;
internal const int MaxAbilityID_3 = 77;
internal const int MaxBallID_3 = 0xC;
/// <summary>
/// Generation 3 -> Generation 4 Transfer Location (Pal Park)
/// </summary>
public const int Transfer3 = 0x37;
public static readonly HashSet<int> SplitBreed_3 = new HashSet<int>
{

View file

@ -5,8 +5,6 @@ namespace PKHeX.Core
{
public static partial class Legal
{
internal const int MaxSpeciesIndex_4_DP = 500;
internal const int MaxSpeciesIndex_4_HGSSPt = 507;
internal const int MaxSpeciesID_4 = 493;
internal const int MaxMoveID_4 = 467;
internal const int MaxItemID_4_DP = 464;
@ -14,6 +12,16 @@ namespace PKHeX.Core
internal const int MaxItemID_4_HGSS = 536;
internal const int MaxAbilityID_4 = 123;
internal const int MaxBallID_4 = 0x18;
/// <summary> Generation 4 -> Generation 5 Transfer Location (Poké Transporter) </summary>
public const int Transfer4 = 30001;
/// <summary> Generation 4 -> Generation 5 Transfer Location (Crown Celebi - Event not activated in Gen 5) </summary>
public const int Transfer4_CelebiUnused = 30010;
/// <summary> Generation 4 -> Generation 5 Transfer Location (Crown Celebi - Event activated in Gen 5) </summary>
public const int Transfer4_CelebiUsed = 30011;
/// <summary> Generation 4 -> Generation 5 Transfer Location (Crown Beast - Event not activated in Gen 5) </summary>
public const int Transfer4_CrownUnused = 30012;
/// <summary> Generation 4 -> Generation 5 Transfer Location (Crown Beast - Event activated in Gen 5) </summary>
public const int Transfer4_CrownUsed = 30013;
internal static readonly int[] Met_HGSS_0 =
{
@ -178,7 +186,7 @@ namespace PKHeX.Core
500, // Park Ball
};
internal static readonly bool[] ReleasedHeldItems_4 = Enumerable.Range(0, MaxItemID_4_HGSS+1).Select(i => HeldItems_HGSS.Contains((ushort)i) && !UnreleasedItems_4.Contains(i)).ToArray();
internal static readonly HashSet<int> CrownBeasts = new HashSet<int> { 251, 243, 244, 245};
internal static readonly HashSet<int> CrownBeasts = new HashSet<int> { 251, 243, 244, 245 };
internal static readonly int[] Tutors_4 =
{

View file

@ -381,7 +381,7 @@ namespace PKHeX.Core
PID = Util.Rand32(),
Ball = 4,
MetDate = DateTime.Now,
Version = (int)GameVersion.RD, // Default to red, for now?
Version = (int)GameVersion.RD, // Default to red
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
@ -394,7 +394,7 @@ namespace PKHeX.Core
Move2_PP = Move2_PP,
Move3_PP = Move3_PP,
Move4_PP = Move4_PP,
Met_Location = 30013, // "Kanto region", hardcoded.
Met_Location = Legal.Transfer1, // "Kanto region", hardcoded.
Gender = Gender,
OT_Name = StringConverter.GetG1ConvertedString(otname, Japanese),
IsNicknamed = false,
@ -425,7 +425,6 @@ namespace PKHeX.Core
Util.Shuffle(new_ivs);
pk7.IVs = new_ivs;
// Really? :(
if (IsShiny)
pk7.SetShinyPID();

View file

@ -64,8 +64,6 @@ namespace PKHeX.Core
int strLen = jp ? STRLEN_J : STRLEN_U;
otname = Enumerable.Repeat((byte) 0x50, strLen).ToArray();
nick = Enumerable.Repeat((byte) 0x50, strLen).ToArray();
IsEgg = false; // Egg data stored in Pokemon List.
}
public override PKM Clone()
@ -413,7 +411,7 @@ namespace PKHeX.Core
PID = Util.Rand32(),
Ball = 4,
MetDate = DateTime.Now,
Version = (int)GameVersion.SV,
Version = Met_Location != 0 ? (int)GameVersion.C : (int)GameVersion.SV,
Move1 = Move1,
Move2 = Move2,
Move3 = Move3,
@ -458,7 +456,6 @@ namespace PKHeX.Core
Util.Shuffle(new_ivs);
pk7.IVs = new_ivs;
// Really? :(
if (IsShiny)
pk7.SetShinyPID();
@ -477,6 +474,7 @@ namespace PKHeX.Core
}
pk7.OT_Name = Korean ? OT_Name
: StringConverter.GetG1ConvertedString(otname, Japanese);
pk7.OT_Gender = OT_Gender; // Crystal
pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm

View file

@ -226,7 +226,7 @@ namespace PKHeX.Core
PKRS_Days = PKRS_Days,
OT_Gender = OT_Gender,
MetDate = moment,
Met_Location = 0x37, // Pal Park
Met_Location = Legal.Transfer3, // Pal Park
RibbonChampionG3Hoenn = RibbonChampionG3Hoenn,
RibbonWinning = RibbonWinning,

View file

@ -431,8 +431,8 @@ namespace PKHeX.Core
// Met / Crown Data Detection
pk5.Met_Location = pk5.Gen4 && pk5.FatefulEncounter && Legal.CrownBeasts.Contains(pk5.Species)
? (pk5.Species == 251 ? 30010 : 30012) // Celebi : Beast
: 30001; // Pokétransfer (not Crown)
? (pk5.Species == 251 ? Legal.Transfer4_CelebiUnused : Legal.Transfer4_CrownUnused) // Celebi : Beast
: Legal.Transfer4; // Pokétransfer (not Crown)
pk5.Egg_Location = Egg_Location;
// Delete HGSS Data

View file

@ -273,7 +273,7 @@ namespace PKHeX.Core
newlist.Add(new ComboItem { Text = inStrings[i], Value = i });
newlist.AddRange(stringNum
.Select((z, i) => new ComboItem{ Text = inStrings[z], Value = stringVal[i]})
.Select((z, i) => new ComboItem { Text = inStrings[z], Value = stringVal[i] })
.OrderBy(z => z.Text));
return newlist;
}

View file

@ -780,9 +780,9 @@ namespace PKHeX.WinForms.Controls
minlvl = level;
if (pkm.VC1)
location = 30013;
location = Legal.Transfer1;
else if (pkm.VC2)
location = 30017;
location = Legal.Transfer2;
if (!silent)
{
@ -1272,8 +1272,8 @@ namespace PKHeX.WinForms.Controls
switch (newTrack)
{
case GameVersion.GO: metLoc = 30012; break;
case GameVersion.RBY: metLoc = 30013; break;
case GameVersion.GSC: metLoc = 30017; break;
case GameVersion.RBY: metLoc = Legal.Transfer1; break;
case GameVersion.GSC: metLoc = Legal.Transfer2; break;
}
if (metLoc != 0)
CB_MetLocation.SelectedValue = metLoc;

View file

@ -748,6 +748,7 @@ namespace PKHeX.WinForms
// USUM
{070, "Roto Lotos"},
{073, "Mantine Surf BP Earned"},
{074, "Battle Agency Wins"},
{100, "Champion Title Defense"},
{104, "Moves used with No Effect"},
@ -828,6 +829,7 @@ namespace PKHeX.WinForms
// USUM
{189, "Mantine Surf Plays"},
{190, "Photo Club Photos saved"},
{191, "Battle Agency Battles"},
{195, "Photo Club Sticker usage"},
{196, "Photo Club Photo Shoots"},
{197, "Highest Wormhole Travel Distance"},