Example #1
0
        public void Die(Entity killer)
        {
            if (killer.MapID == 6002)
            {
                if (Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.Start)
                {
                    if (killer.Elite != null)
                    {
                        killer.Elite.Points++;
                    }
                }
            }
            if (EntityFlag == EntityFlag.Player)
                Owner.XPCount = 0;
            Killer = killer;
            Hitpoints = 0;
            DeathStamp = Time32.Now;
            ToxicFogLeft = 0;
            if (Companion)
            {
                AddFlag(Network.GamePackets.Update.Flags.Ghost);
                AddFlag(Network.GamePackets.Update.Flags.Dead);
                AddFlag(Network.GamePackets.Update.Flags.FadeAway);
                Network.GamePackets.Attack zattack = new Network.GamePackets.Attack(true);
                zattack.Attacked = UID;
                zattack.AttackType = Network.GamePackets.Attack.Kill;
                zattack.X = X;
                zattack.Y = Y;
                MonsterInfo.SendScreen(zattack);
                Owner.Map.RemoveEntity(this);
                Owner.Companion = null;
            }
            if (EntityFlag == EntityFlag.Player)
            {
                if (killer.EntityFlag == EntityFlag.Player)
                {
                    if (killer.MapID == 1860)
                    {
                        killer.ConquerPoints += 300;
                    }
                    if (Owner.Entity.MapID == 1858 || Owner.Entity.MapID == 2555)
                    {
                        Owner.Entity.Teleport(1002, 438, 382);
                        Console.WriteLine("Done");
                    }
                    if (ServerBase.Constants.PKFreeMaps.Contains(killer.Owner.Map.ID) || (killer.Owner.Map.ID != 700 && killer.Owner.Map.BaseID == 700))
                        goto Over;
                    if (!ContainsFlag(Network.GamePackets.Update.Flags.FlashingName) && !ContainsFlag(Network.GamePackets.Update.Flags.BlackName))
                    {
                        killer.AddFlag(Network.GamePackets.Update.Flags.FlashingName);
                        killer.FlashingNameStamp = Time32.Now;
                        killer.FlashingNameTime = 60;

                        if (killer.GuildID != 0)
                        {
                            if (killer.Owner.Guild.Enemy.ContainsKey(GuildID))
                            {
                                killer.PKPoints += 3;
                            }
                            else
                            {
                                if (!killer.Owner.Enemy.ContainsKey(UID))
                                    killer.PKPoints += 10;
                                else
                                    killer.PKPoints += 5;
                            }
                        }
                        else
                        {
                            if (!killer.Owner.Enemy.ContainsKey(UID))
                                killer.PKPoints += 10;
                            else
                                killer.PKPoints += 5;
                        }
                        if (!this.Owner.Enemy.ContainsKey(killer.UID))
                            Network.PacketHandler.AddEnemy(this.Owner, killer.Owner);
                    }
                    //if (killer.EntityFlag == EntityFlag.Player)
                    //    DropRandomStuff(killer.Name);
                    if (killer.EntityFlag == EntityFlag.Player)
                        DropRandomStuff(Killer.Name);
                    else
                        DropRandomStuff(Killer.Name);

                }
            }
            RemoveFlag(Network.GamePackets.Update.Flags.FlashingName);
            Over:

            Network.GamePackets.Attack attack = new Attack(true);
            attack.Attacker = killer.UID;
            attack.Attacked = UID;
            attack.AttackType = Network.GamePackets.Attack.Kill;
            attack.X = X;
            attack.Y = Y;

            if (EntityFlag == EntityFlag.Player)
            {
                AddFlag(Network.GamePackets.Update.Flags.Dead);
                AddFlag(Network.GamePackets.Update.Flags.Ghost);
                RemoveFlag(Network.GamePackets.Update.Flags.Fly);
                RemoveFlag(Network.GamePackets.Update.Flags.Ride);
                RemoveFlag(Network.GamePackets.Update.Flags.Cyclone);
                RemoveFlag(Network.GamePackets.Update.Flags.Superman);
                RemoveFlag(Network.GamePackets.Update.Flags.CannonBarrage);
                RemoveFlag(Network.GamePackets.Update.Flags.FlashingName);
                RemoveFlag(Network.GamePackets.Update.Flags.ShurikenVortex);

                if (Body % 10 < 3)
                    TransformationID = 99;
                else
                    TransformationID = 98;

                Owner.SendScreen(attack, true);
                Owner.Send(new MapStatus() { BaseID = Owner.Map.BaseID, ID = Owner.Map.ID, Status = Database.MapsTable.MapInformations[Owner.Map.ID].Status });

                if (Owner.QualifierGroup != null)
                {
                    Owner.QualifierGroup.End(Owner);
                }
            }
            else
            {

                if (!Companion)
                {
                    if (MonsterInfo != null)
                        if (killer != null)
                            MonsterInfo.Drop(killer);
                }
                ServerBase.Kernel.Maps[MapID].Floor[X, Y, MapObjType, this] = true;
                if (killer.EntityFlag == EntityFlag.Player)
                {
                    killer.Owner.IncreaseExperience(MaxHitpoints, true);
                    if (killer.Owner.Team != null)
                    {
                        foreach (Client.GameState teammate in killer.Owner.Team.Teammates)
                        {
                            if (ServerBase.Kernel.GetDistance(killer.X, killer.Y, teammate.Entity.X, teammate.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                            {
                                if (killer.UID != teammate.Entity.UID)
                                {
                                    uint extraExperience = MaxHitpoints / 2;
                                    if (killer.Spouse == teammate.Entity.Name)
                                        extraExperience = MaxHitpoints * 2;
                                    byte TLevelN = teammate.Entity.Level;
                                    if (killer.Owner.Team.CanGetNoobExperience(teammate))
                                    {
                                        if (teammate.Entity.Level < 137)
                                        {
                                            extraExperience *= 2;
                                            teammate.IncreaseExperience(extraExperience, false);
                                            teammate.Send(ServerBase.Constants.NoobTeamExperience(extraExperience));
                                        }
                                    }
                                    else
                                    {
                                        if (teammate.Entity.Level < 137)
                                        {
                                            teammate.IncreaseExperience(extraExperience, false);
                                            teammate.Send(ServerBase.Constants.TeamExperience(extraExperience));
                                        }
                                    }
                                    byte TLevelNn = teammate.Entity.Level;
                                    byte newLevel = (byte)(TLevelNn - TLevelN);
                                    if (newLevel != 0)
                                    {
                                        if (TLevelN < 70)
                                        {
                                            for (int i = TLevelN; i < TLevelNn; i++)
                                            {
                                                teammate.Team.Teammates[0].VirtuePoints += (uint)(i * 3.83F);
                                                teammate.Team.SendMessage(new Message("The leader, " + teammate.Team.Teammates[0].Entity.Name + ", has gained " + (uint)(i * 7.7F) + " virtue points for power leveling the rookies.", System.Drawing.Color.Red, Message.Team));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (killer.Level < 140)
                    {
                        if (killer.VIPLevel == 0)
                        {
                            uint extraExp = MaxHitpoints;
                            extraExp *= ServerBase.Constants.ExtraExperienceRate;
                            extraExp += extraExp * killer.Gems[3] / 100;
                            extraExp += (uint)(extraExp * ((float)killer.BattlePower / 100));
                            if (killer.DoubleExperienceTime > 0)
                                extraExp *= 2;
                            if (killer.DoubleExperienceTime5 > 0)
                                extraExp *= 5;
                            if (killer.DoubleExperienceTime10 > 0)
                                extraExp *= 10;
                            if (killer.DoubleExperienceTime15 > 0)
                                extraExp *= 15;

                            if (killer.HeavenBlessing > 0)
                                extraExp += (uint)(extraExp * 20 / 100);
                            if (killer.Reborn >= 2)
                                extraExp /= 3;
                            if (killer.Reborn == 1)
                                extraExp /= 2;
                            killer.Owner.Send(ServerBase.Constants.ExtraExperience(extraExp));
                        }
                        else
                        {
                            uint extraExp = MaxHitpoints;
                            extraExp *= ServerBase.Constants.ExtraExperienceRate;
                            extraExp += extraExp * killer.Gems[3] / 100;
                            extraExp += (uint)(extraExp * ((float)killer.BattlePower / 100));
                            if (killer.DoubleExperienceTime > 0)
                                extraExp *= 2;
                            if (killer.HeavenBlessing > 0)
                                extraExp += (uint)(extraExp * 20 / 100);
                            if (killer.Reborn >= 2)
                                extraExp /= 3;
                            if (killer.Reborn == 1)
                                extraExp /= 2;
                            if (killer.VIPLevel == 1)
                                extraExp *= 2;
                            if (killer.VIPLevel == 2)
                                extraExp *= 3;
                            if (killer.VIPLevel == 3)
                                extraExp *= 4;
                            if (killer.VIPLevel == 4)
                                extraExp *= 5;
                            if (killer.VIPLevel == 5)
                                extraExp *= 6;
                            if (killer.VIPLevel == 6)
                                extraExp *= 7;
                            if (killer.Level > 135 && killer.Level < 141 && killer.VIPLevel == 0)
                            {
                                extraExp /= 2;
                            }
                            killer.Owner.Send(ServerBase.Constants.VipExp(extraExp, (killer.VIPLevel) + (uint)1));
                        }
                    }
                    killer.Owner.XPCount++;
                    if (killer.OnKOSpell())
                        killer.KOSpellTime++;
                }
            }
        }
        static void PlayerGroundMovment(GroundMovement groundMovement, Client.GameState client)
        {
            client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
            client.Attackable = true;
            client.Mining = false;

            if (client.Entity.ContainsFlag3(Network.GamePackets.Update.Flags3.MagicDefender))
            {

                client.Entity.MagicDefenderTime = 0;
                client.Entity.MagicDefenderIncrease = 0;
                client.Entity.RemoveFlag3(Network.GamePackets.Update.Flags3.MagicDefender);
                SyncPacket packet = new SyncPacket
                {
                    Identifier = client.Entity.UID,
                    Count = 2,
                    Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                    StatusFlag1 = (ulong)client.Entity.StatusFlag,
                    StatusFlag2 = (ulong)client.Entity.StatusFlag2,
                    Unknown1 = 0x31,
                    StatusFlagOffset = 0x80,
                    Time = 0,
                    Value = 0,
                    Level = 0
                };
                client.Entity.Owner.Send((byte[])packet);
                foreach (var Client in client.MagicDef)
                {
                    if (Client.Entity.ContainsFlag2(Update.Flags2.kimo4))
                    {
                        Client.Entity.RemoveFlag2(Update.Flags2.kimo4);
                    }
                }
                client.MagicDef.Clear();
            }
            if (client.Entity.ContainsFlag(Update.Flags.CastPray))
            {
                client.Entity.RemoveFlag(Update.Flags.CastPray);
                foreach (var Client in client.Prayers)
                {
                    if (Client.Entity.ContainsFlag(Update.Flags.Praying))
                    {
                        Client.Entity.RemoveFlag(Update.Flags.Praying);
                    }
                }
                client.Prayers.Clear();
            }
            if (client.Entity.ContainsFlag(Update.Flags.Praying))
            {
                client.Entity.RemoveFlag(Update.Flags.Praying);
                if (client.PrayLead != null)
                    client.PrayLead.Prayers.Remove(client);
                client.PrayLead = null;
            }
            if (client.Entity.AttackPacket != null)
            {
                client.Entity.AttackPacket = null;
            }
            if (client.Entity.ContainsFlag(Update.Flags.Ride))
                client.Entity.Vigor -= 1;
            client.Entity.PX = client.Entity.X;
            client.Entity.PY = client.Entity.Y;

            if ((byte)groundMovement.Direction > 7)
                groundMovement.Direction = (PhoenixProject.Game.Enums.ConquerAngle)((byte)groundMovement.Direction % 8);

            client.Entity.Move(groundMovement.Direction);

            if (groundMovement.GroundMovementType == GroundMovement.TwoCoordonates)
                client.Entity.Move(groundMovement.Direction);

            client.SendScreen(groundMovement, true);
            client.Screen.Reload(groundMovement);
            if (client.Entity.MapID == 1002)
            {
                if (client.Entity.X == 436 && client.Entity.Y == 444)//stig
                {
                    if (!client.Entity.ContainsFlag(Update.Flags.Ghost))
                    {
                        if (client.Entity.EntityFlag == PhoenixProject.Game.EntityFlag.Player && client.Entity.MaxHitpoints != client.Entity.Hitpoints)
                        {
                            SpellUse suse = new SpellUse(true);
                            suse.Attacker = client.Entity.UID;
                            suse.SpellID = 1195;
                            suse.SpellLevel = 0;
                            suse.X = 436;
                            suse.Y = 444;
                            uint Hp = (client.Entity.MaxHitpoints - client.Entity.Hitpoints);
                            client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                            suse.Targets.Add(client.Entity.UID, Hp);
                            client.SendScreen(suse, true);
                            client.Send(new Message("Your HP Now : " + client.Entity.Hitpoints + "!", System.Drawing.Color.Red, Message.Talk));
                        }
                    }
                }

            }
            if (client.Entity.MapID == 1005)
            {
                if (client.Entity.X == 42 && client.Entity.Y == 51)//stig
                {
                    if (!client.Entity.ContainsFlag(Update.Flags.Stigma) && !client.Entity.ContainsFlag(Update.Flags.Ghost))
                    {
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = client.Entity.UID;
                        suse.SpellID = 1095;
                        suse.SpellLevel = 3;
                        suse.X = 42;
                        suse.Y = 51;
                        suse.Targets.Add(client.Entity.UID, 0);
                        client.Entity.AddFlag(Update.Flags.Stigma);
                        client.Entity.StigmaStamp = Time32.Now;
                        client.Entity.StigmaIncrease = 25;
                        client.Entity.StigmaTime = 20;
                        client.SendScreen(suse, true);
                        if (client.Entity.EntityFlag == PhoenixProject.Game.EntityFlag.Player)
                            client.Send(ServerBase.Constants.Stigma(25, 20));
                    }
                }
                else
                {
                    if (client.Entity.X == 42 && client.Entity.Y == 48)//rev
                    {
                        if (client.Entity.ContainsFlag(Update.Flags.Ghost))
                        {
                            SpellUse suse = new SpellUse(true);
                            suse.Attacker = client.Entity.UID;
                            suse.SpellID = 1050;
                            suse.SpellLevel = 0;
                            suse.X = 42;
                            suse.Y = 48;
                            suse.Targets.Add(client.Entity.UID, 0);
                            client.SendScreen(suse, true);
                            client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
                            client.ReviveStamp = Time32.Now;
                            client.Attackable = false;
                            client.Entity.TransformationID = 0;
                            client.Entity.RemoveFlag(Update.Flags.Dead);
                            client.Entity.RemoveFlag(Update.Flags.Ghost);
                            client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                            client.Entity.Ressurect();

                        }
                    }

                }
            }
            if (client.Entity.InteractionInProgress)
            {
                if (!client.Entity.InteractionSet)
                {
                    if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                    {
                        Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];
                        if (ch.Entity.InteractionInProgress && ch.Entity.InteractionWith == client.Entity.UID)
                        {
                            if (client.Entity.InteractionX == client.Entity.X && client.Entity.Y == client.Entity.InteractionY)
                            {
                                if (client.Entity.X == ch.Entity.X && client.Entity.Y == ch.Entity.Y)
                                {
                                    Network.GamePackets.Attack atac = new Network.GamePackets.Attack(true);
                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    atac.X = ch.Entity.X;
                                    atac.Y = ch.Entity.Y;
                                    atac.Damage = client.Entity.InteractionType;
                                    atac.AttackType = 47;
                                    ch.Send(atac);

                                    atac.AttackType = 49;
                                    atac.Attacker = client.Entity.UID;
                                    atac.Attacked = ch.Entity.UID;
                                    client.SendScreen(atac, true);

                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    client.SendScreen(atac, true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (client.Entity.Body == 1003 || client.Entity.Body == 1004)
                    {
                        if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                        {
                            Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];

                            ch.Entity.Facing = groundMovement.Direction;
                            ch.Entity.Move(groundMovement.Direction);
                            Network.GamePackets.Data general = new Network.GamePackets.Data(true);
                            general.UID = ch.Entity.UID;
                            general.wParam1 = ch.Entity.X;
                            general.wParam2 = ch.Entity.Y;
                            general.ID = 0x9c;
                            ch.Send(general.ToArray());
                            ch.Screen.Reload(null);
                        }
                    }
                }
            }
            client.Entity.MapRegion = Region.Region.FindRegion((uint)client.Map.BaseID, client.Entity.X, client.Entity.Y);
        }
Example #3
0
        public void Die()
        {
            if (EntityFlag == EntityFlag.Player)
                Owner.XPCount = 0;
            Killed = true;
            Hitpoints = 0;
            DeathStamp = Time32.Now;
            ToxicFogLeft = 0;
            if (Companion)
            {
                AddFlag(Network.GamePackets.Update.Flags.Ghost);
                AddFlag(Network.GamePackets.Update.Flags.Dead);
                AddFlag(Network.GamePackets.Update.Flags.FadeAway);
                Network.GamePackets.Attack attack = new Network.GamePackets.Attack(true);
                attack.Attacked = UID;
                attack.AttackType = Network.GamePackets.Attack.Kill;
                attack.X = X;
                attack.Y = Y;
                MonsterInfo.SendScreen(attack);
                Owner.Map.RemoveEntity(this);
                Owner.Companion = null;
            }
            if (EntityFlag == EntityFlag.Player)
            {
                if (ServerBase.Constants.PKFreeMaps.Contains(MapID))
                    goto Over;

              //  DropRandomStuff("");

            Over:
                AddFlag(Network.GamePackets.Update.Flags.Dead);
                AddFlag(Network.GamePackets.Update.Flags.Ghost);
                RemoveFlag(Network.GamePackets.Update.Flags.Fly);
                RemoveFlag(Network.GamePackets.Update.Flags.Ride);
                RemoveFlag(Network.GamePackets.Update.Flags.Cyclone);
                RemoveFlag(Network.GamePackets.Update.Flags.Superman);
                RemoveFlag(Network.GamePackets.Update.Flags.CannonBarrage);
                RemoveFlag(Network.GamePackets.Update.Flags.FlashingName);
                RemoveFlag(Network.GamePackets.Update.Flags.ShurikenVortex);

                Network.GamePackets.Attack attack = new Attack(true);
                attack.AttackType = Network.GamePackets.Attack.Kill;
                attack.X = X;
                attack.Y = Y;
                attack.Attacked = UID;
                Owner.SendScreen(attack, true);

                if (Body % 10 < 3)
                    TransformationID = 99;
                else
                    TransformationID = 98;

                Owner.Send(new MapStatus() { BaseID = Owner.Map.BaseID, ID = Owner.Map.ID, Status = Database.MapsTable.MapInformations[Owner.Map.ID].Status });

                if (Owner.QualifierGroup != null)
                {
                    Owner.QualifierGroup.End(Owner);
                }
            }
            else
            {
                ServerBase.Kernel.Maps[MapID].Floor[X, Y, MapObjType, this] = true;
            }
        }
Example #4
0
        static void PlayerGroundMovment(GroundMovement groundMovement, Client.GameState client)
        {
            client.Entity.Action = Conquer_Online_Server.Game.Enums.ConquerAction.None;
            client.Attackable = true;
            client.Mining = false;
            if (client.Entity.ContainsFlag(Update.Flags.CastPray))
            {
                client.Entity.RemoveFlag(Update.Flags.CastPray);
                foreach (var Client in client.Prayers)
                {
                    if (Client.Entity.ContainsFlag(Update.Flags.Praying))
                    {
                        Client.Entity.RemoveFlag(Update.Flags.Praying);
                    }
                }
                client.Prayers.Clear();
            }
            if (client.Entity.ContainsFlag(Update.Flags.Praying))
            {
                client.Entity.RemoveFlag(Update.Flags.Praying);
                if (client.PrayLead != null)
                    client.PrayLead.Prayers.Remove(client);
                client.PrayLead = null;
            }
            if (client.Entity.AttackPacket != null)
            {
                client.Entity.AttackPacket = null;
            }
            if (client.Entity.ContainsFlag(Update.Flags.Ride))
                client.Entity.Vigor -= 1;
            client.Entity.PX = client.Entity.X;
            client.Entity.PY = client.Entity.Y;

            if ((byte)groundMovement.Direction > 7)
                groundMovement.Direction = (Conquer_Online_Server.Game.Enums.ConquerAngle)((byte)groundMovement.Direction % 8);

            client.Entity.Move(groundMovement.Direction);

            if (groundMovement.GroundMovementType == GroundMovement.TwoCoordonates)
                client.Entity.Move(groundMovement.Direction);

            client.SendScreen(groundMovement, true);
            client.Screen.Reload(groundMovement);

            if (client.Entity.InteractionInProgress)
            {
                if (!client.Entity.InteractionSet)
                {
                    if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                    {
                        Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];
                        if (ch.Entity.InteractionInProgress && ch.Entity.InteractionWith == client.Entity.UID)
                        {
                            if (client.Entity.InteractionX == client.Entity.X && client.Entity.Y == client.Entity.InteractionY)
                            {
                                if (client.Entity.X == ch.Entity.X && client.Entity.Y == ch.Entity.Y)
                                {
                                    Network.GamePackets.Attack atac = new Network.GamePackets.Attack(true);
                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    atac.X = ch.Entity.X;
                                    atac.Y = ch.Entity.Y;
                                    atac.Damage = client.Entity.InteractionType;
                                    atac.AttackType = 47;
                                    ch.Send(atac);

                                    atac.AttackType = 49;
                                    atac.Attacker = client.Entity.UID;
                                    atac.Attacked = ch.Entity.UID;
                                    client.SendScreen(atac, true);

                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    client.SendScreen(atac, true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (client.Entity.Body == 1003 || client.Entity.Body == 1004)
                    {
                        if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                        {
                            Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];

                            ch.Entity.Facing = groundMovement.Direction;
                            ch.Entity.Move(groundMovement.Direction);
                            Network.GamePackets.Data general = new Network.GamePackets.Data(true);
                            general.UID = ch.Entity.UID;
                            general.wParam1 = ch.Entity.X;
                            general.wParam2 = ch.Entity.Y;
                            general.ID = 0x9c;
                            ch.Send(general.ToArray());
                            ch.Screen.Reload(null);
                        }
                    }
                }
            }
        }
        public void _timerCallBack6(object obj, System.Timers.ElapsedEventArgs arg)
        {
            try
            {
                Time32 Now = Time32.Now;
                if (this == null || Owner == null ||  Owner.Account == null)
                {
                    Owner.Disconnect();
                    return;
                }
                if (this == null || Owner == null)
                    return;
                if (Owner.Screen == null || Owner.Entity == null)
                {
                    Owner.Disconnect();
                }
                if (Owner != null)
                {

                    if (this.HandleTiming)
                    {
                      /*  MapStatus mbox = new MapStatus();
                        mbox.BaseID = (ushort)Owner.Map.BaseID;
                       // mbox.ID = Owner.Map.ID;
                        Owner.Send(mbox);*/
                        if (DateTime.Now.Minute == 42 && DateTime.Now.Second == 58)
                        {
                            if (Database.rates.Weather == 1)
                            {

                                    Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                    weather.WeatherType = (uint)Program.WeatherType;
                                    weather.Intensity = 100;
                                    weather.Appearence = 2;
                                    weather.Direction = 4;
                                    Owner.Send(weather);

                            }
                        }
                        if (DateTime.Now.Minute == 57 && DateTime.Now.Second == 58)
                        {
                            if (Database.rates.Weather == 1)
                            {

                                    Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                    weather.WeatherType = (uint)Program.WeatherType;
                                    weather.Intensity = 100;
                                    weather.Appearence = 2;
                                    weather.Direction = 4;
                                    Owner.Send(weather);

                            }
                        }
                        if (DateTime.Now.Minute == 12 && DateTime.Now.Second == 58)
                        {
                            if (Database.rates.Weather == 1)
                            {

                                    Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                    weather.WeatherType = (uint)Program.WeatherType;
                                    weather.Intensity = 100;
                                    weather.Appearence = 2;
                                    weather.Direction = 4;
                                    Owner.Send(weather);

                            }
                        }
                        if (DateTime.Now.Minute == 27 && DateTime.Now.Second == 58)
                        {
                            if (Database.rates.Weather == 1)
                            {

                                    Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                    weather.WeatherType = (uint)Program.WeatherType;
                                    weather.Intensity = 100;
                                    weather.Appearence = 2;
                                    weather.Direction = 4;
                                    Owner.Send(weather);

                            }
                        }
                        if (MapID == 1036)
                        {
                            if (ServerBase.Kernel.GetDistance(X, Y, 184, 205) < 17 && !Owner.Effect)
                            {
                                Owner.Effect = true;
                                if (MapID == 1036)
                                {
                                    Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true);
                                    // floorItem.MapObjType = Game.MapObjectType.Item;
                                    floorItem.ItemID = 812;//794
                                    floorItem.MapID = 1036;
                                    floorItem.X = 184;
                                    floorItem.Y = 205;
                                    floorItem.Type = Network.GamePackets.FloorItem.Effect;
                                    Owner.Send(floorItem);
                                }
                            }
                            else
                            {
                                if (ServerBase.Kernel.GetDistance(X, Y, 184, 205) > 17)
                                {
                                    Owner.Effect = false;
                                }
                            }
                        }
                        else
                        {
                            if (MapID == 1002)
                            {
                                if (ServerBase.Kernel.GetDistance(X,Y, 438, 377) < 17 && !Owner.Effect)
                                {
                                    Owner.Effect = true;
                                    if (MapID == 1002)
                                    {
                                        Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true);
                                        // floorItem.MapObjType = Game.MapObjectType.Item;
                                        floorItem.ItemID = 23;//746
                                        floorItem.MapID = 1002;
                                        floorItem.X = 438;
                                        floorItem.Y = 377;
                                        floorItem.Type = 10;
                                        Owner.Send(floorItem);
                                        floorItem.ItemID = 31;//794
                                        floorItem.MapID = 1002;
                                        floorItem.X = 438;
                                        floorItem.Y = 377;
                                        floorItem.Type = 10;
                                        Owner.Send(floorItem);
                                    }
                                }
                                else
                                {
                                    if (ServerBase.Kernel.GetDistance(X, Y, 438, 377) > 17)
                                    {
                                        Owner.Effect = false;
                                    }
                                }
                                if (ServerBase.Kernel.GetDistance(X, Y, 436, 444) < 17 && !Owner.Effect3)
                                {
                                    Owner.Effect3 = true;
                                    if (MapID == 1002)
                                    {
                                        Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true);
                                        // floorItem.MapObjType = Game.MapObjectType.Item;
                                        floorItem.ItemID = 765;//794
                                        floorItem.MapID = 1002;
                                        floorItem.X = 436;
                                        floorItem.Y = 444;
                                        floorItem.Type = Network.GamePackets.FloorItem.Effect;

                                        Owner.Send(floorItem);
                                    }
                                }
                                else
                                {
                                    if (ServerBase.Kernel.GetDistance(X, Y, 436, 444) > 17)
                                    {
                                        Owner.Effect3 = false;
                                    }
                                }
                            }
                            else
                            {
                                if (MapID == 1005)
                                {
                                    if (ServerBase.Kernel.GetDistance(X, Y, 42, 48) < 17 && !Owner.Effect2)
                                    {
                                        Owner.Effect2 = true;
                                        if (MapID == 1005)
                                        {//1005 42 50 790
                                            Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true);
                                            // floorItem.MapObjType = Game.MapObjectType.Item;
                                            floorItem.ItemID = 797;//794
                                            floorItem.MapID = 1005;
                                            floorItem.X = 42;
                                            floorItem.Y = 48;
                                            floorItem.Type = Network.GamePackets.FloorItem.Effect;
                                            Owner.Send(floorItem);
                                            // floorItem.MapObjType = Game.MapObjectType.Item;
                                            floorItem.ItemID = 731;//794
                                            floorItem.MapID = 1005;
                                            floorItem.X = 42;
                                            floorItem.Y = 51;
                                            floorItem.Type = Network.GamePackets.FloorItem.Effect;
                                            Owner.Send(floorItem);
                                        }
                                    }
                                    else
                                    {
                                        if (ServerBase.Kernel.GetDistance(X, Y, 42, 48) > 17)
                                        {
                                            Owner.Effect2 = false;
                                        }
                                    }

                                }
                            }
                        }
                        // Console.WriteLine(" " + UID + " ");
                        #region Auto attack
                        if (Owner.Entity.AttackPacket != null || Owner.Entity.VortexAttackStamp != null)
                        {
                            try
                            {
                                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                                {
                                    if (Owner.Entity.VortexPacket != null && Owner.Entity.VortexPacket.ToArray() != null)
                                    {
                                        if (Time32.Now > Owner.Entity.VortexAttackStamp.AddMilliseconds(1400))
                                        {
                                            Owner.Entity.VortexAttackStamp = Time32.Now;
                                            new Game.Attacking.Handle(Owner.Entity.VortexPacket, Owner.Entity, null);
                                        }
                                    }
                                }
                                else
                                {
                                    Owner.Entity.VortexPacket = null;
                                    var AttackPacket = Owner.Entity.AttackPacket;
                                    if (AttackPacket != null && AttackPacket.ToArray() != null)
                                    {
                                        uint AttackType = AttackPacket.AttackType;
                                        if (AttackType == Network.GamePackets.Attack.Magic || AttackType == Network.GamePackets.Attack.Melee || AttackType == Network.GamePackets.Attack.Ranged)
                                        {
                                            if (AttackType == Network.GamePackets.Attack.Magic)
                                            {
                                                if (Time32.Now > Owner.Entity.AttackStamp.AddSeconds(1))
                                                {

                                                    new Game.Attacking.Handle(AttackPacket, Owner.Entity, null);
                                                }
                                            }
                                            else
                                            {
                                                int decrease = -300;
                                                if (Owner.Entity.OnCyclone())
                                                    decrease = 700;
                                                if (Owner.Entity.OnSuperman())
                                                    decrease = 200;
                                                if (Time32.Now > Owner.Entity.AttackStamp.AddMilliseconds((1000 - Owner.Entity.Agility - decrease) * (int)(AttackType == Network.GamePackets.Attack.Ranged ? 1 : 1)))
                                                {
                                                    new Game.Attacking.Handle(AttackPacket, Owner.Entity, null);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                Program.SaveException(e);
                                AttackPacket = null;
                                VortexPacket = null;
                            }
                        }
                        #endregion

                    }
                }
                //AutoAttack();
            }
            catch { }
            {
            }
        }
        //just replace this whole void for die delay
        public void Die(Entity killer)
        {
            if (Time32.Now > DeathStamp)
            {
                if (AuraTime != 0)
                {
                    AuraTime = 0;
                    RemoveFlag2(Network.GamePackets.Update.Flags2.TyrantAura);
                    RemoveFlag2(Network.GamePackets.Update.Flags2.FendAura);
                    RemoveFlag2(Network.GamePackets.Update.Flags2.MetalAura);
                    RemoveFlag2(Network.GamePackets.Update.Flags2.WoodAura);
                    RemoveFlag2(Network.GamePackets.Update.Flags2.WaterAura);
                    RemoveFlag2(Network.GamePackets.Update.Flags2.EarthAura);
                    RemoveFlag2(Network.GamePackets.Update.Flags2.FireAura);
                    if (!Owner.AlternateEquipment)
                    {
                        Owner.LoadItemStats(this);
                    }
                    else
                    {
                        Owner.LoadItemStats2(this);
                    }

                }
                if (killer.EntityFlag == EntityFlag.Player)
                {

                    BlackSpot spot = new BlackSpot
                    {
                        Remove = 1,
                        Identifier = UID
                    };
                    killer.Owner.Send((byte[])spot);
                    BlackSpots = false;
                    BlackSpotTime2 = 0;
                    BlackSpotCheck = 0;
                }

                if (killer.EntityFlag == Game.EntityFlag.Player)
                {
                    if (EntityFlag == Game.EntityFlag.Player)
                    {
                       /* Game.PkExpeliate pk = new Game.PkExpeliate();
                        pk.UID = killer.UID;
                        pk.Name = Name;
                        pk.KilledAt = "KimoConquer";
                        pk.LostExp = 0;
                        pk.Times = 0;
                        pk.Potency = (uint)BattlePower;
                        pk.Level = Level;
                        PkExpelTable.PkExploitAdd(killer.Owner, UID, pk);*/
                    }
                }
                if (killer.MapID == 3031)
                {
                    if (this.ConquerPoints >= 20000)
                    {

                        uint ItemID = 729911;
                        this.ConquerPoints -= 20000;
                        ushort X = this.X, Y = this.Y;
                        Game.Map Map = ServerBase.Kernel.Maps[this.MapID];
                        if (Map.SelectCoordonates(ref X, ref Y))
                        {
                            Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true);
                            floorItem.ValueType = Network.GamePackets.FloorItem.FloorValueType.ConquerPoints;
                            floorItem.Value = 20000;
                            floorItem.ItemID = ItemID;
                            floorItem.MapID = this.MapID;
                            floorItem.MapObjType = Game.MapObjectType.Item;
                            floorItem.X = X;
                            floorItem.Y = Y;
                            floorItem.Owner = killer.Owner;
                            floorItem.Type = Network.GamePackets.FloorItem.Drop;
                            floorItem.OnFloor = Time32.Now;
                            floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
                            while (Map.Npcs.ContainsKey(floorItem.UID))
                                floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
                            Map.AddFloorItem(floorItem);
                            this.Owner.SendScreenSpawn(floorItem, true);
                        }
                    }
                    else
                    {
                        this.Teleport(1002, 428, 378);
                        ServerBase.Kernel.SendWorldMessage(new Message("Ops! " + this.Name + " has losed all his/her cps in the LordsWar and teleported back to TwinCity.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
                    }
                }
                if (killer.MapID == 7777)
                {
                    if (killer.MapID == 7777)
                    {
                        killer.Owner.elitepoints += 1;
                        if (killer.Owner.elitepoints >= 20)
                        {
                            Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Congratulations, You Have Now " + killer.Owner.elitepoints + " ElitePk Points you can claim your prize now!");
                            npc.OptionID = 255;
                            killer.Owner.Send(npc.ToArray());
                        }
                        else
                        {
                            Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "You Have Now " + killer.Owner.elitepoints + " ElitePk Points Congratz you still need " + (20 - killer.Owner.elitepoints) + " more!");
                            npc.OptionID = 255;
                            killer.Owner.Send(npc.ToArray());
                        }
                    }
                }
                if (EntityFlag == EntityFlag.Player)
                    Owner.XPCount = 0;
                Killer = killer;
                Hitpoints = 0;
                DeathStamp = Time32.Now;
                //DieString();
                ToxicFogLeft = 0;
                if (Companion)
                {
                    AddFlag(Network.GamePackets.Update.Flags.Ghost | Network.GamePackets.Update.Flags.Dead | Network.GamePackets.Update.Flags.FadeAway);
                    Network.GamePackets.Attack zattack = new Network.GamePackets.Attack(true);
                    zattack.Attacked = UID;
                    zattack.AttackType = Network.GamePackets.Attack.Kill;
                    zattack.X = X;
                    zattack.Y = Y;
                    MonsterInfo.SendScreen(zattack);
                    Owner.Map.RemoveEntity(this);
                    Owner.Companion = null;
                }
                if (EntityFlag == EntityFlag.Player)
                {
                    if (killer.EntityFlag == EntityFlag.Player)

                    {
                        #region Cheack Pk Map

                        if (Owner.Entity.MapID == 2555 || Owner.Entity.MapID == 5530 || Owner.Entity.MapID == 5531 || Owner.Entity.MapID == 5532 || Owner.Entity.MapID == 1452 || Owner.Entity.MapID == 5560 || Owner.Entity.MapID == 5570 || Owner.Entity.MapID == 5580)
                        {
                            Owner.Entity.Teleport(1002, 438, 382);
                            // Console.WriteLine("Done");
                        }

                        #endregion Cheack Pk Map
                        if (ServerBase.Constants.PKFreeMaps.Contains(killer.MapID))
                            goto Over;
                        if (ServerBase.Constants.Damage1Map.Contains(killer.MapID))
                            goto Over;
                        if (killer.Owner.Map.BaseID == 700)
                            goto Over;
                        if (!ContainsFlag(Network.GamePackets.Update.Flags.FlashingName) && !ContainsFlag(Network.GamePackets.Update.Flags.BlackName))
                        {
                            killer.AddFlag(Network.GamePackets.Update.Flags.FlashingName);
                            killer.FlashingNameStamp = Time32.Now;
                            killer.FlashingNameTime = 60;
                            if (killer.GuildID != 0)
                            {
                                if (killer.Owner.Guild.Enemy.ContainsKey(GuildID))
                                {
                                    killer.PKPoints += 3;
                                }
                                else
                                {
                                    if (!killer.Owner.Enemy.ContainsKey(UID))
                                        killer.PKPoints += 10;
                                    else
                                        killer.PKPoints += 5;
                                }
                            }
                            else
                            {
                                if (!killer.Owner.Enemy.ContainsKey(UID))
                                    killer.PKPoints += 10;
                                else
                                    killer.PKPoints += 5;
                            }
                            if (!this.Owner.Enemy.ContainsKey(killer.UID))
                            {
                                Network.PacketHandler.AddEnemy(this.Owner, killer.Owner);

                            }

                        }
                    }

                }

                if (killer.EntityFlag == EntityFlag.Monster)
                {
                    DropRandomStuff(Killer);
                }
                else
                {
                    DropRandomStuff(Killer);
                }

                RemoveFlag(Network.GamePackets.Update.Flags.FlashingName);
            Over:

                Network.GamePackets.Attack attack = new Attack(true);
                attack.Attacker = killer.UID;
                attack.Attacked = UID;
                attack.AttackType = Network.GamePackets.Attack.Kill;
                attack.X = X;
                attack.Y = Y;

                if (EntityFlag == EntityFlag.Player)
                {
                    AddFlag(Network.GamePackets.Update.Flags.Dead);
                    RemoveFlag(Network.GamePackets.Update.Flags.Fly);
                    RemoveFlag(Network.GamePackets.Update.Flags.Ride);
                    RemoveFlag(Network.GamePackets.Update.Flags.Cyclone);
                    RemoveFlag(Network.GamePackets.Update.Flags.Superman);
                    RemoveFlag(Network.GamePackets.Update.Flags.FatalStrike);
                    RemoveFlag(Network.GamePackets.Update.Flags.FlashingName);
                    RemoveFlag(Network.GamePackets.Update.Flags.ShurikenVortex);
                    RemoveFlag2(Network.GamePackets.Update.Flags2.Oblivion);

                    //  if (Body % 10 < 3)
                    //    TransformationID = 99;
                    //else
                    //  TransformationID = 98;

                    Owner.SendScreen(attack, true);
                    Owner.Send(new MapStatus() { BaseID = (ushort)Database.MapsTable.MapInformations[Owner.Map.ID].BaseID, ID = (uint)Owner.Map.ID, Status = Database.MapsTable.MapInformations[Owner.Map.ID].Status, Weather = Database.MapsTable.MapInformations[Owner.Map.ID].Weather });
                    Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                    weather.WeatherType = (uint)Program.WeatherType;
                    weather.Intensity = 100;
                    weather.Appearence = 2;
                    weather.Direction = 4;
                    Owner.Send(weather);
                    if (Owner.QualifierGroup != null)
                    {
                        Owner.QualifierGroup.End(Owner);
                    }
                }
                else
                {

                    if (!Companion)
                    {
                        try
                        {
                            if (MonsterInfo != null)
                                if (killer != null)
                                    MonsterInfo.Drop(killer);
                        }
                        catch { }
                    }
                    ServerBase.Kernel.Maps[MapID].Floor[X, Y, MapObjType, this] = true;
                    if (killer.EntityFlag == EntityFlag.Player)
                    {
                        killer.Owner.IncreaseExperience(MaxHitpoints, true);
                        if (killer.Owner.Team != null)
                        {
                            foreach (Client.GameState teammate in killer.Owner.Team.Teammates)
                            {
                                if (ServerBase.Kernel.GetDistance(killer.X, killer.Y, teammate.Entity.X, teammate.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                {
                                    if (killer.UID != teammate.Entity.UID)
                                    {
                                        uint extraExperience = MaxHitpoints / 2;
                                        if (killer.Spouse == teammate.Entity.Name)
                                            extraExperience = MaxHitpoints * 2;
                                        byte TLevelN = teammate.Entity.Level;
                                        if (killer.Owner.Team.CanGetNoobExperience(teammate))
                                        {
                                            if (teammate.Entity.Level < 137)
                                            {
                                                extraExperience *= 2;
                                                teammate.IncreaseExperience(extraExperience, false);
                                                teammate.Send(ServerBase.Constants.NoobTeamExperience(extraExperience));
                                            }
                                        }
                                        else
                                        {
                                            if (teammate.Entity.Level < 137)
                                            {
                                                teammate.IncreaseExperience(extraExperience, false);
                                                teammate.Send(ServerBase.Constants.TeamExperience(extraExperience));
                                            }
                                        }
                                        byte TLevelNn = teammate.Entity.Level;
                                        byte newLevel = (byte)(TLevelNn - TLevelN);
                                        if (newLevel != 0)
                                        {
                                            if (TLevelN < 70)
                                            {
                                                for (int i = TLevelN; i < TLevelNn; i++)
                                                {
                                                    teammate.Team.Teammates[0].VirtuePoints += (uint)(i * 3.83F);
                                                    teammate.Team.SendMessage(new Message("The leader, " + teammate.Team.Teammates[0].Entity.Name + ", has gained " + (uint)(i * 7.7F) + " virtue points for power leveling the rookies.", System.Drawing.Color.Red, Message.Team));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (killer.Level < 137)
                        {
                            uint extraExp = MaxHitpoints;
                            extraExp *= ServerBase.Constants.ExtraExperienceRate;
                            extraExp += extraExp * killer.Gems[3] / 100;
                            extraExp += (uint)(extraExp * ((float)killer.BattlePower / 100));
                            if (killer.DoubleExperienceTime > 0)
                                extraExp *= 2;
                            if (killer.HeavenBlessing > 0)
                                extraExp += (uint)(extraExp * 20 / 100);
                            if (killer.Reborn >= 2)
                                extraExp /= 3;
                            killer.Owner.Send(ServerBase.Constants.ExtraExperience(extraExp));
                        }
                        killer.Owner.XPCount++;
                        if (killer.OnKOSpell())
                            killer.KOSpellTime++;
                    }

                }
            }
        }
Example #7
0
        static void HandlePacket(byte[] packet, Client.GameState client)
        {
            if (packet == null)
                return;
            if (client == null)
                return;
            ushort Length = BitConverter.ToUInt16(packet, 0);
            ushort ID = BitConverter.ToUInt16(packet, 2);
            ushort ID2 = BitConverter.ToUInt16(packet, 4);
            switch (ID)
            {
                #region market quest
                case 2400:
                    {
                        if (client.Entity.QQ1 == 0)
                        {
                            client.Entity.Teleport(1068, 053, 055);
                        }
                        else
                        {
                            client.Send(new Message("you can only make quest once in day", Color.AntiqueWhite, 2005));
                        }

                        break;
                    }
                #endregion
                #region ElitePk Tournament 2223 | 2219
                case 2223:
                    {
                        if (client.Entity.MapID == 6002)
                            break;

                        if (ServerBase.Kernel.Elite_PK_Tournament.Start)
                            break;

                        GamePackets.Elite_Pk pk = new Elite_Pk(client.Entity.UID);
                        pk.Send(client);
                        break;
                    }
                case 2219:
                    {
                        if (client.Entity.MapID == 6002)
                            break;
                        byte[] sed = new byte[36]
                        {
                        0x1C ,0x00 ,0xAB ,0x08 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x03 ,0x00    //  ; «         
            ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x54 ,0x51 ,0x53 ,0x65     // ;            TQSe
            ,0x72 ,0x76 ,0x65 ,0x72                                         // ;rver
                        };
                        client.Send(sed);
                        break;

                    }
                case 1063:
                    {
                        GamePackets.Guild_Pk pk = new Guild_Pk(client.Entity.UID);
                        pk.Send(client);
                        //byte[] sed = new byte[346];
                        ////{0x5a ,0x01 ,0x27 ,0x04 ,0x09 ,0x00 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x21 ,0x42 ,0x72 ,0x61 ,0x73 ,0x69 ,0x6c ,0x54 ,0x6f ,0x50 ,0x54 ,0x65 ,0x61 ,0x6d ,0x21 ,0x00 ,0x45 ,0x2a ,0x00 ,0x00 ,0x0e ,0x00 ,0x00 ,0x00 ,0x40 ,0xd2 ,0xdf ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x7e ,0x5e ,0x21 ,0x54 ,0x68 ,0x65 ,0x5f ,0x42 ,0x65 ,0x73 ,0x74 ,0x21 ,0x5e ,0x7e ,0x00 ,0x00 ,0x2f ,0x20 ,0x00 ,0x00 ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 ,0x0e ,0x27 ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x46 ,0x69 ,0x72 ,0x65 ,0x45 ,0x6d ,0x62 ,0x6c ,0x65 ,0x6d ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x20 ,0x1c ,0x00 ,0x00 ,0x17 ,0x00 ,0x00 ,0x00 ,0x00 ,0xe1 ,0xf5 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x7e ,0x44 ,0x2e ,0x30 ,0x2e ,0x4a ,0x2e ,0x7e ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x3f ,0x0c ,0x00 ,0x00 ,0x0d ,0x00 ,0x00 ,0x00 ,0x40 ,0xf6 ,0xd3 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x2d ,0x4e ,0x7e ,0x4f ,0x7e ,0x59 ,0x7e ,0x50 ,0x7e ,0x49 ,0x2d ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x9e ,0x06 ,0x00 ,0x00 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 ,0x5a ,0x62 ,0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x53 ,0x75 ,0x70 ,0x72 ,0x65 ,0x6d ,0x65 ,0x7e ,0x46 ,0x6f ,0x72 ,0x63 ,0x65 ,0x00 ,0x00 ,0x00 ,0x2f ,0x06 ,0x00 ,0x00 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x2d ,0x31 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0xc8 ,0x00 ,0x00 ,0x00 ,0x53 ,0x69 ,0x6c ,0x65 ,0x6e ,0x54 ,0x5f ,0x48 ,0x65 ,0x41 ,0x6c ,0x4c ,0x23 ,0x30 ,0x31 ,0x00 ,0x40 ,0x03 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00 ,0x80 ,0xf0 ,0xfa ,0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0xf4 ,0x01 ,0x00 ,0x00 ,0x21 ,0x4e ,0x6f ,0x86 ,0x4d ,0x65 ,0x72 ,0x63 ,0x59 ,0x21 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0xe8 ,0x01 ,0x00 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00

                        ////};
                        //client.Send(sed);
                        break;

                    }
                case 2224:
                    {

                        client.Send(packet);
                        break;

                    }
                case 2232:
                    {

                        //                        byte[] sed = new byte[36]
                        //                        {
                        //                        0x1C ,0x00 ,0xAB ,0x08 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x03 ,0x00    //  ; «         
                        //,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x54 ,0x51 ,0x53 ,0x65     // ;            TQSe
                        //,0x72 ,0x76 ,0x65 ,0x72                                         // ;rver
                        //                        };
                        client.Send(packet);
                        break;

                    }
                case 2233:
                    {

                        GamePackets.Team_Pk pk = new Team_Pk(client.Entity.UID);
                        pk.Send(client);
                        break;

                    }
                case 2252:
                    {

                        // byte[] sed = new byte[60];
                        // ;rver };
                        client.Send(packet);
                        break;

                    }
                case 1130:
                    {
                        if (client.Entity.TitlePacket != null)
                        {
                            if (packet[9] == 4)
                            {
                                if (client.Entity.TitlePacket.dwParam2 != 0)
                                    client.Entity.TitlePacket.Send(client);
                            }
                            if (packet[9] == 3)
                            {
                                client.Entity.TitleActivated = packet[8];
                                client.Send(packet);
                                client.SendScreen(client.Entity.SpawnPacket, false);
                            }
                        }
                        break;
                    }
                #endregion
                #region TopGuilds
                case 1058:
                    {
                        if (client.Guild != null && client.AsMember != null)
                        {
                            if (client.AsMember != null)
                            {
                                Writer.WriteUInt32((uint)client.AsMember.SilverDonation, 8, packet);
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        if (client.AsMember.SilverDonation > client.Guild.money_donation)
                                        {
                                            client.Guild.money_donation = (uint)client.AsMember.SilverDonation;
                                            client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.OSupervisor;
                                            client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                        }

                                Writer.WriteUInt32((uint)client.AsMember.ConquerPointDonation, 20, packet);
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        if (client.AsMember.ConquerPointDonation > client.Guild.cp_donaion)
                                        {
                                            client.Guild.cp_donaion = (uint)client.AsMember.ConquerPointDonation;
                                            client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.CPSupervisor;
                                            client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                        }

                            }
                            Writer.WriteUInt32(client.Entity.PKPoints, 12, packet);
                            if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                    if (client.Entity.PKPoints > client.Guild.pkp_donation)
                                    {
                                        client.Guild.pkp_donation = (uint)client.Entity.PKPoints;
                                        client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.PKSupervisor;
                                        client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                    }

                            if (client.ArenaStatistic != null)
                            {
                                Writer.WriteUInt32(client.ArenaStatistic.CurrentHonor, 24, packet);
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        if (client.ArenaStatistic.CurrentHonor > client.Guild.honor_donation)
                                        {
                                            client.Guild.honor_donation = (uint)client.ArenaStatistic.CurrentHonor;
                                            client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.HonoraryManager;
                                            client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                        }
                            }
                            Writer.WriteUInt32(0, 16, packet);
                            if (client.Entity != null)
                                if (client.Entity.MyFlowers != null)
                                {
                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.RedRoses, 28, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.RedRoses > client.Guild.rose_donation)
                                            {
                                                client.Guild.rose_donation = (uint)client.Entity.MyFlowers.RedRoses;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.RoseSupervisor;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }

                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.Tulips, 32, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.Tulips > client.Guild.tuil_donation)
                                            {
                                                client.Guild.tuil_donation = (uint)client.Entity.MyFlowers.Tulips;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.TulipFollower;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }

                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.Lilies, 36, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.Lilies > client.Guild.lilies_donation)
                                            {
                                                client.Guild.lilies_donation = (uint)client.Entity.MyFlowers.Lilies;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.LilySupervisor;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }

                                    Writer.WriteUInt32((uint)client.Entity.MyFlowers.Orchads, 40, packet);
                                    if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                            if (client.Entity.MyFlowers.Orchads > client.Guild.orchid_donation)
                                            {
                                                client.Guild.orchid_donation = (uint)client.Entity.MyFlowers.Orchads;
                                                client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.OrchidFollower;
                                                client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }
                                    Writer.WriteUInt32((uint)(client.Entity.MyFlowers.Orchads
                                        + (uint)client.Entity.MyFlowers.RedRoses
                                        + (uint)client.Entity.MyFlowers.Tulips
                                        + (uint)client.Entity.MyFlowers.Lilies), 44, packet);
                                }
                            if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                if (client.Entity.GuildRank != (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                {
                                    if (client.Entity.Name == client.Guild.LeaderName)
                                    {
                                        client.Entity.GuildRank = (ushort)Conquer_Online_Server.Game.Enums.GuildMemberRank.LeaderSpouse;
                                        client.AsMember.Rank = (Conquer_Online_Server.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                    }
                                }
                            if (client.Guild != null)
                                client.Guild.SendGuild(client);
                            client.Send(packet);
                        }
                        break;
                    }
                #endregion
                #region Guild members (2102)
                case 2102:
                    {
                        ushort Page = BitConverter.ToUInt16(packet, 8);
                        if (client.Guild != null)
                        {
                            client.Guild.SendMembers(client, Page);
                        }
                        break;
                    }
                #endregion
                #region EnitityCreate (1001)
                case 1001:
                    {
                        if (client.Action == 1)
                        {
                            EnitityCreate EC = new EnitityCreate();
                            EC.Deserialize(packet);
                            string Message = "";
                            Boolean Created = Database.EntityTable.CreateEntity(EC, client, ref Message);
                            client.Send(new Message(Message, "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.PopUP));
                            if (Created)
                                Console.WriteLine(client.Account.Username + " Sucesfully Created a new Character " + EC.Name);
                            client.JustCreated = true;
                        }
                        break;
                    }
                #endregion
                #region Chat/Message (1004)
                case 1004:
                    {
                        if (client.Action != 2)
                            return;
                        Message message = new Message();
                        message.Deserialize(packet);
                        if (message.__Message.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries).Length > 0)
                            message.__Message = message.__Message.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
                        Chat(message, client);
                        break;
                    }
                #endregion
                #region Item/Ping (1009)
                case 1009:
                    {
                        if (client.Action != 2)
                            return;
                        ItemUsage usage = new ItemUsage(false);
                        usage.Deserialize(packet);
                        if (!client.Entity.Dead || usage.ID == ItemUsage.Ping)
                        {
                            switch (usage.ID)
                            {

                                case 52:
                                    {
                                        var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                        item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.ChatItem;
                                        item.Send(client);
                                        break;
                                    }
                                case 41:
                                    {
                                        var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                        usage.dwParam = 5;
                                        client.Send(usage);
                                        break;
                                    }
                                case ItemUsage.ArrowReload:
                                    {
                                        ReloadArrows(client.Equipment.TryGetItem(ConquerItem.LeftWeapon), client);

                                        break;
                                    }
                                case ItemUsage.ShowBoothItems:
                                    {
                                        ShowBoothItems(usage, client);
                                        break;
                                    }
                                case ItemUsage.AddItemOnBoothForSilvers:
                                case ItemUsage.AddItemOnBoothForConquerPoints:
                                    {
                                        AddItemOnBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.BuyFromBooth:
                                    {
                                        BuyFromBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.RemoveItemFromBooth:
                                    {
                                        RemoveItemFromBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.EquipItem:
                                    {
                                        EquipItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.UnequipItem:
                                    {
                                        UnequipItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.BuyFromNPC:
                                    {
                                        HandleBuyFromNPC(usage, client);
                                        break;
                                    }
                                case ItemUsage.SellToNPC:
                                    {
                                        HandleSellToNPC(usage, client);
                                        break;
                                    }
                                case ItemUsage.Repair:
                                    {
                                        HandleRepair(usage, client);
                                        break;
                                    }
                                case ItemUsage.MeteorUpgrade:
                                case ItemUsage.DragonBallUpgrade:
                                    {
                                        UpgradeItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.Ping:
                                    {
                                        if (Time32.Now < client.LastPing.AddSeconds(2))
                                        {
                                            client.PingCount++;
                                            if (client.PingCount == 40)
                                            {
                                                Console.WriteLine(client.Entity.Name + " Nuevo hacker detectado con la ip {" + client.Account.IP + "}");
                                                Conquer_Online_Server.ServerBase.Kernel.SendWorldMessage(new Message("El Usuario " + client.Entity.Name + " ha utilizado hacker y se ha madando a la JailBot.", System.Drawing.Color.Blue, Network.GamePackets.Message.Center), Conquer_Online_Server.ServerBase.Kernel.GamePool.Values);
                                                client.Entity.Teleport(7852, 31, 74);
                                                client.Entity.PuntosJailBot += 1;
                                                client.Entity.AddFlag(Network.GamePackets.Update.Flags.Ghost);
                                                client.Entity.AddFlag(Network.GamePackets.Update.Flags.Dead);
                                                Network.GamePackets.Attack zattack = new Network.GamePackets.Attack(true);
                                                zattack.Attacked = client.Entity.UID;
                                                zattack.AttackType = Network.GamePackets.Attack.Kill;
                                                zattack.X = client.Entity.X;
                                                zattack.Y = client.Entity.Y;
                                            }
                                        }

                                        if (client.Entity != null)
                                        {
                                            if (client.Entity.UID != 0)
                                            {
                                                if (!ServerBase.Kernel.GamePool.ContainsKey(client.Entity.UID))
                                                {
                                                    ServerBase.Kernel.GamePool.Add(client.Entity.UID, client);
                                                }
                                            }
                                        }

                                        client.LastPingT = client.LastPing;
                                        client.LastPing = Time32.Now;

                                        if (client.LastPing > client.LastPingT.AddSeconds(2))
                                            client.PingCount = 0;
                                        usage.TimeStamp += 200;
                                        client.Send(ReturnFinal(packet));
                                        //Network.PacketHandler.HandleBuffer(packet, client);
                                        client.Send(usage);
                                        if (!ServerBase.Kernel.GamePool.ContainsKey(client.Entity.UID))
                                            if (client.Socket.Connected)
                                            {
                                                ServerBase.Kernel.GamePool.Add(client.Entity.UID, client);
                                                client.Screen.FullWipe();
                                                client.Screen.Reload(null);
                                            }
                                        break;
                                    }
                                case ItemUsage.ViewWarehouse:
                                    {
                                        usage.dwParam = client.MoneySave;
                                        client.Send(usage);
                                        break;
                                    }
                                case ItemUsage.WarehouseDeposit:
                                    {
                                        if (client.Entity.Money >= usage.dwParam)
                                        {
                                            client.Entity.Money -= usage.dwParam;
                                            client.MoneySave += usage.dwParam;
                                        }
                                        break;
                                    }
                                case ItemUsage.WarehouseWithdraw:
                                    {
                                        if (client.MoneySave >= usage.dwParam)
                                        {
                                            client.Entity.Money += usage.dwParam;
                                            client.MoneySave -= usage.dwParam;
                                        }
                                        break;
                                    }
                                case ItemUsage.DropItem:
                                    {
                                        DropItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.DropMoney:
                                    {
                                        DropMoney(usage, client);
                                        break;
                                    }
                                case ItemUsage.Enchant:
                                    {
                                        EnchantItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.SocketTalismanWithItem:
                                    {
                                        SocketTalismanWithItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.SocketTalismanWithCPs:
                                    {
                                        SocketTalismanWithCPs(usage, client);
                                        break;
                                    }
                                case 40:
                                    {
                                        uint ItemAdd = (uint)((packet[4] & 0xFF) | ((packet[5] & 0xFF) << 8) | ((packet[6] & 0xFF) << 16) | ((packet[7] & 0xFF) << 24));

                                        //PrintPacket(packet);
                                        Interfaces.IConquerItem item_new = null;
                                        if (client.Inventory.TryGetItem(ItemAdd, out item_new))
                                        {
                                            if (item_new.Bless == 7)
                                                return;

                                            Queue<uint> amount = new Queue<uint>(packet[20]);

                                            for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                            {
                                                if (client.Inventory.ContainsUID((uint)((packet[i] & 0xFF) | ((packet[(byte)(i + 1)] & 0xFF) << 8) | ((packet[(byte)(i + 2)] & 0xFF) << 16) | ((packet[(byte)(i + 3)] & 0xFF) << 24))))
                                                    amount.Enqueue((uint)((packet[i] & 0xFF) | ((packet[(byte)(i + 1)] & 0xFF) << 8) | ((packet[(byte)(i + 2)] & 0xFF) << 16) | ((packet[(byte)(i + 3)] & 0xFF) << 24)));
                                                else
                                                    return;
                                            }

                                            byte oldbless = item_new.Bless;
                                            if (item_new.Bless == 0 && amount.Count == 5)
                                                item_new.Bless = 1;
                                            else if (item_new.Bless == 1 && amount.Count == 1)
                                                item_new.Bless = 3;
                                            else if (item_new.Bless == 3 && amount.Count == 3)
                                                item_new.Bless = 5;
                                            else if (item_new.Bless == 5 && amount.Count == 5)
                                                item_new.Bless = 7;
                                            if (oldbless == item_new.Bless)
                                                return;

                                            while (amount.Count != 0)
                                                client.Inventory.Remove(amount.Dequeue(), Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);

                                            item_new.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                                            item_new.Send(client);
                                            Database.ConquerItemTable.UpdateItem(item_new, client);
                                        }
                                        //client.Send(packet);
                                        break;
                                    }
                                case 53:
                                    {
                                        uint ItemAdd = BitConverter.ToUInt32(packet, 8);

                                        //Interfaces.IConquerItem item_new = null;
                                        //if (client.Inventory.TryGetItem(ItemAdd, out item_new))
                                        {
                                            uint obtined_points = 0;
                                            Database.ConquerItemInformation iteminfo = new Conquer_Online_Server.Database.ConquerItemInformation(ItemAdd, 0);
                                            Dictionary<uint, uint> amount = new Dictionary<uint, uint>();//packet[20]);
                                            for (ushort i = 80; i < 84 + 4 * packet[20]; i += 4)
                                            {
                                                uint item_swap = BitConverter.ToUInt32(packet, i);
                                                if (client.Inventory.ContainsUID(item_swap))
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(item_swap, out item))
                                                    {
                                                        amount.Add(item_swap, i);
                                                    }
                                                    switch (item.ID)
                                                    {
                                                        case 191505:
                                                        case 191605:
                                                        case 191705:
                                                        case 191805:
                                                        case 191905:
                                                        case 191405:
                                                        case 183325:
                                                        case 183315:
                                                        case 183375:
                                                        case 183305:
                                                            {
                                                                obtined_points += 300;
                                                                break;
                                                            }
                                                        default:
                                                            obtined_points += 50;
                                                            break;
                                                    }
                                                }
                                            }
                                            if (iteminfo.BaseInformation.ConquerPointsWorth > obtined_points)
                                            {
                                                uint add_cps = 0;
                                                add_cps = (uint)(iteminfo.BaseInformation.ConquerPointsWorth - obtined_points);
                                                if (add_cps < client.Entity.ConquerPoints)
                                                {
                                                    client.Entity.ConquerPoints -= add_cps;
                                                    foreach (uint key in amount.Keys)
                                                    {
                                                        if (client.Inventory.ContainsUID(key))
                                                            client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
                                                    }
                                                    client.Inventory.Add(ItemAdd, 0, 1);

                                                }
                                            }
                                            else
                                            {
                                                foreach (uint key in amount.Keys)
                                                {
                                                    if (client.Inventory.ContainsUID(key))
                                                        client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
                                                }
                                                client.Inventory.Add(ItemAdd, 0, 1);

                                            }
                                        }
                                        break;
                                    }
                                case ItemUsage.SocketerMan:
                                    {
                                        #region Socketing
                                        UInt32 Count = usage.dwExtraInfo, ItemUID = usage.UID;
                                        Byte Type = 0;
                                        Interfaces.IConquerItem Item = null;
                                        if (client.Inventory.TryGetItem(ItemUID, out Item))
                                        {
                                            #region Removing Used Items
                                            for (int i = 1; i <= Count; i++)
                                            {
                                                uint It = BitConverter.ToUInt32(packet, (int)(80 + (4 * i)));
                                                Interfaces.IConquerItem Rem = null;
                                                if (client.Inventory.TryGetItem(It, out Rem))
                                                {
                                                    if (Rem.ID == 1088000 && Count == 12)
                                                        Type = 1;
                                                    if (Rem.ID == 1088000 && Count == 1)
                                                        Type = 2;
                                                    if (Rem.ID == 1088000 && Count == 5)
                                                        Type = 3;
                                                    if (Rem.ID == 1200005 && Count == 1)
                                                        Type = 4;
                                                    if (Rem.ID == 1200006 && Count == 7)
                                                        Type = 5;
                                                    client.Inventory.Remove(Rem, Game.Enums.ItemUse.Remove);
                                                }
                                            }
                                            #endregion
                                            #region Type Switch
                                            switch (Type)
                                            {
                                                #region Open First Socket
                                                case 1:
                                                case 2:
                                                    {
                                                        usage.dwParam = 1;
                                                        Item.Mode = Game.Enums.ItemMode.Update;
                                                        Item.SocketOne = (Game.Enums.Gem)255;
                                                        Item.Send(client);
                                                        Item.Mode = Game.Enums.ItemMode.Default;
                                                        Conquer_Online_Server.Database.ConquerItemTable.UpdateSockets(Item, client);
                                                        break;
                                                    }
                                                #endregion
                                                #region Open Second Socket
                                                case 3:
                                                case 5:
                                                    {
                                                        usage.dwParam = 1;
                                                        Item.Mode = Game.Enums.ItemMode.Update;
                                                        Kernel.SendWorldMessage(new Message("Congratulations! " + client.Entity.Name + " has oppened the second socket into his/her item!", System.Drawing.Color.Yellow, 2011), Kernel.GamePool.Values, client.Entity.UID);
                                                        Item.SocketTwo = (Game.Enums.Gem)255;
                                                        Item.Send(client);
                                                        Item.Mode = Game.Enums.ItemMode.Default;
                                                        Conquer_Online_Server.Database.ConquerItemTable.UpdateSockets(Item, client);
                                                        break;
                                                    }
                                                #endregion
                                                #region Using Tough Drill
                                                case 4:
                                                    {
                                                        if (ServerBase.Kernel.Rate(10))
                                                        {
                                                            usage.dwParam = 1;
                                                            Item.Mode = Game.Enums.ItemMode.Update;
                                                            Kernel.SendWorldMessage(new Message("Congratulations! " + client.Entity.Name + " has oppened the second socket into his/her item!", System.Drawing.Color.Yellow, 2011), Kernel.GamePool.Values, client.Entity.UID);
                                                            Item.SocketTwo = (Game.Enums.Gem)255;
                                                            Item.Send(client);
                                                            Item.Mode = Game.Enums.ItemMode.Default;
                                                            Conquer_Online_Server.Database.ConquerItemTable.UpdateSockets(Item, client);
                                                        }
                                                        else
                                                        {
                                                            usage.dwParam = 0;
                                                            client.Send(new Message("The ToughDrill has failed. Try your lucky next time!", System.Drawing.Color.Red, Message.TopLeft));
                                                            client.Inventory.Add(1200006, 0, 1);
                                                        }
                                                        break;
                                                    }
                                                #endregion
                                            }
                                            #endregion
                                        }
                                        //dWParam Values, = 0 = Failed, 1 = Suceed, 2 = Nothing
                                        client.Send(usage);
                                        #endregion
                                        break;
                                    }
                                case ItemUsage.RedeemGear:
                                    {
                                        var item = client.DeatinedItem[usage.UID];
                                        if (item != null)
                                        {
                                            if (DateTime.Now > item.Date.AddDays(7))
                                            {
                                                client.Send(new Message("This item is expired!", System.Drawing.Color.White, Message.TopLeft));

                                                return;
                                            }
                                            if (client.Entity.ConquerPoints >= item.ConquerPointsCost)
                                            {
                                                client.Entity.ConquerPoints = (uint)Math.Max(0, (uint)((uint)client.Entity.ConquerPoints - (uint)item.ConquerPointsCost));

                                                usage.dwParam = client.Entity.UID;
                                                usage.dwExtraInfo3 = item.ConquerPointsCost;
                                                client.Send(usage);

                                                client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Add);

                                                Database.DetainedItemTable.Redeem(item, client);
                                                client.DeatinedItem.Remove(item.UID);

                                                if (ServerBase.Kernel.GamePool.ContainsKey(item.GainerUID))
                                                {
                                                    var pClient = ServerBase.Kernel.GamePool[item.GainerUID];
                                                    if (pClient.ClaimableItem.ContainsKey(item.UID))
                                                    {
                                                        pClient.ClaimableItem[item.UID].OwnerUID = 500;
                                                        pClient.ClaimableItem[item.UID].MakeItReadyToClaim();
                                                        usage.dwParam = pClient.Entity.UID;
                                                        usage.ID = ItemUsage.ClaimGear;
                                                        pClient.Send(usage);
                                                        pClient.ClaimableItem[item.UID].Send(pClient);
                                                    }
                                                }
                                                Message message = new Message(item.OwnerName + " has redeemed the detained items from the arrest and " + item.GainerName + " has received the ransom as a reward.", System.Drawing.Color.Wheat, Message.TopLeft);
                                                ServerBase.Kernel.SendWorldMessage(message, ServerBase.Kernel.GamePool.Values);
                                            }
                                        }
                                        else
                                        {
                                            client.Send(new Message("The item you want to redeem has already been redeemed.", System.Drawing.Color.White, Message.TopLeft));
                                        }
                                        break;
                                    }
                                case ItemUsage.ClaimGear:
                                    {
                                        var item = client.ClaimableItem[usage.UID];
                                        if (item != null)
                                        {
                                            if (item.Bound)
                                            {
                                                client.Send(new Message("Unnclaimable item!", System.Drawing.Color.White, Message.TopLeft));
                                                return;
                                            }
                                            if (DateTime.Now < item.Date.AddDays(7) && item.OwnerUID != 500)
                                            {
                                                client.Send(new Message("This item is not expired. You cannot claim it yet!", System.Drawing.Color.White, Message.TopLeft));
                                                return;
                                            }
                                            if (item.OwnerUID == 500)
                                                client.Entity.ConquerPoints += item.ConquerPointsCost;
                                            else
                                            {
                                                client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Move);
                                                Message message = new Message(item.OwnerName + " has redeemed the detained items from the arrest and " + item.GainerName + " has received the ransom as a reward.", System.Drawing.Color.Wheat, Message.TopLeft);
                                                ServerBase.Kernel.SendWorldMessage(message, ServerBase.Kernel.GamePool.Values);
                                            }
                                            Database.DetainedItemTable.Claim(item, client);
                                            client.ClaimableItem.Remove(item.UID);

                                            usage.dwParam = client.Entity.UID;
                                            usage.dwExtraInfo3 = item.ConquerPointsCost;
                                            client.Send(usage);
                                        }
                                        else
                                        {
                                            client.Send(new Message("The item you want to claim has already been claimed.", System.Drawing.Color.White, Message.TopLeft));
                                        }
                                        break;
                                    }
                                case 34:
                                    {
                                        break;
                                    }
                                case 45:
                                    {
                                        client.Entity.Teleport(1002, 429, 378);
                                        break;
                                    }
                                default:
                                    {
                                        Console.WriteLine("Unhandled item usage type : " + usage.ID);
                                        break;
                                    }
                            }
                        }
                        break;
                    }
                #endregion
                #region String (1015)
                case 1015:
                    {
                        if (client.Action != 2)
                            return;
                        _String stringpacket = new _String(false);
                        stringpacket.Deserialize(packet);
                        switch (stringpacket.Type)
                        {
                            case _String.WhisperDetails:
                                {
                                    if (stringpacket.Texts.Count > 0)
                                    {
                                        var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                        varr.MoveNext();
                                        int COunt = ServerBase.Kernel.GamePool.Count;
                                        for (uint x = 0;
                                            x < COunt;
                                            x++)
                                        {
                                            if (x >= COunt) break;

                                            Client.GameState pClient = (varr.Current as Client.GameState);

                                            if (pClient.Entity.Name == stringpacket.Texts[0])
                                            {
                                                string otherstring = "";
                                                otherstring += pClient.Entity.UID + " ";
                                                otherstring += pClient.Entity.Level + " ";
                                                otherstring += pClient.Entity.BattlePower + " #";
                                                if (pClient.Entity.GuildID != 0)
                                                    otherstring += pClient.Guild.Name + " fNone# ";
                                                else
                                                    otherstring += "None fNone# ";
                                                otherstring += pClient.Entity.Spouse + " ";
                                                otherstring += (byte)(pClient.Entity.NobilityRank) + " ";
                                                if (pClient.Entity.Body % 10 < 3)
                                                    otherstring += "1";
                                                else
                                                    otherstring += "0";
                                                stringpacket.Texts.Add(otherstring);
                                                client.Send(stringpacket);
                                            }

                                            varr.MoveNext();

                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region KnownPersons (1019)
                case 1019:
                    {
                        KnownPersons knownP = new KnownPersons(false);
                        knownP.Deserialize(packet);
                        switch (knownP.Type)
                        {
                            case KnownPersons.RequestFriendship:
                                {
                                    AddFriend(knownP, client);
                                    break;
                                }
                            case KnownPersons.RemovePerson:
                                {
                                    RemoveFriend(knownP, client);
                                    break;
                                }
                            case KnownPersons.RemoveEnemy:
                                {
                                    RemoveEnemy(knownP, client);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Attack (1022)
                case 1022:
                    {
                        if (client.Action != 2)
                            return;
                        uint dmg = BitConverter.ToUInt32(packet, 24);
                        uint AttackType = BitConverter.ToUInt32(packet, 20);
                        GamePackets.Attack attack = new Attack(false);
                        attack.Deserialize(packet);
                        if (client.Entity.ContainsFlag(Update.Flags.Ride) && !client.Entity.Owner.Equipment.Free(18))
                        {
                            Attack(attack, client);
                            return;
                        }
                        else
                        {
                            client.Entity.RemoveFlag(Update.Flags.Ride);
                        }
                        Attack(attack, client);
                        break;
                    }
                #endregion
                #region Teams (1023)
                case 1023:
                    {
                        if (client.Action != 2)
                            return;
                        Team teamPacket = new Team();
                        teamPacket.Deserialize(packet);
                        switch (teamPacket.Type)
                        {
                            case Team.Create: CreateTeam(teamPacket, client); break;
                            case Team.AcceptJoinRequest: AcceptRequestToJoinTeam(teamPacket, client); break;
                            case Team.AcceptInvitation: AcceptInviteToJoinTeam(teamPacket, client); break;
                            case Team.InviteRequest: SendInviteToJoinTeam(teamPacket, client); break;
                            case Team.JoinRequest: SendRequestJoinToTeam(teamPacket, client); break;
                            case Team.ExitTeam: LeaveTeam(teamPacket, client); break;
                            case Team.Dismiss: DismissTeam(teamPacket, client); break;
                            case Team.Kick: KickFromTeam(teamPacket, client); break;
                            case Team.ForbidJoining:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.ForbidJoin = true;
                                                Teammate.Send(teamPacket);
                                            }

                                    break;
                                }
                            case Team.UnforbidJoining:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.ForbidJoin = false;
                                                Teammate.Send(teamPacket);
                                            }

                                    break;
                                }
                            case Team.LootMoneyOff:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupMoney = true;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                            case Team.LootMoneyOn:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupMoney = false;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                            case Team.LootItemsOn:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupItems = true;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                            case Team.LootItemsOff:
                                {
                                    if (client.Team != null && client.Team.Teammates != null) foreach (Client.GameState Teammate in client.Team.Teammates)
                                            if (Teammate != null)
                                            {
                                                Teammate.Team.PickupItems = false;
                                                Teammate.Send(teamPacket);
                                            }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Atributes Set (1024)
                case 1024:
                    {
                        if (client.Action != 2)
                            return;
                        ushort AddStr = BitConverter.ToUInt16(packet, 8);
                        ushort AddAgi = BitConverter.ToUInt16(packet, 12);
                        ushort AddVit = BitConverter.ToUInt16(packet, 16);
                        ushort AddSpi = BitConverter.ToUInt16(packet, 20);
                        if (AddStr > 0)
                        {
                            if (client.Entity.Atributes >= AddStr)
                            {
                                client.Entity.Atributes -= AddStr;
                                client.Entity.Strength += AddStr;
                            }
                        }
                        if (AddAgi > 0)
                        {
                            if (client.Entity.Atributes >= AddAgi)
                            {
                                client.Entity.Atributes -= AddAgi;
                                client.Entity.Agility += AddAgi;
                            }
                        }
                        if (AddVit > 0)
                        {
                            if (client.Entity.Atributes >= AddVit)
                            {
                                client.Entity.Atributes -= AddVit;
                                client.Entity.Vitality += AddVit;
                            }
                        }
                        if (AddSpi > 0)
                        {
                            if (client.Entity.Atributes >= AddSpi)
                            {
                                client.Entity.Atributes -= AddSpi;
                                client.Entity.Spirit += AddSpi;
                            }
                        }
                        //Conquer_Online_Server.Game.Attacking.Calculate.Vitals(client.Entity, true);
                        client.CalculateStatBonus();
                        client.CalculateHPBonus();
                        client.GemAlgorithm();
                        client.SendStatMessage();
                        break;
                    }
                #endregion
                #region Socketing (1027)
                case 1027:
                    {
                        EmbedSocket socket = new EmbedSocket(false);
                        socket.Deserialize(packet);
                        SocketItem(socket, client);
                        break;
                    }
                #endregion
                #region ItemAdding Stabilization
                case 1038:
                    {
                        ItemAddingStabilization stabilization = new ItemAddingStabilization(false);
                        stabilization.Deserialize(packet);
                        StabilazeArtifact(stabilization, client);
                        break;
                    }
                #endregion
                #region LoginPacket (1052)
                case 1052:
                    {
                        if (client.Action == 1)
                        {
                            Connect connect = new Connect();
                            connect.Deserialize(packet);
                            AppendConnect(connect, client);
                        }
                        else
                            client.Disconnect();
                        break;
                    }
                #endregion
                #region Trade (1056)
                case 1056:
                    {
                        if (client.Action != 2)
                            return;
                        Trade trade = new Trade(false);
                        trade.Deserialize(packet);
                        switch (trade.Type)
                        {
                            case Trade.Request:
                                RequestTrade(trade, client);
                                break;
                            case Trade.Close:
                                CloseTrade(trade, client);
                                break;
                            case Trade.AddItem:
                                AddTradeItem(trade, client);
                                break;
                            case Trade.SetMoney:
                                SetTradeMoney(trade, client);
                                break;
                            case Trade.SetConquerPoints:
                                SetTradeConquerPoints(trade, client);
                                break;
                            case Trade.Accept:
                                AcceptTrade(trade, client);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Floor items (1101)
                case 1101:
                    {
                        if (client.Action != 2)
                            return;
                        FloorItem floorItem = new FloorItem(false);
                        floorItem.Deserialize(packet);
                        PickupItem(floorItem, client);
                        break;
                    }
                #endregion
                #region Warehouses (1102)
                case 1102:
                    {
                        if (client.Action != 2)
                            return;
                        Warehouse warehousepacket = new Warehouse(false);
                        warehousepacket.Deserialize(packet);
                        switch (warehousepacket.Type)
                        {
                            case Warehouse.Entire:
                                {
                                    Game.ConquerStructures.Warehouse wh = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                    if (wh == null) return;
                                    byte count = 0;
                                    warehousepacket.Count = 1;
                                    warehousepacket.Type = Warehouse.AddItem;
                                    for (; count < wh.Count; count++)
                                    {
                                        warehousepacket.Append(wh.Objects[count]);
                                        client.Send(warehousepacket);
                                    }
                                    break;
                                }
                            case Warehouse.AddItem:
                                {
                                    Game.ConquerStructures.Warehouse wh = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                    if (wh == null) return;
                                    Interfaces.IConquerItem item = null;
                                    if (client.Inventory.TryGetItem(warehousepacket.UID, out item))
                                    {
                                        if (wh.Add(item))
                                        {
                                            warehousepacket.UID = 0;
                                            warehousepacket.Count = 1;
                                            warehousepacket.Append(item);
                                            client.Send(warehousepacket);
                                            return;
                                        }
                                    }
                                    break;
                                }
                            case Warehouse.RemoveItem:
                                {
                                    Game.ConquerStructures.Warehouse wh = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                    if (wh == null) return;
                                    if (wh.ContainsUID(warehousepacket.UID))
                                    {
                                        if (wh.Remove(warehousepacket.UID))
                                        {
                                            client.Send(warehousepacket);
                                            return;
                                        }
                                    }
                                    break;
                                }
                            default:
                                {
                                    Console.WriteLine("Unknown type: " + warehousepacket.Type);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Guild command (1107)
                case 1107:
                    {
                        GuildCommand command = new GuildCommand(false);
                        command.Deserialize(packet);
                        switch (command.Type)
                        {
                            case GuildCommand.Neutral1:
                            case GuildCommand.Neutral2:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.RemoveAlly(name);
                                            foreach (var guild in ServerBase.Kernel.Guilds.Values)
                                            {
                                                if (guild.Name == name && client.Guild.Name != name)
                                                {
                                                    guild.RemoveAlly(client.Guild.Name);
                                                }
                                            }
                                            client.Guild.RemoveEnemy(name);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Allied:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            AllyGuilds(name, client);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Enemied:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.AddEnemy(name);
                                        }
                                    }
                                    break;
                                }
                            default:
                                {
                                    client.Send(packet);
                                    break;
                                }
                            case GuildCommand.Bulletin:
                                {
                                    string message = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.Bulletin = message;
                                            client.Guild.SendGuild(client);
                                            Database.GuildTable.UpdateBulletin(client.Guild, client.Guild.Bulletin);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.DonateSilvers:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.Entity.Money >= command.dwParam)
                                        {
                                            client.Guild.SilverFund += command.dwParam;
                                            Database.GuildTable.SaveFunds(client.Guild);
                                            client.AsMember.SilverDonation += command.dwParam;
                                            client.Entity.Money -= command.dwParam;
                                            client.Guild.SendGuild(client);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.DonateConquerPoints:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.Entity.ConquerPoints >= command.dwParam)
                                        {
                                            client.Guild.ConquerPointFund += command.dwParam;
                                            Database.GuildTable.SaveFunds(client.Guild);
                                            client.AsMember.ConquerPointDonation += command.dwParam;
                                            client.Entity.ConquerPoints -= command.dwParam;
                                            client.Guild.SendGuild(client);
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Refresh:
                                {
                                    if (client.AsMember != null)
                                    {
                                        if (client.Guild != null)
                                            client.Guild.SendGuild(client);
                                    }
                                    break;
                                }
                            case GuildCommand.Discharge:
                                {
                                    string name = System.Text.ASCIIEncoding.ASCII.GetString(packet, 26, packet[25]);
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            var member = client.Guild.GetMemberByName(name);
                                            if (member.ID != client.Entity.UID)
                                            {
                                                if (member.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                                {
                                                    client.Guild.DeputyLeaderCount--;
                                                    member.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.Member;
                                                    if (member.IsOnline)
                                                    {
                                                        client.Guild.SendGuild(member.Client);
                                                        member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                        member.Client.Screen.FullWipe();
                                                        member.Client.Screen.Reload(null);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Promote:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            if (client.Guild.Members.ContainsKey(command.dwParam))
                                            {
                                                var member = client.Guild.Members[command.dwParam];
                                                if (member.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    member.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader;
                                                    if (member.IsOnline)
                                                    {
                                                        client.Guild.SendGuild(member.Client);
                                                        member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                        member.Client.Screen.FullWipe();
                                                        member.Client.Screen.Reload(null);
                                                    }
                                                }
                                                else if (member.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader)
                                                {
                                                    member.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader;
                                                    if (member.IsOnline)
                                                    {
                                                        client.Guild.SendGuild(member.Client);
                                                        member.Client.Entity.GuildRank = (ushort)member.Rank;
                                                        member.Client.Screen.FullWipe();
                                                        member.Client.Screen.Reload(null);
                                                    }
                                                    client.AsMember.Rank = Conquer_Online_Server.Game.Enums.GuildMemberRank.DeputyLeader;
                                                    client.Guild.SendGuild(client);
                                                    client.Entity.GuildRank = (ushort)client.AsMember.Rank;
                                                    client.Screen.FullWipe();
                                                    client.Screen.Reload(null);
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.JoinRequest:
                                {
                                    if (ServerBase.Kernel.GamePool.ContainsKey(command.dwParam))
                                    {
                                        var Client = ServerBase.Kernel.GamePool[command.dwParam];
                                        if (Client.OnHoldGuildJoin == client.OnHoldGuildJoin && Client.OnHoldGuildJoin != 0)
                                        {
                                            if (Client.Guild != null)
                                            {
                                                if (Client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    Client.Guild.AddMember(client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            else
                                            {
                                                if (client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    client.Guild.AddMember(Client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            return;
                                        }
                                        if (client.Guild == null)
                                        {
                                            command.dwParam = client.Entity.UID;
                                            Client.Send(command);
                                            Client.OnHoldGuildJoin = (uint)new Random().Next();
                                            client.OnHoldGuildJoin = Client.OnHoldGuildJoin;
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.InviteRequest:
                                {
                                    if (ServerBase.Kernel.GamePool.ContainsKey(command.dwParam))
                                    {
                                        var Client = ServerBase.Kernel.GamePool[command.dwParam];
                                        if (Client.OnHoldGuildJoin == client.OnHoldGuildJoin && Client.OnHoldGuildJoin != 0)
                                        {
                                            if (Client.Guild != null)
                                            {
                                                if (Client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    Client.Guild.AddMember(client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            else
                                            {
                                                if (client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.Member)
                                                {
                                                    client.Guild.AddMember(Client);
                                                    Client.OnHoldGuildJoin = 0;
                                                    client.OnHoldGuildJoin = 0;
                                                }
                                            }
                                            return;
                                        }
                                        if (client.Guild != null)
                                        {
                                            command.dwParam = client.Entity.UID;
                                            Client.Send(command);
                                            Client.OnHoldGuildJoin = (uint)new Random().Next();
                                            client.OnHoldGuildJoin = Client.OnHoldGuildJoin;
                                        }
                                    }
                                    break;
                                }
                            case GuildCommand.Quit:
                                {
                                    if (client.Guild != null)
                                    {
                                        if (client.AsMember.Rank != Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            client.Guild.ExpelMember(client.Entity.Name, true);
                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Enlight (1127)
                case 1127:
                    {
                        Enlight enlight = new Enlight(false);
                        enlight.Deserialize(packet);
                        if (ServerBase.Kernel.GamePool.ContainsKey(enlight.Enlighted))
                        {
                            var Client = ServerBase.Kernel.GamePool[enlight.Enlighted];

                            if (enlight.Enlighter == client.Entity.UID && enlight.Enlighted != enlight.Enlighter)
                            {
                                if (Client.Entity.ReceivedEnlightenPoints < 5)
                                {
                                    if (client.Entity.EnlightenPoints >= 100)
                                    {
                                        if (Client.Entity.EnlightmentTime <= 80)
                                        {
                                            client.Entity.EnlightenPoints -= 100;
                                            Client.Entity.EnlightmentStamp = Time32.Now;
                                            Client.IncreaseExperience(Game.Attacking.Calculate.Percent((int)Client.ExpBall, .10F), false);
                                            Client.SendScreen(packet, true);
                                            Client.Entity.ReceivedEnlightenPoints++;
                                            Client.Entity.EnlightmentTime += 20;
                                            if (client.Entity.EnlightmentTime > 80)
                                                client.Entity.EnlightmentTime = 100;
                                            else if (client.Entity.EnlightmentTime > 60)
                                                client.Entity.EnlightmentTime = 80;
                                            else if (client.Entity.EnlightmentTime > 40)
                                                client.Entity.EnlightmentTime = 60;
                                            else if (client.Entity.EnlightmentTime > 20)
                                                client.Entity.EnlightmentTime = 40;
                                            else if (client.Entity.EnlightmentTime > 0)
                                                client.Entity.EnlightmentTime = 20;
                                        }
                                        else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " yet because he has to wait a few minutes until he can be enlightened again.", System.Drawing.Color.Blue, Message.TopLeft));
                                    }
                                    else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " because you don't have enough enlighten points!", System.Drawing.Color.Blue, Message.TopLeft));
                                }
                                else client.Send(new Message("You can't enlighten " + Client.Entity.Name + " because he/she was enlightened today five times already!", System.Drawing.Color.Blue, Message.TopLeft));
                            }
                        }
                        break;
                    }
                #endregion
                #region NPC Dialog (2031 + 2032)
                case 2031:
                case 2032:
                    {
                        if (client.Action != 2)
                            return;
                        NpcRequest req = new NpcRequest();
                        req.Deserialize(packet);
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 202)//HoursPK War
                        {
                            if (client.Entity.Owner.Equipment.TryGetItem((byte)12).Plus > 7)
                            {
                                client.Entity.AddFlag(Update.Flags.Ride);
                                Random R = new Random();
                                int Nr = R.Next(1, 10);
                                if (Nr == 1) client.Entity.Teleport(2525, 114, 078);
                                if (Nr == 2) client.Entity.Teleport(2525, 96, 87);
                                if (Nr == 3) client.Entity.Teleport(2525, 142, 88);
                                if (Nr == 4) client.Entity.Teleport(2525, 115, 115);
                                if (Nr == 5) client.Entity.Teleport(2525, 98, 130);
                                if (Nr == 6) client.Entity.Teleport(2525, 96, 153);
                                if (Nr == 7) client.Entity.Teleport(2525, 112, 162);
                                if (Nr == 8) client.Entity.Teleport(2525, 130, 166);
                                if (Nr == 9) client.Entity.Teleport(2525, 139, 114);
                                if (Nr == 10) client.Entity.Teleport(2525, 156, 119);
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 167)//Donation War
                        {
                            if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.King)
                            {
                                client.Entity.Teleport(1166, 50, 50);//Kings Map
                            }
                            if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.Prince)
                            {
                                client.Entity.Teleport(1167, 50, 50);//Princes Map
                            }
                            if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.Duke)
                            {
                                client.Entity.Teleport(1168, 50, 50);//Duke Map
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 133)//5th Elements
                        {
                            client.Entity.Teleport(1233, 36, 34);
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 159)//DeathTeam
                        {
                            client.Entity.Teleport(1595, 125, 130);
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 115)//GuildWar
                        {
                            Random R = new Random();
                            int Nr = R.Next(1, 10);
                            if (Nr == 1)
                            {
                                client.Entity.Teleport(1038, 351, 341);
                            }
                            if (Nr == 2)
                            {
                                client.Entity.Teleport(1038, 335, 345);
                            }
                            if (Nr == 3)
                            {
                                client.Entity.Teleport(1038, 309, 369);
                            }
                            if (Nr == 4)
                            {
                                client.Entity.Teleport(1038, 283, 340);
                            }
                            if (Nr == 5)
                            {
                                client.Entity.Teleport(1038, 310, 327);
                            }
                            if (Nr == 6)
                            {
                                client.Entity.Teleport(1038, 318, 297);
                            }
                            if (Nr == 7)
                            {
                                client.Entity.Teleport(1038, 347, 309);
                            }
                            if (Nr == 8)
                            {
                                client.Entity.Teleport(1038, 337, 320);
                            }
                            if (Nr == 9)
                            {
                                client.Entity.Teleport(1038, 309, 293);
                            }
                            if (Nr == 10)
                            {
                                client.Entity.Teleport(1038, 371, 300);
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 202)//HoursPK War
                        {
                            if (client.Entity.Owner.Equipment.TryGetItem((byte)12).Plus > 7)
                            {
                                client.Entity.AddFlag(Update.Flags.Ride);
                                Random R = new Random();
                                int Nr = R.Next(1, 10);
                                if (Nr == 1) client.Entity.Teleport(2525, 114, 078);
                                if (Nr == 2) client.Entity.Teleport(2525, 96, 87);
                                if (Nr == 3) client.Entity.Teleport(2525, 142, 88);
                                if (Nr == 4) client.Entity.Teleport(2525, 115, 115);
                                if (Nr == 5) client.Entity.Teleport(2525, 98, 130);
                                if (Nr == 6) client.Entity.Teleport(2525, 96, 153);
                                if (Nr == 7) client.Entity.Teleport(2525, 112, 162);
                                if (Nr == 8) client.Entity.Teleport(2525, 130, 166);
                                if (Nr == 9) client.Entity.Teleport(2525, 139, 114);
                                if (Nr == 10) client.Entity.Teleport(2525, 156, 119);
                            }
                        }
                        if (req.InteractType == NpcReply.MessageBox)
                        {
                            if (req.OptionID == 255)
                            {
                                if (client.OnMessageBoxOK != null)
                                {
                                    client.OnMessageBoxOK.Invoke();
                                    client.OnMessageBoxOK = null;
                                }
                            }
                            else
                            {
                                if (client.OnMessageBoxCANCEL != null)
                                {
                                    client.OnMessageBoxCANCEL.Invoke();
                                    client.OnMessageBoxCANCEL = null;
                                }
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 249)
                            if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 230)
                            {

                                if (Program.nobilityrankwar == false)
                                {
                                    client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));
                                    break;

                                }
                                else
                                {
                                    if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.King && Program.nobilityrankwar == true)
                                    {
                                        #region

                                        ushort x = (ushort)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 6);

                                        if (x == 1)
                                        {
                                            client.Entity.Teleport(9991, 091, 014);
                                            break;
                                        }
                                        else if (x == 2)
                                        {
                                            client.Entity.Teleport(9991, 098, 038);
                                            break;
                                        }
                                        else if (x == 3)
                                        {
                                            client.Entity.Teleport(9991, 013, 088);
                                            break;
                                        }
                                        else if (x == 4)
                                        {
                                            client.Entity.Teleport(9991, 234, 150);
                                            break;
                                        }
                                        else if (x == 5)
                                        {
                                            client.Entity.Teleport(9991, 205, 200);
                                            break;
                                        }
                                        else if (x == 6)
                                        {
                                            client.Entity.Teleport(9991, 165, 235);
                                            break;
                                        }
                                        break;
                                        #endregion
                                    }
                                    else if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.Prince && Program.nobilityrankwar == true)
                                    {
                                        #region

                                        ushort x = (ushort)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 6);

                                        if (x == 1)
                                        {
                                            client.Entity.Teleport(9992, 091, 014);
                                            break;
                                        }
                                        else if (x == 2)
                                        {
                                            client.Entity.Teleport(9992, 098, 038);
                                            break;
                                        }
                                        else if (x == 3)
                                        {
                                            client.Entity.Teleport(9992, 013, 088);
                                            break;
                                        }
                                        else if (x == 4)
                                        {
                                            client.Entity.Teleport(9992, 234, 150);
                                            break;
                                        }
                                        else if (x == 5)
                                        {
                                            client.Entity.Teleport(9992, 205, 200);
                                            break;
                                        }
                                        else if (x == 6)
                                        {
                                            client.Entity.Teleport(9992, 165, 235);
                                            break;
                                        }
                                        break;
                                        #endregion
                                    }
                                    else if (client.Entity.NobilityRank == Game.ConquerStructures.NobilityRank.Duke && Program.nobilityrankwar == true)
                                    {
                                        #region

                                        ushort x = (ushort)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 6);

                                        if (x == 1)
                                        {
                                            client.Entity.Teleport(9993, 091, 014);
                                            break;
                                        }
                                        else if (x == 2)
                                        {
                                            client.Entity.Teleport(9993, 098, 038);
                                            break;
                                        }
                                        else if (x == 3)
                                        {
                                            client.Entity.Teleport(9993, 013, 088);
                                            break;
                                        }
                                        else if (x == 4)
                                        {
                                            client.Entity.Teleport(9993, 234, 150);
                                            break;
                                        }
                                        else if (x == 5)
                                        {
                                            client.Entity.Teleport(9993, 205, 200);
                                            break;
                                        }
                                        else if (x == 6)
                                        {
                                            client.Entity.Teleport(9993, 165, 235);
                                            break;
                                        }
                                        break;
                                        #endregion
                                    }
                                    else
                                    {
                                        client.Send(new Network.GamePackets.NpcReply(6, "Sorry The War Avilable For  (King-Princes-Duke) Only."));
                                    }
                                }
                            }
                        {
                            Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 248)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1507, 100, 100);
                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 247)
                        {

                            client.Entity.Teleport(1858, 70, 70);

                        }

                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 246)
                        {

                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }
                        }

                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 245)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }
                        }

                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 244)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 243)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 242)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);

                            }
                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 241)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 240)
                        {
                            if (ServerBase.Kernel.PK == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The Tournoment has finished time of join."));

                            }
                            else
                            {
                                client.InPKT = true;
                                PKTournament.PKTHash.Add(client.Entity.UID, client);
                                //Conquer_Online_Server.ServerBase.Kernel.Elite_PK_Tournament.AddMap(client);
                                client.Entity.Teleport(1787, 50, 50);
                            }

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 238)
                        {

                            client.Entity.Teleport(2555, 50, 50);

                        }
                        if (client.Map.BaseID != 6001 && !client.Entity.Dead && req.OptionID == 239)
                        {
                            if (Program.Steed == false)
                            {
                                client.Send(new Network.GamePackets.NpcReply(6, "The SteedRace has finished time of join."));

                            }
                            else
                            {
                                Conquer_Online_Server.Interfaces.IConquerItem I = client.Equipment.TryGetItem(12);
                                if (I != null && I.ID != 0)
                                {
                                    client.Entity.srjoin = 1;
                                    client.Entity.Teleport(1950, 077, 157);
                                    client.Entity.AddFlag(Update.Flags.Ride);
                                }
                                else
                                {
                                    client.Send(new Network.GamePackets.NpcReply(6, "You Dont have a Steed ."));
                                }
                            }

                        }
                        else
                        {
                            if (ID == 2031)
                                client.ActiveNpc = req.NpcID;
                            if (req.NpcID == 12)
                            {
                                if (client.Entity.VIPLevel > 0)
                                {
                                    Data data = new Data(true);
                                    data.ID = Data.OpenWindow;
                                    data.UID = client.Entity.UID;
                                    data.TimeStamp = Time32.Now;
                                    data.dwParam = Data.WindowCommands.VIPWarehouse;
                                    data.wParam1 = client.Entity.X;
                                    data.wParam2 = client.Entity.Y;
                                    client.WarehouseOpen = true;
                                    client.Send(data);
                                    break;
                                }
                            }
                            Interfaces.INpc npc = null;
                            if (req.InteractType == 102)
                            {
                                if (client.Guild != null)
                                {
                                    if (client.AsMember.Rank == Conquer_Online_Server.Game.Enums.GuildMemberRank.GuildLeader)
                                    {
                                        client.Guild.ExpelMember(req.Input, false);
                                    }
                                }
                                return;
                            }
                            if (client.Map.Npcs.TryGetValue(client.ActiveNpc, out npc))
                            {
                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, npc.X, npc.Y) > 17)
                                    return;
                                if (req.OptionID == 255 || (req.OptionID == 0 && ID == 2032))
                                    return;
                                req.NpcID = client.ActiveNpc;
                                //NpcDialogs.Dialogs.GetDialog(req, client);
                                Dialogs.GetDialog(req, client);
                            }
                        }
                        break;
                    }
                #endregion
                #region Compose (2036)
                case 2036:
                    {
                        Compose compose = new Compose(false);
                        compose.Deserialize(packet);
                        ComposePlus(compose, client);
                        break;
                    }
                #endregion
                #region Offline TG (2044)
                case 2044:
                    {
                        OfflineTGRequest otgr = new OfflineTGRequest(false);
                        otgr.Deserialize(packet);
                        switch (otgr.ID)
                        {
                            case OfflineTGRequest.OnTrainingTimeRequested:
                                {
                                    otgr.Minutes = 900;
                                    client.Send(otgr);
                                    break;
                                }
                            case OfflineTGRequest.OnConfirmation:
                                {
                                    client.Entity.PreviousMapID = client.Entity.MapID;
                                    client.Entity.PrevX = client.Entity.X;
                                    client.Entity.PrevY = client.Entity.Y;
                                    client.Entity.MapID = 601;
                                    client.Entity.X = 64;
                                    client.Entity.Y = 56;
                                    client.OfflineTGEnterTime = DateTime.Now;

                                    client.Disconnect();
                                    break;
                                }
                            case OfflineTGRequest.ClaimExperience:
                                {
                                    var T1 = new TimeSpan(DateTime.Now.Ticks);
                                    var T2 = new TimeSpan(client.OfflineTGEnterTime.Ticks);
                                    ushort minutes = (ushort)(T1.TotalMinutes - T2.TotalMinutes);
                                    minutes = (ushort)Math.Min((ushort)900, minutes);
                                    double expballGain = (double)300 * (double)minutes / (double)900;
                                    while (expballGain >= 100)
                                    {
                                        expballGain -= 100;
                                        client.IncreaseExperience(client.ExpBall, false);
                                    }
                                    if (expballGain != 0)
                                        client.IncreaseExperience((uint)(client.ExpBall * (expballGain / 100)), false);

                                    client.Entity.SetLocation(client.Entity.PreviousMapID, client.Entity.PrevX, client.Entity.PrevY);
                                    if (client.Map.ID == 1036 || client.Map.ID == 1039)
                                        client.Entity.Teleport(1002, 430, 378);
                                    else
                                    {
                                        switch (client.Map.ID)
                                        {
                                            default:
                                                {
                                                    client.Entity.Teleport(1002, 429, 378);
                                                    break;
                                                }
                                            case 1000:
                                                {
                                                    client.Entity.Teleport(1000, 500, 650);
                                                    break;
                                                }
                                            case 1020:
                                                {
                                                    client.Entity.Teleport(1020, 565, 562);
                                                    break;
                                                }
                                            case 1011:
                                                {
                                                    client.Entity.Teleport(1011, 188, 264);
                                                    break;
                                                }
                                            case 6001:
                                                {
                                                    client.Entity.Teleport(6001, 030, 075);
                                                    break;
                                                }

                                            case 1015:
                                                {
                                                    client.Entity.Teleport(1015, 717, 571);
                                                    break;
                                                }
                                        }
                                    }
                                    client.OfflineTGEnterTime = DateTime.Now;
                                    break;
                                }
                            default:
                                client.Send(otgr);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Trade partner (2046)
                case 2046:
                    {
                        TradePartner partner = new TradePartner(false);
                        partner.Deserialize(packet);
                        switch (partner.Type)
                        {
                            case TradePartner.RequestPartnership:
                                RequestTradePartnership(partner, client);
                                break;
                            case TradePartner.RejectRequest:
                                RejectPartnership(partner, client);
                                break;
                            case TradePartner.BreakPartnership:
                                BreakPartnership(partner, client);
                                break;
                        }
                        break;
                    }
                #endregion
                #region ItemLock (2048)
                case 2048:
                    {
                        if (client.Action != 2)
                            return;
                        ItemLock itemlock = new ItemLock(false);
                        itemlock.Deserialize(packet);
                        switch (itemlock.ID)
                        {
                            case ItemLock.RequestLock:
                                LockItem(itemlock, client);
                                break;
                            case ItemLock.RequestUnlock:
                                UnlockItem(itemlock, client);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Broadcast (2050)
                case 2050:
                    {
                        Broadcast cast = new Broadcast(false);
                        cast.Deserialize(packet);
                        switch (cast.Type)
                        {
                            case Broadcast.ReleaseSoonMessages:
                                {
                                    BroadcastInfoAwaiting(cast, client);
                                    break;
                                }
                            case Broadcast.MyMessages:
                                {
                                    BroadcastClientMessages(cast, client);
                                    break;
                                }
                            case Broadcast.BroadcastMessage:
                                {
                                    if (Game.ConquerStructures.Broadcast.Broadcasts.Count == ServerBase.Constants.MaxBroadcasts)
                                    {
                                        client.Send(new Message("You cannot send any broadcasts for now. The limit has been reached. Wait until a broadcast is chopped down.", System.Drawing.Color.Red, Message.TopLeft));
                                        break;
                                    }
                                    if (client.Entity.ConquerPoints >= 5)
                                    {
                                        client.Entity.ConquerPoints = (uint)Math.Max(0, (int)((int)client.Entity.ConquerPoints - (int)5));
                                        Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new Conquer_Online_Server.Game.ConquerStructures.Broadcast.BroadcastStr();
                                        broadcast.EntityID = client.Entity.UID;
                                        broadcast.EntityName = client.Entity.Name;
                                        broadcast.ID = Game.ConquerStructures.Broadcast.BroadcastCounter.Next;
                                        if (cast.List[0].Length > 80)
                                            cast.List[0] = cast.List[0].Remove(80);
                                        broadcast.Message = cast.List[0];
                                        if (Game.ConquerStructures.Broadcast.Broadcasts.Count == 0)
                                        {
                                            if (Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID == 1)
                                            {
                                                Game.ConquerStructures.Broadcast.CurrentBroadcast = broadcast;
                                                Game.ConquerStructures.Broadcast.LastBroadcast = DateTime.Now;
                                                ServerBase.Kernel.SendWorldMessage(new Message(cast.List[0], "ALLUSERS", client.Entity.Name, System.Drawing.Color.Red, Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
                                                client.Send(cast);
                                                break;
                                            }
                                        }
                                        Game.ConquerStructures.Broadcast.Broadcasts.Add(broadcast);
                                        cast.dwParam = (uint)Game.ConquerStructures.Broadcast.Broadcasts.Count;
                                        client.Send(cast);
                                        break;
                                    }
                                    break;
                                }
                            case Broadcast.Urgen5CPs:
                                {
                                    for (int c = 0; c < Game.ConquerStructures.Broadcast.Broadcasts.Count; c++)
                                    {
                                        var broadcast = Game.ConquerStructures.Broadcast.Broadcasts[c];
                                        if (broadcast.ID == cast.dwParam)
                                        {
                                            if (c != 0)
                                            {
                                                if (client.Entity.ConquerPoints >= 5)
                                                {
                                                    broadcast.SpentCPs += 5;
                                                    client.Entity.ConquerPoints = (uint)Math.Max(0, (int)((int)client.Entity.ConquerPoints - (int)5));
                                                    if (Game.ConquerStructures.Broadcast.Broadcasts[c - 1].SpentCPs <= broadcast.SpentCPs)
                                                    {
                                                        Game.ConquerStructures.Broadcast.Broadcasts[c] = Game.ConquerStructures.Broadcast.Broadcasts[c - 1];
                                                        Game.ConquerStructures.Broadcast.Broadcasts[c - 1] = broadcast;
                                                    }
                                                    else
                                                    {
                                                        Game.ConquerStructures.Broadcast.Broadcasts[c] = broadcast;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            case Broadcast.Urgen15CPs:
                                {
                                    for (int c = 0; c < Game.ConquerStructures.Broadcast.Broadcasts.Count; c++)
                                    {
                                        var broadcast = Game.ConquerStructures.Broadcast.Broadcasts[c];
                                        if (broadcast.ID == cast.dwParam)
                                        {
                                            if (c != 0)
                                            {
                                                if (client.Entity.ConquerPoints >= 15)
                                                {
                                                    broadcast.SpentCPs += 15;
                                                    client.Entity.ConquerPoints = (uint)Math.Max(0, (int)((int)client.Entity.ConquerPoints - (int)15));
                                                    for (int b = c - 1; b > 0; b--)
                                                        Game.ConquerStructures.Broadcast.Broadcasts[b] = Game.ConquerStructures.Broadcast.Broadcasts[b - 1];

                                                    Game.ConquerStructures.Broadcast.Broadcasts[0] = broadcast;
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Nobility (2064)
                case 2064:
                    {
                        NobilityInfo nobility = new NobilityInfo(false);
                        nobility.Deserialize(packet);
                        Game.ConquerStructures.Nobility.Handle(nobility, client);
                        break;
                    }
                #endregion
                #region Mentor prize (2067)
                #region MentorPremio
                case 1036:
                    {
                        switch (packet[4])
                        {
                            #region Send
                            case 0:
                                // Writer.WriteUInt32(client.Entity.Contribution_Experience.Training_Exp, 8, packet);
                                //Writer.WriteUInt32(client.Entity.Contribution_Experience.Blessing_Exp, 12, packet);
                                client.Send(packet);
                                break;
                            #endregion
                            #region Claim Training Exp
                            case 1:
                                {
                                    if (client.Entity.Contribution_Experience.Blessing_Exp > 0)
                                    {
                                        ulong Increase = (ulong)(client.ExpBall * (client.Entity.Contribution_Experience.Training_Exp / 6000000));
                                        client.Entity.Contribution_Experience.Training_Exp = 0;
                                        client.IncreaseExperience(Increase, true);
                                        client.Send(packet);
                                    }
                                    break;
                                }
                            #endregion
                            #region Claim Blessing Exp
                            case 2:
                                {
                                    if (client.Entity.Contribution_Experience.Blessing_Exp > 0)
                                    {
                                        ulong Increase = (ulong)(client.ExpBall * (client.Entity.Contribution_Experience.Blessing_Exp / 6000000));
                                        client.Entity.Contribution_Experience.Blessing_Exp = 0;
                                        client.IncreaseExperience(Increase, true);
                                        client.Send(packet);
                                    }
                                    break;
                                }
                            #endregion
                            default: Console.WriteLine("Unknown 1036 claim type " + packet[4]); break;
                        }
                        break;
                    }
                #endregion
                case 2067:
                    {
                        MentorPrize prize = new MentorPrize(false);
                        prize.Deserialize(packet);
                        switch (prize.Prize_Type)
                        {
                            case MentorPrize.ClaimExperience:
                                {
                                    // client.IncreaseExperience((ulong)(((double)client.PrizeExperience / 606) * client.ExpBall), false);
                                    client.PrizeExperience = 0;
                                    foreach (var appr in client.Apprentices.Values)
                                    {
                                        appr.Actual_Experience = 0;
                                        Database.KnownPersons.SaveApprenticeInfo(appr);
                                    }
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                            case MentorPrize.ClaimHeavenBlessing:
                                {
                                    client.AddBless(client.PrizeHeavenBlessing);
                                    client.PrizeHeavenBlessing = 0;
                                    foreach (var appr in client.Apprentices.Values)
                                    {
                                        appr.Actual_HeavenBlessing = 0;
                                        Database.KnownPersons.SaveApprenticeInfo(appr);
                                    }
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                            case MentorPrize.ClaimPlus:
                                {
                                    int stones = client.PrizePlusStone / 100;
                                    int totake = stones;
                                    if (stones > 0)
                                    {
                                        for (; stones > 0; stones--)
                                        {
                                            client.PrizePlusStone -= 100;
                                            if (!client.Inventory.Add(730001, 1, 1))
                                                break;
                                        }
                                    }
                                    foreach (var appr in client.Apprentices.Values)
                                    {
                                        if (appr.Actual_Plus >= totake)
                                        {
                                            appr.Actual_Plus -= (ushort)totake;
                                            totake = 0;
                                        }
                                        else
                                        {
                                            totake -= appr.Actual_Plus;
                                            appr.Actual_Plus = 0;
                                        }
                                        Database.KnownPersons.SaveApprenticeInfo(appr);
                                    }
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                            case MentorPrize.Show:
                                {
                                    prize.Mentor_ID = client.Entity.UID;
                                    prize.Prize_Type = MentorPrize.Show;
                                    prize.Prize_Experience = client.PrizeExperience;
                                    prize.Prize_HeavensBlessing = client.PrizeHeavenBlessing;
                                    prize.Prize_PlusStone = client.PrizePlusStone;
                                    client.Send(prize);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region MentorApprentice (2065)
                case 2065:
                    {
                        MentorApprentice ma = new MentorApprentice(false);
                        ma.Deserialize(packet);
                        switch (ma.Type)
                        {
                            case MentorApprentice.LeaveMentor:
                                {
                                    LeaveMentor(ma, client);
                                    break;
                                }
                            case MentorApprentice.ExpellApprentice:
                                {
                                    ExpelApprentice(ma, client);
                                    break;
                                }
                            case MentorApprentice.RequestApprentice:
                                {
                                    AddApprentice(ma, client);
                                    break;
                                }
                            case MentorApprentice.RequestMentor:
                                {
                                    AddMentor(ma, client);
                                    break;
                                }
                            case MentorApprentice.AcceptRequestApprentice:
                                {
                                    AcceptRequestApprentice(ma, client);
                                    break;
                                }
                            case MentorApprentice.AcceptRequestMentor:
                                {
                                    AcceptRequestMentor(ma, client);
                                    break;
                                }
                        }
                        break;
                    }
                case 2066:
                    {
                        MentorInformation info = new MentorInformation(false);
                        info.Deserialize(packet);
                        if (info.Mentor_Type == 1)
                        {
                            client.ReviewMentor();
                        }
                        break;
                    }
                #endregion
                #region PurifyItem (2076)
                case 2076:
                    {
                        Purification ps = new Purification(false);
                        ps.Deserialize(packet);
                        switch (ps.Mode)
                        {
                            case Purification.Purify:
                                PurifyItem(ps, client); break;
                            case Purification.Purify1:
                                new Game.Features.Refinery.Handle(packet, client);
                                break;
                        }
                        break;
                    }
                #endregion

                #region Arsenal Guild
                case 2202:
                    {

                        ArsenalInscribitionList list = new ArsenalInscribitionList();
                        client.Send(list.Build(packet, client.Guild));
                        break;
                    }
                case 2203:
                    {
                        client.Guild.Arsenal.Update(client.Guild);
                        client.Send(client.Guild.A_Packet);
                        Database.ArsenalsTable.Load(client.Guild);
                        #region Handle
                        byte pType = packet[4];
                        byte i_type = packet[8];
                        uint i_Uid = BitConverter.ToUInt32(packet, 12);
                        switch (pType)
                        {
                            case 0://Unlock
                                {
                                    uint value = 5000000;
                                    if (client.Guild.SilverFund >= value)
                                    {

                                        if (i_type == 2 || i_type == 3)
                                        { value = 10000000; }
                                        if (i_type >= 3 && i_type <= 5)
                                        { value = 15000000; }
                                        if (i_type == 6 || i_type == 7)
                                        { value = 20000000; }
                                        if (client.Guild.SilverFund >= value)
                                        {
                                            client.Guild.SilverFund -= value;
                                            Database.ArsenalsTable.CreateArsenal((ushort)client.Guild.ID, (Game.ConquerStructures.Society.ArsenalType)i_type);
                                        }
                                        else
                                            client.Send(new Network.GamePackets.Message("sorry, you need " + value + " guild Found", System.Drawing.Color.Red, Message.TopLeft).ToArray());
                                    }
                                    else
                                        client.Send(new Network.GamePackets.Message("sorry, you need " + value + " guild Found", System.Drawing.Color.Red, Message.TopLeft).ToArray());
                                    break;
                                }
                            case 1://Inscribe
                                {
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(i_Uid, out Item))
                                    {
                                        client.Guild.Arsenal.Inscribe((Game.ConquerStructures.Society.ArsenalType)i_type, Item, client);
                                        client.Guild.Arsenal.Update((Game.ConquerStructures.Society.ArsenalType)i_type, client.Guild);
                                    }
                                    break;
                                }
                            case 2://Uninscribe
                                {
                                    Game.ConquerStructures.Society.ArsenalSingle AS = null;
                                    if (client.Guild.Arsenal.Inscribed[(Game.ConquerStructures.Society.ArsenalType)i_type].TryGetValue(i_Uid, out AS))
                                    {
                                        client.Guild.Arsenal.Uninscribe((Game.ConquerStructures.Society.ArsenalType)i_type, AS, client);
                                        client.Guild.Arsenal.Update((Game.ConquerStructures.Society.ArsenalType)i_type, client.Guild);
                                    }
                                    break;
                                }
                            case 3://Enhance
                                {
                                    //client.Entity.Mentors.Share();
                                    client.Guild.A_Packet.SetTotals2();
                                    client.Send(client.Guild.A_Packet);
                                    break;
                                }
                            case 4://Show Main Info
                                {
                                    client.Guild.A_Packet.SetTotals();
                                    client.Send(client.Guild.A_Packet);
                                    break;
                                }
                        }
                        client.Send(packet);
                        #endregion
                        break;
                    }
                #endregion
                #region Arena (2207<->2211)
                case 2207://Request Arena ranking List
                    {
                        //Code snippet that belongs to Ultimation
                        ushort PageIndex = BitConverter.ToUInt16(packet, 6);
                        Game.ConquerStructures.Arena.Statistics.ShowRankingPage(packet[4], PageIndex, client);
                        break;
                    }
                case 2206:
                    {
                        //Code snippet that belongs to Ultimation
                        ushort PageIndex = BitConverter.ToUInt16(packet, 4);
                        Game.ConquerStructures.Arena.QualifyEngine.RequestGroupList(client, PageIndex);
                        break;
                    }
                case 2205://Arena Signup!
                    {
                        //Code snippet that belongs to Ultimation
                        uint DialogID = BitConverter.ToUInt32(packet, 4);
                        uint ButtonID = BitConverter.ToUInt32(packet, 8);
                        switch (DialogID)
                        {
                            case 4:
                                {
                                    switch (ButtonID)
                                    {
                                        case 0:
                                            {
                                                Game.ConquerStructures.Arena.QualifyEngine.DoQuit(client);
                                                break;
                                            }
                                    }
                                    break;
                                }
                            case 0: Game.ConquerStructures.Arena.QualifyEngine.DoSignup(client); client.Send(packet); break;
                            case 1: Game.ConquerStructures.Arena.QualifyEngine.DoQuit(client); client.Send(packet); break;
                            case 3:
                                {
                                    switch (ButtonID)
                                    {
                                        case 2: Game.ConquerStructures.Arena.QualifyEngine.DoGiveUp(client); break;
                                        case 1: Game.ConquerStructures.Arena.QualifyEngine.DoAccept(client); break;
                                    }
                                    break;
                                }
                            case 5:
                                {
                                    if (client.ArenaStatistic.ArenaPoints <= 1500)
                                        if (client.Entity.Money >= 9000000)
                                        {
                                            client.Entity.Money -= 9000000;
                                            client.ArenaStatistic.ArenaPoints += 1500;
                                            client.Send(client.ArenaStatistic);
                                        }
                                    break;
                                }
                            case 11://Win/Lose Dialog
                                {
                                    switch (ButtonID)
                                    {
                                        case 0: Game.ConquerStructures.Arena.QualifyEngine.DoSignup(client); break;
                                    }
                                    break;
                                }

                        }
                        break;
                    }
                case 2208://Request Arena Winner List
                    {
                        //Code snippet that belongs to Ultimation
                        Game.ConquerStructures.Arena.Statistics.ShowWiners(client);
                        break;
                    }
                case 2209:
                    {
                        client.ArenaStatistic.Send(client);
                        break;
                    }
                case 2211:
                    {
                        ushort Type = BitConverter.ToUInt16(packet, 4);
                        uint Fighter = BitConverter.ToUInt32(packet, 10);
                        if (Type == 0)
                        {
                            if (ServerBase.Kernel.GamePool.ContainsKey(Fighter))
                            {
                                Client.GameState Client = ServerBase.Kernel.GamePool[Fighter];
                                if (Client.QualifierGroup != null)
                                {
                                    if (Client.QualifierGroup.Inside)
                                    {
                                        if (!Client.QualifierGroup.Done)
                                        {
                                            Client.QualifierGroup.BeginWatching(client);
                                        }
                                    }
                                }
                            }
                        }
                        else if (Type == 1)
                        {
                            Game.ConquerStructures.Arena.QualifyEngine.DoLeave(client);
                        }
                        else if (Type == 4)
                        {
                            string name = "";
                            for (int c = 22; c < packet.Length; c++)
                            {
                                if (packet[c] != 0)
                                    name += (char)packet[c];
                                else
                                    break;
                            }
                            Game.ConquerStructures.Arena.QualifyEngine.DoCheer(client, name);
                        }
                        break;
                    }
                #endregion
                #region Movement/Walk (10005)
                case 10005:
                    {
                        if (client.Action != 2)
                            return;
                        GroundMovement groundMovement = new GroundMovement(false);
                        groundMovement.Deserialize(packet);
                        PlayerGroundMovment(groundMovement, client);
                        break;
                    }
                #endregion
                #region Data (10010)
                case 10010:
                    {
                        if (client.Action != 2)
                            return;
                        Data gData = new Data(false);
                        gData.Deserialize(packet);
                        switch (gData.ID)
                        {
                            case Data.SwingPickaxe:
                                client.Mining = true;
                                break;
                            case Data.Revive:

                                Revive(gData, client);
                                // Revive(gData, client);
                                break;
                            case Data.UsePortal:
                                if (client.Entity.MapID == 601)
                                {
                                    client.Entity.Teleport(601, 063, 055);
                                }
                                else
                                    UsePortal(gData, client);
                                break;

                            case Data.ChangePKMode:
                                ChangePKMode(gData, client);
                                break;
                            case Data.ChangeAction:
                                ChangeAction(gData, client);
                                break;
                            case Data.ChangeDirection:
                                ChangeDirection(gData, client);
                                break;
                            case Data.Hotkeys:
                                client.Send(packet);
                                break;
                            case 408://steed soul remoeve
                                {

                                    break;
                                }
                            case Data.ConfirmSpells:
                                if (client.Spells != null)
                                    foreach (Interfaces.ISkill spell in client.Spells.Values)
                                        if (spell.ID != 3060)
                                            spell.Send(client);
                                client.Send(packet);
                                break;
                            case Data.ConfirmProficiencies:
                                if (client.Proficiencies != null)
                                    foreach (Interfaces.ISkill proficiency in client.Proficiencies.Values)
                                        proficiency.Send(client);
                                client.Send(packet);
                                break;
                            case Data.ConfirmGuild:
                                client.Send(packet);
                                break;
                            case Data.ConfirmFriends:
                                #region Friends/Enemy/TradePartners/Apprentices
                                Message msg2 = new Message("Your friend, " + client.Entity.Name + ", has logged on.", System.Drawing.Color.Red, Message.TopLeft);

                                foreach (Game.ConquerStructures.Society.Friend friend in client.Friends.Values)
                                {
                                    if (friend.IsOnline)
                                    {
                                        var pckt = new KnownPersons(true)
                                        {
                                            UID = client.Entity.UID,
                                            Type = KnownPersons.RemovePerson,
                                            Name = client.Entity.Name,
                                            Online = true
                                        };
                                        friend.Client.Send(pckt);
                                        pckt.Type = KnownPersons.AddFriend;
                                        friend.Client.Send(pckt);
                                        friend.Client.Send(msg2);
                                    }
                                    client.Send(new KnownPersons(true)
                                    {
                                        UID = friend.ID,
                                        Type = KnownPersons.AddFriend,
                                        Name = friend.Name,
                                        Online = friend.IsOnline
                                    });
                                    if (friend.Message != "")
                                    {
                                        client.Send(new Message(friend.Message, client.Entity.Name, friend.Name, System.Drawing.Color.Red, Message.Whisper));
                                        Database.KnownPersons.UpdateMessageOnFriend(friend.ID, client.Entity.UID, "");
                                    }
                                }

                                foreach (Game.ConquerStructures.Society.Enemy enemy in client.Enemy.Values)
                                {
                                    client.Send(new KnownPersons(true)
                                    {
                                        UID = enemy.ID,
                                        Type = KnownPersons.AddEnemy,
                                        Name = enemy.Name,
                                        Online = enemy.IsOnline
                                    });
                                }
                                Message msg3 = new Message("Your partner, " + client.Entity.Name + ", has logged in.", System.Drawing.Color.Red, Message.TopLeft);

                                foreach (Game.ConquerStructures.Society.TradePartner partner in client.Partners.Values)
                                {
                                    if (partner.IsOnline)
                                    {
                                        var packet3 = new TradePartner(true)
                                        {
                                            UID = client.Entity.UID,
                                            Type = TradePartner.BreakPartnership,
                                            Name = client.Entity.Name,
                                            HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
                                            Online = true
                                        };
                                        partner.Client.Send(packet3);
                                        packet3.Type = TradePartner.AddPartner;
                                        partner.Client.Send(packet3);
                                        partner.Client.Send(msg3);
                                    }
                                    var packet4 = new TradePartner(true)
                                    {
                                        UID = partner.ID,
                                        Type = TradePartner.AddPartner,
                                        Name = partner.Name,
                                        HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
                                        Online = partner.IsOnline
                                    };
                                    client.Send(packet4);
                                }

                                foreach (Game.ConquerStructures.Society.Apprentice appr in client.Apprentices.Values)
                                {
                                    if (appr.IsOnline)
                                    {
                                        ApprenticeInformation AppInfo = new ApprenticeInformation();
                                        AppInfo.Apprentice_ID = appr.ID;
                                        AppInfo.Apprentice_Level = appr.Client.Entity.Level;
                                        AppInfo.Apprentice_Class = appr.Client.Entity.Class;
                                        AppInfo.Apprentice_PkPoints = appr.Client.Entity.PKPoints;
                                        AppInfo.Apprentice_Experience = appr.Actual_Experience;
                                        AppInfo.Apprentice_Composing = appr.Actual_Plus;
                                        AppInfo.Apprentice_Blessing = appr.Actual_HeavenBlessing;
                                        AppInfo.Apprentice_Name = appr.Name;
                                        AppInfo.Apprentice_Online = true;
                                        AppInfo.Apprentice_Spouse_Name = appr.Client.Entity.Spouse;
                                        AppInfo.Enrole_date = appr.EnroleDate;
                                        AppInfo.Mentor_ID = client.Entity.UID;
                                        AppInfo.Mentor_Mesh = client.Entity.Mesh;
                                        AppInfo.Mentor_Name = client.Entity.Name;
                                        AppInfo.Type = 2;
                                        client.Send(AppInfo);

                                        MentorInformation Information = new MentorInformation(true);
                                        Information.Mentor_Type = 1;
                                        Information.Mentor_ID = client.Entity.UID;
                                        Information.Apprentice_ID = appr.ID;
                                        Information.Enrole_Date = appr.EnroleDate;
                                        Information.Mentor_Level = client.Entity.Level;
                                        Information.Mentor_Class = client.Entity.Class;
                                        Information.Mentor_PkPoints = client.Entity.PKPoints;
                                        Information.Mentor_Mesh = client.Entity.Mesh;
                                        Information.Mentor_Online = true;
                                        Information.Shared_Battle_Power = (uint)(((client.Entity.BattlePower - client.Entity.ExtraBattlePower) - (appr.Client.Entity.BattlePower - appr.Client.Entity.ExtraBattlePower)) / 3.3F);
                                        Information.String_Count = 3;
                                        Information.Mentor_Name = client.Entity.Name;
                                        Information.Apprentice_Name = appr.Name;
                                        Information.Mentor_Spouse_Name = client.Entity.Spouse;
                                        appr.Client.ReviewMentor();
                                        appr.Client.Send(Information);
                                    }
                                    else
                                    {
                                        ApprenticeInformation AppInfo = new ApprenticeInformation();
                                        AppInfo.Apprentice_ID = appr.ID;
                                        AppInfo.Apprentice_Name = appr.Name;
                                        AppInfo.Apprentice_Online = false;
                                        AppInfo.Enrole_date = appr.EnroleDate;
                                        AppInfo.Mentor_ID = client.Entity.UID;
                                        AppInfo.Mentor_Mesh = client.Entity.Mesh;
                                        AppInfo.Mentor_Name = client.Entity.Name;
                                        AppInfo.Type = 2;
                                        client.Send(AppInfo);
                                    }
                                }
                                #endregion
                                client.Send(packet);
                                break;
                            case Data.EndTeleport:
                                break;
                            case Data.GetSurroundings:
                                if (client.Booth != null)
                                {
                                    client.Entity.TransformationID = 0;
                                    client.Booth.Remove();
                                    client.Booth = null;
                                }
                                GetSurroundings(client);
                                client.Send(new MapStatus() { BaseID = client.Map.BaseID, ID = client.Map.ID, Status = Database.MapsTable.MapInformations[client.Map.ID].Status });
                                Game.Weather.CurrentWeatherBase.Send(client);
                                client.Send(gData);
                                break;
                            case Data.SetLocation:
                                SetLocation(gData, client);
                                break;
                            case Data.Jump:
                                PlayerJump(gData, client);
                                break;
                            case Data.UnknownEntity:
                                {
                                    #region UnknownEntity
                                    Client.GameState pClient = null;
                                    if (ServerBase.Kernel.GamePool.TryGetValue(gData.dwParam, out pClient))
                                    {
                                        if (ServerBase.Kernel.GetDistance(pClient.Entity.X, pClient.Entity.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance && client.Map.ID == pClient.Map.ID)
                                        {
                                            if (pClient.Guild != null)
                                                pClient.Guild.SendName(client);
                                            if (client.Guild != null)
                                                client.Guild.SendName(pClient);
                                            if (pClient.Entity.UID != client.Entity.UID)
                                            {
                                                if (pClient.Map.ID == client.Map.ID)
                                                {
                                                    if (pClient.Map.BaseID == 700)
                                                    {
                                                        if (client.QualifierGroup != null)
                                                        {
                                                            if (pClient.QualifierGroup != null)
                                                            {
                                                                client.Entity.SendSpawn(pClient, false);
                                                                pClient.Entity.SendSpawn(client, false);
                                                            }
                                                            else
                                                            {
                                                                client.Entity.SendSpawn(pClient, false);
                                                                client.Screen.Add(pClient.Entity);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (pClient.QualifierGroup != null)
                                                            {
                                                                pClient.Entity.SendSpawn(client, false);
                                                                pClient.Screen.Add(client.Entity);
                                                            }
                                                            else
                                                            {
                                                                client.Entity.SendSpawn(pClient, false);
                                                                pClient.Entity.SendSpawn(client, false);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        client.Entity.SendSpawn(pClient, false);
                                                        pClient.Entity.SendSpawn(client, false);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Game.Entity monster = null;
                                        if (client.Map.Entities.TryGetValue(gData.dwParam, out monster))
                                        {
                                            if (ServerBase.Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                            {
                                                monster.SendSpawn(client, false);
                                            }
                                        }
                                        if (client.Map.Companions.TryGetValue(gData.dwParam, out monster))
                                        {
                                            if (ServerBase.Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                            {
                                                monster.SendSpawn(client, false);
                                            }
                                        }
                                    }
                                    #endregion
                                    break;
                                }
                            case Data.CompleteLogin:
                                LoginMessages(client);

                                EntityEquipment equips = new EntityEquipment(true);
                                equips.ParseHero(client);
                                client.Send(equips);
                                break;
                            case Data.ChangeFace:
                                ChangeFace(gData, client);
                                break;
                            case Data.ObserveEquipment:
                            case Data.ObserveEquipment2:
                            case Data.ObserveKnownPerson:
                                ObserveEquipment(gData, client);
                                break;
                            case Data.ViewEnemyInfo:
                                {
                                    if (client.Enemy.ContainsKey(gData.dwParam))
                                    {
                                        if (client.Enemy[gData.dwParam].IsOnline)
                                        {
                                            KnownPersonInfo info = new KnownPersonInfo(true);
                                            info.Fill(client.Enemy[gData.dwParam], true, false);
                                            if (client.Enemy[gData.dwParam].Client.Guild != null)
                                                client.Enemy[gData.dwParam].Client.Guild.SendName(client);
                                            client.Send(info);
                                        }
                                    }
                                    break;
                                }
                            case Data.ViewFriendInfo:
                                {
                                    if (client.Friends.ContainsKey(gData.dwParam))
                                    {
                                        if (client.Friends[gData.dwParam].IsOnline)
                                        {
                                            KnownPersonInfo info = new KnownPersonInfo(true);
                                            info.Fill(client.Friends[gData.dwParam], false, false);
                                            if (client.Friends[gData.dwParam].Client.Guild != null)
                                                client.Friends[gData.dwParam].Client.Guild.SendName(client);
                                            client.Send(info);
                                        }
                                    }
                                    break;
                                }
                            case Data.ViewPartnerInfo:
                                {
                                    if (client.Partners.ContainsKey(gData.dwParam))
                                    {
                                        if (client.Partners[gData.dwParam].IsOnline)
                                        {
                                            TradePartnerInfo info = new TradePartnerInfo(true);
                                            info.Fill(client.Partners[gData.dwParam]);
                                            if (client.Partners[gData.dwParam].Client.Guild != null)
                                                client.Partners[gData.dwParam].Client.Guild.SendName(client);
                                            client.Send(info);
                                        }
                                    }
                                    break;
                                }
                            case Data.EndFly:
                                client.Entity.RemoveFlag(Update.Flags.Fly);
                                break;
                            case Data.EndTransformation:
                                client.Entity.Untransform();
                                break;
                            case Data.XPListEnd:
                            case Data.Die:
                                break;
                            case Data.OwnBooth:
                                {

                                    //client.Entity.TransformationTime = 3600;
                                    if (client.WarehouseOpen == true)
                                    {
                                        client.Send(new Message("you cant booth when you open warehose", Color.AntiqueWhite, 2005));

                                        return;
                                    }
                                    else
                                    {
                                        client.Booth = new Conquer_Online_Server.Game.ConquerStructures.Booth(client, gData);
                                        client.Send(new Data(true) { ID = Data.ChangeAction, UID = client.Entity.UID, dwParam = 0 });

                                    }
                                    break;
                                }
                            case Data.Away:
                                {
                                    if (client.Entity.Away == 0)
                                        client.Entity.Away = 1;
                                    else
                                        client.Entity.Away = 0;
                                    client.SendScreenSpawn(client.Entity, false);
                                    break;
                                }
                            case Data.DeleteCharacter:
                                {
                                    if ((client.WarehousePW == null || client.WarehousePW == "" || client.WarehousePW == "0" && gData.dwParam == 0) || (client.WarehousePW == gData.dwParam.ToString()))
                                    {
                                        client.Account.EntityID = 0;
                                        client.Account.Save();
                                        client.Disconnect();
                                    }
                                    break;
                                }
                            case Data.TeamSearchForMember:
                                {
                                    if (client.Team != null)
                                    {
                                        Client.GameState Client = null;
                                        if (!client.Team.IsTeammate(gData.UID))
                                            return;
                                        if (Kernel.GamePool.TryGetValue(gData.UID, out Client))
                                        {
                                            gData.wParam1 = Client.Entity.X;
                                            gData.wParam2 = Client.Entity.Y;
                                            gData.Send(client);
                                        }
                                    }
                                    break;
                                }
                            default:
                                if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager)
                                    client.Send(new Message("Unknown generaldata id: " + gData.ID, System.Drawing.Color.CadetBlue, Message.Talk));
                                break;
                        }
                        break;
                    }
                #endregion
                #region Status 1040
                case 1040:
                    {
                        Conquer_Online_Server.Network.GameBufferets.Status ShowStatistics2 = new Conquer_Online_Server.Network.GameBufferets.Status(client);
                        ShowStatistics2.Deserialize(packet);
                        ShowStatistics2.Send(client);
                        //uint UID = BitConverter.ToUInt32(packet, 4);
                        //Client.GameState Client;
                        //if (ServerBase.Kernel.GamePool.TryGetValue(UID, out Client))
                        //{
                        //    client.Send(WindowStats(Client));
                        //}
                        break;
                    }
                #endregion
                #region Flowers
                case 1150:
                    {
                        SendFlowers(client, packet);

                        break;
                    }
                case 1151:
                    {
                        AddFlowers(client, packet);

                        break;
                    }

                #endregion
                #region Clans
                case 1312:
                    {
                        switch (packet[4])
                        {
                            case 21://transfer
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        PrintPacket(packet);
                                        uint lider = 0;
                                        string name_receive = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);

                                        var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
                                        varr.MoveNext();
                                        int COunt = ServerBase.Kernel.GamePool.Count;
                                        for (uint x = 0;
                                            x < COunt;
                                            x++)
                                        {
                                            if (x >= COunt) break;

                                            Client.GameState clien = (varr.Current as Client.GameState);

                                            if (clien.Entity.Name == name_receive)
                                                lider = clien.Entity.UID;

                                            varr.MoveNext();

                                        }

                                        if (lider == client.Entity.UID) return;
                                        Client.GameState aClient = null;
                                        if (Conquer_Online_Server.ServerBase.Kernel.GamePool.TryGetValue(lider, out aClient))
                                        {

                                            if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                            {
                                                if (Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(aClient.Entity.UID))
                                                {
                                                    Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanLider = aClient.Entity.Name;
                                                    aClient.Entity.ClanRank = 100;
                                                    aClient.Entity.Myclan.Members[aClient.Entity.UID].Rank = 100;
                                                    if (aClient.Entity.Myclan.Members.ContainsKey(client.Entity.UID))
                                                        aClient.Entity.Myclan.Members[client.Entity.UID].Rank = 0;
                                                    client.Entity.ClanRank = 0;
                                                    Database.Clans.SaveClan(aClient.Entity.Myclan);
                                                    Database.Clans.JoinClan(client);
                                                }
                                            }

                                        }
                                        else
                                        {
                                            Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanLider = name_receive;
                                            client.Entity.ClanRank = 0;
                                            Database.Clans.JoinClan(client);
                                            Database.Clans.SaveClan(client.Entity.Myclan);
                                            Database.Clans.TransferClan(name_receive);
                                        }
                                    }
                                    break;
                                }
                            /* case 14://add enemy
                                 {
                                     break;
                                 }*/
                            case 9://recruit member
                                {
                                    break;
                                }
                            case 23://client exit
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                        {
                                            if (Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(client.Entity.UID))
                                            {
                                                Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.Remove(client.Entity.UID);
                                            }
                                        }
                                        client.Entity.ClanId = 0;
                                        client.Entity.ClanName = "";
                                        client.Entity.Myclan = null;

                                        Database.Clans.KickClan(client.Entity.Name);
                                        client.Send(packet);
                                    }
                                    break;
                                }
                            case 25://buleitn
                                {
                                    if (client.Entity.Myclan == null) return;
                                    string buletin = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                    if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                        Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanBuletion = buletin;
                                    Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                    client.Send(packet);
                                    break;
                                }
                            case 22://give kick
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            string name = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                            uint Key = 0;

                                            foreach (Game.ClanMembers mem in client.Entity.Myclan.Members.Values)
                                            {
                                                if (mem.Name == name)
                                                    Key = mem.UID;
                                            }
                                            if (Key != 0)
                                            {

                                                if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(Key))
                                                {

                                                    if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                    {
                                                        if (Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(Key))
                                                        {
                                                            Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.Remove(Key);
                                                            Network.GamePackets.ClanMembers clan = new Network.GamePackets.ClanMembers(client);
                                                            client.Send(clan.ToArray());
                                                            Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 22);
                                                            ServerBase.Kernel.GamePool[Key].Send(cl.ToArray());
                                                            ServerBase.Kernel.GamePool[Key].Entity.ClanName = "";
                                                            ServerBase.Kernel.GamePool[Key].Entity.ClanId = 0;
                                                            ServerBase.Kernel.GamePool[Key].Entity.Myclan = null;
                                                            ServerBase.Kernel.GamePool[Key].Screen.FullWipe();
                                                            ServerBase.Kernel.GamePool[Key].Screen.Reload(null);
                                                        }
                                                    }
                                                }
                                            }
                                            Database.Clans.KickClan(name);
                                        }
                                    }

                                    break;
                                }

                            case 26://donation
                                {
                                    uint money = BitConverter.ToUInt32(packet, 8);
                                    if (client.Entity.Money >= money && client.Entity.Myclan != null)
                                    {
                                        client.Entity.Myclan.Members[client.Entity.UID].Donation += money;
                                        client.Entity.Money -= money;
                                        if (Conquer_Online_Server.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                            Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation += money;
                                        Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                        client.Send(cl.ToArray());
                                        Database.Clans.SaveClientDonation(client);
                                        Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                    }
                                    break;
                                }
                            case 11://add player
                                {

                                    uint lider = BitConverter.ToUInt32(packet, 8);
                                    if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(lider))
                                    {
                                        packet[4] = 11;
                                        Network.Writer.WriteUInt32(client.Entity.UID, 8, packet);
                                        packet[16] = 1;
                                        packet[17] = (byte)client.Entity.Name.Length;
                                        for (int i = 0; i < client.Entity.Name.Length; i++)
                                        {
                                            try
                                            {
                                                packet[18 + i] = Convert.ToByte(client.Entity.Name[i]);

                                            }
                                            catch { }
                                        }
                                        if (Conquer_Online_Server.ServerBase.Kernel.GamePool[lider].Entity.Myclan != null)
                                            Conquer_Online_Server.ServerBase.Kernel.GamePool[lider].Send(packet);
                                    }
                                    break;
                                }
                            case 12:
                                {
                                    if (packet[16] == 1)
                                    {
                                        if (client.Entity.Myclan != null)
                                            if (client.Entity.Myclan.Members[client.Entity.UID].Rank == 100)
                                            {
                                                //if (client.Entity.Myclan != null)
                                                {
                                                    if (client.Entity.Myclan.Members.Count < 7)
                                                    {

                                                        uint memeber = BitConverter.ToUInt32(packet, 8);
                                                        if (ServerBase.Kernel.GamePool.ContainsKey(memeber))
                                                        {
                                                            Game.ClanMembers member = new Conquer_Online_Server.Game.ClanMembers();
                                                            member.UID = ServerBase.Kernel.GamePool[memeber].Entity.UID;
                                                            member.Donation = 0;
                                                            member.Rank = 10;
                                                            member.Class = ServerBase.Kernel.GamePool[memeber].Entity.Class;
                                                            member.Level = ServerBase.Kernel.GamePool[memeber].Entity.Level;
                                                            member.Name = ServerBase.Kernel.GamePool[memeber].Entity.Name;
                                                            if (!client.Entity.Myclan.Members.ContainsKey(memeber))
                                                                client.Entity.Myclan.Members.Add(member.UID, member);

                                                            ServerBase.Kernel.GamePool[memeber].Entity.ClanRank = 0;
                                                            ServerBase.Kernel.GamePool[memeber].Entity.ClanId = client.Entity.ClanId;
                                                            ServerBase.Kernel.GamePool[memeber].Entity.Myclan = client.Entity.Myclan;
                                                            ServerBase.Kernel.GamePool[memeber].Entity.ClanName = client.Entity.ClanName;
                                                            Database.Clans.JoinClan(ServerBase.Kernel.GamePool[memeber]);
                                                            ServerBase.Kernel.GamePool[memeber].Screen.FullWipe();
                                                            ServerBase.Kernel.GamePool[memeber].Screen.Reload(null);
                                                        }
                                                    }
                                                }
                                            }
                                    }
                                    break;
                                }
                            case 4://memebers
                                {
                                    ClanMembers clan = new ClanMembers(client);
                                    client.Send(clan.ToArray());
                                    break;
                                }
                            case 0x1d:
                                {
                                    if (client.Entity.Myclan != null)
                                    {
                                        Network.Writer.WriteUInt32(client.Entity.Myclan.ClanId, 8, packet);
                                        Network.Writer.WriteByte(1, 16, packet);
                                        Network.Writer.WriteByte(0x0d, 17, packet);
                                        Network.Writer.WriteString("0 0 0 0 0 0 0", 18, packet);
                                        client.Send(packet);
                                        Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                        client.Send(cl.ToArray());
                                        client.Send(packet);

                                        if (client.Entity.Myclan.ClanBuletion != "")
                                            client.Send(cl.UpgradeBuletin(client.Entity.Myclan.ClanBuletion));
                                    }
                                    else
                                    {
                                        client.Send(packet);
                                        packet[4] = 23;
                                    }

                                    break;
                                }
                            case 0x18:
                                {
                                    client.Send(packet);
                                    break;
                                }
                            case (byte)Game.Clan_Typ.AddAlly:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        Client.GameState target;
                                        UInt32 Identifier = BitConverter.ToUInt32(packet, 8);

                                        if (client.Entity.ClanRank == 100)
                                        {
                                            if (clan.Allies.Count >= 5)
                                            { client.Send(new Message("The Ammount of Allies You can Have has exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                            if (ServerBase.Kernel.GamePool.TryGetValue(Identifier, out target))
                                            {
                                                Game.Clans tclan = target.Entity.Myclan;
                                                if (tclan != null)
                                                {
                                                    if (target.Entity.ClanRank == 100)
                                                    {
                                                        if (tclan.Allies.Count >= 5)
                                                        { client.Send(new Message("The Ammount of Allies the Target Clan can Have has exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                                        if (!clan.Allies.ContainsKey(tclan.ClanId))
                                                        {
                                                            if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                            {
                                                                String clanName = client.Entity.ClanName;

                                                                Clan2 clanp = new Clan2();

                                                                clanp.Deserialize(packet);

                                                                clanp.Offset16 = 2;
                                                                clanp.Identifier = client.Entity.UID;

                                                                Writer.WriteByte((Byte)clanName.Length, 17, clanp.ToArray());
                                                                Writer.WriteString(clanName, 18, clanp.ToArray());

                                                                tclan.AllyRequest = clan.ClanId;

                                                                target.Send(clanp);
                                                            }
                                                            else client.Send(new Message("That clan is Your Enemy.", System.Drawing.Color.Red, Message.TopLeft));
                                                        }
                                                    }
                                                    else client.Send(new Message("This target is not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                            }
                                            else client.Send(new Message("Can not find target.", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                        else client.Send(new Message("You are not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.AcceptAlliance:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            Game.Clans tclan;
                                            if (ServerBase.Kernel.ServerClans.TryGetValue(clan.AllyRequest, out tclan))
                                            {
                                                if (tclan != null)
                                                {
                                                    if (!tclan.Enemies.ContainsKey(clan.ClanId))
                                                    {
                                                        if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                        {
                                                            if (!clan.Allies.ContainsKey(tclan.ClanId))
                                                                clan.Allies.Add(tclan.ClanId, tclan);

                                                            tclan.Allies.Add(clan.ClanId, clan);

                                                            clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
                                                            tclan.SendMessage(new ClanRelations(tclan, ClanRelations.RelationTypes.Allies));

                                                            clan.SendMessage(new Message(String.Format("Our Clan has Allianced with {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                            tclan.SendMessage(new Message(String.Format("Our Clan has Allianced with {0}", clan.ClanName), System.Drawing.Color.Red, Message.Clan));

                                                            clan.AddRelation(tclan.ClanId, ClanRelations.RelationTypes.Allies);
                                                            tclan.AddRelation(clan.ClanId, ClanRelations.RelationTypes.Allies);

                                                            clan.AllyRequest = tclan.AllyRequest = 0;
                                                        }
                                                        else client.Send(new Message("This Clan is Your Enemy.", System.Drawing.Color.Red, Message.TopLeft));
                                                    }
                                                    client.Send(new Message("This Clan Has Enemied You!.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                            }
                                            else client.Send(new Message("Can not find target", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                        else client.Send(new Message("You are not the clan leader.", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.DeleteEnemy:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            Clan2 clanp = new Clan2();
                                            clanp.Deserialize(packet);

                                            String EnemyTarget = clanp.Offset18String;
                                            UInt32 ClanId = clanp.GetClanId(EnemyTarget);

                                            Game.Clans tclan;
                                            if (ServerBase.Kernel.ServerClans.TryGetValue(ClanId, out tclan))
                                            {
                                                clan.Enemies.Remove(ClanId);

                                                clan.DeleteRelation(ClanId, ClanRelations.RelationTypes.Enemies);

                                                clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));

                                                clan.SendMessage(new Message(String.Format("We are no longer Enemies With {0}", clan.ClanId), System.Drawing.Color.Red, Message.Clan));

                                                client.Send(clanp);
                                            }
                                        }
                                        else client.Send(new Message("You are not authorized to continue with this action", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.DeleteAlly:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            Clan2 clanp = new Clan2();
                                            clanp.Deserialize(packet);

                                            String AlliedTarget = clanp.Offset18String;
                                            UInt32 ClanId = clanp.GetClanId(AlliedTarget);

                                            Game.Clans tclan;
                                            if (clan.Allies.TryGetValue(ClanId, out tclan))
                                            {
                                                clan.Allies.Remove(ClanId);
                                                tclan.Allies.Remove(clan.ClanId);

                                                clan.DeleteRelation(ClanId, ClanRelations.RelationTypes.Allies);
                                                tclan.DeleteRelation(clan.ClanId, ClanRelations.RelationTypes.Allies);

                                                clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
                                                tclan.SendMessage(new ClanRelations(tclan, ClanRelations.RelationTypes.Allies));

                                                clan.SendMessage(new Message(String.Format("We are no longer allied with {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                tclan.SendMessage(new Message(String.Format("We are no longer allied with {0}", clan.ClanName), System.Drawing.Color.Red, Message.Clan));

                                                client.Send(clanp);
                                            }
                                        }
                                        else client.Send(new Message("You are not authorized to continue with this action", System.Drawing.Color.Red, Message.TopLeft));
                                    }
                                    break;
                                }
                            case (byte)Game.Clan_Typ.AddEnemy:
                                {
                                    Game.Clans clan = client.Entity.Myclan;
                                    if (clan != null)
                                    {
                                        if (client.Entity.ClanRank == 100)
                                        {
                                            String Enemy = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]).Trim(new Char[] { '\0' });
                                            UInt32 ClanId = 0;
                                            var AllCland = ServerBase.Kernel.ServerClans.Values.ToArray();
                                            foreach (Game.Clans c_clan in AllCland)
                                            {
                                                if (Enemy == c_clan.ClanName)
                                                {
                                                    ClanId = c_clan.ClanId;
                                                    break;
                                                }
                                            }
                                            if (ClanId == 0) break;
                                            if (!clan.Enemies.ContainsKey(ClanId))
                                            {
                                                if (!clan.Allies.ContainsKey(ClanId))
                                                {
                                                    if (clan.Enemies.Count >= 5)
                                                    { client.Send(new Message("The Ammount of Enemies You can Have has exceeded", System.Drawing.Color.Red, Message.TopLeft)); break; }

                                                    Game.Clans tclan;
                                                    if (ServerBase.Kernel.ServerClans.TryGetValue(ClanId, out tclan))
                                                    {
                                                        if (!clan.Enemies.ContainsKey(tclan.ClanId))
                                                            clan.Enemies.Add(tclan.ClanId, tclan);

                                                        clan.AddRelation(ClanId, ClanRelations.RelationTypes.Enemies);

                                                        clan.SendMessage(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));

                                                        clan.SendMessage(new Message(String.Format("We Have Enemied the clan {0}", tclan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                        tclan.SendMessage(new Message(String.Format("The Clan {0} Has Made us their Enemy!", clan.ClanName), System.Drawing.Color.Red, Message.Clan));
                                                    }
                                                }
                                                else client.Send(new Message("This clan is one of your alliance, What has gone wrong?", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            else client.Send(new Message("This clan is Already One of Your Enemies", System.Drawing.Color.Red, Message.TopLeft));
                                        }
                                    }
                                    break;
                                }
                            default:
                                Console.WriteLine("Clan Type " + packet[4]);
                                break;

                        }
                        break;
                        /* switch (packet[4])
                         {
                             case 23://client exit
                                 {
                                     if (client.Entity.Myclan != null)
                                     {
                                         foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                         {
                                             if (clien.Entity.Myclan != null)
                                             {
                                                 if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                 {
                                                     if (clien.Entity.Myclan.Members.ContainsKey(client.Entity.UID))
                                                         clien.Entity.Myclan.Members.Remove(client.Entity.UID);
                                                 }
                                             }
                                         }
                                         client.Entity.ClanName = "";
                                         client.Entity.Myclan = null;
                                         Database.Clans.KickClan(client.Entity.Name);
                                         client.Send(packet);
                                     }
                                     break;
                                 }
                             case 14://enemy
                                 {
                                     string Enemy = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                     client.Send(packet);

                                     Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 14);
                                     client.Send(cl.SendAlies(Enemy, "Lider"));
                                     break;
                                 }
                             case 25://buleitn
                                 {
                                     if (client.Entity.Myclan == null) return;
                                     string buletin = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                     foreach (var clan in Conquer_Online_Server.ServerBase.Kernel.ServerClans.Values)
                                     {
                                         if (clan.ClanId == client.Entity.Myclan.ClanId)
                                             clan.ClanBuletion = buletin;
                                     }
                                     foreach (var member in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                     {
                                         if (member.Entity.Myclan != null)
                                         {
                                             if (member.Entity.UID != client.Entity.UID)
                                                 if (member.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                 {
                                                     member.Entity.Myclan.ClanBuletion = buletin;
                                                 }
                                         }
                                     }
                                     Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                     client.Send(packet);
                                     client.Entity.Myclan.ClanBuletion = buletin;
                                     break;
                                 }
                             case 22://give kick
                                 {
                                     if (client.Entity.Myclan != null)
                                     {
                                         if (client.Entity.ClanRank == 100)
                                         {
                                             string name = System.Text.Encoding.ASCII.GetString(packet, 18, packet[17]);
                                             uint Key = 0;

                                             foreach (Game.ClanMembers mem in client.Entity.Myclan.Members.Values)
                                             {
                                                 if (mem.Name == name)
                                                     Key = mem.UID;
                                             }
                                             if (Key != 0)
                                             {

                                                 if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(Key))
                                                 {
                                                     foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                                     {
                                                         if (clien.Entity.UID == client.Entity.UID) continue;
                                                         if (clien.Entity.Myclan != null)
                                                         {
                                                             if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                             {
                                                                 if (clien.Entity.Myclan.Members.ContainsKey(Key))
                                                                 {
                                                                     clien.Entity.Myclan.Members.Remove(Key);
                                                                     Network.GamePackets.ClanMembers clan = new Network.GamePackets.ClanMembers(client);
                                                                     client.Send(clan.ToArray());

                                                                     clien.Entity.ClanName = "";
                                                                     clien.Entity.Myclan = null;
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             Database.Clans.KickClan(name);
                                         }
                                     }
                                     break;
                                 }
                             case 26:
                                 {
                                     uint money = BitConverter.ToUInt32(packet, 8);
                                     if (client.Entity.Money >= money && client.Entity.Myclan != null)
                                     {
                                         client.Entity.Myclan.Members[client.Entity.UID].Donation += money;
                                         client.Entity.Money -= money;
                                         Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation += money;
                                         foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                         {
                                             if (clien.Entity.Myclan != null)
                                             {
                                                 if (clien.Entity.UID != client.Entity.UID)
                                                 {
                                                     if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                     {

                                                         clien.Entity.Myclan.ClanDonation = Conquer_Online_Server.ServerBase.Kernel.ServerClans[clien.Entity.Myclan.ClanId].ClanDonation;
                                                     }
                                                 }
                                             }
                                         }
                                         client.Entity.Myclan.ClanDonation = Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation;
                                         Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                         client.Send(cl.ToArray());
                                         Database.Clans.SaveClientDonation(client);
                                         Database.Clans.SaveClan(Conquer_Online_Server.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                     }
                                     break;
                                 }
                             case 11://add player
                                 {

                                     uint lider = BitConverter.ToUInt32(packet, 8);
                                     if (Conquer_Online_Server.ServerBase.Kernel.GamePool.ContainsKey(lider))
                                     {
                                         packet[4] = 11;
                                         Network.Writer.WriteUInt32(client.Entity.UID, 8, packet);

                                         packet[16] = 1;
                                         packet[17] = (byte)client.Entity.Name.Length;
                                         for (int i = 0; i < client.Entity.Name.Length; i++)
                                         {
                                             try
                                             {
                                                 packet[18 + i] = Convert.ToByte(client.Entity.Name[i]);

                                             }
                                             catch { }
                                         }
                                         Conquer_Online_Server.ServerBase.Kernel.GamePool[lider].Send(packet);
                                     }
                                     break;
                                 }
                             case 12:
                                 {
                                     if (packet[16] == 1)
                                     {
                                         if (client.Entity.Myclan.Members[client.Entity.UID].Rank == 100)
                                         {
                                             if (client.Entity.Myclan != null)
                                             {
                                                 if (client.Entity.Myclan.Members.Count < 7)
                                                 {

                                                     uint memeber = BitConverter.ToUInt32(packet, 8);
                                                     if (ServerBase.Kernel.GamePool.ContainsKey(memeber))
                                                     {
                                                         Game.ClanMembers member = new Conquer_Online_Server.Game.ClanMembers();
                                                         member.UID = ServerBase.Kernel.GamePool[memeber].Entity.UID;
                                                         member.Donation = 0;
                                                         member.Rank = 10;
                                                         member.Class = ServerBase.Kernel.GamePool[memeber].Entity.Class;
                                                         member.Level = ServerBase.Kernel.GamePool[memeber].Entity.Level;
                                                         member.Name = ServerBase.Kernel.GamePool[memeber].Entity.Name;
                                                         if (!client.Entity.Myclan.Members.ContainsKey(memeber))
                                                             client.Entity.Myclan.Members.Add(member.UID, member);

                                                         foreach (var clien in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
                                                         {
                                                             if (clien.Entity.Myclan != null)
                                                             {
                                                                 if (clien.Entity.Myclan.ClanId == client.Entity.Myclan.ClanId)
                                                                 {
                                                                     if (!clien.Entity.Myclan.Members.ContainsKey(memeber))
                                                                         clien.Entity.Myclan.Members.Add(member.UID, member);
                                                                 }
                                                             }
                                                         }
                                                       ServerBase.Kernel.GamePool[memeber].Entity.ClanRank = 0;
                                                         ServerBase.Kernel.GamePool[memeber].Entity.Myclan = client.Entity.Myclan;
                                                         ServerBase.Kernel.GamePool[memeber].Entity.ClanName = client.Entity.ClanName;
                                                         Database.Clans.JoinClan(ServerBase.Kernel.GamePool[memeber]);
                                                        ServerBase.Kernel.GamePool[memeber].Entity.Teleport(ServerBase.Kernel.GamePool[memeber].Entity.MapID
                                                             , ServerBase.Kernel.GamePool[memeber].Entity.X
                                                             , ServerBase.Kernel.GamePool[memeber].Entity.Y);
                                                     }
                                                 }
                                             }
                                      }
                                     }
                                     break;
                                 }
                             case 4://memebers
                                 {
                                     ClanMembers clan = new ClanMembers(client);
                                     client.Send(clan.ToArray());
                                     break;
                                 }
                             case 0x1d:
                                 {
                                     if (client.Entity.Myclan != null)
                                     {
                                         Network.Writer.WriteUInt32(client.Entity.Myclan.ClanId, 8, packet);
                                         Network.Writer.WriteByte(1, 16, packet);
                                         Network.Writer.WriteByte(0x0d, 17, packet);
                                         Network.Writer.WriteString("0 0 0 0 0 0 0", 18, packet);
                                         client.Send(packet);
                                         Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                                         client.Send(cl.ToArray());
                                         client.Send(packet);

                                         if (client.Entity.Myclan.ClanBuletion != "")
                                             client.Send(cl.UpgradeBuletin(client.Entity.Myclan.ClanBuletion));
                                     }
                                     else
                                     {
                                         client.Send(packet);
                                         packet[4] = 23;
                                     }

                                     break;
                                 }
                             case 0x18:
                                 {
                                     client.Send(packet);
                                     break;
                                 }
                             default:
                                 Console.WriteLine("Clan Type " + packet[4]);
                                 break;
                         }
                         break;*/
                    }
                #endregion
                #region Reincarnation (1066)
                case 1066:
                    {
                        if (client.Entity.Reborn != 2) return;
                        byte NewClass = packet[4];
                        ushort NewBody = packet[8];
                        if (client.Entity.Body.ToString().EndsWith("1") || client.Entity.Body.ToString().EndsWith("2"))
                            NewBody += 2000;
                        else NewBody += 1000;

                        if (client.Inventory.Contains(711083, 1))
                        {
                            client.Entity.Body = NewBody;
                            new PacketHandler.Reincarnation(client, NewClass);
                            //new Game.Features.Reincarnation.Reincarnate(client.Entity, NewClass);
                            client.Inventory.Remove(711083, 1);
                        }
                        break;
                    }
                #endregion
                #region SubClass (2320)
                case 2320:
                    {
                        byte[] Packet = null;
                        switch (packet[4])
                        {
                            #region [Restore/Switch]
                            case 0:
                                byte To = packet[6];
                                Packet = new byte[0];
                                client.Send(packet);

                                if (To > 0)//Switch
                                {
                                    #region [Effects-Addition]
                                    switch ((Conquer_Online_Server.Game.ClassID)To)
                                    {
                                        case Conquer_Online_Server.Game.ClassID.Apothecary:
                                            {
                                                //

                                                client.Entity.Statistics.Detoxication = (ushort)(client.Entity.SubClasses.Classes[(byte)Conquer_Online_Server.Game.ClassID.Apothecary].Phase * 8);
                                                //client.Entity.Statistics.Detoxication += (client.Entity.SubClasses.Classes[To].Level);
                                                break;
                                            }
                                    }

                                    #endregion
                                    /*switch ((Game.ClassID)To)
                                    {
                                        case Game.ClassID.Wrangler:
                                            {
                                                switch (client.Entity.SubClasses.Classes[To].Level)
                                                {
                                                    case 9:
                                                        {
                                                            //client.Entity.Hitpoints += 1200;
                                                            //client.Entity.MaxHitpoints += 1200;
                                                            break;
                                                        }
                                                }
                                                break;
                                            }
                                    }*/
                                    Packet = new byte[0];
                                    Packet = new SubClassShowFull(true) { ID = 1, Class = To, Level = client.Entity.SubClasses.Classes[To].Phase }.ToArray();//client.Entity.SubClasses.Classes[To].Phase
                                    client.Send(Packet);
                                    //Packet = new SubClass(client.Entity).ToArray();
                                    //client.Send(Packet);
                                    client.Entity.SubClass = To;
                                    client.Entity.SubClassLevel = client.Entity.SubClasses.Classes[To].Level;
                                    client.Entity.SubClasses.Active = To;
                                }
                                else//Restore
                                {
                                    client.Entity.SubClass = 0;
                                    client.Entity.SubClassLevel = 0;
                                    client.Entity.SubClasses.Active = 0;
                                    Packet = new SubClassShowFull(true) { ID = 1 }.ToArray();
                                    client.Send(Packet);
                                }
                                client.SendScreen(client.Entity.SpawnPacket, false);
                                break;
                            #endregion
                            #region [Upgrade]
                            case 2:
                                {
                                    byte Class = packet[6];
                                    ushort Required = 0;
                                    Game.SubClass Sc = client.Entity.SubClasses.Classes[Class];
                                    #region [Set Required]
                                    switch ((Game.ClassID)Sc.ID)
                                    {
                                        case Game.ClassID.MartialArtist:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 300; break;
                                                case 2: Required = 900; break;
                                                case 3: Required = 1800; break;
                                                case 4: Required = 2700; break;
                                                case 5: Required = 3600; break;
                                                case 6: Required = 5100; break;
                                                case 7: Required = 6900; break;
                                                case 8: Required = 8700; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Warlock:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 300; break;
                                                case 2: Required = 900; break;
                                                case 3: Required = 1800; break;
                                                case 4: Required = 2700; break;
                                                case 5: Required = 3600; break;
                                                case 6: Required = 5100; break;
                                                case 7: Required = 6900; break;
                                                case 8: Required = 8700; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.ChiMaster:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 600; break;
                                                case 2: Required = 1800; break;
                                                case 3: Required = 3600; break;
                                                case 4: Required = 5400; break;
                                                case 5: Required = 7200; break;
                                                case 6: Required = 10200; break;
                                                case 7: Required = 13800; break;
                                                case 8: Required = 17400; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Sage:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 400; break;
                                                case 2: Required = 1200; break;
                                                case 3: Required = 2400; break;
                                                case 4: Required = 3600; break;
                                                case 5: Required = 4800; break;
                                                case 6: Required = 6800; break;
                                                case 7: Required = 9200; break;
                                                case 8: Required = 11600; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Apothecary:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 100; break;
                                                case 2: Required = 200; break;
                                                case 3: Required = 300; break;
                                                case 4: Required = 400; break;
                                                case 5: Required = 500; break;
                                                case 6: Required = 1000; break;
                                                case 7: Required = 4000; break;
                                                case 8: Required = 9000; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                        case Game.ClassID.Wrangler:
                                        case Game.ClassID.Performer:
                                            switch (Sc.Level)
                                            {
                                                case 1: Required = 400; break;
                                                case 2: Required = 1200; break;
                                                case 3: Required = 2400; break;
                                                case 4: Required = 3600; break;
                                                case 5: Required = 4800; break;
                                                case 6: Required = 6800; break;
                                                case 7: Required = 9200; break;
                                                case 8: Required = 11600; break;
                                                case 9: Required = ushort.MaxValue; break;
                                            }
                                            break;
                                    }
                                    #endregion
                                    if (client.Entity.SubClasses.StudyPoints >= Required)
                                    {
                                        client.Entity.SubClasses.StudyPoints -= Required;
                                        client.Entity.SubClasses.Classes[Class].Level++;
                                        Packet = new byte[0];
                                        Packet = new SubClassShowFull(true) { ID = 1, Class = Class, Level = client.Entity.SubClasses.Classes[Class].Level }.ToArray();
                                        client.Send(Packet);
                                        Packet = new SubClass(client.Entity).ToArray();
                                        client.Send(Packet);
                                        Database.SubClassTable.Update(client.Entity, client.Entity.SubClasses.Classes[Class]);
                                        Database.SubClassTable.Update(client.Entity);
                                    }
                                    break;
                                }
                            #endregion
                            #region [Info]
                            case 6:
                                Game.Entity Owner = client.Entity;
                                if (Owner.SubClasses.Classes.Count > 0)
                                {
                                    Game.SubClass[] Classes = new Game.SubClass[Owner.SubClasses.Classes.Count];
                                    Owner.SubClasses.Classes.Values.CopyTo(Classes, 0);
                                    foreach (Game.SubClass Class in Classes)
                                    {
                                        if (Class.ID == 9)
                                        {
                                            for (byte i = 0; i < Class.Phase; i++)
                                            {
                                                Packet = new byte[0];
                                                Packet = new SubClassShowFull(true) { ID = 4, Class = Class.ID, Level = Class.Level }.ToArray();
                                                client.Send(Packet);
                                            }
                                            continue;
                                        }
                                        Packet = new byte[0];
                                        Packet = new SubClassShowFull(true) { ID = 4, Class = Class.ID, Level = Class.Level }.ToArray();
                                        client.Send(Packet);
                                    }
                                }
                                Packet = new SubClass(client.Entity).ToArray();
                                client.Send(Packet);
                                break;
                            #endregion
                            default:
                                Console.WriteLine("Unknown 2320 packet type " + packet[4]);
                                break;
                        }
                        break;
                    }
                #endregion
                #region MemoryAgate
                case 2110:
                    {
                        uint ItemUID = BitConverter.ToUInt32(packet, 8);
                        switch (packet[4])
                        {
                            case 1://record
                                {
                                    if (client.Map.IsDynamic()) return;
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(ItemUID, out Item))
                                    {
                                        if (Item.Agate_map.ContainsKey(packet[12]))
                                        {
                                            Item.Agate_map[(uint)packet[12]] = client.Entity.MapID
                                               + "~" + client.Entity.X
                                               + "~" + client.Entity.Y;
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                            Item.SendAgate(client);
                                            break;
                                        }
                                        if (packet[12] > Item.Agate_map.Count)
                                        {
                                            Item.Agate_map.Add((byte)(Item.Agate_map.Count), client.Entity.MapID
                                               + "~" + client.Entity.X
                                               + "~" + client.Entity.Y);
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                            Item.SendAgate(client);
                                            break;
                                        }
                                        else
                                        {
                                            if (!Item.Agate_map.ContainsKey(packet[12]))
                                            {

                                                Item.Agate_map.Add(packet[12], client.Entity.MapID
                                                    + "~" + client.Entity.X

                                                   + "~" + client.Entity.Y);
                                                Database.ConquerItemTable.UpdateItem(Item, client);
                                                Item.SendAgate(client);
                                            }
                                            break;
                                        }
                                    }
                                    break;
                                }
                            case 3://recal
                                {
                                    if (client.Map.IsDynamic()) return;
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(ItemUID, out Item))
                                    {

                                        if (Item.Agate_map.ContainsKey(packet[12]))
                                        {
                                            if (ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString()) == 1038)
                                                return;
                                            if (ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString()) == 6001)
                                                return;
                                            client.Entity.Teleport(ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString())
                                                , ushort.Parse(Item.Agate_map[packet[12]].Split('~')[1].ToString())
                                                , ushort.Parse(Item.Agate_map[packet[12]].Split('~')[2].ToString()));
                                            Item.Durability--;
                                            Item.SendAgate(client);
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                        }
                                    }
                                    break;
                                }
                            case 4://repair
                                {
                                    Interfaces.IConquerItem Item = null;
                                    if (client.Inventory.TryGetItem(ItemUID, out Item))
                                    {
                                        uint cost = (uint)(Item.MaximDurability - Item.Durability) / 2;
                                        if (cost == 0)
                                            cost = 1;
                                        if (client.Entity.ConquerPoints > cost)
                                        {
                                            client.Entity.ConquerPoints -= cost;
                                            Item.Durability = Item.MaximDurability;
                                            Item.SendAgate(client);
                                            Database.ConquerItemTable.UpdateItem(Item, client);
                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                case 1128:
                    {
                        p1128 vp = new p1128(false);
                        vp.Deserialize(packet);
                        switch (vp.UID)
                        {
                            case 0://player city teleport
                                {
                                    switch (vp.UID2)
                                    {
                                        ////////////////////////////////////////////////////////////////////////////////////////////////////
                                        case 1://tc
                                            client.Entity.Teleport(1002, 429, 378);
                                            break;
                                        case 2://pc
                                            client.Entity.Teleport(1011, 188, 264);
                                            break;
                                        case 3://ac
                                            client.Entity.Teleport(1020, 565, 562);
                                            break;
                                        case 4://dc
                                            client.Entity.Teleport(1000, 500, 650);
                                            break;
                                        case 5://bc
                                            client.Entity.Teleport(1015, 717, 571);
                                            break;
                                            ////////////////////////////////////////////////////////////////////////////////////////
                                            {

                                            }
                                        default: Console.WriteLine("Unknown 1128 portal subtype 1 : " + vp.UID2); break;
                                    }
                                    break;
                                }
                            case 1://Team city teleport
                                {
                                    switch (vp.UID2)
                                    {
                                        ////////////////////////////////////////////////////////////////////////////////////////////////////
                                        case 1://tc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1002, 429, 378);
                                                }
                                            }
                                            client.Entity.Teleport(1002, 429, 378);
                                            break;
                                        case 2://pc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1011, 188, 264);
                                                }
                                            }
                                            client.Entity.Teleport(1011, 188, 264);
                                            break;
                                        case 3://ac
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1020, 565, 562);
                                                }
                                            }
                                            client.Entity.Teleport(1020, 565, 562);
                                            break;
                                        case 4://dc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1000, 500, 650);
                                                }
                                            }
                                            client.Entity.Teleport(1000, 500, 650);
                                            break;
                                        case 5://bc
                                            foreach (Client.GameState teammate in client.Entity.Owner.Team.Teammates)
                                            {
                                                if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, teammate.Entity.X, teammate.Entity.Y) <= 18)
                                                {
                                                    teammate.Entity.Teleport(1015, 717, 571);
                                                }
                                            }
                                            client.Entity.Teleport(1015, 717, 571);
                                            break;
                                            ////////////////////////////////////////////////////////////////////////////////////////
                                            {

                                            }
                                        default: Console.WriteLine("Unknown 1128 portal subtype 2 : " + vp.UID2); break;
                                    }
                                    break;
                                }

                            default:
                                Console.WriteLine("Unknown 1128 subtype: " + vp.UID); break;
                        }
                        break;
                    }
                default:
                    {
                        if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager)
                            client.Send(new Message("Unknown type: " + ID + " with length " + packet.Length + "Unknown type: " + ID2, System.Drawing.Color.CadetBlue, Message.Talk));
                        if (ID == 1040)
                            client.Send(packet);
                        if (ID==2064)
                            client.Send(new Message("Packet de Novility Bien", System.Drawing.Color.CadetBlue, Message.Talk));
                        break;
                    }
            }
        }
        public void _timerCallBack(object jjjhh, System.Timers.ElapsedEventArgs arg)
        {
            try
            {
                if (Owner.Socket ==null ||!Owner.Socket.Connected || Owner.Entity == null)
                {
                    if (Owner != null)
                    {
                        if (Owner.Screen != null)
                        {
                            if (Owner.Screen.MyTimer != null)
                            {

                                Owner.Screen.MyTimer.Close();
                                Owner.Screen.MyTimer.Dispose();
                            }
                        }
                    }
                    return;
                }
                try
                {
                    while (OnAdd.Count != 0)
                        Objects.Add(OnAdd.Dequeue());
                    while (OnRemove.Count != 0)
                        Objects.Remove(OnRemove.Dequeue());
                }
                catch
                {
                    // Console.WriteLine(e.ToString());
                }
                #region Monsters
               // List<IMapObject> toRemove = new List<IMapObject>();
                if (Owner.Map.FreezeMonsters)
                    return;
                try
                {
                    for (int c = 0; c < Objects.Count; c++)
                    {
                        if (c >= Objects.Count)
                            break;
                        //List<IMapObject> list = new List<IMapObject>();
                        IMapObject obj = Objects[c];
                        if (obj != null)
                        {
                            if (obj.MapObjType == MapObjectType.SobNpc)
                            {
                                /*short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                if (distance <= monster.MonsterInfo.AttackRange)
                                {
                                    monster.MonsterInfo.LastMove = Time32.Now;
                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                }*/
                                Network.GamePackets.SobNpcSpawn item = obj as Network.GamePackets.SobNpcSpawn;
                                if (item.MapID == 2060)
                                {

                                    if (item.UID == 10011)
                                    {
                                        if (Game.Team.RedCapture)
                                        {
                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (_obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        (_obj as Entity).Owner.Send(item);
                                                        (_obj as Entity).Owner.Screen.Remove(item);
                                                    }
                                                }
                                            }
                                            Owner.Map.Floor[item.X, item.Y, MapObjectType.SobNpc, null] = true;
                                            Remove(obj);
                                            //toRemove.Add(item);
                                        }
                                    }
                                    if (item.UID == 10021)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureR && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.RScore += 1;
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the Red team. RedScore: " + Game.Team.RScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.RScore >= 10)
                                                                {
                                                                    Game.Team.ClaimRed();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (item.UID == 10022)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureB && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.BScore += 1;
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the Blue team. BlueScore: " + Game.Team.BScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.BScore >= 10)
                                                                {
                                                                    Game.Team.ClaimBLUE();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (item.UID == 10023)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureW && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.WScore += 1;
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the White team. WhiteScore: " + Game.Team.WScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.WScore >= 10)
                                                                {
                                                                    Game.Team.ClaimWhite();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (item.UID == 10024)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureBL && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.BLScore += 1;
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the Black team. BlackScore: " + Game.Team.BLScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.BLScore >= 10)
                                                                {
                                                                    Game.Team.ClaimBlack();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (obj.MapObjType == MapObjectType.Monster)
                            {
                                if (Owner != null)
                                {
                                    if (Owner.Map != null)
                                    {
                                        if (Owner.Map != null)
                                        {
                                            Entity monster = null;
                                            if (Objects[c] == null) continue;
                                            monster = Objects[c] as Game.Entity;
                                            if (monster == null) continue;
                                            #region Buffers
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                            {
                                                if (Time32.Now >= monster.StigmaStamp.AddSeconds(monster.StigmaTime))
                                                {
                                                    monster.StigmaTime = 0;
                                                    monster.StigmaIncrease = 0;
                                                    monster.RemoveFlag(Network.GamePackets.Update.Flags.Stigma);
                                                }
                                            }
                                            if (monster.BlackSpotTime2 > 0)
                                            {
                                                if (Time32.Now >= monster.BlackSpotTime.AddSeconds(monster.BlackSpotTime2))
                                                {
                                                    monster.BlackSpotTime2 = 0;
                                                    monster.BlackSpots = false;
                                                    BlackSpot spot = new BlackSpot
                                                    {
                                                        Remove = 1,
                                                        Identifier = monster.UID
                                                    };
                                                    Owner.Send(spot);
                                                }
                                                else
                                                {
                                                    BlackSpot spot = new BlackSpot
                                                    {
                                                        Remove = 0,
                                                        Identifier = monster.UID
                                                    };
                                                    Owner.Send(spot);
                                                }

                                            }
                                            else
                                            {
                                                BlackSpot spot = new BlackSpot
                                                {
                                                    Remove = 1,
                                                    Identifier = monster.UID
                                                };
                                                Owner.Send(spot);
                                            }

                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.Dodge))
                                            {
                                                if (Time32.Now >= monster.DodgeStamp.AddSeconds(monster.DodgeTime))
                                                {
                                                    monster.DodgeTime = 0;
                                                    monster.DodgeIncrease = 0;
                                                    monster.RemoveFlag(Network.GamePackets.Update.Flags.Dodge);
                                                }
                                            }
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                            {
                                                if (Time32.Now >= monster.InvisibilityStamp.AddSeconds(monster.InvisibilityTime))
                                                {
                                                    monster.RemoveFlag(Network.GamePackets.Update.Flags.Invisibility);
                                                }
                                            }
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.StarOfAccuracy))
                                            {
                                                if (monster.StarOfAccuracyTime != 0)
                                                {
                                                    if (Time32.Now >= monster.StarOfAccuracyStamp.AddSeconds(monster.StarOfAccuracyTime))
                                                    {
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.StarOfAccuracy);
                                                    }
                                                }
                                                else
                                                {
                                                    if (Time32.Now >= monster.AccuracyStamp.AddSeconds(monster.AccuracyTime))
                                                    {
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.StarOfAccuracy);
                                                    }
                                                }
                                            }
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.MagicShield))
                                            {
                                                if (monster.MagicShieldTime != 0)
                                                {
                                                    if (Time32.Now >= monster.MagicShieldStamp.AddSeconds(monster.MagicShieldTime))
                                                    {
                                                        monster.MagicShieldIncrease = 0;
                                                        monster.MagicShieldTime = 0;
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.MagicShield);
                                                    }
                                                }
                                                else
                                                {
                                                    if (Time32.Now >= monster.ShieldStamp.AddSeconds(monster.ShieldTime))
                                                    {
                                                        monster.ShieldIncrease = 0;
                                                        monster.ShieldTime = 0;
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.MagicShield);
                                                    }
                                                }
                                            }
                                            #endregion
                                            #region Dead monster
                                            if (monster.Dead || monster.Killed)
                                            {
                                                if (!monster.ContainsFlag(Network.GamePackets.Update.Flags.Ghost) || monster.Killed)
                                                {
                                                    monster.Killed = false;
                                                    monster.MonsterInfo.InSight = 0;
                                                    monster.MonsterInfo.InStig = 0;
                                                    monster.MonsterInfo.InRev = 0;
                                                    monster.MonsterInfo.InBlack = 0;
                                                    monster.AddFlag(Network.GamePackets.Update.Flags.Ghost);
                                                    monster.AddFlag(Network.GamePackets.Update.Flags.Dead);
                                                    monster.AddFlag(Network.GamePackets.Update.Flags.FadeAway);
                                                    Network.GamePackets.Attack attack = new Network.GamePackets.Attack(true);
                                                    attack.Attacker = monster.Killer.UID;
                                                    attack.Attacked = monster.UID;
                                                    attack.AttackType = Network.GamePackets.Attack.Kill;
                                                    attack.X = monster.X;
                                                    attack.Y = monster.Y;
                                                    Owner.Map.Floor[monster.X, monster.Y, MapObjectType.Monster, monster] = true;
                                                    attack.KOCount = ++monster.Killer.KOCount;
                                                    if (monster.Killer.EntityFlag == EntityFlag.Player)
                                                    {
                                                        monster.MonsterInfo.ExcludeFromSend = monster.Killer.UID;
                                                        monster.Killer.Owner.Send(attack);
                                                        if (monster.Killer.Owner.Companion != null)
                                                        {
                                                            if (monster.Killer.Owner.Companion.MonsterInfo != null)
                                                            {
                                                                monster.Killer.Owner.Map.RemoveEntity(monster.Killer.Owner.Companion);
                                                                Data data = new Data(true);
                                                                data.UID = monster.Killer.Owner.Companion.UID;
                                                                data.ID = Data.RemoveEntity;
                                                                monster.Killer.Owner.Companion.MonsterInfo.SendScreen(data);
                                                                monster.Killer.Owner.Companion = null;
                                                            }
                                                        }
                                                    }
                                                    monster.MonsterInfo.SendScreen(attack);
                                                    monster.MonsterInfo.ExcludeFromSend = 0;
                                                }
                                                if (Time32.Now > monster.DeathStamp.AddSeconds(4))
                                                {
                                                    Network.GamePackets.Data data = new Network.GamePackets.Data(true);
                                                    data.UID = monster.UID;
                                                    data.ID = Network.GamePackets.Data.RemoveEntity;
                                                    monster.MonsterInfo.SendScreen(data);
                                                }
                                            }
                                            #endregion
                                            #region Alive monster
                                            else
                                            {
                                                if ((obj as Entity).Stunned)
                                                {
                                                    if (Time32.Now > (obj as Entity).StunStamp.AddMilliseconds(1500))
                                                        (obj as Entity).Stunned = false;
                                                    else
                                                        continue;
                                                }
                                                if ((obj as Entity).Companion)
                                                    continue;
                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MinimumSpeed))
                                                {
                                                    #region Guards
                                                    if (monster.Name.Contains("Guard"))
                                                    {
                                                        if (monster.Name == "Guard1" || monster.MonsterInfo.ID >= 9000 && monster.MonsterInfo.ID <= 9003)
                                                        {
                                                            if (monster.MonsterInfo.InSight == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                    monster.MonsterInfo.InSight = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                {
                                                                    if (monster.MonsterInfo.InSight == Owner.Entity.UID)
                                                                    {
                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                        }
                                                                    }
                                                                    else
                                                                    {

                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InSight == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InSight = 0;
                                                                    }
                                                                }
                                                            }

                                                            for (int i = 0; i < Objects.Count; i++)
                                                            {
                                                                if (i >= Objects.Count)
                                                                    break;
                                                                IMapObject obj2 = Objects[i];
                                                                if (obj2 == null)
                                                                    continue;
                                                                if (obj2.MapObjType == MapObjectType.Monster)
                                                                {
                                                                    Entity monster2 = obj2 as Entity;//null;// Owner.Map.Entities[obj2.UID];
                                                                    if (monster2 == null)
                                                                        continue;
                                                                    if (monster2.Dead)
                                                                        continue;
                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                    {
                                                                        if (!monster2.Name.Contains("Guard") && !monster2.Companion)
                                                                        {
                                                                            short distance = Kernel.GetDistance(monster.X, monster.Y, monster2.X, monster2.Y);

                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                new Game.Attacking.Handle(null, monster, monster2);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        #region BlackName Guard
                                                        if (monster.Name == "Guard2")
                                                        {
                                                            if (monster.MonsterInfo.InBlack == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (Owner.Entity.PKPoints > 99 || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                    monster.MonsterInfo.InBlack = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (Owner.Entity.PKPoints > 99 || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                {
                                                                    if (monster.MonsterInfo.InBlack == Owner.Entity.UID)
                                                                    {
                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                        }

                                                                    }
                                                                    else
                                                                    {

                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InBlack == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InBlack = 0;
                                                                    }
                                                                }
                                                            }

                                                            for (int i = 0; i < Objects.Count; i++)
                                                            {
                                                                if (i >= Objects.Count)
                                                                    break;
                                                                IMapObject obj2 = Objects[i];
                                                                if (obj2 == null)
                                                                    continue;
                                                                if (obj2.MapObjType == MapObjectType.Monster)
                                                                {
                                                                    Entity monster2 = obj2 as Entity;//null;// Owner.Map.Entities[obj2.UID];
                                                                    if (monster2 == null)
                                                                        continue;
                                                                    if (monster2.Dead)
                                                                        continue;
                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                    {
                                                                        if (!monster2.Name.Contains("Guard") && !monster2.Companion)
                                                                        {
                                                                            short distance = Kernel.GetDistance(monster.X, monster.Y, monster2.X, monster2.Y);

                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                new Game.Attacking.Handle(null, monster, monster2);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        #endregion
                                                        #region Rev Guard
                                                        if (monster.Name == "RevGuard")
                                                        {
                                                            if (monster.MonsterInfo.InRev == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (Owner.Entity.Dead)
                                                                    monster.MonsterInfo.InRev = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (Owner.Entity.Dead)
                                                                {
                                                                    if (monster.MonsterInfo.InRev == Owner.Entity.UID)
                                                                    {
                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        /*Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);*/
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        monster.MonsterInfo.InRev = 0;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InRev == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InRev = 0;
                                                                    }
                                                                }
                                                            }

                                                        }
                                                        #endregion
                                                        #region Stig Guard
                                                        if (monster.Name == "StigGuard")
                                                        {
                                                            if (monster.MonsterInfo.InStig == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                                                    monster.MonsterInfo.InStig = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                                                {
                                                                    if (monster.MonsterInfo.InStig == Owner.Entity.UID)
                                                                    {
                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        /*Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);*/
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        monster.MonsterInfo.InStig = 0;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InStig == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InStig = 0;
                                                                    }
                                                                }
                                                            }
                                                            for (int i = 0; i < Objects.Count; i++)
                                                            {
                                                                if (i >= Objects.Count)
                                                                    break;
                                                                IMapObject obj2 = Objects[i];
                                                                if (obj2 == null)
                                                                    continue;
                                                                if (obj2.MapObjType == MapObjectType.Monster)
                                                                {
                                                                    Entity monster2 = obj2 as Entity;//null;// Owner.Map.Entities[obj2.UID];
                                                                    if (monster2 == null)
                                                                        continue;
                                                                    if (monster2.Dead)
                                                                        continue;
                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                    {
                                                                        if (!monster2.Name.Contains("Guard") && !monster2.Companion)
                                                                        {
                                                                            short distance = Kernel.GetDistance(monster.X, monster.Y, monster2.X, monster2.Y);

                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                new Game.Attacking.Handle(null, monster, monster2);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                        }
                                                        #endregion
                                                    #endregion
                                                    }
                                                    else
                                                    {
                                                        #region Monsters

                                                        short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                        if (monster.MonsterInfo.InSight != 0 && monster.MonsterInfo.InSight != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InSight > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InSight];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InSight = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance)
                                                                        monster.MonsterInfo.InSight = 0;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                Entity companion = null;
                                                                for (int x = 0; x < Owner.Map.Companions.Count; x++)
                                                                {
                                                                    if (x >= Owner.Map.Companions.Count)
                                                                        break;
                                                                    if (Owner.Map.Companions[x] != null)
                                                                    {
                                                                        if (Owner.Map.Companions[x].UID == monster.MonsterInfo.InSight)
                                                                        {
                                                                            companion = Owner.Map.Companions[x];
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                                if (companion == null)
                                                                    monster.MonsterInfo.InSight = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, companion.X, companion.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance)
                                                                        monster.MonsterInfo.InSight = 0;
                                                                }
                                                            }
                                                        }
                                                        /*if (monster.MonsterInfo.InRev != 0 && monster.MonsterInfo.InRev != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InRev > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InRev];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InRev = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance2 || !cl.Entity.Dead)
                                                                        monster.MonsterInfo.InRev = 0;
                                                                }
                                                            }

                                                        }
                                                        if (monster.MonsterInfo.InStig != 0 && monster.MonsterInfo.InStig != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InStig > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InStig];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InStig = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance2 || cl.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                                                        monster.MonsterInfo.InStig = 0;
                                                                }
                                                            }

                                                        }
                                                        if (monster.MonsterInfo.InBlack != 0 && monster.MonsterInfo.InBlack != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InBlack > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InBlack];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InBlack = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance || cl.Entity.PKPoints < 100)
                                                                        monster.MonsterInfo.InBlack = 0;
                                                                }
                                                            }

                                                        }*/
                                                        if (distance <= ServerBase.Constants.pScreenDistance)
                                                        {
                                                            #region Companions
                                                            if (Owner.Companion != null)
                                                            {
                                                                if (Owner.Companion.Companion && !Owner.Companion.Dead)
                                                                {
                                                                    short distance2 = Kernel.GetDistance(monster.X, monster.Y, Owner.Companion.X, Owner.Companion.Y);
                                                                    if (distance > distance2 || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility) || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                    {
                                                                        if (monster.MonsterInfo.InSight == 0)
                                                                        {
                                                                            monster.MonsterInfo.InSight = Owner.Companion.UID;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (monster.MonsterInfo.InSight == Owner.Companion.UID)
                                                                            {
                                                                                if (distance2 > ServerBase.Constants.pScreenDistance)
                                                                                {
                                                                                    monster.MonsterInfo.InSight = 0;
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance2 <= monster.MonsterInfo.AttackRange)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;
                                                                                            new Game.Attacking.Handle(null, monster, Owner.Companion);
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (distance2 > monster.MonsterInfo.ViewRange / 2)
                                                                                        {
                                                                                            if (distance2 < ServerBase.Constants.pScreenDistance)
                                                                                            {
                                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                                {
                                                                                                    monster.MonsterInfo.LastMove = Time32.Now;

                                                                                                    Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Companion.X, Owner.Companion.Y);
                                                                                                    if (!monster.Move(facing))
                                                                                                    {
                                                                                                        facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                        if (monster.Move(facing))
                                                                                                        {
                                                                                                            monster.Facing = facing;
                                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                            move.Direction = facing;
                                                                                                            move.UID = monster.UID;
                                                                                                            move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                                        }
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        monster.Facing = facing;
                                                                                                        Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                        move.Direction = facing;
                                                                                                        move.UID = monster.UID;
                                                                                                        move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                        monster.MonsterInfo.SendScreen(move);
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.MonsterInfo.InSight = 0;
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                            {
                                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                                Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Companion.X, Owner.Companion.Y);
                                                                                                if (!monster.Move(facing))
                                                                                                {
                                                                                                    facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                    if (monster.Move(facing))
                                                                                                    {
                                                                                                        monster.Facing = facing;
                                                                                                        Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                        move.Direction = facing;
                                                                                                        move.UID = monster.UID;
                                                                                                        monster.MonsterInfo.SendScreen(move);
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                            else
                                                                                goto Over;
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                    goto Over;
                                                            }
                                                            else
                                                                goto Over;
                                                            #endregion
                                                        Over:
                                                            #region Player
                                                            if (monster.MonsterInfo.Name.Contains("Guard"))
                                                            {
                                                                if (monster.MonsterInfo.InBlack == 0)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InBlack = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InBlack == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                            return;
                                                                        }

                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                {
                                                                                    if (distance < ServerBase.Constants.pScreenDistance)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;

                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        monster.MonsterInfo.InBlack = 0;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                        if (!monster.Move(facing))
                                                                                        {
                                                                                            facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                            if (monster.Move(facing))
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.Facing = facing;
                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                            move.Direction = facing;
                                                                                            move.UID = monster.UID;
                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (monster.MonsterInfo.InSight == 0)
                                                            {
                                                                if (!Owner.Entity.Dead)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InSight = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (!Owner.Entity.Dead)
                                                                {
                                                                    if (monster.MonsterInfo.InSight == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                            return;
                                                                        }

                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (!Owner.Entity.Dead)
                                                                            {
                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                    {
                                                                                        if (distance < ServerBase.Constants.pScreenDistance)
                                                                                        {
                                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                            {
                                                                                                monster.MonsterInfo.LastMove = Time32.Now;

                                                                                                Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                                if (!monster.Move(facing))
                                                                                                {
                                                                                                    facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                    if (monster.Move(facing))
                                                                                                    {
                                                                                                        monster.Facing = facing;
                                                                                                        Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                        move.Direction = facing;
                                                                                                        move.UID = monster.UID;
                                                                                                        move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                        monster.MonsterInfo.SendScreen(move);
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.MonsterInfo.InSight = 0;
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;
                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (Owner.Entity.Dead)
                                                                                {
                                                                                    monster.MonsterInfo.InSight = 0;
                                                                                    // Console.WriteLine("cheack1");
                                                                                    return;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (monster.MonsterInfo.Name.Contains("Guard"))
                                                            {
                                                                if (monster.MonsterInfo.InRev == 0)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InRev = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InRev == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                            return;
                                                                        }

                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                {
                                                                                    if (distance < ServerBase.Constants.pScreenDistance)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;

                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        monster.MonsterInfo.InRev = 0;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                        if (!monster.Move(facing))
                                                                                        {
                                                                                            facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                            if (monster.Move(facing))
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.Facing = facing;
                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                            move.Direction = facing;
                                                                                            move.UID = monster.UID;
                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (monster.MonsterInfo.Name.Contains("Guard"))
                                                            {
                                                                if (monster.MonsterInfo.InStig == 0)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InStig = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InStig == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                            return;
                                                                        }

                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                {
                                                                                    if (distance < ServerBase.Constants.pScreenDistance)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;

                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        monster.MonsterInfo.InStig = 0;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                        if (!monster.Move(facing))
                                                                                        {
                                                                                            facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                            if (monster.Move(facing))
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.Facing = facing;
                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                            move.Direction = facing;
                                                                                            move.UID = monster.UID;
                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                            #endregion
                                                        }
                                                        else
                                                        {
                                                            Remove(obj);
                                                        }
                                                    }
                                                        #endregion
                                                }
                                            }
                                            #endregion
                                        }
                                    }
                                }
                            }
                            if (obj.MapObjType == MapObjectType.Item)
                            {
                                Network.GamePackets.FloorItem item = obj as Network.GamePackets.FloorItem;
                                if (item.Type != Network.GamePackets.FloorItem.Effect)
                                {
                                    if (Time32.Now > item.OnFloor.AddSeconds(ServerBase.Constants.FloorItemSeconds))
                                    {
                                        item.Type = Network.GamePackets.FloorItem.Remove;
                                        foreach (Interfaces.IMapObject _obj in Objects)
                                        {
                                            if (_obj != null)
                                            {
                                                if (_obj.MapObjType == MapObjectType.Player)
                                                {
                                                    (_obj as Entity).Owner.Send(item);
                                                }
                                            }
                                        }
                                        Owner.Map.Floor[item.X, item.Y, MapObjectType.Item, null] = true;
                                        Remove(obj);
                                    }
                                }
                                else
                                {
                                    // Console.WriteLine("zaza");
                                    item.Type = Network.GamePackets.FloorItem.Effect;
                                    foreach (Interfaces.IMapObject _obj in Objects)
                                    {
                                        if (_obj != null)
                                        {
                                            if (_obj.MapObjType == MapObjectType.Player)
                                            {
                                                (_obj as Entity).Owner.Send(item);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e) { Program.SaveException(e); }

               /* foreach (IMapObject obj in toRemove)
                    Remove(obj);*/

                #endregion
            }
            catch { /*Console.WriteLine(e.ToString()); Console.WriteLine("erorrr screnn timer");*/ }
        }