Commit graph

103 commits

Author SHA1 Message Date
Kurt
1e86fdcea8
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue

We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.

## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots. 
* We have a Silcoon that we've leveled up a few times.

Was our Silcoon originally a Wurmple, or was it caught as a Silcoon? 
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.

---

Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).

The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.

---

The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.

---

## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.

## Conclusion

This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-29 17:55:27 -08:00
sora10pls
1be20be877 Fix GO Shiny permissions 2021-01-26 13:35:57 -05:00
Kurt
5f8e2b13c5 Simplify headbutt tree pivot check
See the EncounterSlotDumper with the memoization logic & json tree listing.

Simplifies things a lot, and improves checking speed. Unreachable trees are now treated the same as no-trees maps.

ez 1.5KB reduction in file size :P
2021-01-22 19:20:18 -08:00
Kurt
bfd948ee2b Update pget binaries, check gender
yay single gender availability! (frillish/jellicent being male only)
2021-01-16 18:29:27 -08:00
Lusamine
15da92f9bc
Document weather for static encounters (#3127)
This only matches the weather table with the Pokemon and does not fully
account for whether a location can spawn a particular weather.

Additional minor changes:
- Adds ScriptedNoMarks to Regis and Glimwood Tangle static encounters
- Corrects a few version-specific Pokemon such as Ludicolo/Shiftry
- Removes erroneous encounters such as Milotic in East/West Lake Axewell
- Removes an unused Motostoke Stadium encounter
2021-01-16 09:31:21 -08:00
Kurt
70fe1847ac sync missing changes 2021-01-05 09:51:32 -08:00
Kurt
a4c4a2b231 Make EncounterArea record type
immutable reference types is the goal; the array for the data isn't copied, but both records refer to the same data.
2021-01-01 10:55:33 -08:00
Kurt
fb008be6a6 Condense some more expressions 2020-12-31 23:13:27 -08:00
Kurt
b19688b13d Defer go slots with IV sets as there might be other encs
Move the logic to the class
Update go binaries
2020-12-29 16:07:29 -08:00
Kurt
e8c23f6644 Simplify some repeated comparisons with expressions
Less prone for bugs since it uses the same value for all comparisons without re-specifying
2020-12-29 00:37:59 -08:00
Kurt
ee5349ff98 moar is or 2020-12-25 12:30:26 -08:00
Kurt
afdd2bd57e Mark EncounterSlot/Static types as immutable record types 2020-12-23 20:40:59 -08:00
Kurt
594db92ad0 Minor clean
Handle some stragglers
2020-12-21 17:48:08 -08:00
Kurt
0303eada32 this is not that
clearer than before, yay
2020-12-21 17:12:39 -08:00
Kurt
68ee8cfcc4 Change setters to init only 2020-12-21 17:05:05 -08:00
Kurt
62018cce1a Unify concepts with different names
AltForm & Form & Forme => Form
GenNumber & Generation => Generation

Extract out SpeciesForm interface, and re-add IGeneration

For those using PKHeX as a dependency, this should be a pretty straightforward manual replacement... GenNumber and AltForm should be quick find-replace`s.
2020-12-10 20:42:30 -08:00
Kurt
4f7e34dd47 Simplify slot init to reduce re-allocation
Slap in friend safari at the end during object construction; saves about 1KB of allocation on startup (lol)

Change internal array types to match object types, similar to other encounter-generation definitions.
2020-11-29 15:05:53 -08:00
Kurt
fefc38bacb Minor debug optimizations
Trees:
- Only retain the objects needed after calculation
- Reduce size of TreeCoordinates and remove allocation penalty (now a struct)

No more warnings for Release compilation :D
2020-11-28 14:55:09 -08:00
Kurt
8778d8c6b7 Update 20.11.28 2020-11-27 21:40:36 -08:00
Kurt
3d6bb0ec00 Ignore bad evolution slots 2020-11-27 21:04:06 -08:00
Kurt
9b178fefe2 Xmldoc, minor tweaks
Move form-info logic from FormConverter to AltFormInfo; now FormConverter is entirely form=>string[]
Add a bunch of xmldoc
Make pogo no-end-date cmp agaisnt UTCnow rather than local now.
2020-11-27 11:51:02 -08:00
Kurt
ce17fd4050 Minor tweaks
Enc static 4 should check met location, since locations are flexible for roamers
Simplify expressions
Disallow 0 moves in "needed moves" list.
2020-11-19 15:34:06 -08:00
Kurt
0af0c05bac Update go slot list yield and move fetch 2020-11-18 21:34:40 -08:00
Kurt
037db7b8a3 Add xmldoc for new obj/func related to GO legality 2020-11-16 21:17:45 -08:00
Kurt
26e0f31c95 Include date legality parameters for LGPE
Extract common abstract class for GO transferred encounters
Clamp minlevel instead of met level
Add optional parameter for GO IV randomization
Update go legality binaries with latest
2020-11-16 15:32:22 -08:00
Kurt
d7dc69104b Fix year check
still testing
2020-11-15 18:12:58 -08:00
Kurt
760adb4945 Check date legality 2020-11-15 08:31:48 -08:00
Kurt
377ec02c9b Minor clean
Remove GoPark as a "Type" since it is now baked into the encounter object type
2020-11-14 12:55:30 -08:00
Kurt
ad9e9ddfa0 Relocate go encounter maintenance outside of pkhex.core
PKHeX.Core now accepts generated pkl binaries from PoGoEncounterTool (PGET).

Refer to pporg's repo. This will be treated like event data; occasionally updated.
2020-11-14 12:51:24 -08:00
Kurt
5e22c119be Continued refinements 2020-11-13 08:20:51 -08:00
Kurt
f366d27bdb Revert Mothim form 2020-11-12 22:00:02 -08:00
Kurt
01c597cba7 GO checks round 2 2020-11-12 20:41:01 -08:00
Kurt
915727ed67 Add g-kanto formes
Probably will refactor things when shiny/ball legality is detailed
2020-11-11 13:27:08 -08:00
Lusamine
86096201e8
Add Route 3 -> Motostoke City crossover (#3085)
Not related to the location glitch; whistle to lead Zigzagoon.

Co-Authored-By: tehvik <40148574+tehvik@users.noreply.github.com>
2020-11-10 22:11:19 -08:00
Kurt
7654ce2123 Add initial legality checks for GO->HOME transfers
took me less than an hour to do these changes, and i can flag bad form movesets no problemo

Expect tightening of restrictions (ball, level, shininess) later
if someone wants to curate met date restrictions, go ahead!
2020-11-10 22:10:53 -08:00
Kurt
227efc1fc3 Only allow checking if lvl60 when lvl<60 2020-11-05 21:17:13 -08:00
Kurt
51c872f4e1 Move more logic closer to where it's used 2020-11-02 14:46:26 -08:00
Lusamine
d5e5df802e
Add Ballimere Lake -> Lakeside Cave crossover (#3069) 2020-10-31 22:29:08 -07:00
Kurt
c9ee07e9b9 Update form for friendsafari vivillon
Closes #3066
2020-10-30 22:23:13 -07:00
Lusamine
5e92b7b5f7
Add crossover and static encounters for CT (#3050)
* Add crossover encounters for CT

* Old Cemetery -> Giant's Foot

* Add some static encounters

* Add Frostpoint Field -> Freezington crossover
2020-10-27 22:08:49 -07:00
Kurt
2e4af1afc5 Update legality comparisons for Crown Tundra
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2020-10-24 11:16:01 -07:00
Kurt
52a67f2425 Add Stadium2 Support
Introducing a new PKM format: SK2
Split ICaughtData2 off of PK2 so it can be shared with SK2 when type-checks occur
Add conversion for PK2<->SK2
Split the split-buffer handling for GBPKM to GBPKML (what a name), so that I can reuse shared accessor logic for SK2.
2020-10-02 18:08:40 -07:00
Kurt
ce5897ff94 Move version value from Slot to Area to reduce member size & value passing
Restrict some setters to protected only
2020-08-30 11:08:21 -07:00
Kurt
6ee7a8724b
Offload EncounterSlot loading logic to reduce complexity (#2980)
* Rework gen1 slot loading

Slot templates are precomputed from ROM data and just loaded straight in, with tight coupling to the encounter area (grouped by slot types).

* Revise fuzzy met check for underleveled wild evos

Example: Level 23 poliwhirl in RBY as a level 50 poliwhirl, will assume the chain is 25-50 for poliwhirl (as poliwag evolves at 25). Instead of revising the origin chain, just ignore the evo min level in the comparison.

Previous commit fixed it for gen1.

* Rework gen2-4 slot loading

Gen4 not finished, Type Encounter data and some edge encounters not recognizing yet...

* Add feebas slots for old/good encounters

* Begin moving properties

Great news! Gen5-7 need to be de-dumbed like Gen1-4.

Then I can remove the bang (!) on the Area accessor and ensure that it's never null!

* Split off XD pokespot slot encounter table type

* Set area in constructor

* Deduplicate g3 roaming encounters

* Deduplicate xd encounter locations (rebattle)

Only difference is met location; no need to create 500 extra encounter objects. A simple contains check is ok (rarely in gen3 format).

* Make all slots have a readonly reference to their parent area

* Minor clean

* Remove "Safari" slot type flag

Can be determined via other means (generation-location), allows us to reduce the size of SlotType member to a byte

Output of slot binaries didn't preserve the Safari flag anyway.

* Update SlotType.cs

* Handle type encounters correctly

* Merge safari area into regular xy area

* Merge dexnav accessor logic

* fix some logic so that tests pass again

rearrange g5 dw init to be done outside of static constructor (initializer instead)
PIDGenerator: friend safari slots now generate with required flawless IV count

* Add cianwood tentacool gift encounter

* Remove unnecessary abstractions

Fake area just returned a slot; since Slots have a non-null reference to the area, we can just return the slot and use the API to grab a list of possible slots for the chain.

Increase restrictiveness of location/type get-set operations

* Minor tweaks, pass parameters

DexNav observed state isn't necessary to use, only need to see if it's possible to dexnav. Now that we have metadata for slots, we can.

* Remove unused legality tables
2020-08-30 10:23:22 -07:00
Kurt
780e8bf2bf Branch to specific iterator
Similar to fuzzy matches for gen3/4 iterators
2020-08-22 14:52:17 -07:00
Kurt
42453bdcd8 Update EncounterArea8.cs 2020-08-22 14:12:16 -07:00
Kurt
a62324a5a1
Refactoring some IEncounterable-type'd object initialization and original-generation evo chain (#2974) 2020-08-21 16:35:49 -07:00
Kurt
a6a3c6eaaa Refactoring
change some expressions for better perf/readability
2020-07-19 17:48:45 -05:00
Kurt
40ce63873d Reduce gen1 encounter legality startup alloc by 5KB
Use precomputed counts to remove the need to store a cache of read values

rename some variables in ReadSlots1FishingYellow
2020-07-19 14:08:56 -05:00
Kurt
eb7ed44b29 Finish splitting gen1/2 encounter types from parent class
Results in a little more code, but each path is less tangled
simplify some expressions
remove RBDragonair content in favor of a strict filter for catch rate

Move gen1 trade trainer names to stringconverter, since pk1/pk2 shouldn't refer to legality classes
2020-07-19 13:32:40 -05:00