Example #1
0
        private void MaybeAwardLoot(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var amount = self.inventory.GetItemCount(Definition.itemIndex);

            if (amount > 0 && amount % 3 == 0)
            {
                self.inventory.RemoveItem(Definition.itemIndex, 3);
                PickupIndex loot;
                if (Util.CheckRoll(5, self.master))
                {
                    loot = Run.instance.treasureRng.NextElementUniform(Run.instance.availableTier3DropList);
                }
                else
                {
                    loot = Run.instance.treasureRng.NextElementUniform(Run.instance.availableTier2DropList);
                }
                if (self.isPlayerControlled)
                {
                    PickupDropletController.CreatePickupDroplet(loot, self.corePosition, Vector3.up * 5);
                }
                else
                {
                    PickupDef def = PickupCatalog.GetPickupDef(loot);
                    self.inventory.GiveItem(def.itemIndex);
                    var lootCount = self.inventory.GetItemCount(def.itemIndex);
                    Chat.AddPickupMessage(self, def.nameToken, ColorCatalog.GetColor(ItemCatalog.GetItemDef(def.itemIndex).colorIndex), (uint)lootCount);
                }
            }
        }
Example #2
0
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            // This hook runs on Client and on Server
            orig(self);
            CharacterMaster master = self.master;

            if (!master)
            {
                return;
            }
            MinionOwnership minionOwnership = master.minionOwnership;

            if (!minionOwnership || minionOwnership.ownerMaster || FilterMinions(master))
            {
                return;
            }
            OptionMasterTracker masterTracker = master.GetOrAddComponent <OptionMasterTracker>();
            int newCount = GetCount(self);
            int oldCount = masterTracker.optionItemCount;
            int diff     = newCount - oldCount;

            if (diff != 0)
            {
                masterTracker.optionItemCount = newCount;
                Log.Message($"OnInventoryChanged: Master: {master.name}, OldCount: {oldCount}, NewCount: {newCount}, Difference: {diff}");
                if (diff > 0)
                {
                    LoopAllMinions(master, minion => OptionMasterTracker.SpawnOptions(minion, oldCount, newCount));
                }
                else
                {
                    LoopAllMinions(master, minion => OptionMasterTracker.DestroyOptions(minion, oldCount, newCount));
                }
            }
        }
Example #3
0
 private static void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
 {
     orig(self);
     if (!self.gameObject.GetComponent <StopMovingBehavior>() && self.inventory.GetItemCount(index) != 0)
     {
         self.gameObject.AddComponent <StopMovingBehavior>();
     }
 }
 private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
 {
     orig(self);
     if (!self.inventory.GetComponent <MysticsItemsManuscript>())
     {
         self.inventory.gameObject.AddComponent <MysticsItemsManuscript>();
     }
 }
Example #5
0
 private void ImmediateHauntedWardUpdate(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, RoR2.CharacterBody self)
 {
     orig(self);
     if (self.inventory.GetItemCount(AspectsToItems.AspectsToItems.NewDefsList.Find(x => x.name == "AffixHaunted").itemIndex) > 0)
     {
         self.AddItemBehavior <RoR2.CharacterBody.AffixHauntedBehavior>(self.inventory.GetItemCount(AspectsToItems.AspectsToItems.NewDefsList.Find(x => x.name == "AffixHaunted").itemIndex));
     }
 }
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var component = self.GetComponent <MysticsItemsMarwanAshHelper>();

            if (component)
            {
                component.dirty = true;
            }
        }
 private void On_InventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self) //Checks item count and caches it. Also where the component is added
 {
     orig(self);
     foreach (CatalogBoilerplate x in masterItemList)
     {
         if (x is VirtItem_V2 item)
         {
             item.StoreItemCount(self);
         }
     }
 }
Example #8
0
        private void On_CBInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var cpt = self.GetComponent <ImprintComponent>();

            if (!cpt)
            {
                cpt = self.gameObject.AddComponent <ImprintComponent>();
            }
            cpt.count     = GetCount(self);
            cpt.ownerBody = self;
        }
Example #9
0
        private void GetTotalDamageItems(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        //This compares your inventory to the damage item list each time your inventory changes, and generates the appropriate value for damageItemCount
        {
            orig(self);
            var damageItemCount = 0;

            foreach (ItemIndex x in indiciiToCheck)
            {
                damageItemCount += self.inventory.GetItemCount(x);
            }
            DamageItemCounts[self.netId] = damageItemCount;
        }
Example #10
0
 private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
 {
     orig(self);
     if (NetworkServer.active)
     {
         var component = self.AddItemBehavior <MysticsItemsDroneWiresBehaviour>(self.inventory.GetItemCount(itemDef));
         if (component && component.firstInit)
         {
             component.UpdateDroneInventories();
         }
     }
 }
Example #11
0
        private void On_CBOnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var cpt = self.GetComponent <LifeSavingsComponent>();

            if (!cpt)
            {
                cpt = self.gameObject.AddComponent <LifeSavingsComponent>();
            }
            if (NetworkServer.active)
            {
                cpt.ServerUpdateIcnt();
            }
        }
Example #12
0
        private void RemoveItemFromDeployables(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var inventoryCount = GetCount(self);

            if (inventoryCount > 0 && self.master && self.inventory)
            {
                if (self.master.teamIndex == TeamIndex.Player && !self.isPlayerControlled)
                {
                    //YEAH, YEAH, TAKE THAT YOU DANG DEPLOYABLES. NO CUTE DRONE FOR YOU!
                    self.inventory.RemoveItem(itemDef.itemIndex, inventoryCount);
                }
            }
        }
Example #13
0
        //If I want to update the size of the metaballs in the shader

        /*private void UpdateVoidheartVisual(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
         * {
         *  orig(self);
         *  if (GetCount(self) > 0)
         *  {
         *      var scale = ruleLookup[self.modelLocator.modelTransform.name];
         *      ItemBodyModelPrefab.GetComponent<RoR2.ItemDisplay>().rendererInfos[0].defaultMaterial.SetFloat("_BlobScale", 3.16f / scale);
         *      ItemBodyModelPrefab.GetComponent<RoR2.ItemDisplay>().rendererInfos[0].defaultMaterial.SetFloat("_BlobDepth", 2.9f * scale);
         *      //ItemBodyModelPrefab.GetComponent<RoR2.ItemDisplay>().rendererInfos[0].defaultMaterial.SetFloat("_BlobScale", 3.16f + (1-scale));
         *      ItemBodyModelPrefab.GetComponent<RoR2.ItemDisplay>().rendererInfos[0].defaultMaterial.SetFloat("_BlobMoveSpeed", 6 * scale);
         *  }
         * }*/

        private void VoidheartAnnihilatesItselfOnDeployables(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, RoR2.CharacterBody self)
        {
            orig(self);
            var InventoryCount = GetCount(self);

            if (InventoryCount > 0 && self.master)
            {
                if (self.master.teamIndex == TeamIndex.Player && !self.isPlayerControlled)
                {
                    //Unga bunga, voidheart not like deployables. POP!
                    self.inventory.RemoveItem(itemDef.itemIndex, InventoryCount);
                }
            }
        }
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            int InventoryCount = GetCount(self);

            if (InventoryCount > 0)
            {
                CultistPassiveComponent passiveComponent = self.gameObject.GetComponent <CultistPassiveComponent>();
                if (!passiveComponent)
                {
                    passiveComponent = self.gameObject.AddComponent <CultistPassiveComponent>();
                }
                UpdateComponentForEveryone();
            }
        }
Example #15
0
 private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
 {
     orig(self);
     if (self.inventory.HasItem(this, out int itemCount))
     {
         NetworkedSI si = self.GetComponent <NetworkedSI>();
         if (!si)
         {
             Log("Missing si component!");
             return;
         }
         si.SetItemCount(itemCount);
         self.OnLevelChanged();//hack to avoid reflecting for a bool.
     }
 }
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var inventoryCount = GetCount(self);

            if (inventoryCount == 0)
            {
                return;
            }
            for (int i = 0; i < inventoryCount; i++)
            {
                ApplyAmmoPackToTeam(self.teamComponent.teamIndex);
                self.inventory.RemoveItem(catalogIndex);
            }
        }
Example #17
0
        private void On_CBOnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            if (!NetworkServer.active || GetCount(self) < 1)
            {
                return;
            }
            var cpt = self.GetComponentInChildren <EmbryoComponent>();

            if (!cpt)
            {
                var cptInst = GameObject.Instantiate(embryoCptPrefab, self.transform);
                cptInst.GetComponent <NetworkedBodyAttachment>().AttachToGameObjectAndSpawn(self.gameObject);
            }
        }
Example #18
0
        private void On_CBInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var cpt = self.GetComponent <GoldenGunComponent>();

            if (!cpt)
            {
                cpt = self.gameObject.AddComponent <GoldenGunComponent>();
            }
            var newIcnt = GetCount(self);

            if (cpt.cachedIcnt != newIcnt)
            {
                cpt.cachedIcnt = newIcnt;
                UpdateGGBuff(self);
            }
        }
Example #19
0
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            var component = self.GetComponent <MysticsItemsFragileMaskBehaviour>();

            if (!component)
            {
                component = self.gameObject.AddComponent <MysticsItemsFragileMaskBehaviour>();
            }
            if (self.previousEquipmentIndex == equipmentDef.equipmentIndex && self.inventory.currentEquipmentIndex != equipmentDef.equipmentIndex)
            {
                if (component.maskActive)
                {
                    component.maskWasActive = true;
                    component.maskActive    = false;
                    self.statsDirty         = true;
                }
            }
        }
Example #20
0
 private void On_CBOnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
 {
     orig(self);
     if (handlingInventory)
     {
         return;
     }
     handlingInventory = true;
     if (!HandleScepterSkill(self))
     {
         if (GetCount(self) > 0)
         {
             Reroll(self, GetCount(self));
         }
     }
     else if (GetCount(self) > 1 && rerollExtras)
     {
         Reroll(self, GetCount(self) - 1);
     }
     handlingInventory = false;
 }
Example #21
0
        private void CalculateSpiceReward(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self) //blessed komrade
        {
            int InventoryCount = GetCount(self);

            SpiceReplaceChance = Math.Min(InventoryCount * 5, 100);
            switch (InventoryCount)
            {
            case 0:
                break;

            case 1:
                dynamicPickupText = "A tantalizing cube of power.";
                //self.inventory.GiveItem(Spice_RewardA.instance.catalogIndex);
                //self.inventory.GiveItem(ItemIndex.Hoof);
                //GiveItemVsMax(self, Spice_RewardA.instance.catalogIndex);
                break;

            case 2:
                dynamicPickupText = "One more couldn't hurt.";
                //GiveItemVsMax(self, ItemIndex.Feather);
                break;

            case 3:
                dynamicPickupText = "Just one more hit...";
                //GiveItemVsMax(self, ItemIndex.AlienHead);
                break;

            case 4:
                dynamicPickupText = "MORE";
                //GiveItemVsMax(self, ItemIndex.LunarBadLuck);
                break;

            default:
                dynamicPickupText = "MORE";
                break;
            }
            //protected override string GetPickupString = dynamicPickupText;
            orig(self);
        }
Example #22
0
        private static void OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);

            if (self != currentBody)
            {
                return;
            }

            EquipmentDef[] aimableEquipments = new EquipmentDef[]
            {
                RoR2Content.Equipment.Blackhole,
                RoR2Content.Equipment.BFG,
                RoR2Content.Equipment.GoldGat,
                RoR2Content.Equipment.CrippleWard,
                RoR2Content.Equipment.Gateway,
                RoR2Content.Equipment.Saw
            };

            EquipmentDef currentEquipment = EquipmentCatalog.GetEquipmentDef(self.inventory.currentEquipmentIndex);

            dominantHand.forceRay    = false;
            nonDominantHand.forceRay = false;

            if (aimableEquipments.Contains(currentEquipment))
            {
                (ModConfig.LeftDominantHand.Value != (currentEquipment == RoR2Content.Equipment.GoldGat) ? dominantHand : nonDominantHand).forceRay = true;
            }

            if (self.inventory.GetItemCount(RoR2Content.Items.LunarPrimaryReplacement.itemIndex) > 0)
            {
                dominantHand.forceRay = true;
            }

            if (self.inventory.GetItemCount(RoR2Content.Items.LunarSecondaryReplacement.itemIndex) > 0)
            {
                nonDominantHand.forceRay = true;
            }
        }
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);

            var skillLocator = self.skillLocator;

            if (skillLocator)
            {
                if (skillLocator.utility)
                {
                    var bookCount = GetCount(self);
                    if (bookCount > 0)
                    {
                        skillLocator.utility.SetSkillOverride(this, dodgeRollSkillDef, GenericSkill.SkillOverridePriority.Replacement);
                    }
                    else
                    {
                        skillLocator.utility.UnsetSkillOverride(this, dodgeRollSkillDef, GenericSkill.SkillOverridePriority.Replacement);
                    }
                }
            }
        }
Example #24
0
        private void UpdateAllTrackers(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);
            CharacterMaster ownerMaster = self.master;

            MinionOwnership[] minionOwnerships = Object.FindObjectsOfType <MinionOwnership>();
            foreach (MinionOwnership minionOwnership in minionOwnerships)
            {
                if (minionOwnership && minionOwnership.ownerMaster && minionOwnership.ownerMaster == ownerMaster)
                {
                    CharacterMaster minionMaster = minionOwnership.GetComponent <CharacterMaster>();
                    if (minionMaster)
                    {
                        BotStatTracker tracker = minionMaster.GetComponent <BotStatTracker>();
                        if (tracker)
                        {
                            tracker.UpdateTrackerBoosts();
                        }
                    }
                }
            }
        }
Example #25
0
        private void GiveRandomRed(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self) //ripped from harbcrate, i did credit though.
        {
            orig(self);
            var amount = GetCount(self);

            if (amount > 1)
            {
                self.inventory.RemoveItem(catalogIndex);
                PickupIndex loot = Run.instance.treasureRng.NextElementUniform(Run.instance.availableTier3DropList);
                if (self.isPlayerControlled)
                {
                    PickupDropletController.CreatePickupDroplet(loot, self.corePosition, Vector3.up * 5);
                }
                else
                {
                    PickupDef def = PickupCatalog.GetPickupDef(loot);
                    self.inventory.GiveItem(def.itemIndex);
                    var lootCount = self.inventory.GetItemCount(def.itemIndex);
                    Chat.AddPickupMessage(self, def.nameToken, ColorCatalog.GetColor(ItemCatalog.GetItemDef(def.itemIndex).colorIndex), (uint)lootCount);
                }
            }
        }
Example #26
0
        private void InvChangedHook(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            _swooceHandlers.RemoveAll((handler) => {
                return(handler == null);
            });

            float specialItemDistance = getSpecialItemDistance(self);

            //make this happen once on init rather than using GetComponent every time an inventory changes
            if (self.modelLocator.modelTransform == null)
            {
                return;
            }

            if (self.modelLocator.modelTransform.gameObject.GetComponent <CharacterSwooceHandler>() == null)
            {
                CharacterSwooceHandler swooceHandler = self.modelLocator.modelTransform.gameObject.AddComponent <CharacterSwooceHandler>();
                _swooceHandlers.Add(swooceHandler);
                swooceHandler.Init(this, specialItemDistance);
            }

            orig(self);
        }
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
        {
            orig(self);

            var skillLocator = self.skillLocator;

            if (skillLocator)
            {
                if (skillLocator.utility)
                {
                    var scarfCount = GetCount(self);
                    if (scarfCount > 0)
                    {
                        //skillLocator.utility.SetSkillOverride(this, CharacterBody.CommonAssets.lunarPrimaryReplacementSkillDef, GenericSkill.SkillOverridePriority.Replacement);
                        skillLocator.utility.SetSkillOverride(this, teleportSkillDef, GenericSkill.SkillOverridePriority.Replacement);
                    }
                    else
                    {
                        //skillLocator.utility.UnsetSkillOverride(this, CharacterBody.CommonAssets.lunarPrimaryReplacementSkillDef, GenericSkill.SkillOverridePriority.Replacement);
                        skillLocator.utility.UnsetSkillOverride(this, teleportSkillDef, GenericSkill.SkillOverridePriority.Replacement);
                    }
                }
            }
        }
        private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self) //Update Max Kills
        {
            orig(self);
            var InventoryCount = GetCount(self);
            MetronomeTrackKills metronomeTrackKills = self.gameObject.GetComponent <MetronomeTrackKills>();

            if (!metronomeTrackKills)
            {
                metronomeTrackKills = self.gameObject.AddComponent <MetronomeTrackKills>();
            }
            metronomeTrackKills.characterBody = self;
            if (InventoryCount > 0)
            {
                metronomeTrackKills.enabled  = true;
                metronomeTrackKills.maxkills = MaxKills + MaxKillsPerStack * InventoryCount;

                metronomeTrackKills.UpdateKills();
            }
            else
            {
                metronomeTrackKills.kills   = 0;
                metronomeTrackKills.enabled = false;
            }
        }
Example #29
0
 private void CharacterBody_OnInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
 {
     orig(self);
     MysticsItemsIdolIndicator.dirty = true;
 }
 private void On_CBInventoryChanged(On.RoR2.CharacterBody.orig_OnInventoryChanged orig, CharacterBody self)
 {
     orig(self);
     UpdatePhotonFuel(self);
 }