Skip to content

Commit

Permalink
handle deactivating sleep clause when being awoken by a held item
Browse files Browse the repository at this point in the history
  • Loading branch information
iriv24 committed Oct 6, 2024
1 parent 403e12a commit 42bc12a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7222,6 +7222,11 @@ static u8 ItemEffectMoveEnd(u32 battler, u16 holdEffect)
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureSlpRet;
effect = ITEM_STATUS_CHANGE;
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] && gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]] = FALSE;
}
}
break;
case HOLD_EFFECT_CURE_CONFUSION:
Expand Down Expand Up @@ -7463,6 +7468,11 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
gBattleMons[battler].status2 &= ~STATUS2_NIGHTMARE;
BattleScriptExecute(BattleScript_BerryCureSlpEnd2);
effect = ITEM_STATUS_CHANGE;
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] && gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]] = FALSE;
}
}
break;
case HOLD_EFFECT_CURE_STATUS:
Expand Down Expand Up @@ -7769,6 +7779,11 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
gBattleMons[battler].status2 &= ~STATUS2_NIGHTMARE;
BattleScriptExecute(BattleScript_BerryCureSlpEnd2);
effect = ITEM_STATUS_CHANGE;
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] && gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]] = FALSE;
}
}
break;
case HOLD_EFFECT_CURE_CONFUSION:
Expand Down
2 changes: 2 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -4186,6 +4186,7 @@ bool8 HealStatusConditions(struct Pokemon *mon, u32 healMask, u8 battlerId)
u32 status = GetMonData(mon, MON_DATA_STATUS, 0);
u32 i = 0;
u32 battlerSide = GetBattlerSide(battlerId);

if (status & healMask)
{
status &= ~healMask;
Expand All @@ -4207,6 +4208,7 @@ bool8 HealStatusConditions(struct Pokemon *mon, u32 healMask, u8 battlerId)
{
gBattleStruct->sleepClause.isActive[battlerSide] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[battlerSide][i] = FALSE;
break;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/battle/sleep_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,5 @@ TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping use


TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping is sent out, has trace, and traces insomnia/vital spirit");

TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by a held item, like chesto");

0 comments on commit 42bc12a

Please sign in to comment.