Bas and WorldMgr: Difference between pages

From ZeldaMods (Breath of the Wild)
(Difference between pages)
Jump to navigation Jump to search
imported>Ginger
 
imported>Leoetlino
 
Line 1: Line 1:
{{Stub}}{{Lowercase}}
{{stub}}
<onlyinclude>
{{Subsystem infobox|name=WorldMgr|init_addr_switch150=00000071010F2920|is_name_official=1|description=Manages world state (time, blood moons, climates, weather, etc.)}}
'''bas''' files each represent an animation that can be called by an [[actor]] or [[Demo|cutscene]]. They contain a reference to an animation name, but not the animation file itself. They can be found at '''Actor/AS/{EventName}/{AnimationSequenceName}.bas''' in [[Beventpack|beventpacks]] and [[TitleBG.pack]]/Actor/AS, and '''Actor/AS/{AnimationSequenceName}.bas''' in bactorpacks.
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.
</onlyinclude>


==Layout==
Because of the massive amount of state to handle, functionality is split across the main WorldMgr and 9 sub-managers.
Each bas file is made up of one list of elements, named Elements. Each element (Element0, Element1, etc) can be either a test to figure out what animation to play, or a call to play the animation.


===Parameters===
== WorldMgr ==
All nodes have Parameters, which determine what kind of node they are. They can be a control node, which helps decide which animation to play, or an animation node, which actually plays the animation.
=== Sub-managers ===
{| class="wikitable"
Sub-managers are created in WorldMgr::init (0x71010F43C0) and inserted into a pointer array (@WorldMgr+0x5c0). All names below are unofficial.
!Key
!Key Type
!Description
!Node Type
!Default value
|-
|TypeIndex
|int
|Type of node the Element is. Known types are listed below the table.
| -
| -
|-
|NoSync
|bool
| -
|Control
| -
|-
|JudgeOnce
|bool
|Tells the game to skip evaluating this node (and use the previous result) if the input value has not changed since the last time the node was run.
|Control
|False
|-
|InputLimit
|float
| -
|Control
| -
|-
|FileName
|str64
|Name of the animation to play
|Animation
| -
|-
|Morph
|int
|Time to blend the previous animation into this one. (Whether this is in milliseconds or frames is currently unknown)
|Animation
| -
|-
|}


====Parameter TypeIndexes====
{|class="wikitable"
Nodes with Blender are generally used to perform the same checks as those with Selector in the name, with a key difference: Blender nodes may evaluate multiple cases as true, and will blend the resulting animations together. Selector nodes will choose only the first case that evaluates to true.{{Check}}
|+ Sub-managers by ID
{| class="wikitable"
! ID !! Description
!Index
!Name
!Description
!Type
|-
|-
|0
| 0 || TimeMgr
|AbsTemperatureBlender
|Current world temperature. Evaluated by float range.
|Control
|-
|-
|1
| 1 || CloudPr? Handles cloud procedural generation.
|AbsTemperatureSelector
|Current world temperature. Evaluated by float range.
|Control
|-
|-
|2
| 2 || ShootingStarMgr: Manages shooting stars and (in 1.3.3+) special shooting stars for the Xenoblade 2 quest.
|ArmorSelector
| -
| -
|-
|-
|3
| 3 || Weather? Handles "rain splash" and climate weathers.
|ArrowSelector
| -
| -
|-
|-
|4
| 4 || TemperatureMgr? (Reasonably sure about this one.)
|AttentionSelector
| -
| -
|-
|-
|5
| 5 || ?
|BoneBlender
| -
| -
|-
|-
|6
| 6 || Sky and fog? Holds the configuration for all EnvPalettes, EnvAttributes, WeatherInfluences, Remains palettes, Indoor palettes and dungeon fogs.
|BoneVisibilityAsset
| -
| -
|-
|-
|7
| 7 || DofMgr? Holds depth of field related parameters.
|BoolSelector
|Boolean evaluator - See [[#BitIndex]]{{#tag:ref|Element1 of Player_CutNinja.bas, WiiU 1.5.0|name=e1pcn}}{{#tag:ref|Element0 of Player_FaceDefault.bas, WiiU 1.5.0|name=e0pfd}}{{#tag:ref|Element2 of Player_FaceDefault.bas, WiiU 1.5.0|name=e2pfd}}
|Control
|-
|-
|8
| 8 || ?
|ButtonSelector
|}
| -
 
| -
== 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 field 0x14A is set to 99, WM_BloodyDay is set to true. [[AIDef:Action/SetBloodyMoonEnv]] uses this to force a Blood Moon to be scheduled. This feature appears to be unused.)
* If both [[Demo]]103_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.
{|class="wikitable"
! Mode !! Description
|-
|-
|9
| 0 || If Demo103_0 or Demo997_0 have been played, and if there is no active event (cutscene):
|ChargeSelector
* 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 and the Old Man cutscene is triggered.
* The Blood Moon timer is updated too.
|-
|-
|10
| 1, 13, 35 || Freeze time to 04:00
|ClearMatAnmAsset
| -
| -
|-
|-
|11
| 2, 14 || Freeze time to 05:00
|ComboSelector
| -
| -
|-
|-
|12
| 3, 16, 36 || Freeze time to 07:00
|DiffAngleYBlender
| -
| -
|-
|-
|13
| 4, 19, 37 || Freeze time to 10:00
|DiffAngleYSelector
| -
| -
|-
|-
|14
| 5, 26, 39 || Freeze time to 17:00
|DirectionAngleBlender
|Compares to the movement analog stick's current orientation, in degrees, in counter-clockwise fashion. Accepts -359 to 360. (e.g. 270 and -90 both point directly to the right). Evaluated by float range.
|Control
|-
|-
|15
| 6, 28, 40 || Freeze time to 19:00
|DirectionAngleSelector
|Compares to the movement analog stick's current orientation, in degrees, in counter-clockwise fashion. Accepts -359 to 360. (e.g. 270 and -90 both point directly to the right). Evaluated by float range.
|Control
|-
|-
|16
| 7, 30, 41 || Freeze time to 21:00
|DistanceBlender
|Compares distance between Link and his current locked target{{#tag:ref|Element2 of Player_CutNinja.bas, WiiU 1.5.0|name=e2pcn}}. Evaluated by float range.
|Control
|-
|-
|17
| 8, 11 || Freeze time to 02:00
|DistanceSelector
|Compares distance between Link and his current locked target. Evaluated by float range.
|Control
|-
|-
|18
| 9, 42 || Freeze time to 00:00
|DungeonClearSelector
| -
| -
|-
|-
|19
| 10 || Freeze time to 01:00
|DungeonNumberSelector
| -
| -
|-
|-
|20
| 12 || Freeze time to 03:00
|EmotionSelector
| -
| -
|-
|-
|21
| 15 || Freeze time to 06:00
|EventFlagSelector
| -
| -
|-
|-
|22
| 17 || Freeze time to 08:00
|EyeSelector
| -
| -
|-
|-
|23
| 18 || Freeze time to 09:00
|EyebrowSelector
| -
| -
|-
|-
|24
| 20 || Freeze time to 11:00
|FaceEmotionSelector
| -
| -
|-
|-
|25
| 21 || Freeze time to 12:00
|FootBLLifeSelector
| -
| -
|-
|-
|26
| 22, 38 || Freeze time to 13:00
|FootBRLifeSelector
| -
| -
|-
|-
|27
| 23 || Freeze time to 14:00
|FootFLLifeSelector
| -
| -
|-
|-
|28
| 24 || Freeze time to 15:00
|FootFRLifeSelector
| -
| -
|-
|-
|29
| 25 || Freeze time to 16:00
|ForwardBentBlender
| -
| -
|-
|-
|30
| 27 || Freeze time to 18:00
|ForwardBentSelector
| -
| -
|-
|-
|31
| 29 || Freeze time to 20:00
|GearSelector
| -
| -
|-
|-
|32
| 31 || Freeze time to 22:00
|GenerationSelector
| -
| -
|-
|-
|33
| 32 || Freeze time to 23:00
|GrabTypeSelector
| -
| -
|-
|-
|34
| 34 ||
|GroundNormalBlender
* 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.
|35
|}
|GroundNormalSelector
 
| -
* Update the [[#Day/night time flag]], the [[#Time division, IsMorning, IsNoon, etc.]]
| -
* If the "Bloody Moon end reserve timer" is non zero, decrement it. If the new value is zero, the WM_BloodyDay flag is cleared.
|-
* Update [[#Lord of the Mountain]] flags.
|36
 
|GroundNormalSideBlender
=== Midnight checks ===
| -
The following actions happen every time the timer reaches 360.0 (midnight).
| -
 
|-
WM_NumberOfDays is incremented.
|37
 
|GroundNormalSideSelector
'''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 [https://eventviewer.zeldamods.org/viewer.html?data=/d/Demo011_0.json&params=1 Demo011_0] and set the Blood Moon timer to 0.0.
|-
 
|38
'''Scheduling new Blood Moons''':
|MaskSelector
*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.
|39
 
|MatVisibilityAsset
==== Blood Moon inhibitors ====
| -
If any of the following conditions are true, the Blood Moon cutscene will not be triggered.
| -
 
|-
* Not on MainField (main overworld)
|40
* IsInHyruleCastleArea is set
|MouthSelector
* 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)
|41
* Water_Relic_BattleTime is set (Vah Ruta battle)
|NoAnmAsset
* SkyMgr's field_2B4 is set to 15 and field_2B8 >= 1.0
|Play no animation. Used to cancel evaluation.
 
|Animation
However, these do not prevent the Blood Moon timer from advancing, or the WM_BloodyDay flag from being set.
|-
 
|42
=== Day/night time flag ===
|NoLoopStickAngleBlender
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.
|-
 
|43
=== Time division, IsMorning, IsNoon, etc. ===
|NoLoopStickAngleSelector
{|class="wikitable"
| -
! Start !! End !! Division !! Time type (1) !! Time type (2)
| -
|-
|44
|NodePosSelector
|Compares name of a bone, takes StrRef of the bone name. Unknown how it decides which bone name to compare the StrRef to.{{#tag:ref|Element0 of Player_LadderJump.bas, WiiU 1.5.0|name=e0plj}}
|Control
|-
|45
|PersonalitySelector
| -
| -
|-
|46
|PostureSelector
| -
| -
|-
|47
|PreASSelector
|Compares last played animation name, takes StrRef of animation name. Known to accept two Children to test against, plus a default case, but might accept more or less.
|Control
|-
|48
|PreExclusionRandomSelector
| -
| -
|-
|49
|RandomSelector
|Picks a random node from the given nodes.{{Check}}
|Control
|-
|50
|RideSelector
| -
| -
|-
|51
|RightStickAngleBlender
| -
| -
|-
|52
|RightStickAngleSelector
| -
| -
|-
|53
|RightStickValueBlender
| -
| -
|-
|54
|RightStickValueSelector
| -
| -
|-
|55
|RightStickXBlender
| -
| -
|-
|56
|RightStickXSelector
| -
| -
|-
|57
|RightStickYBlender
| -
| -
|-
|58
|RightStickYSelector
| -
| -
|-
|59
|SelfHeightSelector
| -
| -
|-
|60
|SelfWeightSelector
| -
| -
|-
|61
|SequencePlayContainer
|Float comparison - Unknown{{#tag:ref|Element0 of Player_Move.bas, WiiU 1.5.0|name=e0pm}}
|Control
|-
|62
|ShaderParamAsset
|Plays material animation, takes StrRef of the animation name. Its Extend uses a secondary animation name for unknown purpose.{{#tag:ref|Element1 of Player_SkinColor.bas, WiiU 1.5.0|name=e1psc}}{{#tag:ref|Element2 of Player_SkinColor.bas, WiiU 1.5.0|name=e2psc}}
|Animation
|-
|63
|ShaderParamColorAsset
| -
| -
|-
|64
|ShaderParamTexSRTAsset
|Plays texture transform animation, takes StrRef of the animation name.
|Animation
|-
|65
|SizeBlender
| -
| -
|-
|66
|SizeSelector
| -
| -
|-
|67
|SkeltalAsset
|Plays model animation, takes StrRef of the animation name.
|Animation
|-
|68
|SpeedBlender
|Compares actor's current movement speed. Evaluated by float range.
|Control
|-
|-
|69
| 04:00 || 05:00 || 0 || MorningA || Morning_A1
|SpeedSelector
|Compares actor's current movement speed. Evaluated by float range.
|Control
|-
|-
|70
| 05:00 || 07:00 || 0 || MorningA || Morning_A2
|StickAngleBlender
|Compares the movement analog stick's current orientation, in degrees, in counter-clockwise fashion. Accepts -359 to 360. (e.g. 270 and -90 both point directly to the right). Evaluated by float range.
|Control
|-
|-
|71
| 07:00 || 10:00 || 1 || MorningB || Morning_B
|StickAngleSelector
|Compares the movement analog stick's current orientation, in degrees, in counter-clockwise fashion. Accepts -359 to 360. (e.g. 270 and -90 both point directly to the right). Evaluated by float range.
|Control
|-
|-
|72
| 10:00 || 13:00 || 2 || NoonA || Noon_A
|StickValueBlender
|Range evaluation - Unknown{{#tag:ref|Element0 of Player_SwimAtnMove.bas, WiiU 1.5.0|name=e0psam}}
|Control
|-
|-
|73
| 13:00 || 17:00 || 3 || NoonB || Noon_B
|StickValueSelector
| -
| -
|-
|-
|74
| 17:00 || 19:00 || 4 || EveningA || Evening_A
|StickXBlender
| -
| -
|-
|-
|75
| 19:00 || 21:00 || 5 || EveningB || Evening_B
|StickXSelector
| -
| -
|-
|-
|76
| 21:00 || 00:00 || 6 || NightA || Night_A
|StickYBlender
| -
| -
|-
|77
|StickYSelector
| -
| -
|-
|78
|StressBlender
| -
| -
|-
|79
|StressSelector
| -
| -
|-
|80
|SyncPlayContainer
|Synchronously plays multiple child elements
|Animation
|-
|81
|TemperatureBlender
| -
| -
|-
|82
|TemperatureSelector
|Range evaluation - Unknown{{#tag:ref|Element1 of Player_FaceDefault.bas, WiiU 1.5.0|name=e1pfd}}
|Control
|-
|83
|TexturePatternAsset
| -
| -
|-
|84
|TimeSelector
| -
| -
|-
|85
|TiredBlender
| -
| -
|-
|86
|TiredSelector
| -
| -
|-
|87
|UseItemSelector
| -
| -
|-
|88
|UserAngle2Blender
| -
| -
|-
|89
|UserAngle2Selector
| -
| -
|-
|90
|UserAngleBlender
| -
| -
|-
|91
|UserAngleSelector
| -
| -
|-
|92
|UserSpeedBlender
| -
| -
|-
|93
|UserSpeedSelector
| -
| -
|-
|94
|VariationSelector
| -
| -
|-
|95
|WallAngleBlender
| -
| -
|-
|96
|WallAngleSelector
| -
| -
|-
|97
|WeaponDetailSelector
|Compares actor's equipped weapon subtype (from its bgparamlist [ProfileUser] WeaponSubtype value), takes StrRef of weapon subtype name
|Control
|-
|98
|WeaponSelector
|Compares actor's equipped weapon profile (from its bxml ProfileUser value), takes StrRef of weapon profile name
|Control
|-
|99
|WeatherSelector
| -
| -
|-
|100
|WeightBlender
| -
| -
|-
|101
|WeightSelector
| -
| -
|-
|102
|WindVelocityBlender
| -
| -
|-
|103
|YSpeedBlender
| -
| -
|-
|104
|YSpeedSelector
| -
| -
|-
|105
|ZEx00ExposureBlender
| -
| -
|-
|106
|ZEx00ExposureSelector
| -
| -
|-
|-
| 00:00 || 04:00 || 7 || NightB || Night_B
|}
|}
Note: all intervals include the start time and exclude the end time.
=== Moon type ===
The moon type is calculated based on the number of in-game days (WM_NumberOfDays). The exact formula is <code>(numberOfDays + x + 1) % 8</code><ref>0x71010E8200</ref>, where x is equal to 1 if the current time is > 180.0 (noon) and % is the modulo operator.
If a moon type was set manually (for instance using [[AIDef:Action/EventSetMoonType]]), that value will be used as the moon type.
The moon type is returned by [[AIDef:Query/WhatMoonName]], which some NPC event flows use to check the current moon phase. However, the moon schedule has nothing to do with the blood moon schedule.


===Children===
=== Lord of the Mountain ===
Control nodes will have Children, in addition to Parameters, which determine which Element to go to after the control node is evaluated. The properties of Children will be named Child0, Child1, etc, and each will have a single integer value, which will correspond to the Element number. e.g. <code>Child0: 7</code> points to Element7.
The Lord of the Mountain appears whenever the AnimalMaster_Appearance flag is set. Its value is managed by a simple state machine.


===Extend===
Note that whenever a stage is unloaded, the AnimalMaster_Appearance flag is reset to false.
All nodes have an Extend, which contains specific details about the node. Control node Extends will contain details about the comparison being performed, while animation nodes will contain information about the animation being played, such as: during which frames of the animation a weapon will deal damage if it hits something, when user input is ignored, when to draw weapon trails through the air for attack animations, etc.


====Typed Array====
====State 0 - Wait for conditions====
A list of variables of a given type to use for various control comparisons. Corresponds directly to the Children of the node. i.e. if Value0 matches the value being compared against, the code will jump to the Element listed under Child0. If no comparison of a lower Child number has evaluated as true, automatically evaluates a Child whose value is "default" as true.{{#tag:ref|Element0 of Player_CutNinja.bas, WiiU 1.5.0|name=e0pcn}}{{#tag:ref|Element3 of Player_FaceDefault.bas, WiiU 1.5.0|name=e3pfd}}
If the following three conditions are true:
* The [[#Moon type]] is 5 (waxing crescent)
* The AnimalMaster_Existence flag is false (the LotM must not already be spawned)
* The current [[map area]] number is not 64 ("HyruleHill", presumably the Satori Mountain area)


====BitIndex====
then the game generates a random "appearance hour" in the [0 .. 22] interval and goes into state 1.
Used with BoolSelector Parameters. Also has TypeIndex, which are used to perform the check.


*2 - Unknown (believed to check if Link has any armor equipped)<ref name="e0pfd" />
====State 1 - Wait for the appearance time====
*30 - Whether or not Link has a shield equipped.<ref name="e1pcn" />
If the player is in map area 64, the state is reset back to 0.
*33 - Unknown<ref name="e2pfd" />
*37 - Whether IsBlunt is set to true in the equipped weapon’s bgparamlist
*46 - Unknown (believed to check if Link is crouched)


====Ranges====
Otherwise, the game does nothing until the current hour matches the previously generated appearance hour, at which point it sets AnimalMaster_Appearance to true (which allows the LotM to spawn) and goes into state 2.
Used with control nodes that perform a Range evaluation. If the value being compared is above the Start value and below the End value, evaluates as true. Otherwise, moves on to the next value. (Unknown what happens if none of the Ranges evaluate to true, presumably game crash)


====FrameCtrl====
====State 2====
Used with animation nodes. The node itself is required, even if it is empty (i.e. none of the keys are specified)
After one hour has elapsed, the current day of the week is stored and the state is set to 3.
{| class="wikitable"
 
!Key
====State 3====
!Type
After two week day changes, ''or'' [after the in-game day of the week changes and the current hour is >= the generated appearance hour], the LotM will disappear and the state will be set to 4.
!Description
 
!Default value
====State 4====
|-
The game waits for the moon type to be 5, before going back to state 0.
|Rate
|float
|Speed at which to play the animation. Higher numbers are faster.
|1.0
|-
|EndFrame
|int
| -
| -
|-
|}


====TriggerEvents====
== WeatherMgr ==
Used with Parameter TypeIndex 67. Possibly used with other animation node TypeIndexes, but none have so far been observed. Events which are triggered during this animation.
{{expand section}}
{| class="wikitable"
=== Weather types ===
!Key
{|class="wikitable"
!Type
! Value !! Name
!Description
!Default value
|-
|-
|TypeIndex
| 0 || Bluesky
|int
|Which type of event to fire. Known events are detailed below
| -
|-
|-
|Frame
| 1 || Cloudy
|int
|Which frame to fire the event on, relative to the frame numbers of the animation. Can be negative.
| -
|-
|-
|Value
| 2 || Rain
|strRef
| -
| -
|-
|-
|}
| 3 || HeavyRain
Known TypeIndex values:
 
*0 - Unknown (believed to define when an attack begins to deal damage)<ref>Compare Event0 of TriggerEvents and Event0 of HoldEvents for most of Link's attack animations</ref>
*4 - Triggers the animation controller to transition back into the idle stance. The Frame value should be a few before the end of the actual animation, so that the controller can make the blending look natural.<ref>Compare TriggerEvent TypeIndex 4 Frame value for an animation with the number of frames in the actual animation.</ref>
*7 - Call AS. Passes the strRef to the ASList to retrieve an AS file and starts evaluating it from Element0.
*28 - Play audio. Only observed with PV%03d as the value, which corresponds to bfwav files in PlayerVoice.bars, but is believed to be able to play other audio files as well.
 
====HoldEvents====
Used with Parameter TypeIndex 67. Possibly used with other animation node TypeIndexes, but none have so far been observed. States that are entered into while the animation is playing.
{| class="wikitable"
!Key
!Type
!Description
!Default value
|-
|-
|TypeIndex
| 4 || Snow
|int
|Which type of event to fire. Known events are detailed below
| -
|-
|-
|StartFrame
| 5 || HeavySnow
|int
|Which frame to start the event on, relative to the frame numbers of the animation. Unknown if it can be negative.
| -
|-
|-
|EndFrame
| 6 || ThunderStorm
|int
|Which frame to end the event on, relative to the frame numbers of the animation. A value of -1 is treated as the ending frame of the animation.
| -
|-
|-
|Value
| 7 || ThunderRain
|strRef
| -
| -
|-
|-
| 8 || BlueskyRain
|}
|}
Known TypeIndex values:
*0 - Unknown
*2 - Unknown
*3 - Defines when an attack will deal damage. Value is the damage type. Left: slashing. Stab: piercing. Lower: blunt. {{Check}}
*17 - Unknown
*25 - Unknown
*45 - Defines when to accept input to start the next attack.
*48 - Defines when to display the trails in the air during an attack.


===References===
[[Category:Internals]]
[[Category:File extensions]]
[[Category:Subsystems (BotW)]]
[[Category:File extensions (AAMP)]]
[[Category:Actor parameter files]]
<references />

Revision as of 10:25, 11 November 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 ShootingStarMgr: Manages shooting stars and (in 1.3.3+) special shooting stars for the Xenoblade 2 quest.
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 ?

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 field 0x14A is set to 99, WM_BloodyDay is set to true. AIDef:Action/SetBloodyMoonEnv uses this to force a Blood Moon to be scheduled. This feature appears to be unused.)
  • 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 and the Old Man cutscene is triggered.
  • 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

However, these do not prevent the Blood Moon timer from advancing, or the WM_BloodyDay flag from being set.

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 Time type (1) Time type (2)
04:00 05:00 0 MorningA Morning_A1
05:00 07:00 0 MorningA Morning_A2
07:00 10:00 1 MorningB Morning_B
10:00 13:00 2 NoonA Noon_A
13:00 17:00 3 NoonB Noon_B
17:00 19:00 4 EveningA Evening_A
19:00 21:00 5 EveningB Evening_B
21:00 00:00 6 NightA Night_A
00:00 04:00 7 NightB Night_B

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

Moon type

The moon type is calculated based on the number of in-game days (WM_NumberOfDays). The exact formula is (numberOfDays + x + 1) % 8[1], where x is equal to 1 if the current time is > 180.0 (noon) and % is the modulo operator.

If a moon type was set manually (for instance using AIDef:Action/EventSetMoonType), that value will be used as the moon type.

The moon type is returned by AIDef:Query/WhatMoonName, which some NPC event flows use to check the current moon phase. However, the moon schedule has nothing to do with the blood moon schedule.

Lord of the Mountain

The Lord of the Mountain appears whenever the AnimalMaster_Appearance flag is set. Its value is managed by a simple state machine.

Note that whenever a stage is unloaded, the AnimalMaster_Appearance flag is reset to false.

State 0 - Wait for conditions

If the following three conditions are true:

  • The #Moon type is 5 (waxing crescent)
  • The AnimalMaster_Existence flag is false (the LotM must not already be spawned)
  • The current map area number is not 64 ("HyruleHill", presumably the Satori Mountain area)

then the game generates a random "appearance hour" in the [0 .. 22] interval and goes into state 1.

State 1 - Wait for the appearance time

If the player is in map area 64, the state is reset back to 0.

Otherwise, the game does nothing until the current hour matches the previously generated appearance hour, at which point it sets AnimalMaster_Appearance to true (which allows the LotM to spawn) and goes into state 2.

State 2

After one hour has elapsed, the current day of the week is stored and the state is set to 3.

State 3

After two week day changes, or [after the in-game day of the week changes and the current hour is >= the generated appearance hour], the LotM will disappear and the state will be set to 4.

State 4

The game waits for the moon type to be 5, before going back to state 0.

WeatherMgr

Weather types

Value Name
0 Bluesky
1 Cloudy
2 Rain
3 HeavyRain
4 Snow
5 HeavySnow
6 ThunderStorm
7 ThunderRain
8 BlueskyRain
  1. 0x71010E8200