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

Gen 9 configs for Protean/Libero, Intrepid Sword and Dauntless Sword #3614

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct DisableStruct
u8 steelSurgeDone:1;
u8 weatherAbilityDone:1;
u8 terrainAbilityDone:1;
u8 usedProteanLibero:1;
};

struct ProtectStruct
Expand Down Expand Up @@ -732,6 +733,8 @@ struct BattleStruct
bool8 transformZeroToHero[PARTY_SIZE][NUM_BATTLE_SIDES];
u8 pledgeMove:1;
bool8 isSkyBattle:1;
bool8 intrepidSwordBoost[PARTY_SIZE][NUM_BATTLE_SIDES];
bool8 dauntlessShieldBoost[PARTY_SIZE][NUM_BATTLE_SIDES];
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
};

// The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider,
Expand Down
3 changes: 3 additions & 0 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
#define B_TRANSISTOR_BOOST GEN_LATEST // In Gen9+, Transistor will only boost Electric-type moves by 1.3x as opposed to 1.5x.
#define B_ILLUMINATE_EFFECT GEN_LATEST // In Gen9+, Illuminate prevents accuracy reductions and ignores the target's evasion.
#define B_WEAK_ARMOR_SPEED GEN_LATEST // In Gen7+, Weak Armor raises Speed by 2 stages instead of 1 when hit by a physical move.
#define B_PROTEAN_LIBERO GEN_LATEST // In Gen7+, Weak Armor raises Speed by 2 stages instead of 1 when hit by a physical move.
#define B_INTREPID_SWORD GEN_LATEST // In Gen9+, Intrepid Sword raises Attack by one stage only once per Battle.
#define B_DAUNTLESS_SHIELD GEN_LATEST // In Gen9+, Dauntless Shield raises Defense by one stage only once per Battle.

// Item settings
#define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore HP activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn.
Expand Down
3 changes: 3 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ static bool32 TryAegiFormChange(void)
bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType)
{
if ((ability == ABILITY_PROTEAN || ability == ABILITY_LIBERO)
&& !gDisableStructs[gBattlerAttacker].usedProteanLibero
&& (gBattleMons[battler].type1 != moveType || gBattleMons[battler].type2 != moveType
|| (gBattleMons[battler].type3 != moveType && gBattleMons[battler].type3 != TYPE_MYSTERY))
&& move != MOVE_STRUGGLE)
Expand Down Expand Up @@ -1326,6 +1327,8 @@ static void Cmd_attackcanceler(void)
// Check Protean activation.
if (ProteanTryChangeType(gBattlerAttacker, attackerAbility, gCurrentMove, moveType))
{
if (B_PROTEAN_LIBERO == GEN_9)
gDisableStructs[gBattlerAttacker].usedProteanLibero = TRUE;
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType);
gBattlerAbility = gBattlerAttacker;
BattleScriptPushCursor();
Expand Down
14 changes: 10 additions & 4 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -4706,20 +4706,26 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
}
break;
case ABILITY_INTREPID_SWORD:
if (!gSpecialStatuses[battler].switchInAbilityDone && CompareStat(battler, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN))
if (!gSpecialStatuses[battler].switchInAbilityDone && CompareStat(battler, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)
&& !gBattleStruct->intrepidSwordBoost[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)])
{
gBattlerAttacker = battler;
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
if (B_INTREPID_SWORD == GEN_9)
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
gBattleStruct->intrepidSwordBoost[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)] = TRUE;
SET_STATCHANGER(STAT_ATK, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
effect++;
}
break;
case ABILITY_DAUNTLESS_SHIELD:
if (!gSpecialStatuses[battler].switchInAbilityDone && CompareStat(battler, STAT_DEF, MAX_STAT_STAGE, CMP_LESS_THAN))
if (!gSpecialStatuses[battler].switchInAbilityDone && CompareStat(battler, STAT_DEF, MAX_STAT_STAGE, CMP_LESS_THAN)
&& !gBattleStruct->dauntlessShieldBoost[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)])
{
gBattlerAttacker = battler;
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
if (B_DAUNTLESS_SHIELD == GEN_9)
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
gBattleStruct->dauntlessShieldBoost[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)] = TRUE;
SET_STATCHANGER(STAT_DEF, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
effect++;
Expand Down
47 changes: 47 additions & 0 deletions test/battle/ability/dauntless_shield.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(P_GEN_8_POKEMON == TRUE);
ASSUME(B_PROTEAN_LIBERO == GEN_9);
}

SINGLE_BATTLE_TEST("Dauntless Shield raises Attack by one stage")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_ZAMAZENTA) { Ability(ABILITY_DAUNTLESS_SHIELD); }
} WHEN {
TURN { }
} SCENE {
ABILITY_POPUP(opponent, ABILITY_DAUNTLESS_SHIELD);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
MESSAGE("Foe Zamazenta's Dauntless Shield raised its Defense!");
} THEN {
EXPECT_EQ(opponent->statStages[STAT_DEF], DEFAULT_STAT_STAGE + 1);
}
}

SINGLE_BATTLE_TEST("Dauntless Shield raises Attack by one stage only once per battle")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_ZAMAZENTA) { Ability(ABILITY_DAUNTLESS_SHIELD); }
OPPONENT(SPECIES_WYNAUT);
} WHEN {
TURN { SWITCH(opponent, 1); }
TURN { SWITCH(opponent, 0); }
} SCENE {
ABILITY_POPUP(opponent, ABILITY_DAUNTLESS_SHIELD);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
MESSAGE("Foe Zamazenta's Dauntless Shield raised its Defense!");
NONE_OF {
ABILITY_POPUP(opponent, ABILITY_DAUNTLESS_SHIELD);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
MESSAGE("Foe Zamazenta's Dauntless Shield raised its Defense!");
}
} THEN {
EXPECT_EQ(opponent->statStages[STAT_DEF], DEFAULT_STAT_STAGE);
}
}
47 changes: 47 additions & 0 deletions test/battle/ability/intrepid_sword.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(P_GEN_8_POKEMON == TRUE);
ASSUME(B_INTREPID_SWORD == GEN_9);
}

SINGLE_BATTLE_TEST("Intrepid Sword raises Attack by one stage")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_ZACIAN) { Ability(ABILITY_INTREPID_SWORD); }
} WHEN {
TURN { }
} SCENE {
ABILITY_POPUP(opponent, ABILITY_INTREPID_SWORD);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
MESSAGE("Foe Zacian's Intrepid Sword raised its Attack!");
} THEN {
EXPECT_EQ(opponent->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 1);
}
}

SINGLE_BATTLE_TEST("Intrepid Sword raises Attack by one stage only once per battle")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_ZACIAN) { Ability(ABILITY_INTREPID_SWORD); }
OPPONENT(SPECIES_WYNAUT);
} WHEN {
TURN { SWITCH(opponent, 1); }
TURN { SWITCH(opponent, 0); }
} SCENE {
ABILITY_POPUP(opponent, ABILITY_INTREPID_SWORD);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
MESSAGE("Foe Zacian's Intrepid Sword raised its Attack!");
NONE_OF {
ABILITY_POPUP(opponent, ABILITY_INTREPID_SWORD);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
MESSAGE("Foe Zacian's Intrepid Sword raised its Attack!");
}
} THEN {
EXPECT_EQ(opponent->statStages[STAT_ATK], DEFAULT_STAT_STAGE);
}
}
34 changes: 34 additions & 0 deletions test/battle/ability/protean.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(B_PROTEAN_LIBERO == GEN_9);
}

SINGLE_BATTLE_TEST("Protean changes the type of the user only once per switch in")
{
GIVEN {
PLAYER(SPECIES_REGIROCK);
OPPONENT(SPECIES_KECLEON) { Ability(ABILITY_PROTEAN); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_WATER_GUN); }
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { SWITCH(opponent, 1); }
TURN { SWITCH(opponent, 0); }
TURN { MOVE(opponent, MOVE_WATER_GUN); }
} SCENE {
ABILITY_POPUP(opponent, ABILITY_PROTEAN);
MESSAGE("Foe Kecleon transformed into the Water type!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_WATER_GUN, opponent);
NONE_OF {
ABILITY_POPUP(opponent, ABILITY_PROTEAN);
MESSAGE("Foe Kecleon transformed into the Normal type!");
}
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
ABILITY_POPUP(opponent, ABILITY_PROTEAN);
MESSAGE("Foe Kecleon transformed into the Water type!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_WATER_GUN, opponent);
}
}
Loading