From 0ad3919f226f1f8ba0591ea87711dbd0069f8a8c Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Sat, 19 Aug 2023 01:40:31 -0500 Subject: [PATCH 1/3] Fix overworld snow weather --- include/config/battle.h | 1 + src/battle_message.c | 6 +++++- src/battle_util.c | 15 +++++++++++++++ src/field_weather.c | 2 ++ src/field_weather_effect.c | 29 +---------------------------- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 68cab28b6..0c17c2e96 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -202,6 +202,7 @@ #define B_TRAINER_CLASS_POKE_BALLS GEN_LATEST // In Gen7+, trainers will use certain types of Poké Balls depending on their trainer class. #define B_OBEDIENCE_MECHANICS GEN_7 // In PLA+ (here Gen8+), obedience restrictions also apply to non-outsider Pokémon, albeit based on their level met rather than actual level #define B_USE_FROSTBITE FALSE // In PLA, Frostbite replaces Freeze. Enabling this flag does the same here. Moves can still be cherry-picked to either Freeze or Frostbite. Freeze-Dry, Secret Power & Tri Attack depend on this config. +#define B_OVERWORLD_SNOW GEN_LATEST // In Gen9+, overworld Snow will summon snow instead of hail. // Animation Settings #define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/battle_message.c b/src/battle_message.c index bce1438c0..871a410c2 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -1838,7 +1838,11 @@ const u16 gWeatherStartsStringIds[] = [WEATHER_SUNNY_CLOUDS] = STRINGID_ITISRAINING, [WEATHER_SUNNY] = STRINGID_ITISRAINING, [WEATHER_RAIN] = STRINGID_ITISRAINING, - [WEATHER_SNOW] = STRINGID_ITISRAINING, +#if B_OVERWORLD_SNOW >= GEN_9 + [WEATHER_SNOW] = STRINGID_STARTEDSNOW, +#else + [WEATHER_SNOW] = STRINGID_STARTEDHAIL, +#endif [WEATHER_RAIN_THUNDERSTORM] = STRINGID_ITISRAINING, [WEATHER_FOG_HORIZONTAL] = STRINGID_ITISRAINING, [WEATHER_VOLCANIC_ASH] = STRINGID_ITISRAINING, diff --git a/src/battle_util.c b/src/battle_util.c index c15c46a09..cad07791a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4238,6 +4238,21 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case WEATHER_SNOW: + if (!(gBattleWeather & (B_WEATHER_HAIL | B_WEATHER_SNOW))) + { + #if B_OVERWORLD_SNOW >= GEN_9 + gBattleWeather = B_WEATHER_SNOW; + gBattleScripting.animArg1 = B_ANIM_SNOW_CONTINUES; + effect++; + #else + gBattleWeather = B_WEATHER_HAIL; + gBattleScripting.animArg1 = B_ANIM_HAIL_CONTINUES; + effect++; + #endif + + } + break; } } if (effect != 0) diff --git a/src/field_weather.c b/src/field_weather.c index bcc6a1c44..a252b1785 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -16,6 +16,7 @@ #include "task.h" #include "trig.h" #include "gpu_regs.h" +#include "field_camera.h" #define DROUGHT_COLOR_INDEX(color) ((((color) >> 1) & 0xF) | (((color) >> 2) & 0xF0) | (((color) >> 3) & 0xF00)) @@ -219,6 +220,7 @@ static void Task_WeatherInit(u8 taskId) // When the screen fades in, this is set to TRUE. if (gWeatherPtr->readyForInit) { + UpdateCameraPanning(); sWeatherFuncs[gWeatherPtr->currWeather].initAll(); gTasks[taskId].func = Task_WeatherMain; } diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index 05eae421e..bfd4e325b 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -940,8 +940,7 @@ static void InitSnowflakeSpriteMovement(struct Sprite *sprite) static void WaitSnowflakeSprite(struct Sprite *sprite) { - // Timer is never incremented - if (gWeatherPtr->snowflakeTimer > 18) + if (++gWeatherPtr->snowflakeTimer > 18) { sprite->invisible = FALSE; sprite->callback = UpdateSnowflakeSprite; @@ -970,32 +969,6 @@ static void UpdateSnowflakeSprite(struct Sprite *sprite) sprite->x = 242 - (gSpriteCoordOffsetX + sprite->centerToCornerVecX); else if (x > 242) sprite->x = -3 - (gSpriteCoordOffsetX + sprite->centerToCornerVecX); - - y = (sprite->y + sprite->centerToCornerVecY + gSpriteCoordOffsetY) & 0xFF; - if (y > 163 && y < 171) - { - sprite->y = 250 - (gSpriteCoordOffsetY + sprite->centerToCornerVecY); - sprite->tPosY = sprite->y * 128; - sprite->tFallCounter = 0; - sprite->tFallDuration = 220; - } - else if (y > 242 && y < 250) - { - sprite->y = 163; - sprite->tPosY = sprite->y * 128; - sprite->tFallCounter = 0; - sprite->tFallDuration = 220; - sprite->invisible = TRUE; - sprite->callback = WaitSnowflakeSprite; - } - - if (++sprite->tFallCounter == sprite->tFallDuration) - { - InitSnowflakeSpriteMovement(sprite); - sprite->y = 250; - sprite->invisible = TRUE; - sprite->callback = WaitSnowflakeSprite; - } } #undef tPosY From 5e98891577fbda2223b45f7ac93d2120bccb5f83 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Sun, 20 Aug 2023 13:24:20 -0500 Subject: [PATCH 2/3] Snow doesn't cause shade anymore --- src/field_weather.c | 3 +-- src/field_weather_effect.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/field_weather.c b/src/field_weather.c index a252b1785..045c234ac 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -382,7 +382,6 @@ static void FadeInScreenWithWeather(void) case WEATHER_RAIN: case WEATHER_RAIN_THUNDERSTORM: case WEATHER_DOWNPOUR: - case WEATHER_SNOW: case WEATHER_SHADE: if (FadeInScreen_RainShowShade() == FALSE) { @@ -404,6 +403,7 @@ static void FadeInScreenWithWeather(void) gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; + case WEATHER_SNOW: case WEATHER_VOLCANIC_ASH: case WEATHER_SANDSTORM: case WEATHER_FOG_DIAGONAL: @@ -774,7 +774,6 @@ void FadeScreen(u8 mode, s8 delay) case WEATHER_RAIN: case WEATHER_RAIN_THUNDERSTORM: case WEATHER_DOWNPOUR: - case WEATHER_SNOW: case WEATHER_FOG_HORIZONTAL: case WEATHER_SHADE: case WEATHER_DROUGHT: diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index bfd4e325b..334033403 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -768,7 +768,7 @@ void Snow_InitVars(void) { gWeatherPtr->initStep = 0; gWeatherPtr->weatherGfxLoaded = FALSE; - gWeatherPtr->targetColorMapIndex = 3; + gWeatherPtr->targetColorMapIndex = 0; gWeatherPtr->colorMapStepDelay = 20; gWeatherPtr->targetSnowflakeSpriteCount = 16; gWeatherPtr->snowflakeVisibleCounter = 0; From a79898f1b1525eb10a97dd58acee590a5bda572c Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Sun, 20 Aug 2023 13:51:48 -0500 Subject: [PATCH 3/3] Make fog cause misty terrain --- include/config/battle.h | 1 + src/battle_util.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/config/battle.h b/include/config/battle.h index 0c17c2e96..bb0b25427 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -169,6 +169,7 @@ // Terrain settings #define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. #define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. +#define B_FOG_TERRAIN TRUE // If TRUE, overworld Fog generates Misty Terrain as in Gen 8. #define B_TERRAIN_TYPE_BOOST GEN_LATEST // In Gen8, damage is boosted by 30% instead of 50%. #define B_SECRET_POWER_EFFECT GEN_LATEST // Secret Power's effects change depending on terrain and generation. See GetSecretPowerMoveEffect. #define B_SECRET_POWER_ANIMATION GEN_LATEST // Secret Power's animations change depending on terrain and generation. diff --git a/src/battle_util.c b/src/battle_util.c index cad07791a..a3a26c564 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4205,7 +4205,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } #endif - break; + #if B_FOG_TERRAIN == TRUE + else if ((GetCurrentWeather() == WEATHER_FOG_HORIZONTAL || GetCurrentWeather() == WEATHER_FOG_DIAGONAL) && !(gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)) + { + gFieldStatuses = (STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT); + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + BattleScriptPushCursorAndCallback(BattleScript_OverworldTerrain); + effect++; + } + #endif + break; case ABILITYEFFECT_SWITCH_IN_WEATHER: gBattleScripting.battler = battler; if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED))