mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 22:40:22 +00:00
ab33df2fc9
* Add weather types by location Creates a dictionary of possible weather types for each SWSH location. Unlisted locations may only have Normal weather or do not have any encounter slots. * Prune unused weather from static encounters Some encounters were too permissive with weather, e.g. Sandstorm in Fields of Honor and Challenge Beach; Snowstorm at Dyna Tree Hill. A few crossover areas that would have limited the possible weathers were marked with a "(c)". An example is Nidorina from Giant's Bed crossing to Frostpoint Field, where Raining and Thunderstorm do not occur. This additionally organizes encounters by location. * Move location-weather dictionary to EncounterArea8 * Verify weather marks on encounterslot/static encounters * Adds some static encounters available through weather bleed Weathers aren't normally available, but these static encounters are close enough to the boundary that the weather in an adjacent area can be used to spawn them. - Frostpoint Field Snorlax with Raining/Thunderstorm from Giant's Bed - Snowslide Slope Amaura with Raining/Thunderstorm from Giant's Bed - Frigid Sea Carracosta with Intense_Sun from Three-Point Pass - Frigid Sea Magmortar with Intense_Sun from Three-Point Pass - Ballimere Lake Corviknight with Snowstorm from Giant's Bed - Ballimere Lake Cryogonal with Snowstorm from Giant's Bed - Ballimere Lake Tyrunt with all weather from Giant's Bed - Lakeside Cave Ferrothorn with all weather from Ballimere Lake - Tunnel to the Top Golbat with all weather from Path to the Peak * Defer weather marks if incompatible, enforce encounterslot weather This uses the area weather to check fishing slots and tentatively adds some tables for weather bleed encounterslots. * Warm-Up Tunnel gets weather bleed from Training Lowlands * Update for base PKHeX * Handle weather bleed for SWSH encounter slots Co-authored-by: Skadiv <62726360+Skadiv@users.noreply.github.com> * Minor clean Having duplicate weather marks is illegal, so just auto-partial match them instead of checking the other marks. * Rearrange slot weather check logic * Claim reserved byte in SWSH pkl * No need for two variable names now * Valid weather marks on tree/fishing should return with main weather * Fix tree/fishing deferral and add another surf slot weather bleed * Disallow tree/fishing encounters from using bleed tables None are currently known at this time, and only hidden grass encounters have a weather bleed table * Condense bleed expression, combine tree/fish flag check * Move weather-bleed check into EncounterArea8 Makes the dictionaries private instead of internal. Co-authored-by: Skadiv <62726360+Skadiv@users.noreply.github.com>
116 lines
4.7 KiB
C#
116 lines
4.7 KiB
C#
using static PKHeX.Core.OverworldCorrelation8Requirement;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Encounter Slot found in <see cref="GameVersion.SWSH"/>.
|
|
/// </summary>
|
|
/// <inheritdoc cref="EncounterSlot"/>
|
|
public sealed record EncounterSlot8 : EncounterSlot, IOverworldCorrelation8
|
|
{
|
|
public readonly AreaWeather8 Weather;
|
|
public readonly AreaSlotType8 SlotType;
|
|
public override string LongName => $"{wild} [{(((EncounterArea8)Area).PermitCrossover ? "Symbol" : "Hidden")}] - {Weather.ToString().Replace("_", string.Empty)}";
|
|
public override int Generation => 8;
|
|
|
|
public EncounterSlot8(EncounterArea8 area, int species, int form, int min, int max, AreaWeather8 weather, AreaSlotType8 slotType) : base(area, species, form, min, max)
|
|
{
|
|
Weather = weather;
|
|
SlotType = slotType;
|
|
}
|
|
|
|
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)
|
|
{
|
|
bool symbol = ((EncounterArea8)Area).PermitCrossover;
|
|
var c = symbol ? EncounterCriteria.Unrestricted : criteria;
|
|
if (!symbol && Location is 30 or 54 && (Weather & AreaWeather8.Fishing) == 0)
|
|
((PK8)pk).RibbonMarkCurry = true;
|
|
|
|
base.ApplyDetails(sav, c, pk);
|
|
var req = GetRequirement(pk);
|
|
if (req != MustHave)
|
|
{
|
|
pk.SetRandomEC();
|
|
return;
|
|
}
|
|
if (symbol)
|
|
Overworld8RNG.ApplyDetails(pk, c, c.Shiny);
|
|
}
|
|
|
|
public OverworldCorrelation8Requirement GetRequirement(PKM pk)
|
|
{
|
|
if (((EncounterArea8)Area).PermitCrossover)
|
|
return MustHave; // symbol walking overworld
|
|
|
|
bool curry = pk is IRibbonSetMark8 {RibbonMarkCurry: true} || (pk.Species == (int)Core.Species.Shedinja && pk is PK8 {AffixedRibbon:(int)RibbonIndex.MarkCurry});
|
|
if (curry)
|
|
return MustNotHave;
|
|
|
|
// Tree encounters are generated via the global seed, not the u32
|
|
if ((Weather & AreaWeather8.Shaking_Trees) != 0)
|
|
{
|
|
// Some tree encounters are present in the regular encounters.
|
|
return Weather == AreaWeather8.Shaking_Trees
|
|
? MustNotHave
|
|
: CanBeEither;
|
|
}
|
|
|
|
return MustHave;
|
|
}
|
|
|
|
public bool IsOverworldCorrelationCorrect(PKM pk)
|
|
{
|
|
var flawless = GetFlawlessIVCount();
|
|
return Overworld8RNG.ValidateOverworldEncounter(pk, flawless: flawless);
|
|
}
|
|
|
|
private int GetFlawlessIVCount()
|
|
{
|
|
const int none = 0;
|
|
const int any023 = -1;
|
|
|
|
var area = (EncounterArea8) Area;
|
|
if (area.PermitCrossover)
|
|
return any023; // Symbol
|
|
if ((Weather & AreaWeather8.Fishing) != 0)
|
|
return any023; // Fishing
|
|
return none; // Hidden
|
|
}
|
|
|
|
public override EncounterMatchRating GetMatchRating(PKM pkm)
|
|
{
|
|
// Glimwood Tangle does not spawn Symbol encounters, only Hidden.
|
|
if (Location is 76 && ((EncounterArea8)Area).PermitCrossover)
|
|
return EncounterMatchRating.PartialMatch;
|
|
|
|
bool isHidden = pkm.AbilityNumber == 4;
|
|
if (isHidden && this.IsPartialMatchHidden(pkm.Species, Species))
|
|
return EncounterMatchRating.PartialMatch;
|
|
|
|
if (pkm is IRibbonSetMark8 m)
|
|
{
|
|
if (m.RibbonMarkCurry && (Weather & AreaWeather8.All) == 0)
|
|
return EncounterMatchRating.Deferred;
|
|
if (m.RibbonMarkFishing && (Weather & AreaWeather8.Fishing) == 0)
|
|
return EncounterMatchRating.Deferred;
|
|
|
|
// Check if it has a mark and the weather does not permit the mark.
|
|
// Tree/Fishing slots should be deferred here and are checked later.
|
|
if (!Weather.IsMarkCompatible(m))
|
|
return EncounterMatchRating.Deferred;
|
|
|
|
// Galar Mine hidden encounters can only be found via Curry.
|
|
if (Location is 30 or 54 && !((EncounterArea8)Area).PermitCrossover && !m.RibbonMarkCurry && (Weather & AreaWeather8.Fishing) == 0)
|
|
return EncounterMatchRating.PartialMatch;
|
|
}
|
|
|
|
var req = GetRequirement(pkm);
|
|
return req switch
|
|
{
|
|
MustHave when !IsOverworldCorrelationCorrect(pkm) => EncounterMatchRating.Deferred,
|
|
MustNotHave when IsOverworldCorrelationCorrect(pkm) => EncounterMatchRating.Deferred,
|
|
_ => EncounterMatchRating.Match,
|
|
};
|
|
}
|
|
}
|
|
}
|