/// <summary> /// Teleports the client to a specific place. /// </summary> /// <param name="map">The map to teleport to.</param> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> /// <returns>Returns true if the client was teleported.</returns> public bool Teleport(Maps.Map map, ushort x, ushort y, bool isdynamic = false) { if (!Core.Kernel.Maps.Contains(map.MapID) && !isdynamic) return false; Maps.Map lMap = Map; if (!lMap.LeaveMap(this)) return false; if (DynamicMap != null) { LeaveDynamicMap(false); } DynamicMap = null; ushort lastmap = lMap.MapID; if (!map.EnterMap(this)) return false; if (isdynamic) DynamicMap = (Maps.DynamicMap)map; AttackPacket = null; RemoveFlag1(Enums.Effect1.Riding); ushort SendMap = map.InheritanceMap; Send(new Packets.GeneralDataPacket() { Id = EntityUID, Data1 =SendMap, Data2 = 0, Timestamp = ProjectX_V3_Lib.Time.SystemTime.Now, Action = Enums.DataAction.Teleport, Data3Low = x, Data3High = y, Data4 = 0, Data5 = 0, }); Send(new Packets.GeneralDataPacket() { Id = EntityUID, Data1 = SendMap, Data2 = 0, Timestamp = ProjectX_V3_Lib.Time.SystemTime.Now, Action = Enums.DataAction.ChangeMap, Data3Low = x, Data3High = y, Data4 = 0, Data5 = 0, }); using (var mapinfo = new Packets.MapInfoPacket()) { mapinfo.MapID = SendMap; mapinfo.DocID = SendMap; foreach (Enums.MapTypeFlags flag in map.Flags.Values) mapinfo.AddFlag(flag); mapinfo.Finish(); this.Send(mapinfo); } if (lMap.MapType != Enums.MapType.Tournament) { LastMapID = lastmap; LastMapX = X; LastMapY = Y; } X = x; Y = y; if (lMap.MapType != Enums.MapType.Tournament) { Database.CharacterDatabase.UpdateCharacter(this, "PlayerLastMapID", lastmap); } if (!isdynamic && Map.MapType != Enums.MapType.Tournament) { Database.CharacterDatabase.UpdateCharacter(this, "PlayerMapID", Map.MapID); Database.CharacterDatabase.UpdateCharacter(this, "PlayerX", X); Database.CharacterDatabase.UpdateCharacter(this, "PlayerY", Y); } #region Clear using (var clear = Packets.Message.MessageCore.ClearScore()) { this.Send(clear); } #endregion return true; }