diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 63ae752ec1..d72346b121 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2806,8 +2806,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 @@ -2816,18 +2818,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 55c62af987..7acfaf026b 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -109,6 +109,7 @@ #define B_DISABLE_TURNS GEN_6 // Disable's turns. See Cmd_disablelastusedattack. #define B_INCINERATE_GEMS GEN_6 // In Gen6+, Incinerate can destroy Gems. #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_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 Gen5+, weather caused by abilities lasts the same amount of turns as induced from a move. Before, they lasted till the battle's end or weather change by a move. diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index b081907ec3..38f9254cbf 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -175,6 +175,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 ab3b70e69b..58e4cf60da 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8606,6 +8606,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;