diff --git a/include/constants/battle_ai.h b/include/constants/battle_ai.h index 5ade58d509..63c6a8342c 100644 --- a/include/constants/battle_ai.h +++ b/include/constants/battle_ai.h @@ -23,6 +23,7 @@ #define AI_EFFECTIVENESS_x0 0 // ai weather +#define AI_WEATHER_NONE UINT32_MAX // added as part of bugfix, see Cmd_weather_get in battle_ai_script_commands.c #define AI_WEATHER_SUN 0 #define AI_WEATHER_RAIN 1 #define AI_WEATHER_SANDSTORM 2 diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 6fd3cdad8e..c3658da89f 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1643,6 +1643,15 @@ static void Cmd_if_status_not_in_party(void) static void Cmd_get_weather(void) { + // BUG: due to the lack of an assignment in the case of there not being any + // weather set any previously set value could possibly be interpreted + // as a result of this function. + // Assigning AI_WEATHER_NONE here matches the fix implemented in future + // generations. + #ifdef BUGFIX + AI_THINKING_STRUCT->funcResult = AI_WEATHER_NONE; + #endif + if (gBattleWeather & B_WEATHER_RAIN) AI_THINKING_STRUCT->funcResult = AI_WEATHER_RAIN; if (gBattleWeather & B_WEATHER_SANDSTORM)