DayZ 1.24
Loading...
Searching...
No Matches
WorldData.c
Go to the documentation of this file.
1
3{
4 protected float m_DayTemperature; // legacy, no longer used
5 protected float m_NightTemperature; // legacy, no longer used
6 protected Weather m_Weather;
7 protected float m_EnvironmentTemperature;
8 protected float m_Timer;
9 protected float m_MaxTemps[12];
10 protected float m_MinTemps[12];
11 protected float m_Sunrise_Jan;
12 protected float m_Sunset_Jan;
13 protected float m_Sunrise_Jul;
14 protected float m_Sunset_Jul;
15 protected ref array<vector> m_FiringPos; // Where we should fire from. On Init set the relevant data
16
17 void WorldData()
18 {
19 Init();
20 }
21
22 void Init()
23 {
24 m_DayTemperature = 10; // legacy, no longer used
25 m_NightTemperature = 6; // legacy, no longer used
26 m_Weather = g_Game.GetWeather();
28 m_Timer = 0.0;
29 m_Sunrise_Jan = 8.54;
30 m_Sunset_Jan = 15.52;
31 m_Sunrise_Jul = 3.26;
32 m_Sunset_Jul = 20.73;
33 m_MaxTemps = {3, 5, 7, 14, 19, 24, 26, 25, 21, 16, 10, 5};
34 m_MinTemps = {-3, -2, 0, 4, 9, 14, 18, 17, 12, 7, 4, 0};
35 }
36
38 {
39 if (monthday <= 8.0)
40 return ((m_Sunrise_Jan - m_Sunrise_Jul) / (8 - 1)) * (1 - monthday) + m_Sunrise_Jan;
41 else
42 return (((monthday - 8) * (m_Sunrise_Jan - m_Sunrise_Jul)) / (13 - 8)) + m_Sunrise_Jul;
43 }
45 {
46 if (monthday <= 8.0)
47 return ((m_Sunset_Jan - m_Sunset_Jul) / (8 - 1)) * (1 - monthday) + m_Sunset_Jan;
48 else
49 return (((monthday - 8) * (m_Sunset_Jan - m_Sunset_Jul)) / (13 - 8)) + m_Sunset_Jul;
50 }
51 protected float CalcBaseEnvironmentTemperature(float monthday, float daytime)
52 {
56 float nightTime = 24.0 - dayLight;
59 if (tempArrayIndexToLerp >= 12)
68
70 {
71 if (daytime <= (approxSunrise + (dayLight * 0.75)))
72 return Math.Lerp(
75 ((daytime - approxSunrise) / (dayLight * 0.75)));
76 else
77 return Math.Lerp(
80 (((daytime - approxSunrise) - (dayLight * 0.75)) / (dayLight - (dayLight * 0.75))));
81 }
82 else
83 {
84 if ((daytime > approxSunset) && (daytime < 24))
85 return Math.Lerp(
88 ((daytime - approxSunset) / (24 - approxSunset)) / 2.0);
89 else
90 return Math.Lerp(
93 (((daytime + (24 - approxSunset)) / nightTime) / 2.0) + 0.5);
94 }
95 }
97 {
99 if (m_Timer > 30)
100 {
101 int year, month, day, hour, minute;
102 GetGame().GetWorld().GetDate(year, month, day, hour, minute);
104 m_Timer = 0;
105 }
106 }
107
108 // getter for the new base enviro temperature
110 {
112 }
114 {
115 return CalcBaseEnvironmentTemperature(month + (day / 32.0), hour + (minute / 60.0));
116 }
117
118 // legacy, no longer used
120 {
121 return m_DayTemperature;
122 }
123 // legacy, no longer used
125 {
126 return m_NightTemperature;
127 }
128
130 {
131 // default behaviour is same like setting MissionWeather (in Weather) to true
132 return false;
133 }
134
135 // Used to return the artillery firing positions
137 {
138 return m_FiringPos;
139 }
140
141 // debug
142 void BaseTempDebug(int month, int day)
143 {
144 Print("--------------------");
145 for (int i = 0; i < 24; i++)
146 {
147 for (int j = 0; j < 6; j++)
148 {
149 int minute = (j * 10);
150 Print(string.Format("%1:%2 %3", i, minute, GetBaseEnvTemperatureExact(month, day, i, minute)));
151 }
152 }
153 }
154};
DayZGame g_Game
Definition DayZGame.c:3528
EWeatherPhenomenon
Definition Weather.c:11
Definition EnMath.c:7
Keeps information about currently loaded world, like temperature.
Definition WorldData.c:3
float GetApproxSunriseTime(float monthday)
Definition WorldData.c:37
void Init()
Definition WorldData.c:22
float m_Timer
Definition WorldData.c:8
void UpdateBaseEnvTemperature(float timeslice)
Definition WorldData.c:96
float GetNightTemperature()
Definition WorldData.c:124
float m_Sunset_Jan
Definition WorldData.c:12
float GetBaseEnvTemperature()
Definition WorldData.c:109
float m_Sunrise_Jan
Definition WorldData.c:11
float GetDayTemperature()
Definition WorldData.c:119
float m_DayTemperature
Definition WorldData.c:4
bool WeatherOnBeforeChange(EWeatherPhenomenon type, float actual, float change, float time)
Definition WorldData.c:129
float GetApproxSunsetTime(float monthday)
Definition WorldData.c:44
void WorldData()
Definition WorldData.c:17
array< vector > GetArtyFiringPos()
Definition WorldData.c:136
ref array< vector > m_FiringPos
Definition WorldData.c:15
float GetBaseEnvTemperatureExact(int month, int day, int hour, int minute)
Definition WorldData.c:113
float m_MaxTemps[12]
Definition WorldData.c:9
void BaseTempDebug(int month, int day)
Definition WorldData.c:142
float m_MinTemps[12]
Definition WorldData.c:10
float m_EnvironmentTemperature
Definition WorldData.c:7
float m_NightTemperature
Definition WorldData.c:5
Weather m_Weather
Definition WorldData.c:6
float CalcBaseEnvironmentTemperature(float monthday, float daytime)
Definition WorldData.c:51
float m_Sunset_Jul
Definition WorldData.c:14
float m_Sunrise_Jul
Definition WorldData.c:13
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto float Floor(float f)
Returns floor of value.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float AbsFloat(float f)
Returns absolute value.