From 49ac2c1725333eca8116814a9ba33bba9a2a6c8d Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sun, 4 Aug 2024 15:29:22 -0700 Subject: [PATCH 1/5] Changed type1 and type2 in gBattleMons to match gSpeciesInfo --- include/battle.h | 6 +-- include/constants/pokemon.h | 6 +++ include/pokemon.h | 3 +- src/battle_ai_script_commands.c | 10 ++--- src/battle_ai_switch_items.c | 4 +- src/battle_main.c | 12 +++--- src/battle_script_commands.c | 68 ++++++++++++++++----------------- src/pokemon.c | 4 +- 8 files changed, 59 insertions(+), 54 deletions(-) diff --git a/include/battle.h b/include/battle.h index 6c4d780186c7..1e88fabedc6d 100644 --- a/include/battle.h +++ b/include/battle.h @@ -465,11 +465,11 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER #define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0)) -#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type)) +#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].types[TYPE_PRIMARY] == type || gBattleMons[battlerId].types[TYPE_SECONDARY] == type)) #define SET_BATTLER_TYPE(battlerId, type) \ { \ - gBattleMons[battlerId].type1 = type; \ - gBattleMons[battlerId].type2 = type; \ + gBattleMons[battlerId].types[TYPE_PRIMARY] = type; \ + gBattleMons[battlerId].types[TYPE_SECONDARY] = type; \ } #define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8 diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 0d6a20e2b9e3..96845f6f2b09 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -23,6 +23,12 @@ #define TYPE_DARK 17 #define NUMBER_OF_MON_TYPES 18 +enum { + TYPE_PRIMARY, + TYPE_SECONDARY, + NUM_TYPE_SLOTS, +}; + // Pokémon egg groups #define EGG_GROUP_NONE 0 #define EGG_GROUP_MONSTER 1 diff --git a/include/pokemon.h b/include/pokemon.h index 6d08f487469b..68b8731285c7 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -276,8 +276,7 @@ struct BattlePokemon /*0x17*/ u32 abilityNum:1; /*0x18*/ s8 statStages[NUM_BATTLE_STATS]; /*0x20*/ u8 ability; - /*0x21*/ u8 type1; - /*0x22*/ u8 type2; + /*0x21*/ u8 types[NUM_TYPE_SLOTS]; /*0x23*/ u8 unknown; /*0x24*/ u8 pp[MAX_MON_MOVES]; /*0x28*/ u16 hp; diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 4cb4c516542a..12981e4a534d 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1119,16 +1119,16 @@ static void Cmd_get_type(void) switch (typeVar) { case AI_TYPE1_USER: // AI user primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type1; + AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[TYPE_PRIMARY]; break; case AI_TYPE1_TARGET: // target primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type1; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[TYPE_PRIMARY]; break; case AI_TYPE2_USER: // AI user secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type2; + AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[TYPE_SECONDARY]; break; case AI_TYPE2_TARGET: // target secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type2; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[TYPE_SECONDARY]; break; case AI_TYPE_MOVE: // type of move being pointed to AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; @@ -1527,7 +1527,7 @@ static void Cmd_if_type_effectiveness(void) // TypeCalc does not assign to gMoveResultFlags, Cmd_typecalc does // This makes the check for gMoveResultFlags below always fail - // This is how you get the "dual non-immunity" glitch, where AI + // This is how you get the "dual non-immunity" glitch, where AI // will use ineffective moves on immune pokémon if the second type // has a non-neutral, non-immune effectiveness #ifdef BUGFIX diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 5ef15b627a25..1f7057844b68 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -706,8 +706,8 @@ u8 GetMostSuitableMonToSwitchInto(void) u8 type1 = gSpeciesInfo[species].types[0]; u8 type2 = gSpeciesInfo[species].types[1]; u8 typeDmg = TYPE_MUL_NORMAL; - ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type1, type1, type2, &typeDmg); - ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type2, type1, type2, &typeDmg); + ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_PRIMARY], type1, type2, &typeDmg); + ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_SECONDARY], type1, type2, &typeDmg); /* Possible bug: this comparison gives the type that takes the most damage, when a "good" AI would want to select the type that takes the least damage. Unknown if this diff --git a/src/battle_main.c b/src/battle_main.c index c19089deb043..7d1b7ac83eec 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3343,8 +3343,8 @@ void FaintClearSetData(void) gBattleResources->flags->flags[gActiveBattler] = 0; - gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; - gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; + gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; + gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; ClearBattlerMoveHistory(gActiveBattler); ClearBattlerAbilityHistory(gActiveBattler); @@ -3411,8 +3411,8 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) for (i = 0; i < sizeof(struct BattlePokemon); i++) ptr[i] = gBattleBufferB[gActiveBattler][4 + i]; - gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; - gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; + gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; + gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum); hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)]; *hpOnSwitchout = gBattleMons[gActiveBattler].hp; @@ -4173,8 +4173,8 @@ static void HandleTurnActionSelectionState(void) struct ChooseMoveStruct moveInfo; moveInfo.species = gBattleMons[gActiveBattler].species; - moveInfo.monType1 = gBattleMons[gActiveBattler].type1; - moveInfo.monType2 = gBattleMons[gActiveBattler].type2; + moveInfo.monType1 = gBattleMons[gActiveBattler].types[TYPE_PRIMARY]; + moveInfo.monType2 = gBattleMons[gActiveBattler].types[TYPE_SECONDARY]; for (i = 0; i < MAX_MON_MOVES; i++) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 49279bdb9c01..3e8cb8362335 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1395,11 +1395,11 @@ static void Cmd_typecalc(void) else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY]) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 && - gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && + gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY]) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); } i += 3; @@ -1454,14 +1454,14 @@ static void CheckWonderGuardAndLevitate(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check no effect - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; gProtectStructs[gBattlerAttacker].targetNotAffected = 1; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 && - gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 && + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && + gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; @@ -1469,18 +1469,18 @@ static void CheckWonderGuardAndLevitate(void) } // check super effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] && TYPE_EFFECT_MULTIPLIER(i) == 20) flags |= 1; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 - && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) flags |= 1; // check not very effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] && TYPE_EFFECT_MULTIPLIER(i) == 5) flags |= 2; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 - && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) flags |= 2; } @@ -1570,11 +1570,11 @@ u8 TypeCalc(u16 move, u8 attacker, u8 defender) else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[TYPE_PRIMARY]) ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].type2 && - gBattleMons[defender].type1 != gBattleMons[defender].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[TYPE_SECONDARY] && + gBattleMons[defender].types[TYPE_PRIMARY] != gBattleMons[defender].types[TYPE_SECONDARY]) ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags); } i += 3; @@ -3971,7 +3971,7 @@ static void Cmd_jumpiftype2(void) { u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].type1 || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].type2) + if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[TYPE_PRIMARY] || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[TYPE_SECONDARY]) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; @@ -4520,7 +4520,7 @@ static void Cmd_typecalc2(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY]) { if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { @@ -4537,22 +4537,22 @@ static void Cmd_typecalc2(void) } } // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY]) { - if (gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 + if (gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; break; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 - && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) { flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 - && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) { flags |= MOVE_RESULT_SUPER_EFFECTIVE; @@ -4623,8 +4623,8 @@ static void Cmd_switchindataupdate(void) for (i = 0; i < sizeof(struct BattlePokemon); i++) monData[i] = gBattleBufferB[gActiveBattler][4 + i]; - gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; - gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; + gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; + gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum); // check knocked off item @@ -7354,8 +7354,8 @@ static void Cmd_tryconversiontypechange(void) else moveType = TYPE_NORMAL; } - if (moveType != gBattleMons[gBattlerAttacker].type1 - && moveType != gBattleMons[gBattlerAttacker].type2) + if (moveType != gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] + && moveType != gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY]) { break; } @@ -7381,7 +7381,7 @@ static void Cmd_tryconversiontypechange(void) moveType = TYPE_NORMAL; } } - while (moveType == gBattleMons[gBattlerAttacker].type1 || moveType == gBattleMons[gBattlerAttacker].type2); + while (moveType == gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] || moveType == gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY]); SET_BATTLER_TYPE(gBattlerAttacker, moveType); PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType); @@ -7548,12 +7548,12 @@ static void Cmd_weatherdamage(void) { if (gBattleWeather & B_WEATHER_SANDSTORM) { - if (gBattleMons[gBattlerAttacker].type1 != TYPE_ROCK - && gBattleMons[gBattlerAttacker].type1 != TYPE_STEEL - && gBattleMons[gBattlerAttacker].type1 != TYPE_GROUND - && gBattleMons[gBattlerAttacker].type2 != TYPE_ROCK - && gBattleMons[gBattlerAttacker].type2 != TYPE_STEEL - && gBattleMons[gBattlerAttacker].type2 != TYPE_GROUND + if (gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] != TYPE_ROCK + && gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] != TYPE_STEEL + && gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] != TYPE_GROUND + && gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY] != TYPE_ROCK + && gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY] != TYPE_STEEL + && gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY] != TYPE_GROUND && gBattleMons[gBattlerAttacker].ability != ABILITY_SAND_VEIL && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) diff --git a/src/pokemon.c b/src/pokemon.c index ef8e7e9e0536..d0345006fa7b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4670,8 +4670,8 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex) gBattleMons[battlerId].isEgg = GetMonData(&gPlayerParty[partyIndex], MON_DATA_IS_EGG, NULL); gBattleMons[battlerId].abilityNum = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ABILITY_NUM, NULL); gBattleMons[battlerId].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID, NULL); - gBattleMons[battlerId].type1 = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; - gBattleMons[battlerId].type2 = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; + gBattleMons[battlerId].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; + gBattleMons[battlerId].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].abilityNum); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname); StringCopy_Nickname(gBattleMons[battlerId].nickname, nickname); From 02f1dc691eb7d4337df31edb91b3ec16c58d4a8c Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sun, 4 Aug 2024 15:38:13 -0700 Subject: [PATCH 2/5] Changed monType1 and monType2 to monTypes --- include/battle_controllers.h | 3 +-- src/battle_controller_player.c | 2 +- src/battle_gfx_sfx_util.c | 2 +- src/battle_main.c | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 064c080f6181..b40507d72fbc 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -124,8 +124,7 @@ struct ChooseMoveStruct u8 currentPp[MAX_MON_MOVES]; u8 maxPp[MAX_MON_MOVES]; u16 species; - u8 monType1; - u8 monType2; + u8 monTypes[NUM_TYPE_SLOTS]; }; enum diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 8e09d126c987..61cbe105bb8b 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -485,7 +485,7 @@ static void HandleInputChooseMove(void) PlaySE(SE_SELECT); if (moveInfo->moves[gMoveSelectionCursor[gActiveBattler]] == MOVE_CURSE) { - if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST) + if (moveInfo->monTypes[TYPE_PRIMARY] != TYPE_GHOST && moveInfo->monTypes[TYPE_SECONDARY] != TYPE_GHOST) moveTarget = MOVE_TARGET_USER; else moveTarget = MOVE_TARGET_SELECTED; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index a17ebcb5abb9..5ba4bde9a07f 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -264,7 +264,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) if (moveInfo->moves[chosenMoveId] == MOVE_CURSE) { - if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST) + if (moveInfo->monTypes[TYPE_PRIMARY] != TYPE_GHOST && moveInfo->monTypes[TYPE_SECONDARY] != TYPE_GHOST) moveTarget = MOVE_TARGET_USER; else moveTarget = MOVE_TARGET_SELECTED; diff --git a/src/battle_main.c b/src/battle_main.c index 7d1b7ac83eec..75fe6bbd0080 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4173,8 +4173,8 @@ static void HandleTurnActionSelectionState(void) struct ChooseMoveStruct moveInfo; moveInfo.species = gBattleMons[gActiveBattler].species; - moveInfo.monType1 = gBattleMons[gActiveBattler].types[TYPE_PRIMARY]; - moveInfo.monType2 = gBattleMons[gActiveBattler].types[TYPE_SECONDARY]; + moveInfo.monTypes[TYPE_PRIMARY] = gBattleMons[gActiveBattler].types[TYPE_PRIMARY]; + moveInfo.monTypes[TYPE_SECONDARY] = gBattleMons[gActiveBattler].types[TYPE_SECONDARY]; for (i = 0; i < MAX_MON_MOVES; i++) { From 4151e85a2a9eb1d905ac5ed4ea7c98d9e3d26902 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sun, 4 Aug 2024 15:54:54 -0700 Subject: [PATCH 3/5] Replaced 0 and 1 with TYPE_PRIMARY / TYPE_SECONDARY --- include/constants/pokemon.h | 6 +++--- src/battle_ai_switch_items.c | 4 ++-- src/battle_dome.c | 16 ++++++++-------- src/battle_factory.c | 30 +++++++++++++++--------------- src/battle_main.c | 8 ++++---- src/battle_pike.c | 12 ++++++------ src/battle_script_commands.c | 6 +++--- src/contest.c | 2 +- src/field_specials.c | 2 +- src/pokedex.c | 12 ++++++------ src/pokemon.c | 4 ++-- src/pokemon_summary_screen.c | 6 +++--- src/trade.c | 4 ++-- src/union_room.c | 2 +- src/wild_encounter.c | 2 +- 15 files changed, 58 insertions(+), 58 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 96845f6f2b09..8530f906a7c1 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -24,9 +24,9 @@ #define NUMBER_OF_MON_TYPES 18 enum { - TYPE_PRIMARY, - TYPE_SECONDARY, - NUM_TYPE_SLOTS, + TYPE_PRIMARY, + TYPE_SECONDARY, + NUM_TYPE_SLOTS, }; // Pokémon egg groups diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 1f7057844b68..58ff9b8395d7 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -703,8 +703,8 @@ u8 GetMostSuitableMonToSwitchInto(void) && i != *(gBattleStruct->monToSwitchIntoId + battlerIn1) && i != *(gBattleStruct->monToSwitchIntoId + battlerIn2)) { - u8 type1 = gSpeciesInfo[species].types[0]; - u8 type2 = gSpeciesInfo[species].types[1]; + u8 type1 = gSpeciesInfo[species].types[TYPE_PRIMARY]; + u8 type2 = gSpeciesInfo[species].types[TYPE_SECONDARY]; u8 typeDmg = TYPE_MUL_NORMAL; ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_PRIMARY], type1, type2, &typeDmg); ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_SECONDARY], type1, type2, &typeDmg); diff --git a/src/battle_dome.c b/src/battle_dome.c index 68cae14a6eb2..028827273109 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2405,8 +2405,8 @@ static void InitDomeTrainers(void) rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPDEF, NULL); rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPEED, NULL); rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_MAX_HP, NULL); - monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[0]]; - monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[1]]; + monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[TYPE_PRIMARY]]; + monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[TYPE_SECONDARY]]; } // Count the number of types in the players party, to factor into the ranking @@ -2440,8 +2440,8 @@ static void InitDomeTrainers(void) rankingScores[i] += statValues[STAT_SPDEF]; rankingScores[i] += statValues[STAT_SPEED]; rankingScores[i] += statValues[STAT_HP]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_PRIMARY]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_SECONDARY]]; } for (monTypesCount = 0, j = 0; j < 32; j++) @@ -2807,8 +2807,8 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int mode) if (move == MOVE_NONE || move == MOVE_UNAVAILABLE || gBattleMoves[move].power == 0) return 0; - defType1 = gSpeciesInfo[targetSpecies].types[0]; - defType2 = gSpeciesInfo[targetSpecies].types[1]; + defType1 = gSpeciesInfo[targetSpecies].types[TYPE_PRIMARY]; + defType2 = gSpeciesInfo[targetSpecies].types[TYPE_SECONDARY]; defAbility = gSpeciesInfo[targetSpecies].abilities[0]; moveType = gBattleMoves[move].type; @@ -5940,8 +5940,8 @@ static void InitRandomTourneyTreeResults(void) statSums[i] += statValues[STAT_SPDEF]; statSums[i] += statValues[STAT_SPEED]; statSums[i] += statValues[STAT_HP]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_PRIMARY]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_SECONDARY]]; } // Because GF hates temporary vars, trainerId acts like monTypesCount here. diff --git a/src/battle_factory.c b/src/battle_factory.c index faed16ebb0e7..33b7bf7a7773 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -608,7 +608,7 @@ static void GetOpponentMostCommonMonType(void) { u8 i; u8 typeCounts[NUMBER_OF_MON_TYPES]; - u8 mostCommonTypes[2]; + u8 mostCommonTypes[NUM_TYPE_SLOTS]; gFacilityTrainerMons = gBattleFrontierMons; @@ -618,33 +618,33 @@ static void GetOpponentMostCommonMonType(void) for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { u32 species = gFacilityTrainerMons[gFrontierTempParty[i]].species; - typeCounts[gSpeciesInfo[species].types[0]]++; - if (gSpeciesInfo[species].types[0] != gSpeciesInfo[species].types[1]) - typeCounts[gSpeciesInfo[species].types[1]]++; + typeCounts[gSpeciesInfo[species].types[TYPE_PRIMARY]]++; + if (gSpeciesInfo[species].types[TYPE_PRIMARY] != gSpeciesInfo[species].types[TYPE_SECONDARY]) + typeCounts[gSpeciesInfo[species].types[TYPE_SECONDARY]]++; } // Determine which are the two most-common types. // The second most-common type is only updated if // its count is equal to the most-common type. - mostCommonTypes[0] = 0; - mostCommonTypes[1] = 0; + mostCommonTypes[TYPE_PRIMARY] = 0; + mostCommonTypes[TYPE_SECONDARY] = 0; for (i = 1; i < NUMBER_OF_MON_TYPES; i++) { - if (typeCounts[mostCommonTypes[0]] < typeCounts[i]) - mostCommonTypes[0] = i; - else if (typeCounts[mostCommonTypes[0]] == typeCounts[i]) - mostCommonTypes[1] = i; + if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] < typeCounts[i]) + mostCommonTypes[TYPE_PRIMARY] = i; + else if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] == typeCounts[i]) + mostCommonTypes[TYPE_SECONDARY] = i; } - if (typeCounts[mostCommonTypes[0]] != 0) + if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] != 0) { // The most-common type must be strictly greater than // the second-most-common type, or the top two must be // the same type. - if (typeCounts[mostCommonTypes[0]] > typeCounts[mostCommonTypes[1]]) - gSpecialVar_Result = mostCommonTypes[0]; - else if (mostCommonTypes[0] == mostCommonTypes[1]) - gSpecialVar_Result = mostCommonTypes[0]; + if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] > typeCounts[mostCommonTypes[TYPE_SECONDARY]]) + gSpecialVar_Result = mostCommonTypes[TYPE_PRIMARY]; + else if (mostCommonTypes[TYPE_PRIMARY] == mostCommonTypes[TYPE_SECONDARY]) + gSpecialVar_Result = mostCommonTypes[TYPE_PRIMARY]; else gSpecialVar_Result = NUMBER_OF_MON_TYPES; } diff --git a/src/battle_main.c b/src/battle_main.c index 75fe6bbd0080..4ad1147c89a6 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3343,8 +3343,8 @@ void FaintClearSetData(void) gBattleResources->flags->flags[gActiveBattler] = 0; - gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; - gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; + gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY]; + gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY]; ClearBattlerMoveHistory(gActiveBattler); ClearBattlerAbilityHistory(gActiveBattler); @@ -3411,8 +3411,8 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) for (i = 0; i < sizeof(struct BattlePokemon); i++) ptr[i] = gBattleBufferB[gActiveBattler][4 + i]; - gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; - gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; + gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY]; + gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY]; gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum); hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)]; *hpOnSwitchout = gBattleMons[gActiveBattler].hp; diff --git a/src/battle_pike.c b/src/battle_pike.c index ba24e58ae7a6..2194551542bb 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -845,21 +845,21 @@ static bool8 DoesTypePreventStatus(u16 species, u32 status) switch (status) { case STATUS1_TOXIC_POISON: - if (gSpeciesInfo[species].types[0] == TYPE_STEEL || gSpeciesInfo[species].types[0] == TYPE_POISON - || gSpeciesInfo[species].types[1] == TYPE_STEEL || gSpeciesInfo[species].types[1] == TYPE_POISON) + if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_STEEL || gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_POISON + || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_STEEL || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_POISON) ret = TRUE; break; case STATUS1_FREEZE: - if (gSpeciesInfo[species].types[0] == TYPE_ICE || gSpeciesInfo[species].types[1] == TYPE_ICE) + if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_ICE || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_ICE) ret = TRUE; break; case STATUS1_PARALYSIS: - if (gSpeciesInfo[species].types[0] == TYPE_GROUND || gSpeciesInfo[species].types[0] == TYPE_ELECTRIC - || gSpeciesInfo[species].types[1] == TYPE_GROUND || gSpeciesInfo[species].types[1] == TYPE_ELECTRIC) + if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GROUND || gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_ELECTRIC + || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GROUND || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_ELECTRIC) ret = TRUE; break; case STATUS1_BURN: - if (gSpeciesInfo[species].types[0] == TYPE_FIRE || gSpeciesInfo[species].types[1] == TYPE_FIRE) + if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_FIRE || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_FIRE) ret = TRUE; break; case STATUS1_SLEEP: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3e8cb8362335..9d5946c88556 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1595,7 +1595,7 @@ u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility) { s32 i = 0; u8 flags = 0; - u8 type1 = gSpeciesInfo[targetSpecies].types[0], type2 = gSpeciesInfo[targetSpecies].types[1]; + u8 type1 = gSpeciesInfo[targetSpecies].types[TYPE_PRIMARY], type2 = gSpeciesInfo[targetSpecies].types[TYPE_SECONDARY]; u8 moveType; if (move == MOVE_STRUGGLE) @@ -4623,8 +4623,8 @@ static void Cmd_switchindataupdate(void) for (i = 0; i < sizeof(struct BattlePokemon); i++) monData[i] = gBattleBufferB[gActiveBattler][4 + i]; - gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; - gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; + gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY]; + gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY]; gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum); // check knocked off item diff --git a/src/contest.c b/src/contest.c index 8f0ad7fbfee2..98306657f757 100644 --- a/src/contest.c +++ b/src/contest.c @@ -5314,7 +5314,7 @@ static void SetMoveSpecificAnimData(u8 contestant) switch (move) { case MOVE_CURSE: - if (gSpeciesInfo[species].types[0] == TYPE_GHOST || gSpeciesInfo[species].types[1] == TYPE_GHOST) + if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GHOST || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GHOST) gAnimMoveTurn = 0; else gAnimMoveTurn = 1; diff --git a/src/field_specials.c b/src/field_specials.c index 7d20d3571d0c..0570c4834ad5 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1238,7 +1238,7 @@ void IsGrassTypeInParty(void) if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG)) { species = GetMonData(pokemon, MON_DATA_SPECIES); - if (gSpeciesInfo[species].types[0] == TYPE_GRASS || gSpeciesInfo[species].types[1] == TYPE_GRASS) + if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GRASS || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GRASS) { gSpecialVar_Result = TRUE; return; diff --git a/src/pokedex.c b/src/pokedex.c index 09a25b872b2d..e622ab913c10 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -4741,9 +4741,9 @@ static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 t { species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum); - types[0] = gSpeciesInfo[species].types[0]; - types[1] = gSpeciesInfo[species].types[1]; - if (types[0] == type1 || types[1] == type1) + types[TYPE_PRIMARY] = gSpeciesInfo[species].types[TYPE_PRIMARY]; + types[TYPE_SECONDARY] = gSpeciesInfo[species].types[TYPE_SECONDARY]; + if (types[TYPE_PRIMARY] == type1 || types[TYPE_SECONDARY] == type1) { sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; resultsCount++; @@ -4759,9 +4759,9 @@ static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 t { species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum); - types[0] = gSpeciesInfo[species].types[0]; - types[1] = gSpeciesInfo[species].types[1]; - if ((types[0] == type1 && types[1] == type2) || (types[0] == type2 && types[1] == type1)) + types[TYPE_PRIMARY] = gSpeciesInfo[species].types[TYPE_PRIMARY]; + types[TYPE_SECONDARY] = gSpeciesInfo[species].types[TYPE_SECONDARY]; + if ((types[TYPE_PRIMARY] == type1 && types[TYPE_SECONDARY] == type2) || (types[TYPE_PRIMARY] == type2 && types[TYPE_SECONDARY] == type1)) { sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; resultsCount++; diff --git a/src/pokemon.c b/src/pokemon.c index d0345006fa7b..e2457ec56195 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4670,8 +4670,8 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex) gBattleMons[battlerId].isEgg = GetMonData(&gPlayerParty[partyIndex], MON_DATA_IS_EGG, NULL); gBattleMons[battlerId].abilityNum = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ABILITY_NUM, NULL); gBattleMons[battlerId].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID, NULL); - gBattleMons[battlerId].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; - gBattleMons[battlerId].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; + gBattleMons[battlerId].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[TYPE_PRIMARY]; + gBattleMons[battlerId].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[TYPE_SECONDARY]; gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].abilityNum); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname); StringCopy_Nickname(gBattleMons[battlerId].nickname, nickname); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 642b176d6b4f..8204ad437b1c 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3796,10 +3796,10 @@ static void SetMonTypeIcons(void) } else { - SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[0], 120, 48, SPRITE_ARR_ID_TYPE); - if (gSpeciesInfo[summary->species].types[0] != gSpeciesInfo[summary->species].types[1]) + SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[TYPE_PRIMARY], 120, 48, SPRITE_ARR_ID_TYPE); + if (gSpeciesInfo[summary->species].types[TYPE_PRIMARY] != gSpeciesInfo[summary->species].types[TYPE_SECONDARY]) { - SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[1], 160, 48, SPRITE_ARR_ID_TYPE + 1); + SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[TYPE_SECONDARY], 160, 48, SPRITE_ARR_ID_TYPE + 1); SetSpriteInvisibility(SPRITE_ARR_ID_TYPE + 1, FALSE); } else diff --git a/src/trade.c b/src/trade.c index e07e418d1add..e27e2f71c614 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2532,8 +2532,8 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf else { // Player's Pokémon must be of the type the partner requested - if (gSpeciesInfo[playerSpecies2].types[0] != requestedType - && gSpeciesInfo[playerSpecies2].types[1] != requestedType) + if (gSpeciesInfo[playerSpecies2].types[TYPE_PRIMARY] != requestedType + && gSpeciesInfo[playerSpecies2].types[TYPE_SECONDARY] != requestedType) return UR_TRADE_MSG_NOT_MON_PARTNER_WANTS; } diff --git a/src/union_room.c b/src/union_room.c index 1b29863183cd..9875a7015ccc 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -4187,7 +4187,7 @@ static s32 IsRequestedTradeInPlayerParty(u32 type, u32 species) for (i = 0; i < gPlayerPartyCount; i++) { species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); - if (gSpeciesInfo[species].types[0] == type || gSpeciesInfo[species].types[1] == type) + if (gSpeciesInfo[species].types[TYPE_PRIMARY] == type || gSpeciesInfo[species].types[TYPE_SECONDARY] == type) return UR_TRADE_MATCH; } return UR_TRADE_NOTYPE; diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 11d01f04eac7..e21f5b51b510 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -922,7 +922,7 @@ static bool8 TryGetRandomWildMonIndexByType(const struct WildPokemon *wildMon, u for (validMonCount = 0, i = 0; i < numMon; i++) { - if (gSpeciesInfo[wildMon[i].species].types[0] == type || gSpeciesInfo[wildMon[i].species].types[1] == type) + if (gSpeciesInfo[wildMon[i].species].types[TYPE_PRIMARY] == type || gSpeciesInfo[wildMon[i].species].types[TYPE_SECONDARY] == type) validIndexes[validMonCount++] = i; } From 17ce367a1a208b62d6e9990baa4303358313bf4a Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sun, 4 Aug 2024 20:31:33 -0700 Subject: [PATCH 4/5] Removed enum per https://github.com/pret/pokeemerald/pull/2021\#issuecomment-2268035123 --- include/battle.h | 6 +-- include/battle_controllers.h | 2 +- include/constants/pokemon.h | 6 --- include/pokemon.h | 2 +- src/battle_ai_script_commands.c | 8 ++-- src/battle_ai_switch_items.c | 8 ++-- src/battle_controller_player.c | 2 +- src/battle_dome.c | 16 ++++---- src/battle_factory.c | 30 +++++++------- src/battle_gfx_sfx_util.c | 2 +- src/battle_main.c | 12 +++--- src/battle_pike.c | 12 +++--- src/battle_script_commands.c | 70 ++++++++++++++++----------------- src/contest.c | 2 +- src/field_specials.c | 2 +- src/pokedex.c | 12 +++--- src/pokemon.c | 4 +- src/pokemon_summary_screen.c | 6 +-- src/trade.c | 4 +- src/union_room.c | 2 +- src/wild_encounter.c | 2 +- 21 files changed, 102 insertions(+), 108 deletions(-) diff --git a/include/battle.h b/include/battle.h index 1e88fabedc6d..eb25b96550b9 100644 --- a/include/battle.h +++ b/include/battle.h @@ -465,11 +465,11 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER #define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0)) -#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].types[TYPE_PRIMARY] == type || gBattleMons[battlerId].types[TYPE_SECONDARY] == type)) +#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].types[0] == type || gBattleMons[battlerId].types[1] == type)) #define SET_BATTLER_TYPE(battlerId, type) \ { \ - gBattleMons[battlerId].types[TYPE_PRIMARY] = type; \ - gBattleMons[battlerId].types[TYPE_SECONDARY] = type; \ + gBattleMons[battlerId].types[0] = type; \ + gBattleMons[battlerId].types[1] = type; \ } #define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8 diff --git a/include/battle_controllers.h b/include/battle_controllers.h index b40507d72fbc..6ca290d868ff 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -124,7 +124,7 @@ struct ChooseMoveStruct u8 currentPp[MAX_MON_MOVES]; u8 maxPp[MAX_MON_MOVES]; u16 species; - u8 monTypes[NUM_TYPE_SLOTS]; + u8 monTypes[2]; }; enum diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 8530f906a7c1..0d6a20e2b9e3 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -23,12 +23,6 @@ #define TYPE_DARK 17 #define NUMBER_OF_MON_TYPES 18 -enum { - TYPE_PRIMARY, - TYPE_SECONDARY, - NUM_TYPE_SLOTS, -}; - // Pokémon egg groups #define EGG_GROUP_NONE 0 #define EGG_GROUP_MONSTER 1 diff --git a/include/pokemon.h b/include/pokemon.h index 68b8731285c7..771d947f0a4b 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -276,7 +276,7 @@ struct BattlePokemon /*0x17*/ u32 abilityNum:1; /*0x18*/ s8 statStages[NUM_BATTLE_STATS]; /*0x20*/ u8 ability; - /*0x21*/ u8 types[NUM_TYPE_SLOTS]; + /*0x21*/ u8 types[2]; /*0x23*/ u8 unknown; /*0x24*/ u8 pp[MAX_MON_MOVES]; /*0x28*/ u16 hp; diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 12981e4a534d..716c4567940e 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1119,16 +1119,16 @@ static void Cmd_get_type(void) switch (typeVar) { case AI_TYPE1_USER: // AI user primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[TYPE_PRIMARY]; + AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[0]; break; case AI_TYPE1_TARGET: // target primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[TYPE_PRIMARY]; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[0]; break; case AI_TYPE2_USER: // AI user secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[TYPE_SECONDARY]; + AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[1]; break; case AI_TYPE2_TARGET: // target secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[TYPE_SECONDARY]; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[1]; break; case AI_TYPE_MOVE: // type of move being pointed to AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 58ff9b8395d7..eeb28f8f0f20 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -703,11 +703,11 @@ u8 GetMostSuitableMonToSwitchInto(void) && i != *(gBattleStruct->monToSwitchIntoId + battlerIn1) && i != *(gBattleStruct->monToSwitchIntoId + battlerIn2)) { - u8 type1 = gSpeciesInfo[species].types[TYPE_PRIMARY]; - u8 type2 = gSpeciesInfo[species].types[TYPE_SECONDARY]; + u8 type1 = gSpeciesInfo[species].types[0]; + u8 type2 = gSpeciesInfo[species].types[1]; u8 typeDmg = TYPE_MUL_NORMAL; - ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_PRIMARY], type1, type2, &typeDmg); - ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_SECONDARY], type1, type2, &typeDmg); + ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[0], type1, type2, &typeDmg); + ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[1], type1, type2, &typeDmg); /* Possible bug: this comparison gives the type that takes the most damage, when a "good" AI would want to select the type that takes the least damage. Unknown if this diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 61cbe105bb8b..e447858fc853 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -485,7 +485,7 @@ static void HandleInputChooseMove(void) PlaySE(SE_SELECT); if (moveInfo->moves[gMoveSelectionCursor[gActiveBattler]] == MOVE_CURSE) { - if (moveInfo->monTypes[TYPE_PRIMARY] != TYPE_GHOST && moveInfo->monTypes[TYPE_SECONDARY] != TYPE_GHOST) + if (moveInfo->monTypes[0] != TYPE_GHOST && moveInfo->monTypes[1] != TYPE_GHOST) moveTarget = MOVE_TARGET_USER; else moveTarget = MOVE_TARGET_SELECTED; diff --git a/src/battle_dome.c b/src/battle_dome.c index 028827273109..68cae14a6eb2 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2405,8 +2405,8 @@ static void InitDomeTrainers(void) rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPDEF, NULL); rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPEED, NULL); rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_MAX_HP, NULL); - monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[TYPE_PRIMARY]]; - monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[TYPE_SECONDARY]]; + monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[0]]; + monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[1]]; } // Count the number of types in the players party, to factor into the ranking @@ -2440,8 +2440,8 @@ static void InitDomeTrainers(void) rankingScores[i] += statValues[STAT_SPDEF]; rankingScores[i] += statValues[STAT_SPEED]; rankingScores[i] += statValues[STAT_HP]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_PRIMARY]]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_SECONDARY]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]]; } for (monTypesCount = 0, j = 0; j < 32; j++) @@ -2807,8 +2807,8 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int mode) if (move == MOVE_NONE || move == MOVE_UNAVAILABLE || gBattleMoves[move].power == 0) return 0; - defType1 = gSpeciesInfo[targetSpecies].types[TYPE_PRIMARY]; - defType2 = gSpeciesInfo[targetSpecies].types[TYPE_SECONDARY]; + defType1 = gSpeciesInfo[targetSpecies].types[0]; + defType2 = gSpeciesInfo[targetSpecies].types[1]; defAbility = gSpeciesInfo[targetSpecies].abilities[0]; moveType = gBattleMoves[move].type; @@ -5940,8 +5940,8 @@ static void InitRandomTourneyTreeResults(void) statSums[i] += statValues[STAT_SPDEF]; statSums[i] += statValues[STAT_SPEED]; statSums[i] += statValues[STAT_HP]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_PRIMARY]]; - monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_SECONDARY]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]]; + monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]]; } // Because GF hates temporary vars, trainerId acts like monTypesCount here. diff --git a/src/battle_factory.c b/src/battle_factory.c index 33b7bf7a7773..faed16ebb0e7 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -608,7 +608,7 @@ static void GetOpponentMostCommonMonType(void) { u8 i; u8 typeCounts[NUMBER_OF_MON_TYPES]; - u8 mostCommonTypes[NUM_TYPE_SLOTS]; + u8 mostCommonTypes[2]; gFacilityTrainerMons = gBattleFrontierMons; @@ -618,33 +618,33 @@ static void GetOpponentMostCommonMonType(void) for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { u32 species = gFacilityTrainerMons[gFrontierTempParty[i]].species; - typeCounts[gSpeciesInfo[species].types[TYPE_PRIMARY]]++; - if (gSpeciesInfo[species].types[TYPE_PRIMARY] != gSpeciesInfo[species].types[TYPE_SECONDARY]) - typeCounts[gSpeciesInfo[species].types[TYPE_SECONDARY]]++; + typeCounts[gSpeciesInfo[species].types[0]]++; + if (gSpeciesInfo[species].types[0] != gSpeciesInfo[species].types[1]) + typeCounts[gSpeciesInfo[species].types[1]]++; } // Determine which are the two most-common types. // The second most-common type is only updated if // its count is equal to the most-common type. - mostCommonTypes[TYPE_PRIMARY] = 0; - mostCommonTypes[TYPE_SECONDARY] = 0; + mostCommonTypes[0] = 0; + mostCommonTypes[1] = 0; for (i = 1; i < NUMBER_OF_MON_TYPES; i++) { - if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] < typeCounts[i]) - mostCommonTypes[TYPE_PRIMARY] = i; - else if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] == typeCounts[i]) - mostCommonTypes[TYPE_SECONDARY] = i; + if (typeCounts[mostCommonTypes[0]] < typeCounts[i]) + mostCommonTypes[0] = i; + else if (typeCounts[mostCommonTypes[0]] == typeCounts[i]) + mostCommonTypes[1] = i; } - if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] != 0) + if (typeCounts[mostCommonTypes[0]] != 0) { // The most-common type must be strictly greater than // the second-most-common type, or the top two must be // the same type. - if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] > typeCounts[mostCommonTypes[TYPE_SECONDARY]]) - gSpecialVar_Result = mostCommonTypes[TYPE_PRIMARY]; - else if (mostCommonTypes[TYPE_PRIMARY] == mostCommonTypes[TYPE_SECONDARY]) - gSpecialVar_Result = mostCommonTypes[TYPE_PRIMARY]; + if (typeCounts[mostCommonTypes[0]] > typeCounts[mostCommonTypes[1]]) + gSpecialVar_Result = mostCommonTypes[0]; + else if (mostCommonTypes[0] == mostCommonTypes[1]) + gSpecialVar_Result = mostCommonTypes[0]; else gSpecialVar_Result = NUMBER_OF_MON_TYPES; } diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 5ba4bde9a07f..ed8cf572ea71 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -264,7 +264,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) if (moveInfo->moves[chosenMoveId] == MOVE_CURSE) { - if (moveInfo->monTypes[TYPE_PRIMARY] != TYPE_GHOST && moveInfo->monTypes[TYPE_SECONDARY] != TYPE_GHOST) + if (moveInfo->monTypes[0] != TYPE_GHOST && moveInfo->monTypes[1] != TYPE_GHOST) moveTarget = MOVE_TARGET_USER; else moveTarget = MOVE_TARGET_SELECTED; diff --git a/src/battle_main.c b/src/battle_main.c index 4ad1147c89a6..9039655c4d8e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3343,8 +3343,8 @@ void FaintClearSetData(void) gBattleResources->flags->flags[gActiveBattler] = 0; - gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY]; - gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY]; + gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; + gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; ClearBattlerMoveHistory(gActiveBattler); ClearBattlerAbilityHistory(gActiveBattler); @@ -3411,8 +3411,8 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) for (i = 0; i < sizeof(struct BattlePokemon); i++) ptr[i] = gBattleBufferB[gActiveBattler][4 + i]; - gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY]; - gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY]; + gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; + gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum); hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)]; *hpOnSwitchout = gBattleMons[gActiveBattler].hp; @@ -4173,8 +4173,8 @@ static void HandleTurnActionSelectionState(void) struct ChooseMoveStruct moveInfo; moveInfo.species = gBattleMons[gActiveBattler].species; - moveInfo.monTypes[TYPE_PRIMARY] = gBattleMons[gActiveBattler].types[TYPE_PRIMARY]; - moveInfo.monTypes[TYPE_SECONDARY] = gBattleMons[gActiveBattler].types[TYPE_SECONDARY]; + moveInfo.monTypes[0] = gBattleMons[gActiveBattler].types[0]; + moveInfo.monTypes[1] = gBattleMons[gActiveBattler].types[1]; for (i = 0; i < MAX_MON_MOVES; i++) { diff --git a/src/battle_pike.c b/src/battle_pike.c index 2194551542bb..ba24e58ae7a6 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -845,21 +845,21 @@ static bool8 DoesTypePreventStatus(u16 species, u32 status) switch (status) { case STATUS1_TOXIC_POISON: - if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_STEEL || gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_POISON - || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_STEEL || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_POISON) + if (gSpeciesInfo[species].types[0] == TYPE_STEEL || gSpeciesInfo[species].types[0] == TYPE_POISON + || gSpeciesInfo[species].types[1] == TYPE_STEEL || gSpeciesInfo[species].types[1] == TYPE_POISON) ret = TRUE; break; case STATUS1_FREEZE: - if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_ICE || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_ICE) + if (gSpeciesInfo[species].types[0] == TYPE_ICE || gSpeciesInfo[species].types[1] == TYPE_ICE) ret = TRUE; break; case STATUS1_PARALYSIS: - if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GROUND || gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_ELECTRIC - || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GROUND || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_ELECTRIC) + if (gSpeciesInfo[species].types[0] == TYPE_GROUND || gSpeciesInfo[species].types[0] == TYPE_ELECTRIC + || gSpeciesInfo[species].types[1] == TYPE_GROUND || gSpeciesInfo[species].types[1] == TYPE_ELECTRIC) ret = TRUE; break; case STATUS1_BURN: - if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_FIRE || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_FIRE) + if (gSpeciesInfo[species].types[0] == TYPE_FIRE || gSpeciesInfo[species].types[1] == TYPE_FIRE) ret = TRUE; break; case STATUS1_SLEEP: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9d5946c88556..6f43c6af706b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1395,11 +1395,11 @@ static void Cmd_typecalc(void) else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY]) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0]) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && - gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY]) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] && + gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); } i += 3; @@ -1454,14 +1454,14 @@ static void CheckWonderGuardAndLevitate(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check no effect - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; gProtectStructs[gBattlerAttacker].targetNotAffected = 1; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && - gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] && + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] && + gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; @@ -1469,18 +1469,18 @@ static void CheckWonderGuardAndLevitate(void) } // check super effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] && TYPE_EFFECT_MULTIPLIER(i) == 20) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0] && TYPE_EFFECT_MULTIPLIER(i) == 20) flags |= 1; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] - && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] + && gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) flags |= 1; // check not very effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] && TYPE_EFFECT_MULTIPLIER(i) == 5) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0] && TYPE_EFFECT_MULTIPLIER(i) == 5) flags |= 2; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] - && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] + && gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) flags |= 2; } @@ -1570,11 +1570,11 @@ u8 TypeCalc(u16 move, u8 attacker, u8 defender) else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[TYPE_PRIMARY]) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[0]) ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[TYPE_SECONDARY] && - gBattleMons[defender].types[TYPE_PRIMARY] != gBattleMons[defender].types[TYPE_SECONDARY]) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[1] && + gBattleMons[defender].types[0] != gBattleMons[defender].types[1]) ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags); } i += 3; @@ -1595,7 +1595,7 @@ u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility) { s32 i = 0; u8 flags = 0; - u8 type1 = gSpeciesInfo[targetSpecies].types[TYPE_PRIMARY], type2 = gSpeciesInfo[targetSpecies].types[TYPE_SECONDARY]; + u8 type1 = gSpeciesInfo[targetSpecies].types[0], type2 = gSpeciesInfo[targetSpecies].types[1]; u8 moveType; if (move == MOVE_STRUGGLE) @@ -3971,7 +3971,7 @@ static void Cmd_jumpiftype2(void) { u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); - if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[TYPE_PRIMARY] || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[TYPE_SECONDARY]) + if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[0] || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[1]) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; @@ -4520,7 +4520,7 @@ static void Cmd_typecalc2(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_PRIMARY]) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0]) { if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { @@ -4537,22 +4537,22 @@ static void Cmd_typecalc2(void) } } // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY]) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]) { - if (gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + if (gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; break; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] - && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] + && gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) { flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] - && gBattleMons[gBattlerTarget].types[TYPE_PRIMARY] != gBattleMons[gBattlerTarget].types[TYPE_SECONDARY] + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] + && gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) { flags |= MOVE_RESULT_SUPER_EFFECTIVE; @@ -4623,8 +4623,8 @@ static void Cmd_switchindataupdate(void) for (i = 0; i < sizeof(struct BattlePokemon); i++) monData[i] = gBattleBufferB[gActiveBattler][4 + i]; - gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY]; - gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY]; + gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0]; + gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1]; gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum); // check knocked off item @@ -7354,8 +7354,8 @@ static void Cmd_tryconversiontypechange(void) else moveType = TYPE_NORMAL; } - if (moveType != gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] - && moveType != gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY]) + if (moveType != gBattleMons[gBattlerAttacker].types[0] + && moveType != gBattleMons[gBattlerAttacker].types[1]) { break; } @@ -7381,7 +7381,7 @@ static void Cmd_tryconversiontypechange(void) moveType = TYPE_NORMAL; } } - while (moveType == gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] || moveType == gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY]); + while (moveType == gBattleMons[gBattlerAttacker].types[0] || moveType == gBattleMons[gBattlerAttacker].types[1]); SET_BATTLER_TYPE(gBattlerAttacker, moveType); PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType); @@ -7548,12 +7548,12 @@ static void Cmd_weatherdamage(void) { if (gBattleWeather & B_WEATHER_SANDSTORM) { - if (gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] != TYPE_ROCK - && gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] != TYPE_STEEL - && gBattleMons[gBattlerAttacker].types[TYPE_PRIMARY] != TYPE_GROUND - && gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY] != TYPE_ROCK - && gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY] != TYPE_STEEL - && gBattleMons[gBattlerAttacker].types[TYPE_SECONDARY] != TYPE_GROUND + if (gBattleMons[gBattlerAttacker].types[0] != TYPE_ROCK + && gBattleMons[gBattlerAttacker].types[0] != TYPE_STEEL + && gBattleMons[gBattlerAttacker].types[0] != TYPE_GROUND + && gBattleMons[gBattlerAttacker].types[1] != TYPE_ROCK + && gBattleMons[gBattlerAttacker].types[1] != TYPE_STEEL + && gBattleMons[gBattlerAttacker].types[1] != TYPE_GROUND && gBattleMons[gBattlerAttacker].ability != ABILITY_SAND_VEIL && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) diff --git a/src/contest.c b/src/contest.c index 98306657f757..8f0ad7fbfee2 100644 --- a/src/contest.c +++ b/src/contest.c @@ -5314,7 +5314,7 @@ static void SetMoveSpecificAnimData(u8 contestant) switch (move) { case MOVE_CURSE: - if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GHOST || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GHOST) + if (gSpeciesInfo[species].types[0] == TYPE_GHOST || gSpeciesInfo[species].types[1] == TYPE_GHOST) gAnimMoveTurn = 0; else gAnimMoveTurn = 1; diff --git a/src/field_specials.c b/src/field_specials.c index 0570c4834ad5..7d20d3571d0c 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1238,7 +1238,7 @@ void IsGrassTypeInParty(void) if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG)) { species = GetMonData(pokemon, MON_DATA_SPECIES); - if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GRASS || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GRASS) + if (gSpeciesInfo[species].types[0] == TYPE_GRASS || gSpeciesInfo[species].types[1] == TYPE_GRASS) { gSpecialVar_Result = TRUE; return; diff --git a/src/pokedex.c b/src/pokedex.c index e622ab913c10..09a25b872b2d 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -4741,9 +4741,9 @@ static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 t { species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum); - types[TYPE_PRIMARY] = gSpeciesInfo[species].types[TYPE_PRIMARY]; - types[TYPE_SECONDARY] = gSpeciesInfo[species].types[TYPE_SECONDARY]; - if (types[TYPE_PRIMARY] == type1 || types[TYPE_SECONDARY] == type1) + types[0] = gSpeciesInfo[species].types[0]; + types[1] = gSpeciesInfo[species].types[1]; + if (types[0] == type1 || types[1] == type1) { sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; resultsCount++; @@ -4759,9 +4759,9 @@ static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 t { species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum); - types[TYPE_PRIMARY] = gSpeciesInfo[species].types[TYPE_PRIMARY]; - types[TYPE_SECONDARY] = gSpeciesInfo[species].types[TYPE_SECONDARY]; - if ((types[TYPE_PRIMARY] == type1 && types[TYPE_SECONDARY] == type2) || (types[TYPE_PRIMARY] == type2 && types[TYPE_SECONDARY] == type1)) + types[0] = gSpeciesInfo[species].types[0]; + types[1] = gSpeciesInfo[species].types[1]; + if ((types[0] == type1 && types[1] == type2) || (types[0] == type2 && types[1] == type1)) { sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; resultsCount++; diff --git a/src/pokemon.c b/src/pokemon.c index e2457ec56195..077b8567938f 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4670,8 +4670,8 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex) gBattleMons[battlerId].isEgg = GetMonData(&gPlayerParty[partyIndex], MON_DATA_IS_EGG, NULL); gBattleMons[battlerId].abilityNum = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ABILITY_NUM, NULL); gBattleMons[battlerId].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID, NULL); - gBattleMons[battlerId].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[TYPE_PRIMARY]; - gBattleMons[battlerId].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[TYPE_SECONDARY]; + gBattleMons[battlerId].types[0] = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; + gBattleMons[battlerId].types[1] = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].abilityNum); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname); StringCopy_Nickname(gBattleMons[battlerId].nickname, nickname); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 8204ad437b1c..642b176d6b4f 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3796,10 +3796,10 @@ static void SetMonTypeIcons(void) } else { - SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[TYPE_PRIMARY], 120, 48, SPRITE_ARR_ID_TYPE); - if (gSpeciesInfo[summary->species].types[TYPE_PRIMARY] != gSpeciesInfo[summary->species].types[TYPE_SECONDARY]) + SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[0], 120, 48, SPRITE_ARR_ID_TYPE); + if (gSpeciesInfo[summary->species].types[0] != gSpeciesInfo[summary->species].types[1]) { - SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[TYPE_SECONDARY], 160, 48, SPRITE_ARR_ID_TYPE + 1); + SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[1], 160, 48, SPRITE_ARR_ID_TYPE + 1); SetSpriteInvisibility(SPRITE_ARR_ID_TYPE + 1, FALSE); } else diff --git a/src/trade.c b/src/trade.c index e27e2f71c614..e07e418d1add 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2532,8 +2532,8 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf else { // Player's Pokémon must be of the type the partner requested - if (gSpeciesInfo[playerSpecies2].types[TYPE_PRIMARY] != requestedType - && gSpeciesInfo[playerSpecies2].types[TYPE_SECONDARY] != requestedType) + if (gSpeciesInfo[playerSpecies2].types[0] != requestedType + && gSpeciesInfo[playerSpecies2].types[1] != requestedType) return UR_TRADE_MSG_NOT_MON_PARTNER_WANTS; } diff --git a/src/union_room.c b/src/union_room.c index 9875a7015ccc..1b29863183cd 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -4187,7 +4187,7 @@ static s32 IsRequestedTradeInPlayerParty(u32 type, u32 species) for (i = 0; i < gPlayerPartyCount; i++) { species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); - if (gSpeciesInfo[species].types[TYPE_PRIMARY] == type || gSpeciesInfo[species].types[TYPE_SECONDARY] == type) + if (gSpeciesInfo[species].types[0] == type || gSpeciesInfo[species].types[1] == type) return UR_TRADE_MATCH; } return UR_TRADE_NOTYPE; diff --git a/src/wild_encounter.c b/src/wild_encounter.c index e21f5b51b510..11d01f04eac7 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -922,7 +922,7 @@ static bool8 TryGetRandomWildMonIndexByType(const struct WildPokemon *wildMon, u for (validMonCount = 0, i = 0; i < numMon; i++) { - if (gSpeciesInfo[wildMon[i].species].types[TYPE_PRIMARY] == type || gSpeciesInfo[wildMon[i].species].types[TYPE_SECONDARY] == type) + if (gSpeciesInfo[wildMon[i].species].types[0] == type || gSpeciesInfo[wildMon[i].species].types[1] == type) validIndexes[validMonCount++] = i; } From 82bad72ade1ee89c2bc63dc38087a5429d4a809f Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Mon, 5 Aug 2024 15:12:19 -0700 Subject: [PATCH 5/5] Removed tabs per https://github.com/pret/pokeemerald/pull/2021\#discussion_r1704542065 --- include/battle_controllers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 6ca290d868ff..0024e006b686 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -124,7 +124,7 @@ struct ChooseMoveStruct u8 currentPp[MAX_MON_MOVES]; u8 maxPp[MAX_MON_MOVES]; u16 species; - u8 monTypes[2]; + u8 monTypes[2]; }; enum