/// <summary>Raised after the in-game clock time changes.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (!Game1.hasLoadedGame) { return; } if (!Context.IsMainPlayer) { return; } Conditions.TenMinuteUpdate(); if (Game1.currentLocation.IsOutdoors && Conditions.HasWeather(CurrentWeather.Lightning) && !Conditions.HasWeather(CurrentWeather.Rain) && Game1.timeOfDay < 2400) { Utility.performLightningUpdate(Game1.timeOfDay); } //queued messages clear if (Game1.timeOfDay == 610 && queuedMsg != null) { Game1.hudMessages.Add(queuedMsg); queuedMsg = null; } WeatherProcessing.ProcessHazardousCropWeather(Conditions, Game1.timeOfDay, Dice); ClimatesOfFerngill.WindOverrideSpeed = 0f; //reset once time has passed. }
/// <summary>Raised after a player warps to a new location.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnWarped(object sender, WarpedEventArgs e) { if (e.IsLocalPlayer && Conditions.HasWeather(CurrentWeather.Fog)) { if (Game1.currentLocation is DecoratableLocation loc && !loc.IsOutdoors && WeatherOpt.DarkenLightInFog) { foreach (var f in loc.furniture) { if (f.furniture_type.Value == Furniture.window) { //if (WeatherOpt.Verbose) Monitor.Log($"Attempting to remove the light for {f.name}"); Helper.Reflection.GetMethod(f, "addLights").Invoke(Game1.currentLocation); } } } } }
/// <summary> /// This handles location changes /// </summary> /// <param name="sender">The sender</param> /// <param name="e">Parameters</param> private void LocationEvents_CurrentLocationChanged(object sender, EventArgsCurrentLocationChanged e) { if (IsEclipse) { Game1.globalOutdoorLighting = .5f; Game1.currentLocation.switchOutNightTiles(); Game1.ambientLight = nightColor; if (!Game1.currentLocation.isOutdoors && Game1.currentLocation is DecoratableLocation) { var loc = Game1.currentLocation as DecoratableLocation; foreach (Furniture f in loc.furniture) { if (f.furniture_type == Furniture.window) { Helper.Reflection.GetMethod(f, "addLights").Invoke(new object[] { Game1.currentLocation }); } } } } if (Conditions.HasWeather(CurrentWeather.Fog)) { if (!Game1.currentLocation.isOutdoors && Game1.currentLocation is DecoratableLocation) { var loc = Game1.currentLocation as DecoratableLocation; foreach (Furniture f in loc.furniture) { if (f.furniture_type == Furniture.window) { //if (WeatherOpt.Verbose) Monitor.Log($"Attempting to remove the light for {f.name}"); Helper.Reflection.GetMethod(f, "addLights").Invoke(new object[] { Game1.currentLocation }); } } } } }
internal static HUDMessage HandleOnSaving(WeatherConditions Conditions, MersenneTwister Dice) { if (Conditions.HasWeather(CurrentWeather.Frost) && ClimatesOfFerngill.WeatherOpt.AllowCropDeath) { Farm f = Game1.getFarm(); int count = 0, maxCrops = (int)Math.Floor(SDVUtilities.CropCountInFarm(f) * ClimatesOfFerngill.WeatherOpt.DeadCropPercentage); foreach (KeyValuePair <Vector2, TerrainFeature> tf in f.terrainFeatures.Pairs) { if (count >= maxCrops) { break; } if (tf.Value is HoeDirt curr && curr.crop != null) { Crop test = new Crop(curr.crop.indexOfHarvest.Value, 0, 0); if (Dice.NextDouble() > ClimatesOfFerngill.WeatherOpt.CropResistance && (!test.seasonsToGrowIn.Contains("winter") || !SDVUtilities.IsWinterForageable(test.indexOfHarvest.Value))) { CropList.Add(tf.Key); count++; } } } if (count > 0) { foreach (Vector2 v in CropList) { HoeDirt hd = (HoeDirt)f.terrainFeatures[v]; hd.crop.dead.Value = true; } return(new HUDMessage( ClimatesOfFerngill.Translator.Get("hud-text.desc_frost_killed", new { deadCrops = count }), Color.SeaGreen, 5250f, true) { whatType = 2 }); } } return(null); }
internal string GenerateTVForecast(WeatherConditions Current, MersenneTwister Dice, double fogOdds, string MoonPhase = "", bool IsMoonUp = false) { string ret = ""; //opening string ret += Translator.Get("weather-tv.opening", new { location = Translator.Get("fern-loc." + Dice.Next(12)), playerLocation = Translator.Get("weather-location.player." + Dice.Next(4)) }); //hazard warning if (MoonPhase == "Blood Moon" && IsMoonUp) { ret += Translator.Get("weather-tv.bloodmoon"); } if (Current.WeatherIsHazardous()) { string hazard = "", rainfallW = "", hazardT = "", hazardF; if (Current.HasWeather(CurrentWeather.Heatwave)) { hazardT = Translator.Get("weather-tv.hazard.hw"); } if (Current.HasWeather(CurrentWeather.Frost)) { hazardT = Translator.Get("weather-tv.hazard.frost"); } if (Current.HasWeather(CurrentWeather.Blizzard)) { hazard = Translator.Get("weather-tv.hazard.blizzard"); } if (Current.HasWeather(CurrentWeather.WhiteOut)) { hazard = Translator.Get("weather-tv.hazard.whiteout"); } if (Current.HasWeather(CurrentWeather.ThunderFrenzy)) { hazard = Translator.Get("weather-tv.hazard.thunderfrenzy"); } if (Current.HasWeather(CurrentWeather.Sandstorm)) { hazard = Translator.Get("weather-tv.hazard.sandstorm"); } if (WeatherUtilities.IsSevereRainFall(Current.AmtOfRainDrops)) { switch (WeatherUtilities.GetRainCategory(Current.AmtOfRainDrops)) { case RainLevels.Severe: hazard = Translator.Get("weather-tv.hazard.rainfall.severe"); break; case RainLevels.Torrential: hazard = Translator.Get("weather-tv.hazard.rainfall.torrential"); break; case RainLevels.Typhoon: hazard = Translator.Get("weather-tv.hazard.rainfall.typhoon"); break; case RainLevels.NoahsFlood: hazard = Translator.Get("weather-tv.hazard.rainfall.noahsflood"); break; default: hazard = Translator.Get("weather-tv.hazard.rainfall.severe"); break; } rainfallW = Translator.Get("weather-tv.hazard.rainfallW"); } if (!String.IsNullOrEmpty(hazard) && !String.IsNullOrEmpty(hazardT)) { hazardF = Translator.Get("weather-tv.twoHazardString", new { hazardOne = hazard, hazardTwo = hazardT }); } else if (!String.IsNullOrEmpty(hazard)) { hazardF = hazard; } else { hazardF = hazardT; } ret += Translator.Get("weather-tv.hazard", new { hazard = hazardF, repLocation = Translator.Get("weather-location.reporter." + Dice.Next(4)), rainfallWarning = rainfallW }); } //current conditions string time; switch (SDVTime.CurrentTimePeriod) { case SDVTimePeriods.Morning: time = Translator.Get("weather-tv.time.morning"); break; case SDVTimePeriods.Noon: case SDVTimePeriods.Afternoon: time = Translator.Get("weather-tv.time.afternoon"); break; case SDVTimePeriods.Evening: time = Translator.Get("weather-tv.time.evening"); break; case SDVTimePeriods.Night: time = Translator.Get("weather-tv.time.night"); break; case SDVTimePeriods.Midnight: case SDVTimePeriods.LateNight: time = Translator.Get("weather-tv.time.latenight"); break; default: time = Translator.Get("weather-tv.time.generic"); break; } string abText = ""; if (Current.IsAbnormalHeat) { abText = Translator.Get("weather-tv.abnormalHeat"); } if (Current.IsAbnormalChill) { abText = Translator.Get("weather-tv.abnormalChill"); } string sysText = ""; if (Current.trackerModel.WeatherSystemDays > 0) { if (Current.trackerModel.IsWeatherSystem) { sysText = Translator.Get("weather-tv.systemMaint"); } } //the first monster, describing the weather. string dWeather = ""; if (!String.IsNullOrEmpty(SDVUtilities.GetFestivalName(SDate.Now()))) { dWeather = Translator.Get("weather-tv.weat.festival", new { festivalName = SDVUtilities.GetFestivalName(SDate.Now()) }); } if (Current.HasWeather(CurrentWeather.Wedding)) { dWeather = Translator.Get("weather-tv.weat.wedding"); } if (Current.HasWeather(CurrentWeather.Sunny)) { dWeather = Translator.Get("weather-tv.weat.sunny"); } if (Current.HasWeather(CurrentWeather.Rain) && !Current.HasWeather(CurrentWeather.Lightning)) { dWeather = (Current.IsVariableRain ? Translator.Get("weather-tv.weat.rain.variable", new { rainDesc = GetRainDesc(Current.AmtOfRainDrops).Trim() }) : Translator.Get("weather-tv.weat.rain", new { rainDesc = GetRainDesc(Current.AmtOfRainDrops).Trim() })); } if (Current.HasWeather(CurrentWeather.Rain) && Current.HasWeather(CurrentWeather.Lightning) && !Current.HasWeather(CurrentWeather.ThunderFrenzy)) { dWeather = Translator.Get("weather-tv.weat.thunderstorm"); } if (Current.HasWeather(CurrentWeather.ThunderFrenzy)) { dWeather = Translator.Get("weather-tv.weat.thunderfrenzy"); } if (!Current.HasWeather(CurrentWeather.Rain) && Current.HasWeather(CurrentWeather.Lightning)) { dWeather = Translator.Get("weather-tv.weat.drylightning"); } if (Current.HasWeather(CurrentWeather.Blizzard) && !Current.HasWeather(CurrentWeather.WhiteOut)) { dWeather = Translator.Get("weather-tv.weat.blizzard"); } if (Current.HasWeather(CurrentWeather.WhiteOut)) { dWeather = Translator.Get("weather-tv.weat.whiteout"); } if (Current.HasWeather(CurrentWeather.Snow) && !Current.HasWeather(CurrentWeather.Blizzard) && !Current.HasWeather(CurrentWeather.WhiteOut) && !Current.HasWeather(CurrentWeather.Lightning)) { dWeather = Translator.Get("weather-tv.weat.snowy"); } if (Current.HasWeather(CurrentWeather.Snow) && !Current.HasWeather(CurrentWeather.Blizzard) && !Current.HasWeather(CurrentWeather.WhiteOut) && Current.HasWeather(CurrentWeather.Lightning)) { dWeather = Translator.Get("weather-tv.weat.thundersnow"); } if (Current.HasWeather(CurrentWeather.Sandstorm)) { dWeather = Translator.Get("weather-tv.weat.sandstorms"); } if (Current.HasWeather(CurrentWeather.Wind)) { if (Game1.currentSeason == "winter") { dWeather = Translator.Get("weather-tv.weat.windy.winter"); } else { dWeather = Translator.Get("weather-tv.weat.windy"); } } string fog = ""; if (Current.HasWeather(CurrentWeather.Fog)) { if (!Current.HasWeather(CurrentWeather.Wedding)) { fog = Translator.Get("weather-tv.weat.fog", new { time = Current.GetFogTime() }); } else { fog = Translator.Get("weather-tv.weat.fogWed", new { time = Current.GetFogTime() }); } } //ending up the current conditions. string tHazard = ""; if (Current.HasWeather(CurrentWeather.Heatwave)) { tHazard = Translator.Get("weather-tv.tempHazard.heat"); } if (Current.HasWeather(CurrentWeather.Frost)) { tHazard = Translator.Get("weather-tv.tempHazard.cold", new { time = (Game1.currentSeason == "spring" ? Translator.Get("weather-tv.tempHazard.cold.spring") : Translator.Get("weather-tv.tempHazard.cold.fall")) }); } string rRate = ""; if (Current.HasWeather(CurrentWeather.Rain)) { rRate = Translator.Get("weather-tv.rainfallRate", new { rate = WeatherUtilities.GetRainfallAmt(Current.AmtOfRainDrops).ToString("N2") }); } var transParams = new Dictionary <string, string> { { "time", time }, { "currentTemp", GetTemperatureString(Current.GetCurrentTemperature(Game1.timeOfDay)) }, { "abnormalText", abText }, { "systemText", sysText }, { "descWeather", dWeather }, { "fogText", fog }, { "tempHazard", tHazard }, { "rainfallRate", rRate } }; ret += Translator.Get("weather-tv.currentCond", transParams); transParams.Clear(); //now, tomorrow!! :D sysText = ""; if (Current.trackerModel.WeatherSystemDays > 0) { if (Current.trackerModel.IsWeatherSystem) { sysText = Translator.Get("weather-tv.tmrw.systemMaint", new { desc = Translator.Get("weather-location.system.desc." + Dice.Next(6)) }); } if (!Current.trackerModel.IsWeatherSystem && (Game1.weatherForTomorrow != WeatherUtilities.GetWeatherCode())) { sysText = Translator.Get("weather-tv.tmrw.systemEnding", new { desc = Translator.Get("weather-location.system.desc." + Dice.Next(6)), direction = Translator.Get("weather-location.system.move." + Dice.Next(4)) }); } } else { sysText = Translator.Get("weather-tv.tmrw.systemNone"); } //now weather switch (Game1.weatherForTomorrow) { case Game1.weather_rain: dWeather = Translator.Get("weather-tv.rain." + Dice.Next(2)); break; case Game1.weather_festival: dWeather = Translator.Get("weather-tv.festival", new { festName = SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) }); break; case Game1.weather_debris: dWeather = Translator.Get("weather-tv.debris." + Dice.Next(2)); break; case Game1.weather_snow: dWeather = Translator.Get("weather-tv.snowy." + Dice.Next(2)); break; case Game1.weather_wedding: dWeather = Translator.Get("weather-tv.wedding"); break; case Game1.weather_lightning: dWeather = Translator.Get("weather-tv.tstorm." + Dice.Next(2)); break; case Game1.weather_sunny: default: dWeather = Translator.Get("weather-tv.sunny." + Dice.Next(2)); break; } //overrides for festival and wedding (just in case, my paranoia is spiking. :|) if (!String.IsNullOrEmpty(SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)))) { dWeather = Translator.Get("weather-tv.festival", new { festName = SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) }); } if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) { dWeather = Translator.Get("weather-tv.wedding"); } fog = ""; //now, the fog string if (fogOdds >= .6) { fog = Translator.Get("weather-tv.fogChance"); } //tHazard string if (Current.TomorrowHigh > (Current.TodayHigh + 1.5)) { tHazard = Translator.Get("weather-tv.tmrw.warmer", new { high = GetTemperatureString(Current.TomorrowHigh), low = GetTemperatureString(Current.TomorrowLow), }); } else if ((Current.TomorrowHigh < (Current.TodayHigh - 1.5))) { tHazard = Translator.Get("weather-tv.tmrw.cooler", new { high = GetTemperatureString(Current.TomorrowHigh), low = GetTemperatureString(Current.TomorrowLow), }); } else { tHazard = Translator.Get("weather-tv.tmrw.effsame", new { high = GetTemperatureString(Current.TomorrowHigh), low = GetTemperatureString(Current.TomorrowLow), }); } transParams.Add("sysText", sysText); transParams.Add("weather", dWeather); transParams.Add("fogChance", fog); transParams.Add("tempString", tHazard); ret += Translator.Get("weather-tv.tomorrowForecast", transParams); return(ret); }
internal string GenerateMenuPopup(WeatherConditions Current, string MoonPhase = "", string NightTime = "") { string text; if (SDate.Now().Season == "spring" && SDate.Now().Day == 1) { text = Translator.Get("weather-menu.openingS1D1", new { descDay = Translator.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine; } else if (SDate.Now().Season == "winter" && SDate.Now().Day == 28) { text = Translator.Get("weather-menu.openingS4D28", new { descDay = Translator.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine; } else { text = Translator.Get("weather-menu.opening", new { descDay = Translator.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.Sandstorm)) { text += Translator.Get("weather-menu.condition.sandstorm") + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.Heatwave)) { text += Translator.Get("weather-menu.condition.heatwave") + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.Frost)) { text += Translator.Get("weather-menu.condition.frost") + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.WhiteOut)) { text += Translator.Get("weather-menu.condition.whiteOut") + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.ThunderFrenzy)) { text += Translator.Get("weather-menu.condition.thunderFrenzy") + Environment.NewLine; } if (Current.IsVariableRain) { switch (WeatherUtilities.GetRainCategory(Current.AmtOfRainDrops)) { case RainLevels.Severe: text += Translator.Get("weather-condition.vrain.severe_sw") + Environment.NewLine; break; case RainLevels.Torrential: text += Translator.Get("weather-condition.vrain.torrential_sw") + Environment.NewLine; break; case RainLevels.Typhoon: text += Translator.Get("weather-condition.vrain.typhoon_sw") + Environment.NewLine; break; case RainLevels.NoahsFlood: text += Translator.Get("weather-condition.vrain.godswrath_sw") + Environment.NewLine; break; default: break; } } if (MoonPhase == "Blood Moon") { text += Translator.Get("weather-menu.condition.bloodmoon") + Environment.NewLine; } if (ClimatesOfFerngill.UseLunarDisturbancesApi && ClimatesOfFerngill.MoonAPI.IsSolarEclipse()) { text += Translator.Get("weather-menu.condition.solareclipse") + Environment.NewLine; } ISDVWeather CurrentFog = Current.GetWeatherMatchingType("Fog").First(); string fogString = ""; // If the fog is visible, we don't need to display fog information. However, if it's in the morning, // and we know evening fog is likely, we should display the message it's expected // That said, if it's not, we need to pull the fog information down, assuming it's been reset. This checks that the fog end // time is *before* now. To avoid nested trinary statements.. if (SDVTime.CurrentTime < CurrentFog.WeatherExpirationTime && Current.GenerateEveningFog && CurrentFog.WeatherBeginTime < new SDVTime(1200)) { fogString = Translator.Get("weather-menu.expectedFog"); } if (CurrentFog.WeatherBeginTime > SDVTime.CurrentTime && Current.GenerateEveningFog) { fogString = Translator.Get("weather-menu.fogFuture", new { fogTime = CurrentFog.WeatherBeginTime.ToString(), endFog = CurrentFog.WeatherExpirationTime.ToString() }); } //Current Conditions. string currentMenu; if (Current.HasWeather(CurrentWeather.Rain) && Current.IsVariableRain) { currentMenu = "weather-menu.currentRainfall"; } else { currentMenu = "weather-menu.current"; } text += Translator.Get(currentMenu, new { todayCondition = Current.HasWeather(CurrentWeather.Fog) ? Translator.Get("weather-menu.fog", new { condition = GetBasicWeather(Current), fogTime = CurrentFog.IsWeatherVisible ? CurrentFog.WeatherExpirationTime.ToString() : "" }) : GetBasicWeather(Current), tempString = GetTemperatureString(Current.GetCurrentTemperature(Game1.timeOfDay)), todayHigh = GetTemperatureString(Current.TodayHigh), todayLow = GetTemperatureString(Current.TodayLow), currentRainfall = WeatherUtilities.GetRainfallAmt(Current.AmtOfRainDrops).ToString("N2"), fogString }) + Environment.NewLine; //Tomorrow weather text += Translator.Get("weather-menu.tomorrow", new { tomorrowCondition = GetBasicWeather(Game1.weatherForTomorrow), tomorrowLow = GetTemperatureString(Current.TomorrowLow), tomorrowHigh = GetTemperatureString(Current.TomorrowHigh) }) + Environment.NewLine; //now, night time if (!String.IsNullOrEmpty(NightTime)) { text += NightTime + Environment.NewLine; } if (ClimatesOfFerngill.UseLunarDisturbancesApi) { if (ClimatesOfFerngill.MoonAPI.IsMoonUp(Game1.timeOfDay)) { text += Translator.Get("weather-menu.desc-moonNotUp", new { moonPhase = ClimatesOfFerngill.MoonAPI.GetCurrentMoonPhase(), moonRise = ClimatesOfFerngill.MoonAPI.GetMoonRise(), moonSet = ClimatesOfFerngill.MoonAPI.GetMoonSet() }); } else { text += Translator.Get("weather-menu.desc-moonUp", new { moonPhase = ClimatesOfFerngill.MoonAPI.GetCurrentMoonPhase(), moonSet = ClimatesOfFerngill.MoonAPI.GetMoonSet() }); } } //new line replacer text.Replace("[NLK]", Environment.NewLine); return(text); }
internal static void ProcessHazardousCropWeather(WeatherConditions curr, int timeOfDay, MersenneTwister Dice) { //frost works at night, heatwave works during the day if (timeOfDay == 1700) { if (curr.HasWeather(CurrentWeather.Heatwave) || curr.HasWeather(CurrentWeather.Sandstorm)) { ClimatesOfFerngill.Logger.Log("Beginning Heatwave code"); ExpireTime = 2000; Farm f = Game1.getFarm(); int count = 0, maxCrops = (int)Math.Floor(SDVUtilities.CropCountInFarm(f) * ClimatesOfFerngill.WeatherOpt.DeadCropPercentage); foreach (KeyValuePair <Vector2, TerrainFeature> tf in f.terrainFeatures.Pairs) { if (count >= maxCrops) { break; } if (tf.Value is HoeDirt dirt && dirt.crop != null) { if (Dice.NextDouble() <= ClimatesOfFerngill.WeatherOpt.CropResistance) { if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"Dewatering crop at {tf.Key}. Crop is {dirt.crop.indexOfHarvest}"); } CropList.Add(tf.Key); dirt.state.Value = HoeDirt.dry; count++; } } } if (CropList.Count > 0) { if (ClimatesOfFerngill.WeatherOpt.AllowCropDeath) { if (curr.HasWeather(CurrentWeather.Heatwave) && !curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave_kill", new { crops = count }), 3); } if (curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_sandstorm_kill", new { crops = count }), 3); } } else { if (curr.HasWeather(CurrentWeather.Heatwave) && !curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave_dry", new { crops = count }), 3); } if (curr.HasWeather(CurrentWeather.Sandstorm)) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_sandstorm_dry", new { crops = count }), 3); } } } else { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave"), 3); } } } if (Game1.timeOfDay == ExpireTime && ClimatesOfFerngill.WeatherOpt.AllowCropDeath) { ClimatesOfFerngill.Logger.Log("Beginning Crop Death code"); //if it's still de watered - kill it. Farm f = Game1.getFarm(); bool cDead = false; foreach (Vector2 v in CropList) { HoeDirt hd = (HoeDirt)f.terrainFeatures[v]; if (hd.state.Value == HoeDirt.dry) { if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"Killing crop at {v}. Crop is {hd.crop.indexOfHarvest}"); } hd.crop.dead.Value = true; cDead = true; } } CropList.Clear(); //clear the list if (cDead) { SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_heatwave_cropdeath"), 3); } } }
internal static bool TestForSpecialWeather(WeatherConditions curr, FerngillClimateTimeSpan ClimateForDay) { bool specialWeatherTriggered = false; // Conditions: Blizzard - occurs in weather_snow in "winter" // Dry Lightning - occurs if it's sunny in any season if temps exceed 25C. // Frost and Heatwave check against the configuration. // Thundersnow - as Blizzard, but really rare. Will not happen in fog, may happen in Blizzard/WhiteOut // Sandstorm - windy, with no precip for several days. Spring-Fall only, highest chance in summer. // Fog - per climate, although night fog in winter is double normal chance curr.GenerateEveningFog = (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.EveningFogChance * ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth)) && !curr.GetCurrentConditions().HasFlag(CurrentWeather.Wind); bool blockFog = ClimatesOfFerngill.MoonAPI != null && ClimatesOfFerngill.MoonAPI.IsSolarEclipse(); if (blockFog || ClimatesOfFerngill.WeatherOpt.DisableAllFog) { curr.GenerateEveningFog = false; } double fogRoll = (ClimatesOfFerngill.WeatherOpt.DisableAllFog ? 1.1 : ClimatesOfFerngill.Dice.NextDoublePositive()); if (fogRoll < ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth) && !curr.GetCurrentConditions().HasFlag(CurrentWeather.Wind) && !blockFog) { curr.CreateWeather("Fog"); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"{curr.FogDescription(fogRoll, ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth))}"); } specialWeatherTriggered = true; } //set special temps before we check for the results of them if (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.HeatwaveChance) { SetHotwave(); } else if (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.ChillwaveChance) { SetChillWave(); } //do these here //20190626 - Thanks to Crops Anywhere, I have to add this if ((curr.TodayLow < ClimatesOfFerngill.WeatherOpt.TooColdOutside && !Game1.IsWinter) || (curr.TodayLow < ClimatesOfFerngill.WeatherOpt.TooColdOutside && Game1.IsWinter && ClimatesOfFerngill.WeatherOpt.ApplyFrostsInWinter)) { if (ClimatesOfFerngill.WeatherOpt.HazardousWeather) { curr.AddWeather(CurrentWeather.Frost); specialWeatherTriggered = true; } } //test for spring conversion if (curr.HasWeather(CurrentWeather.Rain) && curr.HasWeather(CurrentWeather.Frost) && (Game1.currentSeason == "spring" || Game1.currentSeason == "fall") && ClimatesOfFerngill.Dice.NextDoublePositive() <= ClimatesOfFerngill.WeatherOpt.RainToSnowConversion) { curr.RemoveWeather(CurrentWeather.Rain); curr.AddWeather(CurrentWeather.Snow); Game1.isRaining = false; Game1.isSnowing = true; specialWeatherTriggered = true; } if (curr.HasWeather(CurrentWeather.Snow)) { double blizRoll = ClimatesOfFerngill.Dice.NextDoublePositive(); double blizOdds = ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "blizzard", Game1.dayOfMonth); if (blizRoll <= blizOdds) { curr.CreateWeather("Blizzard"); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {blizRoll:N3} against {blizOdds}, there will be blizzards today"); } if (ClimatesOfFerngill.Dice.NextDoublePositive() < ClimatesOfFerngill.WeatherOpt.WhiteOutChances && ClimatesOfFerngill.WeatherOpt.HazardousWeather) { curr.CreateWeather("WhiteOut"); } } specialWeatherTriggered = true; } //Dry Lightning is also here for such like the dry and arid climates // which have so low rain chances they may never storm. if (curr.HasWeather(CurrentWeather.Snow)) { double oddsRoll = ClimatesOfFerngill.Dice.NextDoublePositive(); double thunderSnowOdds = ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "storm", Game1.dayOfMonth); if (oddsRoll <= thunderSnowOdds && !curr.HasWeather(CurrentWeather.Fog)) { curr.AddWeather(CurrentWeather.Lightning); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {thunderSnowOdds}, there will be thundersnow today"); } specialWeatherTriggered = true; } } if (!(curr.HasPrecip())) { double oddsRoll = ClimatesOfFerngill.Dice.NextDoublePositive(); if (oddsRoll <= ClimatesOfFerngill.WeatherOpt.DryLightning && curr.TodayHigh >= ClimatesOfFerngill.WeatherOpt.DryLightningMinTemp && !curr.HasWeather(CurrentWeather.Frost)) { curr.AddWeather(CurrentWeather.Lightning); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {ClimatesOfFerngill.WeatherOpt.DryLightning}, there will be dry lightning today."); } specialWeatherTriggered = true; } if (curr.TodayHigh > ClimatesOfFerngill.WeatherOpt.TooHotOutside && ClimatesOfFerngill.WeatherOpt.HazardousWeather) { curr.AddWeather(CurrentWeather.Heatwave); specialWeatherTriggered = true; } double sandstormOdds = .18; if (Game1.currentSeason == "summer") { sandstormOdds *= 1.2; } if (oddsRoll < sandstormOdds && ClimatesOfFerngill.WeatherOpt.HazardousWeather && Game1.isDebrisWeather) { curr.AddWeather(CurrentWeather.Sandstorm); specialWeatherTriggered = true; curr.CreateWeather("Sandstorm"); } } //and finally, test for thunder frenzy if (curr.HasWeather(CurrentWeather.Lightning) && curr.HasWeather(CurrentWeather.Rain) && ClimatesOfFerngill.WeatherOpt.HazardousWeather) { double oddsRoll = ClimatesOfFerngill.Dice.NextDouble(); if (oddsRoll < ClimatesOfFerngill.WeatherOpt.ThunderFrenzyOdds) { curr.AddWeather(CurrentWeather.ThunderFrenzy); specialWeatherTriggered = true; if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {ClimatesOfFerngill.WeatherOpt.ThunderFrenzyOdds}, there will be a thunder frenzy today"); } curr.CreateWeather("ThunderFrenzy"); } } return(specialWeatherTriggered); }
internal static void DynamicRainOnNewDay(WeatherConditions curr, MersenneTwister Dice) { if (!curr.HasWeather(CurrentWeather.Rain)) { return; } curr.SetRainAmt(70); //Rain chances. This will also affect storms (in that storms still can have variable rain) . //only roll this if it's actually raining. :| double roll = Dice.NextDouble(); if (roll <= ClimatesOfFerngill.WeatherOpt.VariableRainChance && Game1.isRaining) { ClimatesOfFerngill.Logger.Log($"With {roll}, we are setting for variable rain against {ClimatesOfFerngill.WeatherOpt.VariableRainChance}"); curr.SetVariableRain(true); //check for overcast chance first. if (Dice.NextDouble() < ClimatesOfFerngill.WeatherOpt.OvercastChance && !Game1.isLightning) { WeatherUtilities.SetWeatherOvercast(true); SDVUtilities.AlterWaterStatusOfCrops(water: false); SDVUtilities.ShowMessage(ClimatesOfFerngill.Translator.Get("hud-text.desc_overcast"), 0); } //now that we've done that base check, we need to change the rainfall... //... after we calc rainfall to see if it's watered. Essentially, every time this is called, //... it'll check to see if it should flip the tiles. //Variable Rain may set the starting rain at 0300 to be something else than normal, and as such, StartingRain should // only be checked if IsVariableRain is true. // Odds are fixed: Normal (default) is 72%, Light is 16%, Heavy is 6%, Sunshower is 5%, Severe is 1% double startingRainRoll = Dice.NextDouble(); if (startingRainRoll <= .72) { curr.StartingRain = RainLevels.Normal; } else if (startingRainRoll > .72 && startingRainRoll <= .88) { curr.StartingRain = RainLevels.Light; } else if (startingRainRoll > .88 && startingRainRoll <= .94) { curr.StartingRain = RainLevels.Heavy; } else if (startingRainRoll > .94 && startingRainRoll <= .99) { curr.StartingRain = RainLevels.Sunshower; } else if (startingRainRoll > .99) { curr.StartingRain = RainLevels.Severe; } if (Game1.isLightning && !(curr.StartingRain == RainLevels.Light || curr.StartingRain == RainLevels.Sunshower || curr.StartingRain == RainLevels.Normal)) { curr.StartingRain = RainLevels.Heavy; } curr.SetRainAmt(WeatherUtilities.GetRainCategoryMidPoint(curr.StartingRain)); curr.TodayRain = curr.AmtOfRainDrops; //now run this for 0300 to 0600. for (int i = 0; i < 17; i++) { curr.SetRainAmt(GetNewRainAmount(curr.AmtOfRainDrops, ClimatesOfFerngill.Translator)); curr.TodayRain += curr.AmtOfRainDrops; } //set starting amount at 6am curr.RefreshRainAmt(); } }
internal string GenerateTVForecast(WeatherConditions Current, string MoonPhase = "") { //assemble params var talkParams = new Dictionary <string, string> { { "location", GetRandomLocation() }, { "descWeather", GetWeather(Current, Game1.dayOfMonth, Game1.currentSeason) }, { "festival", SDVUtilities.GetFestivalName(SDate.Now()) }, { "festivalTomorrow", SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) }, { "fogTime", Current.GetFogTime().ToString() }, { "todayHigh", GetTemperatureString(Current.TodayHigh) }, { "todayLow", GetTemperatureString(Current.TodayLow) }, { "tomorrowWeather", GetWeather(Game1.weatherForTomorrow, Game1.dayOfMonth, Game1.currentSeason, true) }, { "tomorrowHigh", GetTemperatureString(Current.TomorrowHigh) }, { "tomorrowLow", GetTemperatureString(Current.TomorrowLow) }, { "condWarning", GetCondWarning(Current) }, { "condString", GetCondWarning(Current) }, { "eveningFog", GetEveningFog(Current) } }; //select the weather string for the TV. SDVTimePeriods CurrentPeriod = SDVTime.CurrentTimePeriod; //get the current time period int nRandom = OurDice.Next(2); //blood moon checks if ((Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) && MoonPhase == "Blood Moon") { talkParams["tomrrowWeather"] = Helper.Get($"weat-{Game1.currentSeason}.sunny.{nRandom}"); return(Helper.Get("weat-wedTomorrow.BM.0", talkParams)); } //festival tomorrow else if (SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) != "" && MoonPhase == "Blood Moon") { return(Helper.Get("weat-fesTomorrow.BM.0", talkParams)); } else if (MoonPhase == "Blood Moon") { return(Helper.Get("weat-gen.bloodmoon.0", talkParams)); } //first, check for special conditions -fog, festival, wedding else if (Current.HasWeather(CurrentWeather.Fog)) { return(Helper.Get($"weat-loc.fog.{nRandom}", talkParams)); } //festival today else if (Current.HasWeather(CurrentWeather.Festival)) { return(Helper.Get("weat-fesToday.0", talkParams)); } //festival tomorrow else if (SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) != "") { return(Helper.Get("weat-fesTomorrow.0", talkParams)); } //wedding today else if (Current.HasWeather(CurrentWeather.Wedding)) { return(Helper.Get("weat-wedToday.0", talkParams)); } //wedding tomrrow else if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) { talkParams["tomrrowWeather"] = Helper.Get($"weat-{Game1.currentSeason}.sunny.{nRandom}"); return(Helper.Get("weat-wedTomorrow.0", talkParams)); } if (OurDice.NextDoublePositive() > .45) { if (CurrentPeriod == SDVTimePeriods.Morning) { return(Helper.Get($"weat-morn.{nRandom}", talkParams)); } else if (CurrentPeriod == SDVTimePeriods.Afternoon) { return(Helper.Get($"weat-afternoon.{nRandom}", talkParams)); } else if (CurrentPeriod == SDVTimePeriods.Evening) { return(Helper.Get($"weat-evening.{nRandom}", talkParams)); } else if (CurrentPeriod == SDVTimePeriods.Night) { return(Helper.Get($"weat-night.{nRandom}", talkParams)); } else if (CurrentPeriod == SDVTimePeriods.Midnight) { return(Helper.Get($"weat-midnight.{nRandom}", talkParams)); } else if (CurrentPeriod == SDVTimePeriods.LateNight) { return(Helper.Get($"weat-latenight.{nRandom}", talkParams)); } } else { //ye olde generic! return(Helper.Get($"weat-loc.{nRandom}", talkParams)); } return(""); }
internal string GenerateMenuPopup(WeatherConditions Current, string MoonPhase = "", string NightTime = "") { string text = ""; if (SDate.Now().Season == "spring" && SDate.Now().Day == 1) { text = Helper.Get("weather-menu.openingS1D1", new { descDay = Helper.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine; } else if (SDate.Now().Season == "winter" && SDate.Now().Day == 28) { text = Helper.Get("weather-menu.openingS4D28", new { descDay = Helper.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine; } else { text = Helper.Get("weather-menu.opening", new { descDay = Helper.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.Heatwave)) { text += Helper.Get("weather-menu.condition.heatwave") + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.Frost)) { text += Helper.Get("weather-menu.condition.frost") + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.WhiteOut)) { text += Helper.Get("weather-menu.condition.whiteOut") + Environment.NewLine; } if (Current.ContainsCondition(CurrentWeather.ThunderFrenzy)) { text += Helper.Get("weather-menu.condition.thunderFrenzy") + Environment.NewLine; } if (MoonPhase == "Blood Moon") { text += Helper.Get("weather-menu.condition.bloodmoon") + Environment.NewLine; } ISDVWeather CurrentFog = Current.GetWeatherMatchingType("Fog").First(); string fogString = ""; // If the fog is visible, we don't need to display fog information. However, if it's in the morning, // and we know evening fog is likely, we should display the message it's expected // That said, if it's not, we need to pull the fog information down, assuming it's been reset. This checks that the fog end // time is *before* now. To avoid nested trinary statements.. if (SDVTime.CurrentTime < CurrentFog.WeatherExpirationTime && Current.GenerateEveningFog && CurrentFog.WeatherBeginTime < new SDVTime(1200)) { fogString = Helper.Get("weather-menu.expectedFog"); } if (CurrentFog.WeatherBeginTime > SDVTime.CurrentTime && Current.GenerateEveningFog) { fogString = Helper.Get("weather-menu.fogFuture", new { fogTime = CurrentFog.WeatherBeginTime.ToString(), endFog = CurrentFog.WeatherExpirationTime.ToString() }); } //Current Conditions. text += Helper.Get("weather-menu.current", new { todayCondition = Current.HasWeather(CurrentWeather.Fog) ? Helper.Get("weather-menu.fog", new { condition = GetBasicWeather(Current, Game1.currentSeason), fogTime = CurrentFog.IsWeatherVisible ? CurrentFog.WeatherExpirationTime.ToString() : "" }) : GetBasicWeather(Current, Game1.currentSeason), todayHigh = GetTemperatureString(Current.TodayHigh), todayLow = GetTemperatureString(Current.TodayLow), fogString }) + Environment.NewLine; //Tomorrow weather text += Helper.Get("weather-menu.tomorrow", new { tomorrowCondition = GetBasicWeather(Game1.weatherForTomorrow, Game1.currentSeason), tomorrowLow = GetTemperatureString(Current.TomorrowLow), tomorrowHigh = GetTemperatureString(Current.TomorrowHigh) }) + Environment.NewLine; //now, night time if (NightTime != "") { text += Environment.NewLine; text += NightTime + Environment.NewLine; } return(text); }