Skip to content

Visible wild: roll the IVs right after the personality (PID/IV legality) - #266

Merged
ZallaxDev merged 1 commit into
ZallaxDev:integrationfrom
Johannes-Sch:fix/visible-wild-pid-iv
Nov 19, 2026
Merged

ZallaxDev merged 1 commit into
ZallaxDev:integrationfrom
Johannes-Sch:fix/visible-wild-pid-iv

Conversation

@Johannes-Sch

Copy link
Copy Markdown

Closes #265

Problem

A visible wild Pokémon rolls its personality (PID) when it appears, but its IVs only when the battle begins (VisibleStartBattle → CreateMon(..., USE_RANDOM_IVS, ...)), from a much later point of the generator. A wild Pokémon of the game takes both from consecutive random numbers (PID low, PID high, IV1, IV2: "Method 1"), and that is what PKHeX checks. So every visible one caught is flagged "PID+ correlation does not match what was expected for the Encounter's type", shiny or not.

Random encounters are fine: CreateMonWithNature rolls the IVs right after the last PID, also with the shiny odds setting.

Change

New topic patch 0093-visible-wild-pid-iv.patch (wild_encounter.c only):

  • VisibleRollIvs rolls the two IV words at once after VisibleRollPersonality. They are kept in struct VisibleWild.
  • VisibleSetIvs sets them on the enemy after CreateMon and recalculates the stats.

ShinyOdds_WildPersonality returns right after its last Random32(), so with the shiny odds setting the final PID and the IVs are still consecutive. In the devkitARM build Random32() takes the low half first, as Method 1 expects (checked in the disassembly).

Testing

On this branch (integration b85b012, English build), Azahar, Route 101, VISIBLE WILD = MANY, always catch on. Caught, saved, then checked the save with PKHeX.Core 25.12.21 (LegalityAnalysis):

Build Shiny odds Caught PKHeX
integration without the patch normal 3 3 illegal (PID+ correlation)
with the patch normal 4 4 legal, Method_1
with the patch until shiny 2 2 legal, Method_1, shiny in battle and in the save

A real save from v0.5.0 on hardware (German, about 28 h, visible wild on) also shows the problem: 34 of 66 Pokémon caught in Emerald fail with the same message. Random encounters and gifts pass.

  • make verify and release_audit.py --strict pass. On Windows, the tests that call cc needed a local stand-in for it.

Known limitations

  • Pokémon already caught keep their IVs. Only new catches are fixed.
  • Not tested on hardware. The change is only RNG order and two SetMonData calls, with nothing platform-specific.
  • Synchronize and Cute Charm still don't affect visible wild Pokémon, as before. That is not a legality issue.

Made with AI assistance; I reviewed the result and tested it in the emulator.

A visible wild Pokemon rolled its personality when it appeared but its IVs
only when the battle began, from a much later point of the generator. A wild
Pokemon of the game takes both from consecutive random numbers (PID low, PID
high, IV1, IV2: "Method 1"), and that pair is what PKHeX checks, so every
visible one caught was flagged "PID+ correlation does not match".

The IVs are now rolled at once after VisibleRollPersonality, kept with the
Pokemon and set on it when the battle begins. The shiny odds setting is
unaffected: its last roll is still the one right before the IVs.

Closes ZallaxDev#265

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ZallaxDev

Copy link
Copy Markdown
Owner

Thanks a lot, @Johannes-Sch! Generating the visible wild encounters' IVs with Method 1 fixes the overworld shiny mismatch, and all checks and our local RNG/encounter tests pass. Merging into integration.

@ZallaxDev
ZallaxDev merged commit 6699c19 into ZallaxDev:integration Nov 19, 2026
3 checks passed
@ZallaxDev ZallaxDev mentioned this pull request Nov 19, 2026
1 task done
DannyM90 added a commit to DannyM90/emerald-3ds that referenced this pull request Nov 19, 2026
…axDev#286 and the dev sync

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjZs53yVtumpNLmM8AycET
ZallaxDev added a commit that referenced this pull request Nov 21, 2026
- public_sync: an integration commit is held when each file has what it adds; changelog credits beside the pull requests' own entries
- Changelog: public pull requests #190 #209 #262-#300, by their authors
- public_sync: dev takes integration's ported pull requests as their own commits; a conflict or unported pull requests are problems, not a line
- Public export: the benchmark, profiling and macOS builder test tools (#293, #295, #300)
- Public export: upstream.lock's Python 3.15.2 and Pillow 13.0.0 (#288, #289)
- Harden Emerald 3DS runtime and builder workflows (#300)
- Replace deprecated Pillow pixel reads in voxel tools (#294)
- Add opt-in macOS standalone builder support (#295)
- Locales: move the Japanese span in main_menu.c past the main menu card (#298)
- Fly map: choose the destination with the +Control Pad (#267)
- Bottom screen: a tap on the map that slides a little still goes on with a message (#281)
- Summary: give the trainer memo room for a third line (#269)
- Summary: show Pokémon status icons (#270)
- Main menu: the saved game's trainer card on the top screen (#284)
- Restore Japanese naming marks and full touchscreen rows (#275)
- Speed up voxel generation to shorten development builds (#293)
- Release: ship bottom/menu_top.bin with the engine files (#280)
- Bag: planting a berry opens it in the bottom screen's window (#283)
- Frontier Pass map: the picture half as big again, filling its plate (#282)
- CI: support Ubuntu 26.04 with non-PIE sanitizer fixtures (#290)
- Startup: the data pack errors and the START hint in French and Italian (#209)
- Installation: step-by-step builder for Linux and macOS (#190)
- Bottom screen: reuse unchanged wild-list snapshots (#273)
- Upgrade release builds to Pillow 13.0.0 (#289)
- Naming screen: a tab turns straight to its page (#287)
- ci: upgrade GitHub Actions to latest tested releases (#292)
- Generate map event IDs for standalone voxel host tests (#277)
- Tests: update the voxel draft chunk fixture (#262)
- Harden native string formatting and numeric input parsing (#279)
- Build releases with Python 3.15.2 (#288)
- Visible wild: roll the IVs right after the personality (PID/IV legality) (#266)
- CI: use the release toolchain for 3DS builds (#286)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants