reduce nesting (evo.RequiresLevelUp is checked twice, only check once
and handle path)
compact some methods
seal some classes
add a little xmldoc to exposed members
Encounter used to be used to determine if the original encounter was
valid; we now store the encounter object and checking is fast enough --
we don't really care to short-circuit individual verification steps
anymore.
Checks.cs initially started out small, but over the years it has grown
to handle multiple types of checks. With all these checks next to
eachother, it's hard to see the overall groups. Splitting them up
(potentially further?) allows for more focused maintenance &
understanding.
Not sure if I'm happy with the overall bandaids used (checks no longer
done within LegalityAnalysis so variable repointing is excessively
used), but I'm happier the way it is now compared to the huge Checks.cs
push unsaved IVTotal/EVTotal stuff from prior commit
rework exposed types for evo chain
initial trim now uses much less linq
can probably redo the get initial chain to provide a species to break
on...
Add safari min flawless IVs to reroll (can expand if #2025 is required
for egg group15)
Use EV/IVTotal (faster, not linq array based)
Fix missing pumpkaboo form regression, Closes#2026
Relocate swapbits to appropriate class, unneeded in PKM.cs
Can't have species == 0 or invalid gameversion; check for
EncounterInvalid instead.
Egg chain is always valid (since it is not EncounterInvalid) thus always
provide the chain.
Since these 2 are the same, simplify the logic to be shared.
rearrange some parameters for easier flow
Rename "Flag" to "Method"; isn't used besides for indicating the evo
Method.
Remove some unnecessary duplicate checks
- always >=1 in chain at start
- mostEvolved already checked for > maxspeciesgen
continued simplification
core.cs is pretty much the following:
misc one-off junk
moveset fetch
encounter table fetch
evo chain fetch
might eventually move things around a bit further for cleanliness so
that misc meta junk is the only thing that remains in core.
#2015
Can't get a shiny female 1:7 f:m gender ratio transfer after the VC2
bank update; need to respect that when generating random moves for the
pkm by removing any gen2 evo chain data.
update handling that checked for this case to instead check for
equivalence to ability1 instead of 0
was generating a PGF with ability[1] = 0, which is not correct. Just fix
the binaries to behave and get rid of all the workarounds since future
tables don't have missing values.
bypass savefile language checks if no language set
fix gen2 static gift egg that is really a wild encounter -- egg flag was
set & not cleared -> no wild pkm, bad! Adds test case for this.
(probably isn't a better place to clear, enforces only once per
generation rather than on every yield/end of every static yield)
Although Pokémon Ruby, Sapphire, and Emerald include a location pointer
for "Mirage Island", any Wynaut caught here will simply display "Met on
Route 130" in their summary. This is because the player is technically
still on Route 130's map.
Can't get anything with that location ID as an egg or as wild
egg fetch returns array, need to add to the collection
force everything as readonly to prevent adds outside of the constructor
Closes#1988
Thanks @iiippppk !
fix b2w2 egg base levelup reference (not bw, b2w2!), doesn't really
matter much except for better indication (possibly?)
remove some unnecessary linq ToArray() calls
continue relocating code out of Core
pull out some move data fetching to separate class
add methods to quickly fetch if the move is learnable via that method
eventual plan is this:
replace
'fetch all possible moves then look within' move validation
with:
'peek if learnable, and get info how' move validation
advantages:
- returns game the move was learned in and the level (if appropriate)
- infinitely less object creation (garbage collection)
- only looks for a given move, doesn't have to fetch everything before
checking
- faster than full fetch, can be made even faster by optimizing lookups.
subject to change :)
Closes#1317
Needs the events crew to produce serialized binaries with hash-flag data
for each generation before proceeding any further. I'm not really
interested in doing all the work for events since it doesn't impact
battle legality.
nickname reset clears except for encountertrades (some have fixed
nicknames).
remove untraded check for HT memory verification, has to be traded if it
has a HT memory.
stored as wc3's, make "Version" from IVersion rather than int so that
"WasXD" recognizes it.
Update handling for fateful encounter trade-away cases.
#1970
Gen7 weavile can exist in gen4 as sneasel; existing code had pruned it
from gen4. Skip pruning for this case
probably overdid the checks but whatever. works.
Thanks /u/ThrowawayReddNinja for pointing out this false flagged case
with an example!
Had relearnmoves defined but no current moves; better for generator to
spit out all moves rather than the special move (hold back)
store current moves for all link gifts
Too many classes in the same file, break up.
simplify things a little in EncounterArea (remove passing thru nulls,
should throw excpetion immediately if misconfigured).
amount of pkm obj classes is pretty high, move the static utility
classes to another folder
breaks usage of pkm.ShowdownText; removes a dependency from PKM.
* Fix minlevel of Pangoro/Tyrantrum/Aurorus in gen6
30: level + dark type in the party
32: level + day
33: level + night
34: level + female
Note Meowstic isn't affected due to another entry of level + male (23)
* Minor text usage fix
* Fix xorPID flipping in TransferEC check
Remove edge case handling for level 2 blissey; updates over the past 2
(yay 2 years of legality checking) can now handle that case without
special handling.
Store 4g giratina held item for enc->pkm legality
revise usages of GetSaneGender
Rearrange some logic
Better handle impossible version encounters (gen4)
gen 1-5 done, stuck on 659 - bunnelby egg...?
* B2 has an error in the encounter table for Route 3 Corphish Special
water encounter; GF edited from Basculin-1 to Corphish-1 and forgot to
update the form to 0.
* Ranch Trade egg locations
* Trade gender-PID set correctly
* static roamer glitch does not apply for emerald
* Mirage Island wild Wynaut case now allowed (collision with Gift Wynaut
egg hatched on Mirage Island?)
gen1-3 done; now at 413 (Wormadam) which currently yields an
EncounterEgg AS wormadam, which isn't right...
* first case of EncounterLink, now works (version, ability, OT memory)
* handle gen2 gb events (not even sure if they pop up, just in case)
* handle gen3 ereader shadow mons
* handle gen4 spiky pichu PID type
* handle gen2 crystal egg met level
Handle Faraway Island Mew, handle DP Darkrai/Shaymin & Arceus, handle
not-distributed WC3s.
Now stopping at dex 154 -- one full generation of PKM species IDs can be
completely spawned directly from IEncounterable data!
Exeggutor Island has wild & one static with a fixed ability; the fixed
ability is returned first which causes wild lv40 exeggutors with
ability2 (1/2/H) to be flagged as illegal.
Fixes Krabby / etc.
Fix genderless encounterstatic gender set (Voltorb)
Now at 103, Exeggutor
pretty cool that over 100 species can have every single encounter
generate a legal pkm ;)
might be useful to add metrics to count how many encounters are
generated in a session
Graveler (SM Trade) -> Force applying handling trainer details for
ingame trades
Ponyta (Ranch Trade) Apply correct ability for encountertradePID
Up to 98 : Wild Gen2 Krabby (safari zone impossible location needs to
get filtered from possible encounters)
Fix/add missing gameversion references (BU instead of BW,
pokewalker=HGSS)
increase reuse of pidgenerator & add more generating methods.
seems like it's generating pkm fine besides the PID edge cases, which is
nice
version was set to Encounter_XD, which did not contain the miror b
encounters.
simplify XD check to be O(1) now that version is stored in the encounter
obj
* Add general memory intensity/feeling check
Memory setting subroutines: Y: sub_43C1E4 AS: sub_469A94
Memory table RAM address: Y:0x54A4F0 AS: 0x58A134
https://pastebin.com/h1RHL7nR
* Check if egg's OT memory is blank
All empty memory should be checked before common check.
Don't allow eggs to fall through.
Closes#1912 , genderless ~= fixed gender I guess; shouldn't get these
gender-errors unless it's manually tampered data/ShowdownSet
remove unnecessary code in:
* PKMEditor (>=255 is already covered by == 255 and the fact that gt is
always <= 255)
* VerifyGender (3 <= x <= 5) check is already early-returned via
PIDGender check above
Update IsGenderValid knowing that VC mons have a gennumber <= 2
surf does not have another slot set; so they were all being set to
Morning.
Could have set all 3 time flags, but kept as 'any'.
will update release binaries with this one
Correctly fixes#1163 (test cases added), eg wooper->quagsire would
learn yawn at 31 before evolving; the getmoves wouldn't provide yawn
(stopped at 30) with the old code; the lvl decrement was removed in the
incorrect commit, providing a legal verdict which was obtained
incorrectly (dexlevels were inaccurate)
Closes#1895 , re-verified with pkm provided in #1805
there's no shedinja gift, always is an evolution
seal some forms to remove virt call in constructor warning
egg moves also can be taught in gen1, which causes the learn source to
be locked to a tradeback (removing egg moves that have IDs greater than
RBY's moves). Simplify gen<=2 parse preference ordering with this
addition to force egg moves to be acknowledged.
only tested for gen7 egg->pkm (not to eventual set)
pretty sure a good chunk of the egg generation logic can be pulled out
for reuse in other IEncounterable generators (IEncounterable
extensions?)
If one wanted to extend ConvertToPKM to other IEncounterables, this
would be the provided obj containing the receiver's info
allows pkm gen without a savefile, which is nice?
Test parsing glaceon, input must equal output
Test generating encounters for a specific version (exists only on Moon)
Test generating encounters for the same version (add handling trainer
data to permit Tutors)
fixes error in VC generations-present fetch which allowed movesets from
generations 3-6 lul
exclude negative/invalid gameversions
Each contest victory requires a contest participation; each
participation gives 20 OT affection (not current trainer!)
Thanks @WyrXIII , @JusLi, @Cresceda !
party stats set when setting a slot to a save file
simplify set/delete slotchange duplicate logic
suggest better met locations beyond VC transfers
hatching a gen6 egg applies memories automatically
Two checks are performed for Gen 3 & 4:
A: Encounterability (wurmple, ball, ability)
B: RNG Compatibility (frame)
Original code only checked 'A'
Recent code ordered by 'A', but returned anything that matched 'B'. If
'B was not satisfied, an 'A' match would get deferred, allowing for an
eventual B & !A to be returned before a A & !B being returned.
yay bool logic
we want to prefer a RNGFrameMatch as well as a SlotCompatible match
original code (no RNG checks) retrieves with SlotCompatible just fine
recent adding in framematch resulted in deferring compatible if not RNG
frame, yielding !A matches before A & !B
maintain 3 queues (A & B get yielded immediately) to track A!B, !AB, and
!A!B
not necessary to check unown case anymore as it'll fall into the A!B
group. better performant to skip that check in favor of only adding for
fail.
thanks theSlayer!
gen1 & gen2 types aren't laid out contiguously (yay bird type and extra
types)
fix gen2 type accessors looking at the wrong byte
type sprites now load correctly, and 3rd ability no longer throws an
error (forced to None).
Gen5 does not follow the same convention, 0 = non, 1 = rnd, 2 = always;
not gonna bother updating for just that one
bool? occupies 2 bytes; enum:byte is 1 byte.
should probably move validity checking logic into the IEncounterable
objects instead...
faster to do:
null check & comparison for each
vs
collection add (especially if growing collection)
don't evaluate all slots (faster), capturing the dexlevel[] object is
fine until the enumerable is discarded
WinForms->Core logic absorbing (CommonEdits)
loading ShowdownSet now applies properties to PKM instead of PKMEditor
Contest/IVs for Static/Trades are no longer set by default (less object
allocations), and are now checked by the encounter generator
Closes#1829
"In Pokémon Ultra Sun and Ultra Moon, Murkrow is programmed to be able
to learn Punishment through breeding, but no other Pokémon in the Flying
Group can pass down Punishment as an Egg Move in those games. Vullaby
and Mandibuzz are the only Flying Egg Group Pokémon that can learn
Punishment, but they cannot pass down the move due to being female-only
species."
great job gamefreak
allow current handler to be 0, remove static encounter as the data was
sneakily faked as a WC7 in the events gallery.
Closes#1817 ; still needs to update with new pikachu pid method
allowing shinies (next update).
tested for 2 locks, later commits with legality check implementation
will feature more lengthy lock checks (test case automation).
https://pastebin.com/VdbjWaqL
(species doesn't matter since most are 50/50 ratio)
arbitrary access for RNG frame results, only generating frames when the
frame is unavailable. all calculated frames are cached.
to be used in RNG searching where caching seeds is necessary (repeat
checks)