Warp() public method

Warps creature to target location, returns false if warp is unsuccessful.
public Warp ( Location loc ) : bool
loc Location
return bool
Ejemplo n.º 1
0
		/// <summary>
		/// Completes skill, teleporting behind target.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		public void Complete(Creature creature, Skill skill, Packet packet)
		{
			var target = creature.Target;
			if (target != null)
			{
				var pos = creature.GetPosition();
				var targetPos = target.GetPosition();
				var telePos = pos.GetRelative(targetPos, DistanceToTarget);

				Send.Effect(creature, Effect.SilentMoveTeleport, (byte)2, telePos.X, telePos.Y);
				creature.Warp(creature.RegionId, telePos);
			}

			Send.SkillComplete(creature, skill.Info.Id);
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Creates a dungeon with the given parameters and warps the creature's
		/// party inside.
		/// </summary>
		/// <param name="dungeonName"></param>
		/// <param name="itemId"></param>
		/// <param name="creature"></param>
		/// <returns></returns>
		public bool CreateDungeonAndWarp(string dungeonName, int itemId, Creature creature)
		{
			lock (_createAndCleanUpLock)
			{
				try
				{
					var dungeon = this.CreateDungeon(dungeonName, itemId, creature);
					var regionId = dungeon.Regions.First().Id;
					var pos = creature.GetPosition();

					creature.Warp(regionId, pos);

					return true;
				}
				catch (Exception ex)
				{
					Log.Exception(ex, "Failed to create and warp to dungeon.");
					return false;
				}
			}
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Completes skill, warping to destination.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="packet"></param>
		public void Complete(Creature creature, Skill skill, Packet packet)
		{
			var destination = (Continent)packet.GetByte();

			int regionId, x, y;
			switch (destination)
			{
				case Continent.Uladh:
					if (creature.Keywords.Has("portal_dunbarton"))
					{
						regionId = 14; x = 41598; y = 36010; // Dun
					}
					else
					{
						regionId = 1; x = 12789; y = 38399; // Tir
					}
					break;
				case Continent.Iria:
					regionId = 3001; x = 164837; y = 170144; // Qilla
					break;
				case Continent.Belvast:
					regionId = 4005; x = 41760; y = 26924; // Belvast
					break;
				default:
					Send.Notice(creature, "Unknown destination.");
					Send.SkillCancel(creature);
					return;
			}

			creature.Warp(regionId, x, y);

			Send.SkillComplete(creature, skill.Info.Id, (byte)destination);
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Warps creature, based on the item's properties.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="item"></param>
		/// <returns>Whether a warp happened or not.</returns>
		public static bool Warp(Creature creature, Item item)
		{
			if (creature == null)
				throw new ArgumentNullException("creature");

			if (item == null)
				throw new ArgumentNullException("item");

			// Check meta data
			if (!item.MetaData1.Has("TARGET"))
			{
				Send.ServerMessage(creature, Localization.Get("No target found."));
				return false;
			}

			// Get target
			var target = item.MetaData1.GetString("TARGET");

			// Get location based on target
			Location loc;
			if (target.StartsWith("pos")) // pos@regionId,x,y
			{
				var match = Regex.Match(target, @"pos@(?<regionId>[0-9]+),(?<x>[0-9]+),(?<y>[0-9]+)");
				if (!match.Success)
				{
					Log.Warning("HiddenTownBack: Invalid position target: {0}", target);
					Send.ServerMessage(creature, Localization.Get("Invalid target."));
					return false;
				}

				loc.RegionId = Convert.ToInt32(match.Groups["regionId"].Value);
				loc.X = Convert.ToInt32(match.Groups["x"].Value);
				loc.Y = Convert.ToInt32(match.Groups["y"].Value);
			}
			else if (target.StartsWith("portal")) // portal@name
			{
				// Remove "portal@" prefix
				target = target.Substring(7).Trim();

				// Get portal data
				var portalData = AuraData.PortalDb.Find(target);
				if (portalData == null)
				{
					Log.Warning("HiddenTownBack: Unknown target: {0}", target);
					Send.ServerMessage(creature, Localization.Get("Unknown target."));
					return false;
				}

				// Get location
				try
				{
					loc = new Location(portalData.Location);
				}
				catch
				{
					Log.Warning("HiddenTownBack: Invalid portal location: {0}", target);
					Send.ServerMessage(creature, Localization.Get("Invalid portal location."));
					return false;
				}
			}
			else if (target == "last_town")
			{
				loc = new Location(creature.LastTown);
			}
			else
			{
				Log.Warning("HiddenTownBack: Unknown target type: {0}", target);
				Send.ServerMessage(creature, Localization.Get("Unknown target type."));
				return false;
			}

			// Warp
			creature.Warp(loc);

			return true;
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Checks if creature is able to enter a dungeon with the given item,
		/// at his current position, if so, a dungeon is created and the
		/// party is moved inside.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="item"></param>
		/// <returns></returns>
		public bool CheckDrop(Creature creature, Item item)
		{
			var currentRegionId = creature.RegionId;
			if (!_entryRegionIds.Contains(currentRegionId))
				return false;

			var pos = creature.GetPosition();

			var clientEvent = creature.Region.GetClientEvent(a => a.Data.IsAltar);
			if (clientEvent == null)
			{
				Log.Warning("DungeonManager.CheckDrop: No altar found.");
				return false;
			}

			if (!clientEvent.IsInside(pos.X, pos.Y))
			{
				// Tell player to step on altar?
				return false;
			}

			var parameter = clientEvent.Data.Parameters.FirstOrDefault(a => a.EventType == EventType.Altar);
			if (parameter == null || parameter.XML == null || parameter.XML.Attribute("dungeonname") == null)
			{
				Log.Warning("DungeonManager.CheckDrop: No dungeon name found in altar event '{0:X16}'.", clientEvent.EntityId);
				return false;
			}

			var dungeonName = parameter.XML.Attribute("dungeonname").Value.ToLower();

			// Check script
			var dungeonScript = ChannelServer.Instance.ScriptManager.DungeonScripts.Get(dungeonName);
			if (dungeonScript == null)
			{
				Send.ServerMessage(creature, "This dungeon hasn't been added yet.");
				Log.Warning("DungeonManager.CheckDrop: No routing dungeon script found for '{0}'.", dungeonName);
				return false;
			}

			// Check arenas
			if (dungeonScript.Name == "tircho_alby_dungeon" && item.HasTag("/alby_battle_arena/"))
			{
				creature.Warp(28, 1174, 795);
				return true;
			}

			// Check route
			if (!dungeonScript.Route(creature, item, ref dungeonName))
			{
				// The response in case of a fail is handled by the router.
				return false;
			}

			// Check party
			if (creature.IsInParty && creature.Party.Leader != creature)
			{
				// Unofficial
				Send.Notice(creature, Localization.Get("Only the leader may create the dungeon."));
				return false;
			}

			return this.CreateDungeonAndWarp(dungeonName, item.Info.Id, creature);
		}