public static int DamageBonus(Mobile attacker, Mobile defender) { if (Contexts == null) { return(0); } WhirlwindAttackContext context = null; for (var index = 0; index < Contexts.Count; index++) { var c = Contexts[index]; if (c.Attacker == attacker && c.Victims.Contains(defender)) { context = c; break; } } if (context != null) { return(context.DamageBonus); } return(0); }
private static void RemoveContext(WhirlwindAttackContext context) { if (Contexts != null) { Contexts.Remove(context); } }
private static void AddContext(WhirlwindAttackContext context) { if (Contexts == null) { Contexts = new List <WhirlwindAttackContext>(); } Contexts.Add(context); }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { bool any = false; if (Contexts != null) { for (var index = 0; index < Contexts.Count; index++) { var c = Contexts[index]; if (Contexts != null && c.Attacker == attacker) { any = true; break; } } } if (!Validate(attacker) || Contexts != null && any) { return; } ClearCurrentAbility(attacker); Map map = attacker.Map; if (map == null) { return; } BaseWeapon weapon = attacker.Weapon as BaseWeapon; if (weapon == null) { return; } if (!CheckMana(attacker, true)) { return; } attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); List <Mobile> list = new List <Mobile>(); foreach (IDamageable target in SpellHelper.AcquireIndirectTargets(attacker, attacker, attacker.Map, 1)) { if (target is Mobile m && (attacker.InRange(m, weapon.MaxRange) && m != defender)) { list.Add(m); } } int count = list.Count; if (count > 0) { double bushido = attacker.Skills.Bushido.Value; int bonus = 0; if (bushido > 0) { bonus = (int)Math.Min(100, ((list.Count * bushido) * (list.Count * bushido)) / 3600); } var context = new WhirlwindAttackContext(attacker, list, bonus); AddContext(context); attacker.RevealingAction(); for (var index = 0; index < list.Count; index++) { Mobile m = list[index]; attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target! m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage! weapon.OnHit(attacker, m); } RemoveContext(context); } ColUtility.Free(list); weapon.ProcessingMultipleHits = false; }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || (Contexts != null && Contexts.Any(c => c.Attacker == attacker))) { return; } ClearCurrentAbility(attacker); Map map = attacker.Map; if (map == null) { return; } if (!(attacker.Weapon is BaseWeapon weapon)) { return; } if (!CheckMana(attacker, true)) { return; } attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); var list = SpellHelper.AcquireIndirectTargets(attacker, attacker, attacker.Map, 1) .OfType <Mobile>() .Where(m => attacker.InRange(m, weapon.MaxRange) && m != defender).ToList(); int count = list.Count; if (count > 0) { double bushido = attacker.Skills.Bushido.Value; // double damageBonus = 1.0 + Math.Pow((count * bushido) / 60, 2) / 100; int damagebonus = 0; if (bushido > 0) { damagebonus = (int)Math.Min(100, ((list.Count * bushido) * (list.Count * bushido)) / 3600); } if (damagebonus > 2) { damagebonus = 2; } var context = new WhirlwindAttackContext(attacker, list, damagebonus); AddContext(context); attacker.RevealingAction(); foreach (var m in list) { attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target! m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage! weapon.OnHit(attacker, m); // , damageBonus } RemoveContext(context); } ColUtility.Free(list); weapon.ProcessingMultipleHits = false; }