From 3338a6b7861436dd664c349408cc8ba3f0c0a229 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 27 Feb 2023 12:31:29 +0100 Subject: [PATCH 1/3] 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 c96b5fdd2..3419e2e56 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 e8b751777..d7b597c53 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 0751ae809..f2821af05 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 c24178cd0..b6eef0283 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 f3e702ec4..1bd82023e 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 29580ded0..74423781e 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 2d9f6f6c1..023548208 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 From 5a745020eefe7e2ae9e25fada11e92800ced4374 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 27 Feb 2023 16:27:58 +0100 Subject: [PATCH 2/3] add tests for stockpile swallow spit up --- src/battle_message.c | 8 +- test/move_effect_stockpile.c | 252 +++++++++++++++++++++++++++++++++++ test/test_battle.h | 2 +- 3 files changed, 257 insertions(+), 5 deletions(-) create mode 100644 test/move_effect_stockpile.c diff --git a/src/battle_message.c b/src/battle_message.c index 74423781e..997a6ae09 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -177,8 +177,8 @@ static const u8 sText_PkmnCausedUproar[] = _("{B_ATK_NAME_WITH_PREFIX} caused\na static const u8 sText_PkmnMakingUproar[] = _("{B_ATK_NAME_WITH_PREFIX} is making\nan UPROAR!"); static const u8 sText_PkmnCalmedDown[] = _("{B_ATK_NAME_WITH_PREFIX} calmed down."); static const u8 sText_PkmnCantSleepInUproar[] = _("But {B_DEF_NAME_WITH_PREFIX} can't\nsleep in an UPROAR!"); -static const u8 sText_PkmnStockpiled[] = _("{B_ATK_NAME_WITH_PREFIX} STOCKPILED\n{B_BUFF1}!"); -static const u8 sText_PkmnCantStockpile[] = _("{B_ATK_NAME_WITH_PREFIX} can't\nSTOCKPILE any more!"); +static const u8 sText_PkmnStockpiled[] = _("{B_ATK_NAME_WITH_PREFIX} stockpiled\n{B_BUFF1}!"); +static const u8 sText_PkmnCantStockpile[] = _("{B_ATK_NAME_WITH_PREFIX} can't\nstockpile any more!"); static const u8 sText_PkmnCantSleepInUproar2[] = _("But {B_DEF_NAME_WITH_PREFIX} can't\nsleep in an UPROAR!"); static const u8 sText_UproarKeptPkmnAwake[] = _("But the UPROAR kept\n{B_DEF_NAME_WITH_PREFIX} awake!"); static const u8 sText_PkmnStayedAwakeUsing[] = _("{B_DEF_NAME_WITH_PREFIX} stayed awake\nusing its {B_DEF_ABILITY}!"); @@ -360,8 +360,8 @@ static const u8 sText_SunlightFaded[] = _("The sunlight faded."); static const u8 sText_StartedHail[] = _("It started to hail!"); static const u8 sText_HailContinues[] = _("Hail continues to fall."); static const u8 sText_HailStopped[] = _("The hail stopped."); -static const u8 sText_FailedToSpitUp[] = _("But it failed to SPIT UP\na thing!"); -static const u8 sText_FailedToSwallow[] = _("But it failed to SWALLOW\na thing!"); +static const u8 sText_FailedToSpitUp[] = _("But it failed to spit up\na thing!"); +static const u8 sText_FailedToSwallow[] = _("But it failed to swallow\na thing!"); static const u8 sText_WindBecameHeatWave[] = _("The wind turned into a\nHEAT WAVE!"); static const u8 sText_StatChangesGone[] = _("All stat changes were\neliminated!"); static const u8 sText_CoinsScattered[] = _("Coins scattered everywhere!"); diff --git a/test/move_effect_stockpile.c b/test/move_effect_stockpile.c new file mode 100644 index 000000000..1e62f766d --- /dev/null +++ b/test/move_effect_stockpile.c @@ -0,0 +1,252 @@ +#include "global.h" +#include "test_battle.h" + +// These tests cover all 3 effects: Stockpile, Spit up and Swallow. +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_STOCKPILE].effect == EFFECT_STOCKPILE); + ASSUME(gBattleMoves[MOVE_SWALLOW].effect == EFFECT_SWALLOW); + ASSUME(gBattleMoves[MOVE_SPIT_UP].effect == EFFECT_SPIT_UP); +} + +SINGLE_BATTLE_TEST("Stockpile's count can go up only to 3") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, MOVE_STOCKPILE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 2!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 3!"); + + NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet can't stockpile any more!"); + } +} + +#define MAX_HP_TEST 400 +SINGLE_BATTLE_TEST("Spit Up and Swallow don't work if used without Stockpile") +{ + u32 move; + PARAMETRIZE {move = MOVE_SWALLOW ;} + PARAMETRIZE {move = MOVE_SPIT_UP ;} + GIVEN { + PLAYER(SPECIES_WOBBUFFET) {HP(10), MaxHP(MAX_HP_TEST) ;} + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, move); } + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, move); } + } SCENE { + NOT ANIMATION(ANIM_TYPE_MOVE, move, player); + if (move == MOVE_SWALLOW) + MESSAGE("But it failed to swallow a thing!"); + else + MESSAGE("But it failed to spit up a thing!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + + ANIMATION(ANIM_TYPE_MOVE, move, player); + if (move == MOVE_SPIT_UP) { + HP_BAR(opponent); + } + else { + HP_BAR(player); + } + } +} + +SINGLE_BATTLE_TEST("Spit Up's power raises depending on Stockpile's count", s16 damage) +{ + u8 count; + PARAMETRIZE { count = 1;} + PARAMETRIZE { count = 2;} + PARAMETRIZE { count = 3;} + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count != 1){ + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count == 3) { + TURN { MOVE(player, MOVE_STOCKPILE); } + } + } + TURN { MOVE(player, MOVE_SPIT_UP); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + if (count != 1) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 2!"); + if (count == 3) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 3!"); + } + } + ANIMATION(ANIM_TYPE_MOVE, MOVE_SPIT_UP, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, Q_4_12(3.0), results[2].damage); + } +} + +SINGLE_BATTLE_TEST("Swallow heals HP depending on Stockpile's count", s16 hpHeal) +{ + u8 count; + PARAMETRIZE { count = 1;} + PARAMETRIZE { count = 2;} + PARAMETRIZE { count = 3;} + GIVEN { + PLAYER(SPECIES_WOBBUFFET) {HP(1), MaxHP(MAX_HP_TEST); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count != 1){ + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count == 3) { + TURN { MOVE(player, MOVE_STOCKPILE); } + } + } + TURN { MOVE(player, MOVE_SWALLOW); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + if (count != 1) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 2!"); + if (count == 3) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 3!"); + } + } + ANIMATION(ANIM_TYPE_MOVE, MOVE_SWALLOW, player); + HP_BAR(player, captureDamage: &results[i].hpHeal); + } FINALLY { + EXPECT_EQ(results[0].hpHeal, -(MAX_HP_TEST / 4)); + EXPECT_EQ(results[1].hpHeal, -(MAX_HP_TEST / 2)); + EXPECT_EQ(results[2].hpHeal, -(MAX_HP_TEST - 1)); + } +} + +SINGLE_BATTLE_TEST("Stockpile temporarily raises Def and Sp.Def", s16 dmgPyhsical, s16 dmgSpecial) +{ + u16 move; + PARAMETRIZE {move = MOVE_STOCKPILE;} + PARAMETRIZE {move = MOVE_CELEBRATE;} + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); + ASSUME(gBattleMoves[MOVE_GUST].split == SPLIT_SPECIAL); + PLAYER(SPECIES_WOBBUFFET) {Speed(2); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(1); } + } WHEN { + TURN { MOVE(player, move); MOVE(opponent, MOVE_TACKLE); } + TURN { MOVE(opponent, MOVE_GUST); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, move, player); + if (move == MOVE_STOCKPILE) { + MESSAGE("Wobbuffet stockpiled 1!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Wobbuffet's defense rose!"); + MESSAGE("Wobbuffet's sp. defense rose!"); + } + + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + HP_BAR(player, captureDamage: &results[i].dmgPyhsical); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_GUST, opponent); + HP_BAR(player, captureDamage: &results[i].dmgSpecial); + } FINALLY { + EXPECT_MUL_EQ(results[0].dmgPyhsical, Q_4_12(1.5), results[1].dmgPyhsical); + EXPECT_MUL_EQ(results[0].dmgSpecial, Q_4_12(1.5), results[1].dmgSpecial); + } +} + +DOUBLE_BATTLE_TEST("Stockpile's Def and Sp.Def boost is lost after using Spit Up or Swallow", s16 dmgPyhsicalBefore, s16 dmgPhysicalAfter, s16 dmgSpecialBefore, s16 dmgSpecialAfter) +{ + u8 count; + u16 move; + PARAMETRIZE {count = 1, move = MOVE_SPIT_UP;} + PARAMETRIZE {count = 2, move = MOVE_SWALLOW;} + PARAMETRIZE {count = 3, move = MOVE_SPIT_UP;} + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); + ASSUME(gBattleMoves[MOVE_GUST].split == SPLIT_SPECIAL); + PLAYER(SPECIES_WOBBUFFET) {Speed(4); HP(MAX_HP_TEST - 1); MaxHP(MAX_HP_TEST); } + PLAYER(SPECIES_WOBBUFFET) {Speed(3); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(2); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(1); } + } WHEN { + TURN { MOVE(opponentLeft, MOVE_TACKLE, target:playerLeft, criticalHit:FALSE); MOVE(opponentRight, MOVE_GUST, criticalHit:FALSE, target:playerLeft);} + TURN { MOVE(playerLeft, MOVE_STOCKPILE);} + if (count != 1) { + TURN { MOVE(playerLeft, MOVE_STOCKPILE);} + if (count == 3) { + TURN { MOVE(playerLeft, MOVE_STOCKPILE);} + } + } + TURN { MOVE(playerLeft, move, target:opponentLeft); MOVE(opponentLeft, MOVE_TACKLE, target:playerLeft, criticalHit:FALSE); MOVE(opponentRight, MOVE_GUST, target:playerLeft, criticalHit:FALSE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft); + HP_BAR(playerLeft, captureDamage: &results[i].dmgPyhsicalBefore); + ANIMATION(ANIM_TYPE_MOVE, MOVE_GUST, opponentRight); + HP_BAR(playerLeft, captureDamage: &results[i].dmgSpecialBefore); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, playerLeft); + if (count != 1) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, playerLeft); + if (count == 3) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, playerLeft); + } + } + ANIMATION(ANIM_TYPE_MOVE, move, playerLeft); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + if (count == 1) { + MESSAGE("Wobbuffet's defense fell!"); + } + else if (count == 2) { + MESSAGE("Wobbuffet's defense harshly fell!"); + } + else { + MESSAGE("Wobbuffet's defense severely fell!"); + } + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + if (count == 1) { + MESSAGE("Wobbuffet's sp. defense fell!"); + } + else if (count == 2) { + MESSAGE("Wobbuffet's sp. defense harshly fell!"); + } + else { + MESSAGE("Wobbuffet's sp. defense severely fell!"); + } + MESSAGE("Wobbuffet's stockpiled effect wore off!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft); + HP_BAR(playerLeft, captureDamage: &results[i].dmgPhysicalAfter); + ANIMATION(ANIM_TYPE_MOVE, MOVE_GUST, opponentRight); + HP_BAR(playerLeft, captureDamage: &results[i].dmgSpecialAfter); + } FINALLY { + EXPECT_MUL_EQ(results[0].dmgPyhsicalBefore, UQ_4_12(1.0), results[0].dmgPhysicalAfter); + EXPECT_MUL_EQ(results[0].dmgSpecialBefore, UQ_4_12(1.0), results[0].dmgSpecialAfter); + EXPECT_MUL_EQ(results[1].dmgPyhsicalBefore, UQ_4_12(1.0), results[1].dmgPhysicalAfter); + EXPECT_MUL_EQ(results[1].dmgSpecialBefore, UQ_4_12(1.0), results[1].dmgSpecialAfter); + EXPECT_MUL_EQ(results[2].dmgPyhsicalBefore, UQ_4_12(1.0), results[2].dmgPhysicalAfter); + EXPECT_MUL_EQ(results[2].dmgSpecialBefore, UQ_4_12(1.0), results[2].dmgSpecialAfter); + } +} + diff --git a/test/test_battle.h b/test/test_battle.h index 806e7947e..16918251b 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -433,7 +433,7 @@ // NOTE: If the stack is too small the test runner will probably crash // or loop. #define BATTLE_TEST_STACK_SIZE 1024 -#define MAX_QUEUED_EVENTS 16 +#define MAX_QUEUED_EVENTS 25 enum { BATTLE_TEST_SINGLES, BATTLE_TEST_DOUBLES }; From c92a65dc40977fc9ffafafb2a87c91b2981018f4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 27 Feb 2023 21:09:02 +0100 Subject: [PATCH 3/3] Add config for stockpile raising def stats --- data/battle_scripts_1.s | 5 +++++ include/config/battle.h | 3 ++- test/move_effect_stockpile.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d7b597c53..eea0bccac 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5550,6 +5550,9 @@ BattleScript_EffectStockpile:: waitanimation printfromtable gStockpileUsedStringIds waitmessage B_WAIT_TIME_LONG + .if B_STOCKPILE_RAISES_DEFS < GEN_4 + goto BattleScript_EffectStockpileEnd + .endif jumpifmovehadnoeffect BattleScript_EffectStockpileEnd jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_DEF, MAX_STAT_STAGE, BattleScript_EffectStockpileDef jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_EffectStockpileEnd @@ -5572,9 +5575,11 @@ BattleScript_EffectStockpileEnd: goto BattleScript_MoveEnd BattleScript_MoveEffectStockpileWoreOff:: + .if B_STOCKPILE_RAISES_DEFS >= GEN_4 dostockpilestatchangeswearoff BS_ATTACKER, BattleScript_StockpileStatChangeDown printstring STRINGID_STOCKPILEDEFFECTWOREOFF waitmessage B_WAIT_TIME_SHORT + .endif return BattleScript_StockpileStatChangeDown: diff --git a/include/config/battle.h b/include/config/battle.h index a8f4a3e8b..8fdf596cc 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -96,7 +96,8 @@ #define B_DARK_VOID_FAIL GEN_LATEST // In Gen7+, only Darkrai can use Dark Void. #define B_BURN_HIT_THAW GEN_LATEST // In Gen6+, damaging moves with a chance of burn will thaw the target, regardless if they're fire-type moves or not. #define B_HEALING_WISH_SWITCH GEN_LATEST // In Gen5+, the mon receiving Healing Wish is sent out at the end of the turn. - // Additionally, in gen8+ the Healing Wish's effect will be stored until the user switches into a statused or hurt mon. + // Additionally, in gen8+ the Healing Wish's effect will be stored until the user switches into a statused or hurt mon +#define B_STOCKPILE_RAISES_DEFS GEN_LATEST // In Gen4+, Stockpile also raises Defense and Sp.Defense stats. Once Spit Up / Swallow is used, these stat changes are lost. // Ability settings #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. diff --git a/test/move_effect_stockpile.c b/test/move_effect_stockpile.c index 1e62f766d..0530355ef 100644 --- a/test/move_effect_stockpile.c +++ b/test/move_effect_stockpile.c @@ -148,6 +148,7 @@ SINGLE_BATTLE_TEST("Stockpile temporarily raises Def and Sp.Def", s16 dmgPyhsica PARAMETRIZE {move = MOVE_STOCKPILE;} PARAMETRIZE {move = MOVE_CELEBRATE;} GIVEN { + ASSUME(B_STOCKPILE_RAISES_DEFS >= GEN_4); ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); ASSUME(gBattleMoves[MOVE_GUST].split == SPLIT_SPECIAL); PLAYER(SPECIES_WOBBUFFET) {Speed(2); } @@ -183,6 +184,7 @@ DOUBLE_BATTLE_TEST("Stockpile's Def and Sp.Def boost is lost after using Spit Up PARAMETRIZE {count = 2, move = MOVE_SWALLOW;} PARAMETRIZE {count = 3, move = MOVE_SPIT_UP;} GIVEN { + ASSUME(B_STOCKPILE_RAISES_DEFS >= GEN_4); ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); ASSUME(gBattleMoves[MOVE_GUST].split == SPLIT_SPECIAL); PLAYER(SPECIES_WOBBUFFET) {Speed(4); HP(MAX_HP_TEST - 1); MaxHP(MAX_HP_TEST); }