private void HealthComponent_UpdateLastHitTime(On.RoR2.HealthComponent.orig_UpdateLastHitTime orig, HealthComponent self, float damageValue, Vector3 damagePosition, bool damageIsSilent, GameObject attacker) { bool hasBody = self && self.body; if (hasBody) { healingSourceStack.Push(self.body); } orig(self, damageValue, damagePosition, damageIsSilent, attacker); if (hasBody) { healingSourceStack.Pop(); } }
////// Hooks ////// private void HealthComponent_UpdateLastHitTime(On.RoR2.HealthComponent.orig_UpdateLastHitTime orig, HealthComponent self, float damageValue, Vector3 damagePosition, bool damageIsSilent, GameObject attacker) { orig(self, damageValue, damagePosition, damageIsSilent, attacker); if (NetworkServer.active && self.body && damageValue > 0f) { var cpt = self.GetComponent <KleinBottleTimeTracker>(); if (!cpt) { cpt = self.gameObject.AddComponent <KleinBottleTimeTracker>(); } if (Time.fixedTime - cpt.LastTimestamp < PROC_ICD) { return; } else { cpt.LastTimestamp = Time.fixedTime; } var count = GetCount(self.body); var pChance = (1f - Mathf.Pow(1 - procChance / 100f, count)) * 100f; var proc = Util.CheckRoll(pChance, self.body.master); if (proc) { RoR2.Projectile.ProjectileManager.instance.FireProjectile( blackHolePrefab, self.body.corePosition, Quaternion.identity, self.body.gameObject, 0f, 0f, false); var teamMembers = new List <TeamComponent>(); bool isFF = FriendlyFireManager.friendlyFireMode != FriendlyFireManager.FriendlyFireMode.Off; var scan = ((TeamIndex[])Enum.GetValues(typeof(TeamIndex))); var myTeam = TeamComponent.GetObjectTeam(self.body.gameObject); foreach (var ind in scan) { if (isFF || myTeam != ind) { teamMembers.AddRange(TeamComponent.GetTeamMembers(ind)); } } teamMembers.Remove(self.body.teamComponent); float sqrad = PULL_RADIUS * PULL_RADIUS; var isCrit = self.body.RollCrit(); foreach (TeamComponent tcpt in teamMembers) { var velVec = tcpt.transform.position - self.transform.position; if (velVec.sqrMagnitude <= sqrad) { bool shouldPull = meleeSurvivorBodyNames.Contains(self.body.name); if (self.body.name == "ToolbotBody(Clone)") { shouldPull &= self.body.skillLocator.primary.skillDef.skillName == "FireBuzzsaw"; } if (invertBodyNames) { shouldPull = !shouldPull; } if (shouldPull) { var(vInitial, _) = CalculateVelocityForFinalPosition(tcpt.transform.position, self.transform.position, 0f); velVec = vInitial; } else { float theta; if (velVec.x == 0 && velVec.z == 0) { theta = UnityEngine.Random.value * Mathf.PI * 2f; } else { theta = Mathf.Atan2(velVec.z, velVec.x); } float mag = velVec.magnitude; if (mag == 0) { mag = velVec.y; } var pitch = Mathf.Asin(velVec.y / mag); pitch = Remap(pitch, -1, 1, 0.325f, 0.675f); velVec = new Vector3(Mathf.Cos(theta) * Mathf.Cos(pitch), Mathf.Sin(pitch), Mathf.Sin(theta) * Mathf.Cos(pitch)); } if (tcpt.body && tcpt.body.isActiveAndEnabled) { if (tcpt.body.healthComponent) { tcpt.body.healthComponent.TakeDamage(new DamageInfo { attacker = self.gameObject, canRejectForce = true, crit = isCrit, damage = self.body.damage * damageFrac, damageColorIndex = DamageColorIndex.Item, damageType = DamageType.AOE, force = Vector3.zero, inflictor = null, position = tcpt.body.corePosition, procChainMask = default,