public void Message(string Message, ChatType Type, Color Color, string From = "SYSTEM", string To = "ALLUSERS") { Chat *Packet = PacketHelper.CreateChat(From, To, Message); Packet->ChatType = Type; Packet->ID = Entity.UID; Packet->Color = (uint)Color.ToArgb(); Send(Packet, Packet->Size); Memory.Free(Packet); }
public void EndStatusUpdates() { lock (PendingUpdates) { StatusUpdateEntry[] Entries = PendingUpdates.Values.ToArray(); StatusUpdate * Update = PacketHelper.UpdatePacket(Entries); Update->UID = UID; Owner.Send(Update, Update->Size); Memory.Free(Update); PendingUpdates.Clear(); } }
public void Teleport(ushort MapID, ushort X, ushort Y) { if (Kernel.IsWalkable(MapID, X, Y)) { GeneralData *Packet = PacketHelper.AllocGeneral(); if (Entity.Location.MapID == MapID && ConquerMath.CalculateDistance(X, Y, Entity.Location.X, Entity.Location.Y, true) < Kernel.ScreenView) { // Teleporting within Kernel.ScreenView distance. Don't remove entity from other players. Send "Jump" packet instead Packet->DataID = GeneralDataID.Jump; Packet->UID = Entity.UID; Packet->ValueA = Entity.Location.X; Packet->ValueB = Entity.Location.Y; Packet->ValueD_High = X; Packet->ValueD_Low = Y; Entity.Location.MapID = MapID; Entity.Location.X = X; Entity.Location.Y = Y; SendScreen(Packet, Packet->Size, true); } else { Packet->UID = Entity.UID; Packet->DataID = GeneralDataID.RemoveEntity; SendScreen(Packet, Packet->Size); } Packet = PacketHelper.ReAllocGeneral(Packet); Packet->UID = Entity.UID; Packet->DataID = GeneralDataID.ChangeMap; Packet->ValueA = X; Packet->ValueB = Y; Packet->ValueD_High = MapID; Entity.Location.MapID = MapID; Entity.Location.X = X; Entity.Location.Y = Y; Send(Packet, Packet->Size); Memory.Free(Packet); } else { Message(string.Format("Can't teleport to MapID: {0} X {1} Y {2}.", MapID, X, Y), ChatType.Center, Color.White); return; } }
public void RemoveFromScreen() { GeneralData *Packet = PacketHelper.AllocGeneral(); Packet->UID = Entity.UID; Packet->DataID = GeneralDataID.RemoveEntity; SendScreen(Packet, Packet->Size); Entity[] Entities = Screen.Players; Parallel.ForEach(Entities, (entity) => { entity.Owner.Screen.Remove(Entity); }); Memory.Free(Packet); }
public bool Add(Entity Entity) { lock (PlayerDictionary) { if (!PlayerDictionary.ContainsKey(Entity.UID)) { EntitySpawn Spawn = PacketHelper.EntitySpawn(Entity); Client.Send(&Spawn, Spawn.Size); PlayerDictionary.Add(Entity.UID, Entity); Entity[] tmp = new Entity[PlayerDictionary.Count]; PlayerDictionary.Values.CopyTo(tmp, 0); ScreenPlayers = tmp; return(true); } } return(false); }
public override void Execute(GameClient Client, byte *pPacket) { AuthMessage *Message = (AuthMessage *)pPacket; uint Token = Message->AccountID | 0xAABB; Token = Message->AccountID << 8 | Message->AccountID; Token = Token ^ 0x4321; Token = Token << 8 | Token; if (Token == Message->LoginToken) { Client.UID = Message->AccountID; Client.GenerateKeys(Message->LoginToken, Message->AccountID); if (Database.GetCharacterData(Client)) { Chat *Response = PacketHelper.CreateChat("SYSTEM", "ALLUSERS", "ANSWER_OK"); Response->ChatType = ChatType.LoginInformation; Response->ID = Message->AccountID; Client.Send(Response, Response->Size); Memory.Free(Response); CharacterInformation *Information = PacketHelper.CreateInformation(Client); Client.Send(Information, Information->Size); Memory.Free(Information); EntityManager.Add(Client); Client.Status = LoginStatus.Complete; } else { Chat *Response = PacketHelper.CreateChat("SYSTEM", "ALLUSERS", "NEW_ROLE"); Response->ChatType = ChatType.LoginInformation; Response->ID = Message->AccountID; Client.Send(Response, Response->Size); Memory.Free(Response); } } else { Client.Disconnect(); } }
public override void Execute(GameClient Client, byte *pPacket) { AttackRequest *Request = (AttackRequest *)pPacket; if (Request->AttackType == AttackTypes.Magic) { Request->Decrypt(); if (Request->SpellID == 1045) { AttackTargetPacket *Packet = PacketHelper.AttackPacket(); Packet->UID = Client.Entity.UID; Packet->SpellID = 1045; Packet->SpellLevel = 4; Packet->X = Request->TargetX; Packet->Y = Request->TargetY; Client.SendScreen(Packet, Packet->Size, true); Memory.Free(Packet); } } }
public override void Execute(GameClient Client, byte *pPacket) { Chat *Packet = (Chat *)pPacket; string[] Parameters = PacketHelper.ParseChat(Packet); CommandAction Action = CommandAction.None; if ((Action = CommandProcessor.Process(Client, Parameters)) != CommandAction.None) { if (Action == CommandAction.Processed) { } else if (Action == CommandAction.ClearNpcScripts) { NpcScriptEngine.Clear(); } return; } switch (Packet->ChatType) { case ChatType.Talk: Client.SendScreen(Packet, Packet->Size); break; case ChatType.Whisper: GameClient Receiver = EntityManager.FindByName(Parameters[1]); if (Receiver != null) { Receiver.Send(Packet, Packet->Size); } else { Client.Message("It appears that " + Parameters[1] + " is offline", ChatType.Top, Color.White); } break; } }
public override EntitySpawn GetSpawnPacket() { return(PacketHelper.EntitySpawn(this)); }