// try and setup our character, if we hit an error we set it to false //TODO: Find a way to stop it from checking whilst in main menu/lobby menu private static void GetCharacter() { try { LocalNetworkUser = null; foreach (NetworkUser readOnlyInstance in NetworkUser.readOnlyInstancesList) { //localplayer == you! if (readOnlyInstance.isLocalPlayer) { LocalNetworkUser = readOnlyInstance; LocalPlayer = LocalNetworkUser.master; LocalPlayerInv = LocalPlayer.GetComponent <Inventory>(); LocalHealth = LocalPlayer.GetBody().GetComponent <HealthComponent>(); LocalSkills = LocalPlayer.GetBody().GetComponent <SkillLocator>(); if (LocalHealth.alive) { _CharacterCollected = true; } else { _CharacterCollected = false; } } } } catch (Exception e) { _CharacterCollected = false; } }
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 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 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 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); }
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 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 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 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 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 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 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); }
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 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); }
// Token: 0x06000A05 RID: 2565 RVA: 0x00031D38 File Offset: 0x0002FF38 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 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; } } }
// Token: 0x060006F2 RID: 1778 RVA: 0x0001D0F4 File Offset: 0x0001B2F4 private void UpdateCrosshair(Vector3 raycastStartPlanePoint) { this.lastAimAssist = this.aimAssist; Vector2 zero = Vector2.zero; Ray crosshairRaycastRay = this.GetCrosshairRaycastRay(zero, raycastStartPlanePoint); bool flag = false; this.lastCrosshairHurtBox = null; RaycastHit raycastHit = default(RaycastHit); RaycastHit[] array = Physics.RaycastAll(crosshairRaycastRay, this.maxAimRaycastDistance, LayerIndex.world.mask | LayerIndex.entityPrecise.mask, QueryTriggerInteraction.Ignore); float num = float.PositiveInfinity; int num2 = -1; for (int i = 0; i < array.Length; i++) { RaycastHit raycastHit2 = array[i]; HurtBox hurtBox = raycastHit2.collider.GetComponent <HurtBox>(); EntityLocator component = raycastHit2.collider.GetComponent <EntityLocator>(); float distance = raycastHit2.distance; if (distance > 3f && num > distance) { if (hurtBox) { if (hurtBox.teamIndex == this.targetTeamIndex) { goto IL_145; } if (hurtBox.healthComponent && hurtBox.healthComponent.dontShowHealthbar) { hurtBox = null; } } if (component) { VehicleSeat vehicleSeat = component.entity ? component.entity.GetComponent <VehicleSeat>() : null; if (vehicleSeat && vehicleSeat.currentPassengerBody == this.targetBody) { goto IL_145; } } num = distance; num2 = i; this.lastCrosshairHurtBox = hurtBox; } IL_145 :; } if (num2 != -1) { flag = true; raycastHit = array[num2]; } this.aimAssist.aimAssistHurtbox = null; if (flag) { this.crosshairWorldPosition = raycastHit.point; float num3 = 1000f; if (raycastHit.distance < num3) { HurtBox component2 = raycastHit.collider.GetComponent <HurtBox>(); if (component2) { HealthComponent healthComponent = component2.healthComponent; if (healthComponent) { TeamComponent component3 = healthComponent.GetComponent <TeamComponent>(); if (component3 && component3.teamIndex != this.targetTeamIndex && component3.teamIndex != TeamIndex.None) { CharacterBody body = healthComponent.body; HurtBox hurtBox2 = (body != null) ? body.mainHurtBox : null; if (hurtBox2) { this.aimAssist.aimAssistHurtbox = hurtBox2; this.aimAssist.worldPosition = raycastHit.point; this.aimAssist.localPositionOnHurtbox = hurtBox2.transform.InverseTransformPoint(raycastHit.point); return; } } } } } } else { this.crosshairWorldPosition = crosshairRaycastRay.GetPoint(this.maxAimRaycastDistance); } }
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 AddDotModBurnDamageFix(GameObject attackerObject, float duration, DotIndex dotIndex, float damageMultiplier, float damageThatProccedIt) { if (!NetworkServer.active) { Debug.LogWarning("[Server] function 'System.Void RoR2.DotController::AddDot(UnityEngine.GameObject,System.Single,RoR2.DotController/DotIndex,System.Single)' called on client"); return; } if (dotIndex < DotIndex.Bleed || dotIndex >= DotIndex.Count) { return; } TeamIndex teamIndex = TeamIndex.Neutral; float single = 0f; TeamComponent component = attackerObject.GetComponent <TeamComponent>(); if (component) { teamIndex = component.teamIndex; } CharacterBody characterBody = attackerObject.GetComponent <CharacterBody>(); if (characterBody) { single = characterBody.damage; } DotDef dotDef = dotDefs[(int)dotIndex]; DotStack dotStack = new DotStack { dotIndex = dotIndex, dotDef = dotDef, attackerObject = attackerObject, attackerTeam = teamIndex, timer = duration, damageType = DamageType.Generic }; if (teamIndex != TeamIndex.Monster || damageThatProccedIt == 0f) { dotStack.damage = dotDef.damageCoefficient * single * damageMultiplier; } else { dotStack.damage = dotDef.damageCoefficient * damageThatProccedIt * damageMultiplier * 0.6f; } if (dotIndex == DotIndex.Helfire) { if (!characterBody) { return; } HealthComponent healthComponent = characterBody.healthComponent; if (!healthComponent) { return; } dotStack.damage = healthComponent.fullHealth * 0.01f * damageMultiplier; if (victimObject == attackerObject) { DotStack dotStack1 = dotStack; dotStack1.damageType = dotStack1.damageType | DamageType.NonLethal | DamageType.Silent; } else if (victimTeam != teamIndex) { dotStack.damage *= 24f; } else { dotStack.damage *= 0.5f; } int num = 0; int count = dotStackList.Count; while (num < count) { if (dotStackList[num].dotIndex == DotIndex.Helfire && dotStackList[num].attackerObject == attackerObject) { dotStackList[num].timer = Mathf.Max(dotStackList[num].timer, duration); dotStackList[num].damage = dotStack.damage; return; } num++; } if (victimBody) { EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/HelfireIgniteEffect"), new EffectData { origin = victimBody.corePosition }, true); } } dotStackList.Add(dotStack); }
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); }
private static void Init() { CostTypeCatalog.costTypeDefs = new CostTypeDef[11]; CostTypeIndex costType = CostTypeIndex.None; CostTypeDef costTypeDef7 = new CostTypeDef(); costTypeDef7.buildCostString = delegate(CostTypeDef costTypeDef, CostTypeDef.BuildCostStringContext context) { context.stringBuilder.Append(""); }; costTypeDef7.isAffordable = ((CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context) => true); costTypeDef7.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context) { }; CostTypeCatalog.Register(costType, costTypeDef7); CostTypeIndex costType2 = CostTypeIndex.Money; CostTypeDef costTypeDef2 = new CostTypeDef(); costTypeDef2.costStringFormatToken = "COST_MONEY_FORMAT"; costTypeDef2.isAffordable = delegate(CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context) { CharacterBody component = context.activator.GetComponent <CharacterBody>(); if (component) { CharacterMaster master = component.master; if (master) { return((ulong)master.money >= (ulong)((long)context.cost)); } } return(false); }; costTypeDef2.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context) { if (context.activatorMaster) { context.activatorMaster.money -= (uint)context.cost; } }; costTypeDef2.colorIndex = ColorCatalog.ColorIndex.Money; CostTypeCatalog.Register(costType2, costTypeDef2); CostTypeIndex costType3 = CostTypeIndex.PercentHealth; CostTypeDef costTypeDef3 = new CostTypeDef(); costTypeDef3.costStringFormatToken = "COST_PERCENTHEALTH_FORMAT"; costTypeDef3.saturateWorldStyledCostString = false; costTypeDef3.darkenWorldStyledCostString = true; costTypeDef3.isAffordable = delegate(CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context) { HealthComponent component = context.activator.GetComponent <HealthComponent>(); return(component && component.combinedHealth / component.fullCombinedHealth * 100f >= (float)context.cost); }; costTypeDef3.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context) { HealthComponent component = context.activator.GetComponent <HealthComponent>(); if (component) { float combinedHealth = component.combinedHealth; float num = component.fullCombinedHealth * (float)context.cost / 100f; if (combinedHealth > num) { component.TakeDamage(new DamageInfo { damage = num, attacker = context.purchasedObject, position = context.purchasedObject.transform.position, damageType = (DamageType.NonLethal | DamageType.BypassArmor) }); } } }; costTypeDef3.colorIndex = ColorCatalog.ColorIndex.Blood; CostTypeCatalog.Register(costType3, costTypeDef3); CostTypeIndex costType4 = CostTypeIndex.LunarCoin; CostTypeDef costTypeDef4 = new CostTypeDef(); costTypeDef4.costStringFormatToken = "COST_LUNARCOIN_FORMAT"; costTypeDef4.saturateWorldStyledCostString = false; costTypeDef4.darkenWorldStyledCostString = true; costTypeDef4.isAffordable = delegate(CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context) { NetworkUser networkUser = Util.LookUpBodyNetworkUser(context.activator.gameObject); return(networkUser && (ulong)networkUser.lunarCoins >= (ulong)((long)context.cost)); }; costTypeDef4.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context) { NetworkUser networkUser = Util.LookUpBodyNetworkUser(context.activator.gameObject); if (networkUser) { networkUser.DeductLunarCoins((uint)context.cost); } }; costTypeDef4.colorIndex = ColorCatalog.ColorIndex.LunarCoin; CostTypeCatalog.Register(costType4, costTypeDef4); CostTypeCatalog.Register(CostTypeIndex.WhiteItem, new CostTypeDef { costStringFormatToken = "COST_ITEM_FORMAT", isAffordable = new CostTypeDef.IsAffordableDelegate(CostTypeCatalog.< > c.< > 9. < Init > g__IsAffordableItem | 5_0), payCost = new CostTypeDef.PayCostDelegate(CostTypeCatalog.< > c.< > 9. < Init > g__PayCostItems | 5_1), colorIndex = ColorCatalog.ColorIndex.Tier1Item, itemTier = ItemTier.Tier1 });
// 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 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 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); }
// Token: 0x0600138F RID: 5007 RVA: 0x0005F7EC File Offset: 0x0005D9EC public void OnInteractionBegin(Interactor activator) { if (!this.CanBeAffordedByInteractor(activator)) { return; } CharacterBody component = activator.GetComponent <CharacterBody>(); switch (this.costType) { case CostType.Money: if (component) { CharacterMaster master = component.master; if (master) { master.money -= (uint)this.cost; } } break; case CostType.PercentHealth: { HealthComponent component2 = activator.GetComponent <HealthComponent>(); if (component2) { float health = component2.health; float num = component2.fullHealth * (float)this.cost / 100f; if (health > num) { component2.TakeDamage(new DamageInfo { damage = num, attacker = base.gameObject, position = base.transform.position, damageType = DamageType.BypassArmor }); } } break; } case CostType.Lunar: { NetworkUser networkUser = Util.LookUpBodyNetworkUser(activator.gameObject); if (networkUser) { networkUser.DeductLunarCoins((uint)this.cost); } break; } case CostType.WhiteItem: case CostType.GreenItem: case CostType.RedItem: { ItemTier itemTier = PurchaseInteraction.CostTypeToItemTier(this.costType); if (component) { Inventory inventory = component.inventory; if (inventory) { ItemIndex itemIndex = ItemIndex.None; ShopTerminalBehavior component3 = base.GetComponent <ShopTerminalBehavior>(); if (component3) { itemIndex = component3.CurrentPickupIndex().itemIndex; } WeightedSelection <ItemIndex> weightedSelection = new WeightedSelection <ItemIndex>(8); foreach (ItemIndex itemIndex2 in ItemCatalog.allItems) { if (itemIndex2 != itemIndex) { int itemCount = inventory.GetItemCount(itemIndex2); if (itemCount > 0 && ItemCatalog.GetItemDef(itemIndex2).tier == itemTier) { weightedSelection.AddChoice(itemIndex2, (float)itemCount); } } } List <ItemIndex> list = new List <ItemIndex>(); int num2 = 0; while (weightedSelection.Count > 0 && num2 < this.cost) { int num3 = weightedSelection.EvaluteToChoiceIndex(this.rng.nextNormalizedFloat); WeightedSelection <ItemIndex> .ChoiceInfo choice = weightedSelection.GetChoice(num3); ItemIndex value = choice.value; int num4 = (int)choice.weight; num4--; if (num4 <= 0) { weightedSelection.RemoveChoice(num3); } else { weightedSelection.ModifyChoiceWeight(num3, (float)num4); } list.Add(value); num2++; } for (int i = num2; i < this.cost; i++) { list.Add(itemIndex); } for (int j = 0; j < list.Count; j++) { ItemIndex itemIndex3 = list[j]; PurchaseInteraction.CreateItemTakenOrb(component.corePosition, base.gameObject, itemIndex3); inventory.RemoveItem(itemIndex3, 1); if (itemIndex3 != itemIndex) { Action <PurchaseInteraction, Interactor> action = PurchaseInteraction.onItemSpentOnPurchase; if (action != null) { action(this, activator); } } } } } break; } } IEnumerable <StatDef> statDefsToIncrement = this.purchaseStatNames.Select(new Func <string, StatDef>(StatDef.Find)); StatManager.OnPurchase <IEnumerable <StatDef> >(component, this.costType, statDefsToIncrement); this.onPurchase.Invoke(activator); this.lastActivator = activator; }