Commit graph

2227 commits

Author SHA1 Message Date
Kurt
a159da0abf Reduce allocations of default valid/invalid
Condense some expressions, make some comments/params clear and consistent.
2021-07-30 13:05:34 -07:00
Lusamine
535b63f613 Add Frigid Sea weather bleed for Roaring-Sea Caves Hydreigon/Tyranitar
Co-authored-by: Skadiv <62726360+Skadiv@users.noreply.github.com>
2021-07-29 15:20:22 -05:00
Kurt
a64782d313 Prevent fog slots/statics from being valid when not boosted to 60
Flag Misty(fog) mark as invalid when pkm is from Main wild area && not boosted
^ Check before the slot/static specific methods to have a one-liner :)
2021-07-26 15:01:21 -07:00
Kurt
d8b8b622cf Only allow brilliant boost if max level for slot
https://discord.com/channels/401014193211441153/805157881501450270/869223485795336232
2021-07-26 14:33:41 -07:00
Lusamine
ab33df2fc9
Enforce weather legality for SWSH (#3221)
* 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>
2021-07-26 14:28:05 -07:00
Kurt
c9640f8561 Comments: forme->form 2021-07-26 14:14:39 -07:00
Kurt
7bd844d5c5 Move min level check for gen1/2 closer to move adder
Check per-evolution min level rather than basing it on the original encounter data.

Correctly parses stuff like a captured level 23 Nidorina that immediately evolves into Nidoqueen, then learns Body Slam.

Passing zero is better than passing 1, as 0 requires no value pushing.

tidy up method signatures in MoveLevelUp so that species is followed by form, and the lookups are textually aligned. Clarify "maxLevel" instead of max/lvl, same as min.
2021-07-22 21:25:15 -07:00
Kurt
e961694bdb Minor tweaks
Pass evo chain to memory learning machine move
Pass minimum level for GB encounters if present, rather than enc min level
2021-07-22 19:08:56 -07:00
sora10pls
ee004865bd Add fossil distribution raids 2021-07-22 20:08:14 -04:00
Kurt
8e5e4487ba Change interface for method call to less restricted
Don't need "Name" or "LongName" for these methods.
2021-07-13 18:22:04 -07:00
sora10pls
34c401b7a0 Revise IsHOMEGift, check Card ID for gift date range
Currently, HOME gifts present in wc8.pkl will not be flagged for invalid dates due to them missing their respective Card IDs. This will be fixed with the next stable release, so this works for now.
2021-07-13 18:22:04 -07:00
Kurt
46f50a3a56 Use named consts for magic gender values
More personal magic value comparisons
2021-07-13 18:22:04 -07:00
Kurt
aeb83c8269 Update EncounterSlot8.cs
Closes #3232
2021-07-09 10:09:57 -07:00
sora10pls
85c500529e Add Curry distribution raids 2021-07-08 20:06:30 -04:00
Kurt
3fa311f6ed Misc tweaks
more annotations - all bool->out ? are annotated now
fix gender symbol inversion (forgot to set text)
extract some methods to reduce nesting
2021-07-06 08:42:15 -07:00
Kurt
8188208ca3 Add TMs to Item param list
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2021-07-03 13:18:51 -07:00
Kurt
9e665034b7 Implement "Can Buy Item" memory check
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2021-07-03 13:12:46 -07:00
Kurt
0e9d0886a9 Fix BCC if-else slot loading
Not all slots were being loaded.

Thanks jazpersona !
https://projectpokemon.org/home/forums/topic/57375-pkhex-new-update-legality-errors-contribution-page/?do=findComment&comment=267494
2021-07-03 11:35:28 -07:00
Kurt
f2183f985f Tighten up memory 71 permissions 2021-06-30 15:56:08 -07:00
Kurt
600f4a550a Allow urshifu for gen8 dynamax memory 2021-06-30 13:37:40 -07:00
Kurt
103aa9aa4b
Revise EncounterArea and EncounterType for clarity (#3228)
EncounterArea now stores a more specific type'd array for encounter slots. Better iteration and less casting, as the nonspecific `Slots` fetch is rarely referenced.

EncounterType renamed to GroundTile to reflect how it actually works in Gen4. Was previously an ambiguous field that was clarified a little; we can describe it a little better now. Keep the GUI the same to not scare the end users.

Change Trash Byte properties to get/set a Span. Trash Byte legality checking easier on the garbage collector?
2021-06-29 20:58:06 -07:00
Kurt
764e506ab5 Set language for gen3 eggs prior to applying nickname
The sav.ApplyTo call above tries to set the current savefile language, but gen3 savs do not have a Language ID saved.

Just mimic what the encounter slots/static/etc do.
2021-06-27 15:43:35 -07:00
Kurt
b7f849cb42 Allow Charm type to be valid for pokewalker if same PID result
Closes #3227
Thanks @HappyLappy1 !
2021-06-25 13:10:39 -07:00
sora10pls
285f86d7b2 Add squid distribution raids
You're a kid now, you're a squid now
2021-06-24 20:04:07 -04:00
Kurt
49488bb503 Use invariant culture for ToUpper/ToLower
Turkish is quite the language; let's try to prevent any errors down the road for internal/game string case changes.
2021-06-24 09:16:36 -07:00
Kurt
a10b35190c Minor tweaks
off by 1 max range for gen2 slot -> pk2
SetRandomIVs already sets IVs inside the method, retval is for knowing what the new value sare
show WC8 restricted version rather than defaulting to SH
pass the rand object rather than fetching for the current thread every loop for Unown & random IV shuffling
Use ToLowerInvariant for resource fetching, should resolve the turkish issue
Check typeof(T) first, not that we check for ToolStripItem or ContextMenuStrip with this function.
2021-06-24 00:36:04 -07:00
Kurt
401ab98f42 Fix inlined check 2021-06-22 23:30:40 -07:00
Kurt
3e7775fc44
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222)
* Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately

Don't store within the object, track the slot origin data separately.

Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty.

- Requesting a Box Data report now shows all slots in the save file (party, misc)
- Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely)
- Replace some linq usages with direct code

* Remove WasLink virtual in PKM

Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM.

* Use Fateful to directly check gen5 mysterygift origins

No other encounter types in gen5 apply Fateful

* Simplify double ball comparison

Used to be separate for deferral cases, now no longer needed to be separate.

* Grab move/relearn reference and update locally

Fix relearn move identifier

* Inline defog HM transfer preference check

HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly.

* Extract more met location metadata checks: WasBredEgg

* Replace Console.Write* with Debug.Write*

There's no console output UI, so don't include them in release builds.

* Inline WasGiftEgg, WasEvent, and WasEventEgg logic

Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-22 20:23:48 -07:00
Kurt
87ac1cbcc9 Unban Sgr7348 encounter 2021-06-18 22:07:27 -07:00
Kurt
a1ddbc7930 Add settings to use pkm tabs as criteria for Enc->PKM
Some encounters might not use the criteria completely, so it might not listen 100% of the time.
2021-06-14 20:26:12 -07:00
Kurt
652e9eb6da Add Eon Flute to observable used key items
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2021-06-13 00:59:06 -07:00
Kurt
6029c15521 Fix incorrect GameVersion reference 2021-06-09 22:56:19 -07:00
Kurt
f984862f48 Extract catchrate check 2021-06-09 22:54:21 -07:00
Kurt
2abf95cdf8 Minor clean
expand some expressions, extract some methods, add comments
2021-06-08 20:14:55 -07:00
Kurt
f7423daf7a Add array sanitization if error was thrown 2021-06-07 19:59:08 -07:00
Kurt
a07549f013 Extract sketch valid check
GetCanKnowMove should be checking for Smeargle knowing thousand arrows/waves.
GetNeededMoves should also return 1ka/1kw for needed moves, and then no encounters.

All uses of InvalidSketch are behind that method, so any future Smeargle modifications (like sketching a dummied move) will be checked (yay BDSP considerations).
2021-06-06 23:36:59 -07:00
Kurt
c98717bdc0 Fix namespaces 2021-06-06 23:34:15 -07:00
Lusamine
e66d5eaad5 Remove another duplicated distribution index
Index 24 is the same as 26, but they cross epochs from base to DLC1.
Keep the later one since it encompasses all legal Wild Areas.
2021-06-06 21:46:23 -05:00
Kurt
bad65dd4ec Enhance debugging obj->ToString indications for evo checks 2021-06-06 11:49:41 -07:00
Kurt
bf400f27fe Add optional form param for learn check 2021-06-06 11:49:13 -07:00
Kurt
200bdbd553 Sanity check form prior to yield checks 2021-06-06 11:48:54 -07:00
Lusamine
72b4975429 Remove inaccessible water nest encounters 2021-06-05 18:11:19 -05:00
Lusamine
aee35cbe81 Clean up duplicated distribution indices
Removes duplicates if every encounter in the same index is the same as a
previous index. The following were affected, and only the first index
was retained.

- 5, 7 (Index 2 has 1 move different on 1 mon)
- 3, 4
- 11, 13
- 16, 18
- 27, 28, 30, 32
- 33, 35
- 36, 38
- 42, 44
- 45, 47
- 48, 50, 52
- 53, 55, 57
- 59, 61
2021-06-05 16:33:41 -05:00
Kurt
ad79833420 Update EncounterEvent.cs 2021-06-04 13:53:02 -07:00
Kurt
8222297da8 Remove enumerating when loading event templates
Just allocate the parent array and pass it to HashSet; having an ICollection, prevents resizing repeatedly and gc'ing the temp array is cheap.

Actually, only create a hashset if we're adding a gift from external DB. Saves on that allocation, and keeps the final result as an array (fastest iterating).
2021-06-04 13:48:02 -07:00
Kurt
64039b4070 Force shiny state of raids
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2021-06-03 17:50:48 -07:00
Kurt
927ccee613 Cache all created regexes
Regex objects aren't cheap, and the RegexCache has DefaultMaxCacheSize = 15.

We're checking 4,000 regexes for each unique string, so just keep the created regexes around instead of cycling new through the cache.

+4MB passive consumption, but each IsFiltered call no longer generates >4MB of discarded objects.

My unit tests run >25% faster now... nice?!
2021-06-03 17:24:45 -07:00
Kurt
8ec25da194 Condense expression
single bool branch
2021-06-03 17:08:42 -07:00
sora10pls
a2492eddd9 Add Frog distribution raids 2021-06-03 20:07:07 -04:00
Kurt
8c970ec991 Minor tweaks
no functional change, readability++
add more xmldoc
2021-06-03 12:04:19 -07:00