private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e) { if (railroad != null && !railroadMapBlocked && isMainPlayer) { if (Game1.player.currentLocation.IsOutdoors && railroad.train.Value == null) { if (forceNewTrain) { CreateNewTrain(); } else if (enableCreatedTrain && numberOfTrains < maxNumberOfTrains && e.NewTime >= startTimeOfFirstTrain && Game1.random.NextDouble() <= pctChanceOfNewTrain) { CreateNewTrain(); } } if (railroad.train.Value != null && !enableCreatedTrain) { enableCreatedTrain = true; trainType = (TRAINS)railroad.train.Value.type.Value; } } }
private void CreateNewTrain() { numberOfRewardsPerTrain = 0; railroad.setTrainComing(config.trainCreateDelay); numberOfTrains++; forceNewTrain = false; trainType = TRAINS.UNKNOWN; //this.Monitor.Log($"Setting train... Choo choo... {Game1.timeOfDay}"); enableCreatedTrain = false; }
private void CreateNewTrain() { numberOfRewardsPerTrain = 0; railroad.setTrainComing(config.trainCreateDelay); numberOfTrains++; forceNewTrain = false; trainType = TRAINS.UNKNOWN; //this.Monitor.Log($"Setting train... Choo choo... {Game1.timeOfDay}"); enableCreatedTrain = false; SendMulitplayerMessage("A train is approaching Stardew Valley..."); }
private static Item GetCustomTrainTreasure(TRAINS index) { TrainData trainData = BetterTrainLootMod.Instance.trainCars[index]; // Possible treasure based on selected treasure group selected above. List <TrainTreasure> possibleLoot = new List <TrainTreasure>(trainData.treasureList) .Where(loot => loot.Enabled && loot.IsValid()) .OrderBy(loot => loot.Chance) .ThenBy(loot => loot.Id) .ToList(); if (possibleLoot.Count == 0) { BetterTrainLootMod.Instance.Monitor.Log($" Group: {trainData.TrainCarID}, No Possible Loot Found... check the logic"); } TrainTreasure treasure = possibleLoot.ChooseItem(Game1.random); int id = treasure.Id; // Lost books have custom handling -- No default lost books... but someone might configure them if (id == 102) // LostBook Item ID { if (Game1.player.archaeologyFound == null || !Game1.player.archaeologyFound.ContainsKey(102) || Game1.player.archaeologyFound[102][0] >= 21) { possibleLoot.Remove(treasure); } Game1.showGlobalMessage("You found a lost book. The library has been expanded."); } Item reward; // Create reward item if ((id >= 516 && id <= 534) || id == 810 || id == 811 || id == 839 || (id >= 859 && id <= 863) || id == 887 || id == 888) { reward = new Ring(id); } else if ((id >= 504 && id <= 515) || id == 804 || id == 806 || id == 853 || id == 854 || id == 855 || id == 878) { reward = new Boots(id); } //reward = new Clothing(id); //reward = new Hat(id); else { reward = (Item) new StardewValley.Object(id, 1); // Note: if any boots or rings are in the treasure list, they will not be equipable } return(reward); }
private static void CheckForTreasure(TRAINS trainType, Vector2 globalPosition) { double chance = (trainType != TRAINS.PRESENT_TRAIN) ? BetterTrainLootMod.Instance.config.baseChancePercent + Game1.dailyLuck : 3.0 * BetterTrainLootMod.Instance.config.baseChancePercent + Game1.dailyLuck; // SDV 1.4... use Game1.player.DailyLuck int maxNumberOfItems = (trainType != TRAINS.PRESENT_TRAIN) ? BetterTrainLootMod.Instance.config.maxNumberOfItemsPerTrain : 3 * BetterTrainLootMod.Instance.config.maxNumberOfItemsPerTrain; if ((Game1.random.NextDouble() <= chance && BetterTrainLootMod.Instance.config.useCustomTrainTreasure && BetterTrainLootMod.numberOfRewardsPerTrain < maxNumberOfItems) || BetterTrainLootMod.Instance.config.enableNoLimitTreasurePerTrain) { Item reward = GetCustomTrainTreasure(trainType); if (reward.ParentSheetIndex != -1) { Game1.createObjectDebris(reward.ParentSheetIndex, (int)globalPosition.X / 64, (int)globalPosition.Y / 64, (int)((double)globalPosition.Y + 320.0), 0, 1f, (GameLocation)null); BetterTrainLootMod.numberOfRewardsPerTrain++; } } }
public TrainData(TRAINS id) { this.TrainCarID = id; }