add bug bite

This commit is contained in:
ghoulslash 2021-07-25 14:55:52 -06:00
parent e6a2d2226f
commit 4ca6d76160
7 changed files with 48 additions and 2 deletions

View File

@ -1768,6 +1768,11 @@
.macro tryactivategrimneigh, battler:req
various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH
.endm
.macro consumeberry battler:req, restoreItem=FALSE
various \battler, VARIOUS_CONSUME_BERRY
.byte \restoreItem
.endm
@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req

View File

@ -508,6 +508,11 @@ BattleScript_MoveEffectIncinerate::
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
bicword gHitMarker, HITMARKER_NO_ANIMATIONS
setbyte sBERRY_OVERRIDE, FALSE
return
BattleScript_EffectCoreEnforcer:

View File

@ -659,6 +659,7 @@ struct BattleScripting
u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN.
bool8 fixedPopup; // force ability popup to stick until manually called back
u16 abilityPopupOverwrite;
u8 overrideBerryRequirements;
};
// rom_80A5C6C

View File

@ -31,6 +31,7 @@
#define ITEMEFFECT_KINGSROCK_SHELLBELL 0x4
#define ITEMEFFECT_TARGET 0x5
#define ITEMEFFECT_ORBS 0x6
#define ITEMEFFECT_BATTLER_MOVE_END 0x7 // move end effects for just the battler, not whole field
#define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK)))

View File

@ -37,6 +37,7 @@
#define sILLUSION_NICK_HACK gBattleScripting + 0x32
#define sFIXED_ABILITY_POPUP gBattleScripting + 0x33
#define sABILITY_OVERWRITE gBattleScripting + 0x34
#define sBERRY_OVERRIDE gBattleScripting + 0x36
#define cMULTISTRING_CHOOSER gBattleCommunication + 5
#define cMISS_TYPE gBattleCommunication + 6
@ -173,6 +174,7 @@
#define VARIOUS_DESTROY_ABILITY_POPUP 102
#define VARIOUS_TOTEM_BOOST 103
#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104
#define VARIOUS_CONSUME_BERRY 105
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -3284,16 +3284,22 @@ void SetMoveEffect(bool32 primary, u32 certain)
}
break;
case MOVE_EFFECT_BUG_BITE:
if ((gBattleMons[gEffectBattler].item >= FIRST_BERRY_INDEX && gBattleMons[gEffectBattler].item <= LAST_BERRY_INDEX)
if (ItemId_GetPocket(gBattleMons[gEffectBattler].item) == POCKET_BERRIES
&& GetBattlerAbility(gEffectBattler) != ABILITY_STICKY_HOLD)
{
// target loses their berry
gLastUsedItem = gBattleMons[gEffectBattler].item;
gBattleMons[gEffectBattler].item = 0;
CheckSetUnburden(gEffectBattler);
gActiveBattler = gEffectBattler;
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &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;
}
@ -8422,6 +8428,27 @@ static void Cmd_various(void)
gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe)
}
return;
case VARIOUS_CONSUME_BERRY:
if (ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item) == HOLD_EFFECT_NONE)
{
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);
}
gBattlescriptCurrInstr += 4;
return;
}
gBattlescriptCurrInstr += 3;

View File

@ -5385,6 +5385,8 @@ bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
if (gBattleMons[battlerId].hp == 0)
return FALSE;
if (gBattleScripting.overrideBerryRequirements)
return TRUE;
// Unnerve prevents consumption of opponents' berries.
if (isBerry && IsUnnerveAbilityOnOpposingSide(battlerId))
return FALSE;
@ -6095,11 +6097,14 @@ 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_MOVE_END:
for (battlerId = 0; battlerId < gBattlersCount; battlerId++)
{
gLastUsedItem = gBattleMons[battlerId].item;
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
DO_ITEMEFFECT_MOVE_END:
switch (battlerHoldEffect)
{
case HOLD_EFFECT_MICLE_BERRY: