Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clear Amulet visual bug + Tests #3074

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -4796,8 +4796,6 @@ BattleScript_PartyHealEnd::
BattleScript_EffectTripleKick::
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
jumpifmove MOVE_TRIPLE_AXEL BS_TripleAxel
addbyte sTRIPLE_KICK_POWER, 10 @ triple kick gets +10 power
goto BattleScript_HitFromAtkString
Expand Down Expand Up @@ -8717,10 +8715,7 @@ BattleScript_IntimidateLoop:
jumpiftargetally BattleScript_IntimidateLoopIncrement
jumpifabsent BS_TARGET, BattleScript_IntimidateLoopIncrement
jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_IntimidateLoopIncrement
jumpifholdeffect BS_TARGET, HOLD_EFFECT_CLEAR_AMULET, BattleScript_IntimidatePrevented_Item
jumpifability BS_TARGET, ABILITY_CLEAR_BODY, BattleScript_IntimidatePrevented
jumpifability BS_TARGET, ABILITY_HYPER_CUTTER, BattleScript_IntimidatePrevented
jumpifability BS_TARGET, ABILITY_WHITE_SMOKE, BattleScript_IntimidatePrevented
.if B_UPDATED_INTIMIDATE >= GEN_8
jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_IntimidatePrevented
jumpifability BS_TARGET, ABILITY_SCRAPPY, BattleScript_IntimidatePrevented
Expand Down Expand Up @@ -8761,7 +8756,6 @@ BattleScript_IntimidateContrary_WontIncrease:
BattleScript_IntimidatePrevented:
call BattleScript_AbilityPopUp
pause B_WAIT_TIME_LONG
BattleScript_IntimidatePrevented_Item:
setbyte gBattleCommunication STAT_ATK
stattextbuffer BS_TARGET
printstring STRINGID_STATWASNOTLOWERED
Expand Down Expand Up @@ -9089,6 +9083,12 @@ BattleScript_AbilityNoStatLoss::
waitmessage B_WAIT_TIME_LONG
return

BattleScript_ItemNoStatLoss::
pause B_WAIT_TIME_SHORT
printstring STRINGID_STATWASNOTLOWERED
waitmessage B_WAIT_TIME_LONG
return

BattleScript_BRNPrevention::
pause B_WAIT_TIME_SHORT
printfromtable gBRNPreventionStringIds
Expand Down
1 change: 1 addition & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ extern const u8 BattleScript_MonMadeMoveUseless[];
extern const u8 BattleScript_FlashFireBoost_PPLoss[];
extern const u8 BattleScript_FlashFireBoost[];
extern const u8 BattleScript_AbilityNoStatLoss[];
extern const u8 BattleScript_ItemNoStatLoss[];
extern const u8 BattleScript_BRNPrevention[];
extern const u8 BattleScript_PRLZPrevention[];
extern const u8 BattleScript_PSNPrevention[];
Expand Down
25 changes: 16 additions & 9 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -11941,10 +11941,17 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
{
BattleScriptPush(BS_ptr);
gBattleScripting.battler = gActiveBattler;
gBattlerAbility = gActiveBattler;
gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss;
gLastUsedAbility = activeBattlerAbility;
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
if (GetBattlerHoldEffect(gActiveBattler, TRUE) == HOLD_EFFECT_CLEAR_AMULET)
{
gBattlescriptCurrInstr = BattleScript_ItemNoStatLoss;
}
else
{
gBattlerAbility = gActiveBattler;
gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss;
gLastUsedAbility = activeBattlerAbility;
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
}
gSpecialStatuses[gActiveBattler].statLowered = TRUE;
}
}
Expand Down Expand Up @@ -12084,15 +12091,15 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
{
gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler);
gProtectStructs[gActiveBattler].statRaised = TRUE;

// check mirror herb
for (index = 0; index < gBattlersCount; index++)
{
if (GetBattlerSide(index) == GetBattlerSide(gActiveBattler))
continue; // Only triggers on opposing side
continue; // Only triggers on opposing side
if (GetBattlerHoldEffect(index, TRUE) == HOLD_EFFECT_MIRROR_HERB
&& gBattleMons[index].statStages[statId] < MAX_STAT_STAGE)
{
{
gProtectStructs[index].eatMirrorHerb = 1;
gTotemBoosts[index].stats |= (1 << (statId - 1)); // -1 to start at atk
gTotemBoosts[index].statChanges[statId - 1] = statValue;
Expand Down Expand Up @@ -16300,7 +16307,7 @@ void BS_CheckParentalBondCounter(void)
void BS_GetBattlerSide(void)
{
NATIVE_ARGS(u8 battler);
gBattleCommunication[0] = GetBattlerSide(GetBattlerForBattleScript(cmd->battler));
gBattleCommunication[0] = GetBattlerSide(GetBattlerForBattleScript(cmd->battler));
gBattlescriptCurrInstr = cmd->nextInstr;
}

Expand All @@ -16326,7 +16333,7 @@ void BS_TrySymbiosis(void)
gBattlescriptCurrInstr = BattleScript_SymbiosisActivates;
return;
}

gBattlescriptCurrInstr = cmd->nextInstr;
}

Expand Down
38 changes: 38 additions & 0 deletions test/ability_clear_body.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "global.h"
#include "test_battle.h"

SINGLE_BATTLE_TEST("Clear Body prevents intimidate")
{
s16 turnOneHit;
s16 turnTwoHit;

GIVEN {
PLAYER(SPECIES_EKANS) { Ability(ABILITY_SHED_SKIN); };
PLAYER(SPECIES_EKANS) { Ability(ABILITY_INTIMIDATE); };
OPPONENT(SPECIES_BELDUM) { Ability(ABILITY_CLEAR_BODY); };
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_TACKLE); }

} SCENE {
HP_BAR(player, captureDamage: &turnOneHit);
ABILITY_POPUP(player, ABILITY_INTIMIDATE);
NONE_OF { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); }
ABILITY_POPUP(opponent, ABILITY_CLEAR_BODY);
MESSAGE("Foe Beldum's Clear Body prevents stat loss!");
HP_BAR(player, captureDamage: &turnTwoHit);
} THEN {
EXPECT_EQ(turnOneHit, turnTwoHit);
}
}
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved

TO_DO_BATTLE_TEST("Clear Body prevents stat stage reduction from moves"); // Growl, Leer, Confide, Fake Tears, Scary Face, Sweet Scent, Sand Attack (Attack, Defense, Sp. Attack, Sp. Defense, Speed, Evasion, Accuracy
TO_DO_BATTLE_TEST("Clear Body prevents Sticky Web");
TO_DO_BATTLE_TEST("Clear Body doesn't prevent stat stage reduction from moves used by the user"); // e.g. Superpower
TO_DO_BATTLE_TEST("Clear Body doesn't prevent Speed reduction from Iron Ball");
TO_DO_BATTLE_TEST("Clear Body doesn't prevent Speed reduction from paralysis");
TO_DO_BATTLE_TEST("Clear Body doesn't prevent Attack reduction from burn");
TO_DO_BATTLE_TEST("Clear Body doesn't prevent receiving negative stat changes from Baton Pass");
TO_DO_BATTLE_TEST("Clear Body doesn't prevent Topsy-Turvy");
TO_DO_BATTLE_TEST("Clear Body doesn't prevent Spectral Thief from resetting positive stat changes");
TO_DO_BATTLE_TEST("Clear Body is ignored by Mold Breaker");
38 changes: 38 additions & 0 deletions test/ability_full_metal_body.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "global.h"
#include "test_battle.h"

SINGLE_BATTLE_TEST("Full Metal Body prevents intimidate")
{
s16 turnOneHit;
s16 turnTwoHit;

GIVEN {
PLAYER(SPECIES_EKANS) { Ability(ABILITY_SHED_SKIN); };
PLAYER(SPECIES_EKANS) { Ability(ABILITY_INTIMIDATE); };
OPPONENT(SPECIES_SOLGALEO) { Ability(ABILITY_FULL_METAL_BODY); };
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_TACKLE); }

} SCENE {
HP_BAR(player, captureDamage: &turnOneHit);
ABILITY_POPUP(player, ABILITY_INTIMIDATE);
NONE_OF { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); }
ABILITY_POPUP(opponent, ABILITY_FULL_METAL_BODY);
MESSAGE("Foe Solgaleo's Full Metal Body prevents stat loss!");
HP_BAR(player, captureDamage: &turnTwoHit);
} THEN {
EXPECT_EQ(turnOneHit, turnTwoHit);
}
}
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved

TO_DO_BATTLE_TEST("Full Metal Body prevents stat stage reduction from moves"); // Growl, Leer, Confide, Fake Tears, Scary Face, Sweet Scent, Sand Attack (Attack, Defense, Sp. Attack, Sp. Defense, Speed, Evasion, Accuracy
TO_DO_BATTLE_TEST("Full Metal Body prevents Sticky Web");
TO_DO_BATTLE_TEST("Full Metal Body doesn't prevent stat stage reduction from moves used by the user"); // e.g. Superpower
TO_DO_BATTLE_TEST("Full Metal Body doesn't prevent Speed reduction from Iron Ball");
TO_DO_BATTLE_TEST("Full Metal Body doesn't prevent Speed reduction from paralysis");
TO_DO_BATTLE_TEST("Full Metal Body doesn't prevent Attack reduction from burn");
TO_DO_BATTLE_TEST("Full Metal Body doesn't prevent receiving negative stat changes from Baton Pass");
TO_DO_BATTLE_TEST("Full Metal Body doesn't prevent Topsy-Turvy");
TO_DO_BATTLE_TEST("Full Metal Body doesn't prevent Spectral Thief from resetting positive stat changes");
TO_DO_BATTLE_TEST("Full Metal Body is ignored by Mold Breaker");
35 changes: 35 additions & 0 deletions test/ability_hyper_cutter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "global.h"
#include "test_battle.h"

SINGLE_BATTLE_TEST("Hyper Cutter prevents intimidate")
{
s16 turnOneHit;
s16 turnTwoHit;

GIVEN {
PLAYER(SPECIES_EKANS) { Ability(ABILITY_SHED_SKIN); };
PLAYER(SPECIES_EKANS) { Ability(ABILITY_INTIMIDATE); };
OPPONENT(SPECIES_KRABBY) { Ability(ABILITY_HYPER_CUTTER); };
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_TACKLE); }

} SCENE {
HP_BAR(player, captureDamage: &turnOneHit);
ABILITY_POPUP(player, ABILITY_INTIMIDATE);
NONE_OF { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); }
ABILITY_POPUP(opponent, ABILITY_HYPER_CUTTER);
MESSAGE("Foe Krabby's Attack was not lowered!");
HP_BAR(player, captureDamage: &turnTwoHit);
} THEN {
EXPECT_EQ(turnOneHit, turnTwoHit);
}
}
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved

TO_DO_BATTLE_TEST("Hyper Cutter prevents Attack stage reduction from moves"); // Growl
TO_DO_BATTLE_TEST("Hyper Cutter doesn't prevent Attack stage reduction from moves used by the user"); // e.g. Superpower
TO_DO_BATTLE_TEST("Hyper Cutter doesn't prevent Attack reduction from burn");
TO_DO_BATTLE_TEST("Hyper Cutter doesn't prevent receiving negative Attack stage changes from Baton Pass");
TO_DO_BATTLE_TEST("Hyper Cutter doesn't prevent Topsy-Turvy");
TO_DO_BATTLE_TEST("Hyper Cutter doesn't prevent Spectral Thief from resetting positive Attack stage changes");
TO_DO_BATTLE_TEST("Hyper Cutter is ignored by Mold Breaker");
57 changes: 57 additions & 0 deletions test/ability_inner_focus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "global.h"
#include "test_battle.h"

SINGLE_BATTLE_TEST("Inner Focus prevents intimidate")
{
s16 turnOneHit;
s16 turnTwoHit;

GIVEN {
ASSUME(B_UPDATED_INTIMIDATE >= GEN_8);
PLAYER(SPECIES_EKANS) { Ability(ABILITY_SHED_SKIN); };
PLAYER(SPECIES_EKANS) { Ability(ABILITY_INTIMIDATE); };
OPPONENT(SPECIES_ZUBAT) { Ability(ABILITY_INNER_FOCUS); };
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_TACKLE); }

} SCENE {
HP_BAR(player, captureDamage: &turnOneHit);
ABILITY_POPUP(player, ABILITY_INTIMIDATE);
NONE_OF { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); }
ABILITY_POPUP(opponent, ABILITY_INNER_FOCUS);
MESSAGE("Foe Zubat's Attack was not lowered!");
HP_BAR(player, captureDamage: &turnTwoHit);
} THEN {
EXPECT_EQ(turnOneHit, turnTwoHit);
}
}
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved

SINGLE_BATTLE_TEST("Inner Focus prevents flinching")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_ZUBAT) { Ability(ABILITY_INNER_FOCUS); };
} WHEN {
TURN { MOVE(player, MOVE_FAKE_OUT);
MOVE(opponent, MOVE_TACKLE);
}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FAKE_OUT, player);
NONE_OF { MESSAGE("Foe Zubat flinched!"); }
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
}
}

SINGLE_BATTLE_TEST("Inner Focus is ignored by Mold Breaker")
{
GIVEN {
PLAYER(SPECIES_PINSIR) { Ability(ABILITY_MOLD_BREAKER); };
OPPONENT(SPECIES_ZUBAT) { Ability(ABILITY_INNER_FOCUS); };
} WHEN {
TURN { MOVE(player, MOVE_FAKE_OUT); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FAKE_OUT, player);
MESSAGE("Foe Zubat flinched!");
}
}
119 changes: 119 additions & 0 deletions test/ability_own_tempo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include "global.h"
#include "test_battle.h"

SINGLE_BATTLE_TEST("Own Tempo prevents intimidate")
{
s16 turnOneHit;
s16 turnTwoHit;

GIVEN {
ASSUME(B_UPDATED_INTIMIDATE >= GEN_8);
PLAYER(SPECIES_EKANS) { Ability(ABILITY_SHED_SKIN); };
PLAYER(SPECIES_EKANS) { Ability(ABILITY_INTIMIDATE); };
OPPONENT(SPECIES_SLOWPOKE) { Ability(ABILITY_OWN_TEMPO); };
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_TACKLE); }

} SCENE {
HP_BAR(player, captureDamage: &turnOneHit);
ABILITY_POPUP(player, ABILITY_INTIMIDATE);
NONE_OF { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); }
ABILITY_POPUP(opponent, ABILITY_OWN_TEMPO);
MESSAGE("Foe Slowpoke's Attack was not lowered!");
HP_BAR(player, captureDamage: &turnTwoHit);
} THEN {
EXPECT_EQ(turnOneHit, turnTwoHit);
}
}
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved

SINGLE_BATTLE_TEST("Own Tempo prevents confusion from moves by the opponent")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_CONFUSE_RAY].effect == EFFECT_CONFUSE);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_SLOWPOKE) { Ability(ABILITY_OWN_TEMPO); };
} WHEN {
TURN { MOVE(player, MOVE_CONFUSE_RAY); }
} SCENE {
ABILITY_POPUP(opponent, ABILITY_OWN_TEMPO);
MESSAGE("Foe Slowpoke's Own Tempo prevents confusion!");
}
}

SINGLE_BATTLE_TEST("Own Tempo prevents confusion from moves by the user")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_PETAL_DANCE].effect == EFFECT_RAMPAGE);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_SLOWPOKE) { Ability(ABILITY_OWN_TEMPO); };
} WHEN {
TURN { MOVE(opponent, MOVE_PETAL_DANCE); }
TURN { MOVE(opponent, MOVE_PETAL_DANCE); }
TURN { MOVE(opponent, MOVE_PETAL_DANCE); }
TURN { MOVE(opponent, MOVE_PETAL_DANCE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_PETAL_DANCE, opponent);
ANIMATION(ANIM_TYPE_MOVE, MOVE_PETAL_DANCE, opponent);
ANIMATION(ANIM_TYPE_MOVE, MOVE_PETAL_DANCE, opponent);
ANIMATION(ANIM_TYPE_MOVE, MOVE_PETAL_DANCE, opponent);
NONE_OF { MESSAGE("Foe Slowpoke became confused due to fatigue!"); }
}
}

SINGLE_BATTLE_TEST("Own Tempo cures confusion obtained from an opponent with Mold Breaker")
{
KNOWN_FAILING;
GIVEN {
ASSUME(gBattleMoves[MOVE_CONFUSE_RAY].effect == EFFECT_CONFUSE);
PLAYER(SPECIES_PINSIR) { Ability(ABILITY_MOLD_BREAKER); };
OPPONENT(SPECIES_SLOWPOKE) { Ability(ABILITY_OWN_TEMPO); };
} WHEN {
TURN { MOVE(player, MOVE_CONFUSE_RAY); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_CONFUSE_RAY, player);
MESSAGE("Foe Slowpoke became confused!");
NONE_OF {
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_CONFUSION, opponent);
}
ABILITY_POPUP(opponent, ABILITY_OWN_TEMPO);
MESSAGE("Foe Slowpoke's Own Tempo cured its confusion problem!");
}
}

SINGLE_BATTLE_TEST("Own Tempo cures confusion if it's obtained via Skill Swap")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_CONFUSE_RAY].effect == EFFECT_CONFUSE);
ASSUME(gBattleMoves[MOVE_SKILL_SWAP].effect == EFFECT_SKILL_SWAP);
PLAYER(SPECIES_SLOWPOKE) { Ability(ABILITY_OWN_TEMPO); };
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_CONFUSE_RAY); }
TURN { MOVE(player, MOVE_SKILL_SWAP);
MOVE(opponent, MOVE_TACKLE);
}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_CONFUSE_RAY, player);
MESSAGE("Foe Wobbuffet became confused!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_SKILL_SWAP, player);
ABILITY_POPUP(opponent, ABILITY_OWN_TEMPO);
MESSAGE("Foe Wobbuffet's Own Tempo cured its confusion problem!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
}
}

SINGLE_BATTLE_TEST("Own Tempo prevents confusion from items")
{
GIVEN {
ASSUME(gItems[ITEM_BERSERK_GENE].holdEffect == HOLD_EFFECT_BERSERK_GENE);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_SLOWPOKE) { Ability(ABILITY_OWN_TEMPO); Item(ITEM_BERSERK_GENE); };
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
ABILITY_POPUP(opponent, ABILITY_OWN_TEMPO);
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
}
}
Loading