From fe55580fe1e51c669033939125c939ed13a555d0 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Wed, 27 Feb 2019 03:42:04 -0500 Subject: [PATCH] Reverse engineer unusual weather events --- data/event_scripts.s | 56 +++++++++---------- data/maps/Route105/scripts.inc | 8 +-- data/maps/Route114/scripts.inc | 8 +-- data/maps/Route115/scripts.inc | 8 +-- data/maps/Route116/scripts.inc | 8 +-- data/maps/Route118/scripts.inc | 8 +-- .../Route119_WeatherInstitute_2F/scripts.inc | 18 +++--- data/maps/Route125/scripts.inc | 8 +-- data/maps/Route127/scripts.inc | 8 +-- data/maps/Route129/scripts.inc | 8 +-- data/specials.inc | 2 +- include/constants/flags.h | 2 +- include/constants/vars.h | 4 +- include/constants/weather.h | 26 +++++++++ src/field_specials.c | 22 ++++---- src/match_call.c | 2 +- src/overworld.c | 2 +- src/region_map.c | 4 +- 18 files changed, 115 insertions(+), 87 deletions(-) diff --git a/data/event_scripts.s b/data/event_scripts.s index 55bbb7618..adecc3fcf 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -3188,7 +3188,7 @@ gUnknown_08273D1F:: @ 8273D1F gUnknown_08273D1F:: @ 8273D1F lockall - compare VAR_0x4037, 9 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START goto_if_ge Route105_EventScript_273D51 goto Route105_EventScript_273D5F end @@ -3200,7 +3200,7 @@ Route105_EventScript_273D31:: @ 8273D31 doweather call Route105_EventScript_273D6D special DrawWholeMapView - setvar VAR_0x4037, 0 + setvar VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_NONE setvar VAR_0x4039, 0 clearflag FLAG_SPECIAL_FLAG_0x4000 fadescreenswapbuffers 0 @@ -3218,23 +3218,23 @@ Route105_EventScript_273D5F:: @ 8273D5F end Route105_EventScript_273D6D:: @ 8273D6D - switch VAR_0x4037 - case 1, Route105_EventScript_273E23 - case 2, Route105_EventScript_273E36 - case 3, Route105_EventScript_273E49 - case 4, Route105_EventScript_273E5C - case 5, Route105_EventScript_273E6F - case 6, Route105_EventScript_273E82 - case 7, Route105_EventScript_273E95 - case 8, Route105_EventScript_273EA8 - case 9, Route105_EventScript_273EBB - case 10, Route105_EventScript_273F28 - case 11, Route105_EventScript_273F95 - case 12, Route105_EventScript_274002 - case 13, Route105_EventScript_27406F - case 14, Route105_EventScript_2740DC - case 15, Route105_EventScript_274149 - case 16, Route105_EventScript_2741B6 + switch VAR_UNUSUAL_WEATHER_LOCATION + case UNUSUAL_WEATHER_ROUTE_114_NORTH, Route105_EventScript_273E23 + case UNUSUAL_WEATHER_ROUTE_114_SOUTH, Route105_EventScript_273E36 + case UNUSUAL_WEATHER_ROUTE_115_WEST, Route105_EventScript_273E49 + case UNUSUAL_WEATHER_ROUTE_115_EAST, Route105_EventScript_273E5C + case UNUSUAL_WEATHER_ROUTE_116_NORTH, Route105_EventScript_273E6F + case UNUSUAL_WEATHER_ROUTE_116_SOUTH, Route105_EventScript_273E82 + case UNUSUAL_WEATHER_ROUTE_118_EAST, Route105_EventScript_273E95 + case UNUSUAL_WEATHER_ROUTE_118_WEST, Route105_EventScript_273EA8 + case UNUSUAL_WEATHER_ROUTE_105_NORTH, Route105_EventScript_273EBB + case UNUSUAL_WEATHER_ROUTE_105_SOUTH, Route105_EventScript_273F28 + case UNUSUAL_WEATHER_ROUTE_125_WEST, Route105_EventScript_273F95 + case UNUSUAL_WEATHER_ROUTE_125_EAST, Route105_EventScript_274002 + case UNUSUAL_WEATHER_ROUTE_127_NORTH, Route105_EventScript_27406F + case UNUSUAL_WEATHER_ROUTE_127_SOUTH, Route105_EventScript_2740DC + case UNUSUAL_WEATHER_ROUTE_129_WEST, Route105_EventScript_274149 + case UNUSUAL_WEATHER_ROUTE_129_EAST, Route105_EventScript_2741B6 return Route105_EventScript_273E23:: @ 8273E23 @@ -3401,15 +3401,15 @@ Underwater3_EventScript_274223:: @ 8274223 Underwater5_EventScript_274223:: @ 8274223 Underwater6_EventScript_274223:: @ 8274223 Underwater7_EventScript_274223:: @ 8274223 - switch VAR_0x4037 - case 9, Underwater3_EventScript_274281 - case 10, Underwater3_EventScript_27428A - case 11, Underwater3_EventScript_274293 - case 12, Underwater3_EventScript_27429C - case 13, Underwater3_EventScript_2742A5 - case 14, Underwater3_EventScript_2742AE - case 15, Underwater3_EventScript_2742B7 - case 16, Underwater3_EventScript_2742C0 + switch VAR_UNUSUAL_WEATHER_LOCATION + case UNUSUAL_WEATHER_ROUTE_105_NORTH, Underwater3_EventScript_274281 + case UNUSUAL_WEATHER_ROUTE_105_SOUTH, Underwater3_EventScript_27428A + case UNUSUAL_WEATHER_ROUTE_125_WEST, Underwater3_EventScript_274293 + case UNUSUAL_WEATHER_ROUTE_125_EAST, Underwater3_EventScript_27429C + case UNUSUAL_WEATHER_ROUTE_127_NORTH, Underwater3_EventScript_2742A5 + case UNUSUAL_WEATHER_ROUTE_127_SOUTH, Underwater3_EventScript_2742AE + case UNUSUAL_WEATHER_ROUTE_129_WEST, Underwater3_EventScript_2742B7 + case UNUSUAL_WEATHER_ROUTE_129_EAST, Underwater3_EventScript_2742C0 return Underwater3_EventScript_274281:: @ 8274281 diff --git a/data/maps/Route105/scripts.inc b/data/maps/Route105/scripts.inc index 6ad11bc52..74416f153 100644 --- a/data/maps/Route105/scripts.inc +++ b/data/maps/Route105/scripts.inc @@ -6,9 +6,9 @@ Route105_MapScripts:: @ 81EE1DB Route105_MapScript1_1EE1EB: @ 81EE1EB call_if_unset FLAG_REGI_DOORS_OPENED, Route105_EventScript_1EE20B - compare VAR_0x4037, 9 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_NORTH call_if_eq Route105_EventScript_2739AB - compare VAR_0x4037, 10 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_SOUTH call_if_eq Route105_EventScript_273A18 end @@ -20,9 +20,9 @@ Route105_EventScript_1EE20B:: @ 81EE20B Route105_MapScript1_1EE21E: @ 81EE21E compare VAR_0x4039, 1 call_if_eq Route105_EventScript_273D13 - compare VAR_0x4037, 9 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_NORTH call_if_eq Route105_EventScript_273D17 - compare VAR_0x4037, 10 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_SOUTH call_if_eq Route105_EventScript_273D17 end diff --git a/data/maps/Route114/scripts.inc b/data/maps/Route114/scripts.inc index d4327a2f4..856a0f1e4 100644 --- a/data/maps/Route114/scripts.inc +++ b/data/maps/Route114/scripts.inc @@ -7,16 +7,16 @@ Route114_MapScripts:: @ 81F252F Route114_MapScript1_1F253F: @ 81F253F compare VAR_0x4039, 1 call_if_eq Route114_EventScript_273D13 - compare VAR_0x4037, 1 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_NORTH call_if_eq Route114_EventScript_273D1B - compare VAR_0x4037, 2 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_SOUTH call_if_eq Route114_EventScript_273D1B end Route114_MapScript1_1F2561: @ 81F2561 - compare VAR_0x4037, 1 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_NORTH call_if_eq Route114_EventScript_273913 - compare VAR_0x4037, 2 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_SOUTH call_if_eq Route114_EventScript_273926 end diff --git a/data/maps/Route115/scripts.inc b/data/maps/Route115/scripts.inc index 9cb3ea2e0..42cf643af 100644 --- a/data/maps/Route115/scripts.inc +++ b/data/maps/Route115/scripts.inc @@ -5,18 +5,18 @@ Route115_MapScripts:: @ 81F2920 .byte 0 Route115_MapScript1_1F2930: @ 81F2930 - compare VAR_0x4037, 3 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_WEST call_if_eq Route115_EventScript_273939 - compare VAR_0x4037, 4 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_EAST call_if_eq Route115_EventScript_27394C end Route115_MapScript1_1F2947: @ 81F2947 compare VAR_0x4039, 1 call_if_eq Route115_EventScript_273D13 - compare VAR_0x4037, 3 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_WEST call_if_eq Route115_EventScript_273D1B - compare VAR_0x4037, 4 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_EAST call_if_eq Route115_EventScript_273D1B end diff --git a/data/maps/Route116/scripts.inc b/data/maps/Route116/scripts.inc index 90ae29f5b..afb0505c8 100644 --- a/data/maps/Route116/scripts.inc +++ b/data/maps/Route116/scripts.inc @@ -8,9 +8,9 @@ Route116_MapScript1_1F2C1C: @ 81F2C1C call_if_set FLAG_RECOVERED_DEVON_GOODS, Route116_EventScript_1F2C47 compare VAR_0x4039, 1 call_if_eq Route116_EventScript_273D13 - compare VAR_0x4037, 5 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_NORTH call_if_eq Route116_EventScript_273D1B - compare VAR_0x4037, 6 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_SOUTH call_if_eq Route116_EventScript_273D1B end @@ -19,9 +19,9 @@ Route116_EventScript_1F2C47:: @ 81F2C47 return Route116_MapScript1_1F2C4F: @ 81F2C4F - compare VAR_0x4037, 5 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_NORTH call_if_eq Route116_EventScript_27395F - compare VAR_0x4037, 6 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_SOUTH call_if_eq Route116_EventScript_273972 end diff --git a/data/maps/Route118/scripts.inc b/data/maps/Route118/scripts.inc index 758804137..88c4e1275 100644 --- a/data/maps/Route118/scripts.inc +++ b/data/maps/Route118/scripts.inc @@ -8,16 +8,16 @@ Route118_MapScript1_1F3DCC: @ 81F3DCC call Route118_EventScript_28CCC7 compare VAR_0x4039, 1 call_if_eq Route118_EventScript_273D13 - compare VAR_0x4037, 7 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_EAST call_if_eq Route118_EventScript_273D1B - compare VAR_0x4037, 8 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_WEST call_if_eq Route118_EventScript_273D1B end Route118_MapScript1_1F3DF3: @ 81F3DF3 - compare VAR_0x4037, 7 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_EAST call_if_eq Route118_EventScript_273985 - compare VAR_0x4037, 8 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_WEST call_if_eq Route118_EventScript_273998 end diff --git a/data/maps/Route119_WeatherInstitute_2F/scripts.inc b/data/maps/Route119_WeatherInstitute_2F/scripts.inc index 7d557fdef..2eaeceb2f 100644 --- a/data/maps/Route119_WeatherInstitute_2F/scripts.inc +++ b/data/maps/Route119_WeatherInstitute_2F/scripts.inc @@ -137,11 +137,13 @@ Route119_WeatherInstitute_2F_EventScript_2700F7:: @ 82700F7 end Route119_WeatherInstitute_2F_EventScript_27010A:: @ 827010A + @ This code uses VAR_0x8004 to count the number of legendaries the player has defeated + @ already. setvar VAR_0x8004, 0 - call_if_set FLAG_DEFEATED_KYOGRE, Route119_WeatherInstitute_2F_EventScript_270160 - call_if_set FLAG_DEFEATED_GROUDON, Route119_WeatherInstitute_2F_EventScript_270160 + call_if_set FLAG_DEFEATED_KYOGRE, WeatherInstitute_UnusualWeather_IncrementLegendCount + call_if_set FLAG_DEFEATED_GROUDON, WeatherInstitute_UnusualWeather_IncrementLegendCount compare VAR_0x8004, 2 - goto_if_eq Route119_WeatherInstitute_2F_EventScript_270166 + goto_if_eq WeatherInstitute_UnusualWeather_LegendariesAlreadyDefeated call_if_unset FLAG_TEMP_2, Route119_WeatherInstitute_2F_EventScript_270159 specialvar VAR_RESULT, sub_813B374 compare VAR_RESULT, 1 @@ -156,16 +158,16 @@ Route119_WeatherInstitute_2F_EventScript_27014F:: @ 827014F end Route119_WeatherInstitute_2F_EventScript_270159:: @ 8270159 - special sub_813B2E4 + special CreateUnusualWeatherEvent setflag FLAG_TEMP_2 return -Route119_WeatherInstitute_2F_EventScript_270160:: @ 8270160 +WeatherInstitute_UnusualWeather_IncrementLegendCount:: @ 8270160 addvar VAR_0x8004, 1 return -Route119_WeatherInstitute_2F_EventScript_270166:: @ 8270166 - msgbox Route119_WeatherInstitute_2F_Text_2708FC, MSGBOX_DEFAULT +WeatherInstitute_UnusualWeather_LegendariesAlreadyDefeated:: @ 8270166 + msgbox WeatherInstitute_UnusualWeather_LegendariesAlreadyDefeatedText, MSGBOX_DEFAULT release end @@ -325,7 +327,7 @@ Route119_WeatherInstitute_2F_Text_270873: @ 8270873 .string "Could that mean, somewhere near\n" .string "{STR_VAR_1}…$" -Route119_WeatherInstitute_2F_Text_2708FC: @ 82708FC +WeatherInstitute_UnusualWeather_LegendariesAlreadyDefeatedText: @ 82708FC .string "Abnormal weather conditions are\n" .string "no longer being reported.\p" .string "The occasional rainfall is a blessing,\n" diff --git a/data/maps/Route125/scripts.inc b/data/maps/Route125/scripts.inc index 4812b9691..d1046e6a4 100644 --- a/data/maps/Route125/scripts.inc +++ b/data/maps/Route125/scripts.inc @@ -8,16 +8,16 @@ Route125_MapScript1_1F6758: @ 81F6758 call_if_set FLAG_SYS_WEATHER_CTRL, Common_EventScript_SetWeather15 compare VAR_0x4039, 1 call_if_eq Route125_EventScript_273D13 - compare VAR_0x4037, 11 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_WEST call_if_eq Route125_EventScript_273D17 - compare VAR_0x4037, 12 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_EAST call_if_eq Route125_EventScript_273D17 end Route125_MapScript1_1F6783: @ 81F6783 - compare VAR_0x4037, 11 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_WEST call_if_eq Route125_EventScript_273A85 - compare VAR_0x4037, 12 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_EAST call_if_eq Route125_EventScript_273AF2 end diff --git a/data/maps/Route127/scripts.inc b/data/maps/Route127/scripts.inc index 7d5eee844..9f2018e8f 100644 --- a/data/maps/Route127/scripts.inc +++ b/data/maps/Route127/scripts.inc @@ -8,16 +8,16 @@ Route127_MapScript1_1F69E9: @ 81F69E9 call_if_set FLAG_SYS_WEATHER_CTRL, Common_EventScript_SetWeather15 compare VAR_0x4039, 1 call_if_eq Route127_EventScript_273D13 - compare VAR_0x4037, 13 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_NORTH call_if_eq Route127_EventScript_273D17 - compare VAR_0x4037, 14 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_SOUTH call_if_eq Route127_EventScript_273D17 end Route127_MapScript1_1F6A14: @ 81F6A14 - compare VAR_0x4037, 13 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_NORTH call_if_eq Route127_EventScript_273B5F - compare VAR_0x4037, 14 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_SOUTH call_if_eq Route127_EventScript_273BCC end diff --git a/data/maps/Route129/scripts.inc b/data/maps/Route129/scripts.inc index 8aec4bc28..5f65712d7 100644 --- a/data/maps/Route129/scripts.inc +++ b/data/maps/Route129/scripts.inc @@ -5,9 +5,9 @@ Route129_MapScripts:: @ 81F7284 .byte 0 Route129_MapScript1_1F7294: @ 81F7294 - compare VAR_0x4037, 15 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_WEST call_if_eq Route129_EventScript_273C39 - compare VAR_0x4037, 16 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_EAST call_if_eq Route129_EventScript_273CA6 end @@ -16,9 +16,9 @@ Route129_MapScript1_1F72AB: @ 81F72AB call_if_eq Route129_EventScript_273D13 compare VAR_0x405E, 4 call_if_ge Route129_EventScript_1F72D8 - compare VAR_0x4037, 15 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_WEST call_if_eq Route129_EventScript_273D17 - compare VAR_0x4037, 16 + compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_EAST call_if_eq Route129_EventScript_273D17 end diff --git a/data/specials.inc b/data/specials.inc index 965bef117..193af9e86 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -499,7 +499,7 @@ gSpecials:: @ 81DBA64 def_special sub_813B21C def_special SetMatchCallRegisteredFlag def_special sub_8175280 - def_special sub_813B2E4 + def_special CreateUnusualWeatherEvent def_special sub_813B374 def_special sub_813B490 def_special sub_80A08CC diff --git a/include/constants/flags.h b/include/constants/flags.h index b440ba78b..f0759389f 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -236,7 +236,7 @@ #define FLAG_MET_WAILMER_TRAINER 0xDA #define FLAG_EVIL_LEADER_PLEASE_STOP 0xDB -#define FLAG_UNUSED_0x0DC 0xDC // Unused Flag +#define FLAG_NEVER_SET_0x0DC 0xDC // This flag is read, but never written to #define FLAG_RECEIVED_GO_GOGGLES 0xDD #define FLAG_WINGULL_SENT_ON_ERRAND 0xDE diff --git a/include/constants/vars.h b/include/constants/vars.h index fc3b3263d..9f364416c 100644 --- a/include/constants/vars.h +++ b/include/constants/vars.h @@ -60,7 +60,7 @@ #define VAR_POISON_STEP_COUNTER 0x402B #define VAR_RESET_RTC_ENABLE 0x402C #define VAR_ENIGMA_BERRY_AVAILABLE 0x402D -#define VAR_0x402E 0x402E // Seems to be unused. +#define VAR_UNUSED_0x402E 0x402E // Unused Var #define VAR_FRONTIER_MANIAC_FACILITY 0x402F #define VAR_FRONTIER_GAMBLER_FACILITY 0x4030 @@ -71,7 +71,7 @@ #define VAR_DEOXYS_ROCK_STEP_COUNT 0x4034 #define VAR_DEOXYS_ROCK_LEVEL 0x4035 #define VAR_STORAGE_UNKNOWN 0x4036 -#define VAR_0x4037 0x4037 +#define VAR_UNUSUAL_WEATHER_LOCATION 0x4037 #define VAR_0x4038 0x4038 #define VAR_0x4039 0x4039 #define VAR_0x403A 0x403A diff --git a/include/constants/weather.h b/include/constants/weather.h index d62e07474..b01cfb390 100644 --- a/include/constants/weather.h +++ b/include/constants/weather.h @@ -37,4 +37,30 @@ #define COORD_EVENT_WEATHER_ROUTE119_CYCLE 20 #define COORD_EVENT_WEATHER_ROUTE123_CYCLE 21 +// These are the "unusual weather events" that are used +// to find Kyogre and Groudon. +#define UNUSUAL_WEATHER_COUNT_PER_LEGENDARY 8 +#define UNUSUAL_WEATHER_GROUDON_LOCATIONS_START 1 +#define UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START 1 + UNUSUAL_WEATHER_COUNT_PER_LEGENDARY + +#define UNUSUAL_WEATHER_NONE 0 +// Groudon locations +#define UNUSUAL_WEATHER_ROUTE_114_NORTH 1 +#define UNUSUAL_WEATHER_ROUTE_114_SOUTH 2 +#define UNUSUAL_WEATHER_ROUTE_115_WEST 3 +#define UNUSUAL_WEATHER_ROUTE_115_EAST 4 +#define UNUSUAL_WEATHER_ROUTE_116_NORTH 5 +#define UNUSUAL_WEATHER_ROUTE_116_SOUTH 6 +#define UNUSUAL_WEATHER_ROUTE_118_EAST 7 +#define UNUSUAL_WEATHER_ROUTE_118_WEST 8 +// Kyogre locations +#define UNUSUAL_WEATHER_ROUTE_105_NORTH 9 +#define UNUSUAL_WEATHER_ROUTE_105_SOUTH 10 +#define UNUSUAL_WEATHER_ROUTE_125_WEST 11 +#define UNUSUAL_WEATHER_ROUTE_125_EAST 12 +#define UNUSUAL_WEATHER_ROUTE_127_NORTH 13 +#define UNUSUAL_WEATHER_ROUTE_127_SOUTH 14 +#define UNUSUAL_WEATHER_ROUTE_129_WEST 15 +#define UNUSUAL_WEATHER_ROUTE_129_EAST 16 + #endif // GUARD_CONSTANTS_WEATHER_H diff --git a/src/field_specials.c b/src/field_specials.c index 307f81399..1accaa5e5 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -3421,28 +3421,28 @@ bool8 sub_813B260(void) return FALSE; } -void sub_813B2E4(void) +void CreateUnusualWeatherEvent(void) { u16 randomValue = Random(); VarSet(VAR_0x4038, 0); if (FlagGet(FLAG_DEFEATED_KYOGRE) == TRUE) { - VarSet(VAR_0x4037, (randomValue & 7) + 1); + VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue & (UNUSUAL_WEATHER_COUNT_PER_LEGENDARY - 1)) + UNUSUAL_WEATHER_GROUDON_LOCATIONS_START); } else if (FlagGet(FLAG_DEFEATED_GROUDON) == TRUE) { - VarSet(VAR_0x4037, (randomValue & 7) + 9); + VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue & (UNUSUAL_WEATHER_COUNT_PER_LEGENDARY - 1)) + UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START); } else if ((randomValue & 1) == 0) { randomValue = Random(); - VarSet(VAR_0x4037, (randomValue & 7) + 1); + VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue & (UNUSUAL_WEATHER_COUNT_PER_LEGENDARY - 1)) + UNUSUAL_WEATHER_GROUDON_LOCATIONS_START); } else { randomValue = Random(); - VarSet(VAR_0x4037, (randomValue & 7) + 9); + VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue & (UNUSUAL_WEATHER_COUNT_PER_LEGENDARY - 1)) + UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START); } } @@ -3450,7 +3450,7 @@ bool32 sub_813B374(void) { static const u8 gUnknown_085B3400[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c }; - u16 var = VarGet(VAR_0x4037); + u16 var = VarGet(VAR_UNUSUAL_WEATHER_LOCATION); GetMapName(gStringVar1, gUnknown_085B3400[var - 1], 0); @@ -3466,12 +3466,12 @@ bool32 sub_813B374(void) bool8 sub_813B3B0(void) { - static const u8 gUnknown_085B3410[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c }; + static const u8 sUnusualWeatherMapNumbers[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c }; u16 var1 = VarGet(VAR_0x4038); - u16 var2 = VarGet(VAR_0x4037); + u16 unusualWeather = VarGet(VAR_UNUSUAL_WEATHER_LOCATION); - if (!var2) + if (unusualWeather == UNUSUAL_WEATHER_NONE) { return FALSE; } @@ -3510,14 +3510,14 @@ bool8 sub_813B3B0(void) } } - if (gSaveBlock1Ptr->location.mapNum == gUnknown_085B3410[var2 - 1] && + if (gSaveBlock1Ptr->location.mapNum == sUnusualWeatherMapNumbers[unusualWeather - 1] && gSaveBlock1Ptr->location.mapGroup == 0) { return TRUE; } else { - VarSet(VAR_0x4037, 0); + VarSet(VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_NONE); return FALSE; } } diff --git a/src/match_call.c b/src/match_call.c index e7e91969f..de1181e8b 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1016,7 +1016,7 @@ static bool32 MapAllowsMatchCall(void) if (gMapHeader.regionMapSectionId == MAPSEC_SOOTOPOLIS_CITY && FlagGet(FLAG_HIDE_SOOTOPOLIS_CITY_RAYQUAZA) == TRUE - && FlagGet(FLAG_UNUSED_0x0DC) == FALSE) + && FlagGet(FLAG_NEVER_SET_0x0DC) == FALSE) return FALSE; if (gMapHeader.regionMapSectionId == MAPSEC_MT_CHIMNEY diff --git a/src/overworld.c b/src/overworld.c index a10d1e17a..edc4d402c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -411,7 +411,7 @@ static void Overworld_ResetStateAfterWhiteOut(void) if (VarGet(VAR_0x4039) == 1) { VarSet(VAR_0x4039, 0); - VarSet(VAR_0x4037, 0); + VarSet(VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_NONE); } } diff --git a/src/region_map.c b/src/region_map.c index ff0c19167..5c85606a8 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1159,7 +1159,7 @@ static u16 RegionMap_GetTerraCaveMapSecId(void) { s16 idx; - idx = VarGet(VAR_0x4037) - 1; + idx = VarGet(VAR_UNUSUAL_WEATHER_LOCATION) - 1; if (idx < 0 || idx > 15) { idx = 0; @@ -1171,7 +1171,7 @@ static void RegionMap_GetMarineCaveCoords(u16 *x, u16 *y) { u16 idx; - idx = VarGet(VAR_0x4037); + idx = VarGet(VAR_UNUSUAL_WEATHER_LOCATION); if (idx < 9 || idx > 16) { idx = 9;