private float Voidheart30PercentTimebomb(On.RoR2.HealthComponent.orig_Heal orig, RoR2.HealthComponent self, float amount, RoR2.ProcChainMask procChainMask, bool nonRegen) { var InventoryCount = GetCount(self.body); if (self.body && InventoryCount > 0) { if (self.combinedHealth <= self.fullCombinedHealth * Mathf.Clamp((voidHeartBaseTickingTimeBombHealthThreshold + (voidHeartAdditionalTickingTimeBombHealthThreshold * InventoryCount - 1)), voidHeartBaseTickingTimeBombHealthThreshold, voidHeartMaxTickingTimeBombHealthThreshold) && //This check is for the timer to determine time since spawn, at <= 10f it'll only activate after the tenth second self.GetComponent <VoidHeartPrevention>().internalTimer >= 7f) { RoR2.DamageInfo damageInfo = new RoR2.DamageInfo(); damageInfo.crit = false; damageInfo.damage = amount; damageInfo.force = Vector3.zero; damageInfo.position = self.transform.position; damageInfo.procChainMask = procChainMask; damageInfo.procCoefficient = 0f; damageInfo.damageColorIndex = DamageColorIndex.Default; damageInfo.damageType = DamageType.Generic; self.TakeDamage(damageInfo); return(orig(self, 0, procChainMask, nonRegen)); } } return(orig(self, amount, procChainMask, nonRegen)); }
private void IceEliteChanges(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { RoR2.CharacterBody characterBody = null; if (damageInfo.attacker) { characterBody = damageInfo.attacker.GetComponent <RoR2.CharacterBody>(); } if (damageInfo.damage > 0) { if (characterBody) { RoR2.CharacterMaster master = characterBody.master; if (master && master.inventory) { if (damageInfo.procCoefficient > 0f) { if (characterBody.GetBuffCount(Resources.Load <BuffDef>("buffdefs/AffixWhite")) > 0) { self.body.AddTimedBuff(FreezingBlood.buffIndex, 2f * damageInfo.procCoefficient); if (self.body.GetBuffCount(FreezingBlood.buffIndex) >= 10) { self.body.ClearTimedBuffs(FreezingBlood.buffIndex); RoR2.CharacterBody component = damageInfo.attacker.GetComponent <RoR2.CharacterBody>(); RoR2.ProcChainMask procChainMask = damageInfo.procChainMask; int AffixWhiteStack = master.inventory.GetItemCount(AspectsToItems.AspectsToItems.NewDefsList.Find(x => x.name == "AffixWhite").itemIndex); Vector3 position = damageInfo.position; float damageCoefficient = 10f + 10f * AffixWhiteStack; if (AffixWhiteStack == 0) { damageCoefficient = 20f; } float damage2 = RoR2.Util.OnHitProcDamage(component.damage, component.damage, damageCoefficient); RoR2.DamageInfo damageInfo2 = new RoR2.DamageInfo { damage = damage2, damageColorIndex = DamageColorIndex.Item, damageType = DamageType.Generic, attacker = damageInfo.attacker, crit = damageInfo.crit, force = Vector3.zero, inflictor = null, position = position, procChainMask = procChainMask, procCoefficient = 1f }; RoR2.EffectManager.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/IceCullExplosion"), position, Vector3.up, true); self.TakeDamage(damageInfo2); } } } } } } orig(self, damageInfo); }
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); }
private void TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { if (!damageInfo.rejected || damageInfo == null) { var bleedComponent = self.GetComponent <BleedTrackerComponent>(); if (!bleedComponent) { bleedComponent = self.gameObject.AddComponent <BleedTrackerComponent>(); } var inventoryCount = GetCount(self.body.inventory); //var healthBefore = self.health; //debug if (damageInfo.inflictor != SharkTeeth.instance.BleedInflictor && inventoryCount > 0) { //Chat.AddMessage($"Damage Before: {damageInfo.damage}"); //debug var percentage = baseDamageSpreadPercentage + (maxDamageSpreadPercentage - maxDamageSpreadPercentage / (1 + additionalDamageSpreadPercentage * (inventoryCount - 1))); var damage = damageInfo.damage * percentage; var time = durationOfDamageSpread; var segments = ticksOfDamageDuringDuration; damageInfo.damage -= damage; bleedComponent.BleedStacks.Add(new BleedStack(time / segments, damage / segments, segments, damageInfo.attacker, damageInfo.damageType)); } } orig(self, damageInfo); //if (inventoryCount > 0) {Chat.AddMessage($"Actual Damage: {healthBefore - self.health}");} //debug }
private void CalculateBerryBuff(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { var InventoryCount = GetCount(self.body); if (InventoryCount > 0) { self.body.AddTimedBuffAuthority(NumbBerryBuff, 2f + (.5f * (InventoryCount - 1))); } orig(self, damageInfo); }
private void CalculateBuff(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { var preDamageShield = self.body.healthComponent.shield; orig(self, damageInfo); var inventoryCount = GetCount(self.body); if (inventoryCount > 0) { float dmgTaken = damageInfo.damage; if (dmgTaken >= preDamageShield && preDamageShield > 0) { if (self.body.GetBuffCount(SecondWindBuff) == 0 && self.body.GetBuffCount(WindedDebuff) == 0) { self.body.AddTimedBuffAuthority(SecondWindBuff, 4f + (5f * (self.body.maxShield / self.body.maxHealth))); } } } }
private void ReduceKnockback(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { var InventoryCount = GetCount(self.body); if (InventoryCount > 0) { var percentReduction = Mathf.Clamp(1 - (InventoryCount * baseKnockbackReductionPercentage), 0, 1); damageInfo.force = damageInfo.force * percentReduction; } orig(self, damageInfo); }
private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { if (damageInfo.damageType.HasFlag(DamageType.Freeze2s)) { this.frozenBy[self.gameObject] = damageInfo.attacker; } if (damageInfo.dotIndex == this.burnDot) { if (damageInfo.attacker) { CharacterBody attackerBody = damageInfo.attacker.GetComponent <CharacterBody>(); if (attackerBody) { Int32 buffCount = attackerBody.GetBuffCount(this.fireBuff); if (buffCount >= 0) { damageInfo.damage *= 1f + (AltArtiPassive.burnDamageMult * buffCount); } } } } orig(self, damageInfo); }
public void TakeDamage(DamageInfo damageInfo) { if (!NetworkServer.active) { Debug.LogWarning("[Server] function 'System.Void RoR2.HealthComponent::TakeDamage(RoR2.DamageInfo)' called on client"); return; } if (!alive || godMode) { return; } CharacterBody characterBody = null; if (damageInfo.attacker) { characterBody = damageInfo.attacker.GetComponent <CharacterBody>(); } BroadcastMessage("OnIncomingDamage", damageInfo, SendMessageOptions.DontRequireReceiver); var master = body.master; GetComponent <TeamComponent>(); if (master && master.inventory) { var itemCount = master.inventory.GetItemCount((ItemIndex)1); if (itemCount > 0 && Util.CheckRoll((1f - 1f / (0.15f * itemCount + 1f)) * 100f, 0f, null)) { var effectData = new EffectData { origin = damageInfo.position, rotation = Util.QuaternionSafeLookRotation((damageInfo.force != Vector3.zero) ? damageInfo.force : Random.onUnitSphere) }; EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/BearProc"), effectData, true); damageInfo.rejected = true; } } if (body.HasBuff((BuffIndex)3)) { damageInfo.rejected = true; } if (body.HasBuff((BuffIndex)23) && (!characterBody || !characterBody.HasBuff((BuffIndex)22))) { EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/DamageRejected"), new EffectData { origin = damageInfo.position }, true); damageInfo.rejected = true; } if (damageInfo.rejected) { return; } var num = damageInfo.damage; if (characterBody) { var master2 = characterBody.master; if (master2 && master2.inventory) { if (combinedHealth >= fullCombinedHealth * 0.9f) { var itemCount2 = master2.inventory.GetItemCount((ItemIndex)17); if (itemCount2 > 0) { Util.PlaySound("Play_item_proc_crowbar", gameObject); num *= 1.5f + 0.3f * (itemCount2 - 1); EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactCrowbar"), damageInfo.position, -damageInfo.force, true); } } if (body.isBoss) { var itemCount3 = master2.inventory.GetItemCount((ItemIndex)61); if (itemCount3 > 0) { num *= 1.2f + 0.1f * (itemCount3 - 1); damageInfo.damageColorIndex = (DamageColorIndex)5; EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactBossDamageBonus"), damageInfo.position, -damageInfo.force, true); } } } } if (damageInfo.crit) { num *= 2f; } if ((damageInfo.damageType & DamageType.WeakPointHit) != 0) { num *= 1.5f; damageInfo.damageColorIndex = (DamageColorIndex)5; } if ((damageInfo.damageType & DamageType.BypassArmor) == 0) { var armor = body.armor; var num2 = armor >= 0f ? 1f - armor / (armor + 100f) : 2f - 100f / (100f - armor); num = Mathf.Max(1f, num * num2); } if ((damageInfo.damageType & DamageType.BarrierBlocked) != 0) { damageInfo.force *= 0.5f; var component = GetComponent <IBarrier>(); component?.BlockedDamage(damageInfo, num); damageInfo.procCoefficient = 0f; num = 0f; } if (hasOneshotProtection) { num = Mathf.Min(num, fullCombinedHealth * 0.40f); // Make this more aggressive; 90% -> 40% } if ((damageInfo.damageType & DamageType.SlowOnHit) != 0) { body.AddTimedBuff(0, 2f); } if ((damageInfo.damageType & DamageType.ClayGoo) != 0 && (body.bodyFlags & CharacterBody.BodyFlags.ImmuneToGoo) == 0) { body.AddTimedBuff((BuffIndex)21, 2f); } if (master && master.inventory) { var itemCount4 = master.inventory.GetItemCount((ItemIndex)44); if (itemCount4 > 0) { var num3 = num / fullCombinedHealth; var num4 = (uint)Mathf.Max(master.money * num3 * itemCount4, damageInfo.damage * itemCount4); master.money = (uint)Mathf.Max(0f, master.money - num4); EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact"), damageInfo.position, Vector3.up, true); } } if ((damageInfo.damageType & DamageType.NonLethal) != 0) { num = Mathf.Max(Mathf.Min(num, health - 1f), 0f); } if (shield > 0f) { var num5 = Mathf.Min(num, shield); var num6 = num - num5; Networkshield = Mathf.Max(shield - num5, 0f); if (Mathf.Approximately(shield, 0f)) { var scale = 1f; if (body) { scale = body.radius; } EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShieldBreakEffect"), new EffectData { origin = transform.position, scale = scale }, true); } if (num6 > 0f) { Networkhealth = health - num6; } } else { Networkhealth = health - num; } TakeDamageForce(damageInfo, false); SendMessage("OnTakeDamage", damageInfo, SendMessageOptions.DontRequireReceiver); var damageReport = new DamageReport { victim = this, damageInfo = damageInfo }; damageReport.damageInfo.damage = num; if (num > 0f) { SendDamageDealt(damageReport); } UpdateLastHitTime(damageInfo.damage, damageInfo.position, (damageInfo.damageType & (DamageType)2048) > 0); if (damageInfo.attacker) { damageInfo.attacker.SendMessage("OnDamageDealt", damageReport, SendMessageOptions.DontRequireReceiver); } GlobalEventManager.ServerDamageDealt(damageReport); if (isInFrozenState && (body.bodyFlags & (CharacterBody.BodyFlags) 16) == 0 && combinedHealthFraction < 0.3f) { Networkhealth = -1f; EffectManager.instance.SpawnEffect(FrozenState.executeEffectPrefab, new EffectData { origin = body.corePosition, scale = body ? body.radius : 1f }, true); } if (!alive) { BroadcastMessage("OnKilled", damageInfo, SendMessageOptions.DontRequireReceiver); if (damageInfo.attacker) { damageInfo.attacker.SendMessage("OnKilledOther", damageReport, SendMessageOptions.DontRequireReceiver); } GlobalEventManager.instance.OnCharacterDeath(damageReport); return; } if (master && master.inventory) { var itemCount5 = master.inventory.GetItemCount((ItemIndex)25); if (itemCount5 > 0 && Util.CheckRoll(damageInfo.damage / fullCombinedHealth * 100f, master)) { body.AddTimedBuff((BuffIndex)7, 1.5f + itemCount5 * 1.5f); body.AddTimedBuff((BuffIndex)8, 1.5f + itemCount5 * 1.5f); EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ProcStealthkit"), new EffectData { origin = transform.position, rotation = Quaternion.identity }, true); } } }
private void ClearFire(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { InventoryCount = GetCount(self.body); if (InventoryCount > 0) { if (self.body.HasBuff(BuffIndex.OnFire)) { self.body.RemoveBuff(BuffIndex.OnFire); Chat.AddMessage("Extinguished!"); } //if (DotController.HasDotActive(DotController.DotIndex.Burn) | DotController.HasDotActive(DotController.DotIndex.PercentBurn) | DotController.HasDotActive(DotController.DotIndex.Helfire)) //if (DotController.FindDotController(self.body.)) //DoTController Remove //Material remove //ModelLocator component = victimObject.GetComponent<ModelLocator>(); //UnityEngine.Object.Destroy(this.burnEffectController) switch (damageInfo.damageType) { case DamageType.IgniteOnHit: case DamageType.PercentIgniteOnHit: damageInfo.damageType = DamageType.Generic; Chat.AddMessage("Removed Fire from attack!"); break; default: break; } } orig(self, damageInfo); }
private void CalculateSpeedReward(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { var InventoryCount = GetCount(self.body); if (InventoryCount > 0 && self.body.GetBuffCount(SpeedBuff) < buffStacksPerFeatheredPlume * InventoryCount) { self.body.AddTimedBuffAuthority(SpeedBuff, (baseDurationOfBuffInSeconds + (additionalDurationOfBuffInSeconds * InventoryCount - 1))); } orig(self, damageInfo); }
private void OnCharacterDeathCallback(DamageReport damageReport) { if (!NetworkServer.active) { Debug.LogWarning("[Server] function 'System.Void RoR2.BossGroup::OnCharacterDeathCallback(RoR2.DamageReport)' called on client"); return; } DamageInfo damageInfo = damageReport.damageInfo; GameObject gameObject = damageReport.victim.gameObject; CharacterBody component = gameObject.GetComponent <CharacterBody>(); if (!component) { return; } CharacterMaster master = component.master; if (!master) { return; } DeathRewards component2 = gameObject.GetComponent <DeathRewards>(); if (component2) { PickupIndex pickupIndex = (PickupIndex)component2.bossPickup; if (pickupIndex != PickupIndex.none) { this.bossDrops.Add(pickupIndex); } } GameObject victimMasterGameObject = master.gameObject; int num = this.membersList.FindIndex((CharacterMaster x) => x.gameObject == victimMasterGameObject); if (num >= 0) { this.RemoveMemberAt(num); if (!this.defeated && this.membersList.Count == 0) { Run.instance.OnServerBossKilled(true); if (component) { int participatingPlayerCount = Run.instance.participatingPlayerCount; if (participatingPlayerCount != 0 && this.dropPosition) { ItemIndex itemIndex = Run.instance.availableTier2DropList[this.rng.RangeInt(0, Run.instance.availableTier2DropList.Count)].itemIndex; int num2 = participatingPlayerCount * (1 + (TeleporterInteraction.instance ? TeleporterInteraction.instance.shrineBonusStacks : 0)); float angle = 360f / (float)num2; Vector3 vector = Quaternion.AngleAxis((float)UnityEngine.Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f); Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.up); int i = 0; while (i < num2) { PickupIndex pickupIndex2 = new PickupIndex(itemIndex); if (this.bossDrops.Count > 0 && this.rng.nextNormalizedFloat <= this.bossDropChance) { pickupIndex2 = this.bossDrops[this.rng.RangeInt(0, this.bossDrops.Count)]; } PickupDropletController.CreatePickupDroplet(pickupIndex2, this.dropPosition.position, vector); i++; vector = rotation * vector; } } } this.defeated = true; Action <BossGroup> action = BossGroup.onBossGroupDefeatedServer; if (action == null) { return; } action(this); return; } else { Run.instance.OnServerBossKilled(false); } } }
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); }
private void CalculateDamageReduction(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { float currentShield = self.body.healthComponent.shield; orig(self, damageInfo); var inventoryCount = GetCount(self.body); if (inventoryCount > 0) { float dmgTaken = damageInfo.damage; float maxShield = self.body.maxShield; float shieldDamage = Math.Min(dmgTaken, currentShield); if (currentShield > 0 && dmgTaken > currentShield) { float baseReduction = dmgTaken * (.1f + (.05f * (inventoryCount - 1))); float bonusReduction = ((shieldDamage / maxShield) * 100) * (0.05f + ((inventoryCount - 1) * 0.025f)); float totalDamageReduction = baseReduction + bonusReduction; damageInfo.damage -= totalDamageReduction; } } }
private void CalculateBloodBookBuff(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { var inventoryCount = GetCount(self.body); var patheticBuffCount = self.body.GetBuffCount(PatheticBloodBuff); var weakBuffCount = self.body.GetBuffCount(WeakBloodBuff); var averageBuffCount = self.body.GetBuffCount(AverageBloodBuff); var strongBuffCount = self.body.GetBuffCount(StrongBloodBuff); var insaneBuffCount = self.body.GetBuffCount(InsaneBloodBuff); var devotedBuffCount = self.body.GetBuffCount(DevotedBloodBuff); float dmgTaken = damageInfo.damage; float maxHealth = self.body.maxHealth; if (inventoryCount > 0) { //This bit simply caches the damage you take for usage by the actual AddBloodBuffStats hook var cachedDamageComponent = self.body.gameObject.GetComponent <DamageComponent>(); if (!cachedDamageComponent) { cachedDamageComponent = self.body.gameObject.AddComponent <DamageComponent>(); } //Each of these checks to make sure a higher-tier buff isn't already active, and cleanses any lower-tier buffs before applying their buff. Maybe there's a cleaner way to do it but oh well... if (dmgTaken <= maxHealth * .1 && weakBuffCount == 0 && averageBuffCount == 0 && strongBuffCount == 0 && insaneBuffCount == 0 && devotedBuffCount == 0) { self.body.AddTimedBuffAuthority(PatheticBloodBuff, 4f); cachedDamageComponent.cachedDamage = dmgTaken; } if (dmgTaken >= maxHealth * .1 && dmgTaken <= maxHealth * .2 && averageBuffCount == 0 && strongBuffCount == 0 && insaneBuffCount == 0 && devotedBuffCount == 0) { self.body.RemoveBuff(PatheticBloodBuff); self.body.AddTimedBuffAuthority(WeakBloodBuff, 6f); cachedDamageComponent.cachedDamage = dmgTaken; } if (dmgTaken >= maxHealth * .2 && dmgTaken <= maxHealth * .3 && strongBuffCount == 0 && insaneBuffCount == 0 && devotedBuffCount == 0) { self.body.RemoveBuff(PatheticBloodBuff); self.body.RemoveBuff(WeakBloodBuff); self.body.AddTimedBuffAuthority(AverageBloodBuff, 8f); cachedDamageComponent.cachedDamage = dmgTaken; } if (dmgTaken >= maxHealth * .3 && dmgTaken <= maxHealth * .4 && insaneBuffCount == 0 && devotedBuffCount == 0) { self.body.RemoveBuff(PatheticBloodBuff); self.body.RemoveBuff(WeakBloodBuff); self.body.RemoveBuff(AverageBloodBuff); self.body.AddTimedBuffAuthority(StrongBloodBuff, 10f); cachedDamageComponent.cachedDamage = dmgTaken; } if (dmgTaken >= maxHealth * .4 && dmgTaken <= maxHealth * .5 && devotedBuffCount == 0) { self.body.RemoveBuff(PatheticBloodBuff); self.body.RemoveBuff(WeakBloodBuff); self.body.RemoveBuff(AverageBloodBuff); self.body.RemoveBuff(StrongBloodBuff); self.body.AddTimedBuffAuthority(InsaneBloodBuff, 12f); cachedDamageComponent.cachedDamage = dmgTaken; } if (dmgTaken >= maxHealth * .5) { self.body.RemoveBuff(PatheticBloodBuff); self.body.RemoveBuff(WeakBloodBuff); self.body.RemoveBuff(AverageBloodBuff); self.body.RemoveBuff(StrongBloodBuff); self.body.RemoveBuff(InsaneBloodBuff); self.body.AddTimedBuffAuthority(InsaneBloodBuff, 14f); cachedDamageComponent.cachedDamage = dmgTaken; } } orig(self, damageInfo); }
private void BFBuffLoss(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { var BuffCount = self.body.GetBuffCount(BFBuff); while (BuffCount > 0) { self.body.RemoveBuff(BFBuff); BuffCount -= 1; } orig(self, damageInfo); }
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); } } } }
// Token: 0x0600070C RID: 1804 RVA: 0x0001DEC8 File Offset: 0x0001C0C8 public void OnProjectileImpact(ProjectileImpactInfo impactInfo) { if (!this.alive) { return; } Collider collider = impactInfo.collider; if (collider) { DamageInfo damageInfo = new DamageInfo(); if (this.projectileDamage) { damageInfo.damage = this.projectileDamage.damage; damageInfo.crit = this.projectileDamage.crit; damageInfo.attacker = (this.projectileController.owner ? this.projectileController.owner.gameObject : null); damageInfo.inflictor = base.gameObject; damageInfo.position = impactInfo.estimatedPointOfImpact; damageInfo.force = this.projectileDamage.force * this.transform.forward; damageInfo.procChainMask = this.projectileController.procChainMask; damageInfo.procCoefficient = this.projectileController.procCoefficient; damageInfo.damageColorIndex = this.projectileDamage.damageColorIndex; } HurtBox component = collider.GetComponent <HurtBox>(); if (component) { HealthComponent healthComponent = component.healthComponent; if (healthComponent) { Transform transform = healthComponent.gameObject.transform; if (healthComponent.gameObject == this.projectileController.owner) { return; } if ((!this.pastTargetList.Contains(transform) || (this.canBounceToSameTarget && transform != this.lastTarget)) && (transform == this.currentTarget || this.canHitNonTarget || !this.currentTarget)) { this.pastTargetList.Add(transform); if (this.currentTarget) { this.lastTarget = this.currentTarget; } else { this.lastTarget = transform; } this.currentTarget = this.FindTarget(); this.bounceCount++; healthComponent.TakeDamage(damageInfo); GlobalEventManager.instance.OnHitAll(damageInfo, collider.gameObject); GlobalEventManager.instance.OnHitEnemy(damageInfo, component.healthComponent.gameObject); if (this.projectileDamage) { this.projectileDamage.damage *= this.damageMultiplier; } if (this.impactEffect) { EffectManager.SimpleImpactEffect(this.impactEffect, this.transform.position, -this.transform.forward, !this.projectileController.isPrediction); } if (this.bounceCount >= this.maxBounceCount) { this.alive = false; } } } } else if (this.destroyOnWorldIfNoTarget && this.currentTarget == null) { damageInfo.position = this.transform.position; GlobalEventManager.instance.OnHitAll(damageInfo, collider.gameObject); if (this.impactEffect) { EffectManager.SimpleImpactEffect(this.impactEffect, this.transform.position, -this.transform.forward, !this.projectileController.isPrediction); } this.alive = false; } } if (!this.alive) { UnityEngine.Object.Destroy(base.gameObject); } }
private void GetOverHere(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { if (damageInfo?.attacker) //Do we even have a valid attacker? { var attackerBody = damageInfo.attacker.GetComponent <RoR2.CharacterBody>(); if (attackerBody) //Does this attacker have a body we can use? { int ItemCount = GetCount(attackerBody); if (ItemCount > 0) //Does the attacker have any of our item? { var mass = self.body.characterMotor?.mass ?? (self.body.rigidbody?.mass ?? 1f); var forceCalc = Mathf.Clamp(startingForceMultiplier + (additionalForceMultiplier * (ItemCount - 1)), minimumForceMultiplier, maximumForceMultiplier); damageInfo.force += Vector3.Normalize(attackerBody.corePosition - self.body.corePosition) * forceCalc * mass; } } } orig(self, damageInfo); }
private void ApplyBloodBookBuff(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { int inventoryCount = GetCount(self.body); float dmgTaken = damageInfo.damage; float maxHealth = self.body.maxHealth; if (inventoryCount > 0) { //This bit will cache the damage you took for use by the actual damage boost calculator, only if the damage exceeds any previous cached damage numbers var cachedDamageComponent = self.body.gameObject.GetComponent <DamageComponent>(); if (!cachedDamageComponent) { cachedDamageComponent = self.body.gameObject.AddComponent <DamageComponent>(); } if (cachedDamageComponent.cachedDamage < dmgTaken) { cachedDamageComponent.cachedDamage = dmgTaken; } //Check your current buff, and what your potential next buff would be. currentBuffLevel returns -1 if you don't have a buff already int currentBuffLevel = Array.FindIndex(ranges, r => self.body.HasBuff(r.Buff)); int nextBuffLevel = Array.FindIndex(ranges, r => r.Contains((dmgTaken / maxHealth) * 100)); if (nextBuffLevel > currentBuffLevel) { if (currentBuffLevel != -1) { self.body.RemoveBuff(ranges[currentBuffLevel].Buff); } self.body.AddTimedBuff(ranges[nextBuffLevel].Buff, ranges[nextBuffLevel].Duration); //Bombinomicon (Fear of Reading) stuff is handled here if (fearOfReading == true) { int willBookRead = new System.Random().Next(1, 101); if (willBookRead <= chanceBookReads) { AkSoundEngine.PostEvent(4030648726u, self.body.gameObject); } } } } orig(self, damageInfo); }
// Token: 0x06000A0E RID: 2574 RVA: 0x00046974 File Offset: 0x00044B74 public void Fire() { Collider[] array = Physics.OverlapSphere(this.position, this.radius, LayerIndex.entityPrecise.mask); int num = array.Length; for (int i = 0; i < num; i++) { Collider collider = array[i]; HurtBox component = collider.GetComponent <HurtBox>(); if (component) { HealthComponent healthComponent = component.healthComponent; if (healthComponent && ((this.canHurtAttacker && healthComponent.gameObject == this.attacker) || healthComponent.GetComponent <TeamComponent>().teamIndex != this.teamIndex)) { BlastAttack.HitPoint hitPoint = default(BlastAttack.HitPoint); RaycastHit raycastHit = default(RaycastHit); hitPoint.hurtBox = component; Vector3 direction = collider.transform.position - this.position; if (direction.sqrMagnitude > 0f && collider.Raycast(new Ray(this.position, direction), out raycastHit, this.radius)) { hitPoint.hitPosition = raycastHit.point; hitPoint.hitNormal = raycastHit.normal; } else { hitPoint.hitPosition = collider.transform.position; hitPoint.hitNormal = this.position - hitPoint.hitPosition; } hitPoint.distanceSqr = (hitPoint.hitPosition - this.position).sqrMagnitude; if (!BlastAttack.bestHitPoints.ContainsKey(healthComponent) || BlastAttack.bestHitPoints[healthComponent].distanceSqr > hitPoint.distanceSqr) { BlastAttack.bestHitPoints[healthComponent] = hitPoint; } } } } BlastAttack.HitPoint[] array2 = new BlastAttack.HitPoint[BlastAttack.bestHitPoints.Count]; int num2 = 0; foreach (KeyValuePair <HealthComponent, BlastAttack.HitPoint> keyValuePair in BlastAttack.bestHitPoints) { array2[num2++] = keyValuePair.Value; } BlastAttack.bestHitPoints.Clear(); Array.Sort <BlastAttack.HitPoint>(array2, new Comparison <BlastAttack.HitPoint>(BlastAttack.HitPoint.DistanceSort)); foreach (BlastAttack.HitPoint hitPoint2 in array2) { float num3 = Mathf.Sqrt(hitPoint2.distanceSqr); float num4 = 0f; switch (this.falloffModel) { case BlastAttack.FalloffModel.None: num4 = 1f; break; case BlastAttack.FalloffModel.Linear: num4 = 1f - Mathf.Clamp01(num3 / this.radius); break; case BlastAttack.FalloffModel.SweetSpot: num4 = 1f - ((num3 > this.radius / 2f) ? 0.75f : 0f); break; } DamageInfo damageInfo = new DamageInfo(); damageInfo.attacker = this.attacker; damageInfo.inflictor = this.inflictor; damageInfo.damage = this.baseDamage * num4; damageInfo.crit = this.crit; damageInfo.force = this.bonusForce * num4 + this.baseForce * num4 * (hitPoint2.hitPosition - this.position).normalized; damageInfo.procChainMask = this.procChainMask; damageInfo.procCoefficient = this.procCoefficient; damageInfo.damageType = this.damageType; damageInfo.damageColorIndex = this.damageColorIndex; damageInfo.position = hitPoint2.hitPosition; damageInfo.ModifyDamageInfo(hitPoint2.hurtBox.damageModifier); hitPoint2.hurtBox.healthComponent.TakeDamage(damageInfo); GlobalEventManager.instance.OnHitEnemy(damageInfo, hitPoint2.hurtBox.healthComponent.gameObject); GlobalEventManager.instance.OnHitAll(damageInfo, hitPoint2.hurtBox.healthComponent.gameObject); } }
private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { if (damageInfo.dotIndex == RoR2.DotController.DotIndex.Poison) { damageInfo.damage = self.combinedHealth * (1 - Mathf.Exp(-damageInfo.damage / self.fullCombinedHealth)); } orig(self, damageInfo); }
private void hook(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { orig(self, damageInfo); if (damageInfo.rejected) { PlayerStatsComponent.FindBodyStatSheet(self.body).PushStatValue(Definition, 1); } }
private void PunishHeretics(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { if (damageInfo == null || damageInfo.rejected) { return; } var body = self.body; if (body && body.HasBuff(EliteBuffIndex) && damageInfo.attacker) { var attackerBody = damageInfo.attacker.GetComponent <CharacterBody>(); if (attackerBody && (attackerBody.corePosition - body.corePosition).sqrMagnitude > 40 * 40) { var Ray = new Ray(attackerBody.corePosition, Vector3.up); RaycastHit HitResults; var RayHit = Util.CharacterRaycast(damageInfo.attacker, Ray, out HitResults, 1000, LayerIndex.world.mask, QueryTriggerInteraction.Ignore); var newProjectileInfo = new FireProjectileInfo(); newProjectileInfo.owner = body.gameObject; newProjectileInfo.projectilePrefab = RadiantProjectile; newProjectileInfo.damage = body.damage * 4; newProjectileInfo.procChainMask = default(RoR2.ProcChainMask); if (RayHit) { Debug.Log("Terrain Detected"); newProjectileInfo.position = HitResults.point; newProjectileInfo.rotation = Util.QuaternionSafeLookRotation(Vector3.down); } else { Debug.Log("Sky Detected"); newProjectileInfo.position = attackerBody.corePosition + (Vector3.up * 100); newProjectileInfo.rotation = Util.QuaternionSafeLookRotation(Vector3.down); } if (NetworkServer.active) { EffectManager.SimpleEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ExplosionVFX"), newProjectileInfo.position, newProjectileInfo.rotation, true); } ProjectileManager.instance.FireProjectile(newProjectileInfo); } } orig(self, damageInfo); }
private void HealthDamageHook(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { orig.Invoke(self, damageInfo); float dmg = damageInfo.damage; if (!self.body || !self.body.isPlayerControlled) { return; //Ignore if it's not a player. } if (damageInfo.damageType.HasFlag(DamageType.NonLethal) || damageInfo.rejected || !self.alive) { return; //Ignore if it's fall damage, blocked, or we just straight up died. } if (dmg > self.fullCombinedHealth * 0.9) //the big Damage { #if DEBUG PlayerStatsComponent.FindBodyStatSheet(self.body).PushStatValue(this.testDef, 1UL); #endif if (self.combinedHealthFraction <= 0.12) //Are we barely alive? { PlayerStatsComponent.FindBodyStatSheet(self.body).PushStatValue(this.ourStatDef, 1UL); } } }
private void FireSplinter(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { var body = self.body; if (body) { if (body.HasBuff(EliteBuffIndex)) { var newProjectileInfo = new FireProjectileInfo(); newProjectileInfo.owner = body.gameObject; newProjectileInfo.projectilePrefab = SplinteringProjectile; newProjectileInfo.speedOverride = 50.0f; newProjectileInfo.damage = body.damage; newProjectileInfo.damageTypeOverride = null; newProjectileInfo.damageColorIndex = DamageColorIndex.Default; newProjectileInfo.procChainMask = default(RoR2.ProcChainMask); //var theta = (Math.PI * 2) / swordsPerFlower; //var angle = theta * i; //var radius = 3; //var positionChosen = new Vector3((float)(radius * Math.Cos(angle) + damageInfo.position.x), damageInfo.position.y + 3, (float)(radius * Math.Sin(angle) + damageInfo.position.z)); Vector3 PositionChosen; if (damageInfo.attacker) { var attackerBody = damageInfo.attacker.GetComponent <CharacterBody>(); if (attackerBody) { PositionChosen = attackerBody.corePosition; } else { PositionChosen = body.transform.position; } } else { PositionChosen = body.transform.position; } if (random.nextNormalizedFloat > 0.15f) { var randomOffset = new Vector3(random.RangeFloat(-1, 1), random.RangeFloat(-1, 1), random.RangeFloat(-1, 1)); if (randomOffset.Equals(Vector3.zero)) { randomOffset = Vector3.one; } PositionChosen += randomOffset.normalized * random.RangeFloat(0, 10); } newProjectileInfo.position = damageInfo.position; newProjectileInfo.rotation = RoR2.Util.QuaternionSafeLookRotation(PositionChosen - damageInfo.position); if (NetworkServer.active) { EffectManager.SimpleEffect(Resources.Load <GameObject>("Prefabs/Effects/BrittleDeath"), newProjectileInfo.position, newProjectileInfo.rotation, true); } ProjectileManager.instance.FireProjectile(newProjectileInfo); } } orig(self, damageInfo); }