Exemplo n.º 1
0
 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
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }