Ejemplo n.º 1
0
        private void ForceShaft(StardewValley.Locations.MineShaft mine)
        {
            var mineRandom = Helper.Reflection.GetField <Random>(mine, "mineRandom").GetValue();
            var r          = Cloner.Clone(mineRandom);
            var next       = r.NextDouble();

            while (next >= 0.2)
            {
                next = r.NextDouble();
                mineRandom.NextDouble();
            }
            _nextIsShaft = true;
        }
Ejemplo n.º 2
0
        private bool FindLadders(StardewValley.Locations.MineShaft mine)
        {
            var ladderHasSpawned = Helper.Reflection.GetField <bool>(mine, "ladderHasSpawned").GetValue();

            if (ladderHasSpawned || mine.mustKillAllMonstersToAdvance() || !mine.shouldCreateLadderOnThisLevel())
            {
                return(true);
            }
            var netStonesLeftOnThisLevel = Helper.Reflection
                                           .GetField <NetIntDelta>(mine, "netStonesLeftOnThisLevel").GetValue().Value;
            var chance = 0.02 + 1.0 / Math.Max(1, netStonesLeftOnThisLevel) + Game1.player.LuckLevel / 100.0 +
                         Game1.player.DailyLuck / 5.0;

            if (mine.EnemyCount == 0)
            {
                chance += 0.04;
            }
            foreach (var pair in mine.Objects.Pairs.Where(pair => pair.Value.Name.Equals("Stone")))
            {
                var obj = pair.Value;
                // ladder chance calculation taken from checkStoneForItems function in MineShaft class
                var r = new Random((int)pair.Key.X * 1000 + (int)pair.Key.Y + mine.mineLevel + (int)Game1.uniqueIDForThisGame / 2);
                r.NextDouble();
                var next = r.NextDouble();
                if ((netStonesLeftOnThisLevel == 0 || next < chance) && obj.ParentSheetIndex / 24 < Game1.objectSpriteSheet.Height)
                {
                    _ladderStones.Add(new LadderStone(obj));
                }
            }
            if (_config.ForceShafts && mine.getMineArea() == StardewValley.Locations.MineShaft.desertArea &&
                !_nextIsShaft && _ladderStones.Count > 0)
            {
                ForceShaft(mine);
            }
            return(_ladderStones.Count > 0);
        }
Ejemplo n.º 3
0
        private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e)
        {
            if (r.Next(9) == 1)
            {
                StardewValley.Object foragedObject = null;
                int quality = 0;
                if (buffOwner.ForagingLevel - 2 <= 2)
                {
                    quality = 1;
                }
                if (buffOwner.ForagingLevel - 2 <= 6)
                {
                    quality = 2;
                }
                if (buffOwner.ForagingLevel - 2 <= 9)
                {
                    quality = 3;
                }
                else
                {
                    quality = 4;
                }
                GameLocation location = buffOwner.currentLocation;
                StardewValley.Locations.MineShaft ms = location as StardewValley.Locations.MineShaft;
                if (location.IsOutdoors)
                {
                    string locationName = buffOwner.currentLocation.Name;
                    if (locationName.Equals("Woods"))
                    {
                        string season = Game1.currentSeason;
                        switch (season)
                        {
                        case "spring":
                            foragedObject = new StardewValley.Object(woodsSpringForage[r.Next(2)], 1, false, -1, quality); break;

                        case "summer":
                            foragedObject = new StardewValley.Object(woodsSummerForage[r.Next(2)], 1, false, -1, quality); break;

                        case "fall":
                            foragedObject = new StardewValley.Object(woodsFallForage[r.Next(2)], 1, false, -1, quality); break;

                        default:
                            foragedObject = new StardewValley.Object(winterForage[r.Next(5)], 1, false, -1, quality); break;
                        }
                    }
                    else if (locationName.Equals("Beach"))
                    {
                        foragedObject = new StardewValley.Object(beachForage[r.Next(8)], 1, false, -1, quality);
                    }
                    else if (locationName.Equals("Desert"))
                    {
                        foragedObject = new StardewValley.Object(desertForage[r.Next(2)], 1, false, -1, quality);
                    }
                    else
                    {
                        string season = Game1.currentSeason;
                        switch (season)
                        {
                        case "spring":
                            foragedObject = new StardewValley.Object(springForage[r.Next(6)], 1, false, -1, quality); break;

                        case "summer":
                            foragedObject = new StardewValley.Object(summerForage[r.Next(3)], 1, false, -1, quality); break;

                        case "fall":
                            foragedObject = new StardewValley.Object(fallForage[r.Next(4)], 1, false, -1, quality); break;

                        case "winter":
                            foragedObject = new StardewValley.Object(winterForage[r.Next(5)], 1, false, -1, quality); break;
                        }
                    }

                    if (foragedObject != null)
                    {
                    }
                }
                else if (ms != null && combatWithheldDialogue.Count == 0)
                {
                    foragedObject = new StardewValley.Object(caveForage[r.Next(3)], 1, false, -1, quality);
                }

                if (foragedObject != null)
                {
                    buffGranter.showTextAboveHead("!", -1, 2, 3000, 0);
                    foragedObjects.Add(foragedObject);

                    if (forageFoundDialogue == null)
                    {
                        Dialogue d = manager.GenerateDialogue("Perk", "Leah", true);
                        forageFoundDialogue =
                            d ?? throw new Exception(
                                      "Tried to push an foraging dialogue, but there weren't any!");
                        buffGranter.CurrentDialogue.Push(d);
                    }
                }
            }

            if (foragedObjects.Count > 0 &&
                !buffGranter.CurrentDialogue.Contains(forageFoundDialogue) &&
                combatWithheldDialogue.Count == 0)
            {
                buffGranter.CurrentDialogue.Push(forageFoundDialogue);
            }
        }
Ejemplo n.º 4
0
        private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e)
        {
            if (r.Next(2) == 1 && foragedObject == null)
            {
                GameLocation location = buffOwner.currentLocation;
                StardewValley.Locations.MineShaft ms = location as StardewValley.Locations.MineShaft;
                if (location.IsOutdoors)
                {
                    string locationName = buffOwner.currentLocation.Name;
                    if (locationName.Equals("Woods"))
                    {
                        string season = Game1.currentSeason;
                        switch (season)
                        {
                        case "spring":
                            foragedObject = new StardewValley.Object(woodsSpringForage[r.Next(2)], 1, false, -1, 4); break;

                        case "summer":
                            foragedObject = new StardewValley.Object(woodsSummerForage[r.Next(2)], 1, false, -1, 4); break;

                        case "fall":
                            foragedObject = new StardewValley.Object(woodsFallForage[r.Next(2)], 1, false, -1, 4); break;

                        default:
                            foragedObject = new StardewValley.Object(winterForage[r.Next(5)], 1, false, -1, 4); break;
                        }
                    }
                    else if (locationName.Equals("Beach"))
                    {
                        foragedObject = new StardewValley.Object(beachForage[r.Next(8)], 1, false, -1, 4);
                    }
                    else if (locationName.Equals("Desert"))
                    {
                        foragedObject = new StardewValley.Object(desertForage[r.Next(2)], 1, false, -1, 4);
                    }
                    else
                    {
                        string season = Game1.currentSeason;
                        switch (season)
                        {
                        case "spring":
                            foragedObject = new StardewValley.Object(springForage[r.Next(6)], 1, false, -1, 4); break;

                        case "summer":
                            foragedObject = new StardewValley.Object(summerForage[r.Next(3)], 1, false, -1, 4); break;

                        case "fall":
                            foragedObject = new StardewValley.Object(fallForage[r.Next(4)], 1, false, -1, 4); break;

                        case "winter":
                            foragedObject = new StardewValley.Object(winterForage[r.Next(5)], 1, false, -1, 4); break;
                        }
                    }

                    buffGranter.showTextAboveHead("!", -1, 2, 3000, 0);
                    string dialogueString = r.Next(2) == 0
                        ? forageFoundStrings[0] + foragedObject.Name + "!"
                        : forageFoundStrings[1] + foragedObject.Name + forageFoundStrings[2];
                    Dialogue d = new Dialogue(dialogueString, buffGranter);
                    buffGranter.CurrentDialogue.Push(d);
                    forageFoundDialogue = d;
                }
                else if (ms != null && manager.combatWithheldDialogue.Count == 0)
                {
                    foragedObject = new StardewValley.Object(caveForage[r.Next(3)], 1, false, -1, 4);

                    buffGranter.showTextAboveHead("!", -1, 2, 3000, 0);
                    string dialogueString = r.Next(2) == 0
                        ? forageFoundStrings[0] + foragedObject.Name + "!"
                        : forageFoundStrings[1] + foragedObject.Name + forageFoundStrings[2];
                    Dialogue d = new Dialogue(dialogueString, buffGranter);
                    buffGranter.CurrentDialogue.Push(d);
                    forageFoundDialogue = d;
                }
            }

            if (foragedObject != null &&
                !buffGranter.CurrentDialogue.Contains(forageFoundDialogue) &&
                manager.combatWithheldDialogue.Count == 0)
            {
                buffGranter.CurrentDialogue.Push(forageFoundDialogue);
            }
        }