From 6ce122744767ac97694997aa9c90472d977cbb60 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 3 Sep 2021 11:05:11 -0400 Subject: [PATCH] fix throat spray bugs. move shell bell, throat spray etc to life orb moveend case --- data/battle_scripts_1.s | 8 ++- include/battle_util.h | 3 +- include/constants/battle_script_commands.h | 6 +-- src/battle_script_commands.c | 22 ++------- src/battle_util.c | 57 ++++++++++++++++------ 5 files changed, 57 insertions(+), 39 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0d3eb9d50..762b9d3e5 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1868,7 +1868,7 @@ BattleScript_RoomServiceLoop: jumpifnoholdeffect BS_TARGET, HOLD_EFFECT_ROOM_SERVICE, BattleScript_RoomServiceLoop_NextBattler jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPEED, MIN_STAT_STAGE, BattleScript_RoomServiceLoop_NextBattler setstatchanger STAT_SPEED, 1, TRUE - statbuffchange 0, BattleScript_RoomServiceLoop_NextBattler + statbuffchange MOVE_EFFECT_AFFECTS_USER, BattleScript_RoomServiceLoop_NextBattler jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_RoomServiceLoop_NextBattler playanimation BS_TARGET, B_ANIM_HELD_ITEM_EFFECT, NULL waitanimation @@ -2193,18 +2193,21 @@ BattleScript_AlreadyAsleep:: pause B_WAIT_TIME_SHORT printstring STRINGID_PKMNALREADYASLEEP waitmessage B_WAIT_TIME_LONG + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED goto BattleScript_MoveEnd BattleScript_WasntAffected:: pause B_WAIT_TIME_SHORT printstring STRINGID_PKMNWASNTAFFECTED waitmessage B_WAIT_TIME_LONG + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED goto BattleScript_MoveEnd BattleScript_CantMakeAsleep:: pause B_WAIT_TIME_SHORT printfromtable gUproarAwakeStringIds waitmessage B_WAIT_TIME_LONG + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED goto BattleScript_MoveEnd BattleScript_EffectPoisonHit: @@ -5643,7 +5646,7 @@ BattleScript_TargetItemStatRaiseRemoveItemRet: BattleScript_AttackerItemStatRaise:: copybyte sBATTLER, gBattlerAttacker - statbuffchange 0, BattleScript_AttackerItemStatRaiseRet + statbuffchange MOVE_EFFECT_AFFECTS_USER, BattleScript_AttackerItemStatRaiseRet jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_AttackerItemStatRaiseRet playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL waitanimation @@ -7120,6 +7123,7 @@ BattleScript_SoundproofProtected:: call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXBLOCKSY waitmessage B_WAIT_TIME_LONG + orhalfword gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE goto BattleScript_MoveEnd BattleScript_DazzlingProtected:: diff --git a/include/battle_util.h b/include/battle_util.h index 1948161b4..f72f85d5c 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -28,9 +28,10 @@ #define ITEMEFFECT_ON_SWITCH_IN 0x0 #define ITEMEFFECT_MOVE_END 0x3 -#define ITEMEFFECT_KINGSROCK_SHELLBELL 0x4 +#define ITEMEFFECT_KINGSROCK 0x4 #define ITEMEFFECT_TARGET 0x5 #define ITEMEFFECT_ORBS 0x6 +#define ITEMEFFECT_LIFEORB_SHELLBELL 0x7 #define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK))) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 766af072c..f35a37766 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -231,15 +231,15 @@ #define MOVEEND_ITEM_EFFECTS_TARGET 13 #define MOVEEND_MOVE_EFFECTS2 14 #define MOVEEND_ITEM_EFFECTS_ALL 15 -#define MOVEEND_KINGSROCK_SHELLBELL 16 +#define MOVEEND_KINGSROCK 16 // these item effects will occur each strike of a multi-hit move #define MOVEEND_SUBSTITUTE 17 #define MOVEEND_UPDATE_LAST_MOVES 18 #define MOVEEND_MIRROR_MOVE 19 -#define MOVEEND_NEXT_TARGET 20 +#define MOVEEND_NEXT_TARGET 20 // everything up until here is handled for each strike of a multi-hit move #define MOVEEND_EJECT_BUTTON 21 #define MOVEEND_RED_CARD 22 #define MOVEEND_EJECT_PACK 23 -#define MOVEEND_LIFE_ORB 24 +#define MOVEEND_LIFEORB_SHELLBELL 24 // includes shell bell, throat spray, etc #define MOVEEND_PICKPOCKET 25 #define MOVEEND_DANCER 26 #define MOVEEND_EMERGENCY_EXIT 27 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3344573fb..a53a6b0e0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4934,8 +4934,9 @@ static void Cmd_moveend(void) else gBattleScripting.moveendState++; break; - case MOVEEND_KINGSROCK_SHELLBELL: // king's rock and shell bell - if (ItemBattleEffects(ITEMEFFECT_KINGSROCK_SHELLBELL, 0, FALSE)) + case MOVEEND_KINGSROCK: // king's rock and shell bell + // these effects will occur at each hit in a multi-strike move + if (ItemBattleEffects(ITEMEFFECT_KINGSROCK, 0, FALSE)) effect = TRUE; gBattleScripting.moveendState++; break; @@ -5199,22 +5200,9 @@ static void Cmd_moveend(void) } gBattleScripting.moveendState++; break; - case MOVEEND_LIFE_ORB: - // TODO shell bell goes here too - if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_LIFE_ORB - && IsBattlerAlive(gBattlerAttacker) - && !(TestSheerForceFlag(gBattlerAttacker, gCurrentMove)) - && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD - && gSpecialStatuses[gBattlerAttacker].damagedMons) - { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 10; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; + case MOVEEND_LIFEORB_SHELLBELL: + if (ItemBattleEffects(ITEMEFFECT_LIFEORB_SHELLBELL, 0, FALSE)) effect = TRUE; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_ItemHurtRet; - gLastUsedItem = gBattleMons[gBattlerAttacker].item; - } gBattleScripting.moveendState++; break; case MOVEEND_PICKPOCKET: diff --git a/src/battle_util.c b/src/battle_util.c index 0173ca49f..5f5f2e19b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6354,7 +6354,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } } break; - case ITEMEFFECT_KINGSROCK_SHELLBELL: + case ITEMEFFECT_KINGSROCK: + // occur on each hit of a multi-strike move switch (atkHoldEffect) { case HOLD_EFFECT_FLINCH: @@ -6371,6 +6372,25 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) BattleScriptPop(); } break; + case HOLD_EFFECT_BLUNDER_POLICY: + if (gBattleStruct->blunderPolicy + && gBattleMons[gBattlerAttacker].hp != 0 + && gBattleMons[gBattlerAttacker].statStages[STAT_SPEED] < MAX_STAT_STAGE) + { + gBattleStruct->blunderPolicy = FALSE; + gLastUsedItem = atkItem; + gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPEED, 2, FALSE); + effect = ITEM_STATS_CHANGE; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_AttackerItemStatRaise; + } + break; + } + break; + case ITEMEFFECT_LIFEORB_SHELLBELL: + // occur after the final hit of a multi-strike move + switch (atkHoldEffect) + { case HOLD_EFFECT_SHELL_BELL: if (gBattleMoveDamage != 0 // Need to have done damage && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) @@ -6389,35 +6409,40 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gSpecialStatuses[gBattlerTarget].dmg = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; - effect++; + effect = TRUE; + } + break; + case HOLD_EFFECT_LIFE_ORB: + if (IsBattlerAlive(gBattlerAttacker) + && !(TestSheerForceFlag(gBattlerAttacker, gCurrentMove)) + && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD + && gSpecialStatuses[gBattlerAttacker].damagedMons) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 10; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + effect = TRUE; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_ItemHurtRet; + gLastUsedItem = gBattleMons[gBattlerAttacker].item; } break; case HOLD_EFFECT_THROAT_SPRAY: // Does NOT need to be a damaging move if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !(gHitMarker & (HITMARKER_UNABLE_TO_USE_MOVE)) && gBattleMons[gBattlerAttacker].hp != 0 && gBattleMoves[gCurrentMove].flags & FLAG_SOUND - && gBattleMons[gBattlerAttacker].statStages[STAT_SPATK] < MAX_STAT_STAGE) + && gBattleMons[gBattlerAttacker].statStages[STAT_SPATK] < MAX_STAT_STAGE + && !NoAliveMonsForEitherParty()) // don't activate if battle will end { gLastUsedItem = atkItem; + gBattleScripting.battler = gBattlerAttacker; gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE); effect = ITEM_STATS_CHANGE; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AttackerItemStatRaise; } break; - case HOLD_EFFECT_BLUNDER_POLICY: - if (gBattleStruct->blunderPolicy - && gBattleMons[gBattlerAttacker].hp != 0 - && gBattleMons[gBattlerAttacker].statStages[STAT_SPEED] < MAX_STAT_STAGE) - { - gBattleStruct->blunderPolicy = FALSE; - gLastUsedItem = atkItem; - gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPEED, 2, FALSE); - effect = ITEM_STATS_CHANGE; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_AttackerItemStatRaise; - } - break; } break; case ITEMEFFECT_TARGET: