From 1708ac4b1b23de381fdc6ebdcde09f8e374d63dd Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 4 Dec 2021 22:13:29 -0300 Subject: [PATCH 1/2] Wild mon that have a natural enemy or preys on other mon will attack them whem partnered in double wild battles. --- include/constants/battle_config.h | 7 +++++- src/battle_controller_opponent.c | 37 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 29b7b57503..146ce8948e 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -52,6 +52,10 @@ #define SPECIES_MORPEKO 0 #define SPECIES_MORPEKO_HANGRY 10020 #define SPECIES_SIRFETCHD 10021 + #define SPECIES_HEATMOR 0 + #define SPECIES_DURANT 0 + #define SPECIES_CARBINK 0 + #define SPECIES_MAREANIE 0 #endif // Items with peculiar battle effects. @@ -227,7 +231,8 @@ #define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball. // Other -#define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. +#define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. +#define B_WILD_NATURAL_ENEMIES 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 f4982b8043..212894d402 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1617,7 +1617,42 @@ static void OpponentHandleChooseMove(void) if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBattler << 8)); else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - BtlController_EmitTwoReturnValues(1, 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(1, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler)) << 8)); + else + BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + } + else + #endif + BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + } else BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); From 925f65c450cc56be251e0d5c51dae67f04505b31 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 16 Jan 2022 21:10:09 -0300 Subject: [PATCH 2/2] Realigned config to previous state --- include/constants/battle_config.h | 106 +++++++++++++++--------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index d2c25dd2cd..5f37c39416 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -5,59 +5,59 @@ // Species with peculiar battle effects. #ifndef POKEMON_EXPANSION - #define SPECIES_DIALGA 0 - #define SPECIES_PALKIA 0 - #define SPECIES_GIRATINA 0 - #define SPECIES_CHERRIM 0 - #define SPECIES_ARCEUS 0 - #define SPECIES_SILVALLY 0 - #define SPECIES_GENESECT 0 - #define SPECIES_AEGISLASH 0 - #define SPECIES_AEGISLASH_BLADE 10000 - #define SPECIES_MIMIKYU 0 - #define SPECIES_MIMIKYU_BUSTED 10001 - #define SPECIES_DARMANITAN 0 - #define SPECIES_DARMANITAN_ZEN_MODE 10002 - #define SPECIES_MINIOR_CORE_RED 0 - #define SPECIES_MINIOR 10003 - #define SPECIES_MINIOR_CORE_BLUE 0 - #define SPECIES_MINIOR_METEOR_BLUE 10004 - #define SPECIES_MINIOR_CORE_GREEN 0 - #define SPECIES_MINIOR_METEOR_GREEN 10005 - #define SPECIES_MINIOR_CORE_INDIGO 0 - #define SPECIES_MINIOR_METEOR_INDIGO 10006 - #define SPECIES_MINIOR_CORE_ORANGE 0 - #define SPECIES_MINIOR_METEOR_ORANGE 10007 - #define SPECIES_MINIOR_CORE_VIOLET 0 - #define SPECIES_MINIOR_METEOR_VIOLET 10008 - #define SPECIES_MINIOR_CORE_YELLOW 0 - #define SPECIES_MINIOR_METEOR_YELLOW 10009 - #define SPECIES_WISHIWASHI 0 - #define SPECIES_WISHIWASHI_SCHOOL 10010 - #define SPECIES_ZYGARDE 0 // 50% - #define SPECIES_ZYGARDE_10 10011 // 10 % - #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % - #define SPECIES_BURMY 0 - #define SPECIES_BURMY_SANDY_CLOAK 10013 - #define SPECIES_BURMY_TRASH_CLOAK 10014 - #define SPECIES_CRAMORANT 0 - #define SPECIES_CRAMORANT_GORGING 10015 - #define SPECIES_CRAMORANT_GULPING 10016 - #define SPECIES_GRENINJA_BATTLE_BOND 0 - #define SPECIES_GRENINJA_ASH 10017 - #define SPECIES_HOOPA 0 - #define SPECIES_HOOPA_UNBOUND 10018 - #define SPECIES_MELOETTA 0 - #define SPECIES_MELOETTA_PIROUETTE 10019 - #define SPECIES_MORPEKO 0 - #define SPECIES_MORPEKO_HANGRY 10020 - #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 + #define SPECIES_DIALGA 0 + #define SPECIES_PALKIA 0 + #define SPECIES_GIRATINA 0 + #define SPECIES_CHERRIM 0 + #define SPECIES_ARCEUS 0 + #define SPECIES_SILVALLY 0 + #define SPECIES_GENESECT 0 + #define SPECIES_AEGISLASH 0 + #define SPECIES_AEGISLASH_BLADE 10000 + #define SPECIES_MIMIKYU 0 + #define SPECIES_MIMIKYU_BUSTED 10001 + #define SPECIES_DARMANITAN 0 + #define SPECIES_DARMANITAN_ZEN_MODE 10002 + #define SPECIES_MINIOR_CORE_RED 0 + #define SPECIES_MINIOR 10003 + #define SPECIES_MINIOR_CORE_BLUE 0 + #define SPECIES_MINIOR_METEOR_BLUE 10004 + #define SPECIES_MINIOR_CORE_GREEN 0 + #define SPECIES_MINIOR_METEOR_GREEN 10005 + #define SPECIES_MINIOR_CORE_INDIGO 0 + #define SPECIES_MINIOR_METEOR_INDIGO 10006 + #define SPECIES_MINIOR_CORE_ORANGE 0 + #define SPECIES_MINIOR_METEOR_ORANGE 10007 + #define SPECIES_MINIOR_CORE_VIOLET 0 + #define SPECIES_MINIOR_METEOR_VIOLET 10008 + #define SPECIES_MINIOR_CORE_YELLOW 0 + #define SPECIES_MINIOR_METEOR_YELLOW 10009 + #define SPECIES_WISHIWASHI 0 + #define SPECIES_WISHIWASHI_SCHOOL 10010 + #define SPECIES_ZYGARDE 0 // 50% + #define SPECIES_ZYGARDE_10 10011 // 10 % + #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % + #define SPECIES_BURMY 0 + #define SPECIES_BURMY_SANDY_CLOAK 10013 + #define SPECIES_BURMY_TRASH_CLOAK 10014 + #define SPECIES_CRAMORANT 0 + #define SPECIES_CRAMORANT_GORGING 10015 + #define SPECIES_CRAMORANT_GULPING 10016 + #define SPECIES_GRENINJA_BATTLE_BOND 0 + #define SPECIES_GRENINJA_ASH 10017 + #define SPECIES_HOOPA 0 + #define SPECIES_HOOPA_UNBOUND 10018 + #define SPECIES_MELOETTA 0 + #define SPECIES_MELOETTA_PIROUETTE 10019 + #define SPECIES_MORPEKO 0 + #define SPECIES_MORPEKO_HANGRY 10020 + #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.