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 Kee Berry and Custap Berry + Tests #3409

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4964,6 +4964,7 @@ static void TurnValuesCleanUp(bool8 var0)
gProtectStructs[i].kingsShielded = FALSE;
gProtectStructs[i].banefulBunkered = FALSE;
gProtectStructs[i].quash = FALSE;
gProtectStructs[i].usedCustapBerry = FALSE;
}
else
{
Expand Down Expand Up @@ -5130,7 +5131,6 @@ static void CheckQuickClaw_CustapBerryActivation(void)
{
if (gProtectStructs[battler].usedCustapBerry)
{
gProtectStructs[battler].usedCustapBerry = FALSE;
gLastUsedItem = gBattleMons[battler].item;
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem);
if (GetBattlerHoldEffect(battler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY)
Expand Down
3 changes: 2 additions & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -6625,6 +6625,7 @@ static u8 DamagedStatBoostBerryEffect(u32 battler, u8 statId, u8 split)
else
SET_STATCHANGER(statId, 1, FALSE);

gBattleScripting.battler = battler;
gBattleScripting.animArg1 = 14 + statId;
gBattleScripting.animArg2 = 0;
BattleScriptPushCursor();
Expand Down Expand Up @@ -11206,7 +11207,7 @@ bool32 IsGen6ExpShareEnabled(void)


u8 GetBattlerType(u32 battler, u8 typeIndex)
{
{
u16 types[3] = {0};
types[0] = gBattleMons[battler].type1;
types[1] = gBattleMons[battler].type2;
Expand Down
71 changes: 71 additions & 0 deletions test/battle/hold_effect/attack_up.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gItems[ITEM_LIECHI_BERRY].holdEffect == HOLD_EFFECT_ATTACK_UP);
ASSUME(gBattleMoves[MOVE_DRAGON_RAGE].effect == EFFECT_DRAGON_RAGE);
}

SINGLE_BATTLE_TEST("Liechi Berry raises the holder's Attack by one stage when HP drops to 1/4 or below")
{
u32 move;

PARAMETRIZE { move = MOVE_TACKLE; }
PARAMETRIZE { move = MOVE_DRAGON_RAGE; }

GIVEN {
PLAYER(SPECIES_WOBBUFFET) { MaxHP(160); HP(80); Item(ITEM_LIECHI_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, move); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, move, opponent);
if (move == MOVE_TACKLE)
{
NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
NOT MESSAGE("Using Liechi Berry, the Attack of Wobbuffet rose!");
}
else
{
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Using Liechi Berry, the Attack of Wobbuffet rose!");
}
} THEN {
if (move == MOVE_DRAGON_RAGE)
EXPECT_EQ(player->statStages[STAT_ATK], 7);
}
}

SINGLE_BATTLE_TEST("Liechi Berry raises Attack by one stage when HP drops to 1/2 or below if holder has Gluttony")
{
GIVEN {
PLAYER(SPECIES_BELLSPROUT) { MaxHP(80); HP(80); Ability(ABILITY_GLUTTONY); Item(ITEM_LIECHI_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_DRAGON_RAGE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_RAGE, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Using Liechi Berry, the Attack of Bellsprout rose!");
} THEN {
EXPECT_EQ(player->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 1);
}
}

SINGLE_BATTLE_TEST("Liechi Berry raises Attack by one stage when HP drops to 1/4 or below if holder has Ripen")
{
GIVEN {
ASSUME(P_GEN_8_POKEMON == TRUE);
PLAYER(SPECIES_APPLIN) { MaxHP(160); HP(80); Ability(ABILITY_RIPEN); Item(ITEM_LIECHI_BERRY); }
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_DRAGON_RAGE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_RAGE, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Using Liechi Berry, the Attack of Applin sharply rose!");
} THEN {
EXPECT_EQ(player->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 2);
}
}
67 changes: 67 additions & 0 deletions test/battle/hold_effect/critical_hit_up.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gItems[ITEM_LANSAT_BERRY].holdEffect == HOLD_EFFECT_CRITICAL_UP);
ASSUME(gBattleMoves[MOVE_DRAGON_RAGE].effect == EFFECT_DRAGON_RAGE);
}

SINGLE_BATTLE_TEST("Lansat Berry raises the holder's critical-hit-ratio by two stages when HP drops to 1/4 or below")
{
u32 move;

PARAMETRIZE { move = MOVE_TACKLE; }
PARAMETRIZE { move = MOVE_DRAGON_RAGE; }

GIVEN {
PLAYER(SPECIES_WOBBUFFET) { MaxHP(160); HP(80); Item(ITEM_LANSAT_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, move); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, move, opponent);
if (move == MOVE_TACKLE)
{
NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
NOT MESSAGE("Wobbuffet used Lansat Berry to get pumped!");
}
else
{
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet used Lansat Berry to get pumped!");
}
}
}

SINGLE_BATTLE_TEST("Lansat Berry raises the holder's critical-hit-ratio by two stages when HP drops to 1/2 or below")
{
GIVEN {
PLAYER(SPECIES_BELLSPROUT) { MaxHP(80); HP(80); Ability(ABILITY_GLUTTONY); Item(ITEM_LANSAT_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_DRAGON_RAGE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_RAGE, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Bellsprout used Lansat Berry to get pumped!");
}
}

SINGLE_BATTLE_TEST("Lansat Berry raises the holder's critical-hit-ratio by two stages when HP drops to 1/4 or below")
{
PASSES_RANDOMLY(1, 2, RNG_CRITICAL_HIT);
GIVEN {
ASSUME(gBattleMoves[MOVE_TACKLE].highCritRatio == FALSE);
PLAYER(SPECIES_WOBBUFFET) { MaxHP(160); HP(80); Item(ITEM_LANSAT_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_DRAGON_RAGE); MOVE(player, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_RAGE, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet used Lansat Berry to get pumped!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
MESSAGE("A critical hit!");
}
}
37 changes: 37 additions & 0 deletions test/battle/hold_effect/custap_berry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gItems[ITEM_CUSTAP_BERRY].holdEffect == HOLD_EFFECT_CUSTAP_BERRY);
}

SINGLE_BATTLE_TEST("Custap Berry allows the holder to move first in its priority bracket when HP is below 1/4")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Speed(1); MaxHP(160); HP(40); Item(ITEM_CUSTAP_BERRY); }
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); }
} WHEN {
TURN { MOVE(player, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet can act faster, thanks to Custap Berry!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
}
}

SINGLE_BATTLE_TEST("Custap Berry allows the holder to move first in its priority bracket when HP is below 1/2. If the holder has Gluttony")
{
GIVEN {
PLAYER(SPECIES_BELLSPROUT) { Speed(1); MaxHP(160); HP(80); Ability(ABILITY_GLUTTONY); Item(ITEM_CUSTAP_BERRY); }
OPPONENT(SPECIES_WOBBUFFET) { Speed(2); }
} WHEN {
TURN { MOVE(player, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Bellsprout can act faster, thanks to Custap Berry!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
}
}
71 changes: 71 additions & 0 deletions test/battle/hold_effect/defense_up.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gItems[ITEM_GANLON_BERRY].holdEffect == HOLD_EFFECT_DEFENSE_UP);
ASSUME(gBattleMoves[MOVE_DRAGON_RAGE].effect == EFFECT_DRAGON_RAGE);
}

SINGLE_BATTLE_TEST("Ganlon Berry raises the holder's Defense by one stage when HP drops to 1/4 or below")
{
u32 move;

PARAMETRIZE { move = MOVE_TACKLE; }
PARAMETRIZE { move = MOVE_DRAGON_RAGE; }

GIVEN {
PLAYER(SPECIES_WOBBUFFET) { MaxHP(160); HP(80); Item(ITEM_GANLON_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, move); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, move, opponent);
if (move == MOVE_TACKLE)
{
NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
NOT MESSAGE("Using Ganlon Berry, the Defense of Wobbuffet rose!");
}
else
{
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Using Ganlon Berry, the Defense of Wobbuffet rose!");
}
} THEN {
if (move == MOVE_DRAGON_RAGE)
EXPECT_EQ(player->statStages[STAT_DEF], DEFAULT_STAT_STAGE + 1);
}
}

SINGLE_BATTLE_TEST("Ganlon Berry raises Defense by one stage when HP drops to 1/2 or below if holder has Gluttony")
{
GIVEN {
PLAYER(SPECIES_BELLSPROUT) { MaxHP(80); HP(80); Ability(ABILITY_GLUTTONY); Item(ITEM_GANLON_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_DRAGON_RAGE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_RAGE, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Using Ganlon Berry, the Defense of Bellsprout rose!");
} THEN {
EXPECT_EQ(player->statStages[STAT_DEF], DEFAULT_STAT_STAGE + 1);
}
}

SINGLE_BATTLE_TEST("Ganlon Berry raises Defense by one stage when HP drops to 1/4 or below if holder has Ripen")
{
GIVEN {
ASSUME(P_GEN_8_POKEMON == TRUE);
PLAYER(SPECIES_APPLIN) { MaxHP(160); HP(80); Ability(ABILITY_RIPEN); Item(ITEM_GANLON_BERRY); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_DRAGON_RAGE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_RAGE, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Using Ganlon Berry, the Defense of Applin sharply rose!");
} THEN {
EXPECT_EQ(player->statStages[STAT_DEF], DEFAULT_STAT_STAGE + 2);
}
}
44 changes: 44 additions & 0 deletions test/battle/hold_effect/jaboca_berry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gItems[ITEM_JABOCA_BERRY].holdEffect == HOLD_EFFECT_JABOCA_BERRY);
}

SINGLE_BATTLE_TEST("Jaboca Berry causes the attacker to lose 1/8 of its max HP if a physical move was used")
{
s16 damage;

GIVEN {
ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_JABOCA_BERRY); }
} WHEN {
TURN { MOVE(player, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
HP_BAR(opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
HP_BAR(player, captureDamage: &damage);
MESSAGE("Wobbuffet was hurt by Foe Wobbuffet's Jaboca Berry!");
} THEN {
EXPECT_EQ(player->maxHP / 8, damage);
}
}

SINGLE_BATTLE_TEST("Jaboca Berry is not triggered by a special move")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_SWIFT].split == SPLIT_SPECIAL);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_JABOCA_BERRY); }
} WHEN {
TURN { MOVE(player, MOVE_SWIFT); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SWIFT, player);
HP_BAR(opponent);
NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
NOT MESSAGE("Wobbuffet was hurt by Foe Wobbuffet's Jaboca Berry!");
}
}
60 changes: 60 additions & 0 deletions test/battle/hold_effect/kee_berry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gItems[ITEM_KEE_BERRY].holdEffect == HOLD_EFFECT_KEE_BERRY);
}

SINGLE_BATTLE_TEST("Kee Berry raises the holder's Defense by one stage when hit by a physical move")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_KEE_BERRY); }
} WHEN {
TURN { MOVE(player, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
HP_BAR(opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
MESSAGE("Using Kee Berry, the Defense of Foe Wobbuffet rose!");
} THEN {
EXPECT_EQ(opponent->statStages[STAT_DEF], DEFAULT_STAT_STAGE + 1);
}
}

SINGLE_BATTLE_TEST("Kee Berry raises the holder's Defense by two stages with Ripen when hit by a physical move")
{
GIVEN {
ASSUME(P_GEN_8_POKEMON == TRUE);
ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_APPLIN) { Item(ITEM_KEE_BERRY); Ability(ABILITY_RIPEN); }
} WHEN {
TURN { MOVE(player, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
HP_BAR(opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
MESSAGE("Using Kee Berry, the Defense of Foe Applin sharply rose!");
} THEN {
EXPECT_EQ(opponent->statStages[STAT_DEF], DEFAULT_STAT_STAGE + 2);
}
}

SINGLE_BATTLE_TEST("Kee Berry is not triggered by a special move")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_SWIFT].split == SPLIT_SPECIAL);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_KEE_BERRY); }
} WHEN {
TURN { MOVE(player, MOVE_SWIFT); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SWIFT, player);
HP_BAR(opponent);
NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
NOT MESSAGE("Using Kee Berry, the Defense of Foe Wobbuffet rose!");
}
}
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading