public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, BaseCommand command, string[] args) { try { Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1); Extensions ext = Extensions.Parse(from, ref args); if (!CheckObjectTypes(from, command, ext, out bool items, out bool mobiles)) { return; } if (!(items || mobiles)) { return; } IPooledEnumerable <IEntity> eable = map.GetObjectsInBounds(rect, items, mobiles); List <object> objs = eable.Where(obj => !mobiles || !(obj is Mobile) || BaseCommand.IsAccessible(from, obj)) .Where(obj => ext.IsValid(obj)).Cast <object>().ToList(); eable.Free(); ext.Filter(objs); RunCommand(from, objs, command, args); } catch (Exception ex) { from.SendMessage(ex.Message); } }
public static int DeleteTeleporters(Location location) { IPooledEnumerable <Teleporter> eable = location.Map.GetItemsInRange <Teleporter>(location.Pos, 0); var items = eable .Where(x => !(x is KeywordTeleporter || x is SkillTeleporter) && IsWithinZ(x.Z - location.Pos.Z)); int count = 0; foreach (var item in items) { count++; item.Delete(); } eable.Free(); return(count); }
private void DoAreaLeech_Finish() { IPooledEnumerable <Mobile> eable = GetMobilesInRange(6); List <Mobile> list = eable.Where(m => CanBeHarmful(m) && IsEnemy(m)).ToList(); eable.Free(); if (list.Count == 0) { Say(true, "Bah! You have escaped my grasp this time, mortal!"); } else { double scalar; if (list.Count == 1) { scalar = 0.75; } else if (list.Count == 2) { scalar = 0.50; } else { scalar = 0.25; } for (int i = 0; i < list.Count; ++i) { Mobile m = list[i]; int damage = (int)(m.Hits * scalar) + Utility.RandomMinMax(-5, 5); m.MovingParticles(this, 0x36F4, 1, 0, false, false, 32, 0, 9535, 1, 0, (EffectLayer)255, 0x100); m.MovingParticles(this, 0x0001, 1, 0, false, true, 32, 0, 9535, 9536, 0, (EffectLayer)255, 0); DoHarmful(m); Hits += AOS.Damage(m, this, Math.Max(damage, 1), 100, 0, 0, 0, 0); } Say(true, "If I cannot cleanse thy soul, I will destroy it!"); } }
public override void OnThink() { if (Core.SE && Summoned) { IPooledEnumerable <Mobile> eable = GetMobilesInRange(5); List <Mobile> spiritsOrVortexes = eable .Where(m => (m is EnergyVortex || m is BladeSpirits) && ((BaseCreature)m).Summoned).ToList(); eable.Free(); while (spiritsOrVortexes.Count > 6) { int index = Utility.Random(spiritsOrVortexes.Count); Dispel(spiritsOrVortexes[index]); spiritsOrVortexes.RemoveAt(index); } } base.OnThink(); }
public void Target(IPoint3D p) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) { SpellHelper.Turn(Caster, p); if (p is Item item) { p = item.GetWorldLocation(); } List <Mobile> targets; Map map = Caster.Map; bool playerVsPlayer = false; if (map != null) { IPooledEnumerable <Mobile> eable = map.GetMobilesInRange(new Point3D(p), 2); targets = eable.Where(m => { if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false) || (Core.AOS && !Caster.InLOS(m))) { return(false); } if (m.Player) { playerVsPlayer = true; } return(true); }).ToList(); eable.Free(); } else { targets = new List <Mobile>(); } double damage; damage = Core.AOS ? GetNewAosDamage(51, 1, 5, playerVsPlayer) : Utility.Random(27, 22); if (targets.Count > 0) { Effects.PlaySound(p, Caster.Map, 0x160); if (Core.AOS && targets.Count > 2) { damage = damage * 2 / targets.Count; } else if (!Core.AOS) { damage /= targets.Count; } for (int i = 0; i < targets.Count; ++i) { Mobile m = targets[i]; double toDeal = damage; if (!Core.AOS && CheckResisted(m)) { damage *= 0.5; m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } toDeal *= GetDamageScalar(m); Caster.DoHarmful(m); SpellHelper.Damage(this, m, toDeal, 0, 100, 0, 0, 0); Caster.MovingParticles(m, 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100); } } } FinishSequence(); }
public void Target(IPoint3D p) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (CheckSequence()) { SpellHelper.Turn(Caster, p); SpellHelper.GetSurfaceTop(ref p); List <Mobile> targets = new List <Mobile>(); Map map = Caster.Map; Mobile directTarget = p as Mobile; if (map != null) { bool feluccaRules = map.Rules == MapRules.FeluccaRules; // You can target any living mobile directly, beneficial checks apply if (directTarget != null && Caster.CanBeBeneficial(directTarget, false)) { targets.Add(directTarget); } IPooledEnumerable <Mobile> eable = map.GetMobilesInRange(new Point3D(p), 2); targets.AddRange(eable.Where(m => m != directTarget).Where(m => AreaCanTarget(m, feluccaRules))); eable.Free(); } Effects.PlaySound(p, Caster.Map, 0x299); if (targets.Count > 0) { int cured = 0; for (int i = 0; i < targets.Count; ++i) { Mobile m = targets[i]; Caster.DoBeneficial(m); Poison poison = m.Poison; if (poison != null) { int chanceToCure = 10000 + (int)(Caster.Skills.Magery.Value * 75) - (poison.Level + 1) * 1750; chanceToCure /= 100; chanceToCure -= 1; if (chanceToCure > Utility.Random(100) && m.CurePoison(Caster)) { ++cured; } } m.FixedParticles(0x373A, 10, 15, 5012, EffectLayer.Waist); m.PlaySound(0x1E0); } if (cured > 0) { Caster.SendLocalizedMessage(1010058); // You have cured the target of all poisons! } } } FinishSequence(); }
public void Use(Mobile from, IPoint3D loc) { if (!CheckUse(from)) { return; } from.BeginAction <FireHorn>(); Timer.DelayCall(Core.AOS ? TimeSpan.FromSeconds(6.0) : TimeSpan.FromSeconds(12.0), EndAction, from); int music = from.Skills.Musicianship.Fixed; int sucChance = 500 + (music - 775) * 2; double dSucChance = sucChance / 1000.0; if (!from.CheckSkill(SkillName.Musicianship, dSucChance)) { from.SendLocalizedMessage(1049618); // The horn emits a pathetic squeak. from.PlaySound(0x18A); return; } int sulfAsh = Core.AOS ? 4 : 15; from.Backpack.ConsumeUpTo(typeof(SulfurousAsh), sulfAsh); from.PlaySound(0x15F); Effects.SendPacket(from, from.Map, new HuedEffect(EffectType.Moving, from.Serial, Serial.Zero, 0x36D4, from.Location, loc, 5, 0, false, true, 0, 0)); IPooledEnumerable <Mobile> eable = from.Map.GetMobilesInRange(new Point3D(loc), 2); bool playerVsPlayer = false; List <Mobile> targets = eable.Where(m => { if (from == m || !SpellHelper.ValidIndirectTarget(from, m) || !from.CanBeHarmful(m, false) || (Core.AOS && !from.InLOS(m))) { return(false); } if (m.Player) { playerVsPlayer = true; } return(true); }).ToList(); eable.Free(); if (targets.Count > 0) { int prov = from.Skills.Provocation.Fixed; int disc = from.Skills.Discordance.Fixed; int peace = from.Skills.Peacemaking.Fixed; int minDamage, maxDamage; if (Core.AOS) { int musicScaled = music + Math.Max(0, music - 900) * 2; int provScaled = prov + Math.Max(0, prov - 900) * 2; int discScaled = disc + Math.Max(0, disc - 900) * 2; int peaceScaled = peace + Math.Max(0, peace - 900) * 2; int weightAvg = (musicScaled + provScaled * 3 + discScaled * 3 + peaceScaled) / 80; int avgDamage; if (playerVsPlayer) { avgDamage = weightAvg / 3; } else { avgDamage = weightAvg / 2; } minDamage = avgDamage * 9 / 10; maxDamage = avgDamage * 10 / 9; } else { int total = prov + disc / 5 + peace / 5; if (playerVsPlayer) { total /= 3; } maxDamage = total * 2 / 30; minDamage = maxDamage * 7 / 10; } double damage = Utility.RandomMinMax(minDamage, maxDamage); if (Core.AOS && targets.Count > 1) { damage = damage * 2 / targets.Count; } else if (!Core.AOS) { damage /= targets.Count; } for (int i = 0; i < targets.Count; ++i) { Mobile m = targets[i]; double toDeal = damage; if (!Core.AOS && m.CheckSkill(SkillName.MagicResist, 0.0, 120.0)) { toDeal *= 0.5; m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } from.DoHarmful(m); SpellHelper.Damage(TimeSpan.Zero, m, from, toDeal, 0, 100, 0, 0, 0); Effects.SendTargetEffect(m, 0x3709, 10, 30); } } double breakChance = Core.AOS ? 0.01 : 0.16; if (Utility.RandomDouble() < breakChance) { from.SendLocalizedMessage(1049619); // The fire horn crumbles in your hands. Delete(); } }