Пример #1
0
 public static byte[] Team(int UID, Struct.TeamOption T)
 {
     PacketBuilder Packet = new PacketBuilder(1023, 12);
     Packet.Long((int)T);
     Packet.Long(UID);
     return Packet.getFinal();
 }
Пример #2
0
 public static byte[] Chat(int MessageID, string From, string To, string Message, Struct.ChatType CType)
 {
     PacketBuilder Packet = new PacketBuilder(1004, 32 + From.Length + To.Length + Message.Length);
     Packet.Int(255); //Color - Red
     Packet.Int(255); //Color - Blue
     Packet.Short(255); //Color - Red
     Packet.Short((int)CType); //Chat Type
     Packet.Short(0); //Unknown
     Packet.Long(MessageID); //Message ID
     Packet.Int(255);//unknown
     Packet.Int(255);//unknown
     Packet.Int(255);//unknown
     Packet.Int(255);//unknown
     Packet.Long(0); //Unknown
     Packet.Int(4); //Strings+1
     Packet.Int(From.Length);
     Packet.Text(From);
     Packet.Int(To.Length);
     Packet.Text(To);
     Packet.Int(0); //Unknown
     Packet.Int(Message.Length);
     Packet.Text(Message);
     Packet.Int(0);
     Packet.Int(0);
     Packet.Int(0);
     return Packet.getFinal();
 }
Пример #3
0
 public static byte[] ItemUsage(int UID, int Pos, Struct.ItemUsage Usage)
 {
     PacketBuilder Packet = new PacketBuilder(1009, 20);
     Packet.Long(UID);
     Packet.Long(Pos);
     Packet.Long((int)Usage);
     Packet.Long(0);
     return Packet.getFinal();
 }
Пример #4
0
 public static byte[] Status(ClientSocket CSocket, Struct.StatusTypes Type, int Value)
 {
     PacketBuilder Packet = new PacketBuilder(1017, 20);
     Packet.Long(CSocket.Client.ID);
     Packet.Long(1);//statuse count
     Packet.Long((int)Type);
     Packet.Long(Value);
     return Packet.getFinal();
 }
Пример #5
0
 /// <summary>
 /// Will Be removed soon.
 /// </summary>
 public static byte[] GeneralOld(int Identifier, int Value1, int Value2, int Value3, int Value4, int Value5, Struct.DataType PacketType)
 {
     PacketBuilder Packet = new PacketBuilder(1010, 28);
     Packet.Long(Timer);
     Packet.Long(Value1);//val1
     Packet.Short(Value2);//val2
     Packet.Short(Value3);//val3
     Packet.Long(Value4);//val4
     Packet.Long(Value5);//val5
     Packet.Short((int)PacketType + 9527);
     Packet.Short(0);
     return Packet.getFinal();
 }
Пример #6
0
 public static byte[] TerrainNPC(Struct.TerrainNPC TNpc)
 {
     PacketBuilder Packet = new PacketBuilder(1109, 28);
     Packet.Long(TNpc.UID);
     Packet.Long(TNpc.MaximumHP);
     Packet.Long(TNpc.CurrentHP);
     Packet.Short(TNpc.X);
     Packet.Short(TNpc.Y);
     Packet.Short(TNpc.Type);
     Packet.Short(TNpc.Flag);
     Packet.Int(17);
     Packet.Short(0);
     Packet.Int(0);
     return Packet.getFinal();
 }
Пример #7
0
        /// <summary>
        /// General Packet Type 1
        /// </summary>
        /// <param name="PlayerID">Player ID</param>
        /// <param name="PosX">Position X</param>
        /// <param name="PosY">Position X</param>
        /// <param name="Dir">Direction</param>
        /// <param name="SubType">SubType</param>
        /// <param name="Data">Data</param>
        /// <returns>Packet in Byte Array Form</returns>
        public static byte[] General(int PlayerID, ushort PosX, ushort PosY, ushort Dir, Struct.DataType SubType, int Data)
        {
            PacketBuilder Packet = new PacketBuilder(1010, 28);
            Packet.Long(Timer);
            Packet.Long(PlayerID);
            Packet.Short(PosX);
            Packet.Short(PosY);
            Packet.Short(Dir);
            Packet.Short(0); //Fill in the Padding
            Packet.Long(Data);//union
            Packet.Short((int)SubType + 9527);
            Packet.Short(0); //fill in the padding.

            return Packet.getFinal();
        }
Пример #8
0
 /// <summary>
 /// Does damage to a conquer online terrain NPC.
 /// </summary>
 /// <param name="CSocket">Attacking client socket.</param>
 /// <param name="AttackedTNpc">Attacked TNpc</param>
 /// <param name="Damage">Damage done</param>
 /// <param name="AType">Type of attack</param>
 public static void doTNpc(ClientSocket CSocket, Struct.TerrainNPC AttackedTNpc, int Damage, int AType)
 {
     if (AttackedTNpc.UID >= 6700)
     {
         CSocket.Send(EudemonPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] GuildWar is not ready yet.", Struct.ChatType.System));
     }
     else
     {
         GiveExp(CSocket, AttackedTNpc, Damage);
         if (AType != 21)
             EudemonPacket.ToLocal(EudemonPacket.Attack(CSocket.Client.ID, AttackedTNpc.UID, AttackedTNpc.X, AttackedTNpc.Y, Damage, AType), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
     }
 }
Пример #9
0
 public static byte[] Status(ClientSocket CSocket, int Switch, int Value, Struct.StatusTypes Type)
 {
     PacketBuilder Packet = null;
     if (Switch == 1 || Switch == 3)
         Packet = new PacketBuilder(1017, 36);
     else if (Switch == 2 || Switch == 4)
         Packet = new PacketBuilder(1017, 48);
     Packet.Long(CSocket.Client.ID);
     if (Switch == 1)
     {
         Packet.Long(Switch);
         Packet.Long(Value);
         Packet.Long(0);
         Packet.Long((int)Type);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     else if (Switch == 2)
     {
         Packet.Long(Switch);//Unknown Var
         Packet.Short(65535);
         Packet.Short(65535);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long((int)(Type));
         if (Type == Struct.StatusTypes.StatusEffect)
         {
             uint Status = 0;
             if (Value != 1024 && !CSocket.Client.Dead)//Dead
             {
                 if (CSocket.Client.PkPoints >= 100)
                     Status += 0x8000;
                 else if (CSocket.Client.PkPoints >= 30 && CSocket.Client.PkPoints < 100)
                     Status += 0x4000;
                 if (CSocket.Client.Flashing)
                     Status += 0x1;
                 if (CSocket.Client.Team != null)
                 {
                     if (CSocket.Client.Team.LeaderID == CSocket.Client.ID)
                         Status += 0x40;
                 }
                 if (CSocket.Client.Flying)
                     Status += 0x8000000;
             }
             else
                 Status = 1024;
             Packet.Long(Status);
         }
         else
             Packet.Long(Value);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     else if (Switch == 3)
     {
         Packet.Long(Value);//Unknown Var
         Packet.Long(26);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     else if (Switch == 4)
     {
         Packet.Long(2);//Unknown Var
         Packet.Long(4294967295); //(FF FF FF FF)
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(9);
         Packet.Long(3);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     return Packet.getFinal();
 }
Пример #10
0
 public static byte[] Status(ClientSocket CSocket, int Switch, ulong Value, Struct.StatusTypes Type)
 {
     PacketBuilder Packet = null;
     if (Switch == 1 || Switch == 3)
         Packet = new PacketBuilder(1017, 36);
     else if (Switch == 2 || Switch == 4)
         Packet = new PacketBuilder(1017, 48);
     Packet.Long(CSocket.Client.ID);
     if (Switch == 1)
     {
         Packet.Long(Switch);
         //Packet.Long(Value);
         //Packet.Long(0);
         Packet.ULong(Value);
         Packet.Long((int)Type);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     else if (Switch == 2)
     {
         Packet.Long(Switch);//Unknown Var
         Packet.Short(65535);
         Packet.Short(65535);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long((int)(Type));
         Packet.Long(Value);
         Packet.Long(0);
         // Packet.ULong(Value);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     else if (Switch == 3)
     {
         //Packet.Long(Value);//Unknown Var
         //Packet.Long(26);
         Packet.ULong(Value);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     else if (Switch == 4)
     {
         Packet.Long(2);//Unknown Var
         Packet.Long(4294967295); //(FF FF FF FF)
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(9);
         Packet.Long(3);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
         Packet.Long(0);
     }
     return Packet.getFinal();
 }
Пример #11
0
        public static void UseItem(Struct.ItemInfo Item, ClientSocket CSocket)
        {
            bool Delete = true;
            switch (Item.ItemID)
            {
                case 1000000://Stancher
                    {
                        int AddHP = 70;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                //Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1000010://Stancher
                    {
                        int AddHP = 100;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {

                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1000020://Stancher
                    {
                        int AddHP = 250;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1000030://Stancher
                    {
                        int AddHP = 500;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1002000://Stancher
                    {
                        int AddHP = 800;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1002010://Stancher
                    {
                        int AddHP = 1200;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1002020://Stancher
                    {
                        int AddHP = 2000;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1002050://Stancher
                    {
                        int AddHP = 3000;
                        if (CSocket.Client.CurrentHP >= CSocket.Client.MaxHP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentHP + AddHP > CSocket.Client.MaxHP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, (CSocket.Client.MaxHP - CSocket.Client.CurrentHP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentHP, AddHP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentHP, Struct.StatusTypes.Hp));
                            }
                        }
                        break;
                    }
                case 1001000://Stancher
                    {
                        int AddMP = 70;
                        if (CSocket.Client.CurrentMP >= CSocket.Client.MaxMP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentMP + AddMP > CSocket.Client.MaxMP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, (CSocket.Client.MaxMP - CSocket.Client.CurrentMP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, AddMP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                        }
                        break;
                    }
                case 1001010://Stancher
                    {
                        int AddMP = 200;
                        if (CSocket.Client.CurrentMP >= CSocket.Client.MaxMP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentMP + AddMP > CSocket.Client.MaxMP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, (CSocket.Client.MaxMP - CSocket.Client.CurrentMP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, AddMP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                        }
                        break;
                    }
                case 1001020://Stancher
                    {
                        int AddMP = 450;
                        if (CSocket.Client.CurrentMP >= CSocket.Client.MaxMP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentMP + AddMP > CSocket.Client.MaxMP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, (CSocket.Client.MaxMP - CSocket.Client.CurrentMP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, AddMP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                        }
                        break;
                    }
                case 1001030://Stancher
                    {
                        int AddMP = 1000;
                        if (CSocket.Client.CurrentMP >= CSocket.Client.MaxMP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentMP + AddMP > CSocket.Client.MaxMP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, (CSocket.Client.MaxMP - CSocket.Client.CurrentMP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, AddMP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                        }
                        break;
                    }
                case 1001040://Stancher
                    {
                        int AddMP = 2000;
                        if (CSocket.Client.CurrentMP >= CSocket.Client.MaxMP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentMP + AddMP > CSocket.Client.MaxMP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, (CSocket.Client.MaxMP - CSocket.Client.CurrentMP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, AddMP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                        }
                        break;
                    }
                case 1002030://Stancher
                    {
                        int AddMP = 3000;
                        if (CSocket.Client.CurrentMP >= CSocket.Client.MaxMP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentMP + AddMP > CSocket.Client.MaxMP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, (CSocket.Client.MaxMP - CSocket.Client.CurrentMP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, AddMP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                        }
                        break;
                    }
                case 1002040://Stancher
                    {
                        int AddMP = 4500;
                        if (CSocket.Client.CurrentMP >= CSocket.Client.MaxMP)
                        {
                            Delete = false;
                            break;
                        }
                        else
                        {
                            if (CSocket.Client.CurrentMP + AddMP > CSocket.Client.MaxMP)
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, (CSocket.Client.MaxMP - CSocket.Client.CurrentMP));
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                            else
                            {
                                Interlocked.Add(ref CSocket.Client.CurrentMP, AddMP);
                                CSocket.Send(EudemonPacket.Status(CSocket, 2, CSocket.Client.CurrentMP, Struct.StatusTypes.Mp));
                            }
                        }
                        break;
                    }
                default:
                    {
                        CSocket.Send(EudemonPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Please report: Unable to handle item ID: " + Item.ItemID, Struct.ChatType.System));
                        Delete = false;
                        break;
                    }
            }
            if (Delete)
            {
                CSocket.Client.Inventory.Remove(Item.UID);
                CSocket.Send(EudemonPacket.ItemUsage(Item.UID, 255, Struct.ItemUsage.RemoveDropItem));
                Database.Database.DeleteItem(Item.UID);
            }
        }