Exemplo n.º 1
0
 public void OnNewDay()
 {
     FarmerSick           = false;
     ReasonSick           = IllCauses.None;
     IssuedInHouseWarning = false;
     turnTheHeatOn        = false;
 }
Exemplo n.º 2
0
        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);
        }