From db6f9d05ec820177e7fe52d67b832b0e61187c02 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 6 Jan 2021 15:28:58 -0700 Subject: [PATCH] add throat spray --- data/battle_scripts_1.s | 15 +++++++ include/battle_scripts.h | 1 + src/battle_script_commands.c | 13 +++--- src/battle_util.c | 81 ++++++++++++++++++++---------------- 4 files changed, 70 insertions(+), 40 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3eb1f5cbe6..32ba6d1280 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5616,6 +5616,21 @@ BattleScript_TargetItemStatRaise:: removeitem BS_TARGET BattleScript_TargetItemStatRaiseRemoveItemRet: return + +BattleScript_AttackerItemStatRaise:: + copybyte sBATTLER, gBattlerAttacker + statbuffchange 0, BattleScript_AttackerItemStatRaiseRet + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_AttackerItemStatRaiseRet + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + waitanimation + setgraphicalstatchangevalues + playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + waitanimation + printstring STRINGID_USINGXTHEYOFZN + waitmessage 0x40 + removeitem BS_ATTACKER +BattleScript_AttackerItemStatRaiseRet: + return BattleScript_MistProtected:: pause 0x20 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 3566a1c4d2..1efb9052de 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -350,5 +350,6 @@ extern const u8 BattleScript_EmergencyExitWild[]; extern const u8 BattleScript_EmergencyExitWildNoPopUp[]; extern const u8 BattleScript_CheekPouchActivates[]; extern const u8 BattleScript_AnnounceAirLockCloudNine[]; +extern const u8 BattleScript_AttackerItemStatRaise[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 45075ca374..b846e81ecf 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5007,18 +5007,21 @@ static void Cmd_moveend(void) gBattleScripting.moveendState++; break; case MOVEEND_EJECT_BUTTON: - if (gCurrentMove != MOVE_DRAGON_TAIL && gCurrentMove != MOVE_CIRCLE_THROW) + /*if (gCurrentMove != MOVE_DRAGON_TAIL && gCurrentMove != MOVE_CIRCLE_THROW) { u8 battlers[4] = {0, 1, 2, 3}; SortBattlersBySpeed } - BattleScript_ForceRandomSwitch - + BattleScript_ForceRandomSwitch*/ + gBattleScripting.moveendState++; + break; case MOVEEND_RED_CARD: - + gBattleScripting.moveendState++; + break; case MOVEEND_EJECT_PACK: - + gBattleScripting.moveendState++; + break; case MOVEEND_LIFE_ORB: if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_LIFE_ORB && IsBattlerAlive(gBattlerAttacker) diff --git a/src/battle_util.c b/src/battle_util.c index aeeefa7347..dba898693f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5738,44 +5738,55 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case ITEMEFFECT_KINGSROCK_SHELLBELL: - if (gBattleMoveDamage) + switch (atkHoldEffect) { - switch (atkHoldEffect) + case HOLD_EFFECT_FLINCH: + if (gBattleMoveDamage != 0 // need to have done damage + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && (Random() % 100) < atkHoldEffectParam + && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED + && gBattleMons[gBattlerTarget].hp) { - case HOLD_EFFECT_FLINCH: - if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && TARGET_TURN_DAMAGED - && (Random() % 100) < atkHoldEffectParam - && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED - && gBattleMons[gBattlerTarget].hp) - { - gBattleScripting.moveEffect = MOVE_EFFECT_FLINCH; - BattleScriptPushCursor(); - SetMoveEffect(FALSE, 0); - BattleScriptPop(); - } - break; - case HOLD_EFFECT_SHELL_BELL: - if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gSpecialStatuses[gBattlerTarget].dmg != 0 - && gSpecialStatuses[gBattlerTarget].dmg != 0xFFFF - && gBattlerAttacker != gBattlerTarget - && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP - && gBattleMons[gBattlerAttacker].hp != 0) - { - gLastUsedItem = atkItem; - gPotentialItemEffectBattler = gBattlerAttacker; - gBattleScripting.battler = gBattlerAttacker; - gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].dmg / atkHoldEffectParam) * -1; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = -1; - gSpecialStatuses[gBattlerTarget].dmg = 0; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; - effect++; - } - break; + gBattleScripting.moveEffect = MOVE_EFFECT_FLINCH; + BattleScriptPushCursor(); + SetMoveEffect(FALSE, 0); + BattleScriptPop(); } + break; + case HOLD_EFFECT_SHELL_BELL: + if (gBattleMoveDamage != 0 // need to have done damage + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && gSpecialStatuses[gBattlerTarget].dmg != 0 + && gSpecialStatuses[gBattlerTarget].dmg != 0xFFFF + && gBattlerAttacker != gBattlerTarget + && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP + && gBattleMons[gBattlerAttacker].hp != 0) + { + gLastUsedItem = atkItem; + gPotentialItemEffectBattler = gBattlerAttacker; + gBattleScripting.battler = gBattlerAttacker; + gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].dmg / atkHoldEffectParam) * -1; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = -1; + gSpecialStatuses[gBattlerTarget].dmg = 0; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; + effect++; + } + break; + case HOLD_EFFECT_THROAT_SPRAY: // doesn't need to be a damaging move + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && gBattleMons[gBattlerAttacker].hp != 0 + && gBattleMoves[gCurrentMove].flags & FLAG_SOUND) + { + gLastUsedItem = atkItem; + gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE); + effect = ITEM_STATS_CHANGE; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_AttackerItemStatRaise; + } + break; } break; case ITEMEFFECT_TARGET: