Fill() public method

public Fill ( int pLength, byte pValue ) : void
pLength int
pValue byte
return void
Example #1
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);
             }
        }
Example #2
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);
        }
Example #3
0
        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();
        }
Example #4
0
 public static Packet BeginDisplayRest(ZoneCharacter character)
 {
     Packet packet = new Packet(SH8Type.BeginDisplayRest);
     packet.WriteUShort(character.MapObjectID);
     packet.WriteUShort(character.House.ItemID);
     packet.Fill(10, 0xff);
     return packet;
 }
Example #5
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;
 }
Example #6
0
 public static void WriteEquipment(WorldCharacter wchar, Packet packet)
 {
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Helm));
     packet.WriteUShort(Settings.Instance.ShowEquips ? wchar.GetEquipBySlot(ItemSlot.Weapon) : (ushort)0xffff);
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Armor));
     packet.WriteUShort(Settings.Instance.ShowEquips ? wchar.GetEquipBySlot(ItemSlot.Weapon2) : (ushort)0xffff);
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Pants));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Boots));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeBoots));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumePants));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeArmor));
     packet.Fill(6, 0xff);              // UNK
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Glasses));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeHelm));
     packet.Fill(2, 0xff);              // UNK
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.CostumeWeapon));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Wing));
     packet.Fill(2, 0xff);              // UNK
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Tail));
     packet.WriteUShort(wchar.GetEquipBySlot(ItemSlot.Pet));
 }
Example #7
0
        public static void SendInterfaceClock(WorldClient client)
        {
            DateTime dt = DateTime.Now;

            using (var packet = new Packet(SH2Type.InterfaceClock))
            {
                packet.WriteInt(DateTime.Now.DayOfYear); //unk
                packet.WriteInt(DateTime.Now.Minute);
                packet.WriteInt(DateTime.Now.Hour);
                packet.WriteInt(DateTime.Now.Day);
                packet.WriteInt((DateTime.Now.Month - 1));
                packet.WriteInt((DateTime.Now.Year - 1900));
                packet.WriteInt((int)DateTime.Now.DayOfWeek);
                packet.WriteInt((DateTime.Now.DayOfYear - 1));
                packet.Fill(4, 0); //unk
                packet.WriteSByte(Convert.ToSByte((DateTime.Now - DateTime.UtcNow).ToString().Split(':')[0])); //Timezone
                client.SendPacket(packet);
            }
        }
Example #8
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);
        }
Example #9
0
 public void WriteInfo(Packet Packet)
 {
     Packet.WriteInt(Guild.ID);
     Packet.WriteByte(1);//unk
     Packet.WriteString(Guild.Master.Character.Character.Name, 16);
     Packet.WriteUShort((ushort)Members.Count);//membercount
     Packet.WriteUShort(MaxMembers);//maxmembercount
     Packet.WriteInt(Guild.ID);//academyid
     Packet.WriteInt((int)Guild.CreateTime.DayOfWeek);//weeks //Todo Calculate Weeks
     Packet.WriteInt((int)GuildBuffKeepTime.TotalSeconds);  //time in sek (buff?)
     Packet.Fill(128, 1);//GuildAcademyBUff
     Packet.WriteString(Message, 512);
 }
Example #10
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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #11
0
        public static void On_GameClient_UpdateGuildMessage(WorldClient Client, Packet Packet)
        {
            ushort length;
            string message;
            if (Client.Character.Guild == null
                || !Packet.TryReadUShort(out length)
                || !Packet.TryReadString(out message, length))
            {
                return;
            }

            //response packets
            using (var packet = new Packet(SH29Type.UnkMessageChange))
            {
                packet.WriteHexAsBytes("68 1B 00 92 AD F8 4F 2E 00 00 00 2B 00 00 00 17 00 00 00 07 00 00 00 06 00 00 00 70 00 00 00 06 00 00 00 BC 00 00 00 01 00 00 00 00 00");

                Client.SendPacket(packet);
            }
            using (var packet = new Packet(SH29Type.ClearGuildDetailsMessage))
            {
                packet.WriteUShort(3137);
                packet.WriteLong(0);

                Client.SendPacket(packet);
            }
            using (var packet = new Packet(SH29Type.UpdateGuildMessageResponse))
            {
                packet.WriteUShort(3137);
                Client.SendPacket(packet);
            }

            //update guild
            lock (Client.Character.Guild.ThreadLocker)
            {
                Client.Character.Guild.Message = message;
                Client.Character.Guild.MessageCreater = Client.Character;
                Client.Character.Guild.MessageCreateTime = Program.CurrentTime;

                Client.Character.Guild.Save();

                //broadcast packet to all guild members
                using (var packet = new Packet(SH29Type.SendUpdateGuildDetails))
                {
                    packet.Fill(4, 0x00);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Second);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Minute);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Hour);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Day);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Month - 1);
                    packet.WriteInt(Client.Character.Guild.MessageCreateTime.Year - 1900);
                    packet.WriteInt(0);
                    packet.WriteLong(0);
                    packet.WriteString(Client.Character.Character.Name, 16);
                    packet.WriteUShort(length);
                    packet.WriteString(message, length);

                    Client.Character.Guild.Broadcast(packet);
                }

                //send packet to zone that guild message changed
                using (var packet = new InterPacket(InterHeader.ZONE_GuildMessageUpdate))
                {
                    packet.WriteInt(Client.Character.Guild.ID);
                    packet.WriteInt(Client.Character.ID);
                    packet.WriteDateTime(Client.Character.Guild.MessageCreateTime);

                    packet.WriteUShort(length);
                    packet.WriteString(message, length);
                    ZoneManager.Instance.Broadcast(packet);
                }
            }
        }
Example #12
0
 public void WriteInfo(Packet packet)
 {
     packet.WriteString(Character.Character.Name, 16);
     packet.Fill(65, 0x00);//unk
     packet.WriteBool(Character.IsIngame);
     packet.Fill(3, 0x00);//unk
     packet.WriteByte(Character.Character.Job);//job
     packet.WriteByte(Character.Character.CharLevel);//level
     packet.WriteByte(0);// unk
     packet.WriteString(DataProvider.GetMapname(Character.Character.PositionInfo.Map), 12);//mapName
     packet.WriteByte((byte)RegisterDate.Month);//month
     packet.WriteByte(184);//year fortmat unkown
     packet.WriteByte((byte)RegisterDate.Day);//day
     packet.WriteByte(0);//unk
     packet.WriteByte(0);  //unk
 }
Example #13
0
 private void Testg(ZoneCharacter character, params string[] param)
 {
     //05 58 00 04 0A 7A 0F 00 90 2B
     using (var pack = new Packet(SH38Type.AcademyMemberJoined))
     {
         pack.WriteString("invider", 16);
         pack.WriteString("Create", 16);
         pack.WriteByte(6);//rank
         pack.WriteInt(0);//unk
         pack.WriteUShort(9000);//korp
         pack.Fill(64, 0x00);//unk
         pack.WriteByte(95);// (this.isOnline ? (byte)0x95 : (byte)0x00);
         pack.Fill(3, 0x00);//unk
         pack.WriteByte(21);
         pack.WriteByte(255);
         pack.Fill(13, 0x00);//unk
         character.Client.SendPacket(pack);
     }
 }
Example #14
0
        //this is used by the smaller writer (e.g. additem, unequip, equip)
        public void WriteSmallInfo(Packet packet)
        {
            packet.WriteUShort(this.ItemID);
            switch (SlotType)
            {
                case ItemSlot.Helm:
                case ItemSlot.Armor:
                case ItemSlot.Pants:
                case ItemSlot.Boots:
                case ItemSlot.Weapon2:
                case ItemSlot.Weapon:
                    packet.WriteByte(Upgrades);
                    packet.Fill(6, 0);
                    packet.WriteUShort(ushort.MaxValue); //unk
                    packet.WriteUInt(GetExpiringTime());
                    packet.WriteUShort(ushort.MaxValue);
                    break;

                default:
                    packet.WriteUInt(GetExpiringTime());
                    packet.WriteInt(0); //unk
                    break;
            }
        }
Example #15
0
        public void WriteDetailedInfoExtra(Packet packet, bool levelUP = false)
        {
            if (!levelUP)
            {
                packet.WriteUShort(this.MapObjectID);
            }

            packet.WriteLong(this.Exp);
            packet.WriteULong(DataProvider.Instance.GetMaxExpForLevel(this.Level));

            packet.WriteInt(BaseStats.Strength);
            packet.WriteInt(BaseStats.Strength + GetExtraStr());
            packet.WriteInt(BaseStats.Endurance);
            packet.WriteInt(BaseStats.Endurance + GetExtraEnd());
            packet.WriteInt(BaseStats.Dexterity);
            packet.WriteInt(BaseStats.Dexterity + GetExtraDex());
            packet.WriteInt(BaseStats.Intelligence);
            packet.WriteInt(BaseStats.Intelligence + GetExtraInt());

            packet.WriteInt(0); // Wizdom. It isn't set in the server so it can contain shit from old buffers... :D
            packet.WriteInt(0); // I once had a name here :P

            packet.WriteInt(BaseStats.Spirit);
            packet.WriteInt(BaseStats.Spirit + GetExtraSpr());

            packet.WriteInt(GetWeaponDamage()); //base damage
            packet.WriteInt(GetWeaponDamage(true)); //increased damage (e.g. buffs)
            packet.WriteInt(GetMagicDamage()); //magic dmg
            packet.WriteInt(GetMagicDamage(true)); //inc magic dmg

            packet.WriteInt(GetWeaponDefense()); //todo equip stats loading (weapondef)
            packet.WriteInt(GetWeaponDefense(true)); //weapondef inc

            packet.WriteInt(GetAim()); //TODO: basestats aim + dex?
            packet.WriteInt(GetAim(true)); //aim inc (calcuate later based on dex)

            packet.WriteInt(GetEvasion()); //evasion
            packet.WriteInt(GetEvasion(true)); //evasion inc

            packet.WriteInt(GetWeaponDamage()); //damage block again
            packet.WriteInt(GetWeaponDamage(true));

            packet.WriteInt(GetMagicDamage()); //magic damage
            packet.WriteInt(GetMagicDamage(true));

            packet.WriteInt(GetMagicDefense()); //magic def
            packet.WriteInt(GetMagicDefense(true)); //magic def inc

            packet.WriteInt(1);
            packet.WriteInt(20);
            packet.WriteInt(2);
            packet.WriteInt(40);

            packet.WriteUInt(BaseStats.MaxHP); //max HP
            packet.WriteUInt(BaseStats.MaxSP); //max SP
            if (character.Job == (int)Job.Crusader)
                packet.WriteInt(100);   // max LP
            else
                packet.WriteInt(0);              // max LP
            packet.WriteInt(0);                   // UNK
            packet.WriteInt(BaseStats.MAXSoulHP);   // Max HP Stones
            packet.WriteInt(BaseStats.MAXSoulSP);   // Max SP Stones
            packet.Fill(64, 0);
            if (!levelUP)
            {
                packet.WriteInt(this.Position.X);
                packet.WriteInt(this.Position.Y);
            }
        }
Example #16
0
 public void Write(Packet packet)
 {
     packet.WriteUShort(this.MapObjectID);
     packet.WriteByte(2);
     packet.WriteUShort(ID);
     packet.WriteInt(this.Position.X);
     packet.WriteInt(this.Position.Y);
     packet.WriteByte(this.Rotation);
     packet.Fill(119, 0);
     packet.WriteUShort(2);
 }
Example #17
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
     }
 }
Example #18
0
        public static void On_GameClient_GetAcademyList(WorldClient Client, Packet pPacket)
        {
            if (Client.Character == null)
            {
                return;
            }

            const int GuildsPerPacket = 54;
            lock (GuildManager.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(SH38Type.SendAcademyList);
                                    listPacket.WriteUShort(6312);
                                    listPacket.WriteByte(1);
                                    listPacket.WriteUShort((ushort)guildCount);
                                    listPacket.WriteUShort(0);
                                    listPacket.WriteUShort((ushort)Math.Min(GuildsPerPacket, guildCount - globalCount));
                                    listPacket.WriteUShort(0);
                                }

                                Guild guild;
                                if (GuildManager.GetGuildByID(reader.GetInt32("ID"), out guild))
                                {
                                    //write packet
                                    listPacket.WriteString(guild.Name, 16);
                                    listPacket.WriteString(guild.Master.Character.Character.Name, 16);
                                    listPacket.WriteUShort((ushort)guild.Members.Count);
                                    listPacket.WriteUShort((ushort)guild.Academy.Members.Count);
                                    listPacket.WriteUShort(guild.Academy.Points); // Graduates
                                }
                                else
                                {
                                    pPacket.Fill(38, 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;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #19
0
 public void WritePacket(Packet pPacket)
 {
     pPacket.WriteBool(IsOnline);	// Logged In
     pPacket.WriteByte(this.Month);	// Last connect Month << 4 (TODO)
     pPacket.WriteByte(this.Day);	// Last connect Day (TODO)
     pPacket.WriteByte(0);	// Unknown (TODO)
     pPacket.WriteString(this.Name, 16);
     pPacket.WriteByte(this.Job);
     pPacket.WriteByte(this.Level);
     pPacket.WriteByte(0);	// In Party (TODO)
     pPacket.WriteByte(0);	// Unkown (TODO)
     pPacket.WriteString(this.Map, 12);
     pPacket.Fill(32, 0);
 }
Example #20
0
        public void WriteInfo(Packet Packet)
        {
            Packet.WriteString(Character.Character.Name, 16);
            Packet.WriteByte((byte)Rank);
            Packet.WriteInt(0); //unk ?

            Packet.WriteUShort(Corp);
            Packet.WriteByte(0);
            Packet.WriteUShort(0xFFFF); //unk
            Packet.WriteUShort(0xFFFF); //unk
            Packet.WriteByte(0);
            Packet.WriteInt(32);
            Packet.WriteInt(32);
            Packet.Fill(50, 0x00); // unk
            Packet.WriteByte((byte)(Character.IsOnline ? 0xB9 : 0x00));
            Packet.Fill(3, 0x00); // unk
            Packet.WriteByte(Character.Character.Job);
            Packet.WriteByte(Character.Character.CharLevel);
            Packet.WriteByte(0);
            Packet.WriteString(Data.DataProvider.GetMapname(Character.Character.PositionInfo.Map), 12);
        }
Example #21
0
        public void WriteCharacterDisplay(Packet packet)
        {
            packet.WriteUShort(MapObjectID);
            packet.WriteString(Name, 16);
            packet.WriteInt(Position.X);
            packet.WriteInt(Position.Y);
            packet.WriteByte(Rotation);                // Rotation
            packet.WriteByte((byte)State);          // Player State (1,2 - Player, 3 - Dead, 4 - Resting, 5 - Vendor, 6 - On Mount)
            packet.WriteByte((byte)Job);
            if (State != PlayerState.Resting && State != PlayerState.Vendor && this.House == null)
            {
                WriteLook(packet);
                WriteEquipment(packet);
            }
            else
            {
                this.House.WritePacket(packet);
            }
            WriteRefinement(packet);

            packet.WriteUShort(0);  // Mount Handle
            packet.WriteUShort(0xffff);
            packet.WriteByte(0xff);          // Emote (0xff = nothing)
            packet.WriteUShort(0xffff);
            packet.WriteShort(0);
            packet.WriteUShort(0);             // Mob ID (title = 10)

            packet.Fill(81, 0);                // Buff Bits? Something like that
            packet.WriteInt(character.GuildID.HasValue ? character.GuildID.Value : 0);      // Guild ID
            packet.WriteByte(0x02);            // UNK (0x02)
            packet.WriteBool(false);            // In Guild Academy (0 - No, 1 - Yes)
            packet.WriteBool(true);            // Pet AutoPickup   (0 - Off, 1 - On)
            packet.WriteByte(this.Level);
            packet.Fill(32, 0);
            packet.Fill(2, 0xFF);
            packet.WriteUShort(522);
        }
Example #22
0
        private static void On_CharacterManager_CharacterLogin(WorldCharacter Character)
        {
            if (Character.IsInGuild)
            {
                var guild = Character.Guild;

                //send guild info to client
                using (var packet = new Packet(SH4Type.CharacterGuildinfo))
                {
                    guild.WriteGuildInfo(packet);

                    Character.Client.SendPacket(packet);
                }

                //send member list to client
                guild.SendMemberList(Character.Client);

                GuildMember member;
                if (guild.GetMember(Character.Character.Name, out member))
                {
                    //send guild member logged in to other guild members
                    using (var packet = new Packet(SH29Type.GuildMemberLoggedIn))
                    {
                        packet.WriteString(Character.Character.Name, 16);

                        Character.Guild.Broadcast(packet, member);
                    }
                }

                //send packet to zone that guild member logged in
                using (var packet = new InterPacket(InterHeader.ZONE_GuildMemberLogin))
                {
                    packet.WriteInt(guild.ID);
                    packet.WriteInt(Character.ID);

                    ZoneManager.Instance.Broadcast(packet);
                }
            }
            else
            {
                using (var packet = new Packet(SH4Type.CharacterGuildinfo))
                {
                    packet.WriteInt(0);

                    Character.Client.SendPacket(packet);
                }
            }

            //academy
            var academy = Character.GuildAcademy;
            if (academy != null)
            {
                if (Character.IsInGuildAcademy)
                {
                    using (var packet = new Packet(SH4Type.CharacterGuildacademyinfo))
                    {
                        academy.WriteInfo(packet);

                        Character.Client.SendPacket(packet);
                    }

                    academy.SendMemberList(Character.Client);
                }
                else
                {
                    using (var packet = new Packet(SH4Type.CharacterGuildacademyinfo))
                    {
                        packet.Fill(5, 0);

                        Character.Client.SendPacket(packet);
                    }
                }
            }
            else
            {
                using (var packet = new Packet(SH4Type.CharacterGuildacademyinfo))
                {
                    packet.Fill(5, 0);

                    Character.Client.SendPacket(packet);
                }
            }
        }
Example #23
0
 public void WriteDetailedInfo(Packet pPacket)
 {
     pPacket.WriteInt(ID);
     pPacket.WriteString(this.Name, 16);
     pPacket.WriteByte(this.Slot);
     pPacket.WriteByte(this.Level);
     pPacket.WriteLong(this.Exp);
     pPacket.WriteInt(0);                // UNK
     pPacket.WriteShort(this.StonesHP);
     pPacket.WriteShort(this.StonesSP);
     pPacket.WriteUInt(this.HP);
     pPacket.WriteUInt(this.SP);
     pPacket.Fill(4, 0); //UNK
     pPacket.WriteInt(this.Fame);                // Fame
     pPacket.WriteLong(this.Money); //TODO: inventory class
     pPacket.WriteString(this.Map.MapInfo.ShortName, 12);
     pPacket.WriteInt(this.Position.X);
     pPacket.WriteInt(this.Position.Y);
     pPacket.WriteByte(this.Rotation);
     pPacket.WriteByte(this.Str);   // Str bonus
     pPacket.WriteByte(this.End);   // End bonus
     pPacket.WriteByte(this.Dex);   // Dex bonus
     pPacket.WriteByte(this.Int);   // Int bonus
     pPacket.WriteByte(this.Spr);   // Spr bonus
     pPacket.WriteShort(0);               // UNK
     pPacket.WriteUInt(0);               // Killpoints
     pPacket.Fill(7, 0);                 // UNK
 }
Example #24
0
 public static Packet InventoryMessage(ushort pMessage, ushort pID = ushort.MaxValue, ushort pCount = (ushort) 1)
 {
     /*  0x0341 	Item Obtained
         0x0342 	Failed to obtain
         0x0346 	Inventory Full  */
     Packet pack = new Packet();
     pack.WriteUShort(0x300a);
     pack.WriteUShort(pID);
     pack.WriteInt(pCount);
     pack.WriteUShort(pMessage);
     pack.Fill(2, 0xff);
     return pack;
 }
Example #25
0
 public void WriteEquipment(Packet packet)
 {
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Helm));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Weapon));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Armor));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Weapon2));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Pants));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Boots));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.CostumeBoots));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.CostumePants));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.CostumeArmor));
     packet.Fill(6, 0xff);              // UNK
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Glasses));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.CostumeHelm));
     packet.Fill(2, 0xff);              // UNK
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.CostumeWeapon));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Wing));
     packet.Fill(2, 0xff);              // UNK
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Tail));
     packet.WriteUShort(GetEquippedBySlot(ItemSlot.Pet));
 }
Example #26
0
        public void WriteEquipStats(Packet packet)
        {
            byte StatCount = 0;
            if (Str > 0) StatCount++;
            if (End > 0) StatCount++;
            if (Dex > 0) StatCount++;
            if (Spr > 0) StatCount++;
            if (Int > 0) StatCount++;

            packet.WriteUShort(ItemID);
            switch (this.SlotType)
            {
                case ItemSlot.Helm:
                case ItemSlot.Armor:
                case ItemSlot.Pants:
                case ItemSlot.Boots:
                    packet.WriteByte(this.Upgrades);   // Refinement
                    packet.WriteByte(0);
                    packet.WriteShort(0); // Or int?
                    packet.WriteShort(0);
                    packet.WriteByte(0);
                    packet.WriteInt(0); //Temp
                    packet.WriteByte(0x01); //Temp
                    break;
                // case ItemSlot.Bow: // Shield = same
                case ItemSlot.Weapon2:
                case ItemSlot.Weapon:
                    packet.WriteByte(this.Upgrades);   // Refinement
                    packet.WriteByte(0);
                    packet.WriteShort(0); // Or int?
                    packet.WriteShort(0);
                    if (this.SlotType == ItemSlot.Weapon || (this.SlotType == ItemSlot.Weapon2 && Info.TwoHand))
                    {
                        packet.WriteByte(0);
                        // Licence data
                        packet.WriteUShort(0xFFFF);    // Nr.1 - Mob ID
                        packet.WriteUInt(0);           // Nr.1 - Kill count
                        packet.WriteUShort(0xFFFF);    // Nr.2 - Mob ID
                        packet.WriteUInt(0);           // Nr.2 - Kill count
                        packet.WriteUShort(0xFFFF);    // Nr.3 - Mob ID
                        packet.WriteUInt(0);           // Nr.3 - Kill count
                        packet.WriteUShort(0xFFFF);        // UNK
                        packet.WriteString("", 16);    // First licence adder name
                    }
                    packet.WriteByte(0);
                    packet.Fill(9, (byte)0xFF);
                    packet.Fill(7, 0x00);
                    //packet.WriteUInt(GetExpiringTime());               // Expiring time (1992027391 -  never expires)
                    break;
                case ItemSlot.Pet:
                    packet.WriteByte(this.Upgrades);   // Pet Refinement Lol
                    packet.Fill(2, 0);                     // UNK
                    packet.WriteUInt(GetExpiringTime());               // Expiring time (1992027391 -  never expires)
                    packet.WriteUInt(0);               // Time? (1992027391 -  never expires)
                    break;
                case ItemSlot.Earings:
                case ItemSlot.Necklace:
                case ItemSlot.Ring:
                    packet.WriteUInt(GetExpiringTime());               // Expiring time (1992027391 -  never expires)
                    packet.WriteUInt(0);               // Time? (1992027391 -  never expires)
                    packet.WriteByte(this.Upgrades);   // Refinement
                    // Stats added while refining
                    packet.WriteUShort(0);             // it may be byte + byte too (some kind of counter when item downgrades)
                    packet.WriteUShort(0);             // STR
                    packet.WriteUShort(0);             // END
                    packet.WriteUShort(0);             // DEX
                    packet.WriteUShort(0);             // INT
                    packet.WriteUShort(0);             // SPR
                    break;
                case ItemSlot.CostumeWeapon:
                case ItemSlot.CostumeShield:
                    packet.WriteUInt(25000);           // Skin Durability
                    break;
                default:
                    //packet.WriteUInt(GetExpiringTime());      // Expiring time (1992027391 -  never expires)
                    //packet.WriteUInt(0);                        // Time? (1992027391 -  never expires)
                    break;
            }

            //// Random stats data (Not those what were added in refinement)
            //switch (this.SlotType)
            //{                       // Stat count (StatCount << 1 | Visible(0 or 1 are stats shown or not))
            //    case ItemSlot.Earings:
            //        packet.WriteByte((byte)(StatCount << 1 | 1));
            //        break;
            //    case ItemSlot.Necklace:
            //    case ItemSlot.Ring:
            //        packet.WriteByte((byte)(StatCount << 1 | 1));
            //        break;
            //    case ItemSlot.Helm:
            //    case ItemSlot.Armor:
            //    case ItemSlot.Pants:
            //    case ItemSlot.Boots:
            //    case ItemSlot.Weapon2:
            //    case ItemSlot.Weapon:
            //        packet.WriteByte((byte)(StatCount << 1 | 1));
            //        break;
            //    case ItemSlot.Pet:          // Yes!! Its possible to give stats to pet also (It overrides default one(s)).
            //        packet.WriteByte((byte)(StatCount << 1 | 1));
            //        break;
            //}
            //// foreach stat
            ////pPacket.WriteByte(type);              // Stat type ( 0 = STR, 1 = END, 2 = DEX, 3 = INT, 4 = SPR )
            ////pPacket.WriteUShort(amount);          // Amount
            //// end foreach
            //if (Str > 0) { packet.WriteByte(0); packet.WriteUShort(Str); }
            //if (End > 0) { packet.WriteByte(1); packet.WriteUShort(End); }
            //if (Dex > 0) { packet.WriteByte(2); packet.WriteUShort(Dex); }
            //if (Spr > 0) { packet.WriteByte(3); packet.WriteUShort(Spr); }
            //if (Int > 0) { packet.WriteByte(4); packet.WriteUShort(Int); }
        }
Example #27
0
 private static void InvalidClientVersion(LoginClient pClient)
 {
     using (Packet pack = new Packet(SH3Type.IncorrectVersion))
     {
         pack.Fill(10, 0);
         pClient.SendPacket(pack);
     }
 }
Example #28
0
        private static void SendWorldServerIP(LoginClient pClient, WorldConnection wc, string hash)
        {
            using (var pack = new Packet(SH3Type.WorldServerIP))
            {
                pack.WriteByte((byte)wc.Status);

                string ip = pClient.Host == "127.0.0.1" ? "127.0.0.1" : wc.IP;
                pack.WriteString(wc.IP, 16);

                pack.WriteUShort(wc.Port);
                pack.WriteString(hash, 32);
                pack.Fill(32, 0);
                pClient.SendPacket(pack);
            }
        }
Example #29
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);
 }
Example #30
0
        private void InvideResponse(WorldClient pClient,string name,byte level)
        {
            using (var packet = new Packet(SH37Type.SendMasterRequestReponse))
            {
                DateTime now = DateTime.Now;
                packet.WriteUShort(0x1740);//pcode
                packet.WriteString(name, 16);
                packet.WriteByte(0x01);//IsOnline (now.Year - 1900 << 1) | isonline
                packet.WriteByte((byte)(now.Month << 4));
                packet.WriteByte((byte)now.Day);//day
                packet.WriteByte(0);//year
                packet.WriteByte(level);//level
                packet.WriteByte(0);//unk
                packet.WriteByte(2);//unk
                packet.WriteString("KüssMirDieFüße",14);//WTF?
                packet.Fill(22, 0x00);
                packet.WriteByte(112);//unk
                packet.WriteByte(112);//unk
                packet.WriteByte(0);//unk
                pClient.SendPacket(packet);

            }
        }