public override void OnAttack(DamageAction action) { if (action.Spell == null || action.SpellEffect.AuraType == AuraType.ExplosiveArrow) { return; } foreach (WorldObject objectsInRadiu in (IEnumerable <WorldObject>)action.Victim.GetObjectsInRadius <Unit>(6f, ObjectTypes.Unit, false, int.MaxValue)) { if (objectsInRadiu.IsHostileWith((IFactionMember)action.Attacker)) { Unit unit = objectsInRadiu as Unit; if (unit != null) { DamageAction damageAction = unit.DealSpellDamage(action.Attacker, this.SpellEffect, (int)((double)action.Attacker.RandomDamage * (double)this.SpellEffect.MiscValue / 100.0), true, true, false, false); if (damageAction != null) { Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse( this.m_aura.CasterUnit as Character, this.Owner as Character, unit as NPC, damageAction.ActualDamage); action.OnFinished(); } } } } }
/// <summary> /// Any spell and ranged damage /// SMSG_SPELLNONMELEEDAMAGELOG /// </summary> /* * Target: High: 0xF530 (Unit) - Low: 619710 - Entry: UmbralBrute (30922) * Caster: High: 0x0000 (Player) - Low: 2211871 * Spell: ClassSkillArcaneShot_11 (49045) * Damage: 776 * Overkill: 0 * SchoolMask: Arcane (64) * Absorbed: 0 * Resisted: 0 * UnkByte1: 0 * UnkByte2 (Unused): 0 * Blocked: 0 * HitFlags: 37 * UnkByte3 (Unused): 0 */ public static void SendMagicDamage(DamageAction state) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLNONMELEEDAMAGELOG, 40)) { state.Victim.EntityId.WritePacked(packet); if (state.Attacker != null) { state.Attacker.EntityId.WritePacked(packet); } else { packet.Write((byte)0); } packet.Write(state.SpellEffect != null ? state.SpellEffect.Spell.Id : 0); packet.Write(state.Damage); packet.Write(0); // overkill? packet.Write((byte)state.Schools); packet.Write(state.Absorbed); packet.Write(state.Resisted); //packet.Write(0); // is always 0 packet.Write(state.Schools.HasAnyFlag(DamageSchoolMask.Physical)); packet.Write((byte)0); // 0 or 1 packet.Write(state.Blocked); // also flags 0x8, 0x10, var hitFlags = state.IsCritical ? SpellLogFlags.Critical : SpellLogFlags.None; packet.Write((int)hitFlags); packet.Write((byte)0); // unused by client state.Victim.SendPacketToArea(packet, true, false); } }
/// <summary> /// Rage for the attacker of an AttackAction /// </summary> public static void GenerateDefaultAttackerRage(DamageAction action) { var attacker = action.Attacker; // only generate Rage for white damage if (action.IsWeaponAttack) { double hitFactor; hitFactor = 3.5; if (action.IsCritical) { hitFactor *= 2; } hitFactor *= action.Weapon.AttackTime; var lvl = attacker.Level; var c = 0.0092f * lvl * lvl + 3.23f * lvl + 4.27f; var rageRight = ((15 * action.ActualDamage / (4f * c)) + (hitFactor / 2000)); var rageLeft = 15 * action.ActualDamage / c; var rage = rageRight; if (rageRight <= rageLeft) { rage = rageLeft; } // Multiplied by 2 to match an approximate value, check the formula instead. attacker.Power += (int)(rage) * 10; } }
/// <summary> /// Any spell and ranged damage /// SMSG_SPELLNONMELEEDAMAGELOG /// </summary> public static void SendMagicDamage(DamageAction state) { using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_SPELLNONMELEEDAMAGELOG, 40)) { state.Victim.EntityId.WritePacked((BinaryWriter)packet); if (state.Attacker != null) { state.Attacker.EntityId.WritePacked((BinaryWriter)packet); } else { packet.Write((byte)0); } packet.Write(state.SpellEffect != null ? state.SpellEffect.Spell.Id : 0U); packet.Write(state.Damage); packet.Write(0); packet.Write((byte)state.Schools); packet.Write(state.Absorbed); packet.Write(state.Resisted); packet.Write(state.Schools.HasAnyFlag(DamageSchoolMask.Physical)); packet.Write((byte)0); packet.Write(state.Blocked); SpellLogFlags spellLogFlags = state.IsCritical ? SpellLogFlags.Critical : SpellLogFlags.None; packet.Write((int)spellLogFlags); packet.Write((byte)0); state.Victim.SendPacketToArea(packet, true, false, Locale.Any, new float?()); } }
/// <summary>Rage for the attacker of an AttackAction</summary> public static void GenerateDefaultAttackerRage(DamageAction action) { Unit attacker = action.Attacker; if (!action.IsWeaponAttack) { return; } double num1 = 3.5; if (action.IsCritical) { num1 *= 2.0; } double num2 = num1 * (double)action.Weapon.AttackTime; int level = attacker.Level; float num3 = (float)(0.00920000020414591 * (double)level * (double)level + 3.23000001907349 * (double)level + 4.26999998092651); double num4 = (double)(15 * action.ActualDamage) / (4.0 * (double)num3) + num2 / 2000.0; float num5 = (float)(15 * action.ActualDamage) / num3; double num6 = num4; if (num4 <= (double)num5) { num6 = (double)num5; } attacker.Power += (int)num6 * 10; }
public override void OnAttack(DamageAction action) { if (action.Spell != null) { return; } if ((double)this.Owner.SplinterEffect > 0.0) { foreach (WorldObject objectsInRadiu in (IEnumerable <WorldObject>) this.Owner.GetObjectsInRadius <Unit>( 2.5f, ObjectTypes.Attackable, false, int.MaxValue)) { if (this.Owner.IsHostileWith((IFactionMember)objectsInRadiu) && !object.ReferenceEquals((object)objectsInRadiu, (object)this.Owner) && Utility.Random(0, 100000) <= this.Owner.SplinterEffectChange) { Character targetChr = objectsInRadiu as Character; NPC targetNpc = objectsInRadiu as NPC; DamageAction unusedAction = this.Owner.GetUnusedAction(); unusedAction.Damage = (int)((double)this.Owner.RandomDamage * (double)this.Owner.SplinterEffect); unusedAction.Attacker = objectsInRadiu as Unit; unusedAction.Victim = objectsInRadiu as Unit; int num = (int)unusedAction.DoAttack(); if (this.Owner is Character) { Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse((Character)null, targetChr, targetNpc, unusedAction.ActualDamage); } action.OnFinished(); } } } base.OnAttack(action); }
public override void OnDefend(DamageAction action) { action.Victim.AddMessage((Action)(() => { if (!action.Victim.MayAttack((IFactionMember)action.Attacker)) { return; } action.Attacker.DealSpellDamage(action.Victim, this.SpellEffect, action.Damage * (this.SpellEffect.MiscValue / 100), true, true, false, true); Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(this.m_aura.CasterUnit as Character, this.Owner as Character, this.Owner as NPC, action.ActualDamage); })); if (this.SpellEffect.MiscValueB == 0) { action.Resisted = action.Damage; } else { if (this.SpellEffect.MiscValueB != 20) { return; } Character casterUnit = this.m_aura.CasterUnit as Character; if (casterUnit == null || !casterUnit.IsInGroup) { return; } foreach (GroupMember groupMember in casterUnit.Group) { groupMember.Character.Heal(action.Damage * this.SpellEffect.MiscValue / 100, (Unit)null, (SpellEffect)null); } } }
protected override void Remove(bool cancelled) { Unit casterUnit = m_aura.CasterUnit; if (casterUnit == null) { return; } foreach (WorldObject objectsInRadiu in Owner.GetObjectsInRadius(6f, ObjectTypes.Unit, false, int.MaxValue)) { if (casterUnit.IsHostileWith(objectsInRadiu)) { Unit unit = objectsInRadiu as Unit; if (unit != null) { DamageAction damageAction = unit.DealSpellDamage(casterUnit, SpellEffect, (int)(casterUnit.RandomDamage * (double)SpellEffect.MiscValue / 100.0), true, true, false, false); if (damageAction != null) { Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse( m_aura.CasterUnit as Character, Owner as Character, unit as NPC, damageAction.ActualDamage); damageAction.OnFinished(); } } } } }
/// <inheritdoc/> public IEnumerable <DamageCalculation> Calculate(Character user, DamageAction damage, IEnumerable <Character> targets) { var count = _actionHistory.GetMoveActionConsecutiveSuccessCount(damage, user); var basePower = _startingBasePower + _linearFactor * count; return(new BasePowerDamageCalculator(basePower, _random).Calculate(user, damage, targets)); }
public override void OnDefend(DamageAction action) { if (m_spellEffect.Spell.SchoolMask.HasAnyFlag(action.UsedSchool)) { action.ModDamagePercent(EffectValue); } }
public override void OnDefend(DamageAction action) { if (!action.IsCritical) { return; } var max = action.Victim.MaxHealth / 2; // reflect % damage var effect = m_spellEffect; action.Victim.AddMessage(() => { if (action.Victim.MayAttack(action.Attacker)) { var dmg = (EffectValue * action.Damage + 50) / 100; if (dmg > max) { dmg = max; } action.Attacker.DealSpellDamage(action.Victim, effect, dmg); } }); }
IEnumerator DamageAction(DamageAction action) { foreach (IDestructable target in action.targets) { var damage = 0; var resistance = target as IResistant; switch (action.type) { case DamageType.Physical: //Physical damage is reduced by armor var block = resistance != null ? resistance.Armor : 0; damage = Math.Max(action.amount - block, 0); break; case DamageType.Magical: //Magical damage is reduced by magic resist var resist = resistance != null ? resistance.MagicResist : 0; damage = Math.Max(action.amount - resist, 0); break; case DamageType.Poison: //Poison can only bring target down to 1 health var hitPoints = Math.Max(target.HitPoints - action.amount, 1); damage = target.HitPoints - hitPoints; break; case DamageType.True: //True damage cannot be reduced damage = action.amount; break; } target.HitPoints -= damage; action.amount = damage; yield return(null); } }
public override void OnHit(DamageAction action) { var chr = action.Attacker as Character; if (chr != null) { if (chr.Group != null) { List <Character> origGroup = new List <Character>(chr.Group.GetAllCharacters()); List <Character> scrambledGroup = new List <Character>(); Random randNum = new Random(); int i = -1; foreach (Character groupMember in origGroup) { i++; if (groupMember == chr) { continue; } if (randNum.NextDouble() < (3 - scrambledGroup.Count / origGroup.Count - i)) { scrambledGroup.Add(groupMember); } } var effect = SpellHandler.Get(SpellId.DivineStorm_2).GetEffect(SpellEffectType.Heal); foreach (Character target in scrambledGroup) { target.Heal(action.GetDamagePercent(25), chr, effect); } } } base.OnHit(action); }
public override void OnHit(DamageAction action) { // "Effects which increase Bleed damage also increase Maul damage." var bleedBonusPct = action.Attacker.Auras.GetBleedBonusPercent(); action.ModDamagePercent(bleedBonusPct); }
public override void OnDefend(DamageAction action) { var defender = Owner; // same as action.Victim var power = defender.Power; var damage = action.Damage; var drainAmount = Math.Min(damage, (int)(power * factorInverse)); // figure out how much to drain if (remaining < drainAmount) { // shield is used up drainAmount = remaining; remaining = 0; m_aura.Remove(false); } else { remaining -= drainAmount; } drainAmount = (int)(drainAmount * factor); var caster = Aura.CasterUnit; if (caster != null) { // see MageArcaneArcaneShielding drainAmount = caster.Auras.GetModifiedInt(SpellModifierType.HealingOrPowerGain, m_spellEffect.Spell, drainAmount); } defender.Power = power - drainAmount; // drain power damage -= drainAmount; // reduce damage action.Damage = damage; }
public override void OnHit(DamageAction action) { var doubleBonus = CalcEffectValue() * action.Victim.Auras.GetVisibleAuraCount(action.Attacker.SharedReference, DispelType.Disease); action.Damage += (action.Damage * doubleBonus + 100) / 200; // + <1/2 of effect value> percent per disease // consume diseases if the Annihilation talent does not save them var annihilation = action.Attacker.Auras[SpellLineId.DeathKnightFrostAnnihilation]; if (annihilation != null) { var dummy = annihilation.GetHandler(AuraType.Dummy); if (dummy != null) { if (Utility.Random(0, 101) < dummy.EffectValue) { // diseases remain return; } } } // consume diseases action.Victim.Auras.RemoveWhere(aura => aura.Spell.DispelType == DispelType.Disease); }
/// <inheritdoc/> public IEnumerable <DamageCalculation> Calculate(Character user, DamageAction damage, IEnumerable <Character> targets) { var result = _actionHistory.LastMoveDamageResultAgainst(user); var calculations = new List <DamageCalculation>(); foreach (var target in targets) { if (result is null) { calculations.Add(new DamageCalculation { Target = target, Success = false, Amount = 0, }); } else { calculations.Add(new DamageCalculation { Target = target, Success = true, Amount = Math.Max(1, result.Amount * _percentage / 100), }); } } return(calculations); }
protected override void Apply() { IList <WorldObject> objectsInRadius = this.Owner.GetObjectsInRadius <Unit>(6f, ObjectTypes.Unit, false, int.MaxValue); if (objectsInRadius == null) { return; } foreach (WorldObject worldObject in (IEnumerable <WorldObject>)objectsInRadius) { Unit unit = worldObject as Unit; if (unit != null && this.Owner != null && (this.m_aura != null && unit.IsHostileWith((IFactionMember)this.Owner))) { DamageAction damageAction = unit.DealSpellDamage(this.Owner, this.SpellEffect, (int)((double)this.Owner.RandomDamage * (double)this.SpellEffect.MiscValue / 100.0), true, true, false, false); if (damageAction != null) { Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(this.m_aura.CasterUnit as Character, unit as Character, unit as NPC, damageAction.ActualDamage); damageAction.OnFinished(); } } } }
public override void OnAttack(DamageAction action) { if (action.Spell == null || action.SpellEffect.AuraType == AuraType.ExplosiveArrow) { return; } var targets = action.Victim.GetObjectsInRadius(6, ObjectTypes.Unit, false); foreach (var worldObject in targets) { if (!worldObject.IsHostileWith(action.Attacker)) { continue; } var unit = worldObject as Unit; if (unit == null) { continue; } var a = unit.DealSpellDamage(action.Attacker, SpellEffect, (int)(action.Attacker.RandomDamage * SpellEffect.MiscValue / 190), true, true, false, false); if (a == null) { continue; } WCell.RealmServer.Handlers.Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(m_aura.CasterUnit as Character, Owner as Character, unit as NPC, a.ActualDamage); action.OnFinished(); } }
public override void OnDefend(DamageAction action) { Unit owner = Owner; int power = owner.Power; int damage = action.Damage; int num1 = Math.Min(damage, (int)(power * (double)factorInverse)); if (remaining < num1) { num1 = remaining; remaining = 0; m_aura.Remove(false); } else { remaining -= num1; } int num2 = (int)(num1 * (double)factor); Unit casterUnit = Aura.CasterUnit; if (casterUnit != null) { num2 = casterUnit.Auras.GetModifiedInt(SpellModifierType.HealingOrPowerGain, m_spellEffect.Spell, num2); } owner.Power = power - num2; int num3 = damage - num2; action.Damage = num3; }
protected override void Apply() { Unit owner = Owner; if (!owner.IsAlive) { return; } float num = (float)(SpellEffect.MiscValue * (m_aura.CasterUnit != null ? (m_aura.CasterUnit.Class == ClassId.AtackMage || m_aura.CasterUnit.Class == ClassId.SupportMage || m_aura.CasterUnit.Class == ClassId.HealMage ? m_aura.CasterUnit.RandomMagicDamage : m_aura.CasterUnit.RandomDamage) : 666.0) / 100.0 * 3.0); if (m_aura.Spell.Mechanic == SpellMechanic.Bleeding) { int bleedBonusPercent = m_aura.Auras.GetBleedBonusPercent(); num += (float)((num * (double)bleedBonusPercent + 50.0) / 100.0); m_aura.Owner.IncMechanicCount(SpellMechanic.Bleeding, false); } DamageAction damageAction = owner.DealSpellDamage(m_aura.CasterUnit, m_spellEffect, (int)num, true, true, false, false); if (damageAction == null) { return; } Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(m_aura.CasterUnit as Character, Owner as Character, Owner as NPC, damageAction.ActualDamage); damageAction.OnFinished(); }
public override void OnAttack(DamageAction action) { //if (!action.IsDot) { var amount = action.GetDamagePercent(EffectValue); Owner.Heal(amount, m_aura.CasterUnit, m_spellEffect); } }
void ApplyAttackDamage(AttackAction action) { var attacker = action.attacker as ICombatant; var target = action.target as IDestructable; var damageAction = new DamageAction(target, attacker.attack); container.AddReaction(damageAction); }
/// <summary> /// Adds damage mods to the given AttackAction /// </summary> public virtual void OnAttack(DamageAction action) { for (var i = AttackEventHandlers.Count - 1; i >= 0; i--) { var mod = AttackEventHandlers[i]; mod.OnAttack(action); } }
public override void OnDefend(DamageAction action) { RemainingValue = action.Absorb(RemainingValue, (DamageSchoolMask)m_spellEffect.MiscValueC); if (RemainingValue <= 0) { Owner.AddMessage(m_aura.Cancel); } }
public override void OnAttack(DamageAction action) { // "spells and abilities deal $s1% more damage to targets infected with Frost Fever" if (action.SpellEffect != null && action.Victim.Auras.Contains(SpellId.EffectFrostFever)) { action.ModDamagePercent(EffectValue); } }
public override void OnDefend(DamageAction action) { if (action.Blocked <= 0 || this.EffectValue <= Utility.Random(1, 101)) { return; } action.Blocked *= 2; }
public override void OnDefend(DamageAction action) { // absorb EffectValue % from the damage var absorbed = Math.Min(action.GetDamagePercent(EffectValue), RemainingValue); // RemainingValue corresponds to AMZ's health, when it reaches 0, AMZ will be destroyed RemainingValue = action.Absorb(absorbed, (DamageSchoolMask)m_spellEffect.MiscValue); }
public override void OnAttack(DamageAction action) { var attacker = action.Attacker; // same as Owner var victim = action.Victim; var dmg = action.GetDamagePercent(EffectValue); victim.AddMessage(() => victim.DealSpellDamage(attacker, m_spellEffect, dmg, false, false)); // may not crit }
public override void OnAttack(DamageAction action) { // "Your spells and abilities deal 4% more damage to targets infected with Blood Plague." if (action.SpellEffect != null && action.Victim.Auras.Contains(SpellId.EffectBloodPlague)) { action.ModDamagePercent(EffectValue); } }