diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0856324e2d..3eb1f5cbe6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2805,6 +2805,10 @@ BattleScript_EffectDoubleHit:: BattleScript_EffectRecoilIfMiss:: attackcanceler accuracycheck BattleScript_MoveMissedDoDamage, ACC_CURR_MOVE +.if B_CRASH_IF_TARGET_IMMUNE >= GEN_4 + typecalc + jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveMissedDoDamage +.endif goto BattleScript_HitFromAtkString BattleScript_MoveMissedDoDamage:: jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_PrintMoveMissed @@ -2813,19 +2817,33 @@ BattleScript_MoveMissedDoDamage:: pause 0x40 resultmessage waitmessage 0x40 +.if B_CRASH_IF_TARGET_IMMUNE < GEN_4 jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd +.endif printstring STRINGID_PKMNCRASHED waitmessage 0x40 damagecalc typecalc adjustdamage +.if B_CRASH_IF_TARGET_IMMUNE == GEN_4 + manipulatedamage DMG_RECOIL_FROM_IMMUNE +.else manipulatedamage DMG_RECOIL_FROM_MISS +.endif +.if B_CRASH_IF_TARGET_IMMUNE >= GEN_4 + bichalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE +.else bichalfword gMoveResultFlags, MOVE_RESULT_MISSED +.endif orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL +.if B_CRASH_IF_TARGET_IMMUNE >= GEN_4 + orhalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE +.else orhalfword gMoveResultFlags, MOVE_RESULT_MISSED +.endif goto BattleScript_MoveEnd BattleScript_EffectMist:: diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 482a30b1ca..d7f268ae8e 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -111,6 +111,7 @@ #define B_MINIMIZE_DMG_ACC GEN_6 // In Gen6+, moves that causes double damage to minimized Pokémon will also skip accuracy checks. #define B_PP_REDUCED_BY_SPITE GEN_6 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5. #define B_CAN_SPITE_FAIL GEN_6 // In Gen4+, Spite can no longer fail if the foe's last move only has 1 remaining PP. +#define B_CRASH_IF_TARGET_IMMUNE GEN_6 // In Gen4+, The user of Jump Kick or Hi Jump Kick will "keep going and crash" if it attacks a target that is immune to the move. // Ability settings #define B_ABILITY_WEATHER GEN_6 // In Gen6+, ability-induced weather lasts 5 turns. Before, it lasted until the battle ended or until it was changed by a move. diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 36165558b1..2f52da3197 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -177,6 +177,7 @@ #define DMG_CURR_ATTACKER_HP 5 #define DMG_BIG_ROOT 6 #define DMG_1_2_ATTACKER_HP 7 +#define DMG_RECOIL_FROM_IMMUNE 8 // Used to calculate recoil for the Gen 4 version of Jump Kick // Cmd_jumpifcantswitch #define SWITCH_IGNORE_ESCAPE_PREVENTION 0x80 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c1587f0940..bc427698ef 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8586,7 +8586,9 @@ static void Cmd_manipulatedamage(void) gBattleMoveDamage /= 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - if (B_RECOIL_IF_MISS_DMG >= GEN_5 || ((gBattleMons[gBattlerTarget].maxHP / 2) < gBattleMoveDamage)) + if (B_RECOIL_IF_MISS_DMG >= GEN_5) + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2; + if ((B_RECOIL_IF_MISS_DMG <= GEN_4) && ((gBattleMons[gBattlerTarget].maxHP / 2) < gBattleMoveDamage)) gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2; break; case DMG_DOUBLED: @@ -8609,6 +8611,9 @@ static void Cmd_manipulatedamage(void) case DMG_1_2_ATTACKER_HP: gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2; break; + case DMG_RECOIL_FROM_IMMUNE: + gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2; + break; } gBattlescriptCurrInstr += 2;