diff --git a/include/battle/btlcmd.h b/include/battle/btlcmd.h index 3848dd2327..c444f6bcb1 100644 --- a/include/battle/btlcmd.h +++ b/include/battle/btlcmd.h @@ -92,7 +92,7 @@ enum BattleScriptVars { #define BTLSCR_MSG_DEFENDER 15 #define BTLSCR_ATTACKER_PARTNER 16 #define BTLSCR_DEFENDER_PARTNER 17 -// 18 undefined +#define BTLSCR_FORCED_OUT 18 #define BTLSCR_ATTACKER_ENEMY 19 #define BTLSCR_DEFENDER_ENEMY 20 #define BTLSCR_MSG_BATTLER_TEMP 21 diff --git a/include/battle/common.h b/include/battle/common.h index 6a114f318c..8779765d80 100644 --- a/include/battle/common.h +++ b/include/battle/common.h @@ -55,6 +55,8 @@ #define WEATHER_IS_SUN (battleCtx->fieldConditionsMask & FIELD_CONDITION_SUNNY) #define WEATHER_IS_HAIL (battleCtx->fieldConditionsMask & FIELD_CONDITION_HAILING) +#define FLAG_NEGATE(flag) ((flag) ^ 0xFFFFFFFF) + enum { BATTLE_STAT_HP, BATTLE_STAT_ATTACK, diff --git a/include/constants/battle.h b/include/constants/battle.h index 6bb74e6bc8..9f37fcc573 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -29,6 +29,8 @@ #define BATTLE_TYPE_NO_AI_ITEMS (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_SAFARI | BATTLE_TYPE_AI | BATTLE_TYPE_PAL_PARK) #define BATTLE_TYPE_NO_MOVES (BATTLE_TYPE_SAFARI | BATTLE_TYPE_PAL_PARK) #define BATTLE_TYPE_NO_EXPERIENCE (BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_PAL_PARK) +#define BATTLE_TYPE_NO_ABILITIES (BATTLE_TYPE_SAFARI | BATTLE_TYPE_PAL_PARK) +#define BATTLE_TYPE_2vs2_TAG (BATTLE_TYPE_2vs2 | BATTLE_TYPE_TAG) #define MAX_LINK_BATTLERS 4 #define MAX_BATTLERS 4 diff --git a/include/constants/battle/moves.h b/include/constants/battle/moves.h index 30cdf1fff7..174254f5d6 100644 --- a/include/constants/battle/moves.h +++ b/include/constants/battle/moves.h @@ -1,6 +1,7 @@ #ifndef POKEPLATINUM_CONSTANTS_BATTLE_MOVES_H #define POKEPLATINUM_CONSTANTS_BATTLE_MOVES_H +#define MOVE_EFFECT_NONE 0 #define MOVE_EFFECT_LEECH_SEED_RECIPIENT ((1 << 0) | (1 << 1)) // each bit defines which opponent receives the healing effect #define MOVE_EFFECT_LEECH_SEED (1 << 2) #define MOVE_EFFECT_LOCK_ON ((1 << 3) | (1 << 4)) // counter for the number of Lock On turns remaining @@ -34,10 +35,26 @@ | MOVE_EFFECT_UNDERGROUND \ | MOVE_EFFECT_UNDERWATER \ | MOVE_EFFECT_SHADOW_FORCE) +#define MOVE_EFFECT_BATON_PASSED (MOVE_EFFECT_LEECH_SEED_RECIPIENT \ + | MOVE_EFFECT_LEECH_SEED \ + | MOVE_EFFECT_LOCK_ON \ + | MOVE_EFFECT_PERISH_SONG \ + | MOVE_EFFECT_INGRAIN \ + | MOVE_EFFECT_MUD_SPORT \ + | MOVE_EFFECT_WATER_SPORT \ + | MOVE_EFFECT_NO_CRITICAL \ + | MOVE_EFFECT_POWER_TRICK \ + | MOVE_EFFECT_AQUA_RING \ + | MOVE_EFFECT_ABILITY_SUPPRESSED \ + | MOVE_EFFECT_EMBARGO \ + | MOVE_EFFECT_HEAL_BLOCK \ + | MOVE_EFFECT_MAGNET_RISE) #define MOVE_EFFECT_LOCK_ON_SHIFT 3 #define MOVE_EFFECT_YAWN_SHIFT 11 +#define MOVE_EFFECT_LOCK_ON_INITIAL_DURATION (1 << (MOVE_EFFECT_LOCK_ON_SHIFT + 1)) + #define MOVE_STATUS_MISSED (1 << 0) #define MOVE_STATUS_SUPER_EFFECTIVE (1 << 1) #define MOVE_STATUS_NOT_VERY_EFFECTIVE (1 << 2) diff --git a/include/constants/battle/system_control.h b/include/constants/battle/system_control.h index b699681539..907d517784 100644 --- a/include/constants/battle/system_control.h +++ b/include/constants/battle/system_control.h @@ -9,6 +9,7 @@ #define SYSCTL_FIRST_OF_MULTI_TURN (1 << 5) // this could be a charge-up move or Bide #define SYSCTL_SKIP_SPRITE_BLINK (1 << 6) #define SYSCTL_TRY_SYNCHRONIZE_STATUS (1 << 7) +#define SYSCTL_BATON_PASS (1 << 8) #define SYSCTL_LAST_OF_MULTI_TURN (1 << 9) #define SYSCTL_NONSTANDARD_ACC_CHECK (1 << 10) // used by Future Sight and OHKO moves #define SYSCTL_MOVE_HIT (1 << 13) // this indicates that the move hit its target(s) @@ -28,8 +29,10 @@ #define SYSCTL_MAGIC_COAT_REFLECTED (1 << 3) #define SYSCTL_UTURN_ACTIVE (1 << 4) #define SYSCTL_MOVE_SUCCEEDED (1 << 6) // this only reflects that the move is executed, not whether it hit or missed +#define SYSCTL_LINK_WAITING ((1 << 24) | (1 << 25) | (1 << 26) | (1 << 27)) #define SYSCTL_PAYOUT_EXP ((1 << 28) | (1 << 29) | (1 << 30) | (1 << 31)) +#define SYSCTL_LINK_WAITING_SHIFT 24 #define SYSCTL_PAYOUT_EXP_SHIFT 28 #define SYSCTL_SKIP_OBEDIENCE_CHECK (1 << 0) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index cf74c0f5a4..050aac68e4 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -139,7 +139,7 @@ enum PokemonDataParam { MON_DATA_SPATK_IV, MON_DATA_SPDEF_IV, MON_DATA_IS_EGG, - MON_DATA_77, + MON_DATA_HAS_NICKNAME, MON_DATA_78, MON_DATA_79, MON_DATA_80, @@ -179,7 +179,7 @@ enum PokemonDataParam { MON_DATA_114, MON_DATA_115, MON_DATA_116, - MON_DATA_117, + MON_DATA_NICKNAME, MON_DATA_118, MON_DATA_119, MON_DATA_120, @@ -206,7 +206,7 @@ enum PokemonDataParam { MON_DATA_141, MON_DATA_142, MON_DATA_143, - MON_DATA_144, + MON_DATA_OTNAME, MON_DATA_145, MON_DATA_146, MON_DATA_147, @@ -222,7 +222,7 @@ enum PokemonDataParam { MON_DATA_OT_GENDER, MON_DATA_158, MON_DATA_159, - MON_DATA_160, + MON_DATA_STATUS_CONDITION, MON_DATA_LEVEL, MON_DATA_162, MON_DATA_CURRENT_HP, @@ -239,8 +239,8 @@ enum PokemonDataParam { MON_DATA_SPECIES_EGG, MON_DATA_COMBINED_IVS, MON_DATA_176, - MON_DATA_177, - MON_DATA_178, + MON_DATA_TYPE_1, + MON_DATA_TYPE_2, MON_DATA_179, }; diff --git a/include/overlay016/ov16_0223DF00.h b/include/overlay016/ov16_0223DF00.h index 0dea324852..d3d6a7e3e3 100644 --- a/include/overlay016/ov16_0223DF00.h +++ b/include/overlay016/ov16_0223DF00.h @@ -207,7 +207,7 @@ void ov16_0223F4B0(BattleSystem * param0, int param1); u16 BattleSystem_RandNext(BattleSystem * param0); u32 ov16_0223F4E8(BattleSystem * param0); void ov16_0223F4F4(BattleSystem * param0, u32 param1); -void ov16_0223F500(BattleSystem * param0, int param1, u8 param2); +void BattleSystem_Record(BattleSystem * param0, int param1, u8 param2); BOOL ov16_0223F530(BattleSystem * param0, int param1, u8 * param2); u8 ov16_0223F58C(BattleSystem * param0, u8 * param1); void ov16_0223F638(BattleSystem * param0, u16 param1, u8 * param2); diff --git a/include/overlay016/ov16_0225177C.h b/include/overlay016/ov16_0225177C.h index f516549434..566a4fa545 100644 --- a/include/overlay016/ov16_0225177C.h +++ b/include/overlay016/ov16_0225177C.h @@ -141,8 +141,35 @@ enum CountAbilityMode { COUNT_ALIVE_BATTLERS_EXCEPT_ME, //< Count all alive battlers except for me which have the ability }; -void BattleSystem_InitBattleMon(BattleSystem *battleSys, BattleContext *battleCtx, int param2, int param3); -void BattleSystem_ReloadPokemon(BattleSystem * param0, BattleContext * param1, int param2, int param3); +/** + * @brief Initialize a BattleMon from the Pokemon in the given battler's party, + * from the given party slot. + * + * @param battleSys + * @param battleCtx + * @param battler The battler whose party will be read from + * @param partySlot The slot in the party to retrieve + */ +void BattleSystem_InitBattleMon(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot); + +/** + * @brief Reload a BattleMon from the given battler's party, from the given + * party slot. + * + * Specifically, this will only reload the following fields: + * + * - battle stats (attack, defense, etc.) + * - level + * - friendship + * - move known in each slot + * - total experience + * + * @param battleSys + * @param battleCtx + * @param battler The battler whose party will be read from + * @param partySlot The slot in the party to retrieve + */ +void BattleSystem_ReloadPokemon(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot); /** * @brief Load a script file from the specified NARC. @@ -237,7 +264,22 @@ int ov16_02253F7C(BattleContext * param0, int param1); BOOL BattleSystem_CheckTrainerMessage(BattleSystem * param0, BattleContext * param1); void BattleContext_Init(BattleContext * param0); void BattleContext_InitCounters(BattleSystem * param0, BattleContext * param1); -void ov16_0225433C(BattleSystem * param0, BattleContext * param1, int param2); + +/** + * @brief Update relevant buffers for a battler after a switch. + * + * This handles all of the logic for what effects are zero'd out due to a + * switch, as well as what effects are transferred across a switch due to + * Baton Pass. + * + * This routine will update the battler's chosen command to be MOVE_END, which + * functionally ends their turn. + * + * @param battleSys + * @param battleCtx + * @param battler The switching battler + */ +void BattleSystem_UpdateAfterSwitch(BattleSystem *battleSys, BattleContext *battleCtx, int battler); /** * @brief Cleanup lingering state according to the given battler. @@ -409,6 +451,16 @@ BOOL BattleSystem_TrainerIsOT(BattleSystem * param0, BattleContext * param1); BOOL BattleSystem_PokemonIsOT(BattleSystem * param0, Pokemon * param1); BOOL BattleSystem_UpdateWeatherForms(BattleSystem * param0, BattleContext * param1, int * param2); void ov16_0225A1B0(BattleSystem * param0, BattleContext * param1); + +/** + * @brief Switch the party order by swapping the battler in the given party slot + * with an active slot. + * + * @param battleSys + * @param battleCtx + * @param battler The battler who is switching + * @param partySlot The party slot which should be moved to an active slot + */ void BattleSystem_SwitchSlots(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot); /** diff --git a/include/overlay021/struct_ov21_021D3320.h b/include/overlay021/struct_ov21_021D3320.h index ff978fe62f..76732d8f9b 100644 --- a/include/overlay021/struct_ov21_021D3320.h +++ b/include/overlay021/struct_ov21_021D3320.h @@ -15,7 +15,7 @@ typedef struct { int unk_173C; int unk_1740; int unk_1744; - UnkStruct_02098700 * unk_1748; + HeightWeightData * unk_1748; u32 unk_174C; u32 unk_1750; Strbuf* unk_1754; diff --git a/include/struct_decls/struct_02098700_decl.h b/include/struct_decls/struct_02098700_decl.h index 7010a801fc..b76a91f20c 100644 --- a/include/struct_decls/struct_02098700_decl.h +++ b/include/struct_decls/struct_02098700_decl.h @@ -1,6 +1,6 @@ #ifndef POKEPLATINUM_STRUCT_02098700_DECL_H #define POKEPLATINUM_STRUCT_02098700_DECL_H -typedef struct UnkStruct_02098700_t UnkStruct_02098700; +typedef struct HeightWeightData HeightWeightData; #endif // POKEPLATINUM_STRUCT_02098700_DECL_H diff --git a/include/struct_defs/struct_0207F248.h b/include/struct_defs/struct_0207F248.h index 327c73f63b..bf355c262f 100644 --- a/include/struct_defs/struct_0207F248.h +++ b/include/struct_defs/struct_0207F248.h @@ -60,7 +60,7 @@ typedef struct { u8 unk_B12; u8 unk_B13; u16 unk_B14[6]; - UnkStruct_02098700 * unk_B20; + HeightWeightData * unk_B20; UnkStruct_ov118_021D0FDC * unk_B24; UnkStruct_0207C690 * unk_B28; } UnkStruct_0207F248; diff --git a/include/unk_0207A2A8.h b/include/unk_0207A2A8.h index 061a7732d0..2cbb15c36a 100644 --- a/include/unk_0207A2A8.h +++ b/include/unk_0207A2A8.h @@ -6,10 +6,10 @@ #include "struct_decls/struct_party_decl.h" #include "struct_decls/struct_02098700_decl.h" -UnkStruct_02098700 * sub_0207A2A8(int param0); -void sub_0207A2C0(UnkStruct_02098700 * param0); -BOOL sub_0207A2D0(const UnkStruct_0202610C * param0, Pokemon * param1, const UnkStruct_02098700 * param2); -int sub_0207A3AC(const UnkStruct_0202610C * param0, Party * param1, const UnkStruct_02098700 * param2, u8 * param3); -int sub_0207A594(const UnkStruct_0202610C * param0, Party * param1, const UnkStruct_02098700 * param2); +HeightWeightData * sub_0207A2A8(int param0); +void sub_0207A2C0(HeightWeightData * param0); +BOOL sub_0207A2D0(const UnkStruct_0202610C * param0, Pokemon * param1, const HeightWeightData * param2); +int sub_0207A3AC(const UnkStruct_0202610C * param0, Party * param1, const HeightWeightData * param2, u8 * param3); +int sub_0207A594(const UnkStruct_0202610C * param0, Party * param1, const HeightWeightData * param2); #endif // POKEPLATINUM_UNK_0207A2A8_H diff --git a/include/unk_02098700.h b/include/unk_02098700.h index 053d7e199f..505111637e 100644 --- a/include/unk_02098700.h +++ b/include/unk_02098700.h @@ -3,15 +3,15 @@ #include "struct_decls/struct_02098700_decl.h" -UnkStruct_02098700 * sub_02098700(int param0); -void sub_02098718(UnkStruct_02098700 * param0); -void sub_0209872C(UnkStruct_02098700 * param0, int param1, int param2); -void sub_020987BC(UnkStruct_02098700 * param0); -int sub_02098808(const UnkStruct_02098700 * param0, int param1); -int sub_02098828(const UnkStruct_02098700 * param0, int param1); -short sub_02098848(const UnkStruct_02098700 * param0, int param1); -short sub_02098868(const UnkStruct_02098700 * param0, int param1); -short sub_02098888(const UnkStruct_02098700 * param0, int param1); -short sub_020988A8(const UnkStruct_02098700 * param0, int param1); +HeightWeightData * Pokedex_HeightWeightData(int param0); +void Pokedex_HeightWeightData_Free(HeightWeightData * param0); +void Pokedex_HeightWeightData_Load(HeightWeightData * param0, int param1, int param2); +void Pokedex_HeightWeightData_Release(HeightWeightData * param0); +int sub_02098808(const HeightWeightData * param0, int param1); +int Pokedex_HeightWeightData_Weight(const HeightWeightData * param0, int param1); +short sub_02098848(const HeightWeightData * param0, int param1); +short sub_02098868(const HeightWeightData * param0, int param1); +short sub_02098888(const HeightWeightData * param0, int param1); +short sub_020988A8(const HeightWeightData * param0, int param1); #endif // POKEPLATINUM_UNK_02098700_H diff --git a/include/unk_02098988.h b/include/unk_02098988.h index 4feac726a4..448cae5584 100644 --- a/include/unk_02098988.h +++ b/include/unk_02098988.h @@ -1,7 +1,7 @@ #ifndef POKEPLATINUM_UNK_02098988_H #define POKEPLATINUM_UNK_02098988_H -void sub_02098988(u32 param0); +void Pokedex_SetupGiratina(u32 param0); u32 sub_020989B8(void); u32 sub_020989C4(void); u32 sub_020989D0(void); diff --git a/src/overlay005/ov5_021E622C.c b/src/overlay005/ov5_021E622C.c index b330e37495..71380eb307 100644 --- a/src/overlay005/ov5_021E622C.c +++ b/src/overlay005/ov5_021E622C.c @@ -2029,7 +2029,7 @@ static void ov5_021E62C4 (Party * param0, int param1, UnkStruct_02026218 * param TrainerInfo * v6 = sub_02025E38(param3); v2 = TrainerInfo_Name(v6); - Pokemon_GetValue(v1, MON_DATA_117, v3); + Pokemon_GetValue(v1, MON_DATA_NICKNAME, v3); if (ov5_021E62B0(Pokemon_GetBoxPokemon(v1))) { Pokemon_GetValue(v1, MON_DATA_170, sub_02026230(v4)); @@ -2969,7 +2969,7 @@ void ov5_021E7308 (UnkStruct_02026310 * param0, u32 param1, u32 param2, u32 para if (v3 != 2) { v4 = BoxPokemon_GetValue(v1, MON_DATA_SPECIES, NULL); - if (((v4 == 29) || (v4 == 32)) && (BoxPokemon_GetValue(v1, MON_DATA_77, NULL) == 0)) { + if (((v4 == 29) || (v4 == 32)) && (BoxPokemon_GetValue(v1, MON_DATA_HAS_NICKNAME, NULL) == 0)) { v3 = 2; } } diff --git a/src/overlay005/ov5_021EE7D4.c b/src/overlay005/ov5_021EE7D4.c index 3fd5fd84f1..e274414ecf 100644 --- a/src/overlay005/ov5_021EE7D4.c +++ b/src/overlay005/ov5_021EE7D4.c @@ -82,14 +82,14 @@ static u32 ov5_021EE8A8 (u16 param0, u16 param1) u32 v3; u64 v4; u8 v5; - UnkStruct_02098700 * v6; + HeightWeightData * v6; - v6 = sub_02098700(4); - sub_0209872C(v6, 0, 4); + v6 = Pokedex_HeightWeightData(4); + Pokedex_HeightWeightData_Load(v6, 0, 4); - v3 = sub_02098808((const UnkStruct_02098700 *)v6, param0); - sub_020987BC(v6); - sub_02098718(v6); + v3 = sub_02098808((const HeightWeightData *)v6, param0); + Pokedex_HeightWeightData_Release(v6); + Pokedex_HeightWeightData_Free(v6); v5 = ov5_021EE880(param1); v0 = Unk_ov5_021FF508[v5].unk_00; diff --git a/src/overlay006/ov6_02246034.c b/src/overlay006/ov6_02246034.c index 21a9862cad..c90a48f21e 100644 --- a/src/overlay006/ov6_02246034.c +++ b/src/overlay006/ov6_02246034.c @@ -40,7 +40,7 @@ void ov6_02246034 (UnkStruct_0203CDB0 * param0, BattleParams * param1) if (v4 != NULL) { v0 = (u16)(Pokemon_GetValue(v6, MON_DATA_CURRENT_HP, NULL)); - v1 = (u8)(Pokemon_GetValue(v6, MON_DATA_160, NULL)); + v1 = (u8)(Pokemon_GetValue(v6, MON_DATA_STATUS_CONDITION, NULL)); if (((param1->unk_14 == 0x1) && (v0 == 0))) { sub_0202D914(&v4); diff --git a/src/overlay007/ov7_0224B4E8.c b/src/overlay007/ov7_0224B4E8.c index a6fec54a12..6037084d90 100644 --- a/src/overlay007/ov7_0224B4E8.c +++ b/src/overlay007/ov7_0224B4E8.c @@ -54,7 +54,7 @@ typedef struct { Window unk_54; UnkStruct_0200B358 * unk_64; MessageLoader * unk_68; - UnkStruct_02098700 * unk_6C; + HeightWeightData * unk_6C; u16 * unk_70; int unk_74; u16 unk_78; diff --git a/src/overlay013/ov13_0221FC20.c b/src/overlay013/ov13_0221FC20.c index 836813ddef..a397d553d0 100644 --- a/src/overlay013/ov13_0221FC20.c +++ b/src/overlay013/ov13_0221FC20.c @@ -1219,8 +1219,8 @@ static void ov13_02220F98 (UnkStruct_ov13_022213F0 * param0) param0->unk_04[v0].unk_0E = Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_SP_DEF, NULL); param0->unk_04[v0].unk_10 = Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_CURRENT_HP, NULL); param0->unk_04[v0].unk_12 = Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_MAX_HP, NULL); - param0->unk_04[v0].unk_14 = (u8)Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_177, NULL); - param0->unk_04[v0].unk_15 = (u8)Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_178, NULL); + param0->unk_04[v0].unk_14 = (u8)Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_TYPE_1, NULL); + param0->unk_04[v0].unk_15 = (u8)Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_TYPE_2, NULL); param0->unk_04[v0].unk_16_0 = (u8)Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_LEVEL, NULL); if (Pokemon_GetValue(param0->unk_04[v0].unk_00, MON_DATA_176, NULL) == 1) { diff --git a/src/overlay014/ov14_0221FC20.c b/src/overlay014/ov14_0221FC20.c index b8c0dfdef9..6aea891e5e 100644 --- a/src/overlay014/ov14_0221FC20.c +++ b/src/overlay014/ov14_0221FC20.c @@ -1556,7 +1556,7 @@ static void ov14_022211AC (BattleSystem * param0, BattleContext * param1) for (v2 = 0; v2 < BattleSystem_PartyCount(param0, v3); v2++) { v1 = Party_GetPokemonBySlotIndex(v0, v2); - if ((v2 != v4) && (v2 != v5) && (Pokemon_GetValue(v1, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 494) && (Pokemon_GetValue(v1, MON_DATA_160, NULL) & v7)) { + if ((v2 != v4) && (v2 != v5) && (Pokemon_GetValue(v1, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 494) && (Pokemon_GetValue(v1, MON_DATA_STATUS_CONDITION, NULL) & v7)) { ov14_02222D24(param1, v8); return; } @@ -1593,7 +1593,7 @@ static void ov14_022212A0 (BattleSystem * param0, BattleContext * param1) for (v2 = 0; v2 < BattleSystem_PartyCount(param0, v3); v2++) { v1 = Party_GetPokemonBySlotIndex(v0, v2); - if ((v2 != v4) && (v2 != v5) && (Pokemon_GetValue(v1, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 494) && ((Pokemon_GetValue(v1, MON_DATA_160, NULL) & v7) == 0)) { + if ((v2 != v4) && (v2 != v5) && (Pokemon_GetValue(v1, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) != 494) && ((Pokemon_GetValue(v1, MON_DATA_STATUS_CONDITION, NULL) & v7) == 0)) { ov14_02222D24(param1, v8); return; } @@ -3760,7 +3760,7 @@ static BOOL ov14_02223E10 (BattleSystem * param0, BattleContext * param1, int pa v6 = 0; v5 = ov14_0222327C(param0, param1, param1->moveHitBattler[param2], param1->moveHit[param2]); - ov16_022552D4(param1, param1->moveHit[param2], v5, Battler_Ability(param1, param1->moveHitBattler[param2]), Pokemon_GetValue(v9, MON_DATA_ABILITY, NULL), BattleSystem_GetItemData(param1, Pokemon_GetValue(v9, MON_DATA_HELD_ITEM, NULL), 1), Pokemon_GetValue(v9, MON_DATA_177, NULL), Pokemon_GetValue(v9, MON_DATA_178, NULL), &v6); + ov16_022552D4(param1, param1->moveHit[param2], v5, Battler_Ability(param1, param1->moveHitBattler[param2]), Pokemon_GetValue(v9, MON_DATA_ABILITY, NULL), BattleSystem_GetItemData(param1, Pokemon_GetValue(v9, MON_DATA_HELD_ITEM, NULL), 1), Pokemon_GetValue(v9, MON_DATA_TYPE_1, NULL), Pokemon_GetValue(v9, MON_DATA_TYPE_2, NULL), &v6); if (v6 & param3) { for (v1 = 0; v1 < 4; v1++) { diff --git a/src/overlay016/battle_controller.c b/src/overlay016/battle_controller.c index 7ed58f5446..bbddb61f82 100644 --- a/src/overlay016/battle_controller.c +++ b/src/overlay016/battle_controller.c @@ -4877,33 +4877,33 @@ static void BattleSystem_RecordCommand (BattleSystem *battleSys, BattleContext * if (battleCtx->battlerActions[v0][0] != 39) { if (battleCtx->recordedCommandFlags[v0] & 0x1) { v2 = (battleCtx->battlerActions[v0][0] - 13) + 1; - ov16_0223F500(battleSys, v0, v2); + BattleSystem_Record(battleSys, v0, v2); } switch (battleCtx->battlerActions[v0][0]) { case 13: if (battleCtx->recordedCommandFlags[v0] & 0x2) { v2 = battleCtx->battlerActions[v0][2]; - ov16_0223F500(battleSys, v0, v2); + BattleSystem_Record(battleSys, v0, v2); } if (battleCtx->recordedCommandFlags[v0] & 0x4) { v2 = battleCtx->battlerActions[v0][1] + 1; - ov16_0223F500(battleSys, v0, v2); + BattleSystem_Record(battleSys, v0, v2); } break; case 14: v2 = battleCtx->battlerActions[v0][2] & 0xff; - ov16_0223F500(battleSys, v0, v2); + BattleSystem_Record(battleSys, v0, v2); v2 = (battleCtx->battlerActions[v0][2] & 0xff00) >> 16; - ov16_0223F500(battleSys, v0, v2); + BattleSystem_Record(battleSys, v0, v2); break; case 15: v2 = battleCtx->battlerActions[v0][2] + 1; - ov16_0223F500(battleSys, v0, v2); + BattleSystem_Record(battleSys, v0, v2); break; case 16: - ov16_0223F500(battleSys, v0, 1); + BattleSystem_Record(battleSys, v0, 1); break; default: break; diff --git a/src/overlay016/battle_script.c b/src/overlay016/battle_script.c index 42ab37c916..20120e9817 100644 --- a/src/overlay016/battle_script.c +++ b/src/overlay016/battle_script.c @@ -144,10 +144,10 @@ static BOOL BtlCmd_CalcExpGain(BattleSystem *battleSys, BattleContext *battleCtx static BOOL BtlCmd_StartGetExpTask(BattleSystem *battleSys, BattleContext *battleCtx); static BOOL BtlCmd_WaitGetExpTask(BattleSystem *battleSys, BattleContext *battleCtx); static BOOL BtlCmd_Dummy2A(BattleSystem *battleSys, BattleContext *battleCtx); -static BOOL ov16_02241F34(BattleSystem * param0, BattleContext * param1); -static BOOL ov16_0224200C(BattleSystem * param0, BattleContext * param1); -static BOOL ov16_02242134(BattleSystem * param0, BattleContext * param1); -static BOOL ov16_022421D4(BattleSystem * param0, BattleContext * param1); +static BOOL BtlCmd_ShowPartyList(BattleSystem *battleSys, BattleContext *battleCtx); +static BOOL BtlCmd_WaitPartyList(BattleSystem *battleSys, BattleContext *battleCtx); +static BOOL BtlCmd_Switch(BattleSystem *battleSys, BattleContext *battleCtx); +static BOOL BtlCmd_JumpIfAnySwitches(BattleSystem *battleSys, BattleContext *battleCtx); static BOOL ov16_0224221C(BattleSystem * param0, BattleContext * param1); static BOOL ov16_0224226C(BattleSystem * param0, BattleContext * param1); static BOOL ov16_02242298(BattleSystem * param0, BattleContext * param1); @@ -404,10 +404,10 @@ static const BtlCmd sBattleCommands[] = { BtlCmd_StartGetExpTask, BtlCmd_WaitGetExpTask, BtlCmd_Dummy2A, - ov16_02241F34, - ov16_0224200C, - ov16_02242134, - ov16_022421D4, + BtlCmd_ShowPartyList, + BtlCmd_WaitPartyList, + BtlCmd_Switch, + BtlCmd_JumpIfAnySwitches, ov16_0224221C, ov16_0224226C, ov16_02242298, @@ -2593,147 +2593,189 @@ static BOOL BtlCmd_Dummy2A(BattleSystem *battleSys, BattleContext *battleCtx) return FALSE; } -static BOOL ov16_02241F34 (BattleSystem * param0, BattleContext * param1) +/** + * @brief Show the party list. + * + * This command explicitly does not allow the player to cancel switching; + * it should be invoked only when a switch is _forced_ and cannot be undone. + * + * @param battleSys + * @param battleCtx + * @return FALSE + */ +static BOOL BtlCmd_ShowPartyList(BattleSystem *battleSys, BattleContext *battleCtx) { - int v0; - int v1; - int v2; - int v3 = BattleSystem_MaxBattlers(param0); + int maxBattlers = BattleSystem_MaxBattlers(battleSys); - BattleScript_Iter(param1, 1); + BattleScript_Iter(battleCtx, 1); - v2 = 0; + int switchingMask = 0; - for (v0 = 0; v0 < v3; v0++) { - if (param1->battlerStatusFlags[v0] & 0x1) { - v2 |= FlagIndex(v0); - BattleIO_ShowPartyScreen(param0, param1, v0, 1, 0, 6); + int battler; + for (battler = 0; battler < maxBattlers; battler++) { + if (battleCtx->battlerStatusFlags[battler] & BATTLER_STATUS_SWITCHING) { + switchingMask |= FlagIndex(battler); + BattleIO_ShowPartyScreen(battleSys, battleCtx, battler, 1, 0, 6); } } - for (v0 = 0; v0 < v3; v0++) { - if (BattleSystem_BattleType(param0) == ((0x4 | 0x1) | 0x2)) { - v1 = BattleSystem_Partner(param0, v0); - - if (((v2 & FlagIndex(v0)) == 0) && ((v2 & FlagIndex(v1)) == 0)) { - v2 |= FlagIndex(v0); - BattleIO_LinkWaitMessage(param0, v0); - } - } else { - if ((v2 & FlagIndex(v0)) == 0) { - BattleIO_LinkWaitMessage(param0, v0); + for (battler = 0; battler < maxBattlers; battler++) { + if (BattleSystem_BattleType(battleSys) == BATTLE_TYPE_LINK_DOUBLES) { + // If both battlers are done selecting replacements, wait for all other battlers + int partner = BattleSystem_Partner(battleSys, battler); + if ((switchingMask & FlagIndex(battler)) == FALSE + && (switchingMask & FlagIndex(partner)) == FALSE) { + switchingMask |= FlagIndex(battler); + BattleIO_LinkWaitMessage(battleSys, battler); } + } else if ((switchingMask & FlagIndex(battler)) == FALSE) { + BattleIO_LinkWaitMessage(battleSys, battler); } } - for (v0 = 0; v0 < v3; v0++) { - if (param1->battlerStatusFlags[v0] & 0x1) { - param1->switchedMon = v0; + for (battler = 0; battler < maxBattlers; battler++) { + if (battleCtx->battlerStatusFlags[battler] & BATTLER_STATUS_SWITCHING) { + battleCtx->switchedMon = battler; break; } } - return 0; + return FALSE; } -static BOOL ov16_0224200C (BattleSystem * param0, BattleContext * param1) +/** + * @brief Wait for all battlers in the midst of selecting replacement battlers + * to finish selecting their replacements. + * + * @param battleSys + * @param battleCtx + * @return FALSE + */ +static BOOL BtlCmd_WaitPartyList(BattleSystem *battleSys, BattleContext *battleCtx) { - int v0; - int v1; - int v2; - - v1 = BattleSystem_MaxBattlers(param0); - v2 = 0; + int maxBattlers = BattleSystem_MaxBattlers(battleSys); + int totalSwitching = 0; - for (v0 = 0; v0 < v1; v0++) { - if (param1->battlerStatusFlags[v0] & 0x1) { - v2++; + int battler; + for (battler = 0; battler < maxBattlers; battler++) { + if (battleCtx->battlerStatusFlags[battler] & BATTLER_STATUS_SWITCHING) { + totalSwitching++; } } - for (v0 = 0; v0 < v1; v0++) { - if ((param1->battlerStatusFlags[v0] & 0x1) && (BattleContext_IOBufferVal(param1, v0))) { - param1->switchedPartySlot[v0] = param1->ioBuffer[v0][0] - 1; - v2--; + for (battler = 0; battler < maxBattlers; battler++) { + if ((battleCtx->battlerStatusFlags[battler] & BATTLER_STATUS_SWITCHING) + && BattleContext_IOBufferVal(battleCtx, battler)) { + battleCtx->switchedPartySlot[battler] = battleCtx->ioBuffer[battler][0] - 1; + totalSwitching--; - if ((param1->battleStatusMask2 & (FlagIndex(v0) << 24)) == 0) { - param1->battleStatusMask2 |= (FlagIndex(v0) << 24); - BattleIO_LinkWaitMessage(param0, v0); + if ((battleCtx->battleStatusMask2 & (FlagIndex(battler) << SYSCTL_LINK_WAITING_SHIFT)) == FALSE) { + battleCtx->battleStatusMask2 |= (FlagIndex(battler) << SYSCTL_LINK_WAITING_SHIFT); + BattleIO_LinkWaitMessage(battleSys, battler); } } } - if (v2 == 0) { - for (v0 = 0; v0 < v1; v0++) { - if ((param1->battlerStatusFlags[v0] & 0x1) && (BattleContext_IOBufferVal(param1, v0))) { - ov16_0223F500(param0, v0, param1->ioBuffer[v0][0]); + if (totalSwitching == 0) { + for (battler = 0; battler < maxBattlers; battler++) { + if ((battleCtx->battlerStatusFlags[battler] & BATTLER_STATUS_SWITCHING) + && BattleContext_IOBufferVal(battleCtx, battler)) { + BattleSystem_Record(battleSys, battler, battleCtx->ioBuffer[battler][0]); } } - param1->battleStatusMask2 &= (0xf000000 ^ 0xffffffff); - BattleScript_Iter(param1, 1); + battleCtx->battleStatusMask2 &= ~SYSCTL_LINK_WAITING; + BattleScript_Iter(battleCtx, 1); } - param1->battleProgressFlag = 1; - - return 0; + battleCtx->battleProgressFlag = TRUE; + return FALSE; } -static BOOL ov16_02242134 (BattleSystem * param0, BattleContext * param1) +/** + * @brief Switch a battler for another. + * + * Inputs: + * 1. The battler who is switching + * + * Side effects: + * - Flips the switching flag off for the battler status flags + * - Flips the battler-specific flag off for the switching mask + * - Updates the selected and switched party slot values + * - Caches the enemy's current HP value in battleCtx->hpTemp + * - Invokes InitBattleMon, SwitchSlots, and UpdateAfterSwitch; refer to the + * docs for those routines for more detailed information + * + * @param battleSys + * @param battleCtx + * @return FALSE + */ +static BOOL BtlCmd_Switch(BattleSystem *battleSys, BattleContext *battleCtx) { - int v0; - int v1; - - BattleScript_Iter(param1, 1); - v1 = BattleScript_Read(param1); + BattleScript_Iter(battleCtx, 1); + int inBattler = BattleScript_Read(battleCtx); + int battler; - switch (v1) { + switch (inBattler) { default: break; - case 0x1: - v0 = param1->attacker; + + case BTLSCR_ATTACKER: + battler = battleCtx->attacker; break; - case 0x6: - v0 = param1->switchedMon; + + case BTLSCR_SWITCHED_MON: + battler = battleCtx->switchedMon; break; - case 0x12: - v0 = param1->defender; + + case BTLSCR_FORCED_OUT: + battler = battleCtx->defender; break; } - param1->battlerStatusFlags[v0] &= 0x1 ^ 0xffffffff; - param1->battlersSwitchingMask &= (FlagIndex(v0) ^ 0xffffffff); - param1->selectedPartySlot[v0] = param1->switchedPartySlot[v0]; - param1->switchedPartySlot[v0] = 6; + battleCtx->battlerStatusFlags[battler] &= ~BATTLER_STATUS_SWITCHING; + battleCtx->battlersSwitchingMask &= FLAG_NEGATE(FlagIndex(battler)); + battleCtx->selectedPartySlot[battler] = battleCtx->switchedPartySlot[battler]; + battleCtx->switchedPartySlot[battler] = MAX_PARTY_SIZE; - BattleSystem_InitBattleMon(param0, param1, v0, param1->selectedPartySlot[v0]); - BattleSystem_SwitchSlots(param0, param1, v0, param1->selectedPartySlot[v0]); + BattleSystem_InitBattleMon(battleSys, battleCtx, battler, battleCtx->selectedPartySlot[battler]); + BattleSystem_SwitchSlots(battleSys, battleCtx, battler, battleCtx->selectedPartySlot[battler]); - param1->hpTemp = param1->battleMons[1].curHP; + // cache the enemy's current HP (used for force-out moves like Whirlwind?) + battleCtx->hpTemp = battleCtx->battleMons[BATTLER_ENEMY_SLOT_1].curHP; - ov16_0225433C(param0, param1, v0); + BattleSystem_UpdateAfterSwitch(battleSys, battleCtx, battler); - return 0; + return FALSE; } -static BOOL ov16_022421D4 (BattleSystem * param0, BattleContext * param1) +/** + * @brief Jump to the designated address if any battlers are switching. + * + * Inputs: + * 1. The jump distance + * + * @param battleSys + * @param battleCtx + * @return FALSE + */ +static BOOL BtlCmd_JumpIfAnySwitches(BattleSystem *battleSys, BattleContext *battleCtx) { - int v0; - int v1 = BattleSystem_MaxBattlers(param0); - int v2; + int i; // must declare here to match + int maxBattlers = BattleSystem_MaxBattlers(battleSys); - BattleScript_Iter(param1, 1); - v2 = BattleScript_Read(param1); + BattleScript_Iter(battleCtx, 1); + int jump = BattleScript_Read(battleCtx); - for (v0 = 0; v0 < v1; v0++) { - if (param1->battlerStatusFlags[v0] & 0x1) { - param1->switchedMon = v0; - BattleScript_Iter(param1, v2); + for (i = 0; i < maxBattlers; i++) { + if (battleCtx->battlerStatusFlags[i] & BATTLER_STATUS_SWITCHING) { + battleCtx->switchedMon = i; + BattleScript_Iter(battleCtx, jump); break; } } - return 0; + return FALSE; } static BOOL ov16_0224221C (BattleSystem * param0, BattleContext * param1) @@ -5572,7 +5614,7 @@ static BOOL ov16_02245D68 (BattleSystem * param0, BattleContext * param1) while (TRUE) { v5 = BattleSystem_PartyPokemon(param0, param1->attacker, param1->beatUpCounter); - if ((param1->beatUpCounter == param1->selectedPartySlot[param1->attacker]) || ((Pokemon_GetValue(v5, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 494) && (Pokemon_GetValue(v5, MON_DATA_160, NULL) == 0))) { + if ((param1->beatUpCounter == param1->selectedPartySlot[param1->attacker]) || ((Pokemon_GetValue(v5, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 494) && (Pokemon_GetValue(v5, MON_DATA_STATUS_CONDITION, NULL) == 0))) { break; } @@ -5609,7 +5651,7 @@ static BOOL ov16_02245D68 (BattleSystem * param0, BattleContext * param1) while (TRUE) { v5 = BattleSystem_PartyPokemon(param0, param1->attacker, param1->beatUpCounter); - if ((param1->beatUpCounter == param1->selectedPartySlot[param1->attacker]) || ((Pokemon_GetValue(v5, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 494) && (Pokemon_GetValue(v5, MON_DATA_160, NULL) == 0))) { + if ((param1->beatUpCounter == param1->selectedPartySlot[param1->attacker]) || ((Pokemon_GetValue(v5, MON_DATA_CURRENT_HP, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES_EGG, NULL) != 494) && (Pokemon_GetValue(v5, MON_DATA_STATUS_CONDITION, NULL) == 0))) { break; } @@ -7140,7 +7182,7 @@ static BOOL ov16_02247C04 (BattleSystem * param0, BattleContext * param1) BattleScript_Iter(param1, v1); } - ov16_0223F500(param0, 0, v0); + BattleSystem_Record(param0, 0, v0); } param1->battleProgressFlag = 1; @@ -7834,7 +7876,7 @@ static BOOL ov16_02248708 (BattleSystem * param0, BattleContext * param1) if ((param1->battleMons[v1].curHP) && (param1->selectedPartySlot[v1] != 6)) { v3 = BattleSystem_PartyPokemon(param0, v1, param1->selectedPartySlot[v1]); v4 = Pokemon_GetValue(v3, MON_DATA_ABILITY, NULL); - v5 = Pokemon_GetValue(v3, MON_DATA_160, NULL); + v5 = Pokemon_GetValue(v3, MON_DATA_STATUS_CONDITION, NULL); if ((param1->battleMons[v1].ability != 30) && (ov16_022577A4(param1, v4, v5) == 0)) { BattleScript_Iter(param1, v2); diff --git a/src/overlay016/ov16_0223B140.c b/src/overlay016/ov16_0223B140.c index 9d10e14166..bc881243ba 100644 --- a/src/overlay016/ov16_0223B140.c +++ b/src/overlay016/ov16_0223B140.c @@ -1393,7 +1393,7 @@ static void ov16_0223C2C0 (BattleSystem * param0, BattleParams * param1) if (param0->battleType & 0x200) { v3 = Party_GetPokemonBySlotIndex(param0->parties[1], 0); - Pokemon_GetValue(v3, MON_DATA_144, (u8 *)¶m0->trainers[1].unk_14); + Pokemon_GetValue(v3, MON_DATA_OTNAME, (u8 *)¶m0->trainers[1].unk_14); } if (param0->battleType & 0x1) { diff --git a/src/overlay016/ov16_0223DF00.c b/src/overlay016/ov16_0223DF00.c index d590e9462f..f77d6a05f6 100644 --- a/src/overlay016/ov16_0223DF00.c +++ b/src/overlay016/ov16_0223DF00.c @@ -186,7 +186,7 @@ void ov16_0223F4B0(BattleSystem * param0, int param1); u16 BattleSystem_RandNext(BattleSystem * param0); u32 ov16_0223F4E8(BattleSystem * param0); void ov16_0223F4F4(BattleSystem * param0, u32 param1); -void ov16_0223F500(BattleSystem * param0, int param1, u8 param2); +void BattleSystem_Record(BattleSystem * param0, int param1, u8 param2); BOOL ov16_0223F530(BattleSystem * param0, int param1, u8 * param2); u8 ov16_0223F58C(BattleSystem * param0, u8 * param1); void ov16_0223F638(BattleSystem * param0, u16 param1, u8 * param2); @@ -593,7 +593,7 @@ BOOL ov16_0223E30C (BattleSystem * param0, int param1, int param2, int param3, i v6 = 0; if (Item_LoadParam(param4, 15, 5)) { - v3 = Pokemon_GetValue(v1, MON_DATA_160, NULL); + v3 = Pokemon_GetValue(v1, MON_DATA_STATUS_CONDITION, NULL); if (v3 & 0x7) { v3 &= (0x7 ^ 0xffffffff); @@ -613,7 +613,7 @@ BOOL ov16_0223E30C (BattleSystem * param0, int param1, int param2, int param3, i } if (Item_LoadParam(param4, 16, 5)) { - v3 = Pokemon_GetValue(v1, MON_DATA_160, NULL); + v3 = Pokemon_GetValue(v1, MON_DATA_STATUS_CONDITION, NULL); if (v3 & 0xf88) { v3 &= ((0x8 | 0x80 | 0xf00) ^ 0xffffffff); @@ -630,7 +630,7 @@ BOOL ov16_0223E30C (BattleSystem * param0, int param1, int param2, int param3, i } if (Item_LoadParam(param4, 17, 5)) { - v3 = Pokemon_GetValue(v1, MON_DATA_160, NULL); + v3 = Pokemon_GetValue(v1, MON_DATA_STATUS_CONDITION, NULL); if (v3 & 0x10) { v3 &= (0x10 ^ 0xffffffff); @@ -647,7 +647,7 @@ BOOL ov16_0223E30C (BattleSystem * param0, int param1, int param2, int param3, i } if (Item_LoadParam(param4, 18, 5)) { - v3 = Pokemon_GetValue(v1, MON_DATA_160, NULL); + v3 = Pokemon_GetValue(v1, MON_DATA_STATUS_CONDITION, NULL); if (v3 & 0x20) { v3 &= (0x20 ^ 0xffffffff); @@ -664,7 +664,7 @@ BOOL ov16_0223E30C (BattleSystem * param0, int param1, int param2, int param3, i } if (Item_LoadParam(param4, 19, 5)) { - v3 = Pokemon_GetValue(v1, MON_DATA_160, NULL); + v3 = Pokemon_GetValue(v1, MON_DATA_STATUS_CONDITION, NULL); if (v3 & 0x40) { v3 &= (0x40 ^ 0xffffffff); @@ -1482,7 +1482,7 @@ void ov16_0223F4F4 (BattleSystem * param0, u32 param1) param0->unk_2448 = param1; } -void ov16_0223F500 (BattleSystem * param0, int param1, u8 param2) +void BattleSystem_Record (BattleSystem * param0, int param1, u8 param2) { if (((param0->battleStatusMask & 0x10) == 0) && (param0->unk_245C[param1] < 0x400)) { sub_0202F868(param1, param0->unk_245C[param1], param2); diff --git a/src/overlay016/ov16_0225177C.c b/src/overlay016/ov16_0225177C.c index 58759ca093..9a1d1d1a40 100644 --- a/src/overlay016/ov16_0225177C.c +++ b/src/overlay016/ov16_0225177C.c @@ -2,6 +2,7 @@ #include #include "constants/abilities.h" +#include "constants/heap.h" #include "constants/items.h" #include "constants/species.h" #include "constants/string.h" @@ -45,8 +46,8 @@ #include "overlay016/ov16_0225CBB8.h" #include "overlay016/ov16_0226485C.h" -void BattleSystem_InitBattleMon(BattleSystem * param0, BattleContext * param1, int param2, int param3); -void BattleSystem_ReloadPokemon(BattleSystem * param0, BattleContext * param1, int param2, int param3); +void BattleSystem_InitBattleMon(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot); +void BattleSystem_ReloadPokemon(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot); void BattleSystem_LoadScript(BattleContext *battleCtx, int narc, int file); void BattleSystem_CallScript(BattleContext *battleCtx, int narc, int file); BOOL ov16_02251EF4(BattleContext * param0); @@ -74,7 +75,7 @@ int ov16_02253F7C(BattleContext * param0, int param1); BOOL BattleSystem_CheckTrainerMessage(BattleSystem * param0, BattleContext * param1); void BattleContext_Init(BattleContext * param0); void BattleContext_InitCounters(BattleSystem * param0, BattleContext * param1); -void ov16_0225433C(BattleSystem * param0, BattleContext * param1, int param2); +void BattleSystem_UpdateAfterSwitch(BattleSystem *battleSys, BattleContext *battleCtx, int battler); void BattleSystem_CleanupFaintedMon(BattleSystem *battleSys, BattleContext *battleCtx, int battler); void BattleSystem_SetupNextTurn(BattleSystem * param0, BattleContext * param1); int BattleSystem_CheckStruggling(BattleSystem * param0, BattleContext * param1, int param2, int param3, int param4); @@ -143,7 +144,7 @@ void ov16_02259A5C(BattleSystem * param0, BattleContext * param1, Pokemon * para u8 BattleContext_IOBufferVal(BattleContext *battleCtx, int battler); BOOL Battler_BehindSubstitute(BattleContext * param0, int param1); BOOL BattleSystem_TrainerIsOT(BattleSystem * param0, BattleContext * param1); -BOOL BattleSystem_PokemonIsOT(BattleSystem * param0, Pokemon * param1); +BOOL BattleSystem_PokemonWasTraded(BattleSystem * param0, Pokemon * param1); BOOL BattleSystem_UpdateWeatherForms(BattleSystem * param0, BattleContext * param1, int * param2); void ov16_0225A1B0(BattleSystem * param0, BattleContext * param1); void BattleSystem_SwitchSlots(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot); @@ -182,135 +183,129 @@ int ov16_0225BE3C(BattleSystem * param0, BattleContext * param1, Pokemon * param static const Fraction sStatStageBoosts[]; -void BattleSystem_InitBattleMon (BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot) +void BattleSystem_InitBattleMon(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot) { - Pokemon * v0 = BattleSystem_PartyPokemon(battleSys, battler, partySlot); - int v1; - int v2; - UnkStruct_02098700 * v3; + Pokemon *mon = BattleSystem_PartyPokemon(battleSys, battler, partySlot); - battleCtx->battleMons[battler].species = Pokemon_GetValue(v0, MON_DATA_SPECIES, 0); - battleCtx->battleMons[battler].attack = Pokemon_GetValue(v0, MON_DATA_ATK, 0); - battleCtx->battleMons[battler].defense = Pokemon_GetValue(v0, MON_DATA_DEF, 0); - battleCtx->battleMons[battler].speed = Pokemon_GetValue(v0, MON_DATA_SPEED, 0); - battleCtx->battleMons[battler].spAttack = Pokemon_GetValue(v0, MON_DATA_SP_ATK, 0); - battleCtx->battleMons[battler].spDefense = Pokemon_GetValue(v0, MON_DATA_SP_DEF, 0); + battleCtx->battleMons[battler].species = Pokemon_GetValue(mon, MON_DATA_SPECIES, NULL); + battleCtx->battleMons[battler].attack = Pokemon_GetValue(mon, MON_DATA_ATK, NULL); + battleCtx->battleMons[battler].defense = Pokemon_GetValue(mon, MON_DATA_DEF, NULL); + battleCtx->battleMons[battler].speed = Pokemon_GetValue(mon, MON_DATA_SPEED, NULL); + battleCtx->battleMons[battler].spAttack = Pokemon_GetValue(mon, MON_DATA_SP_ATK, NULL); + battleCtx->battleMons[battler].spDefense = Pokemon_GetValue(mon, MON_DATA_SP_DEF, NULL); - for (v1 = 0; v1 < 4; v1++) { - battleCtx->battleMons[battler].moves[v1] = Pokemon_GetValue(v0, MON_DATA_MOVE1 + v1, 0); - battleCtx->battleMons[battler].ppCur[v1] = Pokemon_GetValue(v0, MON_DATA_MOVE1_CUR_PP + v1, 0); - battleCtx->battleMons[battler].ppUps[v1] = Pokemon_GetValue(v0, MON_DATA_MOVE1_PP_UPS + v1, 0); - } - - battleCtx->battleMons[battler].hpIV = Pokemon_GetValue(v0, MON_DATA_HP_IV, 0); - battleCtx->battleMons[battler].attackIV = Pokemon_GetValue(v0, MON_DATA_ATK_IV, 0); - battleCtx->battleMons[battler].defenseIV = Pokemon_GetValue(v0, MON_DATA_DEF_IV, 0); - battleCtx->battleMons[battler].speedIV = Pokemon_GetValue(v0, MON_DATA_SPEED_IV, 0); - battleCtx->battleMons[battler].spAttackIV = Pokemon_GetValue(v0, MON_DATA_SPATK_IV, 0); - battleCtx->battleMons[battler].spDefenseIV = Pokemon_GetValue(v0, MON_DATA_SPDEF_IV, 0); - battleCtx->battleMons[battler].isEgg = Pokemon_GetValue(v0, MON_DATA_IS_EGG, 0); - battleCtx->battleMons[battler].hasNickname = Pokemon_GetValue(v0, MON_DATA_77, 0); - - if ((battleCtx->battleStatusMask & 0x100) == 0) { - for (v1 = 0; v1 < 0x8; v1++) { - battleCtx->battleMons[battler].statBoosts[v1] = 6; - } - } - - battleCtx->battleMons[battler].weatherAbilityAnnounced = 0; - battleCtx->battleMons[battler].intimidateAnnounced = 0; - battleCtx->battleMons[battler].traceAnnounced = 0; - battleCtx->battleMons[battler].downloadAnnounced = 0; - battleCtx->battleMons[battler].anticipationAnnounced = 0; - battleCtx->battleMons[battler].forewarnAnnounced = 0; - battleCtx->battleMons[battler].slowStartAnnounced = 0; - battleCtx->battleMons[battler].slowStartFinished = 0; - battleCtx->battleMons[battler].friskAnnounced = 0; - battleCtx->battleMons[battler].moldBreakerAnnounced = 0; - battleCtx->battleMons[battler].pressureAnnounced = 0; - battleCtx->battleMons[battler].type1 = Pokemon_GetValue(v0, MON_DATA_177, 0); - battleCtx->battleMons[battler].type2 = Pokemon_GetValue(v0, MON_DATA_178, 0); - battleCtx->battleMons[battler].gender = Pokemon_GetGender(v0); - battleCtx->battleMons[battler].isShiny = Pokemon_IsShiny(v0); - - if (BattleSystem_BattleType(battleSys) & (0x20 | 0x200)) { - battleCtx->battleMons[battler].ability = 0; - battleCtx->battleMons[battler].status = 0; - battleCtx->battleMons[battler].heldItem = 0; + int i; + for (i = 0; i < LEARNED_MOVES_MAX; i++) { + battleCtx->battleMons[battler].moves[i] = Pokemon_GetValue(mon, MON_DATA_MOVE1 + i, NULL); + battleCtx->battleMons[battler].ppCur[i] = Pokemon_GetValue(mon, MON_DATA_MOVE1_CUR_PP + i, NULL); + battleCtx->battleMons[battler].ppUps[i] = Pokemon_GetValue(mon, MON_DATA_MOVE1_PP_UPS + i, NULL); + } + + battleCtx->battleMons[battler].hpIV = Pokemon_GetValue(mon, MON_DATA_HP_IV, NULL); + battleCtx->battleMons[battler].attackIV = Pokemon_GetValue(mon, MON_DATA_ATK_IV, NULL); + battleCtx->battleMons[battler].defenseIV = Pokemon_GetValue(mon, MON_DATA_DEF_IV, NULL); + battleCtx->battleMons[battler].speedIV = Pokemon_GetValue(mon, MON_DATA_SPEED_IV, NULL); + battleCtx->battleMons[battler].spAttackIV = Pokemon_GetValue(mon, MON_DATA_SPATK_IV, NULL); + battleCtx->battleMons[battler].spDefenseIV = Pokemon_GetValue(mon, MON_DATA_SPDEF_IV, NULL); + battleCtx->battleMons[battler].isEgg = Pokemon_GetValue(mon, MON_DATA_IS_EGG, NULL); + battleCtx->battleMons[battler].hasNickname = Pokemon_GetValue(mon, MON_DATA_HAS_NICKNAME, NULL); + + if ((battleCtx->battleStatusMask & SYSCTL_BATON_PASS) == FALSE) { + for (i = 0; i < BATTLE_STAT_MAX; i++) { + battleCtx->battleMons[battler].statBoosts[i] = 6; + } + } + + battleCtx->battleMons[battler].weatherAbilityAnnounced = FALSE; + battleCtx->battleMons[battler].intimidateAnnounced = FALSE; + battleCtx->battleMons[battler].traceAnnounced = FALSE; + battleCtx->battleMons[battler].downloadAnnounced = FALSE; + battleCtx->battleMons[battler].anticipationAnnounced = FALSE; + battleCtx->battleMons[battler].forewarnAnnounced = FALSE; + battleCtx->battleMons[battler].slowStartAnnounced = FALSE; + battleCtx->battleMons[battler].slowStartFinished = FALSE; + battleCtx->battleMons[battler].friskAnnounced = FALSE; + battleCtx->battleMons[battler].moldBreakerAnnounced = FALSE; + battleCtx->battleMons[battler].pressureAnnounced = FALSE; + battleCtx->battleMons[battler].type1 = Pokemon_GetValue(mon, MON_DATA_TYPE_1, NULL); + battleCtx->battleMons[battler].type2 = Pokemon_GetValue(mon, MON_DATA_TYPE_2, NULL); + battleCtx->battleMons[battler].gender = Pokemon_GetGender(mon); + battleCtx->battleMons[battler].isShiny = Pokemon_IsShiny(mon); + + if (BattleSystem_BattleType(battleSys) & BATTLE_TYPE_NO_ABILITIES) { + battleCtx->battleMons[battler].ability = ABILITY_NONE; + battleCtx->battleMons[battler].status = MON_CONDITION_NONE; + battleCtx->battleMons[battler].heldItem = ITEM_NONE; } else { - battleCtx->battleMons[battler].ability = Pokemon_GetValue(v0, MON_DATA_ABILITY, 0); - battleCtx->battleMons[battler].status = Pokemon_GetValue(v0, MON_DATA_160, 0); - battleCtx->battleMons[battler].heldItem = Pokemon_GetValue(v0, MON_DATA_HELD_ITEM, 0); + battleCtx->battleMons[battler].ability = Pokemon_GetValue(mon, MON_DATA_ABILITY, NULL); + battleCtx->battleMons[battler].status = Pokemon_GetValue(mon, MON_DATA_STATUS_CONDITION, NULL); + battleCtx->battleMons[battler].heldItem = Pokemon_GetValue(mon, MON_DATA_HELD_ITEM, NULL); } - if ((BattleSystem_BattleType(battleSys) & (0x20 | 0x200)) && (Battler_Side(battleSys, battler) == 0)) { + if ((BattleSystem_BattleType(battleSys) & BATTLE_TYPE_NO_ABILITIES) && Battler_Side(battleSys, battler) == BATTLER_US) { battleCtx->battleMons[battler].formNum = 0; } else { - battleCtx->battleMons[battler].formNum = Pokemon_GetValue(v0, MON_DATA_FORM, 0); + battleCtx->battleMons[battler].formNum = Pokemon_GetValue(mon, MON_DATA_FORM, NULL); } - battleCtx->battleMons[battler].level = Pokemon_GetValue(v0, MON_DATA_LEVEL, 0); - battleCtx->battleMons[battler].friendship = Pokemon_GetValue(v0, MON_DATA_FRIENDSHIP, 0); - battleCtx->battleMons[battler].curHP = Pokemon_GetValue(v0, MON_DATA_CURRENT_HP, 0); - battleCtx->battleMons[battler].maxHP = Pokemon_GetValue(v0, MON_DATA_MAX_HP, 0); - battleCtx->battleMons[battler].exp = Pokemon_GetValue(v0, MON_DATA_EXP, 0); - battleCtx->battleMons[battler].pid = Pokemon_GetValue(v0, MON_DATA_PERSONALITY, 0); - battleCtx->battleMons[battler].OTId = Pokemon_GetValue(v0, MON_DATA_OT_ID, 0); - battleCtx->battleMons[battler].OTGender = Pokemon_GetValue(v0, MON_DATA_OT_GENDER, 0); - battleCtx->battleMons[battler].capturedBall = Pokemon_GetValue(v0, MON_DATA_POKEBALL, 0); + battleCtx->battleMons[battler].level = Pokemon_GetValue(mon, MON_DATA_LEVEL, NULL); + battleCtx->battleMons[battler].friendship = Pokemon_GetValue(mon, MON_DATA_FRIENDSHIP, NULL); + battleCtx->battleMons[battler].curHP = Pokemon_GetValue(mon, MON_DATA_CURRENT_HP, NULL); + battleCtx->battleMons[battler].maxHP = Pokemon_GetValue(mon, MON_DATA_MAX_HP, NULL); + battleCtx->battleMons[battler].exp = Pokemon_GetValue(mon, MON_DATA_EXP, NULL); + battleCtx->battleMons[battler].pid = Pokemon_GetValue(mon, MON_DATA_PERSONALITY, NULL); + battleCtx->battleMons[battler].OTId = Pokemon_GetValue(mon, MON_DATA_OT_ID, NULL); + battleCtx->battleMons[battler].OTGender = Pokemon_GetValue(mon, MON_DATA_OT_GENDER, NULL); + battleCtx->battleMons[battler].capturedBall = Pokemon_GetValue(mon, MON_DATA_POKEBALL, NULL); - sub_02098988(battleCtx->battleMons[battler].formNum); - v3 = sub_02098700(5); - sub_0209872C(v3, 0, 5); + Pokedex_SetupGiratina(battleCtx->battleMons[battler].formNum); - battleCtx->battleMons[battler].weight = sub_02098828(v3, battleCtx->battleMons[battler].species); + HeightWeightData *heightWeightData = Pokedex_HeightWeightData(HEAP_ID_BATTLE); + Pokedex_HeightWeightData_Load(heightWeightData, 0, HEAP_ID_BATTLE); - sub_020987BC(v3); - sub_02098718(v3); - Pokemon_GetValue(v0, MON_DATA_117, &battleCtx->battleMons[battler].nickname[0]); - Pokemon_GetValue(v0, MON_DATA_144, &battleCtx->battleMons[battler].OTName[0]); + battleCtx->battleMons[battler].weight = Pokedex_HeightWeightData_Weight(heightWeightData, battleCtx->battleMons[battler].species); + + Pokedex_HeightWeightData_Release(heightWeightData); + Pokedex_HeightWeightData_Free(heightWeightData); + Pokemon_GetValue(mon, MON_DATA_NICKNAME, battleCtx->battleMons[battler].nickname); + Pokemon_GetValue(mon, MON_DATA_OTNAME, battleCtx->battleMons[battler].OTName); battleCtx->battleMons[battler].timesDamaged = 0; battleCtx->battleMons[battler].trainerMessageFlags = 0; - v2 = Battler_Side(battleSys, battler); - - if (battleCtx->sideConditions[v2].knockedOffItemsMask & FlagIndex(battleCtx->selectedPartySlot[battler])) { - battleCtx->battleMons[battler].heldItem = 0; - battleCtx->battleMons[battler].moveEffectsData.canUnburden = 0; - } else { - if (battleCtx->battleMons[battler].heldItem) { - battleCtx->battleMons[battler].moveEffectsData.canUnburden = 1; - } + int side = Battler_Side(battleSys, battler); + if (battleCtx->sideConditions[side].knockedOffItemsMask & FlagIndex(battleCtx->selectedPartySlot[battler])) { + battleCtx->battleMons[battler].heldItem = ITEM_NONE; + battleCtx->battleMons[battler].moveEffectsData.canUnburden = FALSE; + } else if (battleCtx->battleMons[battler].heldItem) { + battleCtx->battleMons[battler].moveEffectsData.canUnburden = TRUE; } } -void BattleSystem_ReloadPokemon (BattleSystem * param0, BattleContext * param1, int param2, int param3) +void BattleSystem_ReloadPokemon(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot) { - Pokemon * v0 = BattleSystem_PartyPokemon(param0, param2, param3); - int v1; - int v2; + Pokemon *mon = BattleSystem_PartyPokemon(battleSys, battler, partySlot); - param1->battleMons[param2].attack = Pokemon_GetValue(v0, MON_DATA_ATK, 0); - param1->battleMons[param2].defense = Pokemon_GetValue(v0, MON_DATA_DEF, 0); - param1->battleMons[param2].speed = Pokemon_GetValue(v0, MON_DATA_SPEED, 0); - param1->battleMons[param2].spAttack = Pokemon_GetValue(v0, MON_DATA_SP_ATK, 0); - param1->battleMons[param2].spDefense = Pokemon_GetValue(v0, MON_DATA_SP_DEF, 0); - param1->battleMons[param2].level = Pokemon_GetValue(v0, MON_DATA_LEVEL, 0); - param1->battleMons[param2].friendship = Pokemon_GetValue(v0, MON_DATA_FRIENDSHIP, 0); - param1->battleMons[param2].curHP = Pokemon_GetValue(v0, MON_DATA_CURRENT_HP, 0); - param1->battleMons[param2].maxHP = Pokemon_GetValue(v0, MON_DATA_MAX_HP, 0); + battleCtx->battleMons[battler].attack = Pokemon_GetValue(mon, MON_DATA_ATK, NULL); + battleCtx->battleMons[battler].defense = Pokemon_GetValue(mon, MON_DATA_DEF, NULL); + battleCtx->battleMons[battler].speed = Pokemon_GetValue(mon, MON_DATA_SPEED, NULL); + battleCtx->battleMons[battler].spAttack = Pokemon_GetValue(mon, MON_DATA_SP_ATK, NULL); + battleCtx->battleMons[battler].spDefense = Pokemon_GetValue(mon, MON_DATA_SP_DEF, NULL); + battleCtx->battleMons[battler].level = Pokemon_GetValue(mon, MON_DATA_LEVEL, NULL); + battleCtx->battleMons[battler].friendship = Pokemon_GetValue(mon, MON_DATA_FRIENDSHIP, NULL); + battleCtx->battleMons[battler].curHP = Pokemon_GetValue(mon, MON_DATA_CURRENT_HP, NULL); + battleCtx->battleMons[battler].maxHP = Pokemon_GetValue(mon, MON_DATA_MAX_HP, NULL); - if ((param1->battleMons[param2].statusVolatile & 0x200000) == 0) { - for (v1 = 0; v1 < 4; v1++) { - if ((param1->battleMons[param2].moveEffectsData.mimickedMoveSlot & FlagIndex(v1)) == 0) { - param1->battleMons[param2].moves[v1] = Pokemon_GetValue(v0, MON_DATA_MOVE1 + v1, 0); - param1->battleMons[param2].ppCur[v1] = Pokemon_GetValue(v0, MON_DATA_MOVE1_CUR_PP + v1, 0); - param1->battleMons[param2].ppUps[v1] = Pokemon_GetValue(v0, MON_DATA_MOVE1_PP_UPS + v1, 0); + if ((battleCtx->battleMons[battler].statusVolatile & VOLATILE_CONDITION_TRANSFORM) == FALSE) { + for (int i = 0; i < LEARNED_MOVES_MAX; i++) { + if ((battleCtx->battleMons[battler].moveEffectsData.mimickedMoveSlot & FlagIndex(i)) == FALSE) { + battleCtx->battleMons[battler].moves[i] = Pokemon_GetValue(mon, MON_DATA_MOVE1 + i, NULL); + battleCtx->battleMons[battler].ppCur[i] = Pokemon_GetValue(mon, MON_DATA_MOVE1_CUR_PP + i, NULL); + battleCtx->battleMons[battler].ppUps[i] = Pokemon_GetValue(mon, MON_DATA_MOVE1_PP_UPS + i, NULL); } } - param1->battleMons[param2].exp = Pokemon_GetValue(v0, MON_DATA_EXP, 0); + battleCtx->battleMons[battler].exp = Pokemon_GetValue(mon, MON_DATA_EXP, NULL); } } @@ -2080,110 +2075,120 @@ void BattleContext_InitCounters (BattleSystem * param0, BattleContext * param1) param1->safariEscapeCount = 6; } -void ov16_0225433C (BattleSystem * param0, BattleContext * param1, int param2) +void BattleSystem_UpdateAfterSwitch(BattleSystem *battleSys, BattleContext *battleCtx, int battler) { - int v0; - int v1; - u32 v2; - u8 * v3; - MoveEffectsData v4; + // declare C89-style to match + int i, maxBattlers; + u32 battleType; + u8 *addr; + MoveEffectsData moveEffects; - v4 = param1->battleMons[param2].moveEffectsData; - v1 = BattleSystem_MaxBattlers(param0); - v2 = BattleSystem_BattleType(param0); + moveEffects = battleCtx->battleMons[battler].moveEffectsData; + maxBattlers = BattleSystem_MaxBattlers(battleSys); + battleType = BattleSystem_BattleType(battleSys); - param1->battlerActions[param2][0] = 39; + // Forcefully end the battler's turn after the replacement + battleCtx->battlerActions[battler][BATTLE_ACTION_PICK_COMMAND] = BATTLE_CONTROL_MOVE_END; - if ((param1->battleStatusMask & 0x100) == 0) { - for (v0 = 0; v0 < v1; v0++) { - if ((param1->battleMons[v0].statusVolatile & 0x4000000) && (param1->battleMons[v0].moveEffectsData.meanLookTarget == param2)) { - param1->battleMons[v0].statusVolatile &= (0x4000000 ^ 0xffffffff); + if ((battleCtx->battleStatusMask & SYSCTL_BATON_PASS) == FALSE) { + // Clear any Mean Look or Lock On effects from other active battlers + for (i = 0; i < maxBattlers; i++) { + if ((battleCtx->battleMons[i].statusVolatile & VOLATILE_CONDITION_MEAN_LOOK) + && (battleCtx->battleMons[i].moveEffectsData.meanLookTarget == battler)) { + battleCtx->battleMons[i].statusVolatile &= ~VOLATILE_CONDITION_MEAN_LOOK; } - if ((param1->battleMons[v0].moveEffectsMask & 0x18) && (param1->battleMons[v0].moveEffectsData.lockOnTarget == param2)) { - param1->battleMons[v0].moveEffectsMask &= (0x18 ^ 0xffffffff); - param1->battleMons[v0].moveEffectsData.lockOnTarget = 0; + if ((battleCtx->battleMons[i].moveEffectsMask & MOVE_EFFECT_LOCK_ON) + && (battleCtx->battleMons[i].moveEffectsData.lockOnTarget == battler)) { + battleCtx->battleMons[i].moveEffectsMask &= ~MOVE_EFFECT_LOCK_ON; + battleCtx->battleMons[i].moveEffectsData.lockOnTarget = 0; } } - param1->battleMons[param2].statusVolatile = 0; - param1->battleMons[param2].moveEffectsMask = 0; + battleCtx->battleMons[battler].statusVolatile = VOLATILE_CONDITION_NONE; + battleCtx->battleMons[battler].moveEffectsMask = MOVE_EFFECT_NONE; } else { - param1->battleMons[param2].statusVolatile &= (0x100000 | 0x4000000 | 0x7 | 0x10000000 | 0x1000000); - param1->battleMons[param2].moveEffectsMask &= (3 | 4 | 24 | 32 | 1024 | 65536 | 0x20000 | 0x8000 | 0x800000 | 0x1000000 | 0x200000 | 0x4000000 | 0x2000000 | 0x8000000); + // Baton Pass maintains Focus Energy, Mean Look, Confusion, Curse, Substitute, + // and a variety of move effects (see constants/battle/moves.h) + battleCtx->battleMons[battler].statusVolatile &= VOLATILE_CONDITION_BATON_PASSED; + battleCtx->battleMons[battler].moveEffectsMask &= MOVE_EFFECT_BATON_PASSED; - for (v0 = 0; v0 < v1; v0++) { - if ((param1->battleMons[v0].moveEffectsMask & 0x18) && (param1->battleMons[v0].moveEffectsData.lockOnTarget == param2)) { - param1->battleMons[v0].moveEffectsMask &= (0x18 ^ 0xffffffff); - param1->battleMons[v0].moveEffectsMask |= (0x8 * 2); + for (i = 0; i < maxBattlers; i++) { + if ((battleCtx->battleMons[i].moveEffectsMask & MOVE_EFFECT_LOCK_ON) + && battleCtx->battleMons[i].moveEffectsData.lockOnTarget == battler) { + // When transferring Lock On due to Baton Pass, its effect timer is refreshed + battleCtx->battleMons[i].moveEffectsMask &= ~MOVE_EFFECT_LOCK_ON; + battleCtx->battleMons[i].moveEffectsMask |= MOVE_EFFECT_LOCK_ON_INITIAL_DURATION; } } } - for (v0 = 0; v0 < v1; v0++) { - if (param1->battleMons[v0].statusVolatile & (FlagIndex(param2) << 16)) { - param1->battleMons[v0].statusVolatile &= ((FlagIndex(param2) << 16) ^ 0xffffffff); + // Clear the effects of Attract and Bind sourced from the replaced battler + for (i = 0; i < maxBattlers; i++) { + if (battleCtx->battleMons[i].statusVolatile & (FlagIndex(battler) << VOLATILE_CONDITION_ATTRACT_SHIFT)) { + battleCtx->battleMons[i].statusVolatile &= FLAG_NEGATE(FlagIndex(battler) << VOLATILE_CONDITION_ATTRACT_SHIFT); } - if ((param1->battleMons[v0].statusVolatile & 0xe000) && (param1->battleMons[v0].moveEffectsData.bindTarget == param2)) { - param1->battleMons[v0].statusVolatile &= (0xe000 ^ 0xffffffff); + if ((battleCtx->battleMons[i].statusVolatile & VOLATILE_CONDITION_BIND) + && battleCtx->battleMons[i].moveEffectsData.bindTarget == battler) { + battleCtx->battleMons[i].statusVolatile &= ~VOLATILE_CONDITION_BIND; } } - v3 = (u8 *)¶m1->battleMons[param2].moveEffectsData; - - for (v0 = 0; v0 < sizeof(MoveEffectsData); v0++) { - v3[v0] = 0; + // Clear all move effects for the battler + addr = (u8 *)&battleCtx->battleMons[battler].moveEffectsData; // doesn't match with &moveEffectsData + for (i = 0; i < sizeof(MoveEffectsData); i++) { + addr[i] = 0; } - if (param1->battleStatusMask & 0x100) { - param1->battleMons[param2].moveEffectsData.substituteHP = v4.substituteHP; - param1->battleMons[param2].moveEffectsData.lockOnTarget = v4.lockOnTarget; - param1->battleMons[param2].moveEffectsData.perishSongTurns = v4.perishSongTurns; - param1->battleMons[param2].moveEffectsData.meanLookTarget = v4.meanLookTarget; - param1->battleMons[param2].moveEffectsData.magnetRiseTurns = v4.magnetRiseTurns; - param1->battleMons[param2].moveEffectsData.embargoTurns = v4.embargoTurns; - param1->battleMons[param2].moveEffectsData.healBlockTurns = v4.healBlockTurns; + // Update the move effects for Baton Pass, if applicable + if (battleCtx->battleStatusMask & SYSCTL_BATON_PASS) { + battleCtx->battleMons[battler].moveEffectsData.substituteHP = moveEffects.substituteHP; + battleCtx->battleMons[battler].moveEffectsData.lockOnTarget = moveEffects.lockOnTarget; + battleCtx->battleMons[battler].moveEffectsData.perishSongTurns = moveEffects.perishSongTurns; + battleCtx->battleMons[battler].moveEffectsData.meanLookTarget = moveEffects.meanLookTarget; + battleCtx->battleMons[battler].moveEffectsData.magnetRiseTurns = moveEffects.magnetRiseTurns; + battleCtx->battleMons[battler].moveEffectsData.embargoTurns = moveEffects.embargoTurns; + battleCtx->battleMons[battler].moveEffectsData.healBlockTurns = moveEffects.healBlockTurns; } - param1->battleMons[param2].moveEffectsData.fakeOutTurnNumber = param1->totalTurns + 1; - param1->battleMons[param2].moveEffectsData.slowStartTurnNumber = param1->totalTurns + 1; - param1->battleMons[param2].moveEffectsData.truant = (param1->totalTurns + 1) & 1; - param1->moveProtect[param2] = 0; - param1->moveHit[param2] = 0; - param1->moveHitBattler[param2] = 0xff; - param1->moveHitType[param2] = 0; - param1->movePrevByBattler[param2] = 0; - param1->moveCopied[param2] = 0; - param1->moveCopiedHit[param2][0] = 0; - param1->moveCopiedHit[param2][1] = 0; - param1->moveCopiedHit[param2][2] = 0; - param1->moveCopiedHit[param2][3] = 0; - param1->moveSketched[param2] = 0; - param1->conversion2Move[param2] = 0; - param1->conversion2Battler[param2] = 0; - param1->conversion2Type[param2] = 0; - param1->metronomeMove[param2] = 0; - param1->fieldConditionsMask &= ((FlagIndex(param2) << 8) ^ 0xffffffff); - - if (param1->battleMons[param2].moveEffectsMask & 0x800000) { - v0 = param1->battleMons[param2].attack; + battleCtx->battleMons[battler].moveEffectsData.fakeOutTurnNumber = battleCtx->totalTurns + 1; + battleCtx->battleMons[battler].moveEffectsData.slowStartTurnNumber = battleCtx->totalTurns + 1; + battleCtx->battleMons[battler].moveEffectsData.truant = (battleCtx->totalTurns + 1) & 1; + battleCtx->moveProtect[battler] = MOVE_NONE; + battleCtx->moveHit[battler] = MOVE_NONE; + battleCtx->moveHitBattler[battler] = BATTLER_NONE; + battleCtx->moveHitType[battler] = MOVE_NONE; + battleCtx->movePrevByBattler[battler] = MOVE_NONE; + battleCtx->moveCopied[battler] = MOVE_NONE; + battleCtx->moveCopiedHit[battler][0] = MOVE_NONE; + battleCtx->moveCopiedHit[battler][1] = MOVE_NONE; + battleCtx->moveCopiedHit[battler][2] = MOVE_NONE; + battleCtx->moveCopiedHit[battler][3] = MOVE_NONE; + battleCtx->moveSketched[battler] = MOVE_NONE; + battleCtx->conversion2Move[battler] = MOVE_NONE; + battleCtx->conversion2Battler[battler] = MOVE_NONE; + battleCtx->conversion2Type[battler] = MOVE_NONE; + battleCtx->metronomeMove[battler] = MOVE_NONE; + battleCtx->fieldConditionsMask &= FLAG_NEGATE(FlagIndex(battler) << FIELD_CONDITION_UPROAR_SHIFT); - param1->battleMons[param2].attack = param1->battleMons[param2].defense; - param1->battleMons[param2].defense = v0; + if (battleCtx->battleMons[battler].moveEffectsMask & MOVE_EFFECT_POWER_TRICK) { + i = battleCtx->battleMons[battler].attack; + battleCtx->battleMons[battler].attack = battleCtx->battleMons[battler].defense; + battleCtx->battleMons[battler].defense = i; } - for (v0 = 0; v0 < v1; v0++) { - if ((v0 != param2) && (Battler_Side(param0, v0) != Battler_Side(param0, param2))) { - param1->moveCopied[v0] = 0; + for (i = 0; i < maxBattlers; i++) { + if (i != battler && Battler_Side(battleSys, i) != Battler_Side(battleSys, battler)) { + battleCtx->moveCopied[i] = MOVE_NONE; } - param1->moveCopiedHit[v0][param2] = 0; + battleCtx->moveCopiedHit[i][battler] = MOVE_NONE; } - BattleAI_ClearKnownMoves(param1, param2); - BattleAI_ClearKnownAbility(param1, param2); - BattleAI_ClearKnownItem(param1, param2); + BattleAI_ClearKnownMoves(battleCtx, battler); + BattleAI_ClearKnownAbility(battleCtx, battler); + BattleAI_ClearKnownItem(battleCtx, battler); } void BattleSystem_CleanupFaintedMon(BattleSystem *battleSys, BattleContext *battleCtx, int battler) @@ -6141,7 +6146,7 @@ BOOL BattleSystem_PokemonIsOT (BattleSystem * param0, Pokemon * param1) v2 = TrainerInfo_Gender(v0); v3 = TrainerInfo_Name(v0); - Pokemon_GetValue(param1, MON_DATA_144, &v4[0]); + Pokemon_GetValue(param1, MON_DATA_OTNAME, &v4[0]); if ((v1 == Pokemon_GetValue(param1, MON_DATA_OT_ID, NULL)) && (v2 == Pokemon_GetValue(param1, MON_DATA_OT_GENDER, NULL)) && (GF_strncmp(v3, &v4[0], 7) == 0)) { return 1; @@ -6311,37 +6316,37 @@ void ov16_0225A1B0 (BattleSystem * param0, BattleContext * param1) } } -void BattleSystem_SwitchSlots (BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot) +void BattleSystem_SwitchSlots(BattleSystem *battleSys, BattleContext *battleCtx, int battler, int partySlot) { - int v0; - int v1; - int v2; - u32 v3; - - v3 = BattleSystem_BattleType(battleSys); + // declare C89-style to match + int i; + int tmp; + int targetSlot; + u32 battleType = BattleSystem_BattleType(battleSys); - if (((v3 & 0x2) && ((v3 & (0x8 | 0x10)) == 0)) || ((v3 & 0x10) && ((BattleSystem_BattlerSlot(battleSys, battler) & 0x1) == 0))) { - if ((BattleSystem_BattlerSlot(battleSys, battler) == 4) || (BattleSystem_BattlerSlot(battleSys, battler) == 5)) { - v2 = 1; + if (((battleType & BATTLE_TYPE_DOUBLES) && (battleType & BATTLE_TYPE_2vs2_TAG) == FALSE) + || ((battleType & BATTLE_TYPE_TAG) && (BattleSystem_BattlerSlot(battleSys, battler) & BATTLER_TYPE_SOLO_ENEMY) == FALSE)) { + if (BattleSystem_BattlerSlot(battleSys, battler) == BATTLER_TYPE_PLAYER_SIDE_SLOT_2 + || BattleSystem_BattlerSlot(battleSys, battler) == BATTLER_TYPE_ENEMY_SIDE_SLOT_2) { + targetSlot = 1; } else { - v2 = 0; + targetSlot = 0; } battler &= 1; } else { - v2 = 0; + targetSlot = 0; } - for (v0 = 0; v0 < 6; v0++) { - if (battleCtx->partyOrder[battler][v0] == partySlot) { + for (i = 0; i < MAX_PARTY_SIZE; i++) { + if (battleCtx->partyOrder[battler][i] == partySlot) { break; } } - v1 = battleCtx->partyOrder[battler][v2]; - - battleCtx->partyOrder[battler][v2] = battleCtx->partyOrder[battler][v0]; - battleCtx->partyOrder[battler][v0] = v1; + tmp = battleCtx->partyOrder[battler][targetSlot]; + battleCtx->partyOrder[battler][targetSlot] = battleCtx->partyOrder[battler][i]; + battleCtx->partyOrder[battler][i] = tmp; } typedef struct ItemEffectTypePair { @@ -7883,8 +7888,8 @@ int ov16_0225BA88 (BattleSystem * param0, int param1) if ((v7 != 0) && (v7 != 494) && (Pokemon_GetValue(v19, MON_DATA_CURRENT_HP, NULL)) && ((v10 & FlagIndex(v0)) == 0) && (v20->selectedPartySlot[v14] != v0) && (v20->selectedPartySlot[v15] != v0) && (v0 != v20->aiSwitchedPartySlot[v14]) && (v0 != v20->aiSwitchedPartySlot[v15])) { v3 = BattleMon_Get(v20, v2, 27, NULL); v4 = BattleMon_Get(v20, v2, 28, NULL); - v5 = Pokemon_GetValue(v19, MON_DATA_177, NULL); - v6 = Pokemon_GetValue(v19, MON_DATA_178, NULL); + v5 = Pokemon_GetValue(v19, MON_DATA_TYPE_1, NULL); + v6 = Pokemon_GetValue(v19, MON_DATA_TYPE_2, NULL); v11 = ov16_022558CC(v5, v3, v4); v11 += ov16_022558CC(v6, v3, v4); diff --git a/src/overlay016/ov16_0225CBB8.c b/src/overlay016/ov16_0225CBB8.c index 896dff6ccb..716dd03579 100644 --- a/src/overlay016/ov16_0225CBB8.c +++ b/src/overlay016/ov16_0225CBB8.c @@ -4010,7 +4010,7 @@ static void ov16_022611DC (SysTask * param0, void * param1) v18->unk_2C = Pokemon_GetValue(v19, MON_DATA_MAX_HP, NULL); v18->unk_30 = v0->unk_08->unk_04->unk_20; - if (Pokemon_GetValue(v19, MON_DATA_160, NULL) == 0) { + if (Pokemon_GetValue(v19, MON_DATA_STATUS_CONDITION, NULL) == 0) { v18->unk_4A = 0; } @@ -4074,7 +4074,7 @@ static void ov16_022611DC (SysTask * param0, void * param1) v34 = v0->unk_08->unk_04->unk_2C[v0->unk_08->unk_04->unk_11]; v33 = BattleSystem_PartyPokemon(v0->unk_00, v28, v34); - if (Pokemon_GetValue(v33, MON_DATA_160, NULL) == 0) { + if (Pokemon_GetValue(v33, MON_DATA_STATUS_CONDITION, NULL) == 0) { v27->unk_4A = 0; } diff --git a/src/overlay016/ov16_0226485C.c b/src/overlay016/ov16_0226485C.c index e33a0809a6..264a909001 100644 --- a/src/overlay016/ov16_0226485C.c +++ b/src/overlay016/ov16_0226485C.c @@ -622,7 +622,7 @@ void BattleIO_SetCommandSelection (BattleSystem *battleSys, BattleContext *battl if ((v5) && (v5 != 494)) { if (Pokemon_GetValue(v8, MON_DATA_CURRENT_HP, NULL)) { - if (Pokemon_GetValue(v8, MON_DATA_160, NULL)) { + if (Pokemon_GetValue(v8, MON_DATA_STATUS_CONDITION, NULL)) { v0.unk_08[0][v6] = 3; } else { v0.unk_08[0][v6] = 1; @@ -657,7 +657,7 @@ void BattleIO_SetCommandSelection (BattleSystem *battleSys, BattleContext *battl if ((v5) && (v5 != 494)) { if (Pokemon_GetValue(v8, MON_DATA_CURRENT_HP, NULL)) { - if (Pokemon_GetValue(v8, MON_DATA_160, NULL)) { + if (Pokemon_GetValue(v8, MON_DATA_STATUS_CONDITION, NULL)) { v0.unk_08[1][v6] = 3; } else { v0.unk_08[1][v6] = 1; @@ -685,7 +685,7 @@ void BattleIO_SetCommandSelection (BattleSystem *battleSys, BattleContext *battl if ((v5) && (v5 != 494)) { if (Pokemon_GetValue(v8, MON_DATA_CURRENT_HP, NULL)) { - if (Pokemon_GetValue(v8, MON_DATA_160, NULL)) { + if (Pokemon_GetValue(v8, MON_DATA_STATUS_CONDITION, NULL)) { v0.unk_08[1][v6] = 3; } else { v0.unk_08[1][v6] = 1; @@ -708,7 +708,7 @@ void BattleIO_SetCommandSelection (BattleSystem *battleSys, BattleContext *battl if ((v5) && (v5 != 494)) { if (Pokemon_GetValue(v8, MON_DATA_CURRENT_HP, NULL)) { - if (Pokemon_GetValue(v8, MON_DATA_160, NULL)) { + if (Pokemon_GetValue(v8, MON_DATA_STATUS_CONDITION, NULL)) { v0.unk_08[1][v6] = 3; } else { v0.unk_08[1][v6] = 1; @@ -1749,7 +1749,7 @@ static void ov16_02266CF0 (BattleSystem * param0, BattleContext * param1, UnkStr if ((v3) && (v3 != 494)) { if (Pokemon_GetValue(v7, MON_DATA_CURRENT_HP, NULL)) { - if (Pokemon_GetValue(v7, MON_DATA_160, NULL)) { + if (Pokemon_GetValue(v7, MON_DATA_STATUS_CONDITION, NULL)) { param2->unk_02[v4] = 3; } else { param2->unk_02[v4] = 1; @@ -1771,7 +1771,7 @@ static void ov16_02266CF0 (BattleSystem * param0, BattleContext * param1, UnkStr if ((v3) && (v3 != 494)) { if (Pokemon_GetValue(v7, MON_DATA_CURRENT_HP, NULL)) { - if (Pokemon_GetValue(v7, MON_DATA_160, NULL)) { + if (Pokemon_GetValue(v7, MON_DATA_STATUS_CONDITION, NULL)) { param2->unk_02[v4] = 3; } else { param2->unk_02[v4] = 1; @@ -1799,7 +1799,7 @@ static void ov16_02266CF0 (BattleSystem * param0, BattleContext * param1, UnkStr if ((v3) && (v3 != 494)) { if (Pokemon_GetValue(v7, MON_DATA_CURRENT_HP, NULL)) { - if (Pokemon_GetValue(v7, MON_DATA_160, NULL)) { + if (Pokemon_GetValue(v7, MON_DATA_STATUS_CONDITION, NULL)) { param2->unk_02[v4] = 3; } else { param2->unk_02[v4] = 1; diff --git a/src/overlay017/ov17_022413D8.c b/src/overlay017/ov17_022413D8.c index 8ed64a4a0e..63fb003787 100644 --- a/src/overlay017/ov17_022413D8.c +++ b/src/overlay017/ov17_022413D8.c @@ -2127,8 +2127,8 @@ void ov17_022439C8 (UnkStruct_02095C48 * param0, int param1, int param2, UnkStru { int v0, v1; - v0 = Pokemon_GetValue(param0->unk_00.unk_00[param1], MON_DATA_177, NULL); - v1 = Pokemon_GetValue(param0->unk_00.unk_00[param1], MON_DATA_178, NULL); + v0 = Pokemon_GetValue(param0->unk_00.unk_00[param1], MON_DATA_TYPE_1, NULL); + v1 = Pokemon_GetValue(param0->unk_00.unk_00[param1], MON_DATA_TYPE_2, NULL); if ((v0 == 7) || (v1 == 7)) { param3->unk_07 = 1; diff --git a/src/overlay019/ov19_021D0D80.c b/src/overlay019/ov19_021D0D80.c index be630faace..dcfaccb34c 100644 --- a/src/overlay019/ov19_021D0D80.c +++ b/src/overlay019/ov19_021D0D80.c @@ -4153,8 +4153,8 @@ static void ov19_021D58AC (UnkStruct_ov19_021D4DF0 * param0, BoxPokemon * param1 v2 = PokemonPersonalData_FromMonSpecies(v0->unk_04, 9); v0->unk_0A = PokemonPersonalData_GetLevelAt(v2, v0->unk_04, BoxPokemon_GetValue(param1, MON_DATA_EXP, NULL)); v0->unk_0B = BoxPokemon_GetValue(param1, MON_DATA_11, NULL); - v0->unk_0C = BoxPokemon_GetValue(param1, MON_DATA_177, NULL); - v0->unk_0D = BoxPokemon_GetValue(param1, MON_DATA_178, NULL); + v0->unk_0C = BoxPokemon_GetValue(param1, MON_DATA_TYPE_1, NULL); + v0->unk_0D = BoxPokemon_GetValue(param1, MON_DATA_TYPE_2, NULL); if ((v0->unk_0F == 0) && BoxPokemon_GetValue(param1, MON_DATA_176, NULL)) { v0->unk_0E = PokemonPersonalData_GetGenderOf(v2, v0->unk_04, BoxPokemon_GetValue(param1, MON_DATA_PERSONALITY, NULL)); @@ -4296,8 +4296,8 @@ static void ov19_021D5BE8 (UnkStruct_ov19_021D4DF0 * param0, u16 param1, UnkStru if (v2 == 493) { BoxPokemon_SetArceusForm(v0->unk_00); - v0->unk_0C = BoxPokemon_GetValue(v0->unk_00, MON_DATA_177, NULL); - v0->unk_0D = BoxPokemon_GetValue(v0->unk_00, MON_DATA_178, NULL); + v0->unk_0C = BoxPokemon_GetValue(v0->unk_00, MON_DATA_TYPE_1, NULL); + v0->unk_0D = BoxPokemon_GetValue(v0->unk_00, MON_DATA_TYPE_2, NULL); } else if (v2 == 487) { int v3; diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index dbef928a06..c79441c6aa 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -143,7 +143,7 @@ int ov21_021D0D80 (UnkStruct_020067E8 * param0, int * param1) u32 v4; v4 = sub_0202756C(v1->unk_00, 487, 0); - sub_02098988(v4); + Pokedex_SetupGiratina(v4); } sub_02017798(ov21_021D0F04, v0); diff --git a/src/overlay021/ov21_021D3208.c b/src/overlay021/ov21_021D3208.c index 420facccb6..2cd313a63d 100644 --- a/src/overlay021/ov21_021D3208.c +++ b/src/overlay021/ov21_021D3208.c @@ -90,12 +90,12 @@ void ov21_021D3208 (UnkStruct_ov21_021D3320 * param0, UnkStruct_ov21_021D3208 * param0->unk_174C = TrainerInfo_GameCode(param1->unk_04); param0->unk_1750 = TrainerInfo_Gender(param1->unk_04); param0->unk_1754 = TrainerInfo_NameNewStrbuf(param1->unk_04, param2); - param0->unk_1748 = sub_02098700(param2); + param0->unk_1748 = Pokedex_HeightWeightData(param2); if (param0->unk_1750 == 0) { - sub_0209872C(param0->unk_1748, 0, param2); + Pokedex_HeightWeightData_Load(param0->unk_1748, 0, param2); } else { - sub_0209872C(param0->unk_1748, 1, param2); + Pokedex_HeightWeightData_Load(param0->unk_1748, 1, param2); } param0->unk_1760 = param1->unk_0C; @@ -107,8 +107,8 @@ void ov21_021D3208 (UnkStruct_ov21_021D3320 * param0, UnkStruct_ov21_021D3208 * void ov21_021D3320 (UnkStruct_ov21_021D3320 * param0) { Strbuf_Free(param0->unk_1754); - sub_020987BC(param0->unk_1748); - sub_02098718(param0->unk_1748); + Pokedex_HeightWeightData_Release(param0->unk_1748); + Pokedex_HeightWeightData_Free(param0->unk_1748); param0->unk_1748 = NULL; } diff --git a/src/overlay021/ov21_021E737C.c b/src/overlay021/ov21_021E737C.c index 42ab48b2fe..d951020e51 100644 --- a/src/overlay021/ov21_021E737C.c +++ b/src/overlay021/ov21_021E737C.c @@ -291,7 +291,7 @@ static int ov21_021E74A0 (UnkStruct_ov21_021E6A68 * param0, void * param1) param0->unk_08 = v1; v4 = ov21_021D37BC(v0->unk_00); - v2 = sub_02098828(v0->unk_00->unk_1748, v4); + v2 = Pokedex_HeightWeightData_Weight(v0->unk_00->unk_1748, v4); if (ov21_021D3920(v0->unk_00) == 0) { v3 = 380; diff --git a/src/overlay021/ov21_021E8D48.c b/src/overlay021/ov21_021E8D48.c index 8923040832..49da0c828a 100644 --- a/src/overlay021/ov21_021E8D48.c +++ b/src/overlay021/ov21_021E8D48.c @@ -157,9 +157,9 @@ UnkStruct_ov21_021E8D48 * ov21_021E8D48 (const UnkStruct_ov21_021E8E0C * param0) v2 = Pokemon_GetValue(param0->unk_10, MON_DATA_FORM, NULL); if (v1 == 487) { - sub_02098988(v2); + Pokedex_SetupGiratina(v2); } else { - sub_02098988(1); + Pokedex_SetupGiratina(1); } } diff --git a/src/overlay032/ov32_022561C0.c b/src/overlay032/ov32_022561C0.c index 0e42ba6d09..823de3ace4 100644 --- a/src/overlay032/ov32_022561C0.c +++ b/src/overlay032/ov32_022561C0.c @@ -213,7 +213,7 @@ static void ov32_022563C8 (UnkStruct_ov32_02256470_1 * param0, Party * param1) param0->unk_04[v1].unk_06 = Pokemon_GetValue(v0, MON_DATA_CURRENT_HP, NULL); param0->unk_04[v1].unk_08 = Pokemon_GetValue(v0, MON_DATA_MAX_HP, NULL); param0->unk_04[v1].unk_0A = Pokemon_GetValue(v0, MON_DATA_HELD_ITEM, NULL); - param0->unk_04[v1].unk_0C = (Pokemon_GetValue(v0, MON_DATA_160, NULL) != 0); + param0->unk_04[v1].unk_0C = (Pokemon_GetValue(v0, MON_DATA_STATUS_CONDITION, NULL) != 0); param0->unk_04[v1].unk_0E = Pokemon_GetValue(v0, MON_DATA_IS_EGG, NULL); param0->unk_04[v1].unk_0F = Pokemon_GetValue(v0, MON_DATA_FORM, NULL); diff --git a/src/overlay062/ov62_02248408.c b/src/overlay062/ov62_02248408.c index 80888968ef..77f0e78ec3 100644 --- a/src/overlay062/ov62_02248408.c +++ b/src/overlay062/ov62_02248408.c @@ -77,7 +77,7 @@ void ov62_02248408 (BattleRecording * param0, BattleParams * param1, int param2) MI_CpuClear16(v8, sizeof(u16) * v9); - Pokemon_GetValue(v13, MON_DATA_117, v8); + Pokemon_GetValue(v13, MON_DATA_NICKNAME, v8); Strbuf_Clear(v6); Strbuf_CopyChars(v6, v8); diff --git a/src/overlay088/ov88_0223B140.c b/src/overlay088/ov88_0223B140.c index c7be90fff2..654dea667e 100644 --- a/src/overlay088/ov88_0223B140.c +++ b/src/overlay088/ov88_0223B140.c @@ -1312,7 +1312,7 @@ static int ov88_0223C8AC (UnkStruct_ov88_0223C8AC * param0, Party * param1, int { if ((param0->unk_00 == 29) || (param0->unk_00 == 32)) { Pokemon * v0 = Party_GetPokemonBySlotIndex(param1, param2); - int v1 = Pokemon_GetValue(v0, MON_DATA_77, NULL); + int v1 = Pokemon_GetValue(v0, MON_DATA_HAS_NICKNAME, NULL); if (v1 == 0) { return 2; @@ -2547,7 +2547,7 @@ static void ov88_0223E7F0 (UnkStruct_0202B628 * param0, Pokemon * param1) TrainerInfo * v1 = sub_02032EE8(sub_0203608C() ^ 1); u16 v2[10 + 1]; - Pokemon_GetValue(param1, MON_DATA_117, v2); + Pokemon_GetValue(param1, MON_DATA_NICKNAME, v2); v0 = sub_0202C11C((u16 *)TrainerInfo_Name(v1), TrainerInfo_Gender(v1), v2, Pokemon_GetGender(param1), 26); sub_0202B758(param0, v0, 4); } diff --git a/src/overlay094/ov94_02242AD0.c b/src/overlay094/ov94_02242AD0.c index a1cec5dc1c..0bacc9b4af 100644 --- a/src/overlay094/ov94_02242AD0.c +++ b/src/overlay094/ov94_02242AD0.c @@ -1401,7 +1401,7 @@ static void ov94_02243E48 (UnkStruct_0202B628 * param0, UnkStruct_ov94_0223BA88 u16 v1[10 + 1]; Pokemon * v2 = (Pokemon *)param1->unk_00.unk_00; - Pokemon_GetValue(v2, MON_DATA_117, v1); + Pokemon_GetValue(v2, MON_DATA_NICKNAME, v1); v0 = sub_0202C1EC(param1->unk_10C, param1->unk_F6, v1, Pokemon_GetGender(v2), 62); sub_0202B758(param0, v0, 4); } diff --git a/src/overlay104/ov104_022332B4.c b/src/overlay104/ov104_022332B4.c index b3bf34aba9..7fc01ecbda 100644 --- a/src/overlay104/ov104_022332B4.c +++ b/src/overlay104/ov104_022332B4.c @@ -307,7 +307,7 @@ BOOL ov104_022334DC (UnkStruct_ov104_0222E930 * param0) case 17: v3 = Pokemon_New(11); ov104_0222DF40(&v4->unk_3F0[v13], v3, ov104_0223ADA0(v4)); - *v15 = Pokemon_GetValue(v3, MON_DATA_177, NULL); + *v15 = Pokemon_GetValue(v3, MON_DATA_TYPE_1, NULL); Heap_FreeToHeap(v3); break; case 18: @@ -322,8 +322,8 @@ BOOL ov104_022334DC (UnkStruct_ov104_0222E930 * param0) for (v10 = 0; v10 < v5; v10++) { ov104_0222DF40(&v4->unk_3F0[v10], v3, ov104_0223ADA0(v4)); - v7 = Pokemon_GetValue(v3, MON_DATA_177, NULL); - v8 = Pokemon_GetValue(v3, MON_DATA_178, NULL); + v7 = Pokemon_GetValue(v3, MON_DATA_TYPE_1, NULL); + v8 = Pokemon_GetValue(v3, MON_DATA_TYPE_2, NULL); if (v7 == v8) { v8 = 0xff; diff --git a/src/overlay104/ov104_022361B4.c b/src/overlay104/ov104_022361B4.c index 9c0d260185..5c9e0cf041 100644 --- a/src/overlay104/ov104_022361B4.c +++ b/src/overlay104/ov104_022361B4.c @@ -424,7 +424,7 @@ void ov104_02236848 (UnkStruct_ov104_0223BA10 * param0, u8 param1) v4[0] = Pokemon_GetValue(v11, MON_DATA_MOVE4_CUR_PP, NULL); sub_02030308(param0->unk_08, 3, v0, 3, v4); - v6[0] = Pokemon_GetValue(v11, MON_DATA_160, NULL); + v6[0] = Pokemon_GetValue(v11, MON_DATA_STATUS_CONDITION, NULL); sub_02030308(param0->unk_08, 4, v0, 0, v6); v5[0] = Pokemon_GetValue(v11, MON_DATA_HELD_ITEM, NULL); @@ -602,7 +602,7 @@ int ov104_02236D10 (UnkStruct_ov104_0223BA10 * param0) } } - if (Pokemon_GetValue(v9, MON_DATA_160, NULL) == 0) { + if (Pokemon_GetValue(v9, MON_DATA_STATUS_CONDITION, NULL) == 0) { v10[4]++; } } else { diff --git a/src/overlay104/ov104_02237DD8.c b/src/overlay104/ov104_02237DD8.c index 0031743493..26b0d7596c 100644 --- a/src/overlay104/ov104_02237DD8.c +++ b/src/overlay104/ov104_02237DD8.c @@ -596,7 +596,7 @@ static int ov104_02238584 (UnkStruct_ov104_0223BFFC * param0, Party * param1, Pa v1++; } - if (Pokemon_GetValue(v5, MON_DATA_160, NULL) != 0) { + if (Pokemon_GetValue(v5, MON_DATA_STATUS_CONDITION, NULL) != 0) { v2++; } } @@ -615,7 +615,7 @@ static int ov104_02238584 (UnkStruct_ov104_0223BFFC * param0, Party * param1, Pa v1++; } - if (Pokemon_GetValue(v5, MON_DATA_160, NULL) != 0) { + if (Pokemon_GetValue(v5, MON_DATA_STATUS_CONDITION, NULL) != 0) { v2++; } } @@ -1132,8 +1132,8 @@ static void ov104_02238C18 (UnkStruct_ov104_0223BFFC * param0, Party * param1, u for (v0 = 0; v0 < param2; v0++) { v6 = Party_GetPokemonBySlotIndex(param1, v0); - v3 = Pokemon_GetValue(v6, MON_DATA_177, NULL); - v4 = Pokemon_GetValue(v6, MON_DATA_178, NULL); + v3 = Pokemon_GetValue(v6, MON_DATA_TYPE_1, NULL); + v4 = Pokemon_GetValue(v6, MON_DATA_TYPE_2, NULL); v5 = Pokemon_GetValue(v6, MON_DATA_ABILITY, NULL); if ((v3 == 3) || (v4 == 3) || (v3 == 8) || (v4 == 8) || (v5 == 17)) { @@ -1161,8 +1161,8 @@ static void ov104_02238C9C (UnkStruct_ov104_0223BFFC * param0, Party * param1, u for (v0 = 0; v0 < param2; v0++) { v6 = Party_GetPokemonBySlotIndex(param1, v0); - v3 = Pokemon_GetValue(v6, MON_DATA_177, NULL); - v4 = Pokemon_GetValue(v6, MON_DATA_178, NULL); + v3 = Pokemon_GetValue(v6, MON_DATA_TYPE_1, NULL); + v4 = Pokemon_GetValue(v6, MON_DATA_TYPE_2, NULL); v5 = Pokemon_GetValue(v6, MON_DATA_ABILITY, NULL); if ((v3 == 4) || (v4 == 4) || (v5 == 7)) { @@ -1190,8 +1190,8 @@ static void ov104_02238D14 (UnkStruct_ov104_0223BFFC * param0, Party * param1, u for (v0 = 0; v0 < param2; v0++) { v6 = Party_GetPokemonBySlotIndex(param1, v0); - v3 = Pokemon_GetValue(v6, MON_DATA_177, NULL); - v4 = Pokemon_GetValue(v6, MON_DATA_178, NULL); + v3 = Pokemon_GetValue(v6, MON_DATA_TYPE_1, NULL); + v4 = Pokemon_GetValue(v6, MON_DATA_TYPE_2, NULL); v5 = Pokemon_GetValue(v6, MON_DATA_ABILITY, NULL); if ((v3 == 10) || (v4 == 10) || (v5 == 41)) { @@ -1256,8 +1256,8 @@ static void ov104_02238E08 (UnkStruct_ov104_0223BFFC * param0, Party * param1, u for (v1 = 0; v1 < param2; v1++) { v7 = Party_GetPokemonBySlotIndex(param1, v0); - v4 = Pokemon_GetValue(v7, MON_DATA_177, NULL); - v5 = Pokemon_GetValue(v7, MON_DATA_178, NULL); + v4 = Pokemon_GetValue(v7, MON_DATA_TYPE_1, NULL); + v5 = Pokemon_GetValue(v7, MON_DATA_TYPE_2, NULL); v6 = Pokemon_GetValue(v7, MON_DATA_ABILITY, NULL); if ((v4 == 15) || (v5 == 15) || (v6 == 40)) { diff --git a/src/pokemon.c b/src/pokemon.c index dd069658c9..4dfa0f532f 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -536,7 +536,7 @@ static u32 Pokemon_GetDataInternal(Pokemon *mon, enum PokemonDataParam param, vo u32 result = 0; switch (param) { - case MON_DATA_160: + case MON_DATA_STATUS_CONDITION: result = mon->party.unk_00; break; case MON_DATA_LEVEL: @@ -801,7 +801,7 @@ static u32 BoxPokemon_GetDataInternal (BoxPokemon *boxMon, enum PokemonDataParam result = monDataBlockB->isEgg; } break; - case MON_DATA_77: + case MON_DATA_HAS_NICKNAME: result = monDataBlockB->unk_10_31; break; case MON_DATA_78: @@ -859,7 +859,7 @@ static u32 BoxPokemon_GetDataInternal (BoxPokemon *boxMon, enum PokemonDataParam case MON_DATA_114: result = monDataBlockB->unk_1A; break; - case MON_DATA_117: + case MON_DATA_NICKNAME: if (boxMon->invalidData) { // TODO confirm this should be SPECIES_BAD_EGG (lines up with checksum failure check but not throughly checked this call tree) MessageLoader_GetSpeciesName(SPECIES_BAD_EGG, 0, dest); @@ -919,7 +919,7 @@ static u32 BoxPokemon_GetDataInternal (BoxPokemon *boxMon, enum PokemonDataParam result = ((monDataBlockC->unk_18 & (bitMask << param - MON_DATA_123)) != 0); break; } - case MON_DATA_144: + case MON_DATA_OTNAME: u16 *v8 = dest; for (result = 0; result < 7; result++) { @@ -995,8 +995,8 @@ static u32 BoxPokemon_GetDataInternal (BoxPokemon *boxMon, enum PokemonDataParam result = 1; } break; - case MON_DATA_177: - case MON_DATA_178: + case MON_DATA_TYPE_1: + case MON_DATA_TYPE_2: // TODO enum values if (monDataBlockA->species == SPECIES_ARCEUS && monDataBlockA->ability == 121) { result = Pokemon_GetArceusTypeOf(Item_LoadParam(monDataBlockA->heldItem, 1, 0)); @@ -1044,7 +1044,7 @@ static void Pokemon_SetDataInternal(Pokemon *mon, enum PokemonDataParam param, c u8 *u8Value = value; switch (param) { - case MON_DATA_160: + case MON_DATA_STATUS_CONDITION: mon->party.unk_00 = u32Value[0]; break; case MON_DATA_LEVEL: @@ -1281,7 +1281,7 @@ static void BoxPokemon_SetDataInternal(BoxPokemon *boxMon, enum PokemonDataParam case MON_DATA_IS_EGG: monDataBlockB->isEgg = u8Value[0]; break; - case MON_DATA_77: + case MON_DATA_HAS_NICKNAME: monDataBlockB->unk_10_31 = u8Value[0]; break; case MON_DATA_78: @@ -1348,7 +1348,7 @@ static void BoxPokemon_SetDataInternal(BoxPokemon *boxMon, enum PokemonDataParam MessageLoader_GetSpeciesName(monDataBlockA->species, 0, &v10[0]); monDataBlockB->unk_10_31 = sub_0200220C(v10, &u16Value[0]); } - case MON_DATA_117: + case MON_DATA_NICKNAME: for (int i = 0; i < NELEMS(monDataBlockC->unk_00); i++) { monDataBlockC->unk_00[i] = u16Value[i]; } @@ -1403,7 +1403,7 @@ static void BoxPokemon_SetDataInternal(BoxPokemon *boxMon, enum PokemonDataParam } break; } - case MON_DATA_144: + case MON_DATA_OTNAME: for (int i = 0; i < NELEMS(monDataBlockD->unk_00); i++) { monDataBlockD->unk_00[i] = u16Value[i]; } @@ -1476,8 +1476,8 @@ static void BoxPokemon_SetDataInternal(BoxPokemon *boxMon, enum PokemonDataParam monDataBlockB->spDefIV = (u32Value[0] >> 25) & 0x1f; break; case MON_DATA_176: - case MON_DATA_177: - case MON_DATA_178: + case MON_DATA_TYPE_1: + case MON_DATA_TYPE_2: break; case MON_DATA_179: { @@ -1526,7 +1526,7 @@ static void Pokemon_IncreaseDataInternal(Pokemon *mon, enum PokemonDataParam par mon->party.unk_06 += value; } break; - case MON_DATA_160: + case MON_DATA_STATUS_CONDITION: case MON_DATA_LEVEL: case MON_DATA_162: case MON_DATA_MAX_HP: @@ -1748,7 +1748,7 @@ static void BoxPokemon_IncreaseDataInternal(BoxPokemon *boxMon, enum PokemonData case MON_DATA_MOVE3: case MON_DATA_MOVE4: case MON_DATA_IS_EGG: - case MON_DATA_77: + case MON_DATA_HAS_NICKNAME: case MON_DATA_78: case MON_DATA_79: case MON_DATA_80: @@ -1786,7 +1786,7 @@ static void BoxPokemon_IncreaseDataInternal(BoxPokemon *boxMon, enum PokemonData case MON_DATA_FORM: case MON_DATA_113: case MON_DATA_114: - case MON_DATA_117: + case MON_DATA_NICKNAME: case MON_DATA_119: case MON_DATA_120: case MON_DATA_121: @@ -1812,7 +1812,7 @@ static void BoxPokemon_IncreaseDataInternal(BoxPokemon *boxMon, enum PokemonData case MON_DATA_141: case MON_DATA_142: case MON_DATA_143: - case MON_DATA_144: + case MON_DATA_OTNAME: case MON_DATA_145: case MON_DATA_146: case MON_DATA_147: @@ -1830,8 +1830,8 @@ static void BoxPokemon_IncreaseDataInternal(BoxPokemon *boxMon, enum PokemonData case MON_DATA_159: case MON_DATA_COMBINED_IVS: case MON_DATA_176: - case MON_DATA_177: - case MON_DATA_178: + case MON_DATA_TYPE_1: + case MON_DATA_TYPE_2: case MON_DATA_179: default: GF_ASSERT(0); @@ -3524,7 +3524,7 @@ void Pokemon_FromBoxPokemon(BoxPokemon *boxMon, Pokemon *mon) mon->box.partyDecrypted = TRUE; } - Pokemon_SetValue(mon, MON_DATA_160, &zero); + Pokemon_SetValue(mon, MON_DATA_STATUS_CONDITION, &zero); Pokemon_SetValue(mon, MON_DATA_CURRENT_HP, &zero); Pokemon_SetValue(mon, MON_DATA_MAX_HP, &zero); @@ -3953,7 +3953,7 @@ BOOL Pokemon_CanShayminSkyForm(Pokemon *mon) { u32 monSpecies = Pokemon_GetValue(mon, MON_DATA_SPECIES, NULL); u32 monForm = Pokemon_GetValue(mon, MON_DATA_FORM, NULL); - u32 v2 = Pokemon_GetValue(mon, MON_DATA_160, NULL); + u32 v2 = Pokemon_GetValue(mon, MON_DATA_STATUS_CONDITION, NULL); u32 monCurrentHP = Pokemon_GetValue(mon, MON_DATA_CURRENT_HP, NULL); u32 monFatefulEncounter = Pokemon_GetValue(mon, MON_DATA_FATEFUL_ENCOUNTER, NULL); @@ -4150,7 +4150,7 @@ void sub_02077E64(Pokemon *mon, TrainerInfo *param1, int monPokeball, int param3 Pokemon_SetValue(mon, MON_DATA_CURRENT_HP, &monMaxHP); monMaxHP = 0; - Pokemon_SetValue(mon, MON_DATA_160, &monMaxHP); + Pokemon_SetValue(mon, MON_DATA_STATUS_CONDITION, &monMaxHP); } } diff --git a/src/unk_020298BC.c b/src/unk_020298BC.c index b599ccf3fc..697399a81c 100644 --- a/src/unk_020298BC.c +++ b/src/unk_020298BC.c @@ -125,7 +125,7 @@ static void sub_020298D8 (UnkStruct_020298D8 * param0, u8 * param1, u8 * param2, static void sub_0202992C (UnkStruct_0202A138 * param0, Pokemon * param1, u8 param2, u8 param3, s8 param4) { param0->unk_08 = Pokemon_GetValue(param1, MON_DATA_SPECIES, NULL); - Pokemon_GetValue(param1, MON_DATA_117, param0->unk_0A); + Pokemon_GetValue(param1, MON_DATA_NICKNAME, param0->unk_0A); param0->unk_00 = Pokemon_GetValue(param1, MON_DATA_PERSONALITY, NULL); param0->unk_04 = Pokemon_GetValue(param1, MON_DATA_OT_ID, NULL); diff --git a/src/unk_0203F6C4.c b/src/unk_0203F6C4.c index 2eeebda94d..0afb4a27aa 100644 --- a/src/unk_0203F6C4.c +++ b/src/unk_0203F6C4.c @@ -4598,7 +4598,7 @@ static BOOL sub_02042718 (UnkStruct_0203E724 * param0) v1 = Party_GetPokemonBySlotIndex(Party_GetFromSavedata(v2->unk_0C), v3); - Pokemon_GetValue(v1, MON_DATA_117, v0); + Pokemon_GetValue(v1, MON_DATA_NICKNAME, v0); sub_0203DFE8(param0->unk_28, 1, Pokemon_GetValue(v1, MON_DATA_SPECIES, NULL), 10, v3, v0, inline_0204FCAC(param0)); return 1; diff --git a/src/unk_02049D08.c b/src/unk_02049D08.c index c9b1605d5a..e854e79aa4 100644 --- a/src/unk_02049D08.c +++ b/src/unk_02049D08.c @@ -1019,7 +1019,7 @@ static void sub_0204ACFC (UnkStruct_ov104_0223A348_sub2 * param0, Pokemon * para param0->unk_20 = Pokemon_GetValue(param1, MON_DATA_ABILITY, NULL); param0->unk_21 = Pokemon_GetValue(param1, MON_DATA_FRIENDSHIP, NULL); - Pokemon_GetValue(param1, MON_DATA_117, param0->unk_22); + Pokemon_GetValue(param1, MON_DATA_NICKNAME, param0->unk_22); } static void sub_0204AE20 (UnkStruct_0204AFC4 * param0, SaveData * param1, int param2) diff --git a/src/unk_0204CFFC.c b/src/unk_0204CFFC.c index 91ca2b1170..7076607d36 100644 --- a/src/unk_0204CFFC.c +++ b/src/unk_0204CFFC.c @@ -387,8 +387,8 @@ BOOL sub_0204D7D4 (UnkStruct_0203E724 * param0) u16 v4 = inline_02049538(param0); v1 = Party_GetPokemonBySlotIndex(Party_GetFromSavedata(v0->unk_0C), v4); - *v2 = Pokemon_GetValue(v1, MON_DATA_177, NULL); - *v3 = Pokemon_GetValue(v1, MON_DATA_178, NULL); + *v2 = Pokemon_GetValue(v1, MON_DATA_TYPE_1, NULL); + *v3 = Pokemon_GetValue(v1, MON_DATA_TYPE_2, NULL); return 0; } diff --git a/src/unk_02054884.c b/src/unk_02054884.c index b6609499de..4428f4bc23 100644 --- a/src/unk_02054884.c +++ b/src/unk_02054884.c @@ -198,7 +198,7 @@ int sub_02054B04 (Party * param0, u16 param1) v4 = Party_GetPokemonBySlotIndex(param0, v2); if (sub_02054884(v4)) { - if (Pokemon_GetValue(v4, MON_DATA_160, NULL) & (0x80 | 0x8)) { + if (Pokemon_GetValue(v4, MON_DATA_STATUS_CONDITION, NULL) & (0x80 | 0x8)) { u32 v5 = Pokemon_GetValue(v4, MON_DATA_CURRENT_HP, NULL); if (v5 > 1) { @@ -228,7 +228,7 @@ int sub_02054B04 (Party * param0, u16 param1) BOOL sub_02054B94 (Pokemon * param0) { - if ((Pokemon_GetValue(param0, MON_DATA_160, NULL) & (0x80 | 0x8)) && (Pokemon_GetValue(param0, MON_DATA_CURRENT_HP, NULL) == 1)) { + if ((Pokemon_GetValue(param0, MON_DATA_STATUS_CONDITION, NULL) & (0x80 | 0x8)) && (Pokemon_GetValue(param0, MON_DATA_CURRENT_HP, NULL) == 1)) { u32 v0 = 0; Pokemon_SetValue(param0, 160, &v0); diff --git a/src/unk_020562F8.c b/src/unk_020562F8.c index 09cf0b0e99..ce45053df2 100644 --- a/src/unk_020562F8.c +++ b/src/unk_020562F8.c @@ -160,8 +160,8 @@ static void sub_0205642C (UnkStruct_0203CDB0 * param0, UnkStruct_020564B4 * para param1->unk_00[v0].unk_03 = v1[3]; param1->unk_00[v0].unk_04 = v1[2]; - param1->unk_00[v0].unk_06 = Pokemon_GetValue(v3, MON_DATA_177, NULL); - param1->unk_00[v0].unk_07 = Pokemon_GetValue(v3, MON_DATA_178, NULL); + param1->unk_00[v0].unk_06 = Pokemon_GetValue(v3, MON_DATA_TYPE_1, NULL); + param1->unk_00[v0].unk_07 = Pokemon_GetValue(v3, MON_DATA_TYPE_2, NULL); } Heap_FreeToHeap(v3); diff --git a/src/unk_0206CCB0.c b/src/unk_0206CCB0.c index 0231b7a1b7..22c769107d 100644 --- a/src/unk_0206CCB0.c +++ b/src/unk_0206CCB0.c @@ -505,7 +505,7 @@ static void sub_0206CEA4 (UnkStruct_0200B358 * param0, int param1, u16 param2) static void sub_0206CED0 (int param0, Pokemon * param1, u8 * param2, u16 * param3) { - *param2 = Pokemon_GetValue(param1, MON_DATA_77, NULL); + *param2 = Pokemon_GetValue(param1, MON_DATA_HAS_NICKNAME, NULL); if (*param2) { Strbuf* v0 = Strbuf_Init(64, param0); @@ -538,7 +538,7 @@ void sub_0206CF48 (TVBroadcast * param0, Pokemon * param1, int param2) v0->unk_1E = Pokemon_GetNature(param1); sub_0206CE38(param1, &v0->unk_02, &v0->unk_04, &v0->unk_05, &v0->unk_06); - v0->unk_07 = Pokemon_GetValue(param1, MON_DATA_77, NULL); + v0->unk_07 = Pokemon_GetValue(param1, MON_DATA_HAS_NICKNAME, NULL); sub_0206CED0(param2, param1, &v0->unk_07, v0->unk_08); sub_02025C84(27); @@ -613,7 +613,7 @@ void sub_0206D048 (TVBroadcast * param0, Pokemon * param1) v0->unk_00 = 1; sub_0206CE38(param1, &v0->unk_02, &v0->unk_04, &v0->unk_05, &v0->unk_06); - v0->unk_07 = Pokemon_GetValue(param1, MON_DATA_77, NULL); + v0->unk_07 = Pokemon_GetValue(param1, MON_DATA_HAS_NICKNAME, NULL); sub_0206CED0(11, param1, &v0->unk_07, v0->unk_08); sub_02025C84(27); diff --git a/src/unk_0207A2A8.c b/src/unk_0207A2A8.c index e9cd091fe2..d59d9f019c 100644 --- a/src/unk_0207A2A8.c +++ b/src/unk_0207A2A8.c @@ -13,21 +13,21 @@ #include "unk_0207A2A8.h" #include "unk_02098700.h" -UnkStruct_02098700 * sub_0207A2A8 (int param0) +HeightWeightData * sub_0207A2A8 (int param0) { - UnkStruct_02098700 * v0 = sub_02098700(param0); + HeightWeightData * v0 = Pokedex_HeightWeightData(param0); - sub_0209872C(v0, 0, param0); + Pokedex_HeightWeightData_Load(v0, 0, param0); return v0; } -void sub_0207A2C0 (UnkStruct_02098700 * param0) +void sub_0207A2C0 (HeightWeightData * param0) { - sub_020987BC(param0); - sub_02098718(param0); + Pokedex_HeightWeightData_Release(param0); + Pokedex_HeightWeightData_Free(param0); } -BOOL sub_0207A2D0 (const UnkStruct_0202610C * param0, Pokemon * param1, const UnkStruct_02098700 * param2) +BOOL sub_0207A2D0 (const UnkStruct_0202610C * param0, Pokemon * param1, const HeightWeightData * param2) { u16 v0 = (u16)Pokemon_GetValue(param1, MON_DATA_SPECIES, NULL); int v1, v2, v3; @@ -73,7 +73,7 @@ BOOL sub_0207A2D0 (const UnkStruct_0202610C * param0, Pokemon * param1, const Un v1 = sub_02026074(param0, 7) * 10; if (v1 != 0) { - v3 = sub_02098828(param2, v0); + v3 = Pokedex_HeightWeightData_Weight(param2, v0); if (v1 > 0) { if (v3 < v1) { @@ -97,7 +97,7 @@ BOOL sub_0207A2D0 (const UnkStruct_0202610C * param0, Pokemon * param1, const Un return 1; } -int sub_0207A3AC (const UnkStruct_0202610C * param0, Party * param1, const UnkStruct_02098700 * param2, u8 * param3) +int sub_0207A3AC (const UnkStruct_0202610C * param0, Party * param1, const HeightWeightData * param2, u8 * param3) { Pokemon * v0; int v1, v2 = 0, v3, v4, v5 = 0; @@ -204,7 +204,7 @@ static BOOL sub_0207A514 (u16 * param0, u16 * param1, u16 * param2, int param3, return 0; } -int sub_0207A594 (const UnkStruct_0202610C * param0, Party * param1, const UnkStruct_02098700 * param2) +int sub_0207A594 (const UnkStruct_0202610C * param0, Party * param1, const HeightWeightData * param2) { Pokemon * v0; int v1, v2, v3, v4, v5 = 0; diff --git a/src/unk_0207AE68.c b/src/unk_0207AE68.c index 81290f9bd3..74ae75ab94 100644 --- a/src/unk_0207AE68.c +++ b/src/unk_0207AE68.c @@ -422,7 +422,7 @@ static void sub_0207B180 (UnkStruct_0207AE68 * param0) sub_0202CFEC(param0->unk_50, 22); sub_02056A48(param0->unk_54, Pokemon_GetBoxPokemon(param0->unk_28)); - if (Pokemon_GetValue(param0->unk_28, MON_DATA_77, NULL) == 0) { + if (Pokemon_GetValue(param0->unk_28, MON_DATA_HAS_NICKNAME, NULL) == 0) { Pokemon_SetValue(param0->unk_28, 179, NULL); } diff --git a/src/unk_0208C324.c b/src/unk_0208C324.c index f230c9e526..f874638fcb 100644 --- a/src/unk_0208C324.c +++ b/src/unk_0208C324.c @@ -1053,8 +1053,8 @@ static void sub_0208D200 (UnkStruct_0208D7BC * param0, Pokemon * param1, UnkStru param2->unk_13_0 = Pokemon_GetGender(param1); param2->unk_13_2 = (u8)Pokemon_GetValue(param1, MON_DATA_POKEBALL, NULL); - param2->unk_10 = (u8)Pokemon_GetValue(param1, MON_DATA_177, NULL); - param2->unk_11 = (u8)Pokemon_GetValue(param1, MON_DATA_178, NULL); + param2->unk_10 = (u8)Pokemon_GetValue(param1, MON_DATA_TYPE_1, NULL); + param2->unk_11 = (u8)Pokemon_GetValue(param1, MON_DATA_TYPE_2, NULL); param2->unk_14 = Pokemon_GetValue(param1, MON_DATA_OT_ID, NULL); param2->unk_18 = Pokemon_GetValue(param1, MON_DATA_EXP, NULL); param2->unk_44 = (u8)Pokemon_GetValue(param1, MON_DATA_OT_GENDER, NULL); @@ -2215,7 +2215,7 @@ u32 sub_0208E9EC (void) u32 sub_0208E9F0 (Pokemon * param0) { - u32 v0 = Pokemon_GetValue(param0, MON_DATA_160, NULL); + u32 v0 = Pokemon_GetValue(param0, MON_DATA_STATUS_CONDITION, NULL); if (Pokemon_GetValue(param0, MON_DATA_CURRENT_HP, NULL) == 0) { return 6; diff --git a/src/unk_02096420.c b/src/unk_02096420.c index 2a2179ee91..00bcfb4cbe 100644 --- a/src/unk_02096420.c +++ b/src/unk_02096420.c @@ -31,7 +31,7 @@ u8 sub_02096420 (Pokemon * param0, u16 param1, u16 param2, u32 param3) return 0; } - v1[0] = Pokemon_GetValue(param0, MON_DATA_160, NULL); + v1[0] = Pokemon_GetValue(param0, MON_DATA_STATUS_CONDITION, NULL); if (Item_Get(v0, 15) != 0) { if ((v1[0] & 0x7) != 0) { @@ -282,7 +282,7 @@ u8 sub_02096954 (Pokemon * param0, u16 param1, u16 param2, u16 param3, u32 param v2 = 0; v3 = 0; - v1[0] = Pokemon_GetValue(param0, MON_DATA_160, NULL); + v1[0] = Pokemon_GetValue(param0, MON_DATA_STATUS_CONDITION, NULL); v1[1] = v1[0]; if (Item_Get(v0, 15) != 0) { diff --git a/src/unk_02098700.c b/src/unk_02098700.c index 032cb93386..124bbc6b0a 100644 --- a/src/unk_02098700.c +++ b/src/unk_02098700.c @@ -11,14 +11,14 @@ -typedef struct UnkStruct_02098700_t { +typedef struct HeightWeightData { int * unk_00; int * unk_04; short * unk_08; short * unk_0C; short * unk_10; short * unk_14; -} UnkStruct_02098700; +} HeightWeightData; static int * sub_020988C8(NARC * param0, int param1); static int * sub_020988D8(NARC * param0, int param1); @@ -27,17 +27,17 @@ static void sub_02098910(NARC * param0, short ** param1, short ** param2, int pa static void sub_02098938(NARC * param0, short ** param1, short ** param2, int param3); static void sub_02098960(NARC * param0, short ** param1, short ** param2, int param3); -UnkStruct_02098700 * sub_02098700 (int param0) +HeightWeightData * Pokedex_HeightWeightData (int param0) { - UnkStruct_02098700 * v0; + HeightWeightData * v0; - v0 = Heap_AllocFromHeap(param0, sizeof(UnkStruct_02098700)); - memset(v0, 0, sizeof(UnkStruct_02098700)); + v0 = Heap_AllocFromHeap(param0, sizeof(HeightWeightData)); + memset(v0, 0, sizeof(HeightWeightData)); return v0; } -void sub_02098718 (UnkStruct_02098700 * param0) +void Pokedex_HeightWeightData_Free (HeightWeightData * param0) { GF_ASSERT(param0); @@ -45,7 +45,7 @@ void sub_02098718 (UnkStruct_02098700 * param0) param0 = NULL; } -void sub_0209872C (UnkStruct_02098700 * param0, int param1, int param2) +void Pokedex_HeightWeightData_Load (HeightWeightData * param0, int param1, int param2) { NARC * v0; u32 v1; @@ -71,7 +71,7 @@ void sub_0209872C (UnkStruct_02098700 * param0, int param1, int param2) NARC_dtor(v0); } -void sub_020987BC (UnkStruct_02098700 * param0) +void Pokedex_HeightWeightData_Release (HeightWeightData * param0) { GF_ASSERT(param0->unk_00); GF_ASSERT(param0->unk_04); @@ -92,42 +92,42 @@ void sub_020987BC (UnkStruct_02098700 * param0) param0->unk_14 = NULL; } -int sub_02098808 (const UnkStruct_02098700 * param0, int param1) +int sub_02098808 (const HeightWeightData * param0, int param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk_00); return param0->unk_00[param1]; } -int sub_02098828 (const UnkStruct_02098700 * param0, int param1) +int Pokedex_HeightWeightData_Weight (const HeightWeightData * param0, int param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk_04); return param0->unk_04[param1]; } -short sub_02098848 (const UnkStruct_02098700 * param0, int param1) +short sub_02098848 (const HeightWeightData * param0, int param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk_08); return param0->unk_08[param1]; } -short sub_02098868 (const UnkStruct_02098700 * param0, int param1) +short sub_02098868 (const HeightWeightData * param0, int param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk_0C); return param0->unk_0C[param1]; } -short sub_02098888 (const UnkStruct_02098700 * param0, int param1) +short sub_02098888 (const HeightWeightData * param0, int param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk_10); return param0->unk_10[param1]; } -short sub_020988A8 (const UnkStruct_02098700 * param0, int param1) +short sub_020988A8 (const HeightWeightData * param0, int param1) { GF_ASSERT(param0); GF_ASSERT(param0->unk_14); diff --git a/src/unk_02098988.c b/src/unk_02098988.c index 8ce81c7bc0..3009294767 100644 --- a/src/unk_02098988.c +++ b/src/unk_02098988.c @@ -7,7 +7,7 @@ static u32 Unk_02100D94 = 75; static u32 Unk_02100D90 = 707; static u32 Unk_02100D98 = 709; -void sub_02098988 (u32 param0) +void Pokedex_SetupGiratina (u32 param0) { if (param0 == 0) { Unk_02100D94 = 194;