static void PickMove(UInt32 player, ref UInt32 move) { UInt32 Offset = 0; if (player == 1) { Offset = 0x1DD265; } else if (player == 2) { Offset = 0x1DD27D; } switch (Project64Watch.Read16(Offset)) { case 0x0101: //Attack / Switch / Run { if (rand.Next(10) == 0x00) //Switch Chance { PickPokemon(player, ref move, false); } else { PickAttack(player, ref move); } } break; case 0x0505: //Replace fainted Pokémon { PickPokemon(player, ref move, true); } break; } }
static void PickPokemon(UInt32 player, ref UInt32 move, Boolean forced) { UInt32 mon = 0; UInt32 moncount = 0; UInt32 activeteam = 0; UInt32 activespecies = 0; UInt32 activemon1 = 0; UInt32 activemon2 = 0; if (player == 1) { activeteam = 0xD1DC0; activespecies = 0x1DD237; activemon1 = 0xD1CF8; activemon2 = 0xD1D4C; } else if (player == 2) { activeteam = 0xD22A0; activespecies = 0x1DD24F; activemon1 = 0xD1D4C; activemon2 = 0xD1CF8; } if ((Project64Watch.Read8(activemon1 + 0x1B) == 0x00) && ((Project64Watch.Read8(activemon2 + 0x11) & 0x80) == 0x00) || forced) //not trapped from Wrap, Mean Look, etc. { for (uint i = 0; i < 3; i++) //check to see if we have more than 1 pokemon alive, otherwise can't switch. if forced switch then 1 pokemon left is possible { if (Project64Watch.Read16(activeteam + (0x58 * i) + 0x26) != 0x00) { moncount++; } } while ((moncount > 1) || forced) { mon = (uint)rand.Next(3); if ((Project64Watch.Read16(activeteam + (0x58 * mon) + 0x26) != 0x00) && (Project64Watch.Read8(activeteam + (0x58 * mon)) != Project64Watch.Read8(activespecies)))//if HP not 0 and not already active { break; } } if ((moncount > 1) || forced) { move = 5 + mon; } } }
static void DoMove(UInt32 player, UInt32 move, ref UInt32 input) { UInt32 Offset = 0x00; if (player == 1) { Offset = 0x1DD265; } else if (player == 2) { Offset = 0x1DD27D; } switch (Project64Watch.Read16(Offset)) { case 0x0101: //Attack / Switch / Run { switch (move) { case 1: case 2: case 3: case 4: { Project64Watch.SetInput(ref input, "A"); } break; case 5: case 6: case 7: { Project64Watch.SetInput(ref input, "B"); } break; } } break; case 0x0505: //Pick Pokemon Forced case 0x0501: //Pick Pokemon { switch (move) { case 5: { Project64Watch.SetInput(ref input, "C Left"); } break; case 6: { Project64Watch.SetInput(ref input, "C Up"); } break; case 7: { Project64Watch.SetInput(ref input, "C Right"); } break; } } break; case 0x0201: //Pick Move { switch (move) { case 1: { Project64Watch.SetInput(ref input, "C Up"); } break; case 2: { Project64Watch.SetInput(ref input, "C Right"); } break; case 3: { Project64Watch.SetInput(ref input, "C Down"); } break; case 4: { Project64Watch.SetInput(ref input, "C Left"); } break; } } break; } }