private void AddBuffOnUse(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { orig(self, activator); if (!activator) { return; } CharacterBody characterBody = activator.GetComponent <CharacterBody>(); if (characterBody && characterBody.inventory) { var itemCount = GetCount(characterBody); if (itemCount > 0) { var isBloodShrine = self.costType == CostTypeIndex.PercentHealth; var isCost = self.costType > CostTypeIndex.None; if (isCost) { if ((isBloodShrine && HealOnBloodShrineUse.Value) || !isBloodShrine) { Heal(characterBody); } } } } }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { orig(self, activator); if (self && self.CanBeAffordedByInteractor(activator) && !self.GetComponent <RecombobulatorFlag>()) { self.gameObject.AddComponent <RecombobulatorFlag>(); } }
private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (!self.CanBeAffordedByInteractor(activator)) { return; } #region Sharedmoney if (ShareSuite.MoneyIsShared.Value) { switch (self.costType) { case CostTypeIndex.Money: { // Remove money from shared money pool orig(self, activator); SharedMoneyValue -= self.cost; return; } case CostTypeIndex.PercentHealth: { // Share the damage taken from a sacrifice // as it generates shared money orig(self, activator); var teamMaxHealth = 0; foreach (var playerCharacterMasterController in PlayerCharacterMasterController.instances) { var charMaxHealth = playerCharacterMasterController.master.GetBody().maxHealth; if (charMaxHealth > teamMaxHealth) { teamMaxHealth = (int)charMaxHealth; } } var purchaseInteraction = self.GetComponent <PurchaseInteraction>(); var shrineBloodBehavior = self.GetComponent <ShrineBloodBehavior>(); var amount = (uint)(teamMaxHealth * purchaseInteraction.cost / 100.0 * shrineBloodBehavior.goldToPaidHpRatio); if (ShareSuite.MoneyScalarEnabled.Value) { amount *= (uint)ShareSuite.MoneyScalar.Value; } SharedMoneyValue += (int)amount; return; } } } orig(self, activator); #endregion }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { orig(self, activator); if (self.displayNameToken.ToLower() == "shrine_boss_name") { var bossBehavior = self.GetComponent <ShrineBossBehavior>(); bossBehavior.maxPurchaseCount = maxpurchase.Value; bossBehavior.refreshTimer = delaytime.Value; } }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { orig(self, activator); var shopTerminal = self.GetComponent <ShopTerminalBehavior>(); var user = UsersHelper.GetUser(activator); if (shopTerminal && user && CheckIfCostTypeIsItem(self.costType)) { if (!watchedPrintedItems.ContainsKey(user.id)) { watchedPrintedItems[user.id] = new PrintedItems(); } watchedPrintedItems[user.id].AddPrintedItem(shopTerminal.itemTier); } }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { CA_Manager[] allManagers = FindObjectsOfType <CA_Manager>(); for (int i = 0; i < allManagers.Length; i++) { //-1 = Error; 0 = Same but not idling; 1 = Same and Idling; 2 = Not same; 3 = Not a chest int check = allManagers[i].PurchaseInteraction_Receiver(self, activator); //Chat.AddMessage("Check: " + check); if (check == 1 || check == 3) { orig.Invoke(self, activator); break; } else if (check == 0) { break; } } }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (SceneInfo.instance.countsAsStage) { if (!self.CanBeAffordedByInteractor(activator)) { return; } MultiShopController usedShop = GetMultiShopController(self); if (usedShop != null) { self.GetComponent <ShopTerminalBehavior>().DropPickup(); CharacterBody characterBody = activator.GetComponent <CharacterBody>(); characterBody.master.GiveMoney((uint)-usedShop.Networkcost); gameMode.UpdateTerminals(usedShop); return; } } orig(self, activator); }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { orig(self, activator); CharacterBody characterBody = activator.GetComponent <CharacterBody>(); if (characterBody && characterBody.inventory) { var itemCount = GetCount(characterBody); if (itemCount > 0) { var isBloodShrine = self.costType == CostTypeIndex.PercentHealth; if ((isBloodShrine && Mustache_BloodShrine) || !isBloodShrine) { if (Mustache_BloodShrine) { Heal(characterBody); } } } } }
private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (!self.CanBeAffordedByInteractor(activator)) { return; } var characterBody = activator.GetComponent <CharacterBody>(); var inventory = characterBody.inventory; #region Cauldronfix // If this is not a multi-player server or the fix is disabled, do the normal drop action if (!GeneralHooks.IsMultiplayer() || !ShareSuite.PrinterCauldronFixEnabled.Value) { orig(self, activator); return; } var shop = self.GetComponent <ShopTerminalBehavior>(); // If the cost type is an item, give the user the item directly and send the pickup message if (self.costType == CostTypeIndex.WhiteItem || self.costType == CostTypeIndex.GreenItem || self.costType == CostTypeIndex.RedItem || self.costType == CostTypeIndex.BossItem || self.costType == CostTypeIndex.LunarItemOrEquipment) { var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex; inventory.GiveItem(item); SendPickupMessage(inventory.GetComponent <CharacterMaster>(), shop.CurrentPickupIndex()); } #endregion Cauldronfix orig(self, activator); }
private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (!self.CanBeAffordedByInteractor(activator)) { return; } if (!GeneralHooks.IsMultiplayer()) { orig(self, activator); return; } var shop = self.GetComponent <ShopTerminalBehavior>(); #region Cauldronfix if (ShareSuite.PrinterCauldronFixEnabled.Value) { var characterBody = activator.GetComponent <CharacterBody>(); var inventory = characterBody.inventory; if (self.costType == CostTypeIndex.WhiteItem || self.costType == CostTypeIndex.GreenItem || self.costType == CostTypeIndex.RedItem || self.costType == CostTypeIndex.BossItem || self.costType == CostTypeIndex.LunarItemOrEquipment) { var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex; inventory.GiveItem(item); ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(), shop.CurrentPickupIndex()); orig(self, activator); return; } } #endregion Cauldronfix #region EquipDronefix if (ShareSuite.EquipmentShared.Value) { var rng = self.GetComponent <Xoroshiro128Plus>(); var itemIndex = ItemIndex.None; var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType); if (shop) { itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex; } var payCostResults = costTypeDef.PayCost(self.cost, activator, self.gameObject, rng, itemIndex); foreach (var equipmentIndex in payCostResults.equipmentTaken) { //TODO fix equipment drones here } } #endregion EquipDronefix orig(self, activator); }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, RoR2.PurchaseInteraction self, RoR2.Interactor activator) { //Get the lowercase name of the Interacted Object string objName = self.gameObject.name.ToLower(); //Check if its a supported Chest if (!objName.Contains("chest1") && !objName.Contains("chest2") && !objName.Contains("goldchest") && !objName.Contains("equipmentbarrel") && !objName.Contains("isclockbox")) { orig.Invoke(self, activator); return; } //Get the chest type //Too lazy and tired to make it prettier int chestType = objName.Contains("chest1") ? 0 : objName.Contains("chest2") ? 1 : objName.Contains("goldchest") ? 2 : objName.Contains("isclockbox") ? 3 : -1; //Randomly Select Tier double tier = GetRandomTier(chestType); //Send every client a message that a chest has been opened ExampleFuncClient.Invoke(activator.gameObject, check => { //Check which client opened the chest and wheter or not he is idling Debug.Log("Check: " + check); if (check == 0) { orig.Invoke(self, activator); } if (check != 0) { return; } if (objName.Contains("equipmentbarrel")) { //Signal the server that a chest has been opened //Give the player that opend it and the chest position ExampleCommandClientCustom.Invoke(x => { x.Write("Chest"); x.Write(activator.gameObject); x.Write(self.gameObject.transform); //Specify tier as Equipment x.Write((double)6); }); } else { // RNG Value was above specified percantage values // Cancel the drop /*if (tier == 0) * { * Debug.Log("Mhh Unlucky you found nothing in this Chest."); * return; * }*/ //Signal the server that a chest has been opened //Give the player that opend it and the chest position ExampleCommandClientCustom.Invoke(x => { x.Write("Chest"); x.Write(activator.gameObject); x.Write(self.gameObject.transform); x.Write(tier); }); } }); }
private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (!self.CanBeAffordedByInteractor(activator)) { return; } if (!GeneralHooks.IsMultiplayer()) { orig(self, activator); return; } if (self.costType == CostTypeIndex.None) { orig(self, activator); return; } var shop = self.GetComponent <ShopTerminalBehavior>(); #region Cauldronfix if (printerCosts.Contains(self.costType)) { if (ShareSuite.PrinterCauldronFixEnabled.Value) { var characterBody = activator.GetComponent <CharacterBody>(); var inventory = characterBody.inventory; var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex())?.itemIndex; if (item == null) { RoR2.Console.print("ShareSuite: PickupCatalog is null."); } else { inventory.GiveItem(item.Value); } orig(self, activator); ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(), shop.CurrentPickupIndex()); return; } } #endregion Cauldronfix #region EquipDronefix if (ShareSuite.EquipmentShared.Value) { if (self.costType == CostTypeIndex.Equipment) { var rng = self.GetComponent <Xoroshiro128Plus>(); var itemIndex = ItemIndex.None; var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType); if (shop) { itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex; } var payCostResults = costTypeDef.PayCost(self.cost, activator, self.gameObject, rng, itemIndex); if (payCostResults.equipmentTaken.Count >= 1) { orig(self, activator); EquipmentSharingHooks.RemoveAllUnBlacklistedEquipment(); return; } } } #endregion orig(self, activator); }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (currState != State.Idle) { return; } orig.Invoke(self, activator); CharacterBody player = activator.GetComponent <CharacterBody>(); if (!player) { return; } CharacterMaster characterMaster = this.gameObject.GetComponent <CharacterMaster>(); if (!characterMaster) { return; } if (player.gameObject == characterMaster.GetBody().gameObject) { //Debug.Log("Same!"); string objName = self.gameObject.name.ToLower(); chestPos = self.gameObject.transform.position; chestForward = self.gameObject.transform.forward; Debug.Log(objName); if (objName.Contains("chest1")) { //Debug.Log("Default Chest"); //Default Chest tier1Rate = config.GetValue(1, ConfigStuff.ChestType.Normal); tier2Rate = config.GetValue(2, ConfigStuff.ChestType.Normal); tier3Rate = config.GetValue(3, ConfigStuff.ChestType.Normal); chestOpening = true; currState = State.Opening; } else if (objName.Contains("chest2")) { //Debug.Log("Large Chest"); //Large Chest tier1Rate = config.GetValue(1, ConfigStuff.ChestType.Large); tier2Rate = config.GetValue(2, ConfigStuff.ChestType.Large); tier3Rate = config.GetValue(3, ConfigStuff.ChestType.Large); chestOpening = true; currState = State.Opening; } else if (objName.Contains("goldchest")) { //Debug.Log("Golden Chest"); //Golden Chest tier1Rate = config.GetValue(1, ConfigStuff.ChestType.Golden); tier2Rate = config.GetValue(2, ConfigStuff.ChestType.Golden); tier3Rate = config.GetValue(3, ConfigStuff.ChestType.Golden); chestOpening = true; currState = State.Opening; } else if (objName.Contains("isclockbox")) { //Debug.Log("Rusty Chest"); //Rusty Chest tier1Rate = config.GetValue(1, ConfigStuff.ChestType.Rusty); tier2Rate = config.GetValue(2, ConfigStuff.ChestType.Rusty); tier3Rate = config.GetValue(3, ConfigStuff.ChestType.Rusty); chestOpening = true; currState = State.Opening; } else if (objName.Contains("equipmentbarrel")) { //Debug.Log("Equipment Barrel"); //Equipment Barrel chestOpening = true; currState = State.Equipment; } } }
private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (isCurrentStageBazaar()) { NetworkUser networkUser = Util.LookUpBodyNetworkUser(activator.gameObject); BazaarPlayer bazaarPlayer = bazaar.GetBazaarPlayer(networkUser); if (!self.CanBeAffordedByInteractor(activator)) { return; } if (bazaar.IsMoneyLunarPodAvailable()) { if (bazaar.IsMoneyLunarPod(self.gameObject)) { if (bazaarPlayer.lunarExchanges < ModConfig.maxLunarExchanges.Value || ModConfig.infiniteLunarExchanges) { bazaarPlayer.lunarExchanges++; int money = bazaar.GetLunarCoinExchangeMoney(); if (!ModConfig.IsShareSuiteMoneySharing()) { activator.GetComponent <CharacterBody>().master.money += ((uint)money); } else { //ShareSuite.MoneySharingHooks.AddMoneyExternal(money); bazaar.ShareSuiteMoneyFix(activator, money); } //activator.GetComponent<CharacterBody>().master.money += ((uint)money); //activator.GetComponent<CharacterBody>().master.GiveMoney((uint)money); networkUser.DeductLunarCoins((uint)self.cost); var goldReward = (int)((double)ModConfig.lunarCoinWorth.Value * (double)bazaar.CurrentDifficultyCoefficient); GameObject coinEmitterResource = Resources.Load <GameObject>("Prefabs/Effects/CoinEmitter"); EffectManager.SpawnEffect(coinEmitterResource, new EffectData() { origin = self.transform.position, genericFloat = (float)goldReward }, true); EffectManager.SpawnEffect(coinEmitterResource, new EffectData() { origin = self.transform.position, genericFloat = (float)goldReward }, true); Util.PlaySound("Play_UI_coin", self.gameObject); } return; } } // New addition that made everything less nice. Added to check if player still has purchases left int bazaarChestIndex = -1; List <BazaarItem> bazaarItems = bazaar.GetBazaarItems(); PurchaseInteraction bazaarPI; for (int i = 0; i < bazaarItems.Count; i++) { // Fix for SavedGames. SavedGames somehow breaks the BiggerBazaar chests and BiggerBazaar breaks everything else in return :) if (bazaarItems[i].chestBehavior == null) { continue; } bazaarPI = bazaarItems[i].chestBehavior.GetComponent <PurchaseInteraction>(); if (bazaarPI.Equals(self)) { if (!bazaar.PlayerHasPurchasesLeft(bazaarPlayer)) { return; } //ItemTier tier = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(bazaarItems[i].pickupIndex).itemIndex).tier; PickupTier pickupTier = PickupIndexToPickupTier(bazaarItems[i].pickupIndex); if (!bazaar.PlayerHasTierPurchasesLeft(pickupTier, bazaarPlayer)) { return; } if (ModConfig.ShareSuite != null && ModConfig.ShareSuiteTotalPurchaseSharing.Value) { bazaar.GetBazaarPlayers().ForEach(x => x.chestPurchases++); } else { bazaarPlayer.chestPurchases++; } bazaarPlayer.IncreaseTierPurchase(pickupTier); bazaarChestIndex = i; break; } } // Special case for ShareSuite if (ModConfig.isShareSuiteActive() && !ModConfig.ShareSuiteItemSharingEnabled.Value) { if (bazaarChestIndex != -1) { CharacterMaster master = activator.GetComponent <CharacterBody>().master; var isEquipment = PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).equipmentIndex == EquipmentIndex.None ? false : true; if (!isEquipment) { master.inventory.GiveItem(PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).itemIndex); } else { if (!ModConfig.isShareSuiteEquipmentSharing()) { PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(master.inventory.GetEquipmentIndex()), master.GetBody().gameObject.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + self.transform.forward * 2f); } master.inventory.SetEquipmentIndex(PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).equipmentIndex); } if (ModConfig.chestCostType.Value == 1) { var netUser = Util.LookUpBodyNetworkUser(master.GetBody()); netUser.DeductLunarCoins((uint)self.cost); } else { if (!ModConfig.IsShareSuiteMoneySharing()) { master.money -= (uint)self.cost; } else { //ShareSuite.MoneySharingHooks.AddMoneyExternal(-self.cost); bazaar.ShareSuiteMoneyFix(activator, -self.cost); } } bazaarItems[bazaarChestIndex].purchaseCount++; if (!bazaar.IsChestStillAvailable(bazaarItems[bazaarChestIndex])) { self.GetComponent <PurchaseInteraction>().SetAvailable(false); } Vector3 effectPos = self.transform.position; effectPos.y -= 1; EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData() { origin = effectPos, rotation = Quaternion.identity, scale = 0.01f, color = (Color32)Color.yellow }, true); PurchaseInteraction.CreateItemTakenOrb(self.gameObject.transform.position, activator.GetComponent <CharacterBody>().gameObject, PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).itemIndex); return; } } } orig(self, activator); }