Skip to content

Commit

Permalink
rename to isCausingSleepClause, hopefully last rename. add some comme…
Browse files Browse the repository at this point in the history
…nts near places that will need handling, took a stab at items that cure sleep but no dice
  • Loading branch information
iriv24 committed Oct 4, 2024
1 parent fb1267e commit b2266d7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ struct SleepClauseData
{
u8 isActive[NUM_BATTLE_SIDES]; // Stores sleep clause state for each battle side
bool8 effectExempt; // Stores whether effect should be exempt from triggering sleep clause (Effect Spore)
bool8 isMonCausingSleepClause[NUM_BATTLE_SIDES][PARTY_SIZE]; // When a Pokemon falls asleep, need to know if it should deactivate sleep clause upon waking
bool8 isCausingSleepClause[NUM_BATTLE_SIDES][PARTY_SIZE]; // When a Pokemon falls asleep, need to know if it should deactivate sleep clause upon waking
};

struct LostItem
Expand Down
2 changes: 1 addition & 1 deletion src/battle_dynamax.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ void BS_TrySetStatus1(void)
if (B_SLEEP_CLAUSE)
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerTarget)] = TRUE;
gBattleStruct->sleepClause.isMonCausingSleepClause[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]] = TRUE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]] = TRUE;
}

gBattleCommunication[MULTISTRING_CHOOSER] = 4;
Expand Down
7 changes: 4 additions & 3 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -3086,7 +3086,7 @@ void SetMoveEffect(bool32 primary, bool32 certain)
if (B_SLEEP_CLAUSE && !gBattleStruct->sleepClause.effectExempt)
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gEffectBattler)] = TRUE;
gBattleStruct->sleepClause.isMonCausingSleepClause[GetBattlerSide(gEffectBattler)][gBattlerPartyIndexes[gEffectBattler]] = TRUE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gEffectBattler)][gBattlerPartyIndexes[gEffectBattler]] = TRUE;
gBattleStruct->sleepClause.effectExempt = FALSE;
}
}
Expand Down Expand Up @@ -4008,10 +4008,10 @@ static void Cmd_tryfaintmon(void)

PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].moves[moveIndex])
}
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] && gBattleStruct->sleepClause.isMonCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]])
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] && gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(battler)] = FALSE;
gBattleStruct->sleepClause.isMonCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]] = FALSE;
}
}
else
Expand Down Expand Up @@ -13179,6 +13179,7 @@ static void Cmd_tryspiteppreduce(void)

static void Cmd_healpartystatus(void)
{
// TODO sleep clause: add code here for heal bell/armoatherapy/sparkly swirl (??)
CMD_ARGS();

u32 zero = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2828,7 +2828,7 @@ u8 DoBattlerEndTurnEffects(void)
if (B_SLEEP_CLAUSE)
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerTarget)] = TRUE;
gBattleStruct->sleepClause.isMonCausingSleepClause[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]] = TRUE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]] = TRUE;
}

BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1);
Expand Down Expand Up @@ -3302,10 +3302,10 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
}
else
{
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isMonCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]])
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerAttacker)] = FALSE;
gBattleStruct->sleepClause.isMonCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = FALSE;
}

gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE;
Expand Down
32 changes: 32 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -4189,12 +4189,44 @@ bool8 HealStatusConditions(struct Pokemon *mon, u32 healMask, u8 battlerId)
{
status &= ~healMask;
SetMonData(mon, MON_DATA_STATUS, &status);
// i THINK this is where the code should go to handle getting healed by items
// (lets use "awakening" item as an example)
// if you use an awakening on the mon thats in battle, it works as intended
// but if you use an awakening on a mon thats NOT in battle, it is not clearing sleep clause
// see the TODO sleep clause: a little further down
//DebugPrintf("here healing status");
if (gMain.inBattle && battlerId != MAX_BATTLERS_COUNT)
{
gBattleMons[battlerId].status1 &= ~healMask;
// DebugPrintf("here healing status in battle");
// if (B_SLEEP_CLAUSE)
// {
// DebugPrintf("passed check that sleep clause is active");

// TODO sleep clause: make sure you account for full heals, whatever that healMask is. status_any or all or some shit

// if(healMask & STATUS1_SLEEP)
// {
// DebugPrintf("passed check that status is sleep");

// TODO sleep clause: need to access the index of the mon that is getting healed because gBattlerPartyIndexes[battlerId] is not the right way to do it
// if(gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battlerId)][gBattlerPartyIndexes[battlerId]])
// {
// DebugPrintf("passed check that the mon at the right index is the one with sleep clause");
// gBattleStruct->sleepClause.isActive[GetBattlerSide(battlerId)] = FALSE;
// gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(battlerId)][gBattlerPartyIndexes[battlerId]] = FALSE;
// }
// }

// }

}

return FALSE;
}
else
{
DebugPrintf("how do you even get here");
return TRUE;
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/battle/sleep_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,7 @@ 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 uses sleep talk -> move that KOs a mon that has used destiny bond");

TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping uses sleep talk -> role play/skill swap");


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

0 comments on commit b2266d7

Please sign in to comment.