From 8eaf0718ec3adc4d1b51358f99b65dda0dc7d4da Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 23 Jan 2022 02:50:39 -0300 Subject: [PATCH] Review changes Also updated tryfaintmon call in BattleScript_FlingEnd, and updated CanFling. --- asm/macros/battle_script.inc | 4 ++-- data/battle_scripts_1.s | 7 ++----- include/constants/battle_script_commands.h | 2 +- src/battle_script_commands.c | 23 ++-------------------- src/battle_util.c | 3 ++- 5 files changed, 9 insertions(+), 30 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index b7cdeec93..0aeb7309c 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1932,8 +1932,8 @@ various BS_ATTACKER, VARIOUS_SHELL_SIDE_ARM_CHECK .endm - .macro jumpifflingfails battler:req, ptr:req - various \battler, VARIOUS_JUMP_IF_FLING_FAILS + .macro jumpifcantfling battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_CANT_FLING .4byte \ptr .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 7bd93c9db..7aa3c28b7 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -464,12 +464,9 @@ BattleScript_SkyDropFlyingAlreadyConfused: goto BattleScript_ThrashConfuses BattleScript_EffectFling: - jumpifflingfails BS_ATTACKER, BattleScript_ButItFailedAtkStringPpReduce + jumpifcantfling BS_ATTACKER, BattleScript_ButItFailedAtkStringPpReduce jumpifstatus3 BS_ATTACKER, STATUS3_EMBARGO, BattleScript_ButItFailedAtkStringPpReduce jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MAGIC_ROOM, BattleScript_ButItFailedAtkStringPpReduce -.if B_KLUTZ_FLING_INTERACTION >= GEN_5 - jumpifability BS_ATTACKER, ABILITY_KLUTZ, BattleScript_ButItFailedAtkStringPpReduce -.endif setlastuseditem BS_ATTACKER removeitem BS_ATTACKER attackcanceler @@ -511,7 +508,7 @@ BattleScript_EffectFlingConsumeBerry: setbyte sBERRY_OVERRIDE, FALSE restorebattleritem BS_TARGET BattleScript_FlingEnd: - tryfaintmon BS_TARGET, FALSE, NULL + tryfaintmon BS_TARGET goto BattleScript_MoveEnd BattleScript_FlingFlameOrb: diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 819184c3b..594de9ef7 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -229,7 +229,7 @@ #define VARIOUS_SET_SKY_DROP 139 #define VARIOUS_CLEAR_SKY_DROP 140 #define VARIOUS_SKY_DROP_YAWN 141 -#define VARIOUS_JUMP_IF_FLING_FAILS 142 +#define VARIOUS_JUMP_IF_CANT_FLING 142 #define VARIOUS_JUMP_IF_HOLD_EFFECT 143 #define VARIOUS_CURE_CERTAIN_STATUSES 144 #define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 145 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cef2da350..17ea3eaa8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1356,19 +1356,6 @@ static void Cmd_attackcanceler(void) GET_MOVE_TYPE(gCurrentMove, moveType); - // Unnerve prevents a Pokémon holding a Berry from using Fling. - if (gCurrentMove == MOVE_FLING - && GetBattlerAbility(gBattlerAttacker) == ABILITY_UNNERVE - && ItemId_GetPocket(gLastUsedItem) == POCKET_BERRIES) - { - // Fling removes the item just before attackcanceler kicks in. - // This is done to work around an opponent using Protect/Detect. - gBattleMons[gBattlerAttacker].item = gLastUsedItem; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_ButItFailedAtkStringPpReduce; - return; - } - if (moveType == TYPE_FIRE && (gBattleWeather & B_WEATHER_RAIN_PRIMAL) && WEATHER_HAS_EFFECT @@ -9467,14 +9454,8 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; return; } - case VARIOUS_JUMP_IF_FLING_FAILS: - #ifdef ITEM_EXPANSION - if (!ItemId_GetFlingPower(gBattleMons[gActiveBattler].item)) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); - else if (gLastUsedItem == ITEM_NONE) - #else - if (gLastUsedItem == ITEM_NONE) - #endif + case VARIOUS_JUMP_IF_CANT_FLING: + if (!CanFling(gActiveBattler)) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; diff --git a/src/battle_util.c b/src/battle_util.c index 23f2a3500..b531d5679 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9620,7 +9620,9 @@ bool32 CanFling(u8 battlerId) u16 itemEffect = ItemId_GetHoldEffect(item); if (item == ITEM_NONE + #if B_KLUTZ_FLING_INTERACTION >= GEN_5 || GetBattlerAbility(battlerId) == ABILITY_KLUTZ + #endif || gFieldStatuses & STATUS_FIELD_MAGIC_ROOM || gDisableStructs[battlerId].embargoTimer != 0 || !CanBattlerGetOrLoseItem(battlerId, item) @@ -9629,7 +9631,6 @@ bool32 CanFling(u8 battlerId) #ifdef ITEM_ABILITY_CAPSULE || item == ITEM_ABILITY_CAPSULE #endif - || (ItemId_GetPocket(item) == POCKET_BERRIES && IsAbilityOnSide(battlerId, ABILITY_UNNERVE)) || GetPocketByItemId(item) == POCKET_POKE_BALLS) return FALSE;