Example #1
0
        private void VoidheartDeathInteraction(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, RoR2.CharacterMaster self, RoR2.CharacterBody body)
        {
            var InventoryCount = GetCount(body);

            if (InventoryCount > 0 && !body.healthComponent.killingDamageType.HasFlag(DamageType.VoidDeath) && !body.HasBuff(VoidInstabilityDebuff))
            {
                GameObject explosion = new GameObject();
                explosion.transform.position = body.transform.position;

                var componentVoidheartDeath = explosion.AddComponent <VoidheartDeath>();
                componentVoidheartDeath.toReviveMaster      = self;
                componentVoidheartDeath.toReviveBody        = body;
                componentVoidheartDeath.voidExplosionRadius = voidImplosionBaseRadius + (voidImplosionAdditionalRadius * (InventoryCount - 1));
                componentVoidheartDeath.voidHeartImplosionDamageMultiplier = voidImplosionDamageMultiplier;
                componentVoidheartDeath.voidInstabilityDebuff     = VoidInstabilityDebuff;
                componentVoidheartDeath.voidHeartCooldownDuration = voidHeartCooldownDebuffDuration;
                componentVoidheartDeath.Init();

                var tempDestroyOnDeath = self.destroyOnBodyDeath;
                self.destroyOnBodyDeath = false;
                orig(self, body);
                self.destroyOnBodyDeath = tempDestroyOnDeath;
                self.preventGameOver    = true;
                return;
            }
            orig(self, body);
        }
Example #2
0
        private void CoverageCheck(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body)
        {
            if (GetCount(body) > 0)
            {
                var attackerComponent = self.gameObject.GetComponent <DamageReport>();

                var insuranceSavingsTrackerComponent = self.gameObject.GetComponent <InsuranceSavingsTracker>();
                if (!insuranceSavingsTrackerComponent)
                {
                    self.gameObject.AddComponent <InsuranceSavingsTracker>();
                }

                //Tries to get a key with the killer's name. If one exists, throws out the corresponding Range to that key.
                //Then check to ensure that Range's Upper value is less than the amount of gold you saved (confirms you're above that tier)
                if (InsuranceDictionary.TryGetValue(attackerComponent.attacker.name, out Range insuranceRange) && insuranceRange.Upper < insuranceSavingsTrackerComponent.insuranceSavings)
                {
                    self.Invoke("RespawnExtraLife", 2f);
                    self.Invoke("PlayExtraLifeSFX", 1f);

                    //This chunk ensures the extra money you are forced to save once you unlock the final coverage tier isn't wasted,
                    //by only reducing your savings = to the cost of unlocking the final coverage tier (or just to zero, if you haven't unlocked that tier)
                    var savingsComponent = body.gameObject.GetComponent <Run>();
                    if (!savingsComponent)
                    {
                        body.gameObject.AddComponent <Run>();
                    }
                    var diffCoeff = savingsComponent.difficultyCoefficient;
                    var baseCost  = Convert.ToUInt32(25 * Math.Pow(diffCoeff, 1.25f));
                    insuranceSavingsTrackerComponent.insuranceSavings = Math.Max(insuranceSavingsTrackerComponent.insuranceSavings - baseCost * 16, 0);
                }
            }
            orig(self, body);
        }
Example #3
0
 private static void CharacterMaster_OnBodyDeath(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body)
 {
     orig(self, body);
     if (self.IsDeadAndOutOfLivesServer() && body.teamComponent.teamIndex == TeamIndex.Monster)
     {
         BullseyeSearch search = new BullseyeSearch
         {
             searchOrigin    = body.corePosition,
             teamMaskFilter  = TeamMask.none,
             filterByLoS     = false,
             sortMode        = BullseyeSearch.SortMode.Distance,
             searchDirection = Vector3.zero
         };
         search.teamMaskFilter.AddTeam(TeamIndex.Player);
         search.RefreshCandidates();
         foreach (HurtBox hurtBox in search.GetResults())
         {
             //Chat.AddMessage("BaseNameToken: " + hurtBox.healthComponent.body.baseNameToken); //This will show the prefabName
             if (hurtBox.healthComponent.body.baseNameToken == "MAGE_BODY_NAME") //This should reflect the prefabName
             {
                 hurtBox.healthComponent.body.AddBuff(ChargeIndex);
             }
         }
     }
 }
Example #4
0
        private static void WispDeathHook(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body)
        {
            orig(self, body);
            try
            {
                if (ConfigHandler.GlobalChance >= Random.Range(0, 100))
                {
                    int orbsToFire = 0;
                    if (self.IsDeadAndOutOfLivesServer() && (body.bodyIndex == 89 || body.bodyIndex == 90))
                    {
                        orbsToFire = ConfigHandler.LesserWispOrbs;
                    }
                    else if (self.IsDeadAndOutOfLivesServer() && body.bodyIndex == 41)
                    {
                        orbsToFire = ConfigHandler.GreaterWispOrbs;
                    }

                    for (int i = 1; i <= orbsToFire; i++)
                    {
                        WispBoostOrb orb = new WispBoostOrb
                        {
                            origin    = body.corePosition,
                            target    = GetBonusTarget(body, i),
                            bonusType = DetermineBoostType(),
                        };
                        if (orb.bonusType == 5)
                        {
                            orb.affixType = GetAffixType(body);
                        }
                        OrbManager.instance.AddOrb(orb);
                    }
                }
            }
            catch { }
        }
Example #5
0
        private void CharacterDied(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, CharacterMaster self)
        {
            orig(self);
            var pcmc = self.GetComponent <PlayerCharacterMasterController>();

            // Stop the game from ending.
            if (pcmc != null)
            {
                self.preventGameOver = true;
            }
        }
 private void On_Death(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body) //returns to original body prefab after dying
 {
     if (NetworkServer.active)
     {
         if (self.gameObject.GetComponent <ImpExtractComponent>() != null && self.gameObject.GetComponent <ImpExtractComponent>().isImp)
         {
             self.gameObject.GetComponent <ImpExtractComponent>().RemoveImp(false);
         }
     }
     orig(self, body);
 }
 private void CharacterMaster_OnBodyDeath(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body)
 {
     orig(self, body);
     if (!NetworkServer.active || !IsActiveAndEnabled() || !self || !self.minionOwnership || self.minionOwnership.ownerMaster)
     {
         return;
     }
     self.LoopMinions(minion =>
     {
         CharacterBody minionBody = minion.GetBody();
         if (minionBody && minionBody.healthComponent)
         {
             minionBody.healthComponent.Suicide();
         }
     });
 }
Example #8
0
        private void CharacterMaster_OnBodyDeath(On.RoR2.CharacterMaster.orig_OnBodyDeath orig, CharacterMaster self)
        {
            characterMaster = self;
            if (NetworkServer.active)
            {
                deathFootPosition = self.GetBody().footPosition;
                BaseAI[] components = self.GetComponents <BaseAI>();
                for (int i = 0; i < components.Length; i++)
                {
                    components[i].OnBodyDeath();
                }
                PlayerCharacterMasterController component = self.GetComponent <PlayerCharacterMasterController>();
                if (component)
                {
                    component.OnBodyDeath();
                }
                int itemAllNum = 0;
                list.Clear();
                if (self.teamIndex == TeamIndex.Player)
                {
                    for (int i = 0; i < Enum.GetValues(typeof(ItemIndex)).Length; i++)
                    {
                        ItemIndex itemIndex = (ItemIndex)i;
                        if (itemIndex <= ItemIndex.None || itemIndex >= ItemIndex.Count)
                        {
                            continue;
                        }

                        int num = self.inventory.GetItemCount(itemIndex);
                        if (num > 0)
                        {
                            list.Add(itemIndex);
                        }

                        itemAllNum += num;

                        itemStacks[i] = num;
                    }
                }
                string usename           = Util.GetBestMasterName(self);
                bool   tempHerosNeverDie = itemAllNum >= RemoveItemNum;
                if (tempHerosNeverDie)
                {
                    int tempNum = 0;
                    if (userPlayerRespawnNum.ContainsKey(usename) == false)
                    {
                        userPlayerRespawnNum[usename] = 0;
                    }
                    else
                    {
                        tempNum = userPlayerRespawnNum[usename];
                    }
                    if (tempNum >= RespawnNum)
                    {
                        tempHerosNeverDie = false;
                    }
                }

                if (self.inventory.GetItemCount(ItemIndex.ExtraLife) > 0)
                {
                    self.inventory.RemoveItem(ItemIndex.ExtraLife, 1);
                    self.Invoke("RespawnExtraLife", 2f);
                    self.Invoke("PlayExtraLifeSFX", 1f);
                }
                else if (tempHerosNeverDie)
                {
                    for (int i = 0; i < RemoveItemNum; i++)
                    {
                        RandomRemoveItemOne();
                    }
                    userPlayerRespawnNum[usename] += 1;

                    this.Invoke("RespawnExtraLife", 2f);
                    self.Invoke("PlayExtraLifeSFX", 1f);
                }
                else
                {
                    if (self.destroyOnBodyDeath)
                    {
                        UnityEngine.Object.Destroy(self.gameObject);
                    }
                    self.preventGameOver = false;
                    FieldInfo field = self.GetType().GetField("preventRespawnUntilNextStageServer", BindingFlags.NonPublic | BindingFlags.Instance);
                    field.SetValue(self, true);
                }
                MethodInfo methodInfo = self.GetType().GetMethod("ResetLifeStopwatch", BindingFlags.NonPublic | BindingFlags.Instance);
                methodInfo.Invoke(self, null);
            }
            UnityEvent unityEvent = self.onBodyDeath;

            if (unityEvent == null)
            {
                return;
            }
            unityEvent.Invoke();
        }