mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Add optional loop for generating min level
This commit is contained in:
parent
0605a01b24
commit
cf86cafdf7
2 changed files with 18 additions and 4 deletions
|
@ -43,9 +43,18 @@ public sealed record EncounterSlot8a : EncounterSlot, IAlpha, IMasteryInitialMov
|
|||
pk.Gender = (int)Gender;
|
||||
|
||||
var para = GetParams();
|
||||
var (_, slotSeed) = Overworld8aRNG.ApplyDetails(pk, criteria, para, HasAlphaMove);
|
||||
if (LevelMin != LevelMax)
|
||||
pk.CurrentLevel = pk.Met_Level = Overworld8aRNG.GetRandomLevel(slotSeed, LevelMin, LevelMax);
|
||||
while (true)
|
||||
{
|
||||
var (_, slotSeed) = Overworld8aRNG.ApplyDetails(pk, criteria, para, HasAlphaMove);
|
||||
if (LevelMin != LevelMax)
|
||||
{
|
||||
var lvl = Overworld8aRNG.GetRandomLevel(slotSeed, LevelMin, LevelMax);
|
||||
if (criteria.ForceMinLevelRange && lvl != LevelMin)
|
||||
continue;
|
||||
pk.CurrentLevel = pk.Met_Level = lvl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetEncounterMoves(PKM pk, GameVersion version, int level)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static PKHeX.Core.AbilityPermission;
|
||||
|
||||
|
@ -37,6 +37,11 @@ public sealed record EncounterCriteria
|
|||
public int IV_SPD { get; init; } = RandomIV;
|
||||
public int IV_SPE { get; init; } = RandomIV;
|
||||
|
||||
/// <summary>
|
||||
/// If the Encounter yields variable level ranges (e.g. RNG correlation), force the minimum level instead of yielding first match.
|
||||
/// </summary>
|
||||
public bool ForceMinLevelRange { get; set; }
|
||||
|
||||
// unused
|
||||
public int HPType { get; init; } = -1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue