From ef41a4c14d8008b41dd468f9f1a124f1b5a8c017 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sun, 6 Dec 2020 16:14:02 +1300 Subject: [PATCH 1/3] Fix Jump Kick * Now inflicts recoil damage on the user if the target was immune to the attack * Gen V+ recoil damage is now half of the user's HP instead of half of the target's HP. --- data/battle_scripts_1.s | 7 ++++--- src/battle_script_commands.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0ccaa7ef64..63ae752ec1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2806,6 +2806,8 @@ BattleScript_EffectDoubleHit:: BattleScript_EffectRecoilIfMiss:: attackcanceler accuracycheck BattleScript_MoveMissedDoDamage, ACC_CURR_MOVE + typecalc + jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveMissedDoDamage goto BattleScript_HitFromAtkString BattleScript_MoveMissedDoDamage:: jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_PrintMoveMissed @@ -2814,19 +2816,18 @@ BattleScript_MoveMissedDoDamage:: pause 0x40 resultmessage waitmessage 0x40 - jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd printstring STRINGID_PKMNCRASHED waitmessage 0x40 damagecalc typecalc adjustdamage manipulatedamage DMG_RECOIL_FROM_MISS - bichalfword gMoveResultFlags, MOVE_RESULT_MISSED + bichalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL - orhalfword gMoveResultFlags, MOVE_RESULT_MISSED + orhalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE goto BattleScript_MoveEnd BattleScript_EffectMist:: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 16e2989f8e..ab3b70e69b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8584,7 +8584,7 @@ static void Cmd_manipulatedamage(void) if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; if (B_RECOIL_IF_MISS_DMG >= GEN_5 || ((gBattleMons[gBattlerTarget].maxHP / 2) < gBattleMoveDamage)) - gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2; break; case DMG_DOUBLED: gBattleMoveDamage *= 2; From 72b769ec7518e1d8dbdd57b94e721f6107c6f83c Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Mon, 7 Dec 2020 19:30:31 +1300 Subject: [PATCH 2/3] Add config options for Jump Kick Added options for: - Gen 4 style recoil when target is immune (user takes 50% of target's max HP) - Gen 3 style recoil when target is immune (i.e no recoil) - Gen 5+ recoil was already implemented but was bugged --- data/battle_scripts_1.s | 17 +++++++++++++++++ include/constants/battle_config.h | 1 + include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 3 +++ 4 files changed, 22 insertions(+) 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; From a3b891bd653434fa6587275724e334650b502ec3 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Mon, 7 Dec 2020 19:41:49 +1300 Subject: [PATCH 3/3] Cap recoil for Gen 4 Jump Kick Jump Kick's recoil in Gen 4 cannot exceed half of the target's maximum HP. --- src/battle_script_commands.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 58e4cf60da..2de22dd989 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8583,8 +8583,10 @@ 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: gBattleMoveDamage *= 2;