mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Fix Bad Dreams ability pop-up + tests (#3131)
* Fix all bad dreams issues and add tests Co-authored-by: ShaeTsuPog <shaetsu@protonmail.com>
This commit is contained in:
parent
b48175edd2
commit
381aa58587
@ -8957,16 +8957,7 @@ BattleScript_PsychicSurgeActivates::
|
||||
call BattleScript_ActivateTerrainEffects
|
||||
end3
|
||||
|
||||
BattleScript_HurtTarget_NoString:
|
||||
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
|
||||
healthbarupdate BS_TARGET
|
||||
datahpupdate BS_TARGET
|
||||
tryfaintmon BS_TARGET
|
||||
return
|
||||
|
||||
BattleScript_BadDreamsActivates::
|
||||
call BattleScript_AbilityPopUp
|
||||
setbyte sFIXED_ABILITY_POPUP, TRUE
|
||||
setbyte gBattlerTarget, 0
|
||||
BattleScript_BadDreamsLoop:
|
||||
jumpiftargetally BattleScript_BadDreamsIncrement
|
||||
@ -8975,16 +8966,32 @@ BattleScript_BadDreamsLoop:
|
||||
jumpifstatus BS_TARGET, STATUS1_SLEEP, BattleScript_BadDreams_Dmg
|
||||
goto BattleScript_BadDreamsIncrement
|
||||
BattleScript_BadDreams_Dmg:
|
||||
jumpifbyteequal sFIXED_ABILITY_POPUP, sZero, BattleScript_BadDreams_ShowPopUp
|
||||
BattleScript_BadDreams_DmgAfterPopUp:
|
||||
printstring STRINGID_BADDREAMSDMG
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
dmg_1_8_targethp
|
||||
call BattleScript_HurtTarget_NoString
|
||||
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
|
||||
healthbarupdate BS_TARGET
|
||||
datahpupdate BS_TARGET
|
||||
jumpifhasnohp BS_TARGET, BattleScript_BadDreams_HidePopUp
|
||||
BattleScript_BadDreamsIncrement:
|
||||
addbyte gBattlerTarget, 1
|
||||
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_BadDreamsLoop
|
||||
BattleScript_BadDreamsEnd:
|
||||
jumpifbyteequal sFIXED_ABILITY_POPUP, sZero, BattleScript_BadDreamsEnd
|
||||
destroyabilitypopup
|
||||
pause 15
|
||||
BattleScript_BadDreamsEnd:
|
||||
end3
|
||||
BattleScript_BadDreams_ShowPopUp:
|
||||
copybyte gBattlerAbility, gBattlerAttacker
|
||||
call BattleScript_AbilityPopUp
|
||||
setbyte sFIXED_ABILITY_POPUP, TRUE
|
||||
goto BattleScript_BadDreams_DmgAfterPopUp
|
||||
BattleScript_BadDreams_HidePopUp:
|
||||
destroyabilitypopup
|
||||
tryfaintmon BS_TARGET
|
||||
goto BattleScript_BadDreamsIncrement
|
||||
|
||||
BattleScript_TookAttack::
|
||||
attackstring
|
||||
|
130
test/ability_bad_dreams.c
Normal file
130
test/ability_bad_dreams.c
Normal file
@ -0,0 +1,130 @@
|
||||
#include "global.h"
|
||||
#include "test_battle.h"
|
||||
|
||||
ASSUMPTIONS
|
||||
{
|
||||
ASSUME(P_GEN_4_POKEMON == TRUE); // Because only Darkrai can have this ability.
|
||||
}
|
||||
|
||||
// Also checks that non-sleeping enemy is not affected.
|
||||
SINGLE_BATTLE_TEST("Bad Dreams causes the sleeping enemy Pokemon to lose 1/8 of hp")
|
||||
{
|
||||
u32 status;
|
||||
PARAMETRIZE { status = STATUS1_NONE; }
|
||||
PARAMETRIZE { status = STATUS1_SLEEP; }
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_DARKRAI);
|
||||
OPPONENT(SPECIES_WOBBUFFET) {Status1(status);}
|
||||
} WHEN {
|
||||
TURN {;}
|
||||
} SCENE {
|
||||
if (status == STATUS1_SLEEP) {
|
||||
ABILITY_POPUP(player, ABILITY_BAD_DREAMS);
|
||||
MESSAGE("Foe Wobbuffet is tormented!");
|
||||
HP_BAR(opponent);
|
||||
}
|
||||
else {
|
||||
NONE_OF {
|
||||
ABILITY_POPUP(player, ABILITY_BAD_DREAMS);
|
||||
MESSAGE("Foe Wobbuffet is tormented!");
|
||||
HP_BAR(opponent);
|
||||
};
|
||||
}
|
||||
} THEN {
|
||||
if (status == STATUS1_SLEEP) {
|
||||
EXPECT_EQ(opponent->hp, opponent->maxHP - opponent->maxHP / 8);
|
||||
}
|
||||
else {
|
||||
EXPECT_EQ(opponent->hp, opponent->maxHP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DOUBLE_BATTLE_TEST("Bad Dreams does not activate if only the partner Pokemon is sleeping")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_DARKRAI);
|
||||
PLAYER(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);}
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN {;}
|
||||
} SCENE {
|
||||
NONE_OF {
|
||||
ABILITY_POPUP(playerLeft, ABILITY_BAD_DREAMS);
|
||||
MESSAGE("Wobbuffet is tormented!");
|
||||
HP_BAR(playerRight);
|
||||
};
|
||||
} THEN {
|
||||
EXPECT_EQ(opponentLeft->hp, opponentLeft->maxHP);
|
||||
EXPECT_EQ(opponentRight->hp, opponentRight->maxHP);
|
||||
EXPECT_EQ(playerRight->hp, playerRight->maxHP);
|
||||
}
|
||||
}
|
||||
|
||||
DOUBLE_BATTLE_TEST("Bad Dreams activates for both sleeping pokemon on the player side")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);}
|
||||
PLAYER(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);}
|
||||
OPPONENT(SPECIES_DARKRAI);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN {;}
|
||||
} SCENE {
|
||||
ABILITY_POPUP(opponentLeft, ABILITY_BAD_DREAMS);
|
||||
MESSAGE("Wobbuffet is tormented!");
|
||||
HP_BAR(playerLeft);
|
||||
MESSAGE("Wobbuffet is tormented!");
|
||||
HP_BAR(playerRight);
|
||||
} THEN {
|
||||
EXPECT_EQ(opponentLeft->hp, opponentLeft->maxHP);
|
||||
EXPECT_EQ(opponentRight->hp, opponentRight->maxHP);
|
||||
EXPECT_EQ(playerLeft->hp, playerLeft->maxHP - playerLeft->maxHP / 8);
|
||||
EXPECT_EQ(playerRight->hp, playerRight->maxHP - playerRight->maxHP / 8);
|
||||
}
|
||||
}
|
||||
|
||||
DOUBLE_BATTLE_TEST("Bad Dreams faints both sleeping Pokemon on player side")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP); HP(1);}
|
||||
PLAYER(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP); HP(1);}
|
||||
PLAYER(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);}
|
||||
PLAYER(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);}
|
||||
OPPONENT(SPECIES_DARKRAI);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN {SEND_OUT(playerLeft, 2); SEND_OUT(playerRight, 3);}
|
||||
} SCENE {
|
||||
ABILITY_POPUP(opponentLeft, ABILITY_BAD_DREAMS);
|
||||
MESSAGE("Wobbuffet is tormented!");
|
||||
HP_BAR(playerLeft);
|
||||
MESSAGE("Wobbuffet fainted!");
|
||||
MESSAGE("Wobbuffet is tormented!");
|
||||
HP_BAR(playerRight);
|
||||
MESSAGE("Wobbuffet fainted!");
|
||||
}
|
||||
}
|
||||
|
||||
DOUBLE_BATTLE_TEST("Bad Dreams faints both sleeping Pokemon on opponent side")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_DARKRAI);
|
||||
PLAYER(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP); HP(1);}
|
||||
OPPONENT(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP); HP(1);}
|
||||
OPPONENT(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);}
|
||||
OPPONENT(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);}
|
||||
} WHEN {
|
||||
TURN {SEND_OUT(opponentLeft, 2); SEND_OUT(opponentRight, 3);}
|
||||
} SCENE {
|
||||
ABILITY_POPUP(playerLeft, ABILITY_BAD_DREAMS);
|
||||
MESSAGE("Foe Wobbuffet is tormented!");
|
||||
HP_BAR(opponentLeft);
|
||||
MESSAGE("Foe Wobbuffet fainted!");
|
||||
MESSAGE("Foe Wobbuffet is tormented!");
|
||||
HP_BAR(opponentRight);
|
||||
MESSAGE("Foe Wobbuffet fainted!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user