mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-17 12:17:11 -05:00
Inline pk2/pk3 form setter, only SetGender if different
Helps out ALM generate unown
This commit is contained in:
@@ -24,6 +24,9 @@ public static void SetSaneGender(this PKM pk, int gender)
|
||||
public static void SetGender(this PKM pk, int gender)
|
||||
{
|
||||
gender = Math.Min(2, Math.Max(0, gender));
|
||||
if (pk.Gender == gender)
|
||||
return;
|
||||
|
||||
if (pk.Format <= 2)
|
||||
{
|
||||
pk.SetAttackIVFromGender(gender);
|
||||
|
||||
@@ -48,28 +48,6 @@ public static string ClearNickname(this PKM pk)
|
||||
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>
|
||||
/// Sets the <see cref="PKM.Ability"/> value by sanity checking the provided <see cref="PKM.Ability"/> against the possible pool of abilities.
|
||||
/// </summary>
|
||||
@@ -191,6 +169,7 @@ public static void SetNature(this PKM pk, int nature)
|
||||
public static void ApplySetDetails(this PKM pk, IBattleTemplate Set)
|
||||
{
|
||||
pk.Species = Math.Min(pk.MaxSpeciesID, Set.Species);
|
||||
pk.Form = Set.Form;
|
||||
pk.SetMoves(Set.Moves, true);
|
||||
pk.ApplyHeldItem(Set.HeldItem, Set.Format);
|
||||
pk.CurrentLevel = Set.Level;
|
||||
@@ -225,7 +204,6 @@ public static void ApplySetDetails(this PKM pk, IBattleTemplate Set)
|
||||
pk.SetMarkings();
|
||||
|
||||
pk.SetNickname(Set.Nickname);
|
||||
pk.SetForm(Set.Form);
|
||||
pk.SetSaneGender(Set.Gender);
|
||||
|
||||
if (Legal.IsPPUpAvailable(pk))
|
||||
|
||||
@@ -28,7 +28,6 @@ public abstract class G3PKM : PKM, IRibbonSetEvent3, IRibbonSetCommon3, IRibbonS
|
||||
public sealed override int Ability { get => ((PersonalInfoG3)PersonalInfo).GetAbility(AbilityBit); set { } }
|
||||
public sealed override uint EncryptionConstant { get => PID; 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 int Gender { get => PKX.GetGenderFromPID(Species, PID); set { } }
|
||||
public sealed override int Characteristic => -1;
|
||||
@@ -36,6 +35,19 @@ public abstract class G3PKM : PKM, IRibbonSetEvent3, IRibbonSetCommon3, IRibbonS
|
||||
public sealed override int CurrentHandler { 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 abstract bool AbilityBit { get; set; }
|
||||
|
||||
|
||||
@@ -145,7 +145,13 @@ public sealed override int Form
|
||||
formeVal |= (uint)((IV_SPC & 0x6) >> 1);
|
||||
return (int)(formeVal / 10);
|
||||
}
|
||||
set { }
|
||||
set
|
||||
{
|
||||
if (Species != 201) // Unown
|
||||
return;
|
||||
while (Form != value)
|
||||
SetRandomIVs(0);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int EV_SPC { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user