From b2266d7e3d72a4cf43a925438967579f60d13de4 Mon Sep 17 00:00:00 2001 From: Isaac Rivera Date: Fri, 4 Oct 2024 16:56:53 -0400 Subject: [PATCH] rename to isCausingSleepClause, hopefully last rename. add some comments near places that will need handling, took a stab at items that cure sleep but no dice --- include/battle.h | 2 +- src/battle_dynamax.c | 2 +- src/battle_script_commands.c | 7 ++++--- src/battle_util.c | 6 +++--- src/pokemon.c | 32 ++++++++++++++++++++++++++++++++ test/battle/sleep_clause.c | 4 ++++ 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/include/battle.h b/include/battle.h index e599bb2feb7..27ecb78602b 100644 --- a/include/battle.h +++ b/include/battle.h @@ -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 diff --git a/src/battle_dynamax.c b/src/battle_dynamax.c index b469ebefd6e..41f47a6ad86 100644 --- a/src/battle_dynamax.c +++ b/src/battle_dynamax.c @@ -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; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 872294cf468..9a7528f43e2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -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; } } @@ -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 @@ -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; diff --git a/src/battle_util.c b/src/battle_util.c index f1eb71d926f..d71e6a642e5 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -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); @@ -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; diff --git a/src/pokemon.c b/src/pokemon.c index 2b731ef13cf..e04e12d1bd0 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -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; } } diff --git a/test/battle/sleep_clause.c b/test/battle/sleep_clause.c index 4165b9f3974..662c9d33c4c 100644 --- a/test/battle/sleep_clause.c +++ b/test/battle/sleep_clause.c @@ -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");