public void ClearDrain(int reason = 1) { FarmerSick = false; if (Game1.buffsDisplay.otherBuffs.Any()) { int buffId = UniqueStaID + SicknessBuffID; int i = Game1.buffsDisplay.otherBuffs.FindIndex(p => p.which == buffId); //of course a not found is a negative index. if (i > 0) { Game1.buffsDisplay.otherBuffs.RemoveAt(i); } } if (IllOptions.Verbose) { Monitor.Log("Removing buff icon!!"); } if (reason == StaminaDrain.MedicineClear) { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_cold_removed"), 4); } else if (reason == StaminaDrain.BathHouseClear) { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_bathHouse"), 4); } }
public void ClearDrain(int reason = 1) { FarmerSick = false; if (reason == StaminaDrain.MedicineClear) { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_cold_removed"), 4); } else if (reason == StaminaDrain.BathHouseClear) { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_bathHouse"), 4); } }
public void MakeSick() { FarmerSick = true; FarmerHasBeenSick = true; if (IllOptions.Verbose) { Monitor.Log("Adding buff icon!!"); } switch (ReasonSick) { case IllCauses.InclementWeather: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_inclement"), 4); break; case IllCauses.BlizzardsOutside: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_blizzard"), 4); break; case IllCauses.NonspecificSevereWeather: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_flu"), 4); break; case IllCauses.TheWampaWillGetYou: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_wampa"), 4); break; case IllCauses.Darude: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_darude"), 4); break; case IllCauses.TooColdInside: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_turntheheaton"), 4); break; case IllCauses.TooColdOutside: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_cold"), 4); break; case IllCauses.TooHotOutside: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_hot"), 4); break; default: SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_sick"), 4); break; } }
public void MakeSick(int reason = 0) { FarmerSick = true; FarmerHasBeenSick = true; if (reason == FROST) { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_freeze")); } else if (reason == HEATWAVE) { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_exhaust")); } else { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_sick")); } }
public void ClearFog() { FogDebuffValid = false; if (Game1.buffsDisplay.otherBuffs.Any()) { int buffId = UniqueStaID + FogBuffID; int i = Game1.buffsDisplay.otherBuffs.FindIndex(p => p.which == buffId); //of course a not found is a negative index. if (i > 0) { Game1.buffsDisplay.otherBuffs.RemoveAt(i); } } if (IllOptions.Verbose) { Monitor.Log("Removing buff icon!!"); } SDVUtilities.ShowMessage("The evil is defeated!", 4); }
public int TenMinuteTick(int?hatID, double?temp, string conditions, int ticksInHouse, int ticksOutside, int ticksTotal, MersenneTwister Dice) { double amtOutside = ticksOutside / (double)ticksTotal, totalMulti = 0; double amtInHouse = ticksInHouse / (double)ticksTotal; int staminaAffect = 0; var condList = new List <string>(); if (IllOptions.Verbose) { Monitor.Log($"Ticks: {ticksOutside}/{ticksTotal} with percentage {amtOutside:N3} against target {IllOptions.PercentageOutside}"); Monitor.Log($"Ticks in house is {amtInHouse:N3} against target {IllOptions.PercentageOutside}"); Monitor.Log($"Current Condition: {conditions}"); } //First, update the sick status double sickOdds = IllOptions.ChanceOfGettingSick - Game1.player.DailyLuck; //weee. if (hatID == 28 && (conditions.Contains("lightning") || conditions.Contains("stormy") || conditions.Contains("thundersnow"))) { sickOdds -= (Dice.NextDoublePositive() / 5.0) - .1; } if (hatID == 25 && conditions.Contains("blizzard") || conditions.Contains("whiteout")) { sickOdds -= .22; } if (hatID == 4 && conditions.Contains("heatwave") && !SDVTime.IsNight) { sickOdds -= .11; } bool farmerCaughtCold = (Dice.NextDoublePositive() <= sickOdds) && (IllOptions.StaminaDrain > 0); FarmHouse fh = Game1.getLocationFromName("FarmHouse") as FarmHouse; bool isHeaterHere = false; foreach (var v in fh.objects.Pairs) { if (v.Value.Name.Contains("Heater")) { if (IllOptions.Verbose) { Monitor.Log("Heater detected"); } isHeaterHere = true; } } foreach (var v in fh.furniture) { if (v.furniture_type.Value == Furniture.fireplace && v.IsOn) { if (IllOptions.Verbose) { Monitor.Log("fireplace detected"); } isHeaterHere = true; } } if (!(temp is null)) { turnTheHeatOn = (turnTheHeatOn || (amtInHouse >= IllOptions.PercentageOutside && farmerCaughtCold && temp < IllOptions.TooColdInside && !isHeaterHere && IssuedInHouseWarning && (Game1.timeOfDay < 1000 || Game1.timeOfDay > 1650))); if (!IssuedInHouseWarning && amtInHouse >= IllOptions.PercentageOutside && temp < IllOptions.TooColdInside && (Game1.timeOfDay < 1000 || Game1.timeOfDay > 1650) && !Game1.currentLocation.IsOutdoors && !isHeaterHere) { SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_HeatOn"), 4); IssuedInHouseWarning = true; } } if (amtOutside >= IllOptions.PercentageOutside && farmerCaughtCold || this.FarmerSick || turnTheHeatOn) { //check if it's a valid condition if (FarmerCanGetSick()) { //rewrite time.. if (conditions.Contains("blizzard") || conditions.Contains("sandstorm") || conditions.Contains("whiteout") || (conditions.Contains("lightning") || conditions.Contains("stormy") || conditions.Contains("thundersnow")) && !(Game1.currentLocation is Desert) || (conditions.Contains("frost") && SDVTime.IsNight) || (conditions.Contains("heatwave") && !SDVTime.IsNight) || turnTheHeatOn) { if (turnTheHeatOn && !Game1.currentLocation.IsOutdoors) { ReasonSick = IllCauses.TooColdInside; } else if ((conditions.Contains("heatwave") && !SDVTime.IsNight)) { ReasonSick = IllCauses.TooHotOutside; } else if (conditions.Contains("frost") && SDVTime.IsNight) { ReasonSick = IllCauses.TooColdOutside; } else if (condList.Contains("blizzard")) { ReasonSick = IllCauses.BlizzardsOutside; } else if (condList.Contains("whiteout")) { ReasonSick = IllCauses.TheWampaWillGetYou; } else if (condList.Contains("sandstorm")) { ReasonSick = IllCauses.Darude; } else if (conditions.Contains("lightning") || conditions.Contains("stormy")) { ReasonSick = IllCauses.InclementWeather; } else { ReasonSick = IllCauses.NonspecificSevereWeather; } this.MakeSick(); } } //now that we've done that, go through the various conditions if (this.FarmerSick && (conditions.Contains("lightning") || conditions.Contains("stormy") || conditions.Contains("thundersnow"))) { totalMulti += 1; condList.Add("Lightning or Thundersnow"); } if (this.FarmerSick && conditions.Contains("fog")) { totalMulti += .5; condList.Add("Fog"); } if (this.FarmerSick && conditions.Contains("fog") && SDVTime.IsNight) { totalMulti += .25; condList.Add("Night Fog"); } if (this.FarmerSick && conditions.Contains("blizzard") && !conditions.Contains("whiteout")) { totalMulti += 1.25; condList.Add("Blizzard"); } if (this.FarmerSick && conditions.Contains("sandstorm")) { totalMulti += 1.25; condList.Add("Sandstorm"); } if (this.FarmerSick && conditions.Contains("blizzard") && conditions.Contains("whiteout")) { totalMulti += 2.45; condList.Add("White Out"); } if (this.FarmerSick && conditions.Contains("thunderfrenzy")) { totalMulti += 1.85; condList.Add("Thunder Frenzy"); } if (this.FarmerSick && conditions.Contains("frost") && SDVTime.IsNight) { totalMulti += 1.25; condList.Add("Night Frost"); } if (this.FarmerSick && turnTheHeatOn) { totalMulti += 1; condList.Add("Cold House"); } if (this.FarmerSick && conditions.Contains("thundersnow") && SDVTime.IsNight) { totalMulti += .5; condList.Add("Night Thundersnow"); } if (this.FarmerSick && conditions.Contains("blizzard") && SDVTime.IsNight) { totalMulti += .5; condList.Add("Night Blizzard"); } if (this.FarmerSick && conditions.Contains("heatwave") && !SDVTime.IsNight) { totalMulti += 1.25; condList.Add("Day Heatwave"); } } staminaAffect -= (int)Math.Floor(IllOptions.StaminaDrain * totalMulti); if (IllOptions.Verbose && this.FarmerSick) { string condString = "[ "; for (int i = 0; i < condList.Count; i++) { if (i != condList.Count - 1) { condString += condList[i] + ", "; } else { condString += condList[i]; } } condString += " ]"; Monitor.Log($"[{Game1.timeOfDay}] Conditions for the drain are {condString} for a total multiplier of {totalMulti} for a total drain of {staminaAffect}"); } return(staminaAffect); }
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 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(); } }
public void ClearDrain() { FarmerSick = false; SDVUtilities.ShowMessage(Helper.Get("hud-text.desc_cold_removed")); }
/// <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 (Conditions.HasWeather(CurrentWeather.Fog)) { if (!Game1.currentLocation.IsOutdoors && Game1.currentLocation is DecoratableLocation && WeatherOpt.DarkenLightInFog) { var loc = (DecoratableLocation)Game1.currentLocation; foreach (Furniture f in loc.furniture) { //Yes, *add* lights removes them. No, don't ask me why. 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); } } } } if (Game1.currentLocation.IsOutdoors && Conditions.HasWeather(CurrentWeather.Lightning) && !Conditions.HasWeather(CurrentWeather.Rain) && Game1.timeOfDay < 2400) { Utility.performLightningUpdate(); } //queued messages clear if (Game1.timeOfDay == 610 && queuedMsg != null) { Game1.hudMessages.Add(queuedMsg); queuedMsg = null; } //frost works at night, heatwave works during the day if (Game1.timeOfDay == 1700) { if (Conditions.HasWeather(CurrentWeather.Heatwave)) { ExpireTime = 2000; Farm f = Game1.getFarm(); int count = 0, maxCrops = (int)Math.Floor(SDVUtilities.CropCountInFarm(f) * WeatherOpt.DeadCropPercentage); foreach (KeyValuePair <Vector2, TerrainFeature> tf in f.terrainFeatures.Pairs) { if (count >= maxCrops) { break; } if (tf.Value is HoeDirt curr && curr.crop != null) { if (Dice.NextDouble() <= WeatherOpt.CropResistance) { CropList.Add(tf.Key); curr.state.Value = HoeDirt.dry; count++; } } } if (CropList.Count > 0) { if (WeatherOpt.AllowCropDeath) { SDVUtilities.ShowMessage(Helper.Translation.Get("hud-text.desc_heatwave_kill"), 3); } else { SDVUtilities.ShowMessage(Helper.Translation.Get("hud-text.desc_heatwave_dry"), 3); } } } } if (Game1.timeOfDay == ExpireTime && WeatherOpt.AllowCropDeath) { //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) { hd.crop.dead.Value = true; cDead = true; } } if (cDead) { SDVUtilities.ShowMessage(Helper.Translation.Get("hud-text.desc_heatwave_cropdeath"), 3); } } }
/// <summary> /// Handles the ten minute update tick /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Parameters</param> private void TenMinuteUpdate(object sender, EventArgsIntChanged e) { if (!Game1.hasLoadedGame) { return; } Conditions.TenMinuteUpdate(); if (IsEclipse) { Game1.globalOutdoorLighting = .5f; Game1.ambientLight = nightColor; Game1.currentLocation.switchOutNightTiles(); ResetTicker = 1; 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 ((Game1.farmEvent == null && Game1.random.NextDouble() < (0.25 - Game1.dailyLuck / 2.0)) && ((WeatherOpt.SpawnMonsters && Game1.spawnMonstersAtNight) || (WeatherOpt.SpawnMonstersAllFarms))) { Monitor.Log("Spawning a monster, or attempting to.", LogLevel.Debug); if (Game1.random.NextDouble() < 0.25) { if (this.Equals(Game1.currentLocation)) { Game1.getFarm().spawnFlyingMonstersOffScreen(); return; } } else { Game1.getFarm().spawnGroundMonsterOffScreen(); } } } 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) { //Yes, *add* lights removes them. No, don't ask me why. 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 }); } } } } if (Game1.currentLocation.isOutdoors && Conditions.HasWeather(CurrentWeather.Lightning) && Game1.timeOfDay < 2400) { Utility.performLightningUpdate(); } //queued messages clear if (Game1.timeOfDay == 610 && queuedMsg != null) { Game1.hudMessages.Add(queuedMsg); queuedMsg = null; } //frost works at night, heatwave works during the day if (Game1.timeOfDay == 1700) { if (Conditions.HasWeather(CurrentWeather.Heatwave)) { ExpireTime = 2000; Farm f = Game1.getFarm(); int count = 0, maxCrops = (int)Math.Floor(SDVUtilities.CropCountInFarm(f) * WeatherOpt.DeadCropPercentage); foreach (KeyValuePair <Vector2, TerrainFeature> tf in f.terrainFeatures) { if (count >= maxCrops) { break; } if (tf.Value is HoeDirt curr && curr.crop != null) { if (Dice.NextDouble() <= WeatherOpt.CropResistance) { CropList.Add(tf.Key); curr.state = HoeDirt.dry; count++; } } } if (CropList.Count > 0) { if (WeatherOpt.AllowCropDeath) { SDVUtilities.ShowMessage(Helper.Translation.Get("hud-text.desc_heatwave_kill")); } else { SDVUtilities.ShowMessage(Helper.Translation.Get("hud-text.desc_heatwave_dry")); } } } } if (Game1.timeOfDay == ExpireTime && WeatherOpt.AllowCropDeath) { //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 == HoeDirt.dry) { hd.crop.dead = true; cDead = true; } } if (cDead) { SDVUtilities.ShowMessage(Helper.Translation.Get("hud-text.desc_heatwave_cropdeath")); } } float oldStamina = Game1.player.stamina; Game1.player.stamina += StaminaMngr.TenMinuteTick(Conditions, TicksOutside, TicksTotal, Dice); if (Game1.player.stamina <= 0) { SDVUtilities.FaintPlayer(); } TicksTotal = 0; TicksOutside = 0; }