コード例 #1
0
        //private void GrantBaseShield(ILContext il)
        //{
        //    //Provided by Harb from their HarbCrate mod. Thanks Harb!
        //    ILCursor c = new ILCursor(il);
        //    int shieldsLoc = 33;
        //    c.GotoNext(
        //        MoveType.Before,
        //        x => x.MatchLdloc(out shieldsLoc),
        //        x => x.MatchCallvirt<CharacterBody>("set_maxShield")
        //    );
        //    c.Emit(OpCodes.Ldloc, shieldsLoc);
        //    c.EmitDelegate<Func<CharacterBody, float, float>>((self, shields) =>
        //    {
        //        var InventoryCount = GetCount(self);
        //        if (InventoryCount > 0)
        //        {
        //            shields += self.maxHealth * 0.08f;
        //        }
        //        return shields;
        //    });
        //    c.Emit(OpCodes.Stloc, shieldsLoc);
        //    c.Emit(OpCodes.Ldarg_0);
        //}

        private void GrantShieldReward(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, RoR2.GlobalEventManager self, RoR2.DamageReport damageReport)
        {
            if (damageReport?.attackerBody)
            {
                int inventoryCount = GetCount(damageReport.attackerBody);
                if (inventoryCount > 0)
                {
                    var percentage = shieldPercentageRestoredPerKill + (maximumPercentageShieldRestoredPerKill - maximumPercentageShieldRestoredPerKill / (1 + additionalShieldPercentageRestoredPerKillDiminishing * (inventoryCount - 1)));
                    damageReport.attackerBody.healthComponent.RechargeShield(damageReport.attackerBody.healthComponent.fullShield * percentage);
                }
            }
            orig(self, damageReport);
        }
コード例 #2
0
        private void SpawnLightningPillar(On.RoR2.GlobalEventManager.orig_OnHitAll orig, RoR2.GlobalEventManager self, RoR2.DamageInfo damageInfo, GameObject hitObject)
        {
            if (damageInfo.procCoefficient == 0f || damageInfo.rejected)
            {
                return;
            }

            var attacker = damageInfo.attacker;

            if (attacker)
            {
                var body = attacker.GetComponent <CharacterBody>();
                if (body)
                {
                    if (body.HasBuff(EliteBuffIndex))
                    {
                        float   damageCoefficient2 = 0.5f;
                        float   damage             = Util.OnHitProcDamage(damageInfo.damage, body.damage, damageCoefficient2);
                        float   force    = 0f;
                        Vector3 position = damageInfo.position;
                        ProjectileManager.instance.FireProjectile(HyperchargedProjectile, position, Quaternion.identity, damageInfo.attacker, damage, force, damageInfo.crit, DamageColorIndex.Item, null, -1f);
                    }
                }
            }
        }
コード例 #3
0
ファイル: Class1.cs プロジェクト: NoLongerLloyd/ReorderMod
        private System.Collections.IEnumerator GlobalEventManager_CreateLevelUpEffect(On.RoR2.GlobalEventManager.orig_CreateLevelUpEffect orig, RoR2.GlobalEventManager self, float delay, GameObject levelUpEffect, RoR2.EffectData effectData)
        {
            yield return(new WaitForSeconds(delay));

            orig.Invoke(self, delay, levelUpEffect, effectData);

            foreach (RoR2.PlayerCharacterMasterController playerCharacterMasterController in RoR2.PlayerCharacterMasterController.instances)
            {
                bool isClient = playerCharacterMasterController.master.isClient;
                if (isClient)
                {
                    string        displayName = playerCharacterMasterController.GetDisplayName();
                    System.Random rnd         = new System.Random();

                    RoR2.CharacterMaster localUser  = playerCharacterMasterController.master;
                    RoR2.CharacterBody   playerBody = localUser.GetBody();
                    int playerLevel = (int)playerBody.level;

                    if (currentLevel < playerLevel)
                    {
                        ItemTier itemTier1           = ItemTier.Tier1;
                        int      amountOfItemsInTier = this.getAmountOfItemsInTier(itemTier1, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTier1, playerCharacterMasterController.master);
                        this.addItems(itemTier1, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tier1Min.Value, tier1Max.Value);

                        ItemTier itemTier2 = ItemTier.Tier2;
                        amountOfItemsInTier = this.getAmountOfItemsInTier(itemTier2, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTier2, playerCharacterMasterController.master);
                        this.addItems(itemTier2, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tier2Min.Value, tier2Max.Value);

                        ItemTier itemTier3 = ItemTier.Tier3;
                        amountOfItemsInTier = this.getAmountOfItemsInTier(itemTier3, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTier3, playerCharacterMasterController.master);
                        this.addItems(itemTier3, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tier3Min.Value, tier3Max.Value);

                        ItemTier itemTierLunar = ItemTier.Lunar;
                        amountOfItemsInTier = this.getAmountOfItemsInTier(itemTierLunar, playerCharacterMasterController.master);
                        this.removeAllItemsInTier(itemTierLunar, playerCharacterMasterController.master);
                        this.addItems(itemTierLunar, amountOfItemsInTier, playerCharacterMasterController.master, rnd, tierLunarMin.Value, tierLunarMax.Value);
                        currentLevel = playerLevel;
                    }
                }
            }

            yield break;
        }
コード例 #4
0
 private void PoisonEliteChanges(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, RoR2.GlobalEventManager self, RoR2.DamageInfo damageInfo, GameObject victim)
 {
     if (damageInfo.attacker)
     {
         RoR2.CharacterBody component     = damageInfo.attacker.GetComponent <RoR2.CharacterBody>();
         RoR2.CharacterBody characterBody = victim ? victim.GetComponent <RoR2.CharacterBody>() : null;
         if (component)
         {
             RoR2.CharacterMaster master = component.master;
             if (master)
             {
                 if ((component.HasBuff(Resources.Load <BuffDef>("buffdefs/AffixPoison")) ? 1 : 0) > 0 && characterBody)
                 {
                     int   itemCount = master.inventory.GetItemCount(AspectsToItems.AspectsToItems.NewDefsList.Find(x => x.name == "AffixPoison").itemIndex);
                     float amount    = damageInfo.damage * (0.05f + 0.05f * itemCount);
                     if (itemCount == 0)
                     {
                         amount = damageInfo.damage * .1f;
                     }
                     component.healthComponent.Heal(amount, damageInfo.procChainMask, true);
                 }
             }
         }
     }
     orig(self, damageInfo, victim);
 }
コード例 #5
0
        private void GrantOnKillEffectsOnHighDamage(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, RoR2.GlobalEventManager self, RoR2.DamageInfo damageInfo, GameObject victim)
        {
            var attacker = damageInfo.attacker;

            if (attacker)
            {
                var body       = attacker.GetComponent <CharacterBody>();
                var victimBody = victim.GetComponent <CharacterBody>();
                if (body && victimBody)
                {
                    var InventoryCount = GetCount(body);
                    if (InventoryCount > 0)
                    {
                        if (damageInfo.damage / body.damage >= witchesRingTriggerThreshold && !victimBody.HasBuff(WitchesRingImmunityBuff))
                        {
                            if (NetworkServer.active)
                            {
                                victimBody.AddTimedBuffAuthority(WitchesRingImmunityBuff, baseCooldownDuration / (1 + additionalCooldownReduction * (InventoryCount - 1)));
                                DamageReport damageReport = new DamageReport(damageInfo, victimBody.healthComponent, damageInfo.damage, victimBody.healthComponent.combinedHealth);
                                GlobalEventManager.instance.OnCharacterDeath(damageReport);
                            }
                        }
                    }
                }
            }
            orig(self, damageInfo, victim);
        }