Merge pull request #2433 from ghoulslash/be/bug_bite

Redo Bug Bite
This commit is contained in:
BuffelSaft 2022-11-05 22:08:47 +13:00 committed by GitHub
commit bbd7b205fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 266 additions and 214 deletions

View File

@ -1789,9 +1789,9 @@
various BS_ATTACKER, VARIOUS_SET_Z_EFFECT
.endm
.macro consumeberry battler:req, restoreItem=FALSE
.macro consumeberry battler:req, frombattler:req
various \battler, VARIOUS_CONSUME_BERRY
.byte \restoreItem
.byte \frombattler
.endm
.macro activateitemeffects battler:req

View File

@ -694,11 +694,11 @@ BattleScript_EffectFling:
BattleScript_EffectFlingConsumeBerry:
savebattleritem 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
consumeberry BS_TARGET
consumeberry BS_TARGET, TRUE
bicword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, FALSE
setbyte sBERRY_OVERRIDE, 0
restorebattleritem BS_TARGET
BattleScript_FlingEnd:
tryfaintmon BS_TARGET
@ -1082,11 +1082,12 @@ BattleScript_EffectStuffCheeks::
attackanimation
waitanimation
BattleScript_StuffCheeksEatBerry:
setbyte sBERRY_OVERRIDE, TRUE
setbyte sBERRY_OVERRIDE, 1
orword gHitMarker, HITMARKER_NO_ANIMATIONS
consumeberry BS_ATTACKER
consumeberry BS_ATTACKER, TRUE
bicword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, FALSE
setbyte sBERRY_OVERRIDE, 0
removeitem BS_ATTACKER
setstatchanger STAT_DEF, 2, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_StuffCheeksEnd
setgraphicalstatchangevalues
@ -1364,11 +1365,13 @@ BattleScript_MoveEffectBugBite::
printstring STRINGID_BUGBITE
waitmessage B_WAIT_TIME_LONG
orword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries
consumeberry BS_ATTACKER, TRUE @ consume the berry, then restore the item from changedItems
setbyte sBERRY_OVERRIDE, 1 @ override the requirements for eating berries
savetarget
consumeberry BS_ATTACKER, FALSE
bicword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, FALSE
setbyte sBERRY_OVERRIDE, 0
trysymbiosis
restoretarget
return
BattleScript_EffectCoreEnforcer:
@ -9275,11 +9278,15 @@ BattleScript_BerryStatRaiseRet_Anim:
BattleScript_BerryStatRaiseRet_End:
return
BattleScript_BerryFocusEnergyEnd2::
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT
BattleScript_BerryFocusEnergyRet::
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT
printstring STRINGID_PKMNUSEDXTOGETPUMPED
waitmessage B_WAIT_TIME_LONG
removeitem BS_ATTACKER
removeitem BS_SCRIPTING
return
BattleScript_BerryFocusEnergyEnd2::
call BattleScript_BerryFocusEnergyRet
end2
BattleScript_ActionSelectionItemsCantBeUsed::

View File

@ -216,6 +216,7 @@ extern const u8 BattleScript_BerryConfuseHealEnd2[];
extern const u8 BattleScript_BerryConfuseHealRet[];
extern const u8 BattleScript_BerryStatRaiseEnd2[];
extern const u8 BattleScript_BerryStatRaiseRet[];
extern const u8 BattleScript_BerryFocusEnergyRet[];
extern const u8 BattleScript_BerryFocusEnergyEnd2[];
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
extern const u8 BattleScript_ArenaTurnBeginning[];

View File

@ -51,7 +51,7 @@
#define ITEMEFFECT_TARGET 5
#define ITEMEFFECT_ORBS 6
#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)))

View File

@ -271,6 +271,7 @@ static const struct BitfieldInfo sStatus2Bitfield[] =
{/*Multiple Turns*/ 1, 12},
// Wrap bits are omitted. Done in various.
// In Love bits are omitted. Done in various.
{/*(Focus Energy*/ 1, 20},
{/*Transformed*/ 1, 21},
{/*Recharge*/ 1, 22},
{/*Rage*/ 1, 23},

View File

@ -2839,7 +2839,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
if (gBattleMons[gEffectBattler].hp == 0
&& gBattleScripting.moveEffect != MOVE_EFFECT_PAYDAY
&& gBattleScripting.moveEffect != MOVE_EFFECT_STEAL_ITEM)
&& gBattleScripting.moveEffect != MOVE_EFFECT_STEAL_ITEM
&& gBattleScripting.moveEffect != MOVE_EFFECT_BUG_BITE)
INCREMENT_RESET_RETURN
if (DoesSubstituteBlockMove(gBattlerAttacker, gEffectBattler, gCurrentMove) && affectsUser != MOVE_EFFECT_AFFECTS_USER)
@ -3600,11 +3601,6 @@ void SetMoveEffect(bool32 primary, u32 certain)
BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gEffectBattler].item), &gBattleMons[gEffectBattler].item);
MarkBattlerForControllerExec(gActiveBattler);
// attacker temporarily gains their item
gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerAttacker].item;
gBattleMons[gBattlerAttacker].item = gLastUsedItem;
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_MoveEffectBugBite;
}
@ -7485,6 +7481,13 @@ static void Cmd_removeitem(void)
{
u16 itemId = 0;
if (gBattleScripting.overrideBerryRequirements)
{
// bug bite / pluck - don't remove current item
gBattlescriptCurrInstr += 2;
return;
}
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
itemId = gBattleMons[gActiveBattler].item;
@ -9746,24 +9749,18 @@ static void Cmd_various(void)
}
break;
case VARIOUS_CONSUME_BERRY:
if (ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item) == HOLD_EFFECT_NONE)
if (gBattleScripting.overrideBerryRequirements == 2)
{
gBattlescriptCurrInstr += 4;
return;
}
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_BATTLER_MOVE_END, gActiveBattler, FALSE))
return;
if (gBattlescriptCurrInstr[3])
{
gBattleMons[gActiveBattler].item = gBattleStruct->changedItems[gActiveBattler];
gBattleStruct->changedItems[gActiveBattler] = ITEM_NONE;
gBattleResources->flags->flags[gActiveBattler] &= ~RESOURCE_FLAG_UNBURDEN;
}
gLastUsedItem = gBattleMons[gActiveBattler].item;
gBattleScripting.battler = gEffectBattler = gBattlerTarget = gActiveBattler; // Cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID
if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, gActiveBattler, FALSE))
return;
gBattlescriptCurrInstr += 4;
return;
case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL:

View File

@ -60,6 +60,7 @@ static bool32 TryRemoveScreens(u8 battler);
static bool32 IsUnnerveAbilityOnOpposingSide(u8 battlerId);
static u8 GetFlingPowerFromItemId(u16 itemId);
static void SetRandomMultiHitCounter();
static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item);
extern const u8 *const gBattleScriptsForMoveEffects[];
extern const u8 *const gBattlescriptsForRunningByItem[];
@ -6397,7 +6398,7 @@ static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2)
{
PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId);
gBattleMoveDamage = gBattleMons[battlerId].maxHP / GetBattlerHoldEffectParam(battlerId);
gBattleMoveDamage = gBattleMons[battlerId].maxHP / GetBattlerItemHoldEffectParam(battlerId, itemId);
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
gBattleMoveDamage *= -1;
@ -6433,7 +6434,7 @@ static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2)
static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2)
{
if (CompareStat(battlerId, statId, MAX_STAT_STAGE, CMP_LESS_THAN) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId))
if (CompareStat(battlerId, statId, MAX_STAT_STAGE, CMP_LESS_THAN) && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, itemId), itemId))
{
BufferStatChange(battlerId, statId, STRINGID_STATROSE);
gEffectBattler = battlerId;
@ -6469,7 +6470,7 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2)
if (CompareStat(battlerId, STAT_ATK + i, MAX_STAT_STAGE, CMP_LESS_THAN))
break;
}
if (i != NUM_STATS - 1 && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId))
if (i != NUM_STATS - 1 && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, itemId), itemId))
{
u16 battlerAbility = GetBattlerAbility(battlerId);
do
@ -6588,9 +6589,9 @@ static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
&& HasEnoughHpToEatBerry(battlerId, 2, itemId))
{
if (percentHeal)
gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerHoldEffectParam(battlerId) / 100) * -1;
gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerItemHoldEffectParam(battlerId, itemId) / 100) * -1;
else
gBattleMoveDamage = GetBattlerHoldEffectParam(battlerId) * -1;
gBattleMoveDamage = GetBattlerItemHoldEffectParam(battlerId, itemId) * -1;
// check ripen
if (ItemId_GetPocket(itemId) == POCKET_BERRIES && GetBattlerAbility(battlerId) == ABILITY_RIPEN)
@ -6673,6 +6674,192 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
return ret;
}
static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
{
u8 effect = 0;
u32 i;
switch (holdEffect)
{
#if B_HP_BERRIES >= GEN_4
case HOLD_EFFECT_MICLE_BERRY:
effect = TrySetMicleBerry(battlerId, gLastUsedItem, FALSE);
break;
case HOLD_EFFECT_RESTORE_HP:
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, FALSE);
break;
#endif
#if B_BERRIES_INSTANT >= GEN_4
case HOLD_EFFECT_RESTORE_PCT_HP:
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SPICY:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_DRY:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SWEET:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, FALSE);
break;
case HOLD_EFFECT_CONFUSE_BITTER:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SOUR:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, FALSE);
break;
case HOLD_EFFECT_ATTACK_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, FALSE);
break;
case HOLD_EFFECT_DEFENSE_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, FALSE);
break;
case HOLD_EFFECT_SPEED_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, FALSE);
break;
case HOLD_EFFECT_SP_ATTACK_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, FALSE);
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, FALSE);
break;
case HOLD_EFFECT_RANDOM_STAT_UP:
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, FALSE);
break;
#endif
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 != 0)
{
gBattleScripting.battler = battlerId;
gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
return effect;
}
break;
case HOLD_EFFECT_CRITICAL_UP: // lansat berry
if (B_BERRIES_INSTANT >= GEN_4
&& !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)
&& HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
{
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
gBattleScripting.battler = battlerId;
gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryFocusEnergyRet;
effect = ITEM_EFFECT_OTHER;
}
break;
}
return effect;
}
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{
int i = 0, moveType;
@ -6682,9 +6869,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
u8 atkHoldEffectParam;
u16 atkItem;
gLastUsedItem = gBattleMons[battlerId].item;
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
if (caseID != ITEMEFFECT_USE_LAST_ITEM) {
gLastUsedItem = gBattleMons[battlerId].item;
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
}
atkItem = gBattleMons[gBattlerAttacker].item;
atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE);
atkHoldEffectParam = GetBattlerHoldEffectParam(gBattlerAttacker);
@ -6752,9 +6941,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, TRUE);
break;
case HOLD_EFFECT_CRITICAL_UP:
if (!(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem))
if (!(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
{
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
gBattleScripting.battler = battlerId;
BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
effect = ITEM_EFFECT_OTHER;
}
@ -7068,9 +7258,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
case HOLD_EFFECT_CRITICAL_UP:
if (!moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)
&& HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem))
&& HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
{
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
gBattleScripting.battler = battlerId;
BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
effect = ITEM_EFFECT_OTHER;
}
@ -7205,179 +7396,25 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
}
break;
case ITEMEFFECT_BATTLER_MOVE_END:
goto DO_ITEMEFFECT_MOVE_END; // this hurts a bit to do, but is an easy solution
case ITEMEFFECT_USE_LAST_ITEM:
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:
for (battlerId = 0; battlerId < gBattlersCount; battlerId++)
{
gLastUsedItem = gBattleMons[battlerId].item;
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
DO_ITEMEFFECT_MOVE_END:
switch (battlerHoldEffect)
{
#if B_HP_BERRIES >= GEN_4
case HOLD_EFFECT_MICLE_BERRY:
effect = TrySetMicleBerry(battlerId, gLastUsedItem, FALSE);
break;
case HOLD_EFFECT_RESTORE_HP:
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, FALSE);
break;
#endif
#if B_BERRIES_INSTANT >= GEN_4
case HOLD_EFFECT_RESTORE_PCT_HP:
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SPICY:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_DRY:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SWEET:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, FALSE);
break;
case HOLD_EFFECT_CONFUSE_BITTER:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SOUR:
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, FALSE);
break;
case HOLD_EFFECT_ATTACK_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, FALSE);
break;
case HOLD_EFFECT_DEFENSE_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, FALSE);
break;
case HOLD_EFFECT_SPEED_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, FALSE);
break;
case HOLD_EFFECT_SP_ATTACK_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, FALSE);
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, FALSE);
break;
case HOLD_EFFECT_RANDOM_STAT_UP:
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, FALSE);
break;
#endif
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 != 0)
{
gBattleScripting.battler = battlerId;
gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
return effect;
}
break;
}
if (effect != 0)
effect = ItemEffectMoveEnd(battlerId, GetBattlerHoldEffect(battlerId, TRUE));
if (effect)
{
gActiveBattler = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId;
if (effect == ITEM_STATUS_CHANGE)
@ -7954,6 +7991,15 @@ u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating)
return ItemId_GetHoldEffect(gBattleMons[battlerId].item);
}
//
static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item)
{
if (item == ITEM_ENIGMA_BERRY)
return gEnigmaBerries[battlerId].holdEffectParam;
else
return ItemId_GetHoldEffectParam(item);
}
u32 GetBattlerHoldEffectParam(u8 battlerId)
{
if (gBattleMons[battlerId].item == ITEM_ENIGMA_BERRY)