Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overworld snow weather + make overworld fog cause misty terrain #3241

Merged
merged 11 commits into from
Sep 11, 2023
2 changes: 2 additions & 0 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,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.
Expand Down Expand Up @@ -204,6 +205,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.
Expand Down
6 changes: 5 additions & 1 deletion src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,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,
Expand Down
26 changes: 25 additions & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -4195,7 +4195,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))
Expand Down Expand Up @@ -4228,6 +4237,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)
Expand Down
5 changes: 3 additions & 2 deletions src/field_weather.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -380,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)
{
Expand All @@ -402,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:
Expand Down Expand Up @@ -772,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:
Expand Down
31 changes: 2 additions & 29 deletions src/field_weather_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down