private void HandleGetSurroundings(GameClient Client, GeneralData* Packet) { Database.LoadEquipment(Client); Client.Screen.Wipe(); Kernel.GetScreen(Client, ConquerCallbackKernel.GetScreenReply); }
private void HandleJumping(GameClient Client, GeneralData* Packet) { ushort X1 = Packet->ValueA; ushort Y1 = Packet->ValueB; if ((X1 != Client.Entity.Location.X) || (Y1 != Client.Entity.Location.Y)) { Client.Disconnect(); } else { ushort X2 = Packet->ValueD_High; ushort Y2 = Packet->ValueD_Low; Client.Entity.Angle = ConquerMath.GetAngle(Client.Entity.Location, new Location() { X = X2, Y = Y2 }); Client.Entity.Location.X = X2; Client.Entity.Location.Y = Y2; if (!Kernel.IsWalkable(Client.Entity.Location.MapID, Client.Entity.Location.X, Client.Entity.Location.Y)) { Client.Disconnect(); } else { Client.Send(Packet, Packet->Size); Client.SendScreen(Packet, Packet->Size); Kernel.GetScreen(Client, ConquerCallbackKernel.GetScreenReply); } } }
public static CharacterInformation *CreateInformation(GameClient Client) { byte[] Payload = StringPayload(Client.Entity.Name, Client.Entity.Spouse); int Size = 66 + Payload.Length; CharacterInformation* Packet = (CharacterInformation*)Memory.Alloc(Size); Packet->Size = (ushort)Size; Packet->Type = 0x3EE; Packet->ID = Client.Entity.UID; Packet->Model = Client.Entity.Model; Packet->HairStyle = Client.Entity.HairStyle; Packet->Gold = Client.Entity.Money; Packet->Experience = Client.Entity.Experience; Packet->StatPoints = Client.Entity.StatusPoints.Free; Packet->Strength = Client.Entity.StatusPoints.Strength; Packet->Dexterity = Client.Entity.StatusPoints.Dexterity; Packet->Vitality = Client.Entity.StatusPoints.Vitality; Packet->Spirit = Client.Entity.StatusPoints.Spirit; Packet->HitPoints = Client.Entity.HitPoints; Packet->ManaPoints = Client.Entity.ManaPoints; Packet->PKPoints = Client.Entity.PKPoints; Packet->Level = Client.Entity.Level; Packet->Class = Client.Entity.Class; Packet->Reborn = Client.Entity.Reborn; Packet->DisplayName = true; Packet->NameCount = 2; fixed (byte* pPayload = Payload) { Memory.Copy(pPayload, Packet->Names, Payload.Length); } return Packet; }
public void Initialize(GameClient Client) { NpcDialogBuilder.Avatar(Client, 1); NpcDialogBuilder.Text(Client, "NPC ID: " + Client.ActiveNPC + " has not been implemented yet."); NpcDialogBuilder.Option(Client, 0xFF, "Close"); NpcDialogBuilder.Finish(Client); }
public void Initialize(GameClient Client) { NpcDialogBuilder.Avatar(Client, 2); NpcDialogBuilder.Text(Client, "Do you wish to be teleported to arena?"); NpcDialogBuilder.Option(Client, 0x00, "Yes, please"); NpcDialogBuilder.Finish(Client); }
protected override ClientBase CreateClient(Socket socket) { GameClient client = new GameClient(); client.Accept(socket); return client; }
public void Process(GameClient Client, byte OptionID, string Input) { switch(OptionID) { case 0: Client.Teleport(1005, 51, 70); break; } }
public override void Execute(GameClient Client, byte* pPacket) { ItemUsage* Packet = (ItemUsage*)pPacket; switch (Packet->UsageID) { case ItemUsageIDs.Ping: Client.Send(Packet, Packet->Size); break; case ItemUsageIDs.Equip: HandleEquip(Client, Packet); break; case ItemUsageIDs.UnequipItem: HandleUnequip(Client, Packet); break; } }
public Screen(GameClient Client) { this.Client = Client; PlayerDictionary = new Dictionary<uint, Entity>(); NPCDictionary = new Dictionary<uint, NonPlayerCharacter>(); ScreenPlayers = new Entity[0]; ScreenNPCs = new NonPlayerCharacter[0]; }
private unsafe void HandleEquip(GameClient Client, ItemUsage* Packet) { ConquerItem Item; if (Client.TryGetInventory(Packet->ID, out Item)) { Item.Position = (ItemPosition)Packet->Location; Client.AddEquipment(Item, Item.Position); Client.RemoveInventory(Item); } }
private void HandleChangeAvatar(GameClient Client, GeneralData* Packet) { if (Client.Entity.Money >= 500) { Client.Entity.BeginStatusUpdates(); Client.Entity.Money -= 500; Client.Entity.Avatar = (byte)Packet->ValueD_High; Client.Entity.EndStatusUpdates(); } }
public override void Execute(GameClient Client, byte* pPacket) { CharacterCreation* Packet = (CharacterCreation*)pPacket; string Username = new string(Packet->Account, 0, 16).Trim('\x00'); string Name = new string(Packet->Name, 0, 16).Trim('\x00'); string Password = new string(Packet->Password, 0, 16).Trim('\x00'); Database.CreateCharacter(Client, Packet->Model, Packet->Class, Name); Client.Disconnect(); }
public static void GetScreen(GameClient Client, ConquerCallback Callback) { Client.Screen.Cleanup(); try { EntityManager.AcquireLock(); int Distance = -1; GameClient[] Clients = EntityManager.Clients; foreach (GameClient Other in Clients) { if (Other == null) continue; if (Other.UID == Client.UID) continue; if (Other.Entity.Location.MapID != Client.Entity.Location.MapID) continue; Distance = ConquerMath.CalculateDistance(Other.Entity.Location, Client.Entity.Location); if (Distance <= ScreenView) { if (Client.Screen.Add(Other.Entity)) { if (Callback != null) { Callback(Client.Entity, Other.Entity); } } } } NonPlayerCharacter[] NPCs = EntityManager.GetNonPlayingCharacters(Client.Entity.Location.MapID); if (NPCs != null) { foreach (NonPlayerCharacter npc in NPCs) { if (npc.Location.MapID != Client.Entity.Location.MapID) continue; Distance = ConquerMath.CalculateDistance(npc.Location, Client.Entity.Location); if (Distance <= ScreenView) { if (Client.Screen.Add(npc)) { NpcSpawn Spawn = npc.GetSpawnPacket(); Client.Send(&Spawn, Spawn.Size); } } } } } finally { EntityManager.ReleaseLock(); } }
private unsafe void HandleUnequip(GameClient Client, ItemUsage* Packet) { ItemPosition Position = (ItemPosition)Packet->Location; ConquerItem Item; if (Client.TryGetEquipment(Position, out Item)) { if (Client.AddInventory(Item)) { Client.Unequip(Item, Position); } else { Client.Message("Inventory is full!", ChatType.Top, Color.Red); } } }
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); } } }
/// <summary> /// Called when a server receives a tcpclient /// </summary> /// <param name="c"></param> /// <returns></returns> public static GameClient AddClient(GameClient c) { int index = _cIndexer.GetIndex(); if (index >= Constants.MaxClientCount) { Console.WriteLine("Failed to add client to list, count greater than MaxClientCount."); return null; } GamePlayer p = new GamePlayer(c); c.Player = p; c.Index = index; _clients[index] = c; p.AddToWorld(); c.PacketLib.SendHello(); return c; }
public override void Execute(GameClient Client, byte* pPacket) { GeneralData* Packet = (GeneralData*)pPacket; System.Console.WriteLine(Packet->DataID.ToString()); switch (Packet->DataID) { case GeneralDataID.SetLocation: HandleSetLocation(Client, Packet); break; case GeneralDataID.Jump: HandleJumping(Client, Packet); break; case GeneralDataID.GetSurroundings: HandleGetSurroundings(Client, Packet); break; case GeneralDataID.ChangeAction: HandleChangeAction(Client, Packet); break; case GeneralDataID.ChangeAngle: HandleChangeAngle(Client, Packet); break; case GeneralDataID.EnterPortal: HandlePortal(Client, Packet); break; case GeneralDataID.ChangeAvatar: HandleChangeAvatar(Client, Packet); break; case GeneralDataID.ConfirmSpells: HandleSpells(Client, Packet); break; default: Client.Send(Packet, Packet->Size); break; } }
public override void Execute(GameClient Client, byte* pPacket) { PacketHeader* Header = (PacketHeader*)pPacket; if (Header->Type == 0x7EF) { NpcInitialize* Packet = (NpcInitialize*)pPacket; NpcScriptEngine.Initialize(Client, Packet->UID); } else { NpcDialog* Packet = (NpcDialog*)pPacket; if (Packet->OptionID != 255) { string Input = new string(Packet->Input, 1, Packet->Input[0]); NpcScriptEngine.Process(Client, Packet->OptionID, Input); } else { Client.ActiveNPC = 0; } } }
public override void Execute(GameClient Client, byte* pPacket) { EntityMovement* Packet = (EntityMovement*)pPacket; if (Packet->UID == Client.Entity.UID) { ConquerAngle Direction = (ConquerAngle)(Packet->Direction % 8); Client.Entity.Walk(Direction); if (!Kernel.IsWalkable(Client.Entity.Location.MapID, Client.Entity.Location.X, Client.Entity.Location.Y)) { Client.Disconnect(); } else { Client.SendScreen(Packet, Packet->Size, true); Kernel.GetScreen(Client, null); } } else { Client.Disconnect(); } }
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; } }
//private GameClient gameClient; public GamePacketHandlers(GameClient gameClient) : base(gameClient) { // TODO: Complete member initialization //this.gameClient = gameClient; }
private void HandleSetLocation(GameClient Client, GeneralData* Packet) { Packet->ValueA = Client.Entity.Location.X; Packet->ValueB = Client.Entity.Location.Y; Packet->ValueD_High = Client.Entity.Location.MapID; Client.Send(Packet, Packet->Size); }
public GamePlayer(GameClient c) { _client = c; }
public abstract void Execute(GameClient Client, byte* pPacket);
public static void Add(GameClient Client) { GameClients.ThreadSafeAdd(Client.UID, Client); }
private void HandlePortal(GameClient Client, GeneralData* Packet) { Client.Teleport(1002, 400, 400); }
private void HandleSpells(GameClient Client, GeneralData* Packet) { Database.LoadSpells(Client); Database.LoadProfiencys(Client); Client.Send(Packet, Packet->Size); }
private void HandleChangeAngle(GameClient Client, GeneralData* Packet) { Client.Entity.Angle = (ConquerAngle)Packet->ValueC; Client.SendScreen(Packet, Packet->Size); }
private void HandleChangeAction(GameClient Client, GeneralData* Packet) { Client.Entity.Action = (ConquerAction)Packet->ValueD_High; Client.SendScreen(Packet, Packet->Size); }