diff --git a/include/config/battle.h b/include/config/battle.h index 3fdc45e490..06373f2c19 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -130,6 +130,8 @@ #define B_PURSUIT_TARGET GEN_LATEST // In Gen4+, Pursuit attacks a switching opponent even if they weren't targeting them. Before Gen4, Pursuit only attacks a switching opponent that it originally targeted. #define B_SKIP_RECHARGE GEN_LATEST // In Gen1, recharging moves such as Hyper Beam skip the recharge if the target gets KO'd #define B_ENCORE_TARGET GEN_LATEST // In Gen5+, encored moves are allowed to choose a target +#define B_TIME_OF_DAY_HEALING_MOVES GEN_LATEST // In Gen2, Morning Sun, Moonlight, and Synthesis heal twice as much HP based off the time of day. Also changes how much they heal. Evening affects Moonlight. + // If OW_TIMES_OF_DAY is set to Gen 3, then Morning Sun is boosted during the day. // Ability settings #define B_GALE_WINGS GEN_LATEST // In Gen7+ requires full HP to trigger. diff --git a/include/constants/generational_changes.h b/include/constants/generational_changes.h index 143dc6e5bb..1cf2d80072 100644 --- a/include/constants/generational_changes.h +++ b/include/constants/generational_changes.h @@ -19,6 +19,7 @@ enum GenConfigTag GEN_CONFIG_FELL_STINGER_STAT_RAISE, GEN_CONFIG_DEFIANT_STICKY_WEB, GEN_CONFIG_ENCORE_TARGET, + GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_CONFIG_COUNT }; diff --git a/include/generational_changes.h b/include/generational_changes.h index 146139d39e..a734ee49e8 100644 --- a/include/generational_changes.h +++ b/include/generational_changes.h @@ -22,6 +22,7 @@ static const u8 sGenerationalChanges[GEN_CONFIG_COUNT] = [GEN_CONFIG_FELL_STINGER_STAT_RAISE] = B_FELL_STINGER_STAT_RAISE, [GEN_CONFIG_DEFIANT_STICKY_WEB] = B_DEFIANT_STICKY_WEB, [GEN_CONFIG_ENCORE_TARGET] = B_ENCORE_TARGET, + [GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES] = B_TIME_OF_DAY_HEALING_MOVES, }; #if TESTING diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ed2ee03236..f6bfbad7fd 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14316,7 +14316,7 @@ static void Cmd_recoverbasedonsunlight(void) else gBattleStruct->moveDamage[gBattlerAttacker] = GetNonDynamaxMaxHP(gBattlerAttacker) / 2; } - else + else if (GetGenConfig(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES) != GEN_2) { if (!(gBattleWeather & B_WEATHER_ANY) || !HasWeatherEffect() || GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_UTILITY_UMBRELLA) gBattleStruct->moveDamage[gBattlerAttacker] = GetNonDynamaxMaxHP(gBattlerAttacker) / 2; @@ -14325,6 +14325,39 @@ static void Cmd_recoverbasedonsunlight(void) else // not sunny weather gBattleStruct->moveDamage[gBattlerAttacker] = GetNonDynamaxMaxHP(gBattlerAttacker) / 4; } + else // B_TIME_OF_DAY_HEALING_MOVES == GEN_2 + { + u32 healingModifier = 1; + u32 time = GetTimeOfDay(); + + switch (GetMoveEffect(gCurrentMove)) + { + case EFFECT_MOONLIGHT: + if (time == TIME_NIGHT || time == TIME_EVENING) + healingModifier = 2; + break; + case EFFECT_MORNING_SUN: + if ((OW_TIMES_OF_DAY == GEN_3 && time == TIME_DAY) // Gen 3 doesn't have morning + || (OW_TIMES_OF_DAY != GEN_3 && time == TIME_MORNING)) + healingModifier = 2; + break; + case EFFECT_SYNTHESIS: + if (time == TIME_DAY) + healingModifier = 2; + break; + default: + healingModifier = 1; + break; + } + + if (!(gBattleWeather & B_WEATHER_ANY) || !HasWeatherEffect() || GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_UTILITY_UMBRELLA) + gBattleStruct->moveDamage[gBattlerAttacker] = healingModifier * GetNonDynamaxMaxHP(gBattlerAttacker) / 4; + else if (gBattleWeather & B_WEATHER_SUN) + gBattleStruct->moveDamage[gBattlerAttacker] = healingModifier * GetNonDynamaxMaxHP(gBattlerAttacker) / 2; + else // not sunny weather + gBattleStruct->moveDamage[gBattlerAttacker] = healingModifier * GetNonDynamaxMaxHP(gBattlerAttacker) / 8; + + } if (gBattleStruct->moveDamage[gBattlerAttacker] == 0) gBattleStruct->moveDamage[gBattlerAttacker] = 1; diff --git a/test/battle/move_effect/moonlight.c b/test/battle/move_effect/moonlight.c index 34baa31b14..9804e4ba1e 100644 --- a/test/battle/move_effect/moonlight.c +++ b/test/battle/move_effect/moonlight.c @@ -6,9 +6,10 @@ ASSUMPTIONS ASSUME(GetMoveEffect(MOVE_MOONLIGHT) == EFFECT_MOONLIGHT); } -SINGLE_BATTLE_TEST("Moonlight recovers 1/2 of the user's max HP") +SINGLE_BATTLE_TEST("Moonlight recovers 1/2 of the user's max HP (Gen3+)") { GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(200); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -18,9 +19,10 @@ SINGLE_BATTLE_TEST("Moonlight recovers 1/2 of the user's max HP") } } -SINGLE_BATTLE_TEST("Moonlight recovers 2/3 of the user's max HP in Sunlight") +SINGLE_BATTLE_TEST("Moonlight recovers 2/3 of the user's max HP in Sunlight (Gen3+)") { GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -30,7 +32,7 @@ SINGLE_BATTLE_TEST("Moonlight recovers 2/3 of the user's max HP in Sunlight") } } -SINGLE_BATTLE_TEST("Moonlight recovers 1/4 of the user's max HP in Rain, Sandstorm, Hail, and Snow") +SINGLE_BATTLE_TEST("Moonlight recovers 1/4 of the user's max HP in Rain, Sandstorm, Hail, and Snow (Gen3+)") { u32 move; PARAMETRIZE { move = MOVE_RAIN_DANCE; } @@ -38,6 +40,7 @@ SINGLE_BATTLE_TEST("Moonlight recovers 1/4 of the user's max HP in Rain, Sandsto PARAMETRIZE { move = MOVE_HAIL; } PARAMETRIZE { move = MOVE_SNOWSCAPE; } GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(400); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -46,3 +49,15 @@ SINGLE_BATTLE_TEST("Moonlight recovers 1/4 of the user's max HP in Rain, Sandsto HP_BAR(player, damage: -(400 / 4)); } } + +TO_DO_BATTLE_TEST("TODO: Moonlight recovers 1/4 of the user's max HP while it is not night or evening (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Moonlight recovers 1/2 of the user's max HP in Sunlight while it is not night or evening (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Moonlight recovers 1/8 of the user's max HP in Rain, Sandstorm, Hail, and Snow while it is not night or evening (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Moonlight recovers 2/4 of the user's max HP while it is night or evening (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Moonlight recovers 2/2 of the user's max HP in Sunlight while it is night or evening (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Moonlight recovers 2/8 of the user's max HP in Rain, Sandstorm, Hail, and Snow while it is night or evening (Gen2)") diff --git a/test/battle/move_effect/morning_sun.c b/test/battle/move_effect/morning_sun.c index 64fb1b044b..eca9efd31f 100644 --- a/test/battle/move_effect/morning_sun.c +++ b/test/battle/move_effect/morning_sun.c @@ -6,9 +6,10 @@ ASSUMPTIONS ASSUME(GetMoveEffect(MOVE_MORNING_SUN) == EFFECT_MORNING_SUN); } -SINGLE_BATTLE_TEST("Morning Sun recovers 1/2 of the user's max HP") +SINGLE_BATTLE_TEST("Morning Sun recovers 1/2 of the user's max HP (Gen3+)") { GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(200); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -18,9 +19,10 @@ SINGLE_BATTLE_TEST("Morning Sun recovers 1/2 of the user's max HP") } } -SINGLE_BATTLE_TEST("Morning Sun recovers 2/3 of the user's max HP in Sunlight") +SINGLE_BATTLE_TEST("Morning Sun recovers 2/3 of the user's max HP in Sunlight (Gen3+)") { GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -30,7 +32,7 @@ SINGLE_BATTLE_TEST("Morning Sun recovers 2/3 of the user's max HP in Sunlight") } } -SINGLE_BATTLE_TEST("Morning Sun recovers 1/4 of the user's max HP in Rain, Sandstorm, Hail, and Snow") +SINGLE_BATTLE_TEST("Morning Sun recovers 1/4 of the user's max HP in Rain, Sandstorm, Hail, and Snow (Gen3+)") { u32 move; PARAMETRIZE { move = MOVE_RAIN_DANCE; } @@ -38,6 +40,7 @@ SINGLE_BATTLE_TEST("Morning Sun recovers 1/4 of the user's max HP in Rain, Sands PARAMETRIZE { move = MOVE_HAIL; } PARAMETRIZE { move = MOVE_SNOWSCAPE; } GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(400); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -46,3 +49,15 @@ SINGLE_BATTLE_TEST("Morning Sun recovers 1/4 of the user's max HP in Rain, Sands HP_BAR(player, damage: -(400 / 4)); } } + +TO_DO_BATTLE_TEST("TODO: Morning Sun recovers 1/4 of the user's max HP while it is not morning (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Morning Sun recovers 1/2 of the user's max HP in Sunlight while it is not morning (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Morning Sun recovers 1/8 of the user's max HP in Rain, Sandstorm, Hail, and Snow while it is not morning (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Morning Sun recovers 2/4 of the user's max HP while it is morning (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Morning Sun recovers 2/2 of the user's max HP in Sunlight while it is morning (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Morning Sun recovers 2/8 of the user's max HP in Rain, Sandstorm, Hail, and Snow while it is morning (Gen2)") diff --git a/test/battle/move_effect/synthesis.c b/test/battle/move_effect/synthesis.c index 6799bd2870..d9651a509e 100644 --- a/test/battle/move_effect/synthesis.c +++ b/test/battle/move_effect/synthesis.c @@ -6,9 +6,10 @@ ASSUMPTIONS ASSUME(GetMoveEffect(MOVE_SYNTHESIS) == EFFECT_SYNTHESIS); } -SINGLE_BATTLE_TEST("Synthesis recovers 1/2 of the user's max HP") +SINGLE_BATTLE_TEST("Synthesis recovers 1/2 of the user's max HP (Gen3+)") { GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(200); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -18,9 +19,10 @@ SINGLE_BATTLE_TEST("Synthesis recovers 1/2 of the user's max HP") } } -SINGLE_BATTLE_TEST("Synthesis recovers 2/3 of the user's max HP in Sunlight") +SINGLE_BATTLE_TEST("Synthesis recovers 2/3 of the user's max HP in Sunlight (Gen3+)") { GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -30,7 +32,7 @@ SINGLE_BATTLE_TEST("Synthesis recovers 2/3 of the user's max HP in Sunlight") } } -SINGLE_BATTLE_TEST("Synthesis recovers 1/4 of the user's max HP in Rain, Sandstorm, Hail, and Snow") +SINGLE_BATTLE_TEST("Synthesis recovers 1/4 of the user's max HP in Rain, Sandstorm, Hail, and Snow (Gen3+)") { u32 move; PARAMETRIZE { move = MOVE_RAIN_DANCE; } @@ -38,6 +40,7 @@ SINGLE_BATTLE_TEST("Synthesis recovers 1/4 of the user's max HP in Rain, Sandsto PARAMETRIZE { move = MOVE_HAIL; } PARAMETRIZE { move = MOVE_SNOWSCAPE; } GIVEN { + WITH_CONFIG(GEN_CONFIG_TIME_OF_DAY_HEALING_MOVES, GEN_3); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(400); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -46,3 +49,15 @@ SINGLE_BATTLE_TEST("Synthesis recovers 1/4 of the user's max HP in Rain, Sandsto HP_BAR(player, damage: -(400 / 4)); } } + +TO_DO_BATTLE_TEST("TODO: Synthesis recovers 1/4 of the user's max HP while it is not day (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Synthesis recovers 1/2 of the user's max HP in Sunlight while it is not day (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Synthesis recovers 1/8 of the user's max HP in Rain, Sandstorm, Hail, and Snow while it is not day (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Synthesis recovers 2/4 of the user's max HP while it is day (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Synthesis recovers 2/2 of the user's max HP in Sunlight while it is day (Gen2)") + +TO_DO_BATTLE_TEST("TODO: Synthesis recovers 2/8 of the user's max HP in Rain, Sandstorm, Hail, and Snow while it is day (Gen2)")