public void GotoPlayer(character Player, double distance)
        {
            try
            {
                StopMovement();

                float farkx = Player.Position.x + 1; // later have to modify
                float farky = Player.Position.y + 1;
                //Systems.aRound(ref Player.aRound, ref farkx, ref farky);

                xSec = (byte)((farkx / 192) + 135);
                ySec = (byte)((farky / 192) + 92);

                //don't follow the player into the town.
                bool inTown = ObjData.Manager.safeZone.Exists(
                    delegate(ObjData.region r)
                {
                    if (r.SecX == xSec && r.SecY == ySec)
                    {
                        return(true);
                    }
                    return(false);
                });

                Send(Client.Packet.Movement(new ObjData.vektor(UniqueID,
                                                               (float)Formule.packetx((float)farkx, Player.Position.xSec),
                                                               (float)Player.Position.z,
                                                               (float)Formule.packety((float)farky, Player.Position.ySec),
                                                               xSec,
                                                               ySec)));

                if (inTown)
                {
                    AttackStop();
                    Attacking = false;

                    GetDie = true;
                    Die    = true;
                    DeSpawnMe();

                    return;
                }

                // Keep track of the current position of the mob.
                wx = farkx - x;
                wy = farky - y;
                // Calc for time if mob follows initalise speed info Run
                WalkingTime  = (distance / (RunningSpeed * 0.0768)) * 1000.0;
                RecordedTime = WalkingTime;

                StartMovement((int)(WalkingTime / 10));
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        public static byte[] ObjectSpawn(WorldMgr.spez_obj so)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            Writer.DWord(0xFFFFFFFF);                                              //Static
            Writer.DWord(so.spezType);                                             //Type
            Writer.DWord(so.ID);                                                   //skillid
            Writer.DWord(so.UniqueID);                                             //UniqueID of spawn
            Writer.Byte(so.xSec);                                                  //XSec
            Writer.Byte(so.ySec);                                                  //Ysec
            Writer.Float(Formule.packetx((float)so.x, so.xSec));                   //X
            Writer.Float(so.z);                                                    //Z
            Writer.Float(Formule.packety((float)so.y, so.ySec));                   //Y
            Writer.Word(0);                                                        //Angle
            Writer.Byte(1);                                                        //Static
            return(Writer.GetBytes());
        }
        public void ObjeSleepCallBack(object e)
        {
            try
            {
                State  = 3;
                bSleep = false;

                Send(Packet.Movement(new ObjData.vektor(UniqueID,
                                                        (float)Formule.packetx((float)x, xSec),
                                                        (float)z,
                                                        (float)Formule.packety((float)y, ySec),
                                                        xSec,
                                                        ySec)));
                objeSleep.Dispose();
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        public static byte[] SpawnPortal(WorldMgr.Monsters o, WorldMgr.character c, int itemid)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            Writer.DWord(o.ID);
            Writer.DWord(o.UniqueID);
            Writer.Byte(o.xSec);
            Writer.Byte(o.ySec);
            Writer.Float(Formule.packetx((float)o.x, o.xSec));
            Writer.Float(o.z);
            Writer.Float(Formule.packety((float)o.y, o.ySec));
            Writer.Word(0);
            Writer.Byte(1);
            Writer.Byte(0);
            Writer.Byte(1);
            Writer.Byte(6);
            Writer.Text(c.Information.Name);
            Writer.DWord(itemid);
            Writer.Byte(1);
            return(Writer.GetBytes());
        }
        public static byte[] ObjectSpawn(WorldMgr.character c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            /////////////////////////////////////////////////////// Character basic info
            #region Basic info
            Writer.DWord(c.Information.Model);
            Writer.Byte(c.Information.Volume);                                  //Char Volume
            Writer.Byte(c.Information.Title);                                   //Char Title
            Writer.Byte(c.Information.Pvpstate);                                //Pvp state
            if (c.Information.Pvpstate != 0)
            {
                c.Information.PvP = true;
            }
            Writer.Bool((c.Information.Level < 20 ? true : false));             //Beginners Icon

            Writer.Byte(c.Information.Slots);                                   // Amount of items
            #endregion
            /////////////////////////////////////////////////////// Item info
            #region Item info
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 8, 0, true);
            Writer.Byte(5);
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 5, 1, true);
            Writer.Byte(0);
            #endregion
            /////////////////////////////////////////////////////// Character Location / id
            #region Location info / state
            Writer.DWord(c.Information.UniqueID);
            Writer.Byte(c.Position.xSec);
            Writer.Byte(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));
            Writer.Word(0);            //angle
            Writer.Bool(c.Position.Walking);
            Writer.Byte(1);            // walk:0 run:1 ;)
            //This should send the location information while moving. and where we moving
            if (c.Position.Walking)
            {
                Writer.Byte(c.Position.packetxSec);
                Writer.Byte(c.Position.packetySec);
                if (!FileDB.CheckCave(c.Position.packetxSec, c.Position.packetySec))
                {
                    Writer.Word(c.Position.packetX);
                    Writer.Word(c.Position.packetZ);
                    Writer.Word(c.Position.packetY);
                }
                else
                {
                    if (c.Position.packetX < 0)
                    {
                        Writer.Word(c.Position.packetX);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetX);
                    }

                    Writer.DWord(c.Position.packetZ);

                    if (c.Position.packetY < 0)
                    {
                        Writer.Word(c.Position.packetY);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetY);
                    }
                }

                /*byte[] x = BitConverter.GetBytes(c.Position.packetX);
                 * Array.Reverse(x);
                 * Writer.Buffer(x);
                 *
                 * Writer.Word(c.Position.packetZ);
                 *
                 * byte[] y = BitConverter.GetBytes(c.Position.packetY);
                 * Array.Reverse(y);
                 * Writer.Buffer(y);*/
            }
            else
            {
                Writer.Byte(1);
                Writer.Word(0);                //angle
            }


            Writer.Byte((byte)(c.State.LastState == 128 ? 2 : 1));

            Writer.Byte(0);
            //Info : If a player spawns at your location and is walking it send byte 3, else 0 byte.
            if (c.Transport.Right)
            {
                Writer.Byte(c.Transport.Horse.Walking == true ? 3 : 0);
            }
            else
            {
                Writer.Byte(c.Position.Walking == true ? 3 : 0);
            }

            Writer.Byte((byte)(c.Information.Berserking ? 1 : 0));
            Writer.Byte(0);
            Writer.Float(c.Speed.WalkSpeed);
            Writer.Float(c.Speed.RunSpeed);
            Writer.Float(c.Speed.BerserkSpeed);

            Writer.Byte(c.Action.Buff.count);
            for (byte b = 0; b < c.Action.Buff.SkillID.Length; b++)
            {
                if (c.Action.Buff.SkillID[b] != 0)
                {
                    Writer.DWord(c.Action.Buff.SkillID[b]);
                    Writer.DWord(c.Action.Buff.OverID[b]);
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Job information / name
            #region Job information & name
            Writer.Text(c.Information.Name);
            Writer.Byte(0);
            if (c.Transport.Right)
            {
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.DWord(c.Transport.Horse.UniqueID);
            }

            else
            {
                Writer.Byte(0);
                Writer.Byte(0);
            }

            Writer.Byte(0);
            if (c.Network.Stall != null && c.Network.Stall.ownerID == c.Information.UniqueID)
            {
                Writer.Byte(0x04);
            }
            else
            {
                Writer.Byte(0);
            }
            //Writer.Byte(0);

            if (c.Network.Guild.Guildid > 0)
            {
                Writer.Text(c.Network.Guild.Name);
                if (c.Network.Guild.GrantName != "")
                {
                    Writer.DWord(0);                    //Icon ?
                    Writer.Text(c.Network.Guild.GrantName);
                }
                else
                {
                    Writer.DWord(0);                   //Icon
                    Writer.Word(0);                    //No grantname
                }
            }
            else
            {
                Writer.Word(0);                //No guild
                Writer.DWord(0);               //No icon
                Writer.Word(0);                //No grantname
            }

            Writer.DWord(0);            // emblem (guild)
            Writer.DWord(0);            // unique id (union)
            Writer.DWord(0);            //emblem (union)

            Writer.Byte(0);             // flag (guild_war)
            Writer.Byte(0);             // flag (fortress_rank)
            if (c.Network.Stall != null && c.Network.Stall.ownerID == c.Information.UniqueID)
            {
                Writer.Text3(c.Network.Stall.StallName);
                Writer.DWord(c.Information.StallModel);
            }
            Writer.Byte(0);

            #endregion
            /////////////////////////////////////////////////////// Pvp state
            #region pvpstate
            if (c.Information.Pvpstate > 0 || c.Information.Murderer)
            {
                Writer.Byte(0x22);
            }
            else
            {
                Writer.Byte(0xFF);
            }
            #endregion
            Writer.Byte(4);
            return(Writer.GetBytes());
        }
        public static byte[] ObjectSpawn(WorldMgr.pet_obj o)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            switch (o.Named)
            {
            ///////////////////////////////////////////////////////////////////////////
            // Job transports
            ///////////////////////////////////////////////////////////////////////////
            case 4:
                Writer.DWord(o.Model);                                                     //Pet Model id
                Writer.DWord(o.UniqueID);                                                  //Pet Unique id
                Writer.Byte(o.xSec);                                                       //X sector
                Writer.Byte(o.ySec);                                                       //Y sector
                Writer.Float(Formule.packetx((float)o.x, o.xSec));                         //X
                Writer.Float(o.z);                                                         //Z
                Writer.Float(Formule.packety((float)o.y, o.ySec));                         //Y

                Writer.Word(0);                                                            //Angle

                Writer.Byte(1);                                                            //Walking state
                Writer.Byte(1);                                                            //Static

                Writer.Byte(o.xSec);                                                       //X sector
                Writer.Byte(o.ySec);                                                       //Y sector

                Writer.Word(0);                                                            //Static
                Writer.Word(0);                                                            //
                Writer.Word(0);                                                            //

                Writer.Word(1);
                Writer.Word(3);

                Writer.Byte(0);
                Writer.Float(o.Walk);                                                               //Object walking
                Writer.Float(o.Run);                                                                //Object running
                Writer.Float(o.Zerk);                                                               //Object zerk

                Writer.Word(0);                                                                     //

                Writer.Text(o.OwnerName);

                Writer.Word(2);                                                                     //
                Writer.DWord(o.OwnerID);                                                            //Owner unique id
                Writer.Byte(4);                                                                     //Static byte 4
                break;

            case 3:
                ///////////////////////////////////////////////////////////////////////////
                // Attack pet main packet
                ///////////////////////////////////////////////////////////////////////////
                Writer.DWord(o.Model);
                Writer.DWord(o.UniqueID);
                Writer.Byte(o.xSec);
                Writer.Byte(o.ySec);
                Writer.Float(Formule.packetx((float)o.x, o.xSec));
                Writer.Float(o.z);
                Writer.Float(Formule.packety((float)o.y, o.ySec));
                Writer.Word(0);                        //angle
                Writer.Byte(0);
                Writer.Byte(o.Level);                  //level
                Writer.Byte(0);
                Writer.Word(0);                        //angle
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(2);
                Writer.Byte(0);
                Writer.Float(o.Walk);                                                               //Object walking
                Writer.Float(o.Run);                                                                //Object running
                Writer.Float(o.Zerk);                                                               //Object zerk

                Writer.Byte(0);
                Writer.Byte(0);
                if (o.Named == 1)
                {
                    Writer.Text(o.Petname);
                }
                else
                {
                    Writer.Word(0);
                }
                Writer.Text(o.OwnerName);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.DWord(o.OwnerID);
                Writer.Byte(1);
                break;

            case 2:
                ///////////////////////////////////////////////////////////////////////////
                // Grab pet main packet
                ///////////////////////////////////////////////////////////////////////////
                Writer.DWord(o.Model);                                                     //Pet Model id
                Writer.DWord(o.UniqueID);                                                  //Pet Unique id
                Writer.Byte(o.xSec);                                                       //X sector
                Writer.Byte(o.ySec);                                                       //Y sector
                Writer.Float(Formule.packetx((float)o.x, o.xSec));                         //X
                Writer.Float(o.z);                                                         //Z
                Writer.Float(Formule.packety((float)o.y, o.ySec));                         //Y

                Writer.Word(0xDC72);                                                       //Angle

                Writer.Byte(0);                                                            //Walking state
                Writer.Byte(1);                                                            //Static
                Writer.Byte(0);                                                            //Static
                Writer.Word(0xDC72);                                                       //Angle

                Writer.Byte(1);                                                            //Static
                Writer.Word(0);                                                            //
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Float(o.Walk);                                                               //Object walking
                Writer.Float(o.Run);                                                                //Object running
                Writer.Float(o.Zerk);                                                               //Object zerk
                Writer.Word(0);                                                                     //
                if (o.Petname != "No name")
                {
                    Writer.Text(o.Petname);
                }
                else
                {
                    Writer.Word(0);
                }
                Writer.Text(o.OwnerName);                                                           //Pet owner name
                Writer.Byte(4);                                                                     //Static byte 4?
                Writer.DWord(o.OwnerID);                                                            //Owner unique id
                Writer.Byte(1);                                                                     //Static byte 1

                ///////////////////////////////////////////////////////////////////////////
                break;

            default:
                ///////////////////////////////////////////////////////////////////////////
                // // Horse //
                ///////////////////////////////////////////////////////////////////////////
                Writer.DWord(o.Model);
                Writer.DWord(o.UniqueID);
                Writer.Byte(o.xSec);
                Writer.Byte(o.ySec);
                Writer.Float(Formule.packetx((float)o.x, o.xSec));
                Writer.Float(o.z);
                Writer.Float(Formule.packety((float)o.y, o.ySec));

                Writer.Word(0);
                Writer.Byte(0);
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.Word(0);
                Writer.Byte(1);
                Writer.Word(0);
                Writer.Byte(0);

                Writer.Float(o.Speed1);
                Writer.Float(o.Speed2);
                Writer.Float(o.Zerk);
                Writer.Word(0);
                Writer.Byte(1);
                ///////////////////////////////////////////////////////////////////////////
                break;
            }
            return(Writer.GetBytes());
        }
        public static byte[] ObjectSpawnJob(WorldMgr.character c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);

            /////////////////////////////////////////////////////// Character basic info
            #region Basic info
            Writer.DWord(c.Information.Model);
            Writer.Byte(c.Information.Volume);                                  //Char Volume
            Writer.Byte(c.Information.Title);                                   //Char Title
            Writer.Byte(c.Information.Pvpstate);                                //Pvp state
            if (c.Information.Pvpstate != 0)
            {
                c.Information.PvP = true;
            }
            Writer.Bool((c.Information.Level < 20 ? true : false));             //Beginners Icon

            Writer.Byte(c.Information.Slots);                                   // Amount of items
            #endregion
            /////////////////////////////////////////////////////// Item info
            #region Item info
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 8, 0, true);
            Writer.Byte(5);
            Function.Items.PrivateItemPacket(Writer, c.Information.CharacterID, 5, 1, true);
            Writer.Byte(0);
            #endregion
            /////////////////////////////////////////////////////// Character Location / id
            #region Location info / state
            Writer.DWord(c.Information.UniqueID);
            Writer.Byte(c.Position.xSec);
            Writer.Byte(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));
            Writer.Word(0);            //angle
            Writer.Bool(c.Position.Walking);
            Writer.Byte(1);            // walk:0 run:1 ;)

            if (c.Position.Walking)
            {
                Writer.Byte(c.Position.packetxSec);
                Writer.Byte(c.Position.packetySec);

                if (!FileDB.CheckCave(c.Position.packetxSec, c.Position.packetySec))
                {
                    Writer.Word(c.Position.packetX);
                    Writer.Word(c.Position.packetZ);
                    Writer.Word(c.Position.packetY);
                }
                else
                {
                    if (c.Position.packetX < 0)
                    {
                        Writer.Word(c.Position.packetX);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetX);
                    }

                    Writer.DWord(c.Position.packetZ);

                    if (c.Position.packetY < 0)
                    {
                        Writer.Word(c.Position.packetY);
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(c.Position.packetY);
                    }
                }
            }
            else
            {
                Writer.Byte(1);
                Writer.Word(0);                //angle
            }


            Writer.Byte((byte)(c.State.LastState == 128 ? 2 : 1));
            Writer.Byte(0);
            Writer.Byte(3);
            Writer.Byte((byte)(c.Information.Berserking ? 1 : 0));

            Writer.Float(c.Speed.WalkSpeed);
            Writer.Float(c.Speed.RunSpeed);
            Writer.Float(c.Speed.BerserkSpeed);

            Writer.Byte(c.Action.Buff.count);
            for (byte b = 0; b < c.Action.Buff.SkillID.Length; b++)
            {
                if (c.Action.Buff.SkillID[b] != 0)
                {
                    Writer.DWord(c.Action.Buff.SkillID[b]);
                    Writer.DWord(c.Action.Buff.OverID[b]);
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Job information / name
            #region Job information & name
            Writer.Text(c.Job.Jobname);
            Writer.Byte(1);
            Writer.Byte(c.Job.level);            //Level job
            Writer.Byte(c.Information.Level);    //Level char
            Writer.Byte(0);

            if (c.Transport.Right)
            {
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.DWord(c.Transport.Horse.UniqueID);
            }

            else
            {
                Writer.Byte(0);
                Writer.Byte(0);
            }

            Writer.Byte(0);
            Writer.Byte(0);

            if (c.Network.Guild.Guildid > 0)
            {
                Writer.Text(c.Network.Guild.Name);
            }
            else
            {
                Writer.Word(0);                //No guild
            }

            Writer.Byte(0);
            Writer.Byte(0xFF);
            Writer.Byte(4);
            #endregion
            return(Writer.GetBytes());
        }
        public static byte[] ObjectSpawn(WorldMgr.Items w)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            Writer.DWord(w.Model);
            switch (w.Type)
            {
            case 1:
                Writer.DWord(w.amount);
                Writer.DWord(w.UniqueID);
                Writer.Byte(w.xSec);
                Writer.Byte(w.ySec);
                Writer.Float(Formule.packetx((float)w.x, w.xSec));
                Writer.Float(w.z);
                Writer.Float(Formule.packety((float)w.y, w.ySec));
                Writer.DWord(0);
                Writer.Byte(w.fromType);
                Writer.DWord(0);
                break;

            case 2:
                //Weapon and armory drops
                Writer.Byte(w.PlusValue);
                Writer.DWord(w.UniqueID);
                Writer.Byte(w.xSec);
                Writer.Byte(w.ySec);
                Writer.Float(Formule.packetx((float)w.x, w.xSec));
                Writer.Float(w.z);
                Writer.Float(Formule.packety((float)w.y, w.ySec));
                Writer.Word(0);                         // Angle
                Writer.Bool(w.downType);
                if (w.downType)
                {
                    Writer.DWord(w.Owner);
                }
                Writer.Byte(ObjData.Manager.ItemBase[w.Model].SOX);                         // if rare 2 not 0
                Writer.Byte(w.fromType);
                Writer.DWord(w.fromOwner);
                break;

            case 3:
                //Other item types
                //TODO: Define more detailed drops (Quest items, Mall types etc).
                Writer.DWord(w.UniqueID);
                Writer.Byte(w.xSec);
                Writer.Byte(w.ySec);
                Writer.Float(Formule.packetx((float)w.x, w.xSec));
                Writer.Float(w.z);
                Writer.Float(Formule.packety((float)w.y, w.ySec));
                Writer.Word(0);
                Writer.Bool(w.downType);
                if (w.downType)
                {
                    Writer.DWord(w.Owner);
                }
                Writer.Byte(0);
                Writer.Byte(w.fromType);
                Writer.DWord(w.fromOwner);
                break;
            }
            return(Writer.GetBytes());
        }
        public static byte[] ObjectSpawn(WorldMgr.Monsters o)        //Monster spawns
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            Writer.DWord(o.ID);
            Writer.DWord(o.UniqueID);
            Writer.Byte(o.xSec);
            Writer.Byte(o.ySec);
            Writer.Float(Formule.packetx((float)o.x, o.xSec));
            Writer.Float(o.z);
            Writer.Float(Formule.packety((float)o.y, o.ySec));

            switch (o.LocalType)
            {
            case 0:

                Writer.Word(0);
                Writer.Word(1);
                Writer.Byte(o.xSec);
                Writer.Byte(o.ySec);

                if (!FileDB.CheckCave(o.xSec, o.ySec))
                {
                    if (o.xSec == 0)
                    {
                        Writer.Word(0);
                    }
                    else
                    {
                        Writer.Word(Formule.packetx((float)(o.x + o.wx), o.xSec));
                    }
                    Writer.Word(o.z);
                    if (o.ySec == 0)
                    {
                        Writer.Word(0);
                    }
                    else
                    {
                        Writer.Word(Formule.packety((float)(o.y + o.wy), o.ySec));
                    }
                }
                else
                {
                    if (o.x < 0)
                    {
                        Writer.Word(Formule.cavepacketx((float)(o.x + o.wx)));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.cavepacketx((float)(o.x + o.wx)));
                    }

                    Writer.DWord(o.z);

                    if (o.y < 0)
                    {
                        Writer.Word(Formule.cavepackety((float)(o.y + o.wy)));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.cavepackety((float)(o.y + o.wy)));
                    }
                }

                Writer.Byte(1);
                Writer.Byte(o.Runing == true ? 2 : 0);
                Writer.Byte(0);
                Writer.Float(o.WalkingSpeed);          // Walk speed
                Writer.Float(o.RunningSpeed);          // Run speed
                Writer.Float(o.BerserkerSpeed);        // Berserk speed

                Writer.Byte(0);                        //new ?

                Writer.Byte(0);
                Writer.Byte(2);
                Writer.Byte(1);
                Writer.Byte(5);
                Writer.Byte(o.Type);
                break;

            case 1:
                Writer.Word(o.Angle);
                Writer.Word(1);
                Writer.Byte(o.xSec);
                Writer.Byte(o.ySec);

                if (!FileDB.CheckCave(o.xSec, o.ySec))
                {
                    Writer.Word(Formule.packetx((float)(o.x + o.wx), o.xSec));
                    Writer.Word(o.z);
                    Writer.Word(Formule.packety((float)(o.y + o.wy), o.ySec));
                }
                else
                {
                    if (o.x < 0)
                    {
                        Writer.Word(Formule.cavepacketx((float)(o.x + o.wx)));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.cavepacketx((float)(o.x + o.wx)));
                    }

                    Writer.DWord(o.z);

                    if (o.y < 0)
                    {
                        Writer.Word(Formule.cavepackety((float)(o.y + o.wy)));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.cavepackety((float)(o.y + o.wy)));
                    }
                }

                Writer.Byte(1);
                Writer.Byte(o.Runing == true ? 2 : 0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Float(o.WalkingSpeed);                        // Walk speed
                Writer.Float(o.RunningSpeed);                        // Run speed
                Writer.Float(o.BerserkerSpeed);                      // Berserk speed
                Writer.Byte(0);
                Writer.Byte(2);
                Writer.Byte(1);
                Writer.Byte(5);
                Writer.Byte(o.Type);
                Writer.Byte(4);
                break;

            case 2:
                Writer.Word(o.Angle);                         // Should be angle? yet not changing ingame..
                Writer.Byte(0);
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.Word(o.Angle);                         // Should be angle? yet not changing ingame..
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.Float(100);
                Writer.Byte(0);
                Writer.Byte(2);
                Writer.Byte(0);
                Writer.Byte(2);
                break;

            case 3:
                Writer.Word(0);
                Writer.Byte(1);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(1);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.Byte(0);
                break;

            case 4:
                /*Writer.Word(0); // Angle
                 * Writer.Byte(0);
                 * Writer.Byte(1);
                 * Writer.Byte(0);
                 * Writer.Word(0); // Angle
                 * Writer.Byte(1);
                 * Writer.Byte(0);
                 * Writer.Byte(0);
                 * Writer.Byte(0);
                 * Writer.Float(o.WalkingSpeed);// Walk speed
                 * Writer.Float(o.RunningSpeed);// Run speed
                 * Writer.Float(o.BerserkerSpeed);// Berserk speed
                 * Writer.Byte(0);
                 * Writer.Byte(2);
                 * Writer.Byte(1);
                 * Writer.Byte(5);
                 * Writer.Byte(0);
                 * Writer.Byte(34);
                 * Writer.Byte(1);
                 * */
                // Thiefs and trader spawns
                Writer.Word(0);                         // Angle
                Writer.Word(1);
                Writer.Byte(o.xSec);
                Writer.Byte(o.ySec);

                if (!FileDB.CheckCave(o.xSec, o.ySec))
                {
                    Writer.Word(Formule.packetx((float)(o.x + o.wx), o.xSec));
                    Writer.Word(o.z);
                    Writer.Word(Formule.packety((float)(o.y + o.wy), o.ySec));
                }
                else
                {
                    if (o.x < 0)
                    {
                        Writer.Word(Formule.packetx((float)(o.x + o.wx), o.xSec));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.packetx((float)(o.x + o.wx), o.xSec));
                    }

                    Writer.DWord(o.z);

                    if (o.y < 0)
                    {
                        Writer.Word(Formule.packety((float)(o.y + o.wy), o.ySec));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.packety((float)(o.y + o.wy), o.ySec));
                    }
                }

                Writer.Byte(1);
                Writer.Byte(o.Runing == true ? 2 : 0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Float(o.WalkingSpeed);                        // Walk speed
                Writer.Float(o.RunningSpeed);                        // Run speed
                Writer.Float(o.BerserkerSpeed);                      // Berserk speed
                Writer.Byte(0);
                Writer.Byte(2);
                Writer.Byte(1);
                Writer.Byte(5);
                Writer.Byte(0);
                Writer.Byte(34);                         // 227 Need to check what this is...
                Writer.Byte(1);

                break;

            case 5:
                // Static monster spawns
                Writer.Word(0);
                Writer.Word(1);
                Writer.Byte(o.xSec);
                Writer.Byte(o.ySec);

                if (!FileDB.CheckCave(o.xSec, o.ySec))
                {
                    Writer.Word(Formule.packetx((float)o.x, o.xSec));
                    Writer.Word(o.z);
                    Writer.Word(Formule.packety((float)o.y, o.ySec));
                }
                else
                {
                    if (o.x < 0)
                    {
                        Writer.Word(Formule.packetx((float)o.x, o.xSec));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.packetx((float)o.x, o.xSec));
                    }

                    Writer.DWord(o.z);

                    if (o.y < 0)
                    {
                        Writer.Word(Formule.packety((float)o.y, o.ySec));
                        Writer.Word(0xFFFF);
                    }
                    else
                    {
                        Writer.DWord(Formule.packety((float)o.y, o.ySec));
                    }
                }

                Writer.Byte(1);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Float(0);                            // Walk speed
                Writer.Float(0);                            // Run speed
                Writer.Float(100);                          // Berserk speed
                Writer.Byte(0);
                Writer.Byte(2);
                Writer.Byte(1);
                Writer.Byte(5);
                Writer.Byte(o.Type);
                Writer.Byte(0);
                o.LocalType = 1;
                break;

            default:
                break;
            }
            return(Writer.GetBytes());
        }
        public void AutoRunCallBack(object e)
        {
            float  NewX = x, NewY = y;
            double Distance = 0.0;

            try
            {
                if (RecordedTime <= 0 && AutoMovement && !Die)
                {
                    double MaxDistance = 0.0;
                    if (RunningSpeed <= 0 && BerserkerSpeed <= 0)
                    {
                        StopMovement();
                        StopAutoRunTimer();
                        return;
                    }
                    if (UniqueGuardMode)
                    {
                        MaxDistance = 15;
                    }
                    else
                    {
                        MaxDistance = 100;
                    }
                    double OrjDistance = Formule.gamedistance((float)x, (float)y, (float)OriginalX, (float)OriginalY);

                    if (OrjDistance > MaxDistance)
                    {
                        wx   = OriginalX - x;
                        wy   = OriginalY - y;
                        xSec = (byte)((OriginalX / 192) + 135);
                        ySec = (byte)((OriginalY / 192) + 92);
                        if (LastState == 1 && LastState2 == 2)
                        {
                            ChangeState(1, 3);
                            Send(Packet.SetSpeed(UniqueID, WalkingSpeed, RunningSpeed));
                        }
                        Runing       = true;
                        WalkingTime  = (OrjDistance / (WalkingSpeed * 0.0768)) * 1000.0;
                        RecordedTime = WalkingTime;
                        StartMovement((int)(WalkingTime * 0.0768));
                        Send(Packet.Movement(new ObjData.vektor(UniqueID,
                                                                Formule.packetx((float)OriginalX, xSec),
                                                                (float)z,
                                                                Formule.packety((float)OriginalY, ySec),
                                                                xSec,
                                                                ySec)));
                    }
                    else
                    {
                        Helpers.Functions.aRound(ref NewX, ref NewY, 2);
                        wx       = NewX - x;
                        wy       = NewY - y;
                        xSec     = (byte)((NewX / 192) + 135);
                        ySec     = (byte)((NewY / 192) + 92);
                        Runing   = true;
                        Distance = Formule.gamedistance((float)x, (float)y, (float)NewX, (float)NewY);
                        if (Runing == true || WalkingSpeed != 0)
                        {
                            if (LastState == 1 && LastState2 == 3)
                            {
                                ChangeState(1, 2);
                                Send(Packet.SetSpeed(UniqueID, WalkingSpeed, RunningSpeed));
                            }
                            Runing       = false;
                            WalkingTime  = (Distance / (WalkingSpeed * 0.0768)) * 1000.0;
                            RecordedTime = WalkingTime;
                        }
                        else if (RunningSpeed != 0 && WalkingSpeed == 0)
                        {
                            if (LastState == 1 && LastState2 == 2)
                            {
                                ChangeState(1, 3);
                                Send(Packet.SetSpeed(UniqueID, WalkingSpeed, RunningSpeed));
                            }
                            Runing       = true;
                            WalkingTime  = (Distance / (RunningSpeed * 0.0768)) * 1000.0;
                            RecordedTime = WalkingTime;
                        }
                        if (!FileDB.CheckCave(xSec, ySec))
                        {
                            Send(Packet.Movement(new ObjData.vektor(UniqueID,
                                                                    Formule.packetx((float)NewX, xSec),
                                                                    (float)z,
                                                                    Formule.packety((float)NewY, ySec),
                                                                    xSec,
                                                                    ySec)));
                        }
                        else
                        {
                            Send(Packet.Movement(new ObjData.vektor(UniqueID,
                                                                    Formule.cavepacketx((float)NewX),
                                                                    (float)z,
                                                                    Formule.cavepackety((float)NewY),
                                                                    xSec,
                                                                    ySec)));
                        }
                        CheckEveryOne();
                        StartMovement((int)(WalkingTime * 0.0768));
                    }
                }
                else
                {
                    return;
                }
            }
            catch
            {
                StopMovement();
                StopAgressiveTimer();
            }
        }
        public static byte[] Party_DataMember(WorldMgr.party p)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(OperationCode.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
                PlayerMgr PartyMemberInfo = Helpers.GetInformation.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());
        }
        public static byte[] Party_Data(byte type, int id)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(OperationCode.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
                PlayerMgr CharacterInformation = Helpers.GetInformation.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 = Helpers.GetInformation.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());
        }
        public static byte[] CharacterDataLoad(WorldMgr.character c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.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(988);
            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
            //DB perfection reading with multiple data adapters... while this one is open i can still read anything else from the database
            //With no speed reduction...
            DB checkpk = new DB("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);

            DB ms = new DB("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;
                    }
                    DB.query("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 DB("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 <= 7; 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 < 7; 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 (!FileDB.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(c.Information.GM);
            #endregion
            /////////////////////////////////////////////////////// Quickbar + Autopotion
            #region Bar information
            Writer.Byte(7);
            PlayerQuickBar(Writer, c.Information.CharacterID);
            PlayerAutoPot(Writer, c.Information.CharacterID);
            #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());
        }