Jump to content

RainingChain

New Member
  • Posts

    6
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by RainingChain

  1. On 5/12/2023 at 10:35 PM, SupremeThunderDragon said:

    I'm not used to PKHeX so I'm likely doing something wrong or misunderstanding how the Event Flag Research works, but: in Crystal, I saved just before and after talking to Carrie, the Mystery Gift girl in green on floor 5 of the Goldenrod Dept Store. Talking to her is what unlocks the Mystery Gift option in the main menu. Placing the pre-Carrie and post-Carrie saves into the Researcher brings up nothing. Just the Alert "No Event Constant diff found."

    Am I using the Researcher wrong? It's not like I understand what the flags or constants mean. It's also possible that the Mystery Gift unlock isn't a flag, but I don't understand how that could be the case.

    Event Flag Research only searches in a small subset of the savefile where most events are stored. The flag used to determine whether you unlocked Mystery Gift is not located in that subset. In US savefiles, it is located at address 0x0BE3 (value is 0x00 if unlocked). Event flags tracked by the Researcher start at address 0x29F3.

    • Like 1
  2. On 9/10/2023 at 7:52 AM, SnorlaxMonster said:

    From the sounds of it, this research was all conducted on English Pokémon Stadium 2. Is it feasible that it could have been possible to obtain the exclusive decorations on Japanese Pokémon Stadium GS? (e.g. If in the localization process, they tweaked the probabilities of Mystery Gift items, but inadvertently made them impossible to obtain.)

    I just tested Mystery Gifts on Japanese version. The RNG function and the 4 consecutives check (< 36, < 72, < 72 < 77) are the same.

    I confirm that the Tentacool Doll and Pikachu Bed decorations can't be obtained on Japanese Pokémon Stadium either.

     

     

    Japan_DetermineDecoId.png

    Japan_DetermineDecoId1.png

    Japan_DetermineDecoId2.png

    • Like 2
  3. By using hacks, it is possible to receive Pikachu Bed, Unown Doll, and Tentacool Doll.

    In Pokemon Stadium 2 USA 1.0, place a breakpoint at command 0x801454F8 and alter the register V0 to 0x22 for Pikachu Bed, 0x23 for Unown Doll, or 0x24 for Tentacool Doll.

    Note that the Unown Doll is displayed as "DECORATION".

     

    Decoration_0.png

    Decoration_1.png

    HackBreakpoing.png

    PikachuBed_0.png

    PikachuBed_1.png

    TentacoolDoll_0.png

    TentacoolDoll_1.png

    • Like 2
  4. Here's what I've discovered about Mystery Gifts in Pokemon Stadium 2.

     

    Similarities with GameBoy Color Infra-Red Mystery Gifts

    The logic is the mostly the same between Pokemon Stadium 2 and Mystery Gift between GameBoy Color using infra-red system.

    The game chooses a random item and decoration separately. The game first tries to give the decoration but you already have that decoration, you will get the item instead.

    Choosing a specific item or decoration gift to send occurs in two stages. First, the game selects a set from which the gift will come. Then, it uses a part of the player's Trainer ID number to determine which gift from that set to send. (Below, bit 0 refers to the least significant bit of the Trainer ID and bit 15 refers to the most significant bit. Given the Trainer ID 32768, which translates to 1000000000000000 in binary, bit 15 is 1 and bit 0 is 0.)

    The logic for determining the item given is the same as the logic for Mystery Gift between GameBoy Color using infra-red system.

    See https://bulbapedia.bulbagarden.net/wiki/Mystery_Gift for more info.

     

    Decoration Logic

    The logic for determining decoration is different however.

    Random number.   Range     . Gift set                                          . Overall rate
    1st 36-255 Common 223/256
    0-35 N/A (pick a 2nd number)
    2nd 72-255 Uncommon 25/256
    0-71 N/A (pick a 3rd number)
    3rd 72-255 Rare 7/256
    0-71 N/A (pick a 4th number)
    4th 154-255 Very Rare 1/256
    77-153 Tentacool Doll 0/256
    0-76 Tentacool Doll or Pikachu Bed 0/256


    Common, Uncommon, Rare and Very Rare follows a similar logic as GameBoy Color Infra-Red Mystery Gifts (using Trainer ID). The exact bit used for each item and decoration is slightly different. Check https://bulbapedia.bulbagarden.net/wiki/Mystery_Gift for the detailed list.

    Upon reaching the 4th roll with 0-76, Tentacool Doll is given if Round 2 has not been unlocked and Pikachu Bed is given if Round 2 has been unlocked.

    No code exists to return Unown Doll (internal decoration ID 35). 

     

    Why Tentacool Doll and Pikachu Bed are unobtainable
    You may have noticed that Overall rate for Tentacool Doll and Pikachu Bed is 0/256. Here's why:

    To obtain Tentacool Doll, the game must roll 0-35, 0-71, 0-71, 0-153 (assuming Round 2 hasn't been unlocked).
    To obtain Pikachu Bed, the game must roll 0-35, 0-71, 0-71, 0-76 (assuming Round 2 has been unlocked).

    Those sequences of numbers are not possible.

    The game uses a 32-bit linear congruential generator: result = (seed * 0x19660D) + 0x3C6EF35F;

    Mystery Gift logic only uses the last 8 bits of the generated random number.

    The last 8 bits of the generator follows a cyclic pattern:
    0,95,50,233,52,3,134,45,168,231,26,177,92,11,238,117,80,111,2,121,132,19,86,189,248,247,234,65,172,27,190,5,160,127,210,9,212,35,38,77,72,7,186,209,252,43,142,149,240,143,162,153,36,51,246,221,152,23,138,97,76,59,94,37,64,159,114,41,116,67,198,109,232,39,90,241,156,75,46,181,144,175,66,185,196,83,150,253,56,55,42,129,236,91,254,69,224,191,18,73,20,99,102,141,136,71,250,17,60,107,206,213,48,207,226,217,100,115,54,29,216,87,202,161,140,123,158,101,128,223,178,105,180,131,6,173,40,103,154,49,220,139,110,245,208,239,130,249,4,147,214,61,120,119,106,193,44,155,62,133,32,255,82,137,84,163,166,205,200,135,58,81,124,171,14,21,112,15,34,25,164,179,118,93,24,151,10,225,204,187,222,165,192,31,242,169,244,195,70,237,104,167,218,113,28,203,174,53,16,47,194,57,68,211,22,125,184,183,170,1,108,219,126,197,96,63,146,201,148,227,230,13,8,199,122,145,188,235,78,85,176,79,98,89,228,243,182,157,88,215,74,33,12,251,30,229,0

    The first random number is selected randomly in that list, then at every new roll, the next random number is the next one in the list.

    The issue is that there are no 4 consecutive numbers that are 0-35, 0-71, 0-71, 0-153 respectively.
    This means Tentacool Doll (and Pikachu Bed) can't be obtained.

    The sequence to obtain a Very Rare decoration (0-35, 0-71, 0-71, 154-255) appears once (15,34,25,164).

     

    In short, none of the Pokemon Stadium 2 exclusive decorations are actually obtainable.

     

    Special thanks to Lincoln for providing the initial disassembly of Mystery Gift functions of Pokemon Stadium 2.
    https://github.com/Lincoln-LM/stad2


     

    • Like 2
  5. Hello,

    I figured out how RNG works in the Battle Subway in Pokemon Black 2 and White 2.

    I made a tool that predicts the trainer pokemons you'll face depending on your initial seed.

    The tool can also be used to determine the best time to boot the game in order to face 21 easy pokemons that you are guaranteed to defeat.

    For more information and download link, check:

    https://github.com/RainingChain/PokemonB2W2BattleSubwayRNG

    Special thanks to Admiral Fish for his PokeFinder project.

     

    Battle Subway RNG Mechanisms:

    The map where the player starts the Battle Subway has no wandering NPCs, which makes it perfect for RNG abuse.

    Battle Subway only uses PID RNG to determine trainers and pokemons.

    Upon loading the game, an initial seed and initial frame advance is determined based on the boot time, mac, ds type etc.

    Afterwards, when starting the battle subway, the player must save the game, which advances the RNG frame by 1.

    Then, the game selects 7 trainers. The game selects a pool of possible trainers based on the number of wins you'll have when reaching that trainer. The following info is for Super Single subway:

    0-5 wins: Trainers with IDs 110-159

    6-12 wins: Trainers with IDs 140-179

    13-19 wins: Trainers with IDs 160-199

    20-26 wins: Trainers with IDs 180-219

    27 wins: Trainers with IDs 200-239

    28-47 wins: Trainers with IDs 200-299

    48 wins: Trainers with ID 307 (Boss)

    49+ wins: Trainers with IDs 200-299

     

    The formula used is

    Idx = ((((seed >> 32) >> 16) + (seed >> 32)) >> 16) % NumberOfTrainers;

    If there is only 1 possible trainer (ex: at 48 wins), then the RNG frame is not advanced.

    If the selected trainer has already been selected, a new roll is performed until an unused trainer is generated.

     

    After selecting all 7 trainers, the player character moves inside the subway vehicle, which changes the map. Changing map after changing the DS clock date may trigger the daily event reset which will advance the RNG frame uncontrollably. This will cause pokemons predicted by the tool to be incorrect. Note that the trainer prediction is still valid because it was generated before changing map. To avoid this issue, change the DS clock, load the game, go outside, save the game, go inside, save the game again.

    After entering the vehicle, the pokemons of the first trainer are calculated.

    Each trainer has a list of possible pokemons. The same formula as the trainer is used.

    Idx = ((((seed >> 32) >> 16) + (seed >> 32)) >> 16) % NumberOfPokemons;

    If the selected pokemon has already been selected or if it has the same item as an already selected pokemon for that trainer, a new roll is performed until a valid pokemon is generated.

    After selecting all 3 pokemons, there is a 2-frames advance with unknown impact.

    Afterwards, the gender and ability for each pokemon is selected, according to this formula:

    AbilityIdx = (seed >> 32) % 2

    After that, there is a 6-frames avance with unknown impact (most likely battle setup?).

    During the battle, PID RNG is not advanced (thankfully!).

     

    After defeating the first trainer, the 3 pokemons of the next trainer is calculated with the same formula, all the way until the 7th trainer.

     

    If you have any questions, you can contact me on Discord, RainingChain.

     

    • Like 1
×
×
  • Create New...