mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-22 20:13:06 +00:00
Misc enc template -> pkm fixes
This commit is contained in:
parent
3afcfcdfa3
commit
534dc02154
7 changed files with 31 additions and 9 deletions
|
@ -32,6 +32,7 @@ public record EncounterSlot3(EncounterArea3 Parent, ushort Species, byte Form, b
|
|||
public PK3 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
|
||||
{
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language);
|
||||
var version = Version != GameVersion.RSE ? Version : GameVersion.RSE.Contains(tr.Game) ? (GameVersion)tr.Game : GameVersion.E;
|
||||
var pk = new PK3
|
||||
{
|
||||
Species = Species,
|
||||
|
@ -40,7 +41,7 @@ public record EncounterSlot3(EncounterArea3 Parent, ushort Species, byte Form, b
|
|||
|
||||
Met_Location = Location,
|
||||
Met_Level = LevelMin,
|
||||
Version = (byte)Version,
|
||||
Version = (byte)version,
|
||||
Ball = (byte)GetRequiredBall(Ball.Poke),
|
||||
|
||||
Language = lang,
|
||||
|
|
|
@ -108,7 +108,7 @@ public sealed record EncounterSlot6AO(EncounterArea6AO Parent, ushort Species, b
|
|||
pk.Nature = (int)criteria.GetNature(Nature.Random);
|
||||
pk.Gender = criteria.GetGender(-1, PersonalTable.AO.GetFormEntry(Species, Form));
|
||||
pk.RefreshAbility(criteria.GetAbilityFromNumber(Ability));
|
||||
pk.SetRandomIVs();
|
||||
criteria.SetRandomIVs(pk);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -97,11 +97,19 @@ public sealed record EncounterSlot8(EncounterArea8 Parent, ushort Species, byte
|
|||
var req = GetRequirement(pk);
|
||||
if (req != MustHave)
|
||||
{
|
||||
pk.EncryptionConstant = Util.Rand32();
|
||||
var pi = PersonalTable.SWSH[Species, Form];
|
||||
var rand = Util.Rand;
|
||||
pk.EncryptionConstant = rand.Rand32();
|
||||
pk.PID = rand.Rand32();
|
||||
criteria.SetRandomIVs(pk);
|
||||
pk.Gender = criteria.GetGender(-1, pi);
|
||||
pk.Nature = pk.StatNature = (int)criteria.GetNature(Nature.Random);
|
||||
pk.RefreshAbility(criteria.GetAbilityFromNumber(Ability));
|
||||
return;
|
||||
}
|
||||
// Don't bother honoring shiny state.
|
||||
Overworld8RNG.ApplyDetails(pk, c, Shiny.Random);
|
||||
pk.RefreshAbility(criteria.GetAbilityFromNumber(Ability));
|
||||
}
|
||||
|
||||
public OverworldCorrelation8Requirement GetRequirement(PKM pk)
|
||||
|
|
|
@ -115,11 +115,19 @@ public sealed record EncounterStatic8(GameVersion Version = GameVersion.SWSH)
|
|||
var req = GetRequirement(pk);
|
||||
if (req != MustHave)
|
||||
{
|
||||
pk.EncryptionConstant = Util.Rand32();
|
||||
var pi = PersonalTable.SWSH[Species, Form];
|
||||
var rand = Util.Rand;
|
||||
pk.EncryptionConstant = rand.Rand32();
|
||||
pk.PID = rand.Rand32();
|
||||
criteria.SetRandomIVs(pk);
|
||||
pk.Gender = criteria.GetGender(-1, pi);
|
||||
pk.Nature = pk.StatNature = (int)criteria.GetNature(Nature.Random);
|
||||
pk.RefreshAbility(criteria.GetAbilityFromNumber(Ability));
|
||||
return;
|
||||
}
|
||||
var shiny = Shiny == Shiny.Random ? Shiny.FixedValue : Shiny;
|
||||
Overworld8RNG.ApplyDetails(pk, criteria, shiny, FlawlessIVCount);
|
||||
pk.RefreshAbility(criteria.GetAbilityFromNumber(Ability));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -42,13 +42,17 @@ public sealed record EncounterSlot8a(EncounterArea8a Parent, ushort Species, byt
|
|||
Species = Species,
|
||||
Form = Form,
|
||||
CurrentLevel = LevelMin,
|
||||
OT_Friendship = PersonalTable.LA[Species, Form].BaseFriendship,
|
||||
Met_Location = Location,
|
||||
Met_Level = LevelMin,
|
||||
Version = (int)Version,
|
||||
Version = (byte)GameVersion.PLA,
|
||||
IsAlpha = IsAlpha,
|
||||
Ball = (int)Ball.LAPoke,
|
||||
|
||||
OT_Name = tr.OT,
|
||||
OT_Gender = tr.Gender,
|
||||
ID32 = tr.ID32,
|
||||
OT_Friendship = PersonalTable.LA[Species, Form].BaseFriendship,
|
||||
|
||||
HeightScalar = IsAlpha ? (byte)255 : PokeSizeUtil.GetRandomScalar(),
|
||||
WeightScalar = IsAlpha ? (byte)255 : PokeSizeUtil.GetRandomScalar(),
|
||||
Nickname = SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation),
|
||||
|
|
|
@ -16,7 +16,7 @@ public sealed record EncounterStatic8b(GameVersion Version)
|
|||
public bool EggEncounter => EggLocation != None;
|
||||
private const ushort None = Locations.Default8bNone;
|
||||
public byte Form => 0;
|
||||
public bool IsShiny => Shiny != Shiny.Never;
|
||||
public bool IsShiny => Shiny == Shiny.Always;
|
||||
public byte LevelMin => Level;
|
||||
public byte LevelMax => Level;
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ public sealed record EncounterSlot9(EncounterArea9 Parent, ushort Species, byte
|
|||
{
|
||||
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language);
|
||||
var form = GetWildForm(Form);
|
||||
var version = Version != GameVersion.SV ? Version : GameVersion.SV.Contains(tr.Game) ? (GameVersion)tr.Game : GameVersion.SL;
|
||||
var pk = new PK9
|
||||
{
|
||||
Species = Species,
|
||||
|
@ -97,7 +98,7 @@ public sealed record EncounterSlot9(EncounterArea9 Parent, ushort Species, byte
|
|||
CurrentLevel = LevelMin,
|
||||
Met_Location = Location,
|
||||
Met_Level = LevelMin,
|
||||
Version = (byte)Version,
|
||||
Version = (byte)version,
|
||||
Ball = (byte)Ball.Poke,
|
||||
MetDate = EncounterDate.GetDateSwitch(),
|
||||
|
||||
|
@ -129,7 +130,7 @@ public sealed record EncounterSlot9(EncounterArea9 Parent, ushort Species, byte
|
|||
{
|
||||
pk.PID = Util.Rand32();
|
||||
pk.EncryptionConstant = Util.Rand32();
|
||||
pk.SetRandomIVs();
|
||||
criteria.SetRandomIVs(pk);
|
||||
|
||||
pk.Nature = pk.StatNature = (int)criteria.GetNature(Nature.Random);
|
||||
pk.Gender = criteria.GetGender(Gender, PersonalTable.SV[pk.Species, pk.Form]);
|
||||
|
|
Loading…
Reference in a new issue