Add optional loop for generating min level

This commit is contained in:
Kurt 2022-07-02 17:10:30 -07:00
parent 0605a01b24
commit cf86cafdf7
2 changed files with 18 additions and 4 deletions

View file

@ -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)

View file

@ -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;