better bug bite impl, fix item removal

This commit is contained in:
ghoulslash 2022-05-13 16:21:41 -04:00
parent 9685afd981
commit f6f4227f49
5 changed files with 219 additions and 210 deletions

View File

@ -1785,9 +1785,8 @@
various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH
.endm .endm
.macro consumeberry battler:req, restoreItem=FALSE .macro consumeberry battler:req
various \battler, VARIOUS_CONSUME_BERRY various \battler, VARIOUS_CONSUME_BERRY
.byte \restoreItem
.endm .endm
.macro activateitemeffects battler:req .macro activateitemeffects battler:req

View File

@ -659,11 +659,11 @@ BattleScript_EffectFling:
BattleScript_EffectFlingConsumeBerry: BattleScript_EffectFlingConsumeBerry:
savebattleritem BS_TARGET savebattleritem BS_TARGET
battleritemtolastuseditem BS_TARGET battleritemtolastuseditem BS_TARGET
setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries setbyte sBERRY_OVERRIDE, 1 @ override the requirements for eating berries
orword gHitMarker, HITMARKER_NO_ANIMATIONS orword gHitMarker, HITMARKER_NO_ANIMATIONS
consumeberry BS_TARGET consumeberry BS_TARGET
bicword gHitMarker, HITMARKER_NO_ANIMATIONS bicword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, FALSE setbyte sBERRY_OVERRIDE, 0
restorebattleritem BS_TARGET restorebattleritem BS_TARGET
BattleScript_FlingEnd: BattleScript_FlingEnd:
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
@ -1350,7 +1350,7 @@ BattleScript_MoveEffectBugBite::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orword gHitMarker, HITMARKER_NO_ANIMATIONS orword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries
consumeberry BS_ATTACKER, TRUE @ consume the berry, then restore the item from changedItems consumeberry BS_ATTACKER
bicword gHitMarker, HITMARKER_NO_ANIMATIONS bicword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, FALSE setbyte sBERRY_OVERRIDE, FALSE
return return

View File

@ -41,7 +41,7 @@
#define ITEMEFFECT_TARGET 5 #define ITEMEFFECT_TARGET 5
#define ITEMEFFECT_ORBS 6 #define ITEMEFFECT_ORBS 6
#define ITEMEFFECT_LIFEORB_SHELLBELL 7 #define ITEMEFFECT_LIFEORB_SHELLBELL 7
#define ITEMEFFECT_BATTLER_MOVE_END 8 // move end effects for just the battler, not whole field #define ITEMEFFECT_USE_LAST_ITEM 8 // move end effects for just the battler, not whole field
#define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK))) #define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK)))

View File

@ -3474,10 +3474,6 @@ void SetMoveEffect(bool32 primary, u32 certain)
BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gEffectBattler].item), &gBattleMons[gEffectBattler].item); BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gEffectBattler].item), &gBattleMons[gEffectBattler].item);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
// attacker temporarily gains their item
gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerAttacker].item;
gBattleMons[gBattlerAttacker].item = gLastUsedItem;
BattleScriptPush(gBattlescriptCurrInstr + 1); BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_MoveEffectBugBite; gBattlescriptCurrInstr = BattleScript_MoveEffectBugBite;
} }
@ -7043,6 +7039,13 @@ static void Cmd_removeitem(void)
{ {
u16 itemId = 0; u16 itemId = 0;
if (gBattleScripting.overrideBerryRequirements)
{
// bug bite / pluck - don't remove current item
gBattlescriptCurrInstr += 2;
return;
}
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
itemId = gBattleMons[gActiveBattler].item; itemId = gBattleMons[gActiveBattler].item;
@ -9272,26 +9275,13 @@ static void Cmd_various(void)
} }
break; break;
case VARIOUS_CONSUME_BERRY: case VARIOUS_CONSUME_BERRY:
if (ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item) == HOLD_EFFECT_NONE) if (gBattleScripting.overrideBerryRequirements == 2)
{ break;
gBattlescriptCurrInstr += 4;
return;
}
gBattleScripting.battler = gEffectBattler = gBattlerTarget = gActiveBattler; // Cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID gBattleScripting.battler = gEffectBattler = gBattlerTarget = gActiveBattler; // Cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID
// Do move end berry effects for just a single battler, instead of looping through all battlers if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, gActiveBattler, FALSE))
if (ItemBattleEffects(ITEMEFFECT_BATTLER_MOVE_END, gActiveBattler, FALSE))
return; return;
break;
if (gBattlescriptCurrInstr[3])
{
gBattleMons[gActiveBattler].item = gBattleStruct->changedItems[gActiveBattler];
gBattleStruct->changedItems[gActiveBattler] = ITEM_NONE;
gBattleResources->flags->flags[gActiveBattler] &= ~RESOURCE_FLAG_UNBURDEN;
}
gBattlescriptCurrInstr += 4;
return;
case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL: case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL:
{ {
bool8 canDoPrimalReversion = FALSE; bool8 canDoPrimalReversion = FALSE;

View File

@ -6391,6 +6391,189 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
return ret; return ret;
} }
static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
{
u8 effect = 0;
u32 i;
switch (holdEffect)
{
case HOLD_EFFECT_MICLE_BERRY:
if (B_HP_BERRIES >= GEN_4)
effect = TrySetMicleBerry(battlerId, gLastUsedItem, FALSE);
break;
case HOLD_EFFECT_RESTORE_HP:
if (B_HP_BERRIES >= GEN_4)
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, FALSE);
break;
case HOLD_EFFECT_RESTORE_PCT_HP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SPICY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_DRY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SWEET:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, FALSE);
break;
case HOLD_EFFECT_CONFUSE_BITTER:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SOUR:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, FALSE);
break;
case HOLD_EFFECT_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, FALSE);
break;
case HOLD_EFFECT_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, FALSE);
break;
case HOLD_EFFECT_SPEED_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, FALSE);
break;
case HOLD_EFFECT_SP_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, FALSE);
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, FALSE);
break;
case HOLD_EFFECT_RANDOM_STAT_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, FALSE);
break;
case HOLD_EFFECT_CURE_PAR:
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_PARALYSIS;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureParRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_PSN:
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCurePsnRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_BRN:
if (gBattleMons[battlerId].status1 & STATUS1_BURN && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_BURN;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureBrnRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_FRZ:
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_FREEZE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureFrzRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_SLP:
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_SLEEP;
gBattleMons[battlerId].status2 &= ~STATUS2_NIGHTMARE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureSlpRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_CONFUSION:
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureConfusionRet;
effect = ITEM_EFFECT_OTHER;
}
break;
case HOLD_EFFECT_MENTAL_HERB:
if (GetMentalHerbEffect(battlerId))
{
gBattleScripting.savedBattler = gBattlerAttacker;
gBattlerAttacker = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MentalHerbCureRet;
effect = ITEM_EFFECT_OTHER;
}
break;
case HOLD_EFFECT_CURE_STATUS:
if ((gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION) && !UnnerveOn(battlerId, gLastUsedItem))
{
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn);
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
{
gBattleMons[battlerId].status2 &= ~STATUS2_NIGHTMARE;
StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn);
}
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn);
if (gBattleMons[battlerId].status1 & STATUS1_BURN)
StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn);
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn);
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn);
gBattleMons[battlerId].status1 = 0;
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CURED_PROBLEM;
gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < NUM_BATTLE_STATS; i++)
{
if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE)
{
gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE;
effect = ITEM_STATS_CHANGE;
}
}
if (effect)
{
gBattleScripting.battler = battlerId;
gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
return effect;
}
break;
}
return effect;
}
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{ {
int i = 0, moveType; int i = 0, moveType;
@ -6400,9 +6583,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
u8 atkHoldEffectParam; u8 atkHoldEffectParam;
u16 atkItem; u16 atkItem;
gLastUsedItem = gBattleMons[battlerId].item; if (caseID != ITEMEFFECT_USE_LAST_ITEM) {
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE); gLastUsedItem = gBattleMons[battlerId].item;
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
}
atkItem = gBattleMons[gBattlerAttacker].item; atkItem = gBattleMons[gBattlerAttacker].item;
atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE); atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE);
atkHoldEffectParam = GetBattlerHoldEffectParam(gBattlerAttacker); atkHoldEffectParam = GetBattlerHoldEffectParam(gBattlerAttacker);
@ -6935,189 +7120,24 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
} }
} }
break; break;
case ITEMEFFECT_BATTLER_MOVE_END: case ITEMEFFECT_USE_LAST_ITEM:
goto DO_ITEMEFFECT_MOVE_END; // this hurts a bit to do, but is an easy solution effect = ItemEffectMoveEnd(battlerId, ItemId_GetHoldEffect(gLastUsedItem));
gBattleScripting.overrideBerryRequirements = 2; // to exit VARIOUS_CONSUME_BERRIES
if (effect)
{
gActiveBattler = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId;
if (effect == ITEM_STATUS_CHANGE)
{
BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler);
}
break;
}
break;
case ITEMEFFECT_MOVE_END: case ITEMEFFECT_MOVE_END:
for (battlerId = 0; battlerId < gBattlersCount; battlerId++) for (battlerId = 0; battlerId < gBattlersCount; battlerId++)
{ {
gLastUsedItem = gBattleMons[battlerId].item; effect = ItemEffectMoveEnd(battlerId, GetBattlerHoldEffect(battlerId, TRUE));
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
DO_ITEMEFFECT_MOVE_END:
switch (battlerHoldEffect)
{
case HOLD_EFFECT_MICLE_BERRY:
if (B_HP_BERRIES >= GEN_4)
effect = TrySetMicleBerry(battlerId, gLastUsedItem, FALSE);
break;
case HOLD_EFFECT_RESTORE_HP:
if (B_HP_BERRIES >= GEN_4)
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, FALSE);
break;
case HOLD_EFFECT_RESTORE_PCT_HP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SPICY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_DRY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SWEET:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, FALSE);
break;
case HOLD_EFFECT_CONFUSE_BITTER:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SOUR:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, FALSE);
break;
case HOLD_EFFECT_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, FALSE);
break;
case HOLD_EFFECT_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, FALSE);
break;
case HOLD_EFFECT_SPEED_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, FALSE);
break;
case HOLD_EFFECT_SP_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, FALSE);
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, FALSE);
break;
case HOLD_EFFECT_RANDOM_STAT_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, FALSE);
break;
case HOLD_EFFECT_CURE_PAR:
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_PARALYSIS;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureParRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_PSN:
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCurePsnRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_BRN:
if (gBattleMons[battlerId].status1 & STATUS1_BURN && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_BURN;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureBrnRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_FRZ:
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_FREEZE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureFrzRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_SLP:
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status1 &= ~STATUS1_SLEEP;
gBattleMons[battlerId].status2 &= ~STATUS2_NIGHTMARE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureSlpRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_CURE_CONFUSION:
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureConfusionRet;
effect = ITEM_EFFECT_OTHER;
}
break;
case HOLD_EFFECT_MENTAL_HERB:
if (GetMentalHerbEffect(battlerId))
{
gBattleScripting.savedBattler = gBattlerAttacker;
gBattlerAttacker = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MentalHerbCureRet;
effect = ITEM_EFFECT_OTHER;
}
break;
case HOLD_EFFECT_CURE_STATUS:
if ((gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION) && !UnnerveOn(battlerId, gLastUsedItem))
{
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn);
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
{
gBattleMons[battlerId].status2 &= ~STATUS2_NIGHTMARE;
StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn);
}
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn);
if (gBattleMons[battlerId].status1 & STATUS1_BURN)
StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn);
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn);
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn);
gBattleMons[battlerId].status1 = 0;
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CURED_PROBLEM;
gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet;
effect = ITEM_STATUS_CHANGE;
}
break;
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < NUM_BATTLE_STATS; i++)
{
if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE)
{
gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE;
effect = ITEM_STATS_CHANGE;
}
}
if (effect)
{
gBattleScripting.battler = battlerId;
gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
return effect;
}
break;
}
if (effect) if (effect)
{ {
gActiveBattler = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId; gActiveBattler = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId;