Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo Bug Bite #2433

Merged
merged 7 commits into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 19 additions & 12 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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::
Expand Down
1 change: 1 addition & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down
1 change: 1 addition & 0 deletions src/battle_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
33 changes: 15 additions & 18 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -9750,24 +9753,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;
}


if (gBattlescriptCurrInstr[3])
gLastUsedItem = gBattleMons[gActiveBattler].item;

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))
if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, gActiveBattler, FALSE))
return;

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:
Expand Down
Loading