public void SendInitWorldStates(ref WS_Network.ClientClass client, ref WS_PlayerData.CharacterObject Character) { Character.ZoneCheck(); ushort NumberOfFields; switch (Character.ZoneID) { case 0: case 1: case 4: case 8: case 10: case 11: case 12: case 36: case 38: case 40: case 41: case 51: case 267: case 1519: case 1537: case 2257: case 2918: NumberOfFields = 6; break; case 2597: NumberOfFields = 81; break; case 3277: NumberOfFields = 14; break; case 3358: case 3820: NumberOfFields = 38; break; case 3483: NumberOfFields = 22; break; case 3519: NumberOfFields = 36; break; case 3521: NumberOfFields = 35; break; case 3698: case 3702: case 3968: NumberOfFields = 9; break; case 3703: NumberOfFields = 9; break; default: NumberOfFields = 10; break; } Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_INIT_WORLD_STATES); try { packet.AddUInt32(Character.MapID); packet.AddInt32(Character.ZoneID); packet.AddInt32(Character.AreaID); packet.AddUInt16(NumberOfFields); packet.AddUInt32(2264u); packet.AddUInt32(0u); packet.AddUInt32(2263u); packet.AddUInt32(0u); packet.AddUInt32(2262u); packet.AddUInt32(0u); packet.AddUInt32(2261u); packet.AddUInt32(0u); packet.AddUInt32(2260u); packet.AddUInt32(0u); packet.AddUInt32(2259u); packet.AddUInt32(0u); switch (Character.ZoneID) { case 3968: packet.AddUInt32(3000u); packet.AddUInt32(0u); packet.AddUInt32(3001u); packet.AddUInt32(0u); packet.AddUInt32(3002u); packet.AddUInt32(0u); break; default: packet.AddUInt32(2324u); packet.AddUInt32(0u); packet.AddUInt32(2323u); packet.AddUInt32(0u); packet.AddUInt32(2322u); packet.AddUInt32(0u); packet.AddUInt32(2325u); packet.AddUInt32(0u); break; case 1: case 11: case 12: case 38: case 40: case 51: case 1519: case 1537: case 2257: case 2597: case 3277: case 3358: case 3820: break; } client.Send(ref packet); } finally { packet.Dispose(); } }
public void GoToNearestGraveyard(ref WS_PlayerData.CharacterObject Character, bool Alive, bool Teleport) { DataTable GraveQuery = new DataTable(); bool foundNear = false; float distNear = 0f; TGraveyard entryNear = default; TGraveyard entryFar = default; checked { if (WorldServiceLocator._WS_Maps.Maps[Character.MapID].IsDungeon | WorldServiceLocator._WS_Maps.Maps[Character.MapID].IsBattleGround | WorldServiceLocator._WS_Maps.Maps[Character.MapID].IsRaid) { Character.ZoneCheckInstance(); int Ghostzone = WorldServiceLocator._WS_Maps.AreaTable[WorldServiceLocator._WS_Maps.GetAreaIDByMapandParent((int)Character.MapID, WorldServiceLocator._WS_Maps.AreaTable[WorldServiceLocator._WS_Maps.GetAreaFlag(Character.resurrectPositionX, Character.resurrectPositionY, (int)Character.MapID)].Zone)].ID; WorldServiceLocator._WorldServer.WorldDatabase.Query($"SELECT id, faction FROM game_graveyard_zone WHERE ghost_zone = {Ghostzone} and (faction = 0 or faction = {Character.Team}) ", ref GraveQuery); if (GraveQuery.Rows.Count == 0) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.INFORMATION, "GraveYards: No near graveyards for map [{0}], zone [{1}]", Character.MapID, Character.ZoneID); return; } if (WorldServiceLocator._WS_Maps.Maps[Character.MapID].IsDungeon | WorldServiceLocator._WS_Maps.Maps[Character.MapID].IsBattleGround | WorldServiceLocator._WS_Maps.Maps[Character.MapID].IsRaid) { if (Graveyards.ContainsKey(Conversions.ToInteger(GraveQuery.Rows[0]["id"]))) { entryFar = Graveyards[Conversions.ToInteger(GraveQuery.Rows[0]["id"])]; entryNear = entryFar; } else { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.INFORMATION, "GraveYard: {0} is missing for map [{1}], zone [{2}]", GraveQuery.Rows[0]["id"], Character.MapID, Character.ZoneID); } } else { IEnumerator enumerator = default; try { enumerator = GraveQuery.Rows.GetEnumerator(); while (enumerator.MoveNext()) { DataRow row = (DataRow)enumerator.Current; int GraveyardID2 = row.As <int>("id"); int GraveyardFaction2 = row.As <int>("faction"); if (!Graveyards.ContainsKey(GraveyardID2)) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.INFORMATION, "GraveYards: Graveyard link invalid [{0}]", GraveyardID2); } else if (Character.MapID != Graveyards[GraveyardID2].Map) { if (Information.IsNothing(entryFar)) { entryFar = Graveyards[GraveyardID2]; } } else { if (GraveyardFaction2 != 0 && GraveyardFaction2 != Character.Team) { continue; } float dist3 = WorldServiceLocator._WS_Combat.GetDistance(Character.positionX, Graveyards[GraveyardID2].X, Character.positionY, Graveyards[GraveyardID2].Y, Character.positionZ, Graveyards[GraveyardID2].Z); if (foundNear) { if (dist3 < distNear) { distNear = dist3; entryNear = Graveyards[GraveyardID2]; } } else { foundNear = true; distNear = dist3; entryNear = Graveyards[GraveyardID2]; } } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } } TGraveyard selectedGraveyard2 = entryNear; if (Information.IsNothing(selectedGraveyard2)) { selectedGraveyard2 = entryFar; } WorldServiceLocator._WorldServer.Log.WriteLine(LogType.INFORMATION, "GraveYards: GraveYard.Map[{0}], GraveYard.X[{1}], GraveYard.Y[{2}], GraveYard.Z[{3}]", selectedGraveyard2.Map, selectedGraveyard2.X, selectedGraveyard2.Y, selectedGraveyard2.Z); Character.Teleport(selectedGraveyard2.X, selectedGraveyard2.Y, selectedGraveyard2.Z, 0f, selectedGraveyard2.Map); Character.SendDeathReleaseLoc(selectedGraveyard2.X, selectedGraveyard2.Y, selectedGraveyard2.Z, selectedGraveyard2.Map); return; } Character.ZoneCheck(); WorldServiceLocator._WorldServer.WorldDatabase.Query($"SELECT id, faction FROM game_graveyard_zone WHERE ghost_zone = {Character.ZoneID}", ref GraveQuery); if (GraveQuery.Rows.Count == 0) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.INFORMATION, "GraveYards: No near graveyards for map [{0}], zone [{1}]", Character.MapID, Character.ZoneID); return; } IEnumerator enumerator2 = default; try { enumerator2 = GraveQuery.Rows.GetEnumerator(); while (enumerator2.MoveNext()) { DataRow row = (DataRow)enumerator2.Current; int GraveyardID = row.As <int>("id"); int GraveyardFaction = row.As <int>("faction"); if (!Graveyards.ContainsKey(GraveyardID)) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.INFORMATION, "GraveYards: Graveyard link invalid [{0}]", GraveyardID); } else if (Character.MapID != Graveyards[GraveyardID].Map) { if (Information.IsNothing(entryFar)) { entryFar = Graveyards[GraveyardID]; } } else { if (GraveyardFaction != 0 && GraveyardFaction != Character.Team) { continue; } float dist2 = WorldServiceLocator._WS_Combat.GetDistance(Character.positionX, Graveyards[GraveyardID].X, Character.positionY, Graveyards[GraveyardID].Y, Character.positionZ, Graveyards[GraveyardID].Z); if (foundNear) { if (dist2 < distNear) { distNear = dist2; entryNear = Graveyards[GraveyardID]; } } else { foundNear = true; distNear = dist2; entryNear = Graveyards[GraveyardID]; } } } } finally { if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } TGraveyard selectedGraveyard = entryNear; if (Information.IsNothing(selectedGraveyard)) { selectedGraveyard = entryFar; } if (Teleport) { if (Alive & Character.DEAD) { WorldServiceLocator._WS_Handlers_Misc.CharacterResurrect(ref Character); Character.Life.Current = Character.Life.Maximum; if (Character.ManaType == ManaTypes.TYPE_MANA) { Character.Mana.Current = Character.Mana.Maximum; } if (selectedGraveyard.Map == Character.MapID) { Character.SetUpdateFlag(22, Character.Life.Current); if (Character.ManaType == ManaTypes.TYPE_MANA) { Character.SetUpdateFlag(23, Character.Mana.Current); } Character.SendCharacterUpdate(); } } WorldServiceLocator._WorldServer.Log.WriteLine(LogType.INFORMATION, "GraveYards: GraveYard.Map[{0}], GraveYard.X[{1}], GraveYard.Y[{2}], GraveYard.Z[{3}]", selectedGraveyard.Map, selectedGraveyard.X, selectedGraveyard.Y, selectedGraveyard.Z); Character.Teleport(selectedGraveyard.X, selectedGraveyard.Y, selectedGraveyard.Z, 0f, selectedGraveyard.Map); Character.SendDeathReleaseLoc(selectedGraveyard.X, selectedGraveyard.Y, selectedGraveyard.Z, selectedGraveyard.Map); } else { Character.positionX = selectedGraveyard.X; Character.positionY = selectedGraveyard.Y; Character.positionZ = selectedGraveyard.Z; Character.MapID = (uint)selectedGraveyard.Map; } } }