////// Private Methods ////// void InflictFreezeOrStun(int count, SetStateOnHurt ssoh, DamageReport report, bool isStun) { if (!report.victim.isInFrozenState) { if (isStun) { if (ssoh.canBeStunned) { ssoh.SetStun(1f); } } else { if (ssoh.canBeFrozen) { ssoh.SetFrozen(2f * report.damageInfo.procCoefficient); } } } report.victim.TakeDamage(new DamageInfo { attacker = report.attacker, crit = report.damageInfo.crit, damage = ((float)(count - 1) * procStackDamage + procBaseDamage) * report.attackerBody.damage, damageColorIndex = DamageColorIndex.Item, damageType = DamageType.Generic, force = Vector3.zero, inflictor = report.damageInfo.inflictor, position = report.damageInfo.position, procChainMask = report.damageInfo.procChainMask, procCoefficient = 0f }); }
private void On_SSOHOnTakeDamageServer(On.RoR2.SetStateOnHurt.orig_OnTakeDamageServer orig, SetStateOnHurt self, DamageReport damageReport) { orig(self, damageReport); int icnt = GetCount(damageReport.attackerMaster); if (icnt < 1) { return; } var ch = Util.ConvertAmplificationPercentageIntoReductionPercentage(procChance * icnt * damageReport.damageInfo.procCoefficient); if (!Util.CheckRoll(ch)) { return; } if (self.canBeFrozen) { self.SetFrozen(freezeTime); damageReport.victim?.body.AddTimedBuff(ClassicItemsPlugin.freezeBuff, freezeTime); } if ((self.canBeFrozen || slowUnfreezable) && damageReport.victim) { damageReport.victim.body.AddTimedBuff(BuffIndex.Slow60, slowTime); } }
public void Update() { // The charge fraction is synced over network only every few frames, so the animation becomes laggy // Predict the teleporter charge locally to make it smooth predictionChargeFractionDeltaTime += Time.deltaTime; float num = holdoutZoneController.charge - predictionChargeFractionLast; if (num != 0f) { chargeFraction = holdoutZoneController.charge; predictionChargeSpeed = num / predictionChargeFractionDeltaTime; predictionChargeFractionDeltaTime = 0f; } predictionChargeFractionLast = holdoutZoneController.charge; chargeFraction = Mathf.Clamp01(chargeFraction + predictionChargeSpeed * Time.deltaTime); int itemCount = Util.GetItemCountForTeam(TeamIndex.Player, MysticsItemsContent.Items.MysticsItems_CrystalWorld.itemIndex, true); if (itemCount > 0) { float nextPulse = NextPulse(pulses + pulsesPerStack * (itemCount - 1)); if (!holdoutZoneController.enabled) { nextPulse = 100f; } if (nextPulse >= 1f) { nextPulse = 100f; } float t = (1f - (nextPulse - chargeFraction) / windup) * 0.5f; if (chargeFraction <= (prevPulse + winddown)) { t = ((chargeFraction - prevPulse) / winddown) * 0.5f + 0.5f; } t = Mathf.Clamp01(t); currentSpin = finalSpin * animationCurve.Evaluate(t); currentHeight = finalHeight * animationCurve.Evaluate(t); if (model) { if (!model.activeSelf) { model.SetActive(true); } model.transform.Rotate(new Vector3(0f, currentSpin * Time.deltaTime, 0f), Space.Self); model.transform.localPosition = offset + Vector3.up * currentHeight; } if (holdoutZoneController.charge > nextPulse) { prevPulse = nextPulse; if (NetworkServer.active) { EffectManager.SpawnEffect(pulsePrefab, new EffectData { origin = transform.position, scale = holdoutZoneController.currentRadius * 2f }, true); sphereSearch.radius = holdoutZoneController.currentRadius; foreach (HurtBox hurtBox in sphereSearch.RefreshCandidates().FilterCandidatesByHurtBoxTeam(teamMask).FilterCandidatesByDistinctHurtBoxEntities().GetHurtBoxes()) { HealthComponent healthComponent = hurtBox.healthComponent; if (healthComponent) { CharacterBody body = healthComponent.body; if (body) { SetStateOnHurt setStateOnHurt = body.gameObject.GetComponent <SetStateOnHurt>(); if (setStateOnHurt && setStateOnHurt.canBeFrozen) { setStateOnHurt.SetFrozen(freezeTime); // Deal a bit of damage to force execute DamageInfo damageInfo = new DamageInfo { attacker = null, damage = 12f * 2.4f * TeamManager.instance.GetTeamLevel(TeamIndex.Player), procCoefficient = 0f, position = hurtBox.transform.position, crit = false }; healthComponent.TakeDamage(damageInfo); } else { body.AddTimedBuff(MysticsItemsContent.Buffs.MysticsItems_Crystallized, freezeTime); } } } } } } } else { if (model && model.activeSelf) { model.SetActive(false); } } }