// Update inventories after every stage public static void updateAfterStage() { if (DII.UpdateInventory.Value) { On.RoR2.Run.AdvanceStage += (orig, self, nextScene) => { var masters = CharacterMaster.readOnlyInstancesList; List <CharacterMaster> masterList = masters.Cast <CharacterMaster>().ToList(); foreach (CharacterMaster cm in masterList) { if (bodyprefabNames.Contains(cm.bodyPrefab.name)) { if (cm.bodyPrefab.name == "SquidTurretBody") { continue; } if (cm.bodyPrefab.name == "MegaDroneBody" && SceneManager.GetActiveScene().name == "moon") { continue; } if (bodyprefabsDict[cm.bodyPrefab.name]) { CharacterMaster owner = cm.gameObject.GetComponent <AIOwnership>().ownerMaster; DII.updateInventory(cm, owner); if (cm.bodyPrefab.name == "EquipmentDroneBody") { cm.inventory.GiveItem((ItemIndex)121, 15); } } } } orig(self, nextScene); }; } }
// Ghost inheritance public static void spookyGhosts() { if (DII.GhostInherit.Value) { On.RoR2.Util.TryToCreateGhost += (orig, targetBody, ownerBody, duration) => { CharacterBody characterBody = orig(targetBody, ownerBody, duration); if (characterBody == null) { return(null); } CharacterMaster cm = characterBody.master; AIOwnership component2 = cm.gameObject.GetComponent <AIOwnership>(); CharacterMaster master = ownerBody.master; DII.checkConfig(cm, master); CustomBlacklist.customItem(cm, DII.CBItemGhosts.Value); CustomBlacklist.customItemCap(cm, DII.CBItemCapGhosts.Value); CustomBlacklist.customEquip(cm, DII.CBEquipGhosts.Value); cm.inventory.GiveItem(RoR2Content.Items.Ghost, 1); cm.inventory.ResetItem(RoR2Content.Items.HealthDecay); cm.inventory.GiveItem(RoR2Content.Items.HealthDecay, duration); return(characterBody); }; } }
// Check keys and add to inventory public static void masterKeyHandler(CharacterMaster npc, CharacterMaster player) { //Debug.Log(npc.name); if (masterPrefabNamesSummonReturn.Keys.Contains(npc.name) && npc.teamIndex == TeamIndex.Player) { if (masterPrefabNamesSummonReturn[npc.name]) { DII.checkConfig(npc, player); if (npc.name == "Drone2Master" || npc.name == "Emer") { npc.inventory.ResetItem(RoR2Content.Items.LunarPrimaryReplacement); } if (npc.name == "SquidTurretMaster(Clone)") { npc.inventory.GiveItem(RoR2Content.Items.HealthDecay, (int)Math.Ceiling(DII.ConfigToFloat(DII.SquidHealthDecay.Value))); } } } }
// Fixes Dio reinheritance public static void fixBackupDio() { if (DII.FixBackupDio.Value) { On.RoR2.CharacterMaster.RespawnExtraLife += (orig, self) => { orig(self); if (self.bodyPrefab.name.ToString() == "BackupDroneBody") { self.gameObject.AddComponent <MasterSuicideOnTimer>().lifeTimer = DII.ConfigToFloat(DII.BackupDeathTimer.Value) + UnityEngine.Random.Range(0f, 3f); } }; } }