diff --git a/constants/weather_constants.asm b/constants/weather_constants.asm index 756814e6b..88e1c0dcd 100644 --- a/constants/weather_constants.asm +++ b/constants/weather_constants.asm @@ -12,3 +12,5 @@ DEF NUM_OW_WEATHERS EQU const_value - 1 const OW_WEATHER_DO_FLY_F ; 0 const OW_WEATHER_DISABLED_F ; 1 const OW_WEATHER_LIGHTNING_DISABLED_F ; 2 + +DEF NUM_WEATHER_MAPS_PER_DAY EQU 2 \ No newline at end of file diff --git a/engine/events/weather.asm b/engine/events/weather.asm index a90d6224a..0f37d2107 100644 --- a/engine/events/weather.asm +++ b/engine/events/weather.asm @@ -43,6 +43,18 @@ SetCurrentWeather:: ld c, a ld a, [wMapGroup] cp b + jr nz, .check_johto_next_rain + ld a, [wMapNumber] + cp c + jr z, .rain + +.check_johto_next_rain + ld a, [wWeatherRandomMapGroupJohto + 1] + ld b, a + ld a, [wWeatherRandomMapNumberJohto + 1] + ld c, a + ld a, [wMapGroup] + cp b jr nz, .check_kanto_rain ld a, [wMapNumber] cp c @@ -55,10 +67,23 @@ SetCurrentWeather:: ld c, a ld a, [wMapGroup] cp b + jr nz, .check_kanto_next_rain + ld a, [wMapNumber] + cp c + jr z, .rain + +.check_kanto_next_rain + ld a, [wWeatherRandomMapGroupKanto + 1] + ld b, a + ld a, [wWeatherRandomMapNumberKanto + 1] + ld c, a + ld a, [wMapGroup] + cp b jr nz, .not_raining ld a, [wMapNumber] cp c jr z, .rain + .not_raining ld a, OW_WEATHER_NONE jr .set_weather @@ -120,6 +145,9 @@ SetCurrentWeather:: jr .set_weather GenerateNewRandomRainMap: + ; sorry, just kinda hacked this in + assert NUM_WEATHER_MAPS_PER_DAY == 2 + ld a, NUM_JOHTO_WEATHER_MAPS call RandomRange ld h, 0 @@ -132,6 +160,18 @@ GenerateNewRandomRainMap: ld a, [hl] ld [wWeatherRandomMapNumberJohto], a + ld a, NUM_JOHTO_WEATHER_MAPS + call RandomRange + ld h, 0 + ld l, a + add hl, hl + ld de, RandomRainMapsJohto + add hl, de + ld a, [hli] + ld [wWeatherRandomMapGroupJohto + 1], a + ld a, [hl] + ld [wWeatherRandomMapNumberJohto + 1], a + ld a, NUM_KANTO_WEATHER_MAPS call RandomRange ld h, 0 @@ -143,6 +183,18 @@ GenerateNewRandomRainMap: ld [wWeatherRandomMapGroupKanto], a ld a, [hl] ld [wWeatherRandomMapNumberKanto], a + + ld a, NUM_KANTO_WEATHER_MAPS + call RandomRange + ld h, 0 + ld l, a + add hl, hl + ld de, RandomRainMapsKanto + add hl, de + ld a, [hli] + ld [wWeatherRandomMapGroupKanto + 1], a + ld a, [hl] + ld [wWeatherRandomMapNumberKanto + 1], a ret RandomRainMapsJohto: diff --git a/ram/wram.asm b/ram/wram.asm index 5e58ccc9e..954e33896 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -1904,10 +1904,10 @@ wPrevWeather:: db wCurWeather:: db wPrevOvercastIndex:: db wWeatherRandomDay:: db -wWeatherRandomMapGroupJohto:: db -wWeatherRandomMapNumberJohto:: db -wWeatherRandomMapGroupKanto:: db -wWeatherRandomMapNumberKanto:: db +wWeatherRandomMapGroupJohto:: ds NUM_WEATHER_MAPS_PER_DAY +wWeatherRandomMapNumberJohto:: ds NUM_WEATHER_MAPS_PER_DAY +wWeatherRandomMapGroupKanto:: ds NUM_WEATHER_MAPS_PER_DAY +wWeatherRandomMapNumberKanto:: ds NUM_WEATHER_MAPS_PER_DAY SECTION "Fade System Ram", WRAM0