From bb8d0e3d6b87d02d93e4bcbad10518e34f936b20 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Thu, 14 Oct 2021 16:18:11 +1300 Subject: [PATCH] Fix Battle Bond Battle Bond Greninja transforms only after a KO, and doesn't revert when switched out. --- asm/macros/battle_script.inc | 4 ++++ data/battle_scripts_1.s | 1 + include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 13 +++++++++++++ src/battle_util.c | 18 +++--------------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4d8fe0365..7ed108bde 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1825,6 +1825,10 @@ various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER .endm + .macro tryactivatebattlebond battler:req + various \battler, VARIOUS_TRY_ACTIVATE_BATTLE_BOND + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e1fb47930..9ec90e3df 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5288,6 +5288,7 @@ BattleScript_FaintTarget:: tryactivatemoxie BS_ATTACKER @ and chilling neigh, as one ice rider tryactivatebeastboost BS_ATTACKER tryactivategrimneigh BS_ATTACKER @ and as one shadow rider + tryactivatebattlebond BS_ATTACKER trytrainerslidefirstdownmsg BS_TARGET return diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d61eabbf8..29236c7b0 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -185,6 +185,7 @@ #define VARIOUS_REMOVE_TERRAIN 113 #define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 #define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 +#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 116 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..472487e09 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8822,6 +8822,19 @@ static void Cmd_various(void) } break; } + case VARIOUS_TRY_ACTIVATE_BATTLE_BOND: + if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND + && HasAttackerFaintedTarget() + && CalculateEnemyPartyCount() > 1) + { + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); + gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; + gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; + return; + } + break; } gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index 68e787698..e4b8f9cf3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5147,18 +5147,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; - case ABILITY_BATTLE_BOND: - if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND - && gBattleResults.opponentFaintCounter != 0 - && CalculateEnemyPartyCount() > 1) - { - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); - gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; - gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; - } - break; } break; case ABILITYEFFECT_MOVE_END_OTHER: // Abilities that activate on *another* battler's moveend: Dancer, Soul-Heart, Receiver, Symbiosis @@ -8846,6 +8834,7 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut) static const u16 species[][2] = // changed form id, default form id { {SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU}, + {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND}, {SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH}, {SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN}, {SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED}, @@ -8858,11 +8847,10 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut) {SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI}, {SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT}, {SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT}, - {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND}, }; - if (isSwitchingOut) // Don't revert Mimikyu Busted when switching out - i = 1; + if (isSwitchingOut) // Don't revert Mimikyu Busted or Ash-Greninja when switching out + i = 2; else i = 0;