8 #ifdef WEATHER_DATA_LOGGING
9 int overcastChangeCount = 0;
10 int badWeatherCount = 0;
11 int cloudyWeatherCount = 0;
12 int clearWeatherCount = 0;
13 int sandstormCount = 0;
40 m_MinTemps = {3.4, 5.4, 7.4, 8.4, 9.4, 12.4, 14.4, 13.4, 11.4, 8.4, 7.4, 4.4};
49 m_MaxTemps = {17.4, 19.4, 22.4, 25.4, 29.4, 34.4, 38.4, 37.4, 34.4, 28.4, 22.4, 18.4};
83 m_Weather.GetOvercast().SetLimits(0.1, 1);
89 m_Weather.GetWindMagnitude().SetForecastChangeLimits( 0, 20 );
94 m_Weather.GetOvercast().Set(startingOvercast,0,5);
102 super.InitYieldBank();
107 m_YieldBank.RegisterYieldItem(
new YieldItemCarp(42));
109 m_YieldBank.RegisterYieldItem(
new YieldItemRoundGoby(15));
116 m_YieldBank.RegisterYieldItem(
new YieldItemJunkEmpty(1,
"Pot"));
120 m_YieldBank.RegisterYieldItem(
new YieldItemDeadRooster(1));
122 m_YieldBank.RegisterYieldItem(
new YieldItemDeadChicken_Spotted(1));
124 m_YieldBank.RegisterYieldItem(
new YieldItemDeadFox(2));
125 m_YieldBank.RegisterYieldItem(
new YieldItemDeadLizard(4));
130 super.SetupWeatherSettings();
154 super.SetupDustEffects();
174 #ifdef WEATHER_DATA_LOGGING
177 GetGame().GetWorld().GetDate(startYear, startMonth, startDay, startHour, startMinute);
182 float phmnTime = 120;
183 float phmnLength = 10;
189 m_Weather.GetOvercast().SetLimits(0.07, 1);
195 m_Weather.GetWindMagnitude().SetForecastChangeLimits( 0, 20 );
206 float windDirection, windMag;
209 #ifdef WEATHER_DATA_LOGGING
210 overcastChangeCount++;
217 m_Weather.GetOvercast().Set( phmnValue, 120, phmnLength );
229 if (
m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
234 if (
m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
239 if (
m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
253 if (
m_LastWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
260 if (
m_LastWeather == WorldDataWeatherConstants.BAD_WEATHER )
267 if (
m_LastWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
282 #ifdef WEATHER_DATA_LOGGING
293 #ifdef WEATHER_DATA_LOGGING
294 cloudyWeatherCount++;
310 #ifdef WEATHER_DATA_LOGGING
325 if (phmnValue < 0.75)
330 windMagLength = 99999;
340 windDirection = -1.5;
358 windDirection =
m_Weather.GetWindDirection().GetActual();
364 m_Weather.GetOvercast().Set( phmnValue, phmnTime, phmnLength );
371 Debug.
WeatherLog(
string.Format(
"Nasdara::Weather::Overcast:: (%1) overcast: %2",
g_Game.GetDayTime(), actual));
374 #ifdef WEATHER_DATA_LOGGING
380 GetGame().GetWorld().GetDate(testYear, testMonth, testDay, testHour, testMinute);
382 if ( testDay - startDay > currentDay && testHour - startHour >= 0 && testMinute - startMinute >= 0 )
385 FPrintln(file,
"================================================================");
386 FPrintln(file,
" ================== Day " + (currentDay + 1) +
" ================== ");
387 FPrintln(file,
"================================================================");
388 FPrintln(file,
"Overcast Change Count: " + overcastChangeCount);
389 FPrintln(file,
"Bad Weather Change Count: " + badWeatherCount);
390 FPrintln(file,
"Cloudy Weather Count: " + cloudyWeatherCount);
391 FPrintln(file,
"Clear Weather Count: " + clearWeatherCount);
392 FPrintln(file,
"Sandstorm Count: " + sandstormCount);
396 if ( currentDay == daysToRun )
401 overcastChangeCount = 0;
403 cloudyWeatherCount = 0;
404 clearWeatherCount = 0;
415 float actualOvercast =
m_Weather.GetOvercast().GetActual();
425 Debug.
WeatherLog(
string.Format(
"Nasdara::Weather::Rain::ForceEnd:: (%1) %2 -> 0",
g_Game.GetDayTime(), actual));
444 m_Weather.GetRain().Set( phmnValue, phmnTime, phmnLength );
461 float sereneWindMag =
m_Weather.GetWindMagnitude().GetActual() * 0.6;
472 sandstorm.
Stop(phmnTime,
true);
480 m_Weather.GetWindDirection().Set( 0, 60 , 100000);
481 Debug.
LogError(
"Wind direction has been changed out of overcast change");
485 sandstorm.
Stop(30,
true);
486 Debug.
LogError(
"Wind direction changed while sandstorm was active, stopping sandstorm");
499 if (!isStartedByWeather)
504 float fadeInTime = 40;
506 m_Weather.GetWindMagnitude().Set( windMagnitude, fadeInTime, 99999 );
507 m_Weather.GetWindDirection().Set( windDirection, fadeInTime * 0.5 , 99999 );
508 m_Weather.GetOvercast().Set( randomizedOvercast , fadeInTime * 2, 99999);
515 if (!calledFromWeather)
522 protected override void CalculateWind(
int newWeather,
bool suddenChange, out
float magnitude, out
float direction)
530 if ( newWeather == WorldDataWeatherConstants.CLEAR_WEATHER )
532 if ( windChance < 40 )
537 else if ( windChance < 80 )
548 else if ( newWeather == WorldDataWeatherConstants.CLOUDY_WEATHER )
550 if ( windChance < 45 )
563 float sandstormChance = 8;
564 float windRatio = 0.4;
568 float highWindChance = ( 100 - sandstormChance ) * windRatio;
576 #ifdef WEATHER_DATA_LOGGING
580 else if ( windChance < sandstormChance + highWindChance )
593 protected override void CalculateVolFog(
float lerpValue,
float windMagnitude,
float changeTime)
595 float maxVolFogDistanceDensity = 0.006;
596 float minVolFogDistanceDensity = 0.001;
598 maxVolFogDistanceDensity =
Math.
Lerp(maxVolFogDistanceDensity * 0.5, maxVolFogDistanceDensity, lerpValue);
600 if (minVolFogDistanceDensity > maxVolFogDistanceDensity)
601 maxVolFogDistanceDensity = minVolFogDistanceDensity;
603 float volFogDistanceDensity =
Math.
Lerp( minVolFogDistanceDensity, maxVolFogDistanceDensity, windMagnitude/
m_Weather.GetWindMaximumSpeed() );
605 m_Weather.SetDynVolFogDistanceDensity(volFogDistanceDensity, changeTime);
607 float volFogHeightDensity =
Math.
Lerp(0.95, 0.98, lerpValue);
608 m_Weather.SetDynVolFogHeightDensity(volFogHeightDensity, changeTime );
613 #ifdef WEATHER_DATA_LOGGING
621 int year, month, day, hour, minute;
622 g_Game.GetWorld().GetDate(year, month, day, hour, minute);
628 float currentTime = hour + (minute / 60);
629 float dayLength = sunsetTimeStart - sunriseTimeStart;
630 float dawnT = sunriseTimeStart + (dayLength * 0.1);
631 float morningT = sunriseTimeStart + (dayLength * 0.35);
632 float noonT = sunriseTimeStart + (dayLength * 0.65);
633 float afternoonT = sunriseTimeStart + (dayLength * 0.9);
635 if (currentTime >= sunriseTimeStart && currentTime < dawnT)
637 if (currentTime >= dawnT && currentTime < morningT)
639 if (currentTime >= morningT && currentTime < noonT)
641 if (currentTime >= noonT && currentTime < afternoonT)
643 if (currentTime >= afternoonT && currentTime < sunsetTimeStart)
645 if (currentTime >= sunsetTimeStart && currentTime < (sunsetTimeStart + 2))
SandstormController Sandstorm
void YieldItemJunk(int baseWeight, string type)
static array< float > GetEnvironmentMaxTemps()
static array< float > GetEnvironmentMinTemps()
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
static void WeatherLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
override void InitYieldBank()
bool sandstormWillChangeOvercast
override void SetupWeatherSettings()
bool previousWeatherHadSandstorm
override void CalculateWind(int newWeather, bool suddenChange, out float magnitude, out float direction)
override void OnSandstormStart(bool isStartedByWeather)
override bool WeatherOnBeforeChange(EWeatherPhenomenon type, float actual, float change, float time)
override void SetupLiquidTemperatures()
override void SetupDustEffects()
override void CalculateVolFog(float lerpValue, float windMagnitude, float changeTime)
override void OnSandstormStop(bool calledFromWeather)
override int GetDaytime()
proto native void Stop(float duration, bool calledByWeather)
Stops the sandstorm, leaving it to fade out over duration seconds. The sandstorm must be active prior...
proto native bool IsActive()
Returns whether sandstorm is currently active.
void StartSandstorm(float timeToGather)
Helper function that starts the sandstorm while setting an internal flag that allows WorldData identi...
ref WorldDataLiquidSettings m_LiquidSettings
float WIND_DIRECTION_TIME_MULTIPLIER
float GetSunsetTime(float dayNumber)
Returns sunset time for passed day.
ref WorldDataWeatherSettings m_WeatherDefaultSettings
float m_WaterContactTemperatureModifier
float m_TemperaturePerHeightReductionModifier
directly accesible (defined/overriden in Init())
float m_CloudsTemperatureEffectModifier
amount of °C reduced for each 100 meteres of height above water level
ref CatchYieldBank m_YieldBank
ref map< int, float > m_TemperatureUnderSunModifier
int DayOfYear(int day, int month)
Returns number of day in current year (eg. 1 - 365)
float m_TemperatureInsideBuildingsModifier
how many % of environment temperature can be lowered by clouds
float GetSunriseTime(float dayNumber)
Returns sunrise time for passed day.
ref DustEffectsSettings m_DustEffectsSettings
int m_BadWeatherChance
weather related
float WIND_MAGNITUDE_TIME_MULTIPLIER
float m_UniversalTemperatureSourceCapModifier
proto void CloseFile(FileHandle file)
Close the File.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.
const int LIQUID_STILLWATER
const int LIQUID_HOTWATER
const int LIQUID_FRESHWATER
const int LIQUID_CLEANWATER
const int LIQUID_RIVERWATER
const int LIQUID_SALTWATER
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].