diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 74eb40f0ef..11cf51770f 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -54,6 +54,10 @@ #define SPECIES_SIRFETCHD 10021 #define SPECIES_DARMANITAN_GALARIAN 0 #define SPECIES_DARMANITAN_ZEN_MODE_GALARIAN 10022 + #define SPECIES_HEATMOR 0 + #define SPECIES_DURANT 0 + #define SPECIES_CARBINK 0 + #define SPECIES_MAREANIE 0 #endif // Items with peculiar battle effects. @@ -237,6 +241,7 @@ // Other settings #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. #define B_MULTI_BATTLE_WHITEOUT GEN_8 // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. +#define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper) // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 0c4b08620c..08566ebd24 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1614,7 +1614,42 @@ static void OpponentHandleChooseMove(void) if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gActiveBattler << 8)); else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + { + #if B_WILD_NATURAL_ENEMIES == TRUE + // Don't bother to loop through table if the move can't attack ally + if (!(gBattleMoves[move].target & MOVE_TARGET_BOTH)) + { + u16 i, speciesAttacker, speciesTarget, isPartnerEnemy = FALSE; + static const u16 naturalEnemies[][2] = + { + // Attacker Target + {SPECIES_ZANGOOSE, SPECIES_SEVIPER}, + {SPECIES_SEVIPER, SPECIES_ZANGOOSE}, + {SPECIES_HEATMOR, SPECIES_DURANT}, + {SPECIES_DURANT, SPECIES_HEATMOR}, + {SPECIES_SABLEYE, SPECIES_CARBINK}, + {SPECIES_MAREANIE, SPECIES_CORSOLA}, + }; + speciesAttacker = gBattleMons[gActiveBattler].species; + speciesTarget = gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler))].species; + + for (i = 0; i < ARRAY_COUNT(naturalEnemies); i++) + { + if (speciesAttacker == naturalEnemies[i][0] && speciesTarget == naturalEnemies[i][1]) + { + isPartnerEnemy = TRUE; + break; + } + } + if (isPartnerEnemy) + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler)) << 8)); + else + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + } + else + #endif + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + } else BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));