internal void DamageBySpell(SpellDamageInfo damageInfo) { unit.Spells.CalculateSpellDamageTaken(ref damageInfo); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.ServerDamageDone, damageInfo); unit.DealDamage(damageInfo.Target, (int)damageInfo.Damage, damageInfo.SpellDamageType); }
public void OnSpellDamageDone(SpellDamageInfo damageInfo) { if (!critCheckedSpells.Contains(damageInfo.SpellInfo) || damageInfo.SpellDamageType != SpellDamageType.Direct) return; bool isCrit = damageInfo.HitType.HasTargetFlag(HitType.CriticalHit); if (isCrit) { if (damageInfo.Caster.Auras.HasAuraWithSpell(heatingUpSpell.Id)) { damageInfo.Caster.Auras.RemoveAuraWithSpellInfo(heatingUpSpell, AuraRemoveMode.Spell); damageInfo.Caster.Spells.TriggerSpell(hotStreakSpell, damageInfo.Caster); } else damageInfo.Caster.Spells.TriggerSpell(heatingUpSpell, damageInfo.Caster); } else damageInfo.Caster.Auras.RemoveAuraWithSpellInfo(heatingUpSpell, AuraRemoveMode.Spell); }
internal void HandleAbsorb(ref SpellDamageInfo damageInfo) { if (damageInfo.Target.IsDead || damageInfo.Damage == 0) { return; } Unit target = damageInfo.Target; IReadOnlyList <AuraEffect> absorbEffects = target.GetAuraEffects(AuraEffectType.AbsorbDamage); if (absorbEffects == null) { return; } var absorbEffectCopies = new List <AuraEffect>(absorbEffects); for (int index = 0; index < absorbEffectCopies.Count; index++) { AuraEffect absorbEffect = absorbEffectCopies[index]; if (!absorbEffect.Aura.ApplicationsByTargetId.ContainsKey(target.Id)) { continue; } if (absorbEffect.Value <= 0.0f) { continue; } uint availableAbsorb = (uint)Mathf.CeilToInt(absorbEffect.Value); uint effectiveAbsorb = System.Math.Min(availableAbsorb, damageInfo.Damage); damageInfo.AbsorbDamage(effectiveAbsorb); absorbEffect.ModifyValue(-effectiveAbsorb); if (absorbEffect.Value <= 0.0f) { absorbEffect.Aura.Remove(AuraRemoveMode.Spell); } } }
internal void DamageBySpell(SpellDamageInfo damageInfo, Spell spell = null) { unit.Spells.CalculateSpellDamageTaken(ref damageInfo, spell); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.ServerDamageDone, damageInfo); for (int i = unit.Auras.AuraApplications.Count - 1; i >= 0; i--) { AuraApplication application = unit.Auras.AuraApplications[i]; for (int j = 0; j < application.Aura.AuraInfo.AuraScriptables.Count; j++) { AuraScriptable auraScriptable = application.Aura.AuraInfo.AuraScriptables[j]; if (auraScriptable is IAuraScriptSpellDamageHandler spellDamageHandler) { spellDamageHandler.OnSpellDamageDone(damageInfo); } } } unit.DealDamage(damageInfo.Target, (int)damageInfo.Damage, damageInfo.SpellDamageType); }
internal void CalculateSpellDamageTaken(ref SpellDamageInfo damageInfo) { if (damageInfo.Damage == 0 || !damageInfo.Target.IsAlive) { return; } Unit caster = damageInfo.Caster; Unit target = damageInfo.Target; SpellInfo spellInfo = damageInfo.SpellInfo; damageInfo.UpdateDamage(caster.Spells.SpellDamageBonusDone(target, spellInfo, damageInfo.Damage, damageInfo.SpellDamageType)); damageInfo.UpdateDamage(target.Spells.SpellDamageBonusTaken(caster, spellInfo, damageInfo.Damage, damageInfo.SpellDamageType)); if (!spellInfo.HasAttribute(SpellExtraAttributes.FixedDamage) && damageInfo.HasCrit) { uint criticalDamage = CalculateSpellCriticalDamage(spellInfo, damageInfo.Damage); damageInfo.UpdateOriginalDamage(criticalDamage); } HandleAbsorb(ref damageInfo); }