mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Misc tweaks
Ensure GO IVs are respecting the min floor Add some comments, reuse PersonalInfo reference instead of refetch Fix Hoopa Unbound SlotWrite changing to 3
This commit is contained in:
parent
2777a3e039
commit
86459812c1
11 changed files with 48 additions and 31 deletions
|
@ -188,19 +188,26 @@ public sealed record EncounterCriteria
|
|||
pk.IV_SPE = IV_SPE != RandomIV ? IV_SPE : Util.Rand.Next(32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies random IVs with a minimum and maximum (bitshifted >> 1)
|
||||
/// </summary>
|
||||
/// <param name="pk">Entity to mutate.</param>
|
||||
/// <param name="minIV">Minimum IV from GO</param>
|
||||
/// <param name="maxIV">Maximum IV from GO</param>
|
||||
public void SetRandomIVsGO(PKM pk, int minIV = 0, int maxIV = 15)
|
||||
{
|
||||
var bareMin = (minIV << 1) | 1;
|
||||
var rnd = Util.Rand;
|
||||
pk.IV_HP =
|
||||
IV_HP != RandomIV ? IV_HP | 1
|
||||
IV_HP != RandomIV && IV_HP >= bareMin ? IV_HP | 1
|
||||
: (rnd.Next(minIV, maxIV + 1) << 1) | 1; // hp
|
||||
pk.IV_ATK = pk.IV_SPA =
|
||||
IV_ATK != RandomIV ? IV_ATK | 1
|
||||
: IV_SPA != RandomIV ? IV_SPA | 1
|
||||
IV_ATK != RandomIV && IV_ATK >= bareMin ? IV_ATK | 1
|
||||
: IV_SPA != RandomIV && IV_SPA >= bareMin ? IV_SPA | 1
|
||||
: (rnd.Next(minIV, maxIV + 1) << 1) | 1; // attack
|
||||
pk.IV_DEF = pk.IV_SPD =
|
||||
IV_DEF != RandomIV ? IV_DEF | 1
|
||||
: IV_SPD != RandomIV ? IV_SPD | 1
|
||||
IV_DEF != RandomIV && IV_DEF >= bareMin ? IV_DEF | 1
|
||||
: IV_SPD != RandomIV && IV_SPD >= bareMin ? IV_SPD | 1
|
||||
: (rnd.Next(minIV, maxIV + 1) << 1) | 1; // defense
|
||||
pk.IV_SPE =
|
||||
IV_SPE != RandomIV ? IV_SPE
|
||||
|
|
|
@ -56,7 +56,7 @@ public sealed record EncounterStatic2(ushort Species, byte Level, GameVersion Ve
|
|||
|
||||
if (EggEncounter)
|
||||
{
|
||||
if (DizzyPunchEgg)
|
||||
if (DizzyPunchEgg) // Fixed EXP value instead of exactly Level 5
|
||||
pk.EXP = 125;
|
||||
}
|
||||
else if (Version == GameVersion.C || (Version == GameVersion.GSC && tr.Game == (int)GameVersion.C))
|
||||
|
@ -94,7 +94,7 @@ public sealed record EncounterStatic2(ushort Species, byte Level, GameVersion Ve
|
|||
if (EggEncounter && Moves.HasMoves) // Odd Egg
|
||||
{
|
||||
if (pk.Format > 2)
|
||||
return false;
|
||||
return false; // Can't be transferred to Gen7+
|
||||
if (!pk.HasMove((int)Move.DizzyPunch))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ public sealed record EncounterTrade6 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
{
|
||||
var version = this.GetCompatibleVersion((GameVersion)tr.Game);
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, version);
|
||||
var pi = PersonalTable.AO[Species, 0];
|
||||
var pk = new PK6
|
||||
{
|
||||
PID = Util.Rand32(),
|
||||
|
@ -88,7 +89,7 @@ public sealed record EncounterTrade6 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
OT_Intensity = OT_Intensity,
|
||||
OT_Feeling = OT_Feeling,
|
||||
OT_TextVar = OT_TextVar,
|
||||
OT_Friendship = PersonalTable.AO[Species, 0].BaseFriendship,
|
||||
OT_Friendship = pi.BaseFriendship,
|
||||
|
||||
IsNicknamed = IsFixedNickname,
|
||||
Nickname = IsFixedNickname ? Nicknames[lang] : SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation),
|
||||
|
@ -96,7 +97,7 @@ public sealed record EncounterTrade6 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
HT_Name = tr.OT,
|
||||
HT_Gender = tr.Gender,
|
||||
CurrentHandler = 1,
|
||||
HT_Friendship = PersonalTable.AO[Species, 0].BaseFriendship,
|
||||
HT_Friendship = pi.BaseFriendship,
|
||||
};
|
||||
if (tr is IRegionOrigin r)
|
||||
r.CopyRegionOrigin(pk);
|
||||
|
|
|
@ -63,6 +63,7 @@ public sealed record EncounterTrade7 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
{
|
||||
var version = this.GetCompatibleVersion((GameVersion)tr.Game);
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, version);
|
||||
var pi = PersonalTable.USUM[Species, Form];
|
||||
var pk = new PK7
|
||||
{
|
||||
PID = Util.Rand32(),
|
||||
|
@ -87,7 +88,7 @@ public sealed record EncounterTrade7 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
OT_Intensity = OT_Intensity,
|
||||
OT_Feeling = OT_Feeling,
|
||||
OT_TextVar = OT_TextVar,
|
||||
OT_Friendship = PersonalTable.USUM[Species, Form].BaseFriendship,
|
||||
OT_Friendship = pi.BaseFriendship,
|
||||
|
||||
IsNicknamed = true,
|
||||
Nickname = Nicknames[lang],
|
||||
|
@ -95,7 +96,7 @@ public sealed record EncounterTrade7 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
HT_Name = tr.OT,
|
||||
HT_Gender = tr.Gender,
|
||||
CurrentHandler = 1,
|
||||
HT_Friendship = PersonalTable.USUM[Species, Form].BaseFriendship,
|
||||
HT_Friendship = pi.BaseFriendship,
|
||||
};
|
||||
if (tr is IRegionOrigin r)
|
||||
r.CopyRegionOrigin(pk);
|
||||
|
|
|
@ -45,6 +45,7 @@ public sealed record EncounterTrade7b(GameVersion Version) : IEncounterable, IEn
|
|||
{
|
||||
var version = this.GetCompatibleVersion((GameVersion)tr.Game);
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, version);
|
||||
var pi = PersonalTable.GG[Species, Form];
|
||||
var pk = new PB7
|
||||
{
|
||||
Species = Species,
|
||||
|
@ -61,7 +62,7 @@ public sealed record EncounterTrade7b(GameVersion Version) : IEncounterable, IEn
|
|||
OT_Gender = OTGender,
|
||||
OT_Name = TrainerNames[lang],
|
||||
|
||||
OT_Friendship = PersonalTable.GG[Species, Form].BaseFriendship,
|
||||
OT_Friendship = pi.BaseFriendship,
|
||||
|
||||
HeightScalar = PokeSizeUtil.GetRandomScalar(),
|
||||
WeightScalar = PokeSizeUtil.GetRandomScalar(),
|
||||
|
@ -71,7 +72,7 @@ public sealed record EncounterTrade7b(GameVersion Version) : IEncounterable, IEn
|
|||
HT_Name = tr.OT,
|
||||
HT_Gender = tr.Gender,
|
||||
CurrentHandler = 1,
|
||||
HT_Friendship = PersonalTable.GG[Species, Form].BaseFriendship,
|
||||
HT_Friendship = pi.BaseFriendship,
|
||||
};
|
||||
|
||||
EncounterUtil1.SetEncounterMoves(pk, version, Level);
|
||||
|
|
|
@ -95,6 +95,7 @@ public sealed record EncounterTrade8 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
{
|
||||
var version = this.GetCompatibleVersion((GameVersion)tr.Game);
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, version);
|
||||
var pi = PersonalTable.SWSH[Species, Form];
|
||||
var pk = new PK8
|
||||
{
|
||||
PID = Util.Rand32(),
|
||||
|
@ -117,7 +118,7 @@ public sealed record EncounterTrade8 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
OT_Intensity = OT_Intensity,
|
||||
OT_Feeling = OT_Feeling,
|
||||
OT_TextVar = OT_TextVar,
|
||||
OT_Friendship = PersonalTable.SWSH[Species, Form].BaseFriendship,
|
||||
OT_Friendship = pi.BaseFriendship,
|
||||
|
||||
IsNicknamed = IsFixedNickname,
|
||||
Nickname = IsFixedNickname ? Nicknames[lang] : SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation),
|
||||
|
@ -126,7 +127,7 @@ public sealed record EncounterTrade8 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
HT_Gender = tr.Gender,
|
||||
HT_Language = (byte)tr.Language,
|
||||
CurrentHandler = 1,
|
||||
HT_Friendship = PersonalTable.SWSH[Species, Form].BaseFriendship,
|
||||
HT_Friendship = pi.BaseFriendship,
|
||||
};
|
||||
if (Shiny == Shiny.Never && pk.IsShiny)
|
||||
pk.PID ^= 0x1000_0000u;
|
||||
|
|
|
@ -13,12 +13,15 @@ public interface IMasteryInitialMoveShop8
|
|||
void SetInitialMastery(PKM pk)
|
||||
{
|
||||
if (pk is PA8 pa8)
|
||||
SetInitialMastery(pa8);
|
||||
}
|
||||
|
||||
void SetInitialMastery(PA8 pk)
|
||||
{
|
||||
Span<ushort> moves = stackalloc ushort[4];
|
||||
var level = pa8.Met_Level;
|
||||
var level = pk.Met_Level;
|
||||
var (learn, mastery) = LearnSource8LA.GetLearnsetAndMastery(pk.Species, pk.Form);
|
||||
LoadInitialMoveset(pa8, moves, learn, level);
|
||||
pa8.SetEncounterMasteryFlags(moves, mastery, level);
|
||||
}
|
||||
LoadInitialMoveset(pk, moves, learn, level);
|
||||
pk.SetEncounterMasteryFlags(moves, mastery, level);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ public sealed record EncounterTrade8b : IEncounterable, IEncounterMatch, IFixedT
|
|||
{
|
||||
var version = this.GetCompatibleVersion((GameVersion)tr.Game);
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, version);
|
||||
var pi = PersonalTable.BDSP[Species, Form];
|
||||
var pk = new PB8
|
||||
{
|
||||
PID = PID,
|
||||
|
@ -100,7 +101,7 @@ public sealed record EncounterTrade8b : IEncounterable, IEncounterMatch, IFixedT
|
|||
WeightScalar = WeightScalar,
|
||||
HT_Name = tr.OT,
|
||||
HT_Language = (byte)tr.Language,
|
||||
HT_Friendship = PersonalTable.BDSP[Species, Form].BaseFriendship,
|
||||
HT_Friendship = pi.BaseFriendship,
|
||||
};
|
||||
|
||||
// Has German Language ID for all except German origin, which is Japanese
|
||||
|
|
|
@ -63,6 +63,7 @@ public sealed record EncounterTrade9
|
|||
{
|
||||
var version = this.GetCompatibleVersion((GameVersion)tr.Game);
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, version);
|
||||
var pi = PersonalTable.SV[Species, Form];
|
||||
var pk = new PK9
|
||||
{
|
||||
Species = Species,
|
||||
|
@ -82,7 +83,7 @@ public sealed record EncounterTrade9
|
|||
OT_Gender = OTGender,
|
||||
OT_Name = TrainerNames[lang],
|
||||
|
||||
OT_Friendship = PersonalTable.SV[Species, Form].BaseFriendship,
|
||||
OT_Friendship = pi.BaseFriendship,
|
||||
|
||||
IsNicknamed = true,
|
||||
Nickname = Nicknames[lang],
|
||||
|
@ -95,24 +96,24 @@ public sealed record EncounterTrade9
|
|||
HT_Name = tr.OT,
|
||||
HT_Language = (byte)tr.Language,
|
||||
CurrentHandler = 1,
|
||||
HT_Friendship = PersonalTable.SV[Species, Form].BaseFriendship,
|
||||
HT_Friendship = pi.BaseFriendship,
|
||||
Obedience_Level = Level,
|
||||
};
|
||||
|
||||
EncounterUtil1.SetEncounterMoves(pk, version, Level);
|
||||
SetPINGA(pk, criteria);
|
||||
SetPINGA(pk, criteria, pi);
|
||||
|
||||
pk.ResetPartyStats();
|
||||
|
||||
return pk;
|
||||
}
|
||||
|
||||
private void SetPINGA(PK9 pk, EncounterCriteria criteria)
|
||||
private void SetPINGA(PK9 pk, EncounterCriteria criteria, PersonalInfo9SV pi)
|
||||
{
|
||||
pk.PID = Util.Rand32();
|
||||
pk.EncryptionConstant = Util.Rand32();
|
||||
pk.Nature = pk.StatNature = (int)criteria.GetNature(Nature.Random);
|
||||
pk.Gender = criteria.GetGender(-1, PersonalTable.SV.GetFormEntry(Species, Form));
|
||||
pk.Gender = criteria.GetGender(-1, pi);
|
||||
pk.RefreshAbility(criteria.GetAbilityFromNumber(Ability));
|
||||
criteria.SetRandomIVs(pk, IVs);
|
||||
}
|
||||
|
|
|
@ -55,11 +55,12 @@ public static class EvolutionChain
|
|||
EvolutionUtil.ConditionBaseChainForward(chain, encSpecies);
|
||||
if (context == EntityContext.Gen2)
|
||||
{
|
||||
// Handle the evolution case for Gen2->Gen1
|
||||
EvolutionGroup2.Instance.Evolve(chain, pk, enc, history);
|
||||
EvolutionGroup1.Instance.Evolve(chain, pk, enc, history);
|
||||
if (pk.Format > 2)
|
||||
if (pk.Format > 2) // Skip forward to Gen7
|
||||
context = EntityContext.Gen7;
|
||||
else
|
||||
else // no more possible contexts; done.
|
||||
return history;
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ public sealed class SAV9SV : SaveFile, ISaveBlock9Main, ISCBlockArray, ISaveFile
|
|||
return pk.Species switch
|
||||
{
|
||||
(int)Species.Furfrou => 5u, // Furfrou
|
||||
(int)Species.Hoopa => 3u, // Hoopa
|
||||
// Hoopa no longer sets Form Argument for Unbound form. Let it set 0.
|
||||
_ => 0u,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue