mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Inline pk2/pk3 form setter, only SetGender if different
Helps out ALM generate unown
This commit is contained in:
parent
6da235f0e8
commit
a287efe3a1
4 changed files with 24 additions and 25 deletions
|
@ -24,6 +24,9 @@ namespace PKHeX.Core
|
||||||
public static void SetGender(this PKM pk, int gender)
|
public static void SetGender(this PKM pk, int gender)
|
||||||
{
|
{
|
||||||
gender = Math.Min(2, Math.Max(0, gender));
|
gender = Math.Min(2, Math.Max(0, gender));
|
||||||
|
if (pk.Gender == gender)
|
||||||
|
return;
|
||||||
|
|
||||||
if (pk.Format <= 2)
|
if (pk.Format <= 2)
|
||||||
{
|
{
|
||||||
pk.SetAttackIVFromGender(gender);
|
pk.SetAttackIVFromGender(gender);
|
||||||
|
|
|
@ -48,28 +48,6 @@ namespace PKHeX.Core
|
||||||
return nick;
|
return nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the <see cref="PKM.Form"/> value, with special consideration for <see cref="PKM.Format"/> values which derive the <see cref="PKM.Form"/> value.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pk">Pokémon to modify.</param>
|
|
||||||
/// <param name="form">Desired <see cref="PKM.Form"/> value to set.</param>
|
|
||||||
public static void SetForm(this PKM pk, int form)
|
|
||||||
{
|
|
||||||
switch (pk.Format)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
while (pk.Form != form)
|
|
||||||
pk.SetRandomIVs();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
pk.SetPIDUnown3(form);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pk.Form = form;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the <see cref="PKM.Ability"/> value by sanity checking the provided <see cref="PKM.Ability"/> against the possible pool of abilities.
|
/// Sets the <see cref="PKM.Ability"/> value by sanity checking the provided <see cref="PKM.Ability"/> against the possible pool of abilities.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -191,6 +169,7 @@ namespace PKHeX.Core
|
||||||
public static void ApplySetDetails(this PKM pk, IBattleTemplate Set)
|
public static void ApplySetDetails(this PKM pk, IBattleTemplate Set)
|
||||||
{
|
{
|
||||||
pk.Species = Math.Min(pk.MaxSpeciesID, Set.Species);
|
pk.Species = Math.Min(pk.MaxSpeciesID, Set.Species);
|
||||||
|
pk.Form = Set.Form;
|
||||||
pk.SetMoves(Set.Moves, true);
|
pk.SetMoves(Set.Moves, true);
|
||||||
pk.ApplyHeldItem(Set.HeldItem, Set.Format);
|
pk.ApplyHeldItem(Set.HeldItem, Set.Format);
|
||||||
pk.CurrentLevel = Set.Level;
|
pk.CurrentLevel = Set.Level;
|
||||||
|
@ -225,7 +204,6 @@ namespace PKHeX.Core
|
||||||
pk.SetMarkings();
|
pk.SetMarkings();
|
||||||
|
|
||||||
pk.SetNickname(Set.Nickname);
|
pk.SetNickname(Set.Nickname);
|
||||||
pk.SetForm(Set.Form);
|
|
||||||
pk.SetSaneGender(Set.Gender);
|
pk.SetSaneGender(Set.Gender);
|
||||||
|
|
||||||
if (Legal.IsPPUpAvailable(pk))
|
if (Legal.IsPPUpAvailable(pk))
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
public sealed override int Ability { get => ((PersonalInfoG3)PersonalInfo).GetAbility(AbilityBit); set { } }
|
public sealed override int Ability { get => ((PersonalInfoG3)PersonalInfo).GetAbility(AbilityBit); set { } }
|
||||||
public sealed override uint EncryptionConstant { get => PID; set { } }
|
public sealed override uint EncryptionConstant { get => PID; set { } }
|
||||||
public sealed override int Nature { get => (int)(PID % 25); set { } }
|
public sealed override int Nature { get => (int)(PID % 25); set { } }
|
||||||
public sealed override int Form { get => Species == (int)Core.Species.Unown ? PKX.GetUnownForm(PID) : 0; set { } }
|
|
||||||
public sealed override bool IsNicknamed { get => SpeciesName.IsNicknamed(Species, Nickname, Language, 3); set { } }
|
public sealed override bool IsNicknamed { get => SpeciesName.IsNicknamed(Species, Nickname, Language, 3); set { } }
|
||||||
public sealed override int Gender { get => PKX.GetGenderFromPID(Species, PID); set { } }
|
public sealed override int Gender { get => PKX.GetGenderFromPID(Species, PID); set { } }
|
||||||
public sealed override int Characteristic => -1;
|
public sealed override int Characteristic => -1;
|
||||||
|
@ -36,6 +35,19 @@
|
||||||
public sealed override int CurrentHandler { get => 0; set { } }
|
public sealed override int CurrentHandler { get => 0; set { } }
|
||||||
public sealed override int Egg_Location { get => 0; set { } }
|
public sealed override int Egg_Location { get => 0; set { } }
|
||||||
|
|
||||||
|
public sealed override int Form
|
||||||
|
{
|
||||||
|
get => Species == (int)Core.Species.Unown ? PKX.GetUnownForm(PID) : 0;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Species != (int)Core.Species.Unown)
|
||||||
|
return;
|
||||||
|
var rnd = Util.Rand;
|
||||||
|
while (PKX.GetUnownForm(PID) != value)
|
||||||
|
PID = Util.Rand32(rnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public sealed override int AbilityNumber { get => 1 << (AbilityBit ? 1 : 0); set => AbilityBit = value > 1; } // [0,1]->[1,2] ; [1,x]->[0,1]
|
public sealed override int AbilityNumber { get => 1 << (AbilityBit ? 1 : 0); set => AbilityBit = value > 1; } // [0,1]->[1,2] ; [1,x]->[0,1]
|
||||||
public abstract bool AbilityBit { get; set; }
|
public abstract bool AbilityBit { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,13 @@ namespace PKHeX.Core
|
||||||
formeVal |= (uint)((IV_SPC & 0x6) >> 1);
|
formeVal |= (uint)((IV_SPC & 0x6) >> 1);
|
||||||
return (int)(formeVal / 10);
|
return (int)(formeVal / 10);
|
||||||
}
|
}
|
||||||
set { }
|
set
|
||||||
|
{
|
||||||
|
if (Species != 201) // Unown
|
||||||
|
return;
|
||||||
|
while (Form != value)
|
||||||
|
SetRandomIVs(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int EV_SPC { get; set; }
|
public abstract int EV_SPC { get; set; }
|
||||||
|
|
Loading…
Reference in a new issue