Skip to content

Commit

Permalink
Fixes Take heart (#5658)
Browse files Browse the repository at this point in the history
Co-authored-by: KyleLaporte <moog272@gmail.com>
Co-authored-by: Pawkkie <61265402+Pawkkie@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 11, 2024
1 parent a8351e3 commit b55c87f
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 8 deletions.
2 changes: 1 addition & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@
.byte 0xcc
.endm

.macro cureifburnedparalysedorpoisoned failInstr:req
.macro curestatuswithmove failInstr:req
.byte 0xcd
.4byte \failInstr
.endm
Expand Down
4 changes: 2 additions & 2 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ BattleScript_EffectTakeHeart::
attackcanceler
attackstring
ppreduce
cureifburnedparalysedorpoisoned BattleScript_CalmMindTryToRaiseStats
curestatuswithmove BattleScript_CalmMindTryToRaiseStats
attackanimation
waitanimation
updatestatusicon BS_ATTACKER
Expand Down Expand Up @@ -5226,7 +5226,7 @@ BattleScript_EffectRefresh::
attackcanceler
attackstring
ppreduce
cureifburnedparalysedorpoisoned BattleScript_ButItFailed
curestatuswithmove BattleScript_ButItFailed
attackanimation
waitanimation
printstring STRINGID_PKMNSTATUSNORMAL
Expand Down
2 changes: 2 additions & 0 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
#define STATUS1_PSN_ANY (STATUS1_POISON | STATUS1_TOXIC_POISON)
#define STATUS1_ANY (STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE)

#define STATUS1_REFRESH (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE)

// Volatile status ailments
// These are removed after exiting the battle or switching out
#define STATUS2_CONFUSION (1 << 0 | 1 << 1 | 1 << 2)
Expand Down
15 changes: 10 additions & 5 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ static void Cmd_trymemento(void);
static void Cmd_setforcedtarget(void);
static void Cmd_setcharge(void);
static void Cmd_callterrainattack(void);
static void Cmd_cureifburnedparalysedorpoisoned(void);
static void Cmd_curestatuswithmove(void);
static void Cmd_settorment(void);
static void Cmd_jumpifnodamage(void);
static void Cmd_settaunt(void);
Expand Down Expand Up @@ -804,7 +804,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_setforcedtarget, //0xCA
Cmd_setcharge, //0xCB
Cmd_callterrainattack, //0xCC
Cmd_cureifburnedparalysedorpoisoned, //0xCD
Cmd_curestatuswithmove, //0xCD
Cmd_settorment, //0xCE
Cmd_jumpifnodamage, //0xCF
Cmd_settaunt, //0xD0
Expand Down Expand Up @@ -14135,12 +14135,17 @@ u32 GetNaturePowerMove(u32 battler)
return move;
}

// Refresh
static void Cmd_cureifburnedparalysedorpoisoned(void)
static void Cmd_curestatuswithmove(void)
{
CMD_ARGS(const u8 *failInstr);
u32 shouldHeal;

if (gBattleMons[gBattlerAttacker].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE))
if (gMovesInfo[gCurrentMove].effect == EFFECT_REFRESH)
shouldHeal = gBattleMons[gBattlerAttacker].status1 & STATUS1_REFRESH;
else // Take Heart
shouldHeal = gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY;

if (shouldHeal)
{
gBattleMons[gBattlerAttacker].status1 = 0;
gBattlescriptCurrInstr = cmd->nextInstr;
Expand Down
68 changes: 68 additions & 0 deletions test/battle/move_effect/refresh.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gMovesInfo[MOVE_REFRESH].effect == EFFECT_REFRESH);
}

SINGLE_BATTLE_TEST("Refresh cures the user of burn, frostbite, poison, and paralysis")
{
u32 status1;
PARAMETRIZE { status1 = STATUS1_POISON; }
PARAMETRIZE { status1 = STATUS1_BURN; }
PARAMETRIZE { status1 = STATUS1_PARALYSIS; }
PARAMETRIZE { status1 = STATUS1_TOXIC_POISON; }
PARAMETRIZE { status1 = STATUS1_FROSTBITE; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(status1); };
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_REFRESH); }
} SCENE {
MESSAGE("Wobbuffet's status returned to normal!");
STATUS_ICON(player, none: TRUE);
}
}

SINGLE_BATTLE_TEST("Refresh does not cure the user of Freeze")
{
PASSES_RANDOMLY(20, 100, RNG_FROZEN);
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_FREEZE); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_REFRESH); }
} SCENE {
MESSAGE("Wobbuffet used Refresh!");
NONE_OF {
ANIMATION(ANIM_TYPE_MOVE, MOVE_REFRESH, player);
STATUS_ICON(player, none: TRUE); }
MESSAGE("But it failed!");
}
}

SINGLE_BATTLE_TEST("Refresh does not cure sleep when used by Sleep Talk")
{
GIVEN {
ASSUME(gMovesInfo[MOVE_SPORE].effect == EFFECT_SLEEP);
ASSUME(gMovesInfo[MOVE_SLEEP_TALK].effect == EFFECT_SLEEP_TALK);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_SLEEP_TALK, MOVE_REFRESH); }
} WHEN {
TURN { MOVE(player, MOVE_SPORE); MOVE(opponent, MOVE_SLEEP_TALK); }
TURN { MOVE(player, MOVE_SPORE); MOVE(opponent, MOVE_REFRESH); }
} SCENE {
MESSAGE("Wobbuffet used Spore!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_SPORE, player);
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_SLP, opponent);
MESSAGE("Foe Wobbuffet fell asleep!");
MESSAGE("Foe Wobbuffet used Sleep Talk!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, opponent);
MESSAGE("Foe Wobbuffet used Refresh!");
NONE_OF {
ANIMATION(ANIM_TYPE_MOVE, MOVE_REFRESH, player);
STATUS_ICON(player, none: TRUE); }
MESSAGE("But it failed!");
}
}
24 changes: 24 additions & 0 deletions test/battle/move_effect/take_heart.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,32 @@ SINGLE_BATTLE_TEST("Take Heart cures the user of all status conditions")
STATUS_ICON(player, none: TRUE);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player);
} else {
STATUS_ICON(player, none: TRUE);
MESSAGE("Wobbuffet's status returned to normal!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player);
}
}
}

SINGLE_BATTLE_TEST("Take Heart cures sleep when used by Sleep Talk")
{
GIVEN {
ASSUME(gMovesInfo[MOVE_SPORE].effect == EFFECT_SLEEP);
ASSUME(gMovesInfo[MOVE_SLEEP_TALK].effect == EFFECT_SLEEP_TALK);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_SLEEP_TALK, MOVE_TAKE_HEART); }
} WHEN {
TURN { MOVE(player, MOVE_SPORE); MOVE(opponent, MOVE_SLEEP_TALK); }
} SCENE {
MESSAGE("Wobbuffet used Spore!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_SPORE, player);
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_SLP, opponent);
MESSAGE("Foe Wobbuffet fell asleep!");
MESSAGE("Foe Wobbuffet used Sleep Talk!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, opponent);
MESSAGE("Foe Wobbuffet used Take Heart!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TAKE_HEART, opponent);
STATUS_ICON(opponent, none: TRUE);
MESSAGE("Foe Wobbuffet's status returned to normal!");
}
}

0 comments on commit b55c87f

Please sign in to comment.