Skip to content

Commit

Permalink
add handling for gaining insomnia/vital spirit, wake up slap, uproar,…
Browse files Browse the repository at this point in the history
… transforming
  • Loading branch information
iriv24 committed Oct 19, 2024
1 parent 64ab52f commit fad1ce5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
39 changes: 39 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -5717,6 +5717,11 @@ static void Cmd_moveend(void)
gBattlescriptCurrInstr = BattleScript_TargetPRLZHeal;
break;
case STATUS1_SLEEP:
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerTarget)] && gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerTarget)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]] = FALSE;
}
gBattlescriptCurrInstr = BattleScript_TargetWokeUp;
break;
case STATUS1_BURN:
Expand Down Expand Up @@ -13185,6 +13190,7 @@ static void Cmd_healpartystatus(void)
u32 zero = 0;
u32 partner = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker)));
u8 toHeal = 0;
bool32 isStatusSleep = (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP);

if (gCurrentMove == MOVE_HEAL_BELL)
{
Expand All @@ -13198,6 +13204,13 @@ static void Cmd_healpartystatus(void)
{
gBattleMons[gBattlerAttacker].status1 = 0;
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE;
if(B_SLEEP_CLAUSE && isStatusSleep
&& gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerAttacker)]
&& gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerAttacker)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = FALSE;
}
}
else
{
Expand All @@ -13211,8 +13224,16 @@ static void Cmd_healpartystatus(void)
{
if (GetBattlerAbility(partner) != ABILITY_SOUNDPROOF || B_HEAL_BELL_SOUNDPROOF == GEN_5)
{
isStatusSleep = (gBattleMons[partner].status1 & STATUS1_SLEEP);
gBattleMons[partner].status1 = 0;
gBattleMons[partner].status2 &= ~STATUS2_NIGHTMARE;
if(B_SLEEP_CLAUSE && isStatusSleep
&& gBattleStruct->sleepClause.isActive[GetBattlerSide(partner)]
&& gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(partner)][gBattlerPartyIndexes[partner]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(partner)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(partner)][gBattlerPartyIndexes[partner]] = FALSE;
}
}
else
{
Expand Down Expand Up @@ -13268,6 +13289,23 @@ static void Cmd_healpartystatus(void)
gBattleMons[gBattlerAttacker].status1 = 0;
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE;

if(B_SLEEP_CLAUSE && isStatusSleep)
{
if(gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerAttacker)]
&& gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerAttacker)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = FALSE;
}

else if(gBattleStruct->sleepClause.isActive[GetBattlerSide(partner)]
&& gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(partner)][gBattlerPartyIndexes[partner]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(partner)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(partner)][gBattlerPartyIndexes[partner]] = FALSE;
}
}

if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE
&& !(gAbsentBattlerFlags & gBitTable[partner]))
{
Expand Down Expand Up @@ -14635,6 +14673,7 @@ static void Cmd_switchoutabilities(void)
{
switch (GetBattlerAbility(battler))
{
//todo sleep clause here natural cure
case ABILITY_NATURAL_CURE:
gBattleMons[battler].status1 = 0;
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE,
Expand Down
11 changes: 11 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3273,6 +3273,12 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
{
if (UproarWakeUpCheck(gBattlerAttacker))
{
if (B_SLEEP_CLAUSE && gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerAttacker)] && gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]])
{
gBattleStruct->sleepClause.isActive[GetBattlerSide(gBattlerAttacker)] = FALSE;
gBattleStruct->sleepClause.isCausingSleepClause[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = FALSE;
}

gBattleMons[gBattlerAttacker].status1 &= ~STATUS1_SLEEP;
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE;
BattleScriptPushCursor();
Expand Down Expand Up @@ -6119,6 +6125,11 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_VITAL_SPIRIT:
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
{
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;
}
gBattleMons[battler].status2 &= ~STATUS2_NIGHTMARE;
StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn);
effect = 1;
Expand Down
23 changes: 18 additions & 5 deletions test/battle/sleep_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ DOUBLE_BATTLE_TEST("Sleep Clause: G-Max Befuddle can only sleep one opposing mon

//honestly some of these are probably covered by just normal sleep tests
// also possible that these should be done in doubles since its kinda just a nomral "mon woke up" test
// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon wakes up");
// something like:
// player has wob
Expand Down Expand Up @@ -371,40 +372,52 @@ TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon
// AI switches, player uses spore, it fails
// AI switches back to sleeping wob, player uses wake-up-slap/uproar, which wakes up enemy wob
// AI switches AGAIN, player uses spore, it succeeds
// fun fact, uproar and wake-up slap are handled in 2 different places, so probably each require a test
// added handling for both though

// this feels like a horribly complicated scenario that would probably not happen in a million runs but unfortunately i thought of it so i will
// write it down
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by using sleep talk into psycho shift");
// replace psycho shift with the following moves:
// jungle healing, lunar blessing, refresh, purify (maybe?), take heart


// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by the ability hydration in the rain");

TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by the ability natural cure");

// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by the ability shed skin");

TO_DO_BATTLE_TEST("DOUBLES TEST: Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by the ability healer");

// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by the item awakening");
// replace awakening with the following items:
// blue flute, chesto berry, big malasada, casteliacone, full heal, full restore, heal powder, lava cookie, lum berry
// lumiose galett, miracle berry?, old gateau, pewter Crunchies, rage candy bar, shalour sable
// idk wtf half these items even are and id imagine a lot of them share effects so i doubt a test will be needed for all of them

// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by gaining the ability Insomnia");

// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is woken up by gaining the ability Vital Spirit");

// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon faints");

TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping uses sleep talk -> explosion"); // holy fuck if this requires special handling im uninstalling
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon uses sleep talk -> explosion"); // holy fuck if this requires special handling im uninstalling

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 mon 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");
// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is sent out, has trace, and traces insomnia/vital spirit");

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

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");
// ADDED HANDLING FOR THIS
TO_DO_BATTLE_TEST("Sleep Clause: sleep clause is deactivated when a sleeping mon is sent out and transforms into a mon with insomnia/vital spirit");

0 comments on commit fad1ce5

Please sign in to comment.