From 93e4a1ffa22866c92e780eea25698878bbdd1502 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 27 Jul 2024 21:27:41 -0400 Subject: [PATCH] Weather form changes actually changes form and not just follower graphics --- include/event_object_movement.h | 1 + src/data/pokemon/form_change_tables.h | 2 ++ src/event_object_movement.c | 2 +- src/field_weather.c | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 2906789b3754..21608dbf4476 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -139,6 +139,7 @@ void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Sprite *sp void ObjectEventClearHeldMovement(struct ObjectEvent *); void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *); struct Pokemon *GetFirstLiveMon(void); +u16 GetOverworldWeatherSpecies(u16 species); void UpdateFollowingPokemon(void); void RemoveFollowingPokemon(void); struct ObjectEvent *GetFollowerObject(void); diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 118d726390e2..20a1ddc27e5e 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -538,6 +538,8 @@ static const struct FormChange sBurmyFormChangeTable[] = { #if P_FAMILY_CHERUBI static const struct FormChange sCherrimFormChangeTable[] = { + {FORM_CHANGE_OVERWORLD_WEATHER, SPECIES_CHERRIM_SUNSHINE, WEATHER_DROUGHT}, + {FORM_CHANGE_OVERWORLD_WEATHER, SPECIES_CHERRIM_OVERCAST, WEATHER_NONE}, #if B_WEATHER_FORMS >= GEN_5 {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM_SUNSHINE, B_WEATHER_SUN, ABILITY_FLOWER_GIFT}, {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM_OVERCAST, ~B_WEATHER_SUN, ABILITY_FLOWER_GIFT}, diff --git a/src/event_object_movement.c b/src/event_object_movement.c index bc3ef7daa292..6c004db65b01 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2018,7 +2018,7 @@ static void RefreshFollowerGraphics(struct ObjectEvent *objEvent) } } -static u16 GetOverworldWeatherSpecies(u16 species) +u16 GetOverworldWeatherSpecies(u16 species) { u32 i; u32 weather = GetCurrentWeather(); diff --git a/src/field_weather.c b/src/field_weather.c index 3c9f642faf02..a6cb78596ee1 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -198,11 +198,28 @@ void SetNextWeather(u8 weather) gWeatherPtr->finishStep = 0; } +static void UpdateWeatherForms(void) +{ + s32 i; + for (i = 0; i < PARTY_SIZE; i++) + { + struct Pokemon *mon = &gPlayerParty[i]; + u16 species = GetMonData(mon, MON_DATA_SPECIES); + u16 targetSpecies = GetOverworldWeatherSpecies(species); + if (species != targetSpecies) + { + SetMonData(mon, MON_DATA_SPECIES, &targetSpecies); + CalculateMonStats(mon); + } + } +} + void SetCurrentAndNextWeather(u8 weather) { PlayRainStoppingSoundEffect(); gWeatherPtr->currWeather = weather; gWeatherPtr->nextWeather = weather; + UpdateWeatherForms(); } void SetCurrentAndNextWeatherNoDelay(u8 weather) @@ -212,6 +229,7 @@ void SetCurrentAndNextWeatherNoDelay(u8 weather) gWeatherPtr->nextWeather = weather; // Overrides the normal delay during screen fading. gWeatherPtr->readyForInit = TRUE; + UpdateWeatherForms(); } static void Task_WeatherInit(u8 taskId) @@ -239,6 +257,7 @@ static void Task_WeatherMain(u8 taskId) gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER; gWeatherPtr->currWeather = gWeatherPtr->nextWeather; gWeatherPtr->weatherChangeComplete = TRUE; + UpdateWeatherForms(); } } else