WorldMgr: Difference between revisions

From ZeldaMods (Breath of the Wild)
Jump to navigation Jump to search
imported>Leoetlino
imported>Leoetlino
Line 118: Line 118:
* If the timer is >= 360.0, which means that a day has passed, the game subtracts 360 from the timer.
* If the timer is >= 360.0, which means that a day has passed, the game subtracts 360 from the timer.


'''Note''': The blood moon timer is never updated, and the current value is not checked either in this state.  
'''Note''': In this state, the blood moon timer is never updated and its value is never checked either.  
|}
|}



Revision as of 15:46, 30 October 2018

WorldMgr
Subsystem
Official name Yes
Description Manages world state (time, blood moons, climates, weather, etc.)
Init function Switch 1.5.0: 00000071010F2920
Wii U 1.5.0: ???
Debug only No

The World Manager (WorldMgr) is responsible for managing time, blood moons, climates, weather, fog, wind, lighting, procedural generation of clouds, whether the Lord of the Mountain appears, etc.

Because of the massive amount of state to handle, functionality is split across the main WorldMgr and 9 sub-managers.

WorldMgr

Sub-managers

Sub-managers are created in WorldMgr::init (0x71010F43C0) and inserted into a pointer array (@WorldMgr+0x5c0). All names below are unofficial.

Sub-managers by ID
ID Description
0 TimeMgr
1 CloudPr? Handles cloud procedural generation.
2 ???
3 Weather? Handles "rain splash" and climate weathers.
4 TemperatureMgr? (Reasonably sure about this one.)
5 ???
6 Sky and fog? Holds the configuration for all EnvPalettes, EnvAttributes, WeatherInfluences, Remains palettes, Indoor palettes and dungeon fogs.
7 DofMgr? Holds depth of field related parameters.
8 ??? (contains a BaseProcLink, so it might have something to do with actors.)

TimeMgr

TimeMgr handles everything to do with time, including Blood Moons and the Lord of the Mountain's apparition.

Internally, time of day is stored as a float in the [0.0, 360.0] range.

TimeMgr::init

  • Time is set to 78.75 (05:15).
  • Time for TotS environment is set to 78.75 (05:15) as well.
  • "Bloody Moon end reserve timer" is set to 0.

TimeMgr::reset

This is called whenever a stage is unloaded (essentially every time the loading screen is shown).

  • Blood Moon checks are delayed.
  • The AnimalMaster_Appearance flag is cleared, meaning the Lord of the Mountain will not appear.

TimeMgr::calc

This is called every frame.

  • If both Demo103_0 and Demo997_0 have not been played, time of day is reset to 78.75 (05:15).
  • If AIDef:Action/AdvanceTime or anything else that changes time of day was called, the actual time is updated at this moment.
  • #Midnight checks.
  • Update time of day: there are several possible update modes. In most cases, the update mode is 0.
Mode Description
0 If Demo103_0 or Demo997_0 have been played, and if there is no active event (cutscene):
  • Add (0.0083333 * elapsed frames) to the Time of Day timer. Effectively, this means that 1 in-game minute = 1 real-life second.
  • If the timer is >= 360.0, which means that a day has passed, the game subtracts 360 from the timer and then performs midnight checks.
  • If FindDungeon_Activated is false (if the player hasn't received the The Isolated Plateau quest) and if the current time is >= 165.0 (11:00), the time is forcefully set to 11:00. Effectively, this means that time will not get past 11:00 until the Great Plateau Tower is activated.
  • The Blood Moon timer is updated too.
1, 13, 35 Freeze time to 04:00
2, 14 Freeze time to 05:00
3, 16, 36 Freeze time to 07:00
4, 19, 37 Freeze time to 10:00
5, 26, 39 Freeze time to 17:00
6, 28, 40 Freeze time to 19:00
7, 30, 41 Freeze time to 21:00
8, 11 Freeze time to 02:00
9, 42 Freeze time to 00:00
10 Freeze time to 01:00
12 Freeze time to 03:00
15 Freeze time to 06:00
17 Freeze time to 08:00
18 Freeze time to 09:00
20 Freeze time to 11:00
21 Freeze time to 12:00
22, 38 Freeze time to 13:00
23 Freeze time to 14:00
24 Freeze time to 15:00
25 Freeze time to 16:00
27 Freeze time to 18:00
29 Freeze time to 20:00
31 Freeze time to 22:00
32 Freeze time to 23:00
34
  • Add (0.0083333 * elapsed frames) to the Time of Day timer.
  • If the timer is >= 360.0, which means that a day has passed, the game subtracts 360 from the timer.

Note: In this state, the blood moon timer is never updated and its value is never checked either.

Midnight checks

The following actions happen every time the timer reaches 360.0 (midnight).

WM_NumberOfDays is incremented.

If a Blood Moon is scheduled (WM_BloodyDay is true):

  • If Blood Moons are prohibited (see conditions below), set the Blood Moon timer to 2880.0.
  • If they are allowed to happen, call Demo011_0 and set the Blood Moon timer to 0.0.

Scheduling new Blood Moons:

  • If the FirstTouchdown flag is set (i.e. if the player has left the Great Plateau), and if the Blood Moon timer is > 2520.0 (7 in-game days):
    • WM_BloodyDay is set to true, which means that a Blood Moon is scheduled for the next night.
    • The Blood Moon timer is reset to 0.0.
  • Otherwise, the "Bloody end reserve timer" is set to 150. This ensures that the WM_BloodyDay flag is cleared 5 in-game minutes (= 5 seconds in real life) after a Blood Moon occurs.

Blood Moon inhibitors

If any of the following conditions are true, the Blood Moon cutscene will not be triggered.

  • Not on MainField (main overworld)
  • IsInHyruleCastleArea is set
  • LastBossGanonBeastGenerateFlag is set (fighting Dark Beast Ganon)
  • BloodyMoonProhibition is set
  • Wind_Relic_BattleStart is set (Vah Medoh battle)
  • Electric_Relic_Battle is set (Vah Naboris battle)
  • Water_Relic_BattleTime is set (Vah Ruta battle)
  • SkyMgr's field_2B4 is set to 15 and field_2B8 >= 1.0

Day/night time flag

From 00:00 to 06:00 (closed interval) and from 18:00 to 00:00 (closed interval), WM_DaytimeFlag is set to false and WM_NighttimeFlag is true.

In any other case, WM_DaytimeFlag is set to true and WM_NighttimeFlag to false.

Time division, IsMorning, IsNoon, etc.

Start End Division Flag
04:00 07:00 0 WM_IsMorningA
07:00 10:00 1 WM_IsMorningB
10:00 13:00 2 WM_IsNoonA
13:00 17:00 3 WM_IsNoonB
17:00 19:00 4 WM_IsEveningA
19:00 21:00 5 WM_IsEveningB
21:00 00:00 6 WM_IsNightA
00:00 04:00 7 WM_IsNightB

Note: all intervals include the start time and exclude the end time.

Lord of the Mountain