packetx() public static method

public static packetx ( float x, byte sector ) : float
x float
sector byte
return float
Esempio n. 1
0
 /////////////////////////////////////////////////////////////////////////////////
 // Save position
 /////////////////////////////////////////////////////////////////////////////////
 #region Save position
 protected void SavePlayerPosition()
 {
     //Wrap our function inside a catcher
     try
     {
         //Update database
         if (!File.FileLoad.CheckCave(Character.Position.xSec, Character.Position.ySec))
         {
             MsSQL.UpdateData("update character set xsect='" + Character.Position.xSec +
                              "', ysect='" + Character.Position.ySec +
                              "', xpos='" + Math.Round(Formule.packetx(Character.Position.x, Character.Position.xSec)) +
                              "', ypos='" + Math.Round(Formule.packety(Character.Position.y, Character.Position.ySec)) +
                              "', zpos='" + Math.Round(Character.Position.z) +
                              "' where id='" + Character.Information.CharacterID + "'");
         }
         else
         {
             MsSQL.UpdateData("update character set xsect='" + Character.Position.xSec +
                              "', ysect='" + Character.Position.ySec +
                              "', xpos='" + Math.Round(Formule.cavepacketx(Character.Position.x)) +
                              "', ypos='" + Math.Round(Formule.cavepackety(Character.Position.y)) +
                              "', zpos='" + Math.Round(Character.Position.z) +
                              "' where id='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Save position error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 2
0
 /////////////////////////////////////////////////////////////////////////////////
 // Cave movement teleport
 /////////////////////////////////////////////////////////////////////////////////
 public void Movement_CaveTeleport()// This was changed due to going in and out of caves to change the movment patten
 {
     try
     {
         // if our destination is caveteleport
         foreach (Global.CaveTeleports r in Data.CaveTeleports)
         {
             if (!File.FileLoad.CheckCave(Character.Position.xSec, Character.Position.ySec))
             {
                 if (Formule.gamedistance(Formule.packetx(Character.Position.x, Character.Position.xSec), Formule.packety(Character.Position.y, Character.Position.ySec), (float)r.x, (float)r.y) <= 10)
                 {
                     foreach (Global.cavepoint p in Data.cavePointBase)
                     {
                         if (p != null)
                         {
                             if (p.Name == r.name)
                             {
                                 TeleportCave(p.Number);
                                 break;
                             }
                         }
                     }
                     break;
                 }
             }
             else
             {
                 if (Formule.gamedistance(Formule.cavepacketx(Character.Position.x), Formule.cavepackety(Character.Position.y), (float)r.x, (float)r.y) <= 10)
                 {
                     foreach (Global.cavepoint p in Data.cavePointBase)
                     {
                         if (p != null)
                         {
                             if (p.Name == r.name)
                             {
                                 TeleportCave(p.Number);
                                 break;
                             }
                         }
                     }
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 3
0
 /////////////////////////////////////////////////////////////////////////////////
 // Save return / last place of death etc
 /////////////////////////////////////////////////////////////////////////////////
 #region Save last point of death or return scroll usage
 protected void SavePlayerReturn()
 {
     //Wrap our function inside a catcher
     try
     {
         //Update database
         MsSQL.UpdateData("update character_rev set revxsec='" + Character.Position.xSec +
                          "', revysec='" + Character.Position.ySec +
                          "', revx='" + Math.Round(Formule.packetx(Character.Position.x, Character.Position.xSec)) +
                          "', revy='" + Math.Round(Formule.packety(Character.Position.y, Character.Position.ySec)) +
                          "', revz='" + Math.Round(Character.Position.z) +
                          "' where charname='" + Character.Information.Name + "'");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Save return position error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 4
0
        public static byte[] Party_DataMember(party p)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(Systems.SERVER_PARTYMEMBER_DATA);
            //Write static byte
            Writer.Byte(0xFF);
            //Write party id
            Writer.DWord(p.ptid);
            //Write leader id
            Writer.DWord(p.LeaderID);
            //Write byte party type
            Writer.Byte(p.Type);
            //Write total amount of members in party
            Writer.Byte(p.Members.Count);
            //Repeat for each member in party -1
            for (byte b = 0; b <= p.Members.Count - 1; b++)
            {
                //Get player detail information
                Systems PartyMemberInfo = Systems.GetPlayer(p.Members[b]);
                //Calculate hp and mp
                int partyPercentMP = (int)Math.Round((decimal)(PartyMemberInfo.Character.Stat.SecondMP * 10) / PartyMemberInfo.Character.Stat.Mp) << 4;
                int partyPercentHP = (int)Math.Round((decimal)(PartyMemberInfo.Character.Stat.SecondHp * 10) / PartyMemberInfo.Character.Stat.Hp);
                //Set percent
                int partyPercent = partyPercentHP | partyPercentMP;
                //Write static byte
                Writer.Byte(0xff);
                //Write unique member id
                Writer.DWord(PartyMemberInfo.Character.Information.UniqueID);
                //Write character name
                Writer.Text(PartyMemberInfo.Character.Information.Name);
                //Write character model
                Writer.DWord(PartyMemberInfo.Character.Information.Model);
                //Write character level
                Writer.Byte(PartyMemberInfo.Character.Information.Level);
                //Write stat hp mp information
                Writer.Byte((byte)partyPercent);
                //Write x and y sector
                Writer.Byte(PartyMemberInfo.Character.Position.xSec);
                Writer.Byte(PartyMemberInfo.Character.Position.ySec);
                //Write x z y
                Writer.Word(Formule.packetx(PartyMemberInfo.Character.Position.x, PartyMemberInfo.Character.Position.xSec));
                Writer.Word(PartyMemberInfo.Character.Position.z);
                Writer.Word(Formule.packety(PartyMemberInfo.Character.Position.y, PartyMemberInfo.Character.Position.ySec));
                //Write double word 1
                Writer.Word(1);
                Writer.Word(1);
                //If player has a guild
                if (PartyMemberInfo.Character.Network.Guild.Name != null)
                {
                    //Write guild name
                    Writer.Text(PartyMemberInfo.Character.Network.Guild.Name);
                }
                //If player has no guild
                else
                {
                    //Write word 0 value
                    Writer.Word(0);
                }
                //Write static byte
                Writer.Byte(0);
                //Write dword
                Writer.DWord(0);
                Writer.DWord(0);
            }
            //Return all bytes for sending
            return(Writer.GetBytes());
        }
Esempio n. 5
0
        public static byte[] Party_Data(byte type, int id)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(Systems.SERVER_PARTY_DATA);
            //Write type byte
            Writer.Byte(type);
            //Create switch for type given
            switch (type)
            {
            case 1:
                //Remove party state
                Writer.Byte(0x0b);
                Writer.Byte(0);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 2:
                //Formed party new member update
                Systems CharacterInformation = Systems.GetPlayer(id);
                //Write static byte
                Writer.Byte(0xFF);
                //Write unique character id
                Writer.DWord(CharacterInformation.Character.Information.UniqueID);
                //Write character name
                Writer.Text(CharacterInformation.Character.Information.Name);
                //Write character model
                Writer.DWord(CharacterInformation.Character.Information.Model);
                //Write character level
                Writer.Byte(CharacterInformation.Character.Information.Level);
                //Write static byte
                Writer.Byte(0xAA);
                //Write x and y sector
                Writer.Byte(CharacterInformation.Character.Position.xSec);
                Writer.Byte(CharacterInformation.Character.Position.ySec);
                //Write x z y
                Writer.Word(Formule.packetx(CharacterInformation.Character.Position.x, CharacterInformation.Character.Position.xSec));
                Writer.Word(CharacterInformation.Character.Position.z);
                Writer.Word(Formule.packety(CharacterInformation.Character.Position.y, CharacterInformation.Character.Position.ySec));
                //Write double word 1
                Writer.Word(1);
                Writer.Word(1);
                //If character is in a guild
                if (CharacterInformation.Character.Network.Guild.Name != null)
                {
                    //Write guild name
                    Writer.Text(CharacterInformation.Character.Network.Guild.Name);
                }
                //If character has no guild
                else
                {
                    //Write 0 word value
                    Writer.Word(0);
                }
                //Static byte
                Writer.Byte(0);
                //Permissions
                Writer.DWord(0);
                Writer.DWord(0);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 3:
                //Write character id
                Writer.DWord(id);
                //Write static byte 4
                Writer.Byte(4);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 6:
                //Update player location and stat
                CharacterInformation = Systems.GetPlayer(id);
                //Calculate hp and mp
                int partyPercentMP = (int)Math.Round((decimal)(CharacterInformation.Character.Stat.SecondMP * 10) / CharacterInformation.Character.Stat.Mp) << 4;
                int partyPercentHP = (int)Math.Round((decimal)(CharacterInformation.Character.Stat.SecondHp * 10) / CharacterInformation.Character.Stat.Hp);
                //Set percent information
                int partyPercent = partyPercentHP | partyPercentMP;
                //Write character id
                Writer.DWord(id);
                //If character is moving
                if (CharacterInformation.Character.Position.Walking)
                {
                    //Write byte 20
                    Writer.Byte(0x20);
                    //Write location information
                    Writer.Byte(CharacterInformation.Character.Position.packetxSec);
                    Writer.Byte(CharacterInformation.Character.Position.packetySec);
                    Writer.Word(CharacterInformation.Character.Position.packetX);
                    Writer.Word(CharacterInformation.Character.Position.packetZ);
                    Writer.Word(CharacterInformation.Character.Position.packetY);
                    //Write double word 1
                    Writer.Word(1);
                    Writer.Word(1);
                }
                //If not walking
                else
                {
                    //Write static byte 4
                    Writer.Byte(4);
                    //Write hp mp information
                    Writer.Byte((byte)partyPercent);
                }
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 9:
                //New leader id
                Writer.DWord(id);
                //Return all bytes for sending
                return(Writer.GetBytes());
            }
            //Return all bytes for sending
            return(Writer.GetBytes());
        }
Esempio n. 6
0
        void ActionNormalAttack()
        {
            try
            {
                float x = 0, y = 0;

                bool[] aRound = null;

                if (Character.Action.Object != null)
                {
                    //Set target object as object
                    obj TargetInformation = Character.Action.Object as obj;
                    //If our target object is a monster
                    #region Attacking a monster
                    if (Data.ObjectBase[TargetInformation.ID].Object_type == Global.objectdata.NamdedType.MONSTER)
                    {
                        //If state is dead
                        if (TargetInformation.State == 4)
                        {
                            //Set normal attack bool to false
                            Character.Action.nAttack = false;
                            //Stop attack timer
                            StopAttackTimer();
                        }

                        if (TargetInformation.Agro == null)
                        {
                            TargetInformation.Agro = new List <_agro>();
                        }
                        x = (float)TargetInformation.x;
                        y = (float)TargetInformation.y;

                        if (!TargetInformation.Attacking)
                        {
                            TargetInformation.AddAgroDmg(Character.Information.UniqueID, 1);
                        }
                        if (TargetInformation.Die || TargetInformation.GetDie)
                        {
                            StopAttackTimer();
                            return;
                        }
                    }
                    #endregion
                    //If attacking a player
                    #region Attacking a player
                    if (Data.ObjectBase[TargetInformation.ID].Object_type == Global.objectdata.NamdedType.PLAYER)
                    {
                        if (!Character.Information.PvP)
                        {
                            Character.Action.nAttack = false;
                            StopAttackTimer();
                            return;
                        }

                        Systems sys = Character.Action.Object as Systems;
                        if (sys.Character.State.LastState == 4)
                        {
                            StopAttackTimer();
                            return;
                        }

                        if (!(Character.Information.PvP && sys.Character.Information.PvP))
                        {
                            StopAttackTimer();
                            return;
                        }
                        if (!Character.InGame)
                        {
                            StopAttackTimer();
                            return;
                        }
                        x      = sys.Character.Position.x;
                        y      = sys.Character.Position.y;
                        aRound = sys.Character.aRound;
                    }
                    #endregion

                    double distance = Formule.gamedistance(Character.Position.x,
                                                           Character.Position.y,
                                                           x,
                                                           y);

                    if (Character.Information.Item.wID == 0)
                    {
                        distance -= 0.5;
                    }
                    else
                    {
                        distance -= Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                    }

                    if (distance > 0)
                    {
                        float farkx = x;
                        float farky = y;

                        if (Character.Information.Item.wID == 0)
                        {
                            Character.Position.wX = farkx - Character.Position.x - 0;
                            Character.Position.wY = farky - Character.Position.y - 0;
                            Character.Position.kX = Character.Position.wX;
                            Character.Position.kY = Character.Position.wY;
                        }
                        else
                        {
                            Character.Position.wX = farkx - Character.Position.x - (float)Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                            Character.Position.wY = farky - Character.Position.y - (float)Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                            Character.Position.kX = Character.Position.wX;
                            Character.Position.kY = Character.Position.wY;
                        }

                        Send(Packet.Movement(new DarkEmu_GameServer.Global.vektor(Character.Information.UniqueID,
                                                                                  (float)Formule.packetx((float)farkx, Character.Position.xSec),
                                                                                  (float)Character.Position.z,
                                                                                  (float)Formule.packety((float)farky, Character.Position.ySec),
                                                                                  Character.Position.xSec,
                                                                                  Character.Position.ySec)));

                        Character.Position.Time         = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                        Character.Position.RecordedTime = Character.Position.Time;

                        Character.Position.packetxSec = Character.Position.xSec;
                        Character.Position.packetySec = Character.Position.ySec;

                        Character.Position.packetX = (ushort)Formule.packetx((float)farkx, Character.Position.xSec);
                        Character.Position.packetY = (ushort)Formule.packety((float)farky, Character.Position.ySec);

                        Character.Position.Walking = true;

                        StartMovementTimer((int)(Character.Position.Time * 0.1));

                        return;
                    }
                }
                ActionAttack();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Normal Attack Error : {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 7
0
 /////////////////////////////////////////////////////////////////////////////////
 // Pickup item
 /////////////////////////////////////////////////////////////////////////////////
 void Player_PickUpItem()
 {
     try
     {
         //First check if player allready is picking up an item
         if (Character.Action.PickUping)
         {
             //Get item information that the player has selected.
             world_item item = GetWorldItem(Character.Action.Target);
             //Checks
             if (item == null)
             {
                 Character.Action.PickUping = false; return;
             }
             //If the amount is lower then one
             if (item.amount < 1)
             {
                 item.amount = 1;
             }
             //If not gold model
             if (item.Model > 3)
             {
                 //Get our free slots
                 byte slot = GetFreeSlot();
                 //If to low
                 if (slot <= 12)
                 {
                     Character.Action.PickUping = false;
                     client.Send(Packet.MoveItemError());
                     return;
                 }
                 //Else continue stop delete timer because its allready beeing removed.
                 item.StopDeleteTimer();
                 //Remove the world item spawn
                 Systems.WorldItem.Remove(item);
                 //Delete the global id
                 Global.ID.Delete(item.UniqueID);
                 //Move towards the item
                 Send(Packet.MovementOnPickup(new DarkEmu_GameServer.Global.vektor(Character.Information.UniqueID,
                                                                                   (float)Formule.packetx((float)item.x, item.xSec),
                                                                                   (float)Character.Position.z,
                                                                                   (float)Formule.packety((float)(float)item.y, item.ySec),
                                                                                   Character.Position.xSec,
                                                                                   Character.Position.ySec)));
                 //Send animation packet pickup
                 Send(Packet.Pickup_Animation(Character.Information.UniqueID, 0));
                 //Check what item type we have (Etc, or armor / weapon).
                 int amount = 0;
                 //Set amount or plusvalue
                 #region Amount definition
                 if (Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.BLADE ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_SHIELD ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.BOW ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_AXE ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_CROSSBOW ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_HARP ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_STAFF ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_SWORD ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.GLAVIE ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.SPEAR ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.SWORD ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.EARRING ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.RING ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.NECKLACE ||
                     Data.ItemBase[item.Model].Type == Global.item_database.ArmorType.ARMOR ||
                     Data.ItemBase[item.Model].Type == Global.item_database.ArmorType.GARMENT ||
                     Data.ItemBase[item.Model].Type == Global.item_database.ArmorType.GM ||
                     Data.ItemBase[item.Model].Type == Global.item_database.ArmorType.HEAVY ||
                     Data.ItemBase[item.Model].Type == Global.item_database.ArmorType.LIGHT ||
                     Data.ItemBase[item.Model].Type == Global.item_database.ArmorType.PROTECTOR ||
                     Data.ItemBase[item.Model].Itemtype == Global.item_database.ItemType.AVATAR ||
                     Data.ItemBase[item.Model].Type == Global.item_database.ArmorType.ROBE)
                 {
                     amount = item.PlusValue;
                 }
                 else
                 {
                     amount = item.amount;
                 }
                 #endregion
                 //Send item creation packet
                 client.Send(Packet.GM_MAKEITEM(0, slot, item.Model, (short)amount, (int)Data.ItemBase[item.Model].Defans.Durability, Data.ItemBase[item.Model].ID, item.UniqueID));
                 //Save to database
                 AddItem(item.Model, (short)amount, slot, Character.Information.CharacterID, item.Model);
             }
             //If the item is gold
             else
             {
                 //Remove the spawned item
                 Systems.WorldItem.Remove(item);
                 //Remove global id
                 Global.ID.Delete(item.UniqueID);
                 //Movement packet
                 Send(Packet.MovementOnPickup(new DarkEmu_GameServer.Global.vektor(Character.Information.UniqueID,
                                                                                   (float)Formule.packetx((float)item.x, item.xSec),
                                                                                   (float)Character.Position.z,
                                                                                   (float)Formule.packety((float)(float)item.y, item.ySec),
                                                                                   Character.Position.xSec,
                                                                                   Character.Position.ySec)));
                 //Send animation packet
                 Send(Packet.Pickup_Animation(Character.Information.UniqueID, 0));
                 //Add gold to player information
                 Character.Information.Gold += item.amount;
                 //Send visual packet for gold
                 client.Send(Packet.UpdateGold(Character.Information.Gold));
                 //Send message packet gold gained
                 client.Send(Packet.GoldMessagePick(item.amount));
                 //Save player gold
                 SaveGold();
             }
             //Despawn item for us
             item.DeSpawnMe();
             //Dispose of the item
             item.Dispose();
             //Set picking to false
             Character.Action.PickUping = false;
             if (Timer.Pickup != null)
             {
                 Timer.Pickup.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Pickup Error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 8
0
        /////////////////////////////////////////////////////////////////////////////////
        // Movement checks before picking
        /////////////////////////////////////////////////////////////////////////////////
        void Player_PickUp()
        {
            try
            {
                if (Character.State.Sitting)
                {
                    return;
                }
                if (Character.State.Exchanging)
                {
                    return;
                }

                if (Character.Action.Target != 0)
                {
                    world_item item = GetWorldItem(Character.Action.Target);

                    if (item == null)
                    {
                        return;
                    }

                    double distance = Formule.gamedistance(Character.Position.x, Character.Position.y, (float)item.x, (float)item.y);

                    if (distance >= 1)
                    {
                        Character.Position.wX = (float)item.x - Character.Position.x;
                        Character.Position.wY = (float)item.y - Character.Position.y;

                        Send(Packet.Movement(new DarkEmu_GameServer.Global.vektor(Character.Information.UniqueID, (float)Formule.packetx((float)item.x, item.xSec), (float)Character.Position.z, (float)Formule.packety((float)(float)item.y, item.ySec), Character.Position.xSec, Character.Position.ySec)));

                        Character.Position.Time         = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                        Character.Position.RecordedTime = Character.Position.Time;

                        StartMovementTimer((int)(Character.Position.Time * 0.1));
                        return;
                    }

                    Player_PickUpItem();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 9
0
        public static byte[] Load(character c)
        {

            PacketWriter Writer = new PacketWriter();
            Writer.Create(Systems.SERVER_PLAYERDATA);
            /////////////////////////////////////////////////////// Character basic info
            #region Basic info   
            Writer.DWord(c.Ids.GetLoginID);
            Writer.DWord(c.Information.Model);
            Writer.Byte(c.Information.Volume);
            Writer.Byte(c.Information.Level);
            Writer.Byte(c.Information.Level);
            Writer.LWord(c.Information.XP);
            Writer.DWord(c.Information.SpBar);
            Writer.LWord(c.Information.Gold);
            Writer.DWord(c.Information.SkillPoint);
            Writer.Word(c.Information.Attributes);
            Writer.Byte(c.Information.BerserkBar);
            Writer.DWord(0);
            Writer.DWord(c.Stat.SecondHp);
            Writer.DWord(c.Stat.SecondMP);
            Writer.Bool(c.Information.Level < 20 ? true : false);
            #endregion
            /////////////////////////////////////////////////////// Character Player Kill Info
            #region Pk information
            //Mssql perfection reading with multiple data adapters... while this one is open i can still read anything else from the database
            //With no speed reduction...
            Systems.MsSQL checkpk = new Systems.MsSQL("SELECT * FROM character WHERE name ='" + c.Information.Name + "'");
            using (System.Data.SqlClient.SqlDataReader getinfo = checkpk.Read())
            {
                while (getinfo.Read())
                {
                    byte dailypk = getinfo.GetByte(48);
                    byte pklevel = getinfo.GetByte(49);
                    byte murderlevel = getinfo.GetByte(50);

                    Writer.Byte(dailypk);
                    Writer.Word(pklevel);
                    Writer.DWord(murderlevel);
                    if (murderlevel != 0) c.Information.Murderer = true;
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Title
            #region Title
            Writer.Byte(c.Information.Title);
            #endregion
            /////////////////////////////////////////////////////// Character Pvpstate
            #region Pvp
            Writer.Byte(c.Information.Pvpstate);
            if (c.Information.Pvpstate > 0) 
                c.Information.PvP = true;
            #endregion
            /////////////////////////////////////////////////////// Character Items
            #region Item
            
            Writer.Byte(c.Information.Slots);

            Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "' AND slot >= '0' AND slot <= '" + c.Information.Slots + "' AND inavatar='0' AND storagetype='0'");
            Writer.Byte(ms.Count());
            using (System.Data.SqlClient.SqlDataReader msreader = ms.Read())
            {

                while (msreader.Read())
                {

                    short amount = msreader.GetInt16(6);

                    if (amount < 1) amount = 1;
                    Systems.MsSQL.InsertData("UPDATE char_items SET quantity='" + amount + "' WHERE owner='" + c.Information.CharacterID + "' AND itemid='" + msreader.GetInt32(2) + "' AND id='" + msreader.GetInt32(0) + "' AND storagetype='0'");

                    if (msreader.GetByte(5) == 6)
                        c.Information.Item.wID = Convert.ToInt32(msreader.GetInt32(2));
                    if (msreader.GetByte(5) == 7)
                    {
                        c.Information.Item.sID = msreader.GetInt32(2);
                        c.Information.Item.sAmount = msreader.GetInt16(6);
                    }
                    
                    Item.AddItemPacket(Writer, msreader.GetByte(5), msreader.GetInt32(2), msreader.GetByte(4), amount, msreader.GetInt32(7),msreader.GetInt32(0), msreader.GetInt32(9), msreader.GetInt32(30));
                }
            }
            ms.Close();

            //Avatar
            Writer.Byte(5);

            ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "' AND slot >= '0' AND slot <= '" + c.Information.Slots + "' AND inavatar='1' AND storagetype='0'");

            Writer.Byte(ms.Count());
            using (System.Data.SqlClient.SqlDataReader msreader = ms.Read())
            {
                while (msreader.Read())
                {
                    Item.AddItemPacket(Writer, msreader.GetByte(5), msreader.GetInt32(2), msreader.GetByte(4), msreader.GetInt16(6), msreader.GetInt32(7), msreader.GetInt32(0), msreader.GetInt32(9),msreader.GetInt32(30));
                }
            }
            ms.Close();

            Writer.Byte(0);

            // job mastery 
            Writer.Byte(0x0B);
            Writer.Byte(0);
            Writer.Byte(0);

            #endregion
            ///////////////////////////////////////////////////////  Mastery
            #region Mastery
            if (c.Information.Model <= 12000)
            {
                for (byte i = 1; i <= 8; i++)
                {
                    Writer.Byte(1);
                    Writer.DWord(c.Stat.Skill.Mastery[i]);
                    Writer.Byte(c.Stat.Skill.Mastery_Level[i]);
                }
            }
            else
            {
                if (c.Information.Model >= 14000)
                {
                    for (byte i = 1; i < 8; i++)
                    {
                        Writer.Byte(1);
                        Writer.DWord(c.Stat.Skill.Mastery[i]);
                        Writer.Byte(c.Stat.Skill.Mastery_Level[i]);
                    }
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Skills
            #region Skill
            Writer.Byte(2);
            Writer.Byte(0);
                for (int i = 1; i <= c.Stat.Skill.AmountSkill; i++)
                {
                    Writer.Byte(1);
                    Writer.DWord(c.Stat.Skill.Skill[i]);
                    Writer.Byte(1);
                }
            Writer.Byte(2);
            #endregion
            /////////////////////////////////////////////////////// Quests
            #region Quest
            Writer.Word(1); // how many Quest ids completed/aborted
            Writer.DWord(1);// Quest id
            Writer.Byte(0);//number of Quests that are live
            #endregion
            Writer.Byte(0);//? for now
            /////////////////////////////////////////////////////// Talisman
            #region Talisman
            Writer.DWord(1);//new
            Writer.DWord(1);//new
            Writer.DWord(0);//? for now
            Writer.DWord(0x0C);//new
            #endregion
            /////////////////////////////////////////////////////// Position + id + speed
            #region Character id / Position / Speed
            Writer.DWord(c.Information.UniqueID);
            Writer.Byte(c.Position.xSec);
            Writer.Byte(c.Position.ySec);
            if (!File.FileLoad.CheckCave(c.Position.xSec, c.Position.ySec))
            {
                Writer.Float(Formule.packetx(c.Position.x, c.Position.xSec));
                Writer.Float(c.Position.z);
                Writer.Float(Formule.packety(c.Position.y, c.Position.ySec));
            }
            else
            {
                Writer.Float(Formule.cavepacketx(c.Position.x));// Added for cave Coords
                Writer.Float(c.Position.z);
                Writer.Float(Formule.cavepackety(c.Position.y));// Added for cave Coords

            }
            Writer.Word(0);							// Angle
            Writer.Byte(0);
            Writer.Byte(1);
            Writer.Byte(0);
            Writer.Word(0);							// Angle
            Writer.Word(0);
            Writer.Byte(0);
            Writer.Bool(false); //berserk

            Writer.Byte(0);//new ?

            Writer.Float(c.Speed.WalkSpeed);
            Writer.Float(c.Speed.RunSpeed);
            Writer.Float(c.Speed.BerserkSpeed);
            #endregion
            /////////////////////////////////////////////////////// Premium Tickets
            #region Premium ticket
            Writer.Byte(0); //ITEM_MALL_GOLD_TIME_SERVICE_TICKET_4W
            #endregion
            /////////////////////////////////////////////////////// GM Check + Name
            #region GM Check + Name
            Writer.Text(c.Information.Name);
            #endregion
            /////////////////////////////////////////////////////// Character jobs
            #region Character Job / hunter thief trader ( old job things )
                //Writer info with job name when on job
                /*if (c.Job.state == 1 && c.Job.Jobname != "0")
                {
                    Writer.Text(c.Job.Jobname);
                    Writer.Byte(3);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }
                //Write basic info noname
                if (c.Job.Jobname == "0")
                {
                    Writer.Word(0);
                    Writer.Byte(3);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }
                //Write no info
                else
                {
                    Writer.Word(0);
                    Writer.Byte(0);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }*/
            #endregion
            #region New job system
            if (c.Job.state == 1)
            {
                Writer.Text(c.Job.Jobname);
                Writer.Byte(1);
                Writer.Byte(c.Job.level);//Level job
                Writer.Byte(c.Information.Level);//Level char
                Writer.Byte(1); // job level? myb
                Writer.LWord(0);// job exp probably y
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
            }
            else
            {

                Writer.Word(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(2); // job type
                Writer.Byte(1); // job level? myb
                Writer.LWord(0);// job exp probably y
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
            }

            #endregion
                /////////////////////////////////////////////////////// Pvp / Pk State
            #region Pvp / Pk State
            if (c.Information.Pvpstate == 1 || c.Information.Murderer)
            {
                Writer.Byte(0x22);
            }
            else if (c.Information.Pvpstate == 0 || !c.Information.Murderer)
            {
                Writer.Byte(0xFF);
            }
            #endregion
            /////////////////////////////////////////////////////// Guide Data 
            #region Guide Data this data stacks on itself so if guide id is 0400000000000000 and next guide is 0300000000000000 the data to send is 0700000000000000

            for (int i = 0; i < 8; ++i)//Main Guide Packet Info
            {
                Writer.Byte(c.Guideinfo.G1[i]);//Reads From Int Array
            }
            #endregion
            /////////////////////////////////////////////////////// Account / Gm Check
            #region Account ID + Gm Check
            Writer.DWord(c.Account.ID);
            Writer.Byte(0);//c.Information.GM
            #endregion
            /////////////////////////////////////////////////////// Quickbar + Autopotion
            #region Bar information
            Writer.Byte(7);
            PacketReader reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\quickbar\" + c.Information.Name + ".dat"));
            PlayerQuickBar(reader, Writer);
            reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\autopot\" + c.Information.Name + ".dat"));
            PlayerAutoPot(reader, Writer);
            #endregion
            /////////////////////////////////////////////////////// Academy
            #region Academy
            Writer.Byte(0); // number of player in academy
            /* // if we have players there 
             Writer.Byte(1);
             Writer.Text("asd"); 
             */
            Writer.Byte(0);//added byte today for 1.310
            Writer.Byte(0);
            Writer.Word(1); 
            Writer.Word(1);
            Writer.Byte(0);
            Writer.Byte(1);
            #endregion
            return Writer.GetBytes();
        }