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

Destiny Bond fails on repeated use in Gen 7+ #5652

Open
wants to merge 8 commits into
base: upcoming
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,9 @@
.4byte \failInstr
.endm

.macro setdestinybond
.macro trysetdestinybond failInstr:req
.byte 0xaa
.4byte \failInstr
.endm

.macro trysetdestinybondtohappen
Expand Down
2 changes: 1 addition & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -4063,7 +4063,7 @@ BattleScript_EffectDestinyBond::
attackcanceler
attackstring
ppreduce
setdestinybond
trysetdestinybond BattleScript_ButItFailed
attackanimation
waitanimation
printstring STRINGID_PKMNTRYINGTOTAKEFOE
Expand Down
1 change: 1 addition & 0 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,6 @@ void TryActivateSleepClause(u32 battler, u32 indexInParty);
void TryDeactivateSleepClause(u32 battlerSide, u32 indexInParty);
bool8 IsSleepClauseActiveForSide(u32 battlerSide);
bool32 IsSleepClauseEnabled();
u32 DoesDestinyBondFail(u32 battler);

#endif // GUARD_BATTLE_UTIL_H
1 change: 1 addition & 0 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
#define B_POWDER_RAIN GEN_LATEST // In Gen7+, Powder doesn't damage the user of a Fire type move in heavy rain.
#define B_AFTER_YOU_TURN_ORDER GEN_LATEST // In Gen8+, After You doesn't fail if the turn order wouldn't change after use.
#define B_QUASH_TURN_ORDER GEN_LATEST // In Gen8+, Quash-affected battlers move according to speed order. Before Gen8, Quash-affected battlers move in the order they were affected by Quash.
#define B_DESTINY_BOND_FAIL GEN_LATEST // In Gen7+, Destiny Bond fails if used repeatedly.

// Ability settings
#define B_ABILITY_WEATHER GEN_LATEST // In Gen6+, ability-induced weather lasts 5 turns. Before, it lasted until the battle ended or until it was changed by a move or a different weather-affecting ability.
Expand Down
2 changes: 2 additions & 0 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-10);
break;
case EFFECT_DESTINY_BOND:
if (DoesDestinyBondFail(battlerAtk))
ADJUST_SCORE(-10);
if (gBattleMons[battlerDef].status2 & STATUS2_DESTINY_BOND)
ADJUST_SCORE(-10);
else if (GetActiveGimmick(battlerDef) == GIMMICK_DYNAMAX)
Expand Down
20 changes: 13 additions & 7 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static void Cmd_settypetorandomresistance(void);
static void Cmd_setalwayshitflag(void);
static void Cmd_copymovepermanently(void);
static void Cmd_trychoosesleeptalkmove(void);
static void Cmd_setdestinybond(void);
static void Cmd_trysetdestinybond(void);
static void Cmd_trysetdestinybondtohappen(void);
static void Cmd_settailwind(void);
static void Cmd_tryspiteppreduce(void);
Expand Down Expand Up @@ -767,7 +767,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_setalwayshitflag, //0xA7
Cmd_copymovepermanently, //0xA8
Cmd_trychoosesleeptalkmove, //0xA9
Cmd_setdestinybond, //0xAA
Cmd_trysetdestinybond, //0xAA
Cmd_trysetdestinybondtohappen, //0xAB
Cmd_settailwind, //0xAC
Cmd_tryspiteppreduce, //0xAD
Expand Down Expand Up @@ -13145,12 +13145,18 @@ static void Cmd_trychoosesleeptalkmove(void)
}
}

static void Cmd_setdestinybond(void)
static void Cmd_trysetdestinybond(void)
{
CMD_ARGS();

gBattleMons[gBattlerAttacker].status2 |= STATUS2_DESTINY_BOND;
gBattlescriptCurrInstr = cmd->nextInstr;
CMD_ARGS(const u8 *failInstr);
if (DoesDestinyBondFail(gBattlerAttacker))
{
gBattlescriptCurrInstr = cmd->failInstr;
}
else
{
gBattleMons[gBattlerAttacker].status2 |= STATUS2_DESTINY_BOND;
gBattlescriptCurrInstr = cmd->nextInstr;
}
}

static void TrySetDestinyBondToHappen(void)
Expand Down
9 changes: 9 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -12040,3 +12040,12 @@ bool32 IsSleepClauseEnabled()
return TRUE;
return FALSE;
}

bool32 DoesDestinyBondFail(u32 battler)
{
if (B_DESTINY_BOND_FAIL >= GEN_7
&& gMovesInfo[gLastResultingMoves[battler]].effect == EFFECT_DESTINY_BOND
&& !(gBattleStruct->lastMoveFailed & (1u << battler)))
return TRUE;
return FALSE;
}
62 changes: 62 additions & 0 deletions test/battle/move_effect/destiny_bond.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gMovesInfo[MOVE_DESTINY_BOND].effect == EFFECT_DESTINY_BOND);
}

SINGLE_BATTLE_TEST("Destiny Bond faints the opposing mon if it fainted from the attack")
{
GIVEN {
Expand All @@ -15,3 +20,60 @@ SINGLE_BATTLE_TEST("Destiny Bond faints the opposing mon if it fainted from the
MESSAGE("The opposing Wobbuffet fainted!");
}
}

SINGLE_BATTLE_TEST("Destiny Bond fails if used sequentially in Gen 7+")
{
GIVEN {
ASSUME(B_DESTINY_BOND_FAIL >= GEN_7);
PLAYER(SPECIES_ZIGZAGOON);
OPPONENT(SPECIES_ZIGZAGOON);
OPPONENT(SPECIES_ZIGZAGOON);
} WHEN {
TURN { MOVE(player, MOVE_DESTINY_BOND); }
TURN { MOVE(player, MOVE_DESTINY_BOND); SWITCH(opponent, 1); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DESTINY_BOND, player);
MESSAGE("2 sent out Zigzagoon!");
NOT { ANIMATION(ANIM_TYPE_MOVE, MOVE_DESTINY_BOND, player); }
MESSAGE("But it failed!");
}
}

SINGLE_BATTLE_TEST("Destiny Bond does not fail if used repeatedly separated by other moves in Gen 7+")
{
GIVEN {
ASSUME(B_DESTINY_BOND_FAIL >= GEN_7);
PLAYER(SPECIES_ZIGZAGOON);
OPPONENT(SPECIES_ZIGZAGOON);
OPPONENT(SPECIES_ZIGZAGOON);
} WHEN {
TURN { MOVE(player, MOVE_DESTINY_BOND); }
TURN { MOVE(player, MOVE_GROWL); SWITCH(opponent, 1); }
TURN { MOVE(player, MOVE_DESTINY_BOND); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DESTINY_BOND, player);
MESSAGE("2 sent out Zigzagoon!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_DESTINY_BOND, player);
NOT { MESSAGE("But it failed!"); }
}
}

SINGLE_BATTLE_TEST("Destiny Bond does not fail if used after failing in Gen 7+")
{
GIVEN {
ASSUME(B_DESTINY_BOND_FAIL >= GEN_7);
PLAYER(SPECIES_ZIGZAGOON);
OPPONENT(SPECIES_ZIGZAGOON);
OPPONENT(SPECIES_ZIGZAGOON);
} WHEN {
TURN { MOVE(player, MOVE_DESTINY_BOND); }
TURN { MOVE(player, MOVE_DESTINY_BOND); SWITCH(opponent, 1); }
TURN { MOVE(player, MOVE_DESTINY_BOND); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DESTINY_BOND, player);
MESSAGE("2 sent out Zigzagoon!");
NOT { ANIMATION(ANIM_TYPE_MOVE, MOVE_DESTINY_BOND, player); }
MESSAGE("But it failed!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_DESTINY_BOND, player);
}
}
Loading