add fail ptr arg to JumpIfMoveFailed, fix tryworryseed (#6925)

Co-authored-by: ghoulslash <pokevoyager0@gmail.com>
This commit is contained in:
ghoulslash 2025-05-20 11:07:29 -04:00 committed by GitHub
parent 8f88cfad5b
commit c485ae4e90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1354,13 +1354,13 @@ static void Cmd_attackcanceler(void)
}
}
static bool32 JumpIfMoveFailed(u8 adder, u16 move)
static bool32 JumpIfMoveFailed(u8 adder, u16 move, const u8 *failInstr)
{
if (gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_NO_EFFECT)
{
gLastLandedMoves[gBattlerTarget] = 0;
gLastHitByType[gBattlerTarget] = 0;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = failInstr;
return TRUE;
}
else
@ -1380,7 +1380,7 @@ static void Cmd_unused5(void)
if (IsBattlerProtected(gBattlerAttacker, gBattlerTarget, gCurrentMove))
{
gBattleStruct->moveResultFlags[gBattlerTarget] |= MOVE_RESULT_MISSED;
JumpIfMoveFailed(sizeof(*cmd), MOVE_NONE);
JumpIfMoveFailed(sizeof(*cmd), MOVE_NONE, cmd->failInstr);
gBattleCommunication[MISS_TYPE] = B_MSG_PROTECTED;
}
else
@ -1389,14 +1389,14 @@ static void Cmd_unused5(void)
}
}
static bool32 JumpIfMoveAffectedByProtect(u32 move, u32 battler, u32 shouldJump)
static bool32 JumpIfMoveAffectedByProtect(u32 move, u32 battler, u32 shouldJump, const u8 *failInstr)
{
bool32 affected = IsBattlerProtected(gBattlerAttacker, battler, move);
if (affected)
{
gBattleStruct->moveResultFlags[battler] |= MOVE_RESULT_MISSED;
if (shouldJump)
JumpIfMoveFailed(7, move);
JumpIfMoveFailed(7, move, failInstr);
}
return affected;
}
@ -1623,7 +1623,7 @@ static void AccuracyCheck(bool32 recalcDragonDarts, const u8 *nextInstr, const u
gBattlescriptCurrInstr = nextInstr;
else if (gStatuses3[gBattlerTarget] & (STATUS3_SEMI_INVULNERABLE))
gBattlescriptCurrInstr = failInstr;
else if (!JumpIfMoveAffectedByProtect(gCurrentMove, gBattlerTarget, TRUE))
else if (!JumpIfMoveAffectedByProtect(gCurrentMove, gBattlerTarget, TRUE, failInstr))
gBattlescriptCurrInstr = nextInstr;
if (GetActiveGimmick(gBattlerAttacker) == GIMMICK_DYNAMAX)
{
@ -1660,7 +1660,7 @@ static void AccuracyCheck(bool32 recalcDragonDarts, const u8 *nextInstr, const u
continue;
numTargets++;
if (JumpIfMoveAffectedByProtect(move, battlerDef, FALSE) || AccuracyCalcHelper(move, battlerDef))
if (JumpIfMoveAffectedByProtect(move, battlerDef, FALSE, failInstr) || AccuracyCalcHelper(move, battlerDef))
continue;
u32 accuracy = GetTotalAccuracy(gBattlerAttacker,
@ -1707,7 +1707,7 @@ static void AccuracyCheck(bool32 recalcDragonDarts, const u8 *nextInstr, const u
if (calcSpreadMove)
gBattleStruct->calculatedSpreadMoveAccuracy = TRUE;
JumpIfMoveFailed(7, move);
JumpIfMoveFailed(7, move, failInstr);
}
}
@ -12499,9 +12499,8 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
return STAT_CHANGE_DIDNT_WORK;
}
else if (gCurrentMove != MOVE_CURSE
&& notProtectAffected != TRUE && JumpIfMoveAffectedByProtect(gCurrentMove, gBattlerTarget, TRUE))
&& notProtectAffected != TRUE && JumpIfMoveAffectedByProtect(gCurrentMove, gBattlerTarget, TRUE, BattleScript_ButItFailed))
{
gBattlescriptCurrInstr = BattleScript_ButItFailed;
return STAT_CHANGE_DIDNT_WORK;
}
else if ((battlerHoldEffect == HOLD_EFFECT_CLEAR_AMULET || CanAbilityPreventStatLoss(battlerAbility))
@ -16730,7 +16729,6 @@ static void Cmd_tryworryseed(void)
|| gBattleMons[gBattlerTarget].ability == ABILITY_INSOMNIA)
{
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = cmd->failInstr;
}
else if (GetBattlerHoldEffect(gBattlerTarget, TRUE) == HOLD_EFFECT_ABILITY_SHIELD)