From b93e58266e03e9c9a9592ededa40629b67604bdd Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:43:58 +0200 Subject: [PATCH] Fixes recoil moves not triggering berries if possible (#5449) * Fixes recoil moves not triggering berries if possible * Update battle_script_commands.h --- include/constants/battle_script_commands.h | 84 +++++++++++----------- src/battle_script_commands.c | 7 +- test/battle/hold_effect/restore_hp.c | 36 ++++++++++ 3 files changed, 86 insertions(+), 41 deletions(-) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 03173c43cf..901a76c1a8 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -273,46 +273,50 @@ #define PARTY_SCREEN_OPTIONAL (1 << 7) // Flag for first argument to openpartyscreen // cases for Cmd_moveend -#define MOVEEND_SUM_DAMAGE 0 -#define MOVEEND_PROTECT_LIKE_EFFECT 1 -#define MOVEEND_RAGE 2 -#define MOVEEND_SYNCHRONIZE_TARGET 3 -#define MOVEEND_ABILITIES 4 -#define MOVEEND_ABILITIES_ATTACKER 5 -#define MOVEEND_STATUS_IMMUNITY_ABILITIES 6 -#define MOVEEND_SYNCHRONIZE_ATTACKER 7 -#define MOVEEND_CHOICE_MOVE 8 -#define MOVEEND_ATTACKER_INVISIBLE 9 -#define MOVEEND_ATTACKER_VISIBLE 10 -#define MOVEEND_TARGET_VISIBLE 11 -#define MOVEEND_ITEM_EFFECTS_TARGET 12 -#define MOVEEND_MOVE_EFFECTS2 13 -#define MOVEEND_ITEM_EFFECTS_ALL 14 -#define MOVEEND_KINGSROCK 15 // These item effects will occur each strike of a multi-hit move -#define MOVEEND_NUM_HITS 16 -#define MOVEEND_SUBSTITUTE 17 -#define MOVEEND_SKY_DROP_CONFUSE 18 -#define MOVEEND_UPDATE_LAST_MOVES 19 -#define MOVEEND_MIRROR_MOVE 20 -#define MOVEEND_NEXT_TARGET 21 // Everything up until here is handled for each strike of a multi-hit move -#define MOVEEND_MULTIHIT_MOVE 22 -#define MOVEEND_DEFROST 23 -#define MOVEEND_RECOIL 24 -#define MOVEEND_MAGICIAN 25 // Occurs after final multi-hit strike, and after other items/abilities would activate -#define MOVEEND_EJECT_ITEMS 26 -#define MOVEEND_WHITE_HERB 27 -#define MOVEEND_RED_CARD 28 -#define MOVEEND_LIFEORB_SHELLBELL 29 // Includes shell bell, throat spray, etc -#define MOVEEND_CHANGED_ITEMS 30 -#define MOVEEND_PICKPOCKET 31 -#define MOVEEND_DANCER 32 -#define MOVEEND_EMERGENCY_EXIT 33 -#define MOVEEND_SYMBIOSIS 34 -#define MOVEEND_OPPORTUNIST 35 // Occurs after other stat change items/abilities to try and copy the boosts -#define MOVEEND_SAME_MOVE_TURNS 36 -#define MOVEEND_SET_EVOLUTION_TRACKER 37 -#define MOVEEND_CLEAR_BITS 38 -#define MOVEEND_COUNT 39 +enum MoveEndEffects +{ + MOVEEND_SUM_DAMAGE, + MOVEEND_PROTECT_LIKE_EFFECT, + MOVEEND_RAGE, + MOVEEND_SYNCHRONIZE_TARGET, + MOVEEND_ABILITIES, + MOVEEND_ABILITIES_ATTACKER, + MOVEEND_STATUS_IMMUNITY_ABILITIES, + MOVEEND_SYNCHRONIZE_ATTACKER, + MOVEEND_CHOICE_MOVE, + MOVEEND_ATTACKER_INVISIBLE, + MOVEEND_ATTACKER_VISIBLE, + MOVEEND_TARGET_VISIBLE, + MOVEEND_ITEM_EFFECTS_TARGET, + MOVEEND_MOVE_EFFECTS2, + MOVEEND_ITEM_EFFECTS_ALL, + MOVEEND_KINGSROCK, // These item effects will occur each strike of a multi-hit move + MOVEEND_NUM_HITS, + MOVEEND_SUBSTITUTE, + MOVEEND_SKY_DROP_CONFUSE, + MOVEEND_UPDATE_LAST_MOVES, + MOVEEND_MIRROR_MOVE, + MOVEEND_NEXT_TARGET, // Everything up until here is handled for each strike of a multi-hit move + MOVEEND_MULTIHIT_MOVE, + MOVEEND_DEFROST, + MOVEEND_RECOIL, + MOVEEND_ITEM_EFFECTS_ATTACKER, + MOVEEND_MAGICIAN, // Occurs after final multi-hit strike, and after other items/abilities would activate + MOVEEND_EJECT_ITEMS, + MOVEEND_WHITE_HERB, + MOVEEND_RED_CARD, + MOVEEND_LIFEORB_SHELLBELL, // Includes shell bell, throat spray, etc + MOVEEND_CHANGED_ITEMS, + MOVEEND_PICKPOCKET, + MOVEEND_DANCER, + MOVEEND_EMERGENCY_EXIT, + MOVEEND_SYMBIOSIS, + MOVEEND_OPPORTUNIST, // Occurs after other stat change items/abilities to try and copy the boosts + MOVEEND_SAME_MOVE_TURNS, + MOVEEND_SET_EVOLUTION_TRACKER, + MOVEEND_CLEAR_BITS, + MOVEEND_COUNT, +}; // switch cases #define B_SWITCH_NORMAL 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b018535cbe..aa92a7b884 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5614,6 +5614,11 @@ static void Cmd_moveend(void) } gBattleScripting.moveendState++; break; + case MOVEEND_ITEM_EFFECTS_ATTACKER: + if (ItemBattleEffects(ITEMEFFECT_MOVE_END, gBattlerAttacker, FALSE)) + effect = TRUE; + gBattleScripting.moveendState++; + break; case MOVEEND_SYNCHRONIZE_TARGET: // target synchronize if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBattlerTarget, 0, 0, 0)) effect = TRUE; @@ -11570,7 +11575,7 @@ static void Cmd_stockpiletohpheal(void) if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - + gBattlescriptCurrInstr = cmd->nextInstr; gBattlerTarget = gBattlerAttacker; } diff --git a/test/battle/hold_effect/restore_hp.c b/test/battle/hold_effect/restore_hp.c index 09daecc860..c19433751c 100644 --- a/test/battle/hold_effect/restore_hp.c +++ b/test/battle/hold_effect/restore_hp.c @@ -27,3 +27,39 @@ DOUBLE_BATTLE_TEST("Restore HP Item effects do not miss timing") MESSAGE("The opposing Foe Wobbuffet was hurt by the sea of fire!"); } } + +DOUBLE_BATTLE_TEST("Restore HP Item effects do not miss timing after a recoil move") +{ + u16 item; + + PARAMETRIZE { item = ITEM_BERRY_JUICE; } + PARAMETRIZE { item = ITEM_ORAN_BERRY; } + PARAMETRIZE { item = ITEM_SITRUS_BERRY; } + + GIVEN { + ASSUME(gMovesInfo[MOVE_TAKE_DOWN].recoil == 25); + ASSUME(gItemsInfo[ITEM_ORAN_BERRY].holdEffect == HOLD_EFFECT_RESTORE_HP); + ASSUME(gItemsInfo[ITEM_BERRY_JUICE].holdEffect == HOLD_EFFECT_RESTORE_HP); + ASSUME(gItemsInfo[ITEM_SITRUS_BERRY].holdEffect == HOLD_EFFECT_RESTORE_PCT_HP); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WYNAUT) { MaxHP(100); HP(51); Item(item); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { + MOVE(opponentLeft, MOVE_TAKE_DOWN, target: playerLeft); + MOVE(opponentRight, MOVE_CELEBRATE); + MOVE(playerLeft, MOVE_CELEBRATE); + MOVE(playerRight, MOVE_CELEBRATE); + } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TAKE_DOWN, opponentLeft); + HP_BAR(playerLeft); + HP_BAR(opponentLeft); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponentLeft); + HP_BAR(opponentLeft); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponentRight); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, playerLeft); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, playerRight); + } +}