From b39c40d722190c639f56dc6633d92be7200e2997 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Apr 2023 23:34:07 +0200 Subject: [PATCH 1/3] fix for burn up/double shock --- data/battle_scripts_1.s | 10 ++++++---- src/battle_script_commands.c | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0be893412761..163333ef59ef 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1444,8 +1444,9 @@ BattleScript_EffectBurnUp: goto BattleScript_ButItFailed BattleScript_BurnUpWorks: - setmoveeffect MOVE_EFFECT_BURN_UP | MOVE_EFFECT_CERTAIN - goto BattleScript_EffectHit + setmoveeffect MOVE_EFFECT_BURN_UP | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + goto BattleScript_HitFromCritCalc BattleScript_BurnUpRemoveType:: losetype BS_ATTACKER, TYPE_FIRE @@ -1461,8 +1462,9 @@ BattleScript_EffectDoubleShock: goto BattleScript_ButItFailed BattleScript_DoubleShockWorks: - setmoveeffect MOVE_EFFECT_DOUBLE_SHOCK | MOVE_EFFECT_CERTAIN - goto BattleScript_EffectHit + setmoveeffect MOVE_EFFECT_DOUBLE_SHOCK | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + goto BattleScript_HitFromCritCalc BattleScript_DoubleShockRemoveType:: losetype BS_ATTACKER, TYPE_ELECTRIC diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4e1494ce3828..10b02de2a3f9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11264,7 +11264,7 @@ static void Cmd_various(void) // Open party menu, wait to go to next instruction. else - { + { BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_FAINTED_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gBattlerAttacker]); MarkBattlerForControllerExec(gBattlerAttacker); } @@ -16469,7 +16469,7 @@ void BS_ItemRestoreHP(void) { } if (hp + healAmount > maxHP) healAmount = maxHP - hp; - + // Heal is applied as move damage if battler is active. if (battlerId != MAX_BATTLERS_COUNT && hp != 0) { @@ -16494,10 +16494,10 @@ void BS_ItemRestoreHP(void) { void BS_ItemCureStatus(void) { NATIVE_ARGS(); struct Pokemon *party = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; - + // Heal Status1 conditions. HealStatusConditions(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], gBattleStruct->itemPartyIndex[gBattlerAttacker], GetItemStatus1Mask(gLastUsedItem), gBattlerAttacker); - + // Heal Status2 conditions if battler is active. if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) { @@ -16506,10 +16506,10 @@ void BS_ItemCureStatus(void) { else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)]) { - gBattleMons[gBattlerAttacker].status2 &= ~GetItemStatus2Mask(gLastUsedItem); + gBattleMons[gBattlerAttacker].status2 &= ~GetItemStatus2Mask(gLastUsedItem); gBattlerTarget = BATTLE_PARTNER(gBattlerAttacker); } - + if (GetItemStatus1Mask(gLastUsedItem) & STATUS1_SLEEP) gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; From 4146f0136d5d360aebc7aa1fe50a750178c982fc Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sat, 29 Apr 2023 00:02:58 +0200 Subject: [PATCH 2/3] Tests for BurnUp/DoublShock --- src/battle_script_commands.c | 1 - test/move_effect_burn_up.c | 57 +++++++++++++++++++++++++++++++++ test/move_effect_double_shock.c | 57 +++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 test/move_effect_burn_up.c create mode 100644 test/move_effect_double_shock.c diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a22b155a3b58..a5613074831c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16541,7 +16541,6 @@ void BS_ItemCureStatus(void) { NATIVE_ARGS(); struct Pokemon *party = GetBattlerParty(gBattlerAttacker); - // Heal Status1 conditions. HealStatusConditions(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], gBattleStruct->itemPartyIndex[gBattlerAttacker], GetItemStatus1Mask(gLastUsedItem), gBattlerAttacker); diff --git a/test/move_effect_burn_up.c b/test/move_effect_burn_up.c new file mode 100644 index 000000000000..53dd44e69f3c --- /dev/null +++ b/test/move_effect_burn_up.c @@ -0,0 +1,57 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_BURN_UP].effect == EFFECT_BURN_UP); +} + +SINGLE_BATTLE_TEST("Burn Up user loses it's typing", s16 damage) +{ + s16 stabDamage; + s16 nonStabDamage; + + GIVEN { + PLAYER(SPECIES_CYNDAQUIL); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_BURN_UP); } + TURN { MOVE(player, MOVE_BURN_UP); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_BURN_UP, player); + MESSAGE("Cyndaquil burned itself out!"); + MESSAGE("Cyndaquil used Burn Up!"); + MESSAGE("But it failed!"); + } +} + +SINGLE_BATTLE_TEST("Burn Up fails if the user isn't a fire type", s16 damage) +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_BURN_UP); } + } SCENE { + NONE_OF { ANIMATION(ANIM_TYPE_MOVE, MOVE_BURN_UP, player); } + MESSAGE("Wobbuffet used Burn Up!"); + MESSAGE("But it failed!"); + } +} + +SINGLE_BATTLE_TEST("Burn Up user loses it's typing if enemy faints", s16 damage) +{ + s16 stabDamage; + s16 nonStabDamage; + + GIVEN { + PLAYER(SPECIES_CYNDAQUIL); + OPPONENT(SPECIES_WOBBUFFET) { HP(1); } + } WHEN { + TURN { MOVE(player, MOVE_BURN_UP); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_BURN_UP, player); + HP_BAR(opponent, hp: 0); + MESSAGE("Cyndaquil burned itself out!"); + } +} diff --git a/test/move_effect_double_shock.c b/test/move_effect_double_shock.c new file mode 100644 index 000000000000..b3b2f62b516f --- /dev/null +++ b/test/move_effect_double_shock.c @@ -0,0 +1,57 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_DOUBLE_SHOCK].effect == EFFECT_DOUBLE_SHOCK); +} + +SINGLE_BATTLE_TEST("Double Shock user loses it's typing", s16 damage) +{ + s16 stabDamage; + s16 nonStabDamage; + + GIVEN { + PLAYER(SPECIES_PIKACHU); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_DOUBLE_SHOCK); } + TURN { MOVE(player, MOVE_DOUBLE_SHOCK); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DOUBLE_SHOCK, player); + MESSAGE("Pikachu used up all of its electricity!"); + MESSAGE("Pikachu used Double Shock!"); + MESSAGE("But it failed!"); + } +} + +SINGLE_BATTLE_TEST("Double Shock fails if the user isn't a fire type", s16 damage) +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_DOUBLE_SHOCK); } + } SCENE { + NONE_OF { ANIMATION(ANIM_TYPE_MOVE, MOVE_DOUBLE_SHOCK, player); } + MESSAGE("Wobbuffet used Double Shock!"); + MESSAGE("But it failed!"); + } +} + +SINGLE_BATTLE_TEST("Double Shock user loses it's typing if enemy faints", s16 damage) +{ + s16 stabDamage; + s16 nonStabDamage; + + GIVEN { + PLAYER(SPECIES_PIKACHU); + OPPONENT(SPECIES_WOBBUFFET) { HP(1); } + } WHEN { + TURN { MOVE(player, MOVE_DOUBLE_SHOCK); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DOUBLE_SHOCK, player); + HP_BAR(opponent, hp: 0); + MESSAGE("Pikachu used up all of its electricity!"); + } +} From 37de222887a62ff3d747808d6903898721519816 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 30 Apr 2023 10:32:40 +0200 Subject: [PATCH 3/3] Improve BurnUp/DoubleShock tests --- test/move_effect_burn_up.c | 14 +++++--------- test/move_effect_double_shock.c | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/test/move_effect_burn_up.c b/test/move_effect_burn_up.c index 53dd44e69f3c..a53b1afa8655 100644 --- a/test/move_effect_burn_up.c +++ b/test/move_effect_burn_up.c @@ -4,13 +4,12 @@ ASSUMPTIONS { ASSUME(gBattleMoves[MOVE_BURN_UP].effect == EFFECT_BURN_UP); + ASSUME(gSpeciesInfo[SPECIES_WOBBUFFET].types[0] != TYPE_FIRE || gSpeciesInfo[SPECIES_WOBBUFFET].types[1] != TYPE_FIRE); + ASSUME(gSpeciesInfo[SPECIES_CYNDAQUIL].types[0] == TYPE_FIRE || gSpeciesInfo[SPECIES_CYNDAQUIL].types[1] == TYPE_FIRE); } -SINGLE_BATTLE_TEST("Burn Up user loses it's typing", s16 damage) +SINGLE_BATTLE_TEST("Burn Up user loses its Fire-type") { - s16 stabDamage; - s16 nonStabDamage; - GIVEN { PLAYER(SPECIES_CYNDAQUIL); OPPONENT(SPECIES_WOBBUFFET); @@ -25,7 +24,7 @@ SINGLE_BATTLE_TEST("Burn Up user loses it's typing", s16 damage) } } -SINGLE_BATTLE_TEST("Burn Up fails if the user isn't a fire type", s16 damage) +SINGLE_BATTLE_TEST("Burn Up fails if the user isn't a Fire-type") { GIVEN { PLAYER(SPECIES_WOBBUFFET); @@ -39,11 +38,8 @@ SINGLE_BATTLE_TEST("Burn Up fails if the user isn't a fire type", s16 damage) } } -SINGLE_BATTLE_TEST("Burn Up user loses it's typing if enemy faints", s16 damage) +SINGLE_BATTLE_TEST("Burn Up user loses its Fire-type if enemy faints") { - s16 stabDamage; - s16 nonStabDamage; - GIVEN { PLAYER(SPECIES_CYNDAQUIL); OPPONENT(SPECIES_WOBBUFFET) { HP(1); } diff --git a/test/move_effect_double_shock.c b/test/move_effect_double_shock.c index b3b2f62b516f..c3651c4034cb 100644 --- a/test/move_effect_double_shock.c +++ b/test/move_effect_double_shock.c @@ -4,13 +4,12 @@ ASSUMPTIONS { ASSUME(gBattleMoves[MOVE_DOUBLE_SHOCK].effect == EFFECT_DOUBLE_SHOCK); + ASSUME(gSpeciesInfo[SPECIES_WOBBUFFET].types[0] != TYPE_ELECTRIC || gSpeciesInfo[SPECIES_WOBBUFFET].types[1] != TYPE_ELECTRIC); + ASSUME(gSpeciesInfo[SPECIES_PIKACHU].types[0] == TYPE_ELECTRIC || gSpeciesInfo[SPECIES_PIKACHU].types[1] == TYPE_ELECTRIC); } -SINGLE_BATTLE_TEST("Double Shock user loses it's typing", s16 damage) +SINGLE_BATTLE_TEST("Double Shock user loses its Electric-type") { - s16 stabDamage; - s16 nonStabDamage; - GIVEN { PLAYER(SPECIES_PIKACHU); OPPONENT(SPECIES_WOBBUFFET); @@ -25,7 +24,7 @@ SINGLE_BATTLE_TEST("Double Shock user loses it's typing", s16 damage) } } -SINGLE_BATTLE_TEST("Double Shock fails if the user isn't a fire type", s16 damage) +SINGLE_BATTLE_TEST("Double Shock fails if the user isn't an Electric-type") { GIVEN { PLAYER(SPECIES_WOBBUFFET); @@ -39,11 +38,8 @@ SINGLE_BATTLE_TEST("Double Shock fails if the user isn't a fire type", s16 damag } } -SINGLE_BATTLE_TEST("Double Shock user loses it's typing if enemy faints", s16 damage) +SINGLE_BATTLE_TEST("Double Shock user loses its Electric-type if enemy faints") { - s16 stabDamage; - s16 nonStabDamage; - GIVEN { PLAYER(SPECIES_PIKACHU); OPPONENT(SPECIES_WOBBUFFET) { HP(1); }