From 3338a6b7861436dd664c349408cc8ba3f0c0a229 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 27 Feb 2023 12:31:29 +0100 Subject: [PATCH] add messages for stockpile effects wear off --- asm/macros/battle_script.inc | 6 ++++ data/battle_scripts_1.s | 15 +++++++++ include/battle_scripts.h | 1 + include/constants/battle.h | 3 +- include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 ++ src/battle_script_commands.c | 46 +++++++++++++++++++++------ 7 files changed, 65 insertions(+), 11 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index c96b5fdd2d..3419e2e560 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1317,6 +1317,12 @@ .2byte \holdEffect .4byte \jumpInstr .endm + + .macro dostockpilestatchangeswearoff, battler:req, statChangeInstr:req + callnative BS_DoStockpileStatChangesWearOff + .byte \battler + .4byte \statChangeInstr + .endm .macro jumpifmorethanhalfHP battler:req, jumpInstr:req callnative BS_JumpIfMoreThanHalfHP diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e8b751777b..d7b597c53f 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5570,6 +5570,21 @@ BattleScript_EffectStockpileSpDef:: BattleScript_EffectStockpileEnd: stockpile 1 goto BattleScript_MoveEnd + +BattleScript_MoveEffectStockpileWoreOff:: + dostockpilestatchangeswearoff BS_ATTACKER, BattleScript_StockpileStatChangeDown + printstring STRINGID_STOCKPILEDEFFECTWOREOFF + waitmessage B_WAIT_TIME_SHORT + return + +BattleScript_StockpileStatChangeDown: + statbuffchange MOVE_EFFECT_AFFECTS_USER, BattleScript_StockpileStatChangeDown_Ret + setgraphicalstatchangevalues + playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatDownStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_StockpileStatChangeDown_Ret: + return BattleScript_EffectSpitUp:: attackcanceler diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 0751ae8097..f2821af059 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -456,6 +456,7 @@ extern const u8 BattleScript_HealingWishActivates[]; extern const u8 BattleScript_LunarDanceActivates[]; extern const u8 BattleScript_ShellTrapSetUp[]; extern const u8 BattleScript_CouldntFullyProtect[]; +extern const u8 BattleScript_MoveEffectStockpileWoreOff[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/battle.h b/include/constants/battle.h index c24178cd08..b6eef02830 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -372,8 +372,9 @@ #define MOVE_EFFECT_TRAP_BOTH 70 #define MOVE_EFFECT_DOUBLE_SHOCK 71 #define MOVE_EFFECT_ROUND 72 +#define MOVE_EFFECT_STOCKPILE_WORE_OFF 74 -#define NUM_MOVE_EFFECTS 73 +#define NUM_MOVE_EFFECTS 75 #define MOVE_EFFECT_AFFECTS_USER 0x4000 #define MOVE_EFFECT_CERTAIN 0x8000 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index f3e702ec46..1bd82023ed 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -642,8 +642,9 @@ #define STRINGID_PREPARESHELLTRAP 640 #define STRINGID_SHELLTRAPDIDNTWORK 641 #define STRINGID_COULDNTFULLYPROTECT 642 +#define STRINGID_STOCKPILEDEFFECTWOREOFF 643 -#define BATTLESTRINGS_COUNT 643 +#define BATTLESTRINGS_COUNT 644 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/src/battle_message.c b/src/battle_message.c index 29580ded00..74423781e1 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -777,9 +777,11 @@ static const u8 sText_AttackerGainedStrengthFromTheFallen[] = _("{B_ATK_NAME_WIT static const u8 sText_PrepareShellTrap[] = _("{B_ATK_NAME_WITH_PREFIX} set a shell trap!"); static const u8 sText_ShellTrapDidntWork[] = _("{B_ATK_NAME_WITH_PREFIX}'s shell trap didn't work!"); static const u8 sText_CouldntFullyProtect[] = _("{B_DEF_NAME_WITH_PREFIX} couldn't fully protect\nitself and got hurt!"); +static const u8 sText_StockpiledEffectWoreOff[] = _("{B_ATK_NAME_WITH_PREFIX}'s stockpiled\neffect wore off!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_STOCKPILEDEFFECTWOREOFF - BATTLESTRINGS_TABLE_START] = sText_StockpiledEffectWoreOff, [STRINGID_COULDNTFULLYPROTECT - BATTLESTRINGS_TABLE_START] = sText_CouldntFullyProtect, [STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN - BATTLESTRINGS_TABLE_START] = sText_AttackerGainedStrengthFromTheFallen, [STRINGID_ABILITYWEAKENEDFSURROUNDINGMONSSTAT - BATTLESTRINGS_TABLE_START] = sText_AbilityWeakenedSurroundingMonsStat, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2d9f6f6c18..023548208e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2890,6 +2890,7 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_KNOCK_OFF: case MOVE_EFFECT_SMACK_DOWN: case MOVE_EFFECT_REMOVE_STATUS: + case MOVE_EFFECT_STOCKPILE_WORE_OFF: gBattleStruct->moveEffect2 = gBattleScripting.moveEffect; gBattlescriptCurrInstr++; return; @@ -5609,6 +5610,15 @@ static void Cmd_moveend(void) case MOVE_EFFECT_KNOCK_OFF: effect = TryKnockOffBattleScript(gBattlerTarget); break; + case MOVE_EFFECT_STOCKPILE_WORE_OFF: + if (gDisableStructs[gBattlerAttacker].stockpileCounter != 0) + { + gDisableStructs[gBattlerAttacker].stockpileCounter = 0; + effect = TRUE; + BattleScriptPush(gBattlescriptCurrInstr); + gBattlescriptCurrInstr = BattleScript_MoveEffectStockpileWoreOff; + } + break; case MOVE_EFFECT_SMACK_DOWN: if (!IsBattlerGrounded(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)) { @@ -11651,10 +11661,7 @@ static void Cmd_stockpiletobasedamage(void) if (!(gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT && gBattleMons[gBattlerTarget].hp != 0)) { - gDisableStructs[gBattlerAttacker].stockpileCounter = 0; - // Restore stat changes from stockpile. - gBattleMons[gBattlerAttacker].statStages[STAT_DEF] -= gDisableStructs[gBattlerAttacker].stockpileDef; - gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] -= gDisableStructs[gBattlerAttacker].stockpileSpDef; + gBattleStruct->moveEffect2 = MOVE_EFFECT_STOCKPILE_WORE_OFF; } gBattlescriptCurrInstr = cmd->nextInstr; } @@ -11689,14 +11696,10 @@ static void Cmd_stockpiletohpheal(void) gBattleMoveDamage *= -1; gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; - gDisableStructs[gBattlerAttacker].stockpileCounter = 0; + gBattleStruct->moveEffect2 = MOVE_EFFECT_STOCKPILE_WORE_OFF; gBattlescriptCurrInstr = cmd->nextInstr; gBattlerTarget = gBattlerAttacker; } - - // Restore stat changes from stockpile. - gBattleMons[gBattlerAttacker].statStages[STAT_DEF] -= gDisableStructs[gBattlerAttacker].stockpileDef; - gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] -= gDisableStructs[gBattlerAttacker].stockpileSpDef; } } @@ -16136,6 +16139,31 @@ void BS_JumpIfHoldEffect(void) } } +void BS_DoStockpileStatChangesWearOff(void) +{ + NATIVE_ARGS(u8 battler, const u8 *statChangeInstr); + + u32 battler = GetBattlerForBattleScript(cmd->battler); + if (gDisableStructs[battler].stockpileDef != 0) + { + SET_STATCHANGER(STAT_DEF, abs(gDisableStructs[battler].stockpileDef), TRUE); + gDisableStructs[battler].stockpileDef = 0; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = cmd->statChangeInstr; + } + else if (gDisableStructs[battler].stockpileSpDef) + { + SET_STATCHANGER(STAT_SPDEF, abs(gDisableStructs[battler].stockpileSpDef), TRUE); + gDisableStructs[battler].stockpileSpDef = 0; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = cmd->statChangeInstr; + } + else + { + gBattlescriptCurrInstr = cmd->nextInstr; + } +} + static bool32 CriticalCapture(u32 odds) { #if B_CRITICAL_CAPTURE == TRUE