mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Set ability bit, precheck for encounter activation
This commit is contained in:
parent
f27326cb2e
commit
205e9b433d
6 changed files with 38 additions and 13 deletions
|
@ -13,10 +13,17 @@ public static class GenerateMethodH
|
|||
var gr = pi.Gender;
|
||||
var ability = criteria.GetAbilityFromNumber(AbilityPermission.Any12);
|
||||
var (min, max) = SlotMethodH.GetRange(enc.Type, enc.SlotNumber);
|
||||
bool checkProc = MethodH.IsEncounterCheckApplicable(enc.Type);
|
||||
|
||||
// Generate Method H correlated PID and IVs, no lead (keep things simple).
|
||||
while (true)
|
||||
{
|
||||
if (checkProc)
|
||||
{
|
||||
var check = new LeadSeed(seed, LeadRequired.None);
|
||||
if (!MethodH.CheckEncounterActivation(enc, ref check))
|
||||
continue;
|
||||
}
|
||||
var esv = LCRNG.Next16(ref seed) % 100;
|
||||
if (esv < min || esv > max)
|
||||
continue;
|
||||
|
@ -116,6 +123,7 @@ public static class GenerateMethodH
|
|||
|
||||
pk.PID = pid;
|
||||
pk.IV32 = ((iv2 & 0x7FFF) << 15) | (iv1 & 0x7FFF);
|
||||
pk.RefreshAbility((int)(pid & 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -142,6 +150,7 @@ public static class GenerateMethodH
|
|||
|
||||
pk.PID = pid;
|
||||
pk.IV32 = ((iv2 & 0x7FFF) << 15) | (iv1 & 0x7FFF);
|
||||
pk.RefreshAbility((int)(pid & 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -221,6 +230,7 @@ public static class GenerateMethodH
|
|||
var iv1 = LCRNG.Next16(ref rand);
|
||||
var iv2 = LCRNG.Next16(ref rand);
|
||||
pk.IV32 = ((iv2 & 0x7FFF) << 15) | (iv1 & 0x7FFF);
|
||||
pk.RefreshAbility((int)(pid & 1));
|
||||
}
|
||||
|
||||
private static (uint iv1, uint iv2) GetCombinedIVs(EncounterCriteria criteria)
|
||||
|
|
|
@ -202,7 +202,9 @@ public static class MethodH
|
|||
return default;
|
||||
}
|
||||
|
||||
private static bool CheckEncounterActivation<T>(T enc, ref LeadSeed result)
|
||||
public static bool IsEncounterCheckApplicable(SlotType3 type) => type is Rock_Smash; // Fishing can use Sticky/Suction along with Friendship boost.
|
||||
|
||||
public static bool CheckEncounterActivation<T>(T enc, ref LeadSeed result)
|
||||
where T : IEncounterSlot3
|
||||
{
|
||||
if (enc.Type is Rock_Smash)
|
||||
|
|
|
@ -23,10 +23,17 @@ public static class GenerateMethodJ
|
|||
var ability = criteria.GetAbilityFromNumber(AbilityPermission.Any12);
|
||||
var (min, max) = SlotMethodJ.GetRange(enc.Type, enc.SlotNumber);
|
||||
bool randLevel = MethodJ.IsLevelRand(enc);
|
||||
bool checkProc = MethodJ.IsEncounterCheckApplicable(enc.Type);
|
||||
|
||||
// Generate Method J correlated PID and IVs, no lead (keep things simple).
|
||||
while (true)
|
||||
{
|
||||
if (checkProc)
|
||||
{
|
||||
var check = new LeadSeed(seed, LeadRequired.None);
|
||||
if (!MethodJ.CheckEncounterActivation(enc, ref check))
|
||||
continue;
|
||||
}
|
||||
var esv = LCRNG.Next16(ref seed) / 656;
|
||||
if (esv < min || esv > max)
|
||||
continue;
|
||||
|
@ -55,7 +62,10 @@ public static class GenerateMethodJ
|
|||
: ((lv % (enc.LevelMax - enc.LevelMin + 1)) + enc.LevelMin);
|
||||
pk.MetLevel = pk.CurrentLevel = (byte)lvl;
|
||||
}
|
||||
SetPIDIVSequential(pk, pid, seed);
|
||||
pk.PID = pid;
|
||||
var iv1 = LCRNG.Next16(ref seed);
|
||||
var iv2 = LCRNG.Next16(ref seed);
|
||||
pk.IV32 = ((iv2 & 0x7FFF) << 15) | (iv1 & 0x7FFF);
|
||||
pk.Gender = gender;
|
||||
pk.Ability = (pid & 1) == 0 ? pi.Ability1 : pi.Ability2;
|
||||
return LCRNG.Prev4(seed);
|
||||
|
@ -112,14 +122,6 @@ public static class GenerateMethodJ
|
|||
|
||||
public static uint GetPIDRegular(uint a, uint b) => b << 16 | a;
|
||||
|
||||
private static void SetPIDIVSequential(PK4 pk, uint pid, uint rand)
|
||||
{
|
||||
pk.PID = pid;
|
||||
var iv1 = LCRNG.Next16(ref rand);
|
||||
var iv2 = LCRNG.Next16(ref rand);
|
||||
pk.IV32 = ((iv2 & 0x7FFF) << 15) | (iv1 & 0x7FFF);
|
||||
}
|
||||
|
||||
private static (uint iv1, uint iv2) GetCombinedIVs(EncounterCriteria criteria)
|
||||
{
|
||||
uint iv1 = (uint)criteria.IV_HP | (uint)criteria.IV_ATK << 5 | (uint)criteria.IV_DEF << 10;
|
||||
|
|
|
@ -24,10 +24,17 @@ public static class GenerateMethodK
|
|||
var (min, max) = SlotMethodK.GetRange(enc.Type, enc.SlotNumber);
|
||||
bool randLevel = MethodK.IsLevelRand(enc);
|
||||
var modulo = enc.Type.IsSafari() ? 10 : 100;
|
||||
bool checkProc = MethodK.IsEncounterCheckApplicable(enc.Type);
|
||||
|
||||
// Generate Method K correlated PID and IVs, no lead (keep things simple).
|
||||
while (true)
|
||||
{
|
||||
if (checkProc)
|
||||
{
|
||||
var check = new LeadSeed(seed, LeadRequired.None);
|
||||
if (!MethodK.CheckEncounterActivation(enc, ref check))
|
||||
continue;
|
||||
}
|
||||
var esv = LCRNG.Next16(ref seed) % modulo;
|
||||
if (esv < min || esv > max)
|
||||
continue;
|
||||
|
|
|
@ -93,7 +93,9 @@ public static class MethodJ
|
|||
}
|
||||
}
|
||||
|
||||
private static bool CheckEncounterActivation<T>(T enc, ref LeadSeed result)
|
||||
public static bool IsEncounterCheckApplicable(SlotType4 type) => type is HoneyTree || type.IsFishingRodType();
|
||||
|
||||
public static bool CheckEncounterActivation<T>(T enc, ref LeadSeed result)
|
||||
where T : IEncounterSlot4
|
||||
{
|
||||
if (enc.Type.IsFishingRodType())
|
||||
|
|
|
@ -90,7 +90,9 @@ public static class MethodK
|
|||
}
|
||||
}
|
||||
|
||||
private static bool CheckEncounterActivation<T>(T enc, ref LeadSeed result)
|
||||
public static bool IsEncounterCheckApplicable(SlotType4 type) => type is Rock_Smash or BugContest || type.IsFishingRodType();
|
||||
|
||||
public static bool CheckEncounterActivation<T>(T enc, ref LeadSeed result)
|
||||
where T : IEncounterSlot4
|
||||
{
|
||||
if (enc.Type.IsFishingRodType())
|
||||
|
|
Loading…
Reference in a new issue