diff --git a/src/battle_util.c b/src/battle_util.c index 54cc6a239b..e0146c265f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7976,6 +7976,18 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn) case HOLD_EFFECT_MARANGA_BERRY: // consume and boost sp. defense if used special move effect = DamagedStatBoostBerryEffect(battler, STAT_SPDEF, DAMAGE_CATEGORY_SPECIAL); break; + case HOLD_EFFECT_CURE_STATUS: // only Toxic Chain's interaction with Knock Off + case HOLD_EFFECT_CURE_PSN: + if (gBattleMons[battler].status1 & STATUS1_PSN_ANY && !UnnerveOn(battler, gLastUsedItem) && gLastUsedAbility == ABILITY_TOXIC_CHAIN && gMovesInfo[gCurrentMove].effect == EFFECT_KNOCK_OFF) + { + gBattleScripting.battler = battler; + gBattleMons[battler].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER); + BattleScriptExecute(BattleScript_BerryCurePsnEnd2); + BtlController_EmitSetMonData(battler, 0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1); + MarkBattlerForControllerExec(battler); + effect = ITEM_STATUS_CHANGE; + } + break; case HOLD_EFFECT_STICKY_BARB: if (TARGET_TURN_DAMAGED && (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) diff --git a/test/battle/ability/toxic_chain.c b/test/battle/ability/toxic_chain.c index 17ee455992..d6aba06f70 100644 --- a/test/battle/ability/toxic_chain.c +++ b/test/battle/ability/toxic_chain.c @@ -77,4 +77,36 @@ DOUBLE_BATTLE_TEST("Toxic Chain can inflict bad poison on both foes") } } -TO_DO_BATTLE_TEST("Toxic Chain makes Lum/Pecha Berry trigger before being knocked off"); +SINGLE_BATTLE_TEST("Toxic Chain makes Lum/Pecha Berry trigger before being knocked off") +{ + u16 item = 0; + + PARAMETRIZE { item = ITEM_PECHA_BERRY; } + PARAMETRIZE { item = ITEM_LUM_BERRY; } + + GIVEN { + ASSUME(gMovesInfo[MOVE_KNOCK_OFF].category != DAMAGE_CATEGORY_STATUS); + ASSUME(gMovesInfo[MOVE_KNOCK_OFF].effect == EFFECT_KNOCK_OFF); + ASSUME(gMovesInfo[MOVE_KNOCK_OFF].power > 0); + ASSUME(gItemsInfo[ITEM_PECHA_BERRY].holdEffect == HOLD_EFFECT_CURE_PSN); + ASSUME(gItemsInfo[ITEM_LUM_BERRY].holdEffect == HOLD_EFFECT_CURE_STATUS); + PLAYER(SPECIES_OKIDOGI) { Ability(ABILITY_TOXIC_CHAIN); } + OPPONENT(SPECIES_WOBBUFFET) { Item(item); } + } WHEN { + TURN { MOVE(player, MOVE_KNOCK_OFF, WITH_RNG(RNG_TOXIC_CHAIN, TRUE)); } + } SCENE { + ABILITY_POPUP(player, ABILITY_TOXIC_CHAIN); + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_PSN, opponent); + MESSAGE("Foe Wobbuffet is badly poisoned!"); + STATUS_ICON(opponent, badPoison: TRUE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + STATUS_ICON(opponent, badPoison: FALSE); + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF); + MESSAGE("Okidogi knocked off Foe Wobbuffet's Pecha Berry!"); + MESSAGE("Okidogi knocked off Foe Wobbuffet's Lum Berry!"); + } + } THEN { + EXPECT(opponent->status1 == 0); + } +}