示例#1
0
        public static void GetAcademyGoldRewardList(WorldClient client, Packet packet)
        {
            using (var pack = new Packet(SH38Type.SendAcademyGoldRewardList))
            {
                pack.WriteHexAsBytes("80 18");//responsecode
                pack.WriteByte(1);//stat count
                pack.WriteHexAsBytes("0A 0A CA 9A 3B 00 00 00 00");//unk

                pack.WriteByte(10);//levelbreich
                pack.WriteLong(1000);
                pack.WriteByte(15);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(26);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(31);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(36);//levelbereich
                pack.WriteLong(1000);
                pack.WriteByte(41);//level bereich
                pack.WriteLong(9000);
                pack.WriteByte(46);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(51);//level bereich
                pack.WriteLong(1000);
                pack.WriteByte(56);//level bereich
                pack.WriteLong(1000);
                client.SendPacket(pack);
            }
        }
示例#2
0
 public static void WriteLook(WorldCharacter wchar, Packet packet)
 {
     packet.WriteByte(Convert.ToByte(0x01 | (wchar.Character.Job << 2) | (Convert.ToByte(wchar.Character.LookInfo.Male)) << 7));
     packet.WriteByte(wchar.Character.LookInfo.Hair);
     packet.WriteByte(wchar.Character.LookInfo.HairColor);
     packet.WriteByte(wchar.Character.LookInfo.Face);
 }
示例#3
0
        public static void ChangeFromGuildAcademyToResponse(WorldClient client, Packet packet)
        {
            string GuildName;
              string RequestName;
              bool answer;
              if (!packet.TryReadString(out GuildName, 16) || !packet.TryReadString(out RequestName, 16)|| (!packet.TryReadBool(out answer) || !client.Character.IsInGuildAcademy))
                  return;
             if (answer)
            {
                GuildAcademyMember pMember = client.Character.GuildAcademy.Members.Find(m => m.Character.Character.Name == RequestName);
                if (pMember == null)
                    return;
                pMember.Character.IsInGuildAcademy = false;
                pMember.Academy.RemoveMember(pMember);
               pMember.Character.GuildAcademy.Guild.AddMember(pMember.Character, GuildRank.Member, Program.DatabaseManager.GetClient().GetConnection(), true, true);

                pMember.Character.Guild = pMember.Character.GuildAcademy.Guild;
                pMember.Character.IsInGuild = true;
             using (var pack = new Packet(SH38Type.SendJoinGuildFromAcademy))
             {
                 //this packet remove character from academy List and added to GuildList
                 pack.WriteString(RequestName, 16);
                 pack.WriteString(client.Character.Character.Name, 16);
                 pack.WriteByte(6);//rank
                 pack.WriteInt(0);//unk
                 pack.WriteUShort(0);//korp
                 pack.Fill(64, 0x00);//unk
                 pack.WriteByte(true ? (byte)0x95 : (byte)0x00);// (this.isOnline ? (byte)0x95 : (byte)0x00);
                 pack.Fill(3, 0x00);//unk
                 pack.WriteByte(pMember.Character.Character.Job);
                 pack.WriteByte(pMember.Character.Character.CharLevel);
                 pack.Fill(13, 0x00);//unk
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);
                 }
             }
             using (var p2 = new Packet(SH4Type.CharacterGuildinfo))
             {
                 client.Character.Guild.WriteGuildInfo(packet);
                 client.SendPacket(p2);
             }
             using (var pack = new Packet(SH29Type.GuildMemberJoined))
             {
                 pack.WriteString(client.Character.Character.Name, 16);
                 client.Character.GuildAcademy.Guild.Broadcast(pack);
                 client.Character.GuildAcademy.Broadcast(pack);

             }
             using (var pack = new Packet(SH29Type.ChangeResponse))
             {
                 pack.WriteUShort(3137);//unk
                 pack.WriteByte(3);
                 pack.Fill(2, 0x00);//unk
                 client.SendPacket(pack);
             }
        }
示例#4
0
 public static void Handunk1(WorldClient character, Packet packet)
 {
     using (var to = new Packet(SH2Type.Unk1))
     {
         DateTime now = DateTime.Now;
         to.WriteByte(Convert.ToByte(now.Hour));
         to.WriteByte(Convert.ToByte(now.Minute));
         to.WriteByte(Convert.ToByte(now.Second));
         character.SendPacket(to);
     }
 }
示例#5
0
 public void SendRemoveFromGuildStore(GuildStoreAddFlags Flags, string Charname, long Value, long NewGuildMoney = 0, ushort ItemID = 0xFFFF)
 {
     using (var packet = new Packet(SH38Type.RemoveFromGuildStore))
     {
         packet.WriteByte(0);//unk
         packet.WriteByte((byte)Flags);
         packet.WriteString(Charname, 16);
         packet.WriteUShort(ItemID);
         packet.WriteByte(0);
         packet.WriteLong(Value);
         packet.WriteLong(NewGuildMoney);//new GuildMoney
         Guild.Broadcast(packet);
     }
 }
示例#6
0
 public static void Wisper(WorldClient client, Packet packet)
 {
     string toname;
     byte messagelenght;
     if (packet.TryReadString(out toname, 16) && packet.TryReadByte(out messagelenght))
     {
         string message;
         if (!packet.TryReadString(out message, messagelenght))
         {
             return;
         }
         WorldClient toChar = ClientManager.Instance.GetClientByCharname(toname);
         if (toChar != null)
         {
             using (var frompacket = new Packet(SH8Type.WisperFrom))
             {
                 frompacket.WriteString(client.Character.Character.Name, 16);
                 if (!toChar.Character.BlocketUser.Contains(client.Character.Character.Name))
                 {
                     frompacket.WriteByte(0);
                 }
                 else
                 {
                     frompacket.WriteByte(12);//blocket notdisplay message
                 }
                 frompacket.WriteByte(messagelenght);
                 frompacket.WriteString(message, messagelenght);
                 toChar.SendPacket(frompacket);
             }
             using (var pack = new Packet(SH8Type.WisperTo))
             {
                 pack.WriteString(toname, 16);
                 pack.WriteByte(messagelenght);
                 pack.WriteString(message, messagelenght);
                 client.SendPacket(pack);
             }
         }
         else
         {
             //target not found
             using (var pp = new Packet(SH8Type.WisperTargetNotfound))
             {
                 pp.WriteUShort(3945);//unk
                 pp.WriteString(toname, 16);
                 client.SendPacket(pp);
             }
         }
     }
 }
示例#7
0
 public static Packet ShowDrops(List<Drop> drops)
 {
     Packet packet = new Packet(SH7Type.ShowDrops);
     packet.WriteByte((byte)drops.Count);
     drops.ForEach(d => d.Write(packet));
     return packet;
 }
示例#8
0
 public static Packet CreateWorldMessage(WorldMessageTypes pType, string pMessage)
 {
     var packet = new Packet(SH25Type.WorldMessage);
     packet.WriteByte((byte)pType);
     packet.WriteStringLen(pMessage, true);
     return packet;
 }
示例#9
0
 public static Packet Animation(ZoneCharacter character, byte id)
 {
     Packet packet = new Packet(SH8Type.Emote);
     packet.WriteUShort(character.MapObjectID);
     packet.WriteByte(id);
     return packet;
 }
示例#10
0
        public static void SendClientTime(WorldClient client, DateTime time)
        {
            using (var packet = new Packet(SH2Type.UpdateClientTime))
            {
                //pPacket.WriteUInt((59 << 25) | (23 << 19) | (31 << 13) | (12 << 8) | (254));
            // *                    Minutes   | Hours      | Days       | Months    | Years
                packet.WriteInt(3);
                packet.WriteInt(time.Minute);//minutes
                packet.WriteInt(time.Hour);//hourses
                packet.WriteInt(time.Day);
                packet.WriteInt(time.Month-1);
                packet.WriteInt((time.Year - 1900));
                packet.WriteInt((int)time.DayOfWeek);//wekday?
                packet.WriteInt(105);
                packet.WriteInt(2);

                packet.WriteByte(1); //GMT 0-130 positive 130 -254 negative
              //  packet.WriteLong(2012);
               // packet.WriteInt(4);//unk
                //packet.WriteInt(1);//unk
                //packet.WriteInt(3);//unk
                //packet.WriteInt(46);
              //  packet.Fill(3, 0);//unk
               // packet.WriteByte(2);
                client.SendPacket(packet);
            }
        }
示例#11
0
        public void WritePacket(Packet pPacket)
        {
            pPacket.WriteUShort(ItemID);
            if (this.Type != HouseType.Resting)
            {
                pPacket.Fill(10, 0xFF); // Unknown

                pPacket.WriteString(this.Name, 30);
            }
            else
            {
                pPacket.WriteHexAsBytes("BE 02 FA 01 F8 01");
                pPacket.Fill(34, 0xFF); // No idea!?
            }
            pPacket.WriteByte(0xFF);
            pPacket.WriteByte(0);//unk
        }
示例#12
0
 public static void SendSkillLearnt(ZoneCharacter character, ushort skillid)
 {
     using (var packet = new Packet(SH18Type.LearnSkill))
     {
         packet.WriteUShort(skillid);
         packet.WriteByte(0); //unk
         character.Client.SendPacket(packet);
     }
 }
示例#13
0
 public void Write(Packet packet)
 {
     packet.WriteUShort(ID);
     packet.WriteUShort(Item.ItemID);
     packet.WriteInt(Position.X);
     packet.WriteInt(Position.Y);
     packet.WriteUShort((DroppedBy != null) ? DroppedBy.MapObjectID : (ushort)0xffff);
     packet.WriteByte(CanTake ? (byte)0x08 : (byte)0x00);
 }
示例#14
0
 public static void SendQuestion(ZoneCharacter character, Question question, ushort range)
 {
     using (var packet = new Packet(SH15Type.Question))
     {
         packet.WriteString(question.Text, 129);
         packet.WriteUShort(character.MapObjectID);     // Obj id
         packet.WriteInt(character.Position.X);
         packet.WriteInt(character.Position.Y);
         packet.WriteUShort(range);        // Distance how far your allowed to run when the question window is closed by Client
         packet.WriteByte((byte)question.Answers.Count);
         for (byte i = 0; i < question.Answers.Count; ++i)
         {
             packet.WriteByte(i);
             packet.WriteString(question.Answers[i], 32);
         }
         character.Client.SendPacket(packet);
     }
 }
示例#15
0
 public static Packet Equip(ZoneCharacter character, Item equip)
 {
     //B2 00 - AB 38 - 07 - 0D 00 04
     Packet packet = new Packet(SH7Type.ShowEquip);
     packet.WriteUShort(character.MapObjectID);
     packet.WriteUShort(equip.ID);
     packet.WriteByte(equip.UpgradeStats.Upgrades);
     packet.Fill(3, 0xff);
     return packet;
 }
示例#16
0
        public void Write(Packet packet)
        {
            packet.WriteUShort(this.MapObjectID);
            packet.WriteByte(2); //always 2 (type i bet shown / transparent?) -> test it
            packet.WriteUShort(this.ID);
            packet.WriteInt(this.Position.X);
            packet.WriteInt(this.Position.Y);
            packet.WriteByte(this.Rotation);
            if (Gate != null)
            {
                packet.WriteByte(1);
                packet.WriteString(Gate.MapClient, 12);
                packet.Fill(43, 0);

            }
            else
            {
                packet.Fill(56, 0); //find out later
            }
        }
示例#17
0
 public static Packet SpawnMultiPlayer(List<ZoneCharacter> characters, ZoneCharacter exclude = null)
 {
     Packet packet = new Packet(SH7Type.SpawnMultiPlayer);
     packet.WriteByte(exclude == null ? (byte)characters.Count : (byte)(characters.Count - 1));
     foreach (var character in characters)
     {
         if (character == exclude) continue;
         character.WriteCharacterDisplay(packet);
     }
     return packet;
 }
示例#18
0
        public static void WriteBasicCharInfo(WorldCharacter wchar, Packet packet)
        {
            packet.WriteInt(wchar.Character.ID); //charid
            packet.FillPadding(wchar.Character.Name, 0x10);
            packet.WriteInt(0);//unk
            packet.WriteShort((short)wchar.Character.CharLevel); //level
            packet.WriteByte(wchar.Character.Slot);
            MapInfo mapinfo;
            if (!DataProvider.Instance.Maps.TryGetValue(wchar.Character.PositionInfo.Map, out mapinfo))
            {
                Log.WriteLine(LogLevel.Warn, "{0} has an invalid MapID ({1})", wchar.Character.Name, wchar.Character.PositionInfo.Map);
                wchar.Character.PositionInfo.Map = 0;
                packet.FillPadding(mapinfo.ShortName, 0x0D); //townname
            }
            else
            {
                packet.FillPadding(mapinfo.ShortName, 0x0D); //townname
            }

            //packet.WriteByte(0); // UNK
            packet.WriteInt(0); // Random seed
            WriteLook(wchar,packet);
            WriteEquipment(wchar,packet);
            WriteRefinement(wchar,packet);
            packet.WriteByte(0);

            packet.WriteByte(0xF0);
            packet.WriteByte(0xFF);//unk
            packet.WriteByte(0xFF);

            packet.FillPadding(mapinfo.ShortName, 0x0c);
            packet.WriteInt(0); //pos
            packet.WriteInt(0); //pos
            packet.WriteUShort(0xdb78);
            packet.WriteUShort(4910);//unk
            packet.WriteUShort(25600);
            packet.Fill(4, 0);
        }
示例#19
0
 public static void ChangeCharNameHandler(WorldClient client, Packet packet)
 {
     byte Character_slot;
     string charname;
     if (!packet.TryReadByte(out Character_slot) || !packet.TryReadString(out charname, 16))
         return;
     using (var pack = new Packet(SH5Type.SendCharacterChangeNewName))
     {
         pack.WriteByte(Character_slot);
         pack.WriteString(charname,16);
         pack.WriteUShort(208);//Responsecode?
     }
     //Todo ChangeinDatabase
 }
示例#20
0
        public static void SendAttackAnimation(MapObject from, ushort objectID, ushort attackspeed, byte stance)
        {
            using (var packet = new Packet(SH9Type.AttackAnimation))
            {
                packet.WriteUShort(from.MapObjectID);
                packet.WriteUShort(objectID);
                packet.WriteByte(stance);

                packet.WriteUShort(attackspeed);

                packet.WriteByte(4);
                packet.WriteByte(100);
                from.MapSector.Broadcast(packet);
            }
        }
示例#21
0
 public static void SendActiveSkillList(ZoneCharacter character)
 {
     using (var packet = new Packet(SH4Type.CharacterActiveSkillList))
     {
         var list = character.SkillsActive.Values;
         packet.WriteByte(0);
         packet.WriteInt(character.ID);
         packet.WriteUShort((ushort)list.Count); // Skill count (max 300)
         foreach (var skill in list)
         {
             skill.Write(packet);
         }
         character.Client.SendPacket(packet);
     }
 }
示例#22
0
        public static Packet MultiObjectList(List<MapObject> objs, int start, int end)
        {
            Packet packet = new Packet(SH7Type.SpawnMultiObject);
            packet.WriteByte((byte)(end - start));
            Log.WriteLine(LogLevel.Debug, "Sending {0} objects ({1} - {2})", end - start, start, end);
            for (int i = start; i < end; i++)
            {

                var obj = objs[i];
                if (obj is Npc)
                {
                    ((Npc)obj).Write(packet);
                }
                else if (obj is Mob) // Just to be sure
                {
                    ((Mob)obj).Write(packet);
                }
                else
                {
                    Log.WriteLine(LogLevel.Warn, "What the F is {0} doing here lol", obj.ToString());
                }
             }
            return packet;
        }
示例#23
0
        private static void SendCharacterList(WorldClient client)
        {
            if (!client.LoadCharacters())
            {
                SendError(client, ServerError.DatabaseError);
                return;
            }

            using (var packet = new Packet(SH3Type.CharacterList))
            {
                packet.WriteUShort(client.RandomID);
                packet.WriteByte((byte)client.Characters.Count);
                foreach (WorldCharacter ch in client.Characters.Values)
                {

                    PacketHelper.WriteBasicCharInfo(ch, packet);

                }
                client.SendPacket(packet);
            }
        }
示例#24
0
        public static void On_GameClient_UpdateGuildMemberRank(WorldClient Client, Packet Packet)
        {
            string targetName;
            byte newRankByte;
            if (!Packet.TryReadString(out targetName, 16)
                || !Packet.TryReadByte(out newRankByte))
            {
                return;
            }

            var newRank = (GuildRank)newRankByte;
            GuildMember member;
            GuildMember target;
            if (Client.Character.Guild != null
                && Client.Character.Guild.GetMember(Client.Character.Character.Name, out member)
                && Client.Character.Guild.GetMember(targetName, out target))
            {
                switch (member.Rank)
                {
                    case GuildRank.Master:

                        if (newRank == GuildRank.Master)
                        {
                            Client.Character.Guild.UpdateMemberRank(member, GuildRank.Member);
                        }

                        Client.Character.Guild.UpdateMemberRank(target, newRank);

                        using (var packet = new Packet(SH29Type.UpdateGuildMemberRankResponse))
                        {
                            packet.WriteString(targetName, 16);
                            packet.WriteByte(newRankByte);
                            packet.WriteUShort(3137); // ok response

                            Client.SendPacket(packet);
                        }

                        break;

                    case GuildRank.Admin:
                    case GuildRank.Advice:
                    case GuildRank.Commander:
                    case GuildRank.Default:
                    case GuildRank.Guard:
                    case GuildRank.Member:
                        return;
                }
            }
        }
示例#25
0
        public static void On_GameClient_GuildChat(WorldClient Client, Packet pPacket)
        {
            byte len;
            string msg;
            if (Client.Character == null
                || !pPacket.TryReadByte(out len)
                || !pPacket.TryReadString(out msg, len))
            {
                return;
            }

            len = (byte)(len + 2);

            if (Client.Character.Guild != null)
            {
                using (var packet = new Packet(SH29Type.GuildChat))
                {
                    packet.WriteInt(Client.Character.Guild.ID);
                    packet.WriteString(Client.Character.Character.Name, 16);

                    packet.WriteByte(len);
                    packet.WriteString(msg, len);

                    Client.Character.Guild.Broadcast(packet);
                }
            }
        }
示例#26
0
        public static void On_GameClient_GetGuildList(WorldClient Client, Packet Packet)
        {
            if (Client.Character == null)
            {
                return;
            }

            var now = Program.CurrentTime;
            if (now.Subtract(Client.Character.LastGuildListRefresh).TotalSeconds >= 60)
            {
                Client.Character.LastGuildListRefresh = now;

                const int GuildsPerPacket = 100;
                lock (ThreadLocker)
                {
                    using (var con = Program.DatabaseManager.GetClient().GetConnection())
                    {
                        //get guild count
                        int guildCount;
                        using (var cmd = con.CreateCommand())
                        {
                            cmd.CommandText = "SELECT COUNT(*) FROM Guilds";

                            guildCount = Convert.ToInt32(cmd.ExecuteScalar());
                        }

                        using (var cmd = con.CreateCommand())
                        {
                            cmd.CommandText = "SELECT ID FROM Guilds";

                            Packet listPacket = null;
                            var count = 0;
                            var globalCount = 0;

                            using (var reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    if (listPacket == null)
                                    {
                                        listPacket = new Packet(SH29Type.SendGuildList);
                                        listPacket.WriteUShort(3137);
                                        listPacket.WriteByte(1);
                                        listPacket.WriteUShort((ushort)guildCount);
                                        listPacket.WriteUShort((ushort)Math.Min(GuildsPerPacket, guildCount - globalCount));
                                    }

                                    Guild guild;
                                    if (GuildManager.GetGuildByID(reader.GetInt32(0), out guild))
                                    {
                                        //write packet
                                        listPacket.WriteInt(guild.ID);
                                        listPacket.WriteString(guild.Name, 16);
                                        listPacket.WriteString(guild.Master.Character.Character.Name, 16);
                                        listPacket.WriteBool(guild.AllowGuildWar);
                                        listPacket.WriteByte(1);     // unk
                                        listPacket.WriteUShort((ushort)guild.Members.Count);
                                        listPacket.WriteUShort(100); // unk
                                    }
                                    else
                                    {
                                        Packet.Fill(42, 0); // guild get error
                                    }

                                    globalCount++;
                                    count++;
                                    if (count >= Math.Min(GuildsPerPacket, guildCount - globalCount))
                                    {
                                        //send packet
                                        Client.SendPacket(listPacket);

                                        listPacket.Dispose();
                                        listPacket = null;

                                        //reset
                                        count = 0;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#27
0
 public void WriteUpdateStats(Packet packet)
 {
     packet.WriteUInt(this.HP);
     packet.WriteUInt(BaseStats.MaxHP);
     packet.WriteUInt(this.SP);
     packet.WriteUInt(BaseStats.MaxSP);
     packet.WriteByte(this.Level);
     packet.WriteUShort(this.UpdateCounter);
 }
示例#28
0
 public void WriteRewardList(ushort PageID)
 {
     List<RewardItem> Items;
     if (this.RewardInventory.RewardItems.TryGetValue(PageID, out Items))
     {
         using (var packet = new Packet(SH12Type.SendRewardList))
         {
             packet.WriteByte((byte)Items.Count);
             foreach (RewardItem pItem in Items)
             {
                 pItem.WriteInfo(packet);
             }
             packet.WriteByte(90);//unk
             Client.SendPacket(packet);
         }
     }
 }
示例#29
0
 public void WriteRefinement(Packet packet)
 {
     packet.WriteByte(Convert.ToByte(GetUpgradesBySlot(ItemSlot.Weapon) << 4 | GetUpgradesBySlot(ItemSlot.Weapon2)));
     packet.WriteByte(0);    		// UNK
     packet.WriteByte(0);    		// UNK
 }
示例#30
0
 public void WritePremiumList(byte PageID)
 {
     List<PremiumItem> Items;
     if(this.PremiumInventory.PremiumItems.TryGetValue(PageID, out Items))
     {
     using (var packet = new Packet(SH12Type.SendPremiumItemList))
     {
         packet.WriteUShort(0x1041);
         packet.WriteByte(1);//unk
         packet.WriteUShort((ushort)this.PremiumInventory.PremiumItems.Count);
         foreach (PremiumItem pItem in Items)
         {
             pItem.WritePremiumInfo(packet);
         }
         this.Client.SendPacket(packet);
     }
     }
 }