public virtual void Teleport() { if (Combatant == null) { return; } // 20 tries to teleport for (int tries = 0; tries < 20; tries++) { int x = Utility.RandomMinMax(5, 7); int y = Utility.RandomMinMax(5, 7); if (Utility.RandomBool()) { x *= -1; } if (Utility.RandomBool()) { y *= -1; } Point3D p = new Point3D(X + x, Y + y, 0); IPoint3D po = new LandTarget(p, Map) as IPoint3D; if (po == null) { continue; } SpellHelper.GetSurfaceTop(ref po); if (InRange(p, 12) && InLOS(p) && Map.CanSpawnMobile(po.X, po.Y, po.Z)) { Point3D from = Location; Point3D to = new Point3D(po); Location = to; ProcessDelta(); FixedParticles(0x376A, 9, 32, 0x13AF, EffectLayer.Waist); PlaySound(0x1FE); return; } } RevealingAction(); }
public override bool GetHarvestDetails(Mobile from, Item tool, object toHarvest, out int tileID, out Map map, out Point3D loc) { bool lava = HasTypeHook(tool, HookType.Lava); if (toHarvest is Static && !((Static)toHarvest).Movable) { Static obj = (Static)toHarvest; if (lava) tileID = obj.ItemID; else tileID = (obj.ItemID & 0x3FFF) | 0x4000; map = obj.Map; loc = obj.GetWorldLocation(); } else if (toHarvest is StaticTarget) { StaticTarget obj = (StaticTarget)toHarvest; if (lava) tileID = obj.ItemID; else tileID = (obj.ItemID & 0x3FFF) | 0x4000; map = from.Map; loc = obj.Location; } else if (toHarvest is LandTarget) { LandTarget obj = (LandTarget)toHarvest; tileID = obj.TileID; map = from.Map; loc = obj.Location; } else { tileID = 0; map = null; loc = Point3D.Zero; return false; } //Lava tile, no lava hook if (ValidateSpecialTile(tileID) && !lava) return false; return (map != null && map != Map.Internal); }
public override bool DoActionGuard() { if (m_LastTarget != null && m_LastTarget.Hidden) { Map map = m_Mobile.Map; if (map == null || !m_Mobile.InRange(m_LastTargetLoc, Core.ML ? 10 : 12)) { m_LastTarget = null; } else if (m_Mobile.Spell == null && DateTime.UtcNow > m_NextCastTime) { m_Mobile.DebugSay("I am going to reveal my last target"); m_RevealTarget = new LandTarget(m_LastTargetLoc, map); Spell spell = new RevealSpell(m_Mobile, null); if (spell.Cast()) { m_LastTarget = null; // only do it once } m_NextCastTime = DateTime.UtcNow + GetDelay(spell); } } if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { m_Mobile.DebugSay("I am going to attack {0}", m_Mobile.FocusMob.Name); m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; } else { ProcessTarget(); Spell spell = CheckCastHealingSpell(); if (spell != null) { spell.Cast(); } base.DoActionGuard(); } return(true); }
protected override void OnTarget(Mobile from, object targeted) { if (m_Seed.Deleted) { return; } if (!m_Seed.IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it. return; } if (!from.CanBeginAction(typeof(MonsterSeed))) { from.SendMessage("You must wait before planting another seed."); return; } LandTarget land = targeted as LandTarget; if (land == null) { from.SendMessage("You cannot plant that there."); } else { //MonsterSeedEffect effect = MonsterSeedEffect.Create( from, land, m_Seed.CreatureType ); if (false) // Target is in tiles { from.SendMessage("That would be futile."); } else { m_Seed.Consume(); from.SendMessage("You push the seed into the ground."); from.Emote("*Pushes a seed into the ground.*"); object[] arg = new object[] { from, land, m_Creature }; Timer.DelayCall(TimeSpan.FromSeconds(2.0), new TimerStateCallback(SpawnCreature), arg); } } }
protected override void OnTarget(Mobile from, object targeted) { if (m_Thorn.Deleted) { return; } if (!m_Thorn.IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it. return; } if (!from.CanBeginAction(typeof(GreenThorns))) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061908); // * You must wait a while before planting another thorn. * return; } LandTarget land = targeted as LandTarget; if (land == null) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061912); // * You cannot plant a green thorn there! * } else { GreenThornsEffect effect = GreenThornsEffect.Create(from, land); if (effect == null) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061913); // * You sense it would be useless to plant a green thorn there. * } else { m_Thorn.Consume(); from.LocalOverheadMessage(MessageType.Emote, 0x961, 1061914); // * You push the strange green thorn into the ground * from.NonlocalOverheadMessage(MessageType.Emote, 0x961, 1061915, from.Name); // * ~1_PLAYER_NAME~ pushes a strange green thorn into the ground. * from.BeginAction(typeof(GreenThorns)); new GreenThorns.EndActionTimer(from).Start(); effect.Start(); } } }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is LandTarget) { LandTarget targ = (LandTarget)targeted; DeplacerMobile(m_MovingMobile, new Point3D(targ.X, targ.Y, targ.Z)); } else if (targeted is StaticTarget) { StaticTarget targ = (StaticTarget)targeted; DeplacerMobile(m_MovingMobile, new Point3D(targ.X, targ.Y, targ.Z)); } else { from.SendMessage("Vous ne pouvez déplacer le mobile sur " + targeted.GetType().ToString()); } }
public void Teleport() { // 20 tries to teleport for (int tries = 0; tries < 20; tries++) { int x = Utility.RandomMinMax(5, 7); int y = Utility.RandomMinMax(5, 7); if (Utility.RandomBool()) { x *= -1; } if (Utility.RandomBool()) { y *= -1; } Point3D p = new Point3D(this.X + x, this.Y + y, 0); IPoint3D po = new LandTarget(p, this.Map) as IPoint3D; if (po == null) { continue; } SpellHelper.GetSurfaceTop(ref po); if (this.InRange(p, 12) && this.InLOS(p) && this.Map.CanSpawnMobile(po.X, po.Y, po.Z)) { Point3D from = this.Location; Point3D to = new Point3D(po); this.Location = to; this.ProcessDelta(); this.FixedParticles(0x376A, 9, 32, 0x13AF, EffectLayer.Waist); this.PlaySound(0x1FE); break; } } this.RevealingAction(); }
protected override void OnTarget(Mobile from, object targeted) { Map map = from.Map; if (targeted is LandTarget && map != null) { LandTarget lt = (LandTarget)targeted; Region r = Region.Find(lt.Location, map); if (r != null && r.IsPartOf("Magincia") && (lt.Name == "dirt" || lt.Name == "grass")) { if (!MaginciaPlantSystem.Enabled) { from.SendMessage("Magincia plant placement is currently disabled."); } else if (MaginciaPlantSystem.CanAddPlant(from, lt.Location)) { int fertileDirt = from.Backpack == null ? 0 : from.Backpack.GetAmount(typeof(FertileDirt), false); if (fertileDirt > 0) { from.SendGump(new FertileDirtGump(null, fertileDirt, lt)); } else { if (from.Body.IsHuman && !from.Mounted) { from.Animate(11, 5, 1, true, false, 0); } from.PlaySound(0x125); MaginciaPlantItem dirt = new MaginciaPlantItem(); dirt.StartTimer(); Timer.DelayCall(TimeSpan.FromSeconds(.7), new TimerStateCallback(MoveItem_Callback), new object[] { dirt, lt.Location, map }); } } } else { from.SendLocalizedMessage(1150457); // The ground here is not good for gardening. } } }
public void Target(LandTarget p) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (!CheckLineOfSight(p)) { this.DoFizzle(); Caster.SendAsciiMessage("Target is not in line of sight"); } else { if (CheckSequence()) { try { BaseCreature creature = (BaseCreature)Activator.CreateInstance(m_Types[Utility.Random(m_Types.Length)]); creature.ControlSlots = 2; TimeSpan duration; if (Core.AOS) { duration = TimeSpan.FromSeconds((2 * Caster.Skills.Magery.Fixed) / 5); } else { duration = TimeSpan.FromSeconds(4.0 * Caster.Skills[SkillName.Magery].Value); } SpellHelper.Summon(creature, Caster, 0x215, duration, false, false); creature.MoveToWorld(new Point3D(p), Caster.Map); } catch { } } FinishSequence(); } }
protected override void OnTarget(Mobile from, object o) { if (o != null) { if (o is LandTarget) { LandTarget l = o as LandTarget; m_IdentifyAddon.MoveToWorld(l.Location, from.Map); } else { from.SendMessage(37, "Use must target a land tile to place your addon."); if (m_IdentifyAddon != null) { m_IdentifyAddon.Delete(); } } } }
private static bool FindValidTile(Mobile m, HarvestDefinition definition, out object toHarvest) { Map map = m.Map; toHarvest = null; if (m == null || map == null || map == Map.Internal) { return(false); } for (int x = m.X - 1; x <= m.X + 1; x++) { for (int y = m.Y - 1; y <= m.Y + 1; y++) { StaticTile[] tiles = map.Tiles.GetStaticTiles(x, y, false); if (tiles.Length > 0) { foreach (var tile in tiles) { int id = (tile.ID & 0x3FFF) | 0x4000; if (definition.Validate(id)) { toHarvest = new StaticTarget(new Point3D(x, y, tile.Z), tile.ID); return(true); } } } LandTile lt = map.Tiles.GetLandTile(x, y); if (definition.Validate(lt.ID)) { toHarvest = new LandTarget(new Point3D(x, y, lt.Z), map); return(true); } } } return(false); }
public virtual bool GetHarvestDetails(Mobile from, Item tool, object toHarvest, out int tileID, out Map map, out Point3D loc) { if (toHarvest is Static && !((Static)toHarvest).Movable) { Static obj = (Static)toHarvest; tileID = (obj.ItemID & 0x3FFF) | 0x4000; map = obj.Map; loc = obj.GetWorldLocation(); } else if (toHarvest is StaticTarget) { StaticTarget obj = (StaticTarget)toHarvest; tileID = (obj.ItemID & 0x3FFF) | 0x4000; map = from.Map; loc = obj.Location; } else if (toHarvest is LandTarget) { LandTarget obj = (LandTarget)toHarvest; tileID = obj.TileID; map = from.Map; loc = obj.Location; } else { tileID = 0; map = null; loc = Point3D.Zero; return(false); } return(map != null && map != Map.Internal); }
public static void TargetResponse(NetState state, CircularBufferReader reader, int packetLength) { int type = reader.ReadByte(); var targetID = reader.ReadInt32(); int flags = reader.ReadByte(); var serial = (Serial)reader.ReadUInt32(); int x = reader.ReadInt16(); int y = reader.ReadInt16(); reader.ReadByte(); int z = reader.ReadSByte(); int graphic = reader.ReadUInt16(); if (targetID == unchecked ((int)0xDEADBEEF)) { return; } var from = state.Mobile; var t = from.Target; if (t == null) { return; } var prof = TargetProfile.Acquire(t.GetType()); prof?.Start(); try { if (x == -1 && y == -1 && !serial.IsValid) { // User pressed escape t.Cancel(from, TargetCancelType.Canceled); } else if (t.TargetID != targetID) { // Sanity, prevent fake target } else { object toTarget; if (type == 1) { if (graphic == 0) { toTarget = new LandTarget(new Point3D(x, y, z), from.Map); } else { var map = from.Map; if (map == null || map == Map.Internal) { t.Cancel(from, TargetCancelType.Canceled); return; } else { var tiles = map.Tiles.GetStaticTiles(x, y, !t.DisallowMultis); var valid = false; if (state.HighSeas) { var id = TileData.ItemTable[graphic & TileData.MaxItemValue]; if (id.Surface) { z -= id.Height; } } for (var i = 0; !valid && i < tiles.Length; ++i) { if (tiles[i].Z == z && tiles[i].ID == graphic) { valid = true; } } if (!valid) { t.Cancel(from, TargetCancelType.Canceled); return; } else { toTarget = new StaticTarget(new Point3D(x, y, z), graphic); } } } } else if (serial.IsMobile) { toTarget = World.FindMobile(serial); } else if (serial.IsItem) { toTarget = World.FindItem(serial); } else { t.Cancel(from, TargetCancelType.Canceled); return; } t.Invoke(from, toTarget); } } finally { prof?.Finish(); } }
private bool ProcessTarget() { Target targ = this.m_Mobile.Target; if (targ == null) { return(false); } Mobile toTarget; toTarget = this.m_Mobile.Combatant; //if ( toTarget != null ) //RunTo( toTarget ); if (targ is DispelSpell.InternalTarget && !(this.m_Mobile.AutoDispel)) { List <Mobile> targets = new List <Mobile>(); foreach (Mobile m in this.m_Mobile.GetMobilesInRange(12)) { if (m is BaseCreature) { if (((BaseCreature)m).IsDispellable && CanTarget(this.m_Mobile, m)) { targets.Add(m); } } } if (targets.Count >= 0) { int whichone = Utility.RandomMinMax(0, targets.Count); if (targets[whichone] != null) { targ.Invoke(this.m_Mobile, targets[whichone]); } } } else if (targ is TeleportSpell.InternalTarget || targ is Shadowjump.InternalTarget) { if (targ is Shadowjump.InternalTarget && !this.m_Mobile.Hidden) { return(false); } Map map = this.m_Mobile.Map; if (map == null) { targ.Cancel(this.m_Mobile, TargetCancelType.Canceled); return(true); } int px, py; bool teleportAway = (this.m_Mobile.Hits < (this.m_Mobile.Hits / 10)); if (teleportAway) { int rx = this.m_Mobile.X - toTarget.X; int ry = this.m_Mobile.Y - toTarget.Y; double d = this.m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_RandomLocations.Length; i += 2) { int x = m_RandomLocations[i], y = m_RandomLocations[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || this.m_Mobile.InRange(p, targ.Range)) && this.m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(this.m_Mobile, lt); return(true); } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(this.m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), this.m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (this.m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(this.m_Mobile, new LandTarget(randomPoint, map)); return(true); } } } else if (targ is AnimateDeadSpell.InternalTarget) { Type type = null; List <Item> itemtargets = new List <Item>(); foreach (Item itemstofind in this.m_Mobile.GetItemsInRange(5)) { if (itemstofind is Corpse) { itemtargets.Add(itemstofind); } } for (int i = 0; i < itemtargets.Count; ++i) { Corpse items = (Corpse)itemtargets[i]; if (items.Owner != null) { type = items.Owner.GetType(); } if (items.ItemID != 0x2006 || items.Channeled || type == typeof(PlayerMobile) || type == null || (items.Owner != null && items.Owner.Fame < 100) || ((items.Owner != null) && (items.Owner is BaseCreature) && (((BaseCreature)items.Owner).Summoned || ((BaseCreature)items.Owner).IsBonded))) { continue; } else { targ.Invoke(this.m_Mobile, items); break; } } if (targ != null) { targ.Cancel(this.m_Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { if ((targ.Range == -1 || this.m_Mobile.InRange(toTarget, targ.Range)) && this.m_Mobile.CanSee(toTarget) && this.m_Mobile.InLOS(toTarget)) { targ.Invoke(this.m_Mobile, toTarget); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { targ.Invoke(this.m_Mobile, this.m_Mobile); } else { targ.Cancel(this.m_Mobile, TargetCancelType.Canceled); } return(true); }
// Shadowjump private bool PerformShadowjump(Mobile toTarget) { if (m_Mobile.Skills[SkillName.Ninjitsu].Value < 50.0) { return(false); } if (toTarget != null) { Map map = m_Mobile.Map; if (map == null) { return(false); } int px, py, ioffset = 0; px = toTarget.X; py = toTarget.Y; if (Action == ActionType.Flee) { double outerradius = m_Mobile.Skills[SkillName.Ninjitsu].Value / 10.0; double radiusoffset = 2.0; // random point for direction vector int rpx = Utility.Random(40) - 20 + toTarget.X; int rpy = Utility.Random(40) - 20 + toTarget.Y; // get vector int dx = rpx - toTarget.X; int dy = rpy - toTarget.Y; // get vector's length double l = Math.Sqrt((double)(dx * dx + dy * dy)); if (l == 0) { return(false); } // normalize vector double dpx = ((double)dx) / l; double dpy = ((double)dy) / l; // move px += (int)(dpx * (outerradius - radiusoffset) + Math.Sign(dpx) * (radiusoffset + 0.5)); py += (int)(dpy * (outerradius - radiusoffset) + Math.Sign(dpy) * (radiusoffset + 0.5)); } else { ioffset = 2; } for (int i = ioffset; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { m_Mobile.Location = new Point3D(lt.X, lt.Y, lt.Z); m_Mobile.ProcessDelta(); return(true); } } } return(false); }
public bool Intersects(LandTarget o) { return(Intersects(o.X, o.Y, o.Z, 1)); }
protected virtual bool ProcessTarget() { Target targ = m_Mobile.Target; if (targ == null) { return(false); } bool isDispel = (targ is DispelSpell.InternalTarget || targ is MassDispelSpell.InternalTarget); bool isParalyze = (targ is ParalyzeSpell.InternalTarget); bool isTeleport = (targ is TeleportSpell.InternalTarget); bool isSummon = (targ is EnergyVortexSpell.InternalTarget || targ is BladeSpiritsSpell.InternalTarget || targ is NatureFurySpell.InternalTarget); bool isField = (targ is FireFieldSpell.InternalTarget || targ is PoisonFieldSpell.InternalTarget || targ is ParalyzeFieldSpell.InternalTarget); bool isAnimate = (targ is AnimateDeadSpell.InternalTarget); bool isDispelField = (targ is DispelFieldSpell.InternalTarget); bool teleportAway = false; bool harmful = (targ.Flags & TargetFlags.Harmful) != 0 || targ is HailStormSpell.InternalTarget || targ is WildfireSpell.InternalTarget; bool beneficial = (targ.Flags & TargetFlags.Beneficial) != 0 || targ is ArchCureSpell.InternalTarget; if (isTeleport && m_Mobile.CanSwim) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } IDamageable toTarget = null; if (isDispel) { toTarget = FindDispelTarget(false); if (toTarget != null) { RunTo(toTarget); } } else if (isDispelField) { Item field = GetHarmfulFieldItem(); if (field != null) { targ.Invoke(m_Mobile, field); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if (SmartAI && (isParalyze || isTeleport)) { toTarget = FindDispelTarget(true); if (toTarget == null) { toTarget = m_Mobile.Combatant as Mobile; if (toTarget != null) { RunTo(toTarget); } } else if (m_Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); teleportAway = true; } else { teleportAway = true; } } else if (isAnimate) { Item corpse = FindCorpseToAnimate(); if (corpse != null) { targ.Invoke(m_Mobile, corpse); } } else { toTarget = m_Mobile.Combatant; if (toTarget != null) { RunTo(toTarget); } } if (isSummon && toTarget != null) { int failSafe = 0; Map map = toTarget.Map; while (failSafe <= 25) { int x = Utility.RandomMinMax(toTarget.X - 2, toTarget.X + 2); int y = Utility.RandomMinMax(toTarget.Y - 2, toTarget.Y + 2); int z = toTarget.Z; LandTarget lt = new LandTarget(new Point3D(x, y, z), map); if (map.CanSpawnMobile(x, y, z)) { targ.Invoke(m_Mobile, lt); break; } failSafe++; } } else if (isField && toTarget != null) { Map map = toTarget.Map; int x = m_Mobile.X; int y = m_Mobile.Y; int z = m_Mobile.Z; if (toTarget == null || m_Mobile.InRange(toTarget.Location, 3)) { targ.Invoke(m_Mobile, toTarget); return(true); } Direction d = Utility.GetDirection(m_Mobile, toTarget); int dist = (int)m_Mobile.GetDistanceToSqrt(toTarget.Location) / 2; Point3D p = m_Mobile.Location; switch ((int)d) { case (int)Direction.Running: case (int)Direction.North: y = p.Y - dist; break; case 129: case (int)Direction.Right: x = p.X + dist; y = p.Y - dist; break; case 130: case (int)Direction.East: x = p.X + dist; break; case 131: case (int)Direction.Down: x = p.X + dist; y = p.Y + dist; break; case 132: case (int)Direction.South: y = p.Y + dist; break; case 133: case (int)Direction.Left: x = p.X - dist; y = p.Y + dist; break; case 134: case (int)Direction.West: x = p.X - dist; break; case (int)Direction.ValueMask: case (int)Direction.Up: x = p.X - dist; y = p.Y - dist; break; } LandTarget lt = new LandTarget(new Point3D(x, y, z), map); targ.Invoke(m_Mobile, lt); } if (harmful && toTarget != null) { if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) { targ.Invoke(m_Mobile, toTarget); } else if (isDispel) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if (beneficial) { targ.Invoke(m_Mobile, m_Mobile); } else if (isTeleport && toTarget != null) { Map map = m_Mobile.Map; if (map == null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); return(true); } int px, py; if (teleportAway) { int rx = m_Mobile.X - toTarget.X; int ry = m_Mobile.Y - toTarget.Y; double d = m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(m_Mobile, lt); return(true); } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = Core.ML ? 11 : 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); return(true); } } targ.Cancel(m_Mobile, TargetCancelType.Canceled); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } return(true); }
public virtual object SearchForNearbyNode(Point3D location, Map map, int range) { int rows = (range * 2) + 1; int columns = (range * 2) + 1; bool foundValidNode = false; HarvestBank harvestBank = null; List <Point3D> nearbyPoints = new List <Point3D>(); for (int a = 1; a < rows + 1; a++) { for (int b = 1; b < columns + 1; b++) { Point3D newPoint = new Point3D(location.X + (-1 * (range + 1)) + a, location.Y + (-1 * (range + 1)) + b, location.Z); nearbyPoints.Add(newPoint); } } int totalPoints = nearbyPoints.Count; for (int a = 0; a < totalPoints; a++) { Point3D currentPoint = nearbyPoints[Utility.RandomMinMax(0, nearbyPoints.Count - 1)]; //Land Target on Tile LandTarget landTarget = new LandTarget(currentPoint, map); if (landTarget != null) { HarvestDefinition landTargetHarvestDefinition = GetDefinition(landTarget.TileID); if (landTargetHarvestDefinition != null) { harvestBank = landTargetHarvestDefinition.GetBank(map, currentPoint.X, currentPoint.Y); if (harvestBank != null) { if (harvestBank.Current >= landTargetHarvestDefinition.ConsumedPerHarvest) { return(landTarget); } } } } StaticTile[] staticTiles = map.Tiles.GetStaticTiles(currentPoint.X, currentPoint.Y, false); if (staticTiles == null) { continue; } foreach (StaticTile staticTile in staticTiles) { StaticTarget staticTarget = new StaticTarget(currentPoint, staticTile.ID); if (staticTarget == null) { continue; } int tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000; HarvestDefinition staticTargetHarvestDefinition = GetDefinition(tileID); if (staticTargetHarvestDefinition == null) { continue; } harvestBank = staticTargetHarvestDefinition.GetBank(map, currentPoint.X, currentPoint.Y); if (harvestBank == null) { continue; } if (harvestBank.Current >= staticTargetHarvestDefinition.ConsumedPerHarvest) { return(staticTarget); } } nearbyPoints.Remove(currentPoint); } return(null); }
private bool ProcessTarget() { Target targ = m_Mobile.Target; if (targ == null) { return(false); } Mobile toTarget; toTarget = m_Mobile.Combatant; //if ( toTarget != null ) //RunTo( toTarget ); if (targ is DispelSpell.InternalTarget && !(m_Mobile.AutoDispel)) { List <Mobile> targets = new List <Mobile>(); foreach (Mobile m in m_Mobile.GetMobilesInRange(12)) { if (m is BaseCreature) { if (((BaseCreature)m).IsDispellable && CanTarget(m_Mobile, m)) { targets.Add(m); } } } if (targets.Count >= 0) { int whichone = Utility.RandomMinMax(0, targets.Count); if (targets[whichone] != null) { targ.Invoke(m_Mobile, targets[whichone]); } } } else if (targ is TeleportSpell.InternalTarget || targ is Shadowjump.InternalTarget) { if (targ is Shadowjump.InternalTarget && !m_Mobile.Hidden) { return(false); } Map map = m_Mobile.Map; if (map == null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); return(true); } int px, py; bool teleportAway = (m_Mobile.Hits < (m_Mobile.Hits / 10)); if (teleportAway) { int rx = m_Mobile.X - toTarget.X; int ry = m_Mobile.Y - toTarget.Y; double d = m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_RandomLocations.Length; i += 2) { int x = m_RandomLocations[i], y = m_RandomLocations[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(m_Mobile, lt); return(true); } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); return(true); } } } else if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) { targ.Invoke(m_Mobile, toTarget); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { targ.Invoke(m_Mobile, m_Mobile); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } return(true); }
public override void ProcessTarget(Target targ) { bool isDispel = (targ is DispelSpell.InternalTarget); bool isParalyze = (targ is ParalyzeSpell.InternalTarget); bool isTeleport = (targ is TeleportSpell.InternalTarget); bool isCrossHeal = (targ is GreaterHealSpell.InternalTarget); bool isTrap = (targ is MagicTrapSpell.InternalTarget); bool teleportAway = false; bool isReveal = (targ is RevealSpell.InternalTarget || targ is DetectHidden.InternalTarget); Mobile toTarget = null; Mobile toHeal = null; if (isReveal) { targ.Invoke(m_Mobile, m_Mobile); } if (isTrap) { Pouch p = FindPouch(m_Mobile); if (p != null) { targ.Invoke(m_Mobile, p); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } if (isDispel) { toTarget = FindDispelTarget(false); if (toTarget != null && m_Mobile.InRange(toTarget, 10) && !toTarget.Paralyzed) { RunFrom(toTarget); } } if (CrossHeals && isCrossHeal) { toHeal = FindHealTarget(true); if (toHeal != null && !m_Mobile.InRange(toHeal, 8)) { RunTo(toHeal, CanRun); } } else if (isParalyze || isTeleport) { toTarget = FindDispelTarget(true); if (toTarget == null) { toTarget = m_Mobile.Combatant; if (toTarget != null && !m_Mobile.InRange(toTarget, 8)) { RunTo(toTarget, CanRun); } } else if (m_Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); teleportAway = true; } else { teleportAway = true; } } else { if (m_Mobile.ControlOrder == OrderType.Come && isTeleport) { toTarget = m_Mobile.ControlMaster; } else { toTarget = m_Mobile.Combatant; } if (toTarget != null) { RunTo(toTarget, CanRun); } } if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { if ((m_Mobile.InRange(toTarget, 10)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) { targ.Invoke(m_Mobile, toTarget); } else if (isDispel) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0 && toHeal != null) { if ((m_Mobile.InRange(toHeal, 10)) && m_Mobile.CanSee(toHeal) && m_Mobile.InLOS(toHeal) && NeedGHeal(toHeal)) { targ.Invoke(m_Mobile, toHeal); } else { Targeting.Target.Cancel(m_Mobile); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { if (!isCrossHeal) { targ.Invoke(m_Mobile, m_Mobile); } if ((isCrossHeal) && (NeedGHeal(m_Mobile))) { targ.Invoke(m_Mobile, m_Mobile); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if (isTeleport && toTarget != null) { Map map = m_Mobile.Map; if (map == null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); return; } int px, py; if (teleportAway) { int rx = m_Mobile.X - toTarget.X; int ry = m_Mobile.Y - toTarget.Y; double d = m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(m_Mobile, lt); return; } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); return; } } targ.Cancel(m_Mobile, TargetCancelType.Canceled); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } }
public static void AntiEUOTargeting(NetState state, PacketReader pvSrc) { int type = pvSrc.ReadByte(); // type int cid = pvSrc.ReadInt32(); // cursor id int cur = pvSrc.ReadByte(); // cursor Serial s = (Serial)pvSrc.ReadInt32(); // serial int x = pvSrc.ReadInt16(); // x int y = pvSrc.ReadInt16(); // y int z = pvSrc.ReadInt16(); // z int model = pvSrc.ReadInt16(); // model number Mobile m = state.Mobile; Target t = m.Target; if (t == null) { return; } if (x == -1 && y == -1 && !s.IsValid) { t.Cancel(m, TargetCancelType.Canceled); return; } object o; if (type == 1) { if (model == 0) { o = new LandTarget(new Point3D(x, y, z), m.Map); } else { if (m.Map == null || m.Map == Map.Internal) { t.Cancel(m, TargetCancelType.Canceled); return; } StaticTile[] TileArray = m.Map.Tiles.GetStaticTiles(x, y, !t.DisallowMultis); bool flag = false; for (int i = 0; (!flag && (i < TileArray.Length)); i++) { if ((TileArray[i].Z == z) && ((TileArray[i].ID & 16383) == (model & 16383))) { flag = true; } } if (!flag) { t.Cancel(m, TargetCancelType.Canceled); return; } o = new StaticTarget(new Point3D(x, y, z), model); } } else { PlayerMobile pm = m as PlayerMobile; if (pm == null) // should never happen { t.Cancel(m, TargetCancelType.Canceled); return; } if (pm.LastTarget == Serial.MinusOne) // last target not set yet { if (s == Serial.Zero) // client is a f*****g retard { t.Cancel(m, TargetCancelType.Canceled); return; } if (s != m.Serial) { pm.LastTarget = s; } } else if (x == 0 && y == 0 && z == 0) // is last target or euo { if (s != pm.LastTarget) // they are sending last target while server monitored last target is different { { Catch(pm); /* m.SendMessage( "BAD LAST TARGET!!! CURSOR ID:{0} CURSOR:{1} X:{2} Y:{3} Z:{4} MODEL:{5} TYPE:{6} LAST:{7} NEW:{8}", cid, cur, x, y, z, model, type, ((PlayerMobile)m).LastTarget, s ); * m.SendMessage( "CURSOR ID:{0} CURSOR:{1} X:{2} Y:{3} Z:{4} MODEL:{5} TYPE:{6} LAST:{7} NEW:{8}", cid, cur, x, y, z, model, type, ((PlayerMobile)m).LastTarget, s ); */ // t.Cancel( m, TargetCancelType.Canceled ); // return; } } if (s != m.Serial) { pm.LastTarget = s; } if (s.IsMobile) { o = World.FindMobile(s); } else if (s.IsItem) { o = World.FindItem(s); } else { t.Cancel(m, TargetCancelType.Canceled); return; } } t.Invoke(m, o); }
private void ProcessTarget(Target targ) { bool isDispel = (targ is DispelSpell.InternalTarget); bool isParalyze = (targ is ParalyzeSpell.InternalTarget); bool isTeleport = (targ is TeleportSpell.InternalTarget); bool teleportAway = false; Mobile toTarget; if (isDispel) { toTarget = this.FindDispelTarget(false); if (toTarget != null && this.m_Mobile.InRange(toTarget, 10)) { this.RunFrom(toTarget); } } else if (isParalyze || isTeleport) { toTarget = this.FindDispelTarget(true); if (toTarget == null) { toTarget = this.m_Mobile.Combatant; if (toTarget != null) { this.RunTo(toTarget); } } else if (this.m_Mobile.InRange(toTarget, 10)) { this.RunFrom(toTarget); teleportAway = true; } else { teleportAway = true; } } else { toTarget = this.m_Mobile.Combatant; if (toTarget != null) { this.RunTo(toTarget); } } if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { if ((targ.Range == -1 || this.m_Mobile.InRange(toTarget, targ.Range)) && this.m_Mobile.CanSee(toTarget) && this.m_Mobile.InLOS(toTarget)) { targ.Invoke(this.m_Mobile, toTarget); } else if (isDispel) { targ.Cancel(this.m_Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { targ.Invoke(this.m_Mobile, this.m_Mobile); } else if (isTeleport && toTarget != null) { Map map = this.m_Mobile.Map; if (map == null) { targ.Cancel(this.m_Mobile, TargetCancelType.Canceled); return; } int px, py; if (teleportAway) { int rx = this.m_Mobile.X - toTarget.X; int ry = this.m_Mobile.Y - toTarget.Y; double d = this.m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || this.m_Mobile.InRange(p, targ.Range)) && this.m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(this.m_Mobile, lt); return; } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(this.m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), this.m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (this.m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(this.m_Mobile, new LandTarget(randomPoint, map)); return; } } targ.Cancel(this.m_Mobile, TargetCancelType.Canceled); } else { targ.Cancel(this.m_Mobile, TargetCancelType.Canceled); } }
protected override void OnTarget(Mobile from, object targeted) { StaticTarget a = targeted as StaticTarget; Item b = targeted as Item; LandTarget c = targeted as LandTarget; if (m_Bandage.Deleted) { return; } if (targeted == a) { if ((a.ItemID >= 5937 && a.ItemID <= 5978) || (a.ItemID >= 6038 && a.ItemID <= 6066) || (a.ItemID >= 6595 && a.ItemID <= 6636) || (a.ItemID >= 8093 && a.ItemID <= 8094) || (a.ItemID >= 8099 && a.ItemID <= 8138) || (a.ItemID >= 9299 && a.ItemID <= 9309) || (a.ItemID >= 13422 && a.ItemID <= 13525) || (a.ItemID >= 13549 && a.ItemID <= 13616) || (a.ItemID == 3707) || (a.ItemID >= 4088 && a.ItemID <= 4089) || (a.ItemID == 4104) || (a.ItemID == 5453) || (a.ItemID >= 5458 && a.ItemID <= 5460) || (a.ItemID == 5465) || (a.ItemID >= 2881 && a.ItemID <= 2884)) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } m_Bandage.Amount = 1; m_Bandage.Consume(); } else { from.SendMessage("You can only wash bloody bandages in water."); } } else if (targeted == b) { if ((b.ItemID >= 5937 && b.ItemID <= 5978) || (b.ItemID >= 6038 && b.ItemID <= 6066) || (b.ItemID >= 6595 && b.ItemID <= 6636) || (b.ItemID >= 8099 && b.ItemID <= 8138) || (b.ItemID >= 9299 && b.ItemID <= 9309) || (b.ItemID >= 13422 && b.ItemID <= 13525) || (b.ItemID >= 13549 && b.ItemID <= 13616) || (b.ItemID == 3707) || (b.ItemID == 4104) || (b.ItemID == 5453) || (b.ItemID >= 5458 && b.ItemID <= 5460) || (b.ItemID == 5465) || (b.ItemID >= 2881 && b.ItemID <= 2884)) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (b is BaseBeverage) { BaseBeverage bev = b as BaseBeverage; if (bev.Content == BeverageType.Water) { if (bev.Quantity == 10 && m_Bandage.Amount <= 100) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 91) { bev.Quantity = (bev.Quantity - 10); } else if (m_Bandage.Amount >= 81) { bev.Quantity = (bev.Quantity - 9); } else if (m_Bandage.Amount >= 71) { bev.Quantity = (bev.Quantity - 8); } else if (m_Bandage.Amount >= 61) { bev.Quantity = (bev.Quantity - 7); } else if (m_Bandage.Amount >= 51) { bev.Quantity = (bev.Quantity - 6); } else if (m_Bandage.Amount >= 41) { bev.Quantity = (bev.Quantity - 5); } else if (m_Bandage.Amount >= 31) { bev.Quantity = (bev.Quantity - 4); } else if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 9 && m_Bandage.Amount <= 90) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 81) { bev.Quantity = (bev.Quantity - 9); } else if (m_Bandage.Amount >= 71) { bev.Quantity = (bev.Quantity - 8); } else if (m_Bandage.Amount >= 61) { bev.Quantity = (bev.Quantity - 7); } else if (m_Bandage.Amount >= 51) { bev.Quantity = (bev.Quantity - 6); } else if (m_Bandage.Amount >= 41) { bev.Quantity = (bev.Quantity - 5); } else if (m_Bandage.Amount >= 31) { bev.Quantity = (bev.Quantity - 4); } else if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 8 && m_Bandage.Amount <= 80) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 71) { bev.Quantity = (bev.Quantity - 8); } else if (m_Bandage.Amount >= 61) { bev.Quantity = (bev.Quantity - 7); } else if (m_Bandage.Amount >= 51) { bev.Quantity = (bev.Quantity - 6); } else if (m_Bandage.Amount >= 41) { bev.Quantity = (bev.Quantity - 5); } else if (m_Bandage.Amount >= 31) { bev.Quantity = (bev.Quantity - 4); } else if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 7 && m_Bandage.Amount <= 70) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 61) { bev.Quantity = (bev.Quantity - 7); } else if (m_Bandage.Amount >= 51) { bev.Quantity = (bev.Quantity - 6); } else if (m_Bandage.Amount >= 41) { bev.Quantity = (bev.Quantity - 5); } else if (m_Bandage.Amount >= 31) { bev.Quantity = (bev.Quantity - 4); } else if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 6 && m_Bandage.Amount <= 60) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 51) { bev.Quantity = (bev.Quantity - 6); } else if (m_Bandage.Amount >= 41) { bev.Quantity = (bev.Quantity - 5); } else if (m_Bandage.Amount >= 31) { bev.Quantity = (bev.Quantity - 4); } else if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 5 && m_Bandage.Amount <= 50) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 41) { bev.Quantity = (bev.Quantity - 5); } else if (m_Bandage.Amount >= 31) { bev.Quantity = (bev.Quantity - 4); } else if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 4 && m_Bandage.Amount <= 40) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 31) { bev.Quantity = (bev.Quantity - 4); } else if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 3 && m_Bandage.Amount <= 30) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 21) { bev.Quantity = (bev.Quantity - 3); } else if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 2 && m_Bandage.Amount <= 20) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } if (m_Bandage.Amount >= 11) { bev.Quantity = (bev.Quantity - 2); } else if (m_Bandage.Amount >= 1) { bev.Quantity = (bev.Quantity - 1); } from.SendMessage("Some of the water in the container has been depleted."); m_Bandage.Amount = 1; m_Bandage.Consume(); } else if (bev.Quantity == 1 && m_Bandage.Amount <= 10) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } from.SendMessage("Some of the water in the container has been depleted."); bev.Quantity = (bev.Quantity - 1); m_Bandage.Amount = 1; m_Bandage.Consume(); } else { from.SendMessage("There isn't enough water in that to wash with."); } } else { from.SendMessage("You can only wash bloody bandages in water."); } } else { from.SendMessage("You can only wash bloody bandages in water."); } } else if (targeted == c) { if ((c.TileID >= 168 && c.TileID <= 171) || (c.TileID >= 310 && c.TileID <= 311)) { int amount = m_Bandage.Amount; from.AddToBackpack(new Bandage(amount)); if (m_Bandage.Amount > 1) { from.SendMessage("You wash {0} bloody bandages and put the clean bandages in your pack.", amount); } else { from.SendMessage("You wash the bloody bandage and put the clean bandage in your pack."); } m_Bandage.Amount = 1; m_Bandage.Consume(); } else { from.SendMessage("You can only wash bloody bandages in water."); } } else { from.SendMessage("You can only wash bloody bandages in water."); } }
private bool ProcessTarget() { Target targ = m_Mobile.Target; if (targ == null) { return(false); } bool isReveal = (targ is RevealSpell.InternalTarget); bool isDispel = (targ is DispelSpell.InternalTarget); bool isParalyze = (targ is ParalyzeSpell.InternalTarget); bool isTeleport = (targ is TeleportSpell.InternalTarget); bool isInvisible = (targ is InvisibilitySpell.InternalTarget); bool teleportAway = false; Mobile toTarget = null; if (isInvisible) { toTarget = m_Mobile; } else if (isDispel) { toTarget = FindDispelTarget(false); if (!SmartAI && toTarget != null) { RunTo(toTarget); } else if (toTarget != null && m_Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); } } else if (SmartAI && (isParalyze || isTeleport)) { toTarget = FindDispelTarget(true); if (toTarget == null) { //Fixed, only running to combatants that are visible and within range. if (m_Mobile.Combatant != null && m_Mobile.CanSee(m_Mobile.Combatant) && m_Mobile.InRange(m_Mobile.Combatant, 10)) { RunTo(m_Mobile.Combatant); } } else if (m_Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); teleportAway = true; } else { teleportAway = true; } } else { if (m_Mobile.Combatant != null && m_Mobile.CanSee(m_Mobile.Combatant)) { if (m_Mobile.InRange(m_Mobile.Combatant, 10)) { toTarget = m_Mobile.Combatant; } if (m_Mobile.Combatant != null) { RunTo(m_Mobile.Combatant); } } } if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) { targ.Invoke(m_Mobile, toTarget); } else if (isDispel) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { targ.Invoke(m_Mobile, m_Mobile); } /*else if( isReveal && m_RevealTarget != null ) * { * targ.Invoke( m_Mobile, m_RevealTarget ); * }*/ else if (isTeleport && toTarget != null) { Map map = m_Mobile.Map; if (map == null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); return(true); } int px, py; if (teleportAway) { int rx = m_Mobile.X - toTarget.X; int ry = m_Mobile.Y - toTarget.Y; double d = m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(m_Mobile, lt); return(true); } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = m_Mobile.EraML ? 11 : 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); return(true); } } targ.Cancel(m_Mobile, TargetCancelType.Canceled); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } return(true); }
protected override void OnTarget(Mobile from, object targeted) { LandTarget land = targeted as LandTarget; PlayerMobile pm = from as PlayerMobile; if (pm == null) { return; } if (from.Skills[SkillName.Tinkering].Value < 60.0) { from.SendLocalizedMessage(1113318); // You do not have enough skill to set the trap. } else if (IsAssembling(from)) { from.SendLocalizedMessage(1113317); // You can only build one trap at a time. } else if (m_Trap.Deleted || !m_Trap.IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1113316); // You don't have the trap. } else if (from.Flying || from.Mounted) { from.SendLocalizedMessage(1113319); // You cannot set the trap while riding or flying. } else if (land == null) { from.SendLocalizedMessage(1113311); // There is something in the way. } else if (pm.FloorTrapsPlaced >= 7) { from.SendLocalizedMessage(1113312); // You have the maximum number of traps active (limit 7). Remove one or wait for one to expire before trying again. } else if (!CheckItems(land.Location, from.Map, 0, 1, false)) { from.SendLocalizedMessage(1113311); // There is something in the way. } else if (!CheckItems(land.Location, from.Map, 20, 7, true)) { from.SendLocalizedMessage(1113320); // There are too many traps in this area (limit 7). } else if (!CheckItems(land.Location, from.Map, 40, 14, true)) { from.SendLocalizedMessage(1113313); // There are too many traps in this area (limit 14). } else { from.PlaySound(0x241); from.SendLocalizedMessage(1113295); // You begin assembling the goblin trap. Timer t = Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback( delegate { if (m_Trap.Deleted || !m_Trap.IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1113316); // You don't have the trap. } else { from.SendLocalizedMessage(1113294); // You carefully arm the goblin trap. from.SendLocalizedMessage(1113297); // You hide the trap to the best of your ability. FloorTrap trap = new FloorTrap(from.Skills[SkillName.Tinkering].Value, from.Skills[SkillName.Hiding].Value, from); trap.Map = from.Map; trap.MoveToWorld(land.Location); from.PlaySound(0x22F); Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerCallback(delegate { trap.Visible = false; })); m_Trap.Consume(); pm.FloorTrapsPlaced++; } m_Assembling.Remove(from); })); m_Assembling.Add(from, t); } }
private void ProcessTarget(Target targ) { bool isDispel = (targ is DispelSpell.InternalTarget); bool isParalyze = (targ is ParalyzeSpell.InternalTarget); bool isTeleport = (targ is TeleportSpell.InternalTarget); bool isFireField = (targ is FireFieldSpell.InternalTarget); bool isPoisonField = (targ is PoisonFieldSpell.InternalTarget); bool teleportAway = false; Mobile toTarget; if (isDispel) { toTarget = FindDispelTarget(false); if (toTarget != null) { RunTo(toTarget); } else if (toTarget != null && m_Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); } } else if (isParalyze || isTeleport) { toTarget = FindDispelTarget(true); if (toTarget == null) { toTarget = m_Mobile.Combatant; if (toTarget != null) { RunTo(toTarget); } } else if (toTarget != null && m_Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); teleportAway = true; } else { teleportAway = true; } } else { toTarget = m_Mobile.Combatant; if (toTarget != null) { RunTo(toTarget); } } if ((toTarget != null && ((targ.Flags & TargetFlags.Harmful) != 0) || (isPoisonField || isFireField))) { //Check switch to target ally's target foreach (Mobile m in m_Mobile.GetMobilesInRange(HiveRange)) { if ((m_Mobile != m && m_Mobile.InLOS(m) && !SpellHelper.ValidIndirectTarget(m_Mobile, m) && ((!(m is BaseCreature)) || ((BaseCreature)m_Mobile).Team == ((BaseCreature)m).Team) && m.Combatant != null && Utility.RandomDouble() < AllySwitchChance) && (targ.Range == -1 || m_Mobile.InRange(m.Combatant, targ.Range)) && m_Mobile.CanSee(m.Combatant) && m_Mobile.InLOS(m.Combatant)) { m_Mobile.Combatant = m.Combatant; toTarget = m.Combatant; break; } } //check switch to target's owner if (toTarget is BaseCreature && ((BaseCreature)toTarget).Controlled && ((BaseCreature)toTarget).ControlMaster != null && Utility.RandomDouble() < PetSwitchChance && ((targ.Range == -1 || m_Mobile.InRange(((BaseCreature)toTarget).ControlMaster, targ.Range)) && m_Mobile.CanSee(((BaseCreature)toTarget).ControlMaster) && m_Mobile.InLOS(((BaseCreature)toTarget).ControlMaster))) { targ.Invoke(m_Mobile, ((BaseCreature)toTarget).ControlMaster); } if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) { targ.Invoke(m_Mobile, toTarget); } else if (isDispel) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { if (m_Mobile.Hits < HealPercent) { targ.Invoke(m_Mobile, m_Mobile); } else { bool Invoked = false; foreach (Mobile m in m_Mobile.GetMobilesInRange(HiveRange)) { if (WillHeal(m)) { targ.Invoke(m_Mobile, m); Invoked = true; break; } } if (!Invoked) { targ.Invoke(m_Mobile, m_Mobile); } } } else if (isTeleport && toTarget != null) { Map map = m_Mobile.Map; if (map == null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); return; } int px, py; if (teleportAway) { int rx = m_Mobile.X - toTarget.X; int ry = m_Mobile.Y - toTarget.Y; double d = m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(m_Mobile, lt); return; } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); return; } } targ.Cancel(m_Mobile, TargetCancelType.Canceled); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } }
private void TryToTeleport() { Mobile m = FindNearestAggressor(); if (m == null || m.Map == null || m_Mobile.Map == null) { return; } if (m_Mobile.GetDistanceToSqrt(m) > m_Mobile.RangePerception + 1) { return; } int px = m_Mobile.X; int py = m_Mobile.Y; int dx = m_Mobile.X - m.X; int dy = m_Mobile.Y - m.Y; // get vector's length double l = Math.Sqrt((dx * dx + dy * dy)); if (l == 0) { int rand = Utility.Random(8) + 1; rand *= 2; dx = m_Offsets[rand]; dy = m_Offsets[rand + 1]; l = Math.Sqrt((dx * dx + dy * dy)); } // normalize vector double dpx = (dx) / l; double dpy = (dy) / l; // move px += (int)(dpx * (4 + Utility.Random(3))); py += (int)(dpy * (4 + Utility.Random(3))); for (int i = 0; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, m_Mobile.Map); if (m_Mobile.InLOS(lt) && m_Mobile.Map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, m_Mobile.Map)) { m_Mobile.FixedParticles(0x376A, 9, 32, 0x13AF, EffectLayer.Waist); m_Mobile.PlaySound(0x1FE); m_Mobile.Location = new Point3D(lt.X, lt.Y, lt.Z); m_Mobile.ProcessDelta(); return; } } }
protected override void OnTarget(Mobile from, object to) { LandTarget toLand = to as LandTarget; StaticTarget toStatic = to as StaticTarget; if ((null != toLand && toLand.Name == JailConfig.WhatToMine) || (null != toStatic && toStatic.Name == JailConfig.WhatToMine)) { from.Animate(9, 1, 1, true, false, 0); from.PlaySound(0x145); JailHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as JailHammer; if (null != hammer) { if (Utility.RandomMinMax(0, 101) >= hammer.Difficulty) { from.SendMessage("The {0} crumbles under your hammer.", JailConfig.WhatToMine); from.AddToBackpack(new JailRock()); } else { from.SendMessage("You did not swing hard enough."); } } } else if (to is PlayerMobile) { from.Animate(9, 1, 1, true, false, 0); from.PlaySound(0x145); PlayerMobile toPlayer = to as PlayerMobile; if (toPlayer == from) { from.Say("Ouch, I hit myself with my hammer!"); } else { from.SendMessage("You hit " + toPlayer.Name + " with your hammer!"); toPlayer.SendMessage(from.Name + " has hit you with a hammer!"); toPlayer.Say("Ouch"); JailHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as JailHammer; if (null != hammer) { hammer.UsesRemaining++; } } } else if (to is Mobile) { Mobile toMobile = to as JailSlaveDriver; if (null != toMobile) { from.Animate(9, 1, 1, true, false, 0); from.PlaySound(0x145); toMobile.Say("How dare you!, You\'ll pay with your life!"); from.Criminal = true; toMobile.Combatant = from; } else { from.SendMessage("You dont think they would like that very much."); } } else { from.SendMessage("You should try breaking up some {0} with your hammer!", JailConfig.WhatToMine); } }
public static bool IsWater(this LandTarget targ) { return(LandWaterTiles.Contains(targ.TileID) || TileData.LandTable[targ.TileID].Flags.HasFlag(TileFlag.Wet) || Insensitive.Contains(TileData.LandTable[targ.TileID].Name, "water")); }
private void ProcessTarget(Target targ) { bool isDispel = (targ is MassDispelSpell.InternalTarget || targ is DispelSpell.InternalTarget); bool isParalyze = (targ is ParalyzeSpell.InternalTarget); bool isTeleport = (targ is TeleportSpell.InternalTarget); bool isFireField = (targ is FireFieldSpell.InternalTarget); bool isPoisonField = (targ is PoisonFieldSpell.InternalTarget); bool teleportAway = false; Mobile toTarget; if (isDispel) { toTarget = FindDispelTarget(false); if (toTarget != null) { RunTo(toTarget); } /* * else if ( toTarget != null && m_Mobile.InRange( toTarget, 10 ) ) * RunFrom( toTarget ); */ } else if (isParalyze || isTeleport) { toTarget = FindDispelTarget(true); if (toTarget == null) { toTarget = m_Mobile.Combatant; if (toTarget != null) { RunTo(toTarget); } } else if (toTarget != null && m_Mobile.InRange(toTarget, 10)) { RunFrom(toTarget); teleportAway = true; } else { teleportAway = true; } } else { toTarget = m_Mobile.Combatant; if (toTarget != null) { RunTo(toTarget); } } if ((toTarget != null && (((targ.Flags & TargetFlags.Harmful) != 0) || (isPoisonField || isFireField)))) { /* * //check switch to target's owner * if (toTarget is BaseCreature && * ((BaseCreature)toTarget).Controlled && * ((BaseCreature)toTarget).ControlMaster != null && * Utility.RandomDouble() < PetSwitchChance && * ((targ.Range == -1 || (targ != null && m_Mobile.InRange(((BaseCreature)toTarget).ControlMaster, targ.Range))) && * m_Mobile.CanSee(((BaseCreature)toTarget).ControlMaster) && * m_Mobile.InLOS(((BaseCreature)toTarget).ControlMaster))) * { * targ.Invoke(m_Mobile, ((BaseCreature)toTarget).ControlMaster); * }*/ if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) { targ.Invoke(m_Mobile, toTarget); } else if (isDispel) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { targ.Invoke(m_Mobile, m_Mobile); } else if (isTeleport && toTarget != null) { Map map = m_Mobile.Map; if (map == null) { targ.Cancel(m_Mobile, TargetCancelType.Canceled); return; } int px, py; if (teleportAway) { int rx = m_Mobile.X - toTarget.X; int ry = m_Mobile.Y - toTarget.Y; double d = m_Mobile.GetDistanceToSqrt(toTarget); px = toTarget.X + (int)(rx * (10 / d)); py = toTarget.Y + (int)(ry * (10 / d)); } else { px = toTarget.X; py = toTarget.Y; } for (int i = 0; i < m_Offsets.Length; i += 2) { int x = m_Offsets[i], y = m_Offsets[i + 1]; Point3D p = new Point3D(px + x, py + y, 0); LandTarget lt = new LandTarget(p, map); if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map)) { targ.Invoke(m_Mobile, lt); return; } } int teleRange = targ.Range; if (teleRange < 0) { teleRange = 12; } for (int i = 0; i < 10; ++i) { Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0); LandTarget lt = new LandTarget(randomPoint, map); if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map)) { targ.Invoke(m_Mobile, new LandTarget(randomPoint, map)); return; } } targ.Cancel(m_Mobile, TargetCancelType.Canceled); } else { targ.Cancel(m_Mobile, TargetCancelType.Canceled); } }