public void UpdateTerminals(MultiShopController self) { // choose random item tier ItemTierShopConfig itemTierConfig = PickRandomItemTier(); MultiShop.RepopulateTerminals(self, itemTierConfig); }
public void CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self) { // choose random item tier ItemTierShopConfig itemTierConfig = PickRandomItemTier(); self.itemTier = itemTierConfig.itemTier; self.Networkcost = 1; MultiShop.CreateTerminals(orig, self, itemTierConfig); }
public void CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, RoR2.MultiShopController self) { int index = MultiShop.instances.Count; // I don't super like this ItemTierShopConfig itemTierConfig = ModConfig.tierWeights[index]; self.itemTier = itemTierConfig.itemTier; self.Networkcost = itemTierConfig.price; MultiShop.CreateTerminals(orig, self, itemTierConfig); }
private ItemTierShopConfig PickRandomItemTier() { double randomVal = random.NextDouble() * ModConfig.tierTotal; double currentVal = ModConfig.tierTotal; ItemTierShopConfig itemTierConfig = new ItemTierShopConfig(); for (int i = ModConfig.tierWeights.Count - 1; i > 0; i--) { currentVal -= ModConfig.tierWeights[i].tierWeight; if (randomVal >= currentVal) { itemTierConfig = ModConfig.tierWeights[i]; break; } } return(itemTierConfig); }
public static void RepopulateTerminals(MultiShopController multiShopController, ItemTierShopConfig itemTierConfig) { GameObject[] terminalGameObjects = multiShopController.GetFieldValue <GameObject[]>("terminalGameObjects"); for (int i = 0; i < multiShopController.terminalPositions.Length; i++) { List <PickupIndex> otherItemsList = new List <PickupIndex>(); PickupIndex newPickupIndex = PickupIndex.none; Xoroshiro128Plus treasureRng = Run.instance.treasureRng; switch (itemTierConfig.itemTier) { case ItemTier.Tier1: newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList); break; case ItemTier.Tier2: newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList); break; case ItemTier.Tier3: newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList); break; case ItemTier.Lunar: newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableLunarDropList); break; case ItemTier.Boss: otherItemsList = new List <PickupIndex>(); var bossItemIndexList = R2API.ItemDropAPI.GetDefaultDropList(ItemTier.Boss); foreach (var itemIndex in bossItemIndexList) { otherItemsList.Add(new PickupIndex(itemIndex)); } newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList); break; case ItemTier.NoTier: if (itemTierConfig.isEquipment) { otherItemsList = new List <PickupIndex>(); var equipmentIndexList = R2API.ItemDropAPI.GetDefaultEquipmentDropList(); foreach (var itemIndex in equipmentIndexList) { otherItemsList.Add(new PickupIndex(itemIndex)); } newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList); //self.itemTier = ItemTier.Tier1; } break; } bool newHidden = Run.instance.treasureRng.nextNormalizedFloat < 0.2f; terminalGameObjects[i].GetComponent <ShopTerminalBehavior>().SetPickupIndex(newPickupIndex, newHidden); } }
public static void CreateTerminals(On.RoR2.MultiShopController.orig_CreateTerminals orig, MultiShopController self, ItemTierShopConfig itemTierConfig) { // Boss Items and Equipment can not be part of multi shops by default, so needs a special case List <PickupIndex> otherItemsList = new List <PickupIndex>(); if (itemTierConfig.itemTier == ItemTier.Boss) { var itemIndexList = R2API.ItemDropAPI.GetDefaultDropList(ItemTier.Boss); foreach (var itemIndex in itemIndexList) { otherItemsList.Add(new PickupIndex(itemIndex)); } } else if (itemTierConfig.itemTier == ItemTier.NoTier && itemTierConfig.isEquipment) { var itemIndexList = R2API.ItemDropAPI.GetDefaultEquipmentDropList(); foreach (var itemIndex in itemIndexList) { otherItemsList.Add(new PickupIndex(itemIndex)); } } if (otherItemsList.Count > 0) { self.SetFieldValue("terminalGameObjects", new GameObject[self.terminalPositions.Length]); for (int i = 0; i < self.terminalPositions.Length; i++) { PickupIndex newPickupIndex = PickupIndex.none; Xoroshiro128Plus treasureRng = Run.instance.treasureRng; newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList); bool newHidden = Run.instance.treasureRng.nextNormalizedFloat < 0.2f; GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(self.terminalPrefab, self.terminalPositions[i].position, self.terminalPositions[i].rotation); self.GetFieldValue <GameObject[]>("terminalGameObjects")[i] = gameObject; gameObject.GetComponent <ShopTerminalBehavior>().SetPickupIndex(newPickupIndex, newHidden); NetworkServer.Spawn(gameObject); } return; } orig(self); }
public static void InitConfig(ConfigFile config) { GameMode = config.Wrap( "1. General", "-- GameMode", "Set the desired game mode." + "\n 0 - Default mode: Spawn X amount of multi shops with random item tiers." + "\n 1 - Alternate mode: Spawn one multi shop for each enabled tier" + "\n(Default value: 0)", 0); MoneyGrantedPerTeleporterBossClear = config.Wrap( "1. General", "-- MoneyGrantedPerTeleporterBossClear", "Set how much money, and thus items, each player obtains after every teleporter boss clear\n(Default value: 8)", 8); BossSpawnCostReductionMultiplier = config.Wrap( "1. General", "-- BossSpawnCostReductionMultiplier", "Set how much less boss enemies (champions) cost the game to spawn. A higher value means that the game can afford to spawn more or stronger boss type enemies.\nSetting this to 2 e.g. should spawn two bosses on the first stage in single player, rather than just one. \n(Default value: 1.0 (float))", 1f); RandomBosses = config.Wrap( "1. General", "-- RandomBosses", "Bosses will be random, rather than stage dependant.\n(Default value: false)", false); // ITEM TIERS Tier1Enabled = config.Wrap( "2. Item Tiers", "-- Tier1", "Enable tier 1 items to appear in the multishop\n(Default value: true)", true); Tier2Enabled = config.Wrap( "2. Item Tiers", "-- Tier2", "Enable tier 2 items to appear in the multishop\n(Default value: true)", true); Tier3Enabled = config.Wrap( "2. Item Tiers", "-- Tier3", "Enable tier 3 items to appear in the multishop\n(Default value: true)", true); TierBossEnabled = config.Wrap( "2. Item Tiers", "-- TierBoss", "Enable boss tier items to appear in the multishop\n(Default value: false)", false); TierLunarEnabled = config.Wrap( "2. Item Tiers", "-- TierLunar", "Enable lunar tier items to appear in the multishop\n(Default value: false)", false); EquipmentEnabled = config.Wrap( "2. Item Tiers", "-- EquipmentEnabled", "Enable equipment items to appear in the multishop\n(Default value: true)", true); // Game Mode Config MultiShopAmount = config.Wrap( "3. DefaultMode Options", "-- MultiShopAmount", "Set the amount of multishops that spawn after the boss is defeated\n(Default value: 3)", 3); MultiShopAmountScaleWithPlayer = config.Wrap( "3. DefaultMode Options", "-- MultiShopAmountScaleWithPlayer", "Overrides the amount specified at MultiShopAmount and instead scales the amount of multishops with amount of players (one shop per player)\n(Default value: false)", false); // TIER WEIGHTS Tier1Weight = config.Wrap( "3. DefaultMode Options", "-- Tier1Weights", "Set the weight for Tier 1 items to appear in the multishop\n(Default value: 0.8)", 0.8f); Tier2Weight = config.Wrap( "3. DefaultMode Options", "-- Tier2Weights", "Set the weight for Tier 2 items to appear in the multishop\n(Default value: 0.2)", 0.2f); Tier3Weight = config.Wrap( "3. DefaultMode Options", "-- Tier3Weights", "Set the weight for Tier 3 items to appear in the multishop\n(Default value: 0.1)", 0.1f); TierBossWeight = config.Wrap( "3. DefaultMode Options", "-- TierBossWeights", "Set the weight for Boss items to appear in the multishop\n(Default value: 0.05)", 0.05f); TierLunarWeight = config.Wrap( "3. DefaultMode Options", "-- TierLunarWeights", "Set the weight for Lunar items to appear in the multishop\n(Default value: 0.1)", 0.1f); EquipmentWeight = config.Wrap( "3. DefaultMode Options", "-- EquipmentWeight", "Set the weight for equipment items to appear in the multishop\n(Default value: 0.1)", 0.1f); Tier1Price = config.Wrap( "4. AlternateMode Options", "-- Tier1Price", "Set the price for tier 1 items\n(Default value: 1)", 1); Tier2Price = config.Wrap( "4. AlternateMode Options", "-- Tier2Price", "Set the price for tier 2 items\n(Default value: 2)", 2); Tier3Price = config.Wrap( "4. AlternateMode Options", "-- Tier3Price", "Set the price for tier 3 items\n(Default value: 4)", 4); TierBossPrice = config.Wrap( "4. AlternateMode Options", "-- TierBossPrice", "Set the price for boss tier items\n(Default value: 7)", 7); TierLunarPrice = config.Wrap( "4. AlternateMode Options", "-- TierLunarPrice", "Set the price for lunar tier items\n(Default value: 5)", 5); EquipmentPrice = config.Wrap( "4. AlternateMode Options", "-- TierEquipmentPrice", "Set the price for equipment items\n(Default value: 3)", 3); if (Tier1Enabled.Value && Tier1Weight.Value != 0f) { ItemTierShopConfig tierWeightConf = new ItemTierShopConfig { itemTier = ItemTier.Tier1, tierWeight = Tier1Weight.Value, isEquipment = false, price = Tier1Price.Value }; tierWeights.Add(tierWeightConf); tierTotal += tierWeightConf.tierWeight; } if (Tier2Enabled.Value && Tier2Weight.Value != 0f) { ItemTierShopConfig tierWeightConf = new ItemTierShopConfig { itemTier = ItemTier.Tier2, tierWeight = Tier2Weight.Value, isEquipment = false, price = Tier2Price.Value }; tierWeights.Add(tierWeightConf); tierTotal += tierWeightConf.tierWeight; } if (Tier3Enabled.Value && Tier3Weight.Value != 0f) { ItemTierShopConfig tierWeightConf = new ItemTierShopConfig { itemTier = ItemTier.Tier3, tierWeight = Tier3Weight.Value, isEquipment = false, price = Tier3Price.Value }; tierWeights.Add(tierWeightConf); tierTotal += tierWeightConf.tierWeight; } if (TierBossEnabled.Value && TierBossWeight.Value != 0f) { ItemTierShopConfig tierWeightConf = new ItemTierShopConfig { itemTier = ItemTier.Boss, tierWeight = TierBossWeight.Value, isEquipment = false, price = TierBossPrice.Value }; tierWeights.Add(tierWeightConf); tierTotal += tierWeightConf.tierWeight; } if (TierLunarEnabled.Value && TierLunarWeight.Value != 0f) { ItemTierShopConfig tierWeightConf = new ItemTierShopConfig { itemTier = ItemTier.Lunar, tierWeight = TierLunarWeight.Value, isEquipment = false, price = TierLunarPrice.Value }; tierWeights.Add(tierWeightConf); tierTotal += tierWeightConf.tierWeight; } if (EquipmentEnabled.Value && EquipmentWeight.Value != 0f) { ItemTierShopConfig tierWeightConf = new ItemTierShopConfig { itemTier = ItemTier.NoTier, tierWeight = EquipmentWeight.Value, isEquipment = true, price = EquipmentPrice.Value }; tierWeights.Add(tierWeightConf); tierTotal += tierWeightConf.tierWeight; } }