WriteByte() public méthode

public WriteByte ( byte pValue ) : void
pValue byte
Résultat void
        public static void WriteBasicCharInfo(WorldCharacter wchar, Packet packet)
        {
            packet.WriteInt(wchar.Character.ID);
            packet.WriteString(wchar.Character.Name, 16);
            packet.WriteUShort(wchar.Character.CharLevel);
            packet.WriteByte(wchar.Character.Slot);
            MapInfo mapinfo;
            if (!DataProvider.Instance.Maps.TryGetValue(wchar.Character.Map, out mapinfo))
            {
                Log.WriteLine(LogLevel.Warn, "{0} has an invalid MapID ({1})", wchar.Character.Name, wchar.Character.Map);
                wchar.Character.Map = 0;//we reset
                packet.WriteString("Rou", 12);
            }
            else
            {
                packet.WriteString(mapinfo.ShortName, 12);
            }
            packet.WriteByte(0);               // UNK
            packet.WriteInt(0x00000000);       // Random seed
            WriteLook(wchar, packet);
            WriteEquipment(wchar, packet);
            WriteRefinement(wchar, packet);
            packet.Fill(4, 0xff);      		// UNK
            packet.WriteString("Rou", 12); //TODO: load from mapinfo.shn
            packet.WriteInt(0);				// X, doesn't matter
            packet.WriteInt(0);        		// Y, neither

            packet.WriteInt(0x63dd45ca);
            packet.WriteByte(0);
            packet.WriteInt(100);      		// Test later!
            packet.WriteByte(0);
            wchar.Detach();
        }
 public static void WriteLook(WorldCharacter wchar, Packet packet)
 {
     packet.WriteByte(Convert.ToByte(0x01 | (wchar.Character.Job << 2) | (Convert.ToByte(wchar.Character.Male)) << 7));
     packet.WriteByte(wchar.Character.Hair);
     packet.WriteByte(wchar.Character.HairColor);
     packet.WriteByte(wchar.Character.Face);
 }
Exemple #3
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);
            }
        }
 public static void WriteRefinement(WorldCharacter wchar, Packet pPacket)
 {
     //TODO: pPacket.WriteByte(Convert.ToByte(this.Inventory.GetEquippedUpgradesByType(ItemType.Weapon) << 4 | this.Inventory.GetEquippedUpgradesByType(ItemType.Shield)));
     pPacket.WriteByte(0xff); //this must be the above, but currently not cached
     pPacket.WriteByte(0xff);    		// UNK
     pPacket.WriteByte(0xff);    		// UNK
 }
        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);
             }
        }
Exemple #6
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);
     }
 }
Exemple #7
0
 public static void SendGameMessage(ZoneCharacter character, string Message, string script)
 {
     using (var packet = new Packet(SH27Type.GameMessage))
     {
         packet.WriteString(script, 31);
         packet.WriteByte(24);
         packet.WriteInt(Message.Length);
         packet.WriteByte(0);
         packet.WriteString(Message, Message.Length);
         character.Client.SendPacket(packet);
     }
 }
Exemple #8
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);
     }
 }
Exemple #9
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);
             }
         }
     }
 }
Exemple #10
0
        public static void SendPartyInformation(ZoneClient client)
        {
            if (Program.Entity.Parties.Where(c => c.CharNo == client.Character.ID).Count() == 1)
            {
                Party PartyNo = Program.Entity.Parties.First(c => c.CharNo == client.Character.ID);
                foreach (Party party in Program.Entity.Parties.Where(c => c.PartyNo == PartyNo.PartyNo))
                {
                    Character Pcharacter = Program.Entity.Characters.First(c => c.ID == party.CharNo);
                    ZoneClient otherLiveInfo = ClientManager.Instance.GetClientByName(Pcharacter.Name);
                    if (otherLiveInfo != null)
                    {
                        if (otherLiveInfo.Character.MapID == client.Character.MapID)
                        {
                            using (var ppacket = new Packet(SH14Type.PartyInformationShort))
                            {
                                ppacket.WriteByte(1);
                                ppacket.WriteString(otherLiveInfo.Character.Name, 16);
                                ppacket.WriteUInt(otherLiveInfo.Character.HP);
                                ppacket.WriteUInt(otherLiveInfo.Character.SP);
                                ppacket.WriteUInt(otherLiveInfo.Character.LP);
                                client.SendPacket(ppacket);
                            }

                            using (var ppacket = new Packet(SH14Type.PartyInformation))
                            {
                                ppacket.WriteByte(1); //unk
                                ppacket.WriteString(otherLiveInfo.Character.Name, 16);
                                ppacket.WriteByte((byte)otherLiveInfo.Character.Job);
                                ppacket.WriteByte(otherLiveInfo.Character.Level);
                                ppacket.WriteUInt(otherLiveInfo.Character.HP);
                                ppacket.WriteUInt(otherLiveInfo.Character.SP);
                                ppacket.WriteUInt(otherLiveInfo.Character.LP);
                                ppacket.WriteByte(1); //unk
                                client.SendPacket(ppacket);
                            }

                            using (var ppacket = new Packet(SH14Type.PartyLoginCord))
                            {
                                ppacket.WriteByte(1); //unk
                                ppacket.WriteString(otherLiveInfo.Character.Name, 16);
                                ppacket.WriteInt(otherLiveInfo.Character.Position.X);
                                ppacket.WriteInt(otherLiveInfo.Character.Position.Y);
                                client.SendPacket(ppacket);
                            }
                        }
                    }
                }
            }
        }
Exemple #11
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);
            }
        }
Exemple #12
0
        public static void sendPartyMessage(WorldClient client, Packet packet)
        {
            string mess;
            byte len;
            if (!packet.TryReadByte(out len) || !packet.TryReadString(out mess, len))
            {
                Log.WriteLine(LogLevel.Error, "PartyChat :: Can not parse party chat from {0}", client.Character.Character.Name);
                return;
            }

            if(Program.Entity.Parties.Where(c => c.CharNo == client.Character.Character.ID).Count() == 1)
            {
                Party getPartyInfo = Program.Entity.Parties.First(c => c.CharNo == client.Character.Character.ID);
                foreach (Party party in Program.Entity.Parties.Where(c => c.PartyNo == getPartyInfo.PartyNo))
                {
                    Character character = Program.Entity.Characters.First(c => c.ID == party.CharNo);
                    WorldClient wclient = ClientManager.Instance.GetClientByCharname(character.Name);
                    using (var ppacket = new Packet(SH8Type.PartyChat))
                    {
                        ppacket.WriteString(client.Character.Character.Name, 16);
                        ppacket.WriteByte(len);
                        ppacket.WriteString(mess, len);
                        wclient.SendPacket(ppacket);
                    }
                }
            }
            else
            {
                using (var ppacket = new Packet(SH8Type.PartyChatErr))
                {
                    ppacket.WriteUShort(1985);
                    client.SendPacket(ppacket);
                }
            }
        }
Exemple #13
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;
 }
Exemple #14
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);
            }
        }
Exemple #15
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;
 }
Exemple #16
0
 public static Packet Animation(ZoneCharacter character, byte id)
 {
     Packet packet = new Packet(SH8Type.Emote);
     packet.WriteUShort(character.MapObjectID);
     packet.WriteByte(id);
     return packet;
 }
Exemple #17
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
        }
Exemple #18
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);
     }
 }
Exemple #19
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);
 }
Exemple #20
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);
     }
 }
Exemple #21
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;
 }
Exemple #22
0
 public void Write(Packet packet)
 {
     packet.WriteUShort(this.MapObjectID);
     packet.WriteByte(2); //always 2 (type i bet shown / transparent?)
     packet.WriteUShort(ID);
     packet.WriteInt(this.Position.X);
     packet.WriteInt(this.Position.Y);
     packet.WriteByte(this.Rotation); //TODO: rotation for NPC (from txt official files?)
     if (Gate != null)
     {
         packet.WriteByte(1);
         packet.WriteString(Gate.MapClient, 12);
         packet.Fill(41, 0);
     }
     else
     {
         packet.Fill(54, 0); //find out later
     }
 }
Exemple #23
0
        public static void getWhisperMessage(WorldClient client, Packet packet)
        {
            string toChar;
            byte len;
            string mess;
            if (!packet.TryReadString(out toChar, 16) || !packet.TryReadByte(out len) || !packet.TryReadString(out mess, len))
            {
                Log.WriteLine(LogLevel.Error, "WhisperChat :: Can not parse Whisper request from {0}", client.Character.Character.Name);
                return;
            }

            WorldClient wclient = ClientManager.Instance.GetClientByCharname(toChar);

            if (wclient != null)
            {
                using (var ppacket = new Packet(SH8Type.WhisperTo))
                {
                    ppacket.WriteString(toChar, 16);
                    ppacket.WriteByte(len);
                    ppacket.WriteString(mess, len);
                    client.SendPacket(ppacket);
                }

                using (var ppacket = new Packet(SH8Type.WhisperFrom))
                {
                    ppacket.WriteString(client.Character.Character.Name, 16);
                    ppacket.WriteByte(0); // unk
                    ppacket.WriteByte(len);
                    ppacket.WriteString(mess, len);
                    wclient.SendPacket(ppacket);
                }
            }
            else
            {
                using (var ppacket = new Packet(SH8Type.WhisperErrAnswer))
                {
                    ppacket.WriteUShort(3945);
                    ppacket.WriteString(toChar, 16);
                    client.SendPacket(ppacket);
                }
            }
        }
Exemple #24
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;
 }
Exemple #25
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
            }
        }
Exemple #26
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);
        }
Exemple #27
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
 }
Exemple #28
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);
     }
 }
Exemple #29
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;
 }
Exemple #30
0
 public void WriteUpdateStats(Packet packet)
 {
     packet.WriteUInt(HP);
     packet.WriteUInt(MaxHP); // Max HP
     packet.WriteUInt(SP);
     packet.WriteUInt(MaxSP); // Max SP
     packet.Fill(8, 0); //unk
     packet.WriteByte(Level);
     packet.WriteUShort(this.UpdateCounter);
 }