diff options
author | Phlosioneer <mattmdrr2@gmail.com> | 2019-02-27 03:42:04 -0500 |
---|---|---|
committer | Phlosioneer <mattmdrr2@gmail.com> | 2019-02-27 03:42:04 -0500 |
commit | fe55580fe1e51c669033939125c939ed13a555d0 (patch) | |
tree | 2481f3b23d0036393eb9a72fb36cf9c920ce300d /src/field_specials.c | |
parent | 231355f84dccd11329d81d074fa36135cfad4f94 (diff) |
Reverse engineer unusual weather events
Diffstat (limited to 'src/field_specials.c')
-rw-r--r-- | src/field_specials.c | 22 |
1 files changed, 11 insertions, 11 deletions
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; } } |