public Reincarnation(Client.GameState client, byte new_class)
        {
            if (client.Entity.Level < 130)
                return;
            _client = client;
            RemoveSkill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(500);
            Addskill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(500);
            #region Low level items
            for (byte i = 1; i < 9; i++)
            {
                if (i != 7)
                {
                    Interfaces.IConquerItem item = client.Equipment.TryGetItem(i);
                    if (item != null && item.ID != 0)
                    {
                        try

                        {
                            //client.UnloadItemStats(item, false);
                            Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                            item.ID = cii.LowestID(Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                            item.Send(client);
                            client.LoadItemStats(client.Entity);
                            Database.ConquerItemTable.UpdateItemID(item, client);
                        }
                        catch
                        {
                            Console.WriteLine("Reborn item problem: " + item.ID);
                        }
                    }
                }
            }
            Interfaces.IConquerItem hand = client.Equipment.TryGetItem(5);
            if (hand != null)
            {
                client.Equipment.Remove(5);
                client.CalculateStatBonus();
                client.CalculateHPBonus();
                client.SendStatMessage();
            }
            else
                //client.Screen.send(client.Entity.SpawnPacket, false);
            #endregion

            #region Remove Extra Skill
            if (client.Entity.FirstRebornClass == 15 && client.Entity.SecondRebornClass == 15 && client.Entity.Class == 15)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.DragonWhirl);
            }
            if (client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25 && client.Entity.Class == 25)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.Perseverance);
            }
            if (client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45 && client.Entity.Class == 45)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.StarArrow);
            }
            if (client.Entity.FirstRebornClass == 55 && client.Entity.SecondRebornClass == 55 && client.Entity.Class == 55)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.PoisonStar);
            }
            if (client.Entity.FirstRebornClass == 65 && client.Entity.SecondRebornClass == 65 && client.Entity.Class == 65)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.SoulShackle);
            }
            if (client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135 && client.Entity.Class == 135)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.AzureShield);
            }
            if (client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145 && client.Entity.Class == 145)
            {
                WontAdd(PhoenixProject.Game.Enums.SkillIDs.HeavenBlade);
            }
            #endregion
            Database.ReincarnationTable.NewReincarnated(client.Entity);
            Game.Features.Reincarnation.ReincarnateInfo info = new Game.Features.Reincarnation.ReincarnateInfo();
            info.UID = client.Entity.UID;
            info.Level = client.Entity.Level;
            info.Experience = client.Entity.Experience;
            ServerBase.Kernel.ReincarnatedCharacters.Add(info.UID, info);
            client.Entity.FirstRebornClass = client.Entity.SecondRebornClass;
            client.Entity.SecondRebornClass = client.Entity.Class;
            client.Entity.Class = new_class;
            client.Entity.SecondRebornLevel = client.Entity.Level;
            client.Entity.Level = 15;
            client.Entity.Experience = 0;
            client.Entity.Atributes =
             (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornClass, client.Entity.FirstRebornLevel) +
              client.ExtraAtributePoints(client.Entity.SecondRebornClass, client.Entity.SecondRebornLevel) + 62);

            client.Spells.Clear();
            client.Spells = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(100);
            switch (client.Entity.FirstRebornClass)
            {
                case 15:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cyclone);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Hercules);
                        Add(PhoenixProject.Game.Enums.SkillIDs.SpiritHealing);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Robot);
                        break;
                    }
                case 25:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.SuperMan);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Dash);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Shield);
                        break;
                    }
                case 45:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Intensify);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Scatter);
                        Add(PhoenixProject.Game.Enums.SkillIDs.RapidFire);
                        Add(PhoenixProject.Game.Enums.SkillIDs.XPFly);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedFly);
                        break;
                    }
                case 55:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.FatalStrike);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ShurikenVortex);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ToxicFog);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TwofoldBlades);
                        Add(PhoenixProject.Game.Enums.SkillIDs.PoisonStar);

                        break;
                    }
                case 65:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 75:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 135:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WaterElf);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Volcano);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Pray);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedCure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Meditation);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Stigma);
                        break;
                    }
                case 140:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Tornado);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireCircle);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireMeteor);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireRing);
                        break;
                    }

            }

            byte PreviousClass = client.Entity.FirstRebornClass;
            byte toClass = (byte)(client.Entity.SecondRebornClass - 4);

            Interfaces.ISkill[] ADD_spells = this.Addskill.Values.ToArray();
            foreach (Interfaces.ISkill skill in ADD_spells)
            {
                skill.Available = true;
                if (!client.Spells.ContainsKey(skill.ID))
                    client.Spells.Add(skill.ID, skill);
            }
            #region Spells
            Interfaces.ISkill[] spells = client.Spells.Values.ToArray();
            foreach (Interfaces.ISkill spell in spells)
            {
                spell.PreviousLevel = spell.Level;
                spell.Level = 0;
                spell.Experience = 0;
                #region Pirate
                if (PreviousClass == 75)
                {
                    if (client.Entity.Class != 71)
                    {
                        switch (spell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Monk
                if (PreviousClass == 65)
                {
                    if (client.Entity.Class != 61)
                    {
                        switch (spell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Warrior
                if (PreviousClass == 25)
                {
                    if (client.Entity.Class != 21)
                    {
                        switch (spell.ID)
                        {
                            case 1025:
                                if (client.Entity.Class != 21 && client.Entity.Class != 132)
                                    client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Ninja
                if (toClass != 51)
                {
                    switch (spell.ID)
                    {
                        case 6010:
                        case 6000:
                        case 6011:
                            client.RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region Trojan
                if (toClass != 11)
                {
                    switch (spell.ID)
                    {
                        case 1115:
                            client.RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region Archer
                if (toClass != 41)
                {
                    switch (spell.ID)
                    {
                        case 8001:
                        case 8000:
                        case 8003:
                        case 9000:
                        case 8002:
                        case 8030:
                            client.RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region WaterTaoist
                if (PreviousClass == 135)
                {
                    if (toClass != 132)
                    {
                        switch (spell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1010:
                            case 1125:
                            case 1100:
                            case 8030:
                                client.RemoveSpell(spell);
                                break;
                            case 1050:
                            case 1175:
                            case 1170:
                                if (toClass != 142)
                                    client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region FireTaoist
                if (PreviousClass == 145)
                {
                    if (toClass != 142)
                    {
                        switch (spell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1150:
                            case 1180:
                            case 1120:
                            case 1002:
                            case 1160:
                            case 1165:
                                client.RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                if (client.Spells.ContainsKey(spell.ID))
                    if (spell.ID != (ushort)Game.Enums.SkillIDs.Reflect)
                        spell.Send(client);
            }
            #endregion
            Add(PhoenixProject.Game.Enums.SkillIDs.Bless);

            Addskill.Clear();
            Addskill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(100);

            PreviousClass = client.Entity.SecondRebornClass;
            toClass = client.Entity.Class;
            switch (client.Entity.SecondRebornClass)
            {
                case 15:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Robot);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cyclone);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Hercules);
                        Add(PhoenixProject.Game.Enums.SkillIDs.SpiritHealing);

                        break;
                    }
                case 25:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.SuperMan);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Dash);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Shield);
                        break;
                    }
                case 45:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Intensify);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Scatter);
                        Add(PhoenixProject.Game.Enums.SkillIDs.RapidFire);
                        Add(PhoenixProject.Game.Enums.SkillIDs.XPFly);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedFly);
                        break;
                    }
                case 55:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.FatalStrike);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ShurikenVortex);
                        Add(PhoenixProject.Game.Enums.SkillIDs.ToxicFog);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TwofoldBlades);
                        break;
                    }
                case 65:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 75:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.RadiantPalm);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WhirlWindKick);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TripleAttack);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Oblivion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Serenity);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Compassion);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.TyrantAura);
                        Add(PhoenixProject.Game.Enums.SkillIDs.DeflectionAura);
                        break;
                    }
                case 135:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.WaterElf);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Volcano);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Pray);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Stigma);
                        Add(PhoenixProject.Game.Enums.SkillIDs.AdvancedCure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Meditation);
                        break;
                    }
                case 140:
                    {
                        Add(PhoenixProject.Game.Enums.SkillIDs.Thunder);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Cure);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Lightning);
                        Add(PhoenixProject.Game.Enums.SkillIDs.Tornado);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireCircle);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireMeteor);
                        Add(PhoenixProject.Game.Enums.SkillIDs.FireRing);
                        break;
                    }

            }

            //PreviousClass = client.Entity.FirstRebornClass;
            //toClass = client.Entity.SecondRebornClass;
            Add(PhoenixProject.Game.Enums.SkillIDs.Bless);

            Interfaces.ISkill[] aADD_spells = this.Addskill.Values.ToArray();
            foreach (Interfaces.ISkill skill in aADD_spells)
            {
                skill.Available = true;
                if (!client.Spells.ContainsKey(skill.ID))
                    client.Spells.Add(skill.ID, skill);
            }
            #region Spells
            Interfaces.ISkill[] aspells = client.Spells.Values.ToArray();
            foreach (Interfaces.ISkill aspell in spells)
            {
                aspell.PreviousLevel = aspell.Level;
                aspell.Level = 0;
                aspell.Experience = 0;
                #region Pirate
                if (PreviousClass == 75)
                {
                    if (client.Entity.Class != 71)
                    {
                        switch (aspell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region Monk
                if (PreviousClass == 65)
                {
                    if (client.Entity.Class != 61)
                    {
                        switch (aspell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region Warrior
                if (PreviousClass == 25)
                {
                    if (client.Entity.Class != 21)
                    {
                        switch (aspell.ID)
                        {
                            case 1025:
                                if (client.Entity.Class != 21 && client.Entity.Class != 132)
                                    client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region Ninja
                if (toClass != 51)
                {
                    switch (aspell.ID)
                    {
                        case 6010:
                        case 6000:
                        case 6011:
                            client.RemoveSpell(aspell);
                            break;
                    }
                }
                #endregion
                #region Trojan
                if (toClass != 11)
                {
                    switch (aspell.ID)
                    {
                        case 1115:
                            client.RemoveSpell(aspell);
                            break;
                    }
                }
                #endregion
                #region Archer
                if (toClass != 41)
                {
                    switch (aspell.ID)
                    {
                        case 8001:
                        case 8000:
                        case 8003:
                        case 9000:
                        case 8002:
                        case 8030:
                            client.RemoveSpell(aspell);
                            break;
                    }
                }
                #endregion
                #region WaterTaoist
                if (PreviousClass == 135)
                {
                    if (toClass != 132)
                    {
                        switch (aspell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1010:
                            case 1125:
                            case 1100:
                            case 8030:
                                client.RemoveSpell(aspell);
                                break;
                            case 1050:
                            case 1175:
                            case 1170:
                                if (toClass != 142)
                                    client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                #region FireTaoist
                if (PreviousClass == 145)
                {
                    if (toClass != 142)
                    {
                        switch (aspell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1150:
                            case 1180:
                            case 1120:
                            case 1002:
                            case 1160:
                            case 1165:
                                client.RemoveSpell(aspell);
                                break;
                        }
                    }
                }
                #endregion
                if (client.Spells.ContainsKey(aspell.ID))
                    if (aspell.ID != (ushort)Game.Enums.SkillIDs.Reflect)
                        aspell.Send(client);
            }
            #endregion
            Addskill.Clear();
            Addskill = new SafeDictionary<ushort, PhoenixProject.Interfaces.ISkill>(20);
            #region Add Extra Skill
            if (client.Entity.FirstRebornClass == 15 && client.Entity.SecondRebornClass == 15 && client.Entity.Class == 11)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.DragonWhirl);
            }
            if (client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25 && client.Entity.Class == 21)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.Perseverance);
            }
            if (client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45 && client.Entity.Class == 41)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.StarArrow);
            }
            if (client.Entity.FirstRebornClass == 55 && client.Entity.SecondRebornClass == 55 && client.Entity.Class == 55)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.PoisonStar);
                Add(PhoenixProject.Game.Enums.SkillIDs.CounterKill);
            }
            if (client.Entity.FirstRebornClass == 65 && client.Entity.SecondRebornClass == 65 && client.Entity.Class == 61)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.SoulShackle);
            }
            if (client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135 && client.Entity.Class == 132)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.AzureShield);
            }
            if (client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145 && client.Entity.Class == 142)
            {
                Add(PhoenixProject.Game.Enums.SkillIDs.HeavenBlade);
            }
            #endregion
            Interfaces.ISkill[] aaADD_spells = this.Addskill.Values.ToArray();
            foreach (Interfaces.ISkill skill in aaADD_spells)
            {
                skill.Available = true;
                if (!client.Spells.ContainsKey(skill.ID))
                    client.Spells.Add(skill.ID, skill);
            }

            #region Proficiencies
            foreach (Interfaces.ISkill proficiency in client.Proficiencies.Values)
            {
                proficiency.PreviousLevel = proficiency.Level;
                proficiency.Level = 0;
                proficiency.Experience = 0;
                proficiency.Send(client);
            }
            #endregion
            Database.DataHolder.GetStats(client.Entity.Class, client.Entity.Level, client);
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.GemAlgorithm();
            client.SendStatMessage();
            Network.PacketHandler.WorldMessage(client.Entity.Name + " has got Reincarnation! Congratulations!");
        }
        public void UnloadItemStats(Interfaces.IConquerItem item, bool onPurpose)
        {
            if (item == null) return;

            if (item.Durability == 0 && !onPurpose)
                return;
            if (item.Position == ConquerItem.Garment)
                return;
            Database.ConquerItemInformation Infos = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
            if (Infos.BaseInformation == null)
                return;

            if (item.Position == ConquerItem.Tower)
            {
                Entity.PhysicalDamageDecrease -= Infos.BaseInformation.PhysicalDefence;
                Entity.MagicDamageDecrease -= Infos.BaseInformation.MagicDefence;
            }
            else
            {
                Entity.Defence -= Infos.BaseInformation.PhysicalDefence;
                Entity.MagicDefencePercent -= Infos.BaseInformation.MagicDefence;
                Entity.Dodge -= (byte)Infos.BaseInformation.Dodge;
                if (item.Position != ConquerItem.Fan)
                    Entity.BaseMagicAttack -= Infos.BaseInformation.MagicAttack;
            }

            Entity.ItemHP -= Infos.BaseInformation.ItemHP;
            Entity.ItemMP -= Infos.BaseInformation.ItemMP;
            Entity.ItemBless -= item.Bless;
            if (item.Position == ConquerItem.RightWeapon)
            {
                Entity.AttackRange -= Infos.BaseInformation.AttackRange;
                if (Network.PacketHandler.IsTwoHand(Infos.BaseInformation.ID))
                    Entity.AttackRange -= 2;
            }
            if (item.Position == ConquerItem.LeftWeapon)
            {
                Entity.BaseMinAttack -= (uint)(Infos.BaseInformation.MinAttack * 0.5F);
                Entity.BaseMaxAttack -= (uint)(Infos.BaseInformation.MaxAttack * 0.5F);
            }
            else if (item.Position == ConquerItem.Fan)
            {
                Entity.PhysicalDamageIncrease -= Infos.BaseInformation.MinAttack;
                Entity.MagicDamageIncrease -= Infos.BaseInformation.MagicAttack;
            }
            else
            {
                Entity.BaseMinAttack -= Infos.BaseInformation.MinAttack;
                Entity.BaseMaxAttack -= Infos.BaseInformation.MaxAttack;
            }
            if (item.Plus != 0)
            {
                if (item.Position == ConquerItem.Tower)
                {
                    Entity.PhysicalDamageDecrease -= Infos.PlusInformation.PhysicalDefence;
                    Entity.MagicDamageDecrease -= (ushort)Infos.PlusInformation.MagicDefence;
                }
                else if (item.Position == ConquerItem.Fan)
                {
                    Entity.PhysicalDamageIncrease -= (ushort)Infos.PlusInformation.MinAttack;
                    Entity.MagicDamageIncrease -= (ushort)Infos.PlusInformation.MagicAttack;
                }
                else
                {
                    if (item.Position == ConquerItem.Steed)
                        Entity.ExtraVigor -= Infos.PlusInformation.Agility;
                    Entity.BaseMinAttack -= Infos.PlusInformation.MinAttack;
                    Entity.BaseMaxAttack -= Infos.PlusInformation.MaxAttack;
                    Entity.BaseMagicAttack -= Infos.PlusInformation.MagicAttack;
                    Entity.Defence -= Infos.PlusInformation.PhysicalDefence;
                    Entity.MagicDefence -= Infos.PlusInformation.MagicDefence;
                    Entity.ItemHP -= Infos.PlusInformation.ItemHP;
                    if (item.Position == ConquerItem.Boots)
                        Entity.Dodge -= (byte)Infos.PlusInformation.Dodge;
                }
            }
            byte socketone = (byte)item.SocketOne;
            byte sockettwo = (byte)item.SocketTwo;
            ushort madd = 0, dadd = 0, aatk = 0, matk = 0;
            if (item.Position != ConquerItem.Garment &&
                item.Position != ConquerItem.Bottle &&
                item.Position != ConquerItem.Steed)
                switch (socketone)
                {
                    case 1: Entity.PhoenixGem += 5; break;
                    case 2: Entity.PhoenixGem += 10; break;
                    case 3: Entity.PhoenixGem += 15; break;

                    case 11: Entity.DragonGem += 5; break;
                    case 12: Entity.DragonGem += 10; break;
                    case 13: Entity.DragonGem += 15; break;

                    case 71: Entity.TortisGem += 15; break;
                    case 72: Entity.TortisGem += 30; break;
                    case 73: Entity.TortisGem += 50; break;

                    case 101: aatk = matk += 100; break;
                    case 102: aatk = matk += 300; break;
                    case 103: aatk = matk += 500; break;

                    case 121: madd = dadd += 100; break;
                    case 122: madd = dadd += 300; break;
                    case 123: madd = dadd += 500; break;
                }
            if (item.Position != ConquerItem.Garment &&
                 item.Position != ConquerItem.Bottle &&
                 item.Position != ConquerItem.Steed)
                switch (sockettwo)
                {
                    case 1: Entity.PhoenixGem += 5; break;
                    case 2: Entity.PhoenixGem += 10; break;
                    case 3: Entity.PhoenixGem += 15; break;

                    case 11: Entity.DragonGem += 5; break;
                    case 12: Entity.DragonGem += 10; break;
                    case 13: Entity.DragonGem += 15; break;

                    case 71: Entity.TortisGem += 15; break;
                    case 72: Entity.TortisGem += 30; break;
                    case 73: Entity.TortisGem += 50; break;

                    case 101: aatk = matk += 100; break;
                    case 102: aatk = matk += 300; break;
                    case 103: aatk = matk += 500; break;

                    case 121: madd = dadd += 100; break;
                    case 122: madd = dadd += 300; break;
                    case 123: madd = dadd += 500; break;
                }
            Entity.PhysicalDamageDecrease -= dadd;
            Entity.MagicDamageDecrease -= madd;
            Entity.PhysicalDamageIncrease -= aatk;
            Entity.MagicDamageIncrease -= matk;
            if (item.Position != ConquerItem.Garment &&
                item.Position != ConquerItem.Bottle)
            {
                Entity.ItemHP -= item.Enchant;
                GemAlgorithm();
            }
        }
        void doIt()
        {
            #region Reincarnate
            Database.ReincarnationTable.NewReincarnated(Entity);
            Game.Features.Reincarnation.ReincarnateInfo info = new Game.Features.Reincarnation.ReincarnateInfo();
            info.UID = Entity.UID;
            info.Level = Entity.Level;
            info.Experience = Entity.Experience;
            ServerBase.Kernel.ReincarnatedCharacters.Add(info.UID, info);
            Entity.FirstRebornClass = First;
            Entity.SecondRebornClass = Second;
            Entity.Class = Class;
            Entity.Atributes = 182;
            Entity.Level = 15;
            Entity.Experience = 0;
            #endregion
            #region Low level items
            for (byte i = 1; i < 9; i++)
            {
                if (i != 7)
                {
                    Interfaces.IConquerItem item = Entity.Owner.Equipment.TryGetItem(i);
                    if (item != null && item.ID != 0)
                    {
                        try
                        {
                            UnloadItemStats(item, false);
                            Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                            item.ID = cii.LowestID(Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                            item.Send(Entity.Owner);
                            LoadItemStats(item);
                            Database.ConquerItemTable.UpdateItemID(item, Entity.Owner);
                        }
                        catch
                        {
                            Console.WriteLine("Reborn item problem: " + item.ID);
                        }
                    }
                }
            }
            Interfaces.IConquerItem hand = Entity.Owner.Equipment.TryGetItem(5);
            if (hand != null)
            {
                Entity.Owner.Equipment.Remove(5);
                CalculateStatBonus();
                CalculateHPBonus();
                Entity.Owner.Screen.Reload(null);
            }
            else
                Entity.Owner.SendScreen(Entity.Owner.Entity.SpawnPacket, false);
            #endregion

            foreach (Interfaces.ISkill s in Skills)
                Entity.Owner.Spells.Remove(s.ID);

            switch (First)
            {
                #region Trojan
                case 15:
                    {
                        switch (Second)
                        {
                            case 11:
                                Add(Enums.SkillIDs.CruelShade);
                                break;
                            default: WontAdd(Enums.SkillIDs.Accuracy); break;
                        }
                        break;
                    }
                #endregion
                #region Warrior
                case 25:
                    {
                        switch (Second)
                        {
                            case 11:
                                Add(Enums.SkillIDs.IronShirt);
                                WontAdd(Enums.SkillIDs.Shield);
                                WontAdd(Enums.SkillIDs.SuperMan);
                                break;
                            case 21:
                                Add(Enums.SkillIDs.Reflect);
                                break;
                            case 132:
                                WontAdd(Enums.SkillIDs.FlyingMoon);
                                WontAdd(Enums.SkillIDs.Shield);
                                break;
                            case 142:
                                WontAdd(Enums.SkillIDs.Accuracy);
                                WontAdd(Enums.SkillIDs.FlyingMoon);
                                WontAdd(Enums.SkillIDs.SuperMan);
                                break;
                            default:
                                WontAdd(Enums.SkillIDs.Accuracy);
                                WontAdd(Enums.SkillIDs.FlyingMoon);
                                WontAdd(Enums.SkillIDs.SuperMan);
                                WontAdd(Enums.SkillIDs.Shield);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Archer
                case 45:
                    {
                        switch (Second)
                        {
                            case 41: break;
                            default:
                                WontAdd(Enums.SkillIDs.Scatter);
                                WontAdd(Enums.SkillIDs.XPFly);
                                WontAdd(Enums.SkillIDs.AdvancedFly);
                                WontAdd(Enums.SkillIDs.ArrowRain);
                                WontAdd(Enums.SkillIDs.Intensify);
                                WontAdd(Enums.SkillIDs.RapidFire);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Ninja
                case 55:
                    {
                        switch (Second)
                        {
                            case 51: break;
                            default:
                                WontAdd(Enums.SkillIDs.PoisonStar);
                                WontAdd(Enums.SkillIDs.ShurikenVortex);
                                WontAdd(Enums.SkillIDs.FatalStrike);
                                WontAdd(Enums.SkillIDs.TwofoldBlades);
                                WontAdd(Enums.SkillIDs.ArcherBane);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Monk
                case 65:
                    {
                        switch (Second)
                        {
                            case 61: break;
                            default:
                                WontAdd(Enums.SkillIDs.Oblivion);
                                WontAdd(Enums.SkillIDs.RadiantPalm);
                                WontAdd(Enums.SkillIDs.TyrantAura);
                                WontAdd(Enums.SkillIDs.DeathBlow);
                                WontAdd(Enums.SkillIDs.DeflectionAura);
                                WontAdd(Enums.SkillIDs.TripleAttack);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Water
                case 135:
                    {
                        switch (Second)
                        {
                            case 132: Add(Enums.SkillIDs.Pervade); break;
                            case 142:
                                WontAdd(Enums.SkillIDs.Nectar);
                                WontAdd(Enums.SkillIDs.HealingRain);
                                break;
                            default:
                                WontAdd(Enums.SkillIDs.Nectar);
                                WontAdd(Enums.SkillIDs.Lightning);
                                WontAdd(Enums.SkillIDs.Volcano);
                                WontAdd(Enums.SkillIDs.AdvancedCure);
                                WontAdd(Enums.SkillIDs.SpeedLightning);
                                WontAdd(Enums.SkillIDs.HealingRain);
                                break;
                        }
                        break;
                    }
                #endregion
                #region Fire
                case 145:
                    {
                        switch (Second)
                        {
                            case 142: Add(Enums.SkillIDs.Dodge); break;
                            default:
                                if (Second != 132)
                                    WontAdd(Enums.SkillIDs.FireCircle);

                                WontAdd(Enums.SkillIDs.Tornado);
                                WontAdd(Enums.SkillIDs.FireMeteor);
                                WontAdd(Enums.SkillIDs.FireOfHell);
                                WontAdd(Enums.SkillIDs.FireRing);
                                WontAdd(Enums.SkillIDs.Volcano);
                                WontAdd(Enums.SkillIDs.Lightning);
                                WontAdd(Enums.SkillIDs.SpeedLightning);
                                break;
                        }
                        break;
                    }
                #endregion
            }

            Add(Enums.SkillIDs.Bless);

            #region Re-Learn Profs
            foreach (Interfaces.IProf Prof in Profs)
            {
                if (Prof == null)
                    continue;

                Prof.Available = false;
                Prof.PreviousLevel = Prof.Level;
                Prof.Level = 0;
                Prof.Experience = 0;
                Entity.Owner.Proficiencies.Add(Prof.ID, Prof);
                Prof.Send(Entity.Owner);
            }
            #endregion
            #region Re-Learn Skills
            foreach (Interfaces.ISkill Skill in Skills)
            {
                if (Skill == null)
                    continue;

                Skill.Available = false;
                Skill.PreviousLevel = Skill.Level;
                Skill.Level = 0;
                Skill.Experience = 0;

                if (!WontLearn.ContainsKey(Skill.ID))
                {
                    Entity.Owner.Spells.Add(Skill.ID, Skill);
                    Skill.Send(Entity.Owner);
                }
            }
            #endregion
            #region Learn Skills
            foreach (Interfaces.ISkill L in Learn.Values)
            {
                if (L == null)
                    continue;

                L.Available = false;
                Entity.Owner.Spells.Add(L.ID, L);
                L.Send(Entity.Owner);
            }
            #endregion
            #region Remove Skills
            foreach (Interfaces.ISkill L in WontLearn.Values)
            {
                if (L == null)
                    continue;

                L.Available = false;
                Entity.Owner.Spells.Remove(L.ID);
                Database.SkillTable.DeleteSpell(Entity.Owner, L.ID);
                L.Send(Entity.Owner);
            }
            #endregion

            Database.DataHolder.GetStats(Entity.Class, Entity.Level, Entity.Owner);
            Entity.Owner.CalculateStatBonus();
            Entity.Owner.CalculateHPBonus();

                Database.SkillTable.SaveProficiencies(Entity.Owner);
                Database.SkillTable.SaveSpells(Entity.Owner);

            ServerBase.Kernel.SendWorldMessage(new PhoenixProject.Network.GamePackets.Message("Congratulations, " + Entity.Name + " reincarnated!", System.Drawing.Color.White, Network.GamePackets.Message.TopLeft), ServerBase.Kernel.GamePool.Values);
        }
        static void HandleBuyFromNPC(ItemUsage itemUsage, Client.GameState client)
        {
            if (client.Trade.InTrade)
                return;
            if (client.Entity.MapID == 3031)
                return;
            if (itemUsage == null)
                return;
            if (client == null)
                return;
            Interfaces.INpc npc = null;
            if (client.Map.Npcs.TryGetValue(itemUsage.UID, out npc) || itemUsage.UID == 2888 || itemUsage.UID == 6000)
            {
                Interfaces.IConquerItem _ExistingItem;
                Database.ConquerItemInformation iteminfo = new PhoenixProject.Database.ConquerItemInformation(itemUsage.dwParam, 0);

                if (client.Inventory.Count == 40 && !client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
                    return;
                if (itemUsage.UID != 2888 && itemUsage.UID != 6000)
                    if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, npc.X, npc.Y) > 17)
                        return;
                Database.ShopFile.Shop shop = new PhoenixProject.Database.ShopFile.Shop();

                if (Database.ShopFile.Shops.TryGetValue(itemUsage.UID, out shop))
                {
                    if (shop.UID == 0)
                        return;
                    if (shop.UID != 6000 && shop.UID != 6001)
                    {
                        if (!shop.Items.Contains(itemUsage.dwParam))
                        { Console.WriteLine("Error! Cannot puchase item ID: " + itemUsage.dwParam + " from shop ID: " + itemUsage.UID); return; }
                    }
                    else
                    {
                        if (shop.UID == 6000)
                        {
                            if (!shop.HonorShopItems.ContainsKey(itemUsage.dwParam))
                            {
                                return;
                            }
                        }
                        else
                        {
                            if (shop.UID == 6001)
                            {
                                if (!shop.SteedShops.ContainsKey(itemUsage.dwParam))
                                {
                                    return;
                                }
                            }
                        }
                    }

                    uint Amount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;

                    Interfaces.IConquerItem item = new ConquerItem(true);

                    switch (shop.MoneyType)
                    {
                        case Database.ShopFile.MoneyType.HonorPoints:
                            {

                                Database.ShopFile.Shop.HonorShopItem hshopi;
                                if (shop.HonorShopItems.TryGetValue(itemUsage.dwParam, out hshopi))
                                {
                                    if (client.ArenaStatistic != null)
                                    {
                                        if (client.Inventory.Count <= 39)
                                        {
                                            if (client.ArenaStatistic.CurrentHonor >= hshopi.cost)
                                            {
                                                Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                                newItem.ID = itemUsage.dwParam;
                                                Database.ConquerItemBaseInformation ibi;
                                                if (Database.ConquerItemInformation.BaseInformations.TryGetValue(newItem.ID, out ibi))
                                                {
                                                    if (ibi.Durability > 0)
                                                    {
                                                        newItem.Durability = ibi.Durability;
                                                        newItem.MaximDurability = ibi.Durability;
                                                    }
                                                }
                                                client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                Data data = new Data(true);
                                                data.ID = GamePackets.Data.OpenCustom;
                                                data.UID = client.Entity.UID;
                                                data.TimeStamp = Time32.Now;
                                                data.dwParam = 3382;
                                                data.wParam1 = client.Entity.X;
                                                data.wParam2 = client.Entity.Y;
                                                client.Send(data);
                                                client.ArenaStatistic.CurrentHonor -= hshopi.cost;
                                                client.ArenaStatistic.Send(client);

                                            }
                                            else client.Send(new Message("You do not have enough Honor Points", Color.Red, Message.TopLeft));
                                        }
                                        else client.Send(new Message("You do not have enough space in your inventory", Color.Red, Message.TopLeft));
                                    }
                                }
                                else client.Send(new Message("Can not find this item", Color.Red, Message.TopLeft));
                                break;

                            }
                        case Database.ShopFile.MoneyType.RaceShop:
                            {

                                Database.ShopFile.Shop.SteedShop hshopi;
                                if (shop.SteedShops.TryGetValue(itemUsage.dwParam, out hshopi))
                                {
                                    if (client.Entity.RacePoints >= hshopi.cost)
                                    {
                                        if (client.Inventory.Count <= 39)
                                        {
                                            if (client.Entity.RacePoints >= hshopi.cost)
                                            {
                                                Interfaces.IConquerItem newItem = new GamePackets.ConquerItem(true);
                                                newItem.ID = itemUsage.dwParam;
                                                Database.ConquerItemBaseInformation ibi;
                                                if (Database.ConquerItemInformation.BaseInformations.TryGetValue(newItem.ID, out ibi))
                                                {
                                                    if (ibi.Durability > 0)
                                                    {
                                                        newItem.Durability = ibi.Durability;
                                                        newItem.MaximDurability = ibi.Durability;
                                                    }
                                                }
                                                client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                Data data = new Data(true);
                                                data.ID = GamePackets.Data.OpenCustom;
                                                data.UID = client.Entity.UID;
                                                data.TimeStamp = Time32.Now;
                                                data.dwParam = 3382;
                                                data.wParam1 = client.Entity.X;
                                                data.wParam2 = client.Entity.Y;
                                                client.Send(data);
                                                client.Entity.RacePoints -= hshopi.cost;
                                            }
                                            else client.Send(new Message("You do not have enough Race Points", Color.Red, Message.TopLeft));
                                        }
                                        else client.Send(new Message("You do not have enough space in your inventory", Color.Red, Message.TopLeft));
                                    }
                                }
                                else client.Send(new Message("Can not find this item", Color.Red, Message.TopLeft));
                                break;

                            }
                        case PhoenixProject.Database.ShopFile.MoneyType.Gold:
                            {
                                if (iteminfo.BaseInformation.GoldWorth * Amount > client.Entity.Money)
                                    return;
                                if (client.Entity.Money - (iteminfo.BaseInformation.GoldWorth * Amount) > client.Entity.Money)
                                    return;
                                item.ID = itemUsage.dwParam;
                                item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                item.Color = (PhoenixProject.Game.Enums.Color)3;

                                uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                                while (NewAmount > 0)
                                {
                                    if (client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
                                    {
                                        if (_ExistingItem.StackSize == 0)
                                            _ExistingItem.StackSize = 1;

                                        ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                        _StackCount -= (ushort)_ExistingItem.StackSize;

                                        if (_StackCount >= NewAmount)
                                            _StackCount = (ushort)NewAmount;
                                        _ExistingItem.StackSize += _StackCount;

                                        Database.ConquerItemTable.UpdateStack(_ExistingItem);
                                        _ExistingItem.Mode = Game.Enums.ItemMode.Update;
                                        _ExistingItem.Send(client);
                                        _ExistingItem.Mode = Game.Enums.ItemMode.Default;
                                        NewAmount -= _StackCount;
                                        Data data = new Data(true);
                                        data.ID = GamePackets.Data.OpenCustom;
                                        data.UID = client.Entity.UID;
                                        data.TimeStamp = Time32.Now;
                                        data.dwParam = 3382;
                                        data.wParam1 = client.Entity.X;
                                        data.wParam2 = client.Entity.Y;
                                        client.Send(data);

                                        //uint _TotalItemStacks = Math.Min(1, (itemUsage.dwExtraInfo / iteminfo.BaseInformation.StackSize));
                                    }
                                    else
                                    {
                                        if (iteminfo.BaseInformation.StackSize > 1 && itemUsage.dwExtraInfo > 1)
                                        {
                                            item = new ConquerItem(true);
                                            item.ID = itemUsage.dwParam;
                                            item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                            item.Color = (PhoenixProject.Game.Enums.Color)3;
                                            ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                            if (NewAmount <= iteminfo.BaseInformation.StackSize)
                                                _StackCount = (ushort)NewAmount;
                                            item.StackSize = (ushort)_StackCount;
                                            client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                            Database.ConquerItemTable.UpdateStack(item);
                                            NewAmount -= _StackCount;
                                            Data data = new Data(true);
                                            data.ID = GamePackets.Data.OpenCustom;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = 3382;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);
                                        }
                                        else
                                        {
                                            item = new ConquerItem(true);
                                            item.ID = itemUsage.dwParam;
                                            item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                            item.Color = (PhoenixProject.Game.Enums.Color)3;
                                            item.StackSize = 1;
                                            client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                            NewAmount--;
                                            Data data = new Data(true);
                                            data.ID = GamePackets.Data.OpenCustom;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = 3382;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);
                                        }
                                    }
                                }
                                client.Entity.Money -= (iteminfo.BaseInformation.GoldWorth * Amount);

                                //if (Amount > 1 && canMakeStack)
                                //{
                                //    item.StackSize = (ushort)Amount > 5 ? (ushort)5 : (ushort)Amount;
                                //    item.MaxStackSize = 5;
                                //    Amount -= (uint)item.StackSize - 1;
                                //    Database.ConquerItemTable.UpdateStack(item);
                                //}
                                //client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                //if (client.Inventory.ContainsUID(item.UID))
                                //    if (canMakeStack)
                                //        client.Entity.Money -= iteminfo.BaseInformation.GoldWorth * Amount;
                                //    else
                                //        client.Entity.Money -= iteminfo.BaseInformation.GoldWorth;
                                //        //Database.EntityTable.UpdateMoney(client);
                                break;
                            }
                        case PhoenixProject.Database.ShopFile.MoneyType.ConquerPoints:
                            {

                                if (itemUsage.dwExtraInfo3 == 1)
                                {
                                    if (iteminfo.BaseInformation.ConquerPointsWorth * Amount > client.Entity.ConquerPoints)
                                        return;
                                    if (client.Entity.ConquerPoints - (iteminfo.BaseInformation.ConquerPointsWorth * Amount) > client.Entity.ConquerPoints)
                                        return;
                                    item.ID = itemUsage.dwParam;
                                    if (item.ID % 730000 <= 12)
                                        item.Plus = (Byte)(item.ID % 730000);
                                    item.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                    uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                                    while (NewAmount > 0)
                                    {
                                        if (client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
                                        {
                                            if (_ExistingItem.StackSize == 0)
                                                _ExistingItem.StackSize = 1;

                                            ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                            _StackCount -= (ushort)_ExistingItem.StackSize;

                                            if (_StackCount >= NewAmount)
                                                _StackCount = (ushort)NewAmount;
                                            _ExistingItem.StackSize += _StackCount;

                                            Database.ConquerItemTable.UpdateStack(_ExistingItem);
                                            _ExistingItem.Mode = Game.Enums.ItemMode.Update;
                                            _ExistingItem.Send(client);
                                            _ExistingItem.Mode = Game.Enums.ItemMode.Default;
                                            NewAmount -= _StackCount;
                                            Data data = new Data(true);
                                            data.ID = GamePackets.Data.OpenCustom;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = 3382;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);

                                            //uint _TotalItemStacks = Math.Min(1, (itemUsage.dwExtraInfo / iteminfo.BaseInformation.StackSize));
                                        }
                                        else
                                        {
                                            if (iteminfo.BaseInformation.StackSize > 1 && itemUsage.dwExtraInfo > 1)
                                            {
                                                item = new ConquerItem(true);
                                                item.ID = itemUsage.dwParam;
                                                item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                item.Color = (PhoenixProject.Game.Enums.Color)3;
                                                ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                                if (NewAmount <= iteminfo.BaseInformation.StackSize)
                                                    _StackCount = (ushort)NewAmount;
                                                item.StackSize = (ushort)_StackCount;
                                                client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                Database.ConquerItemTable.UpdateStack(item);
                                                NewAmount -= _StackCount;
                                                Data data = new Data(true);
                                                data.ID = GamePackets.Data.OpenCustom;
                                                data.UID = client.Entity.UID;
                                                data.TimeStamp = Time32.Now;
                                                data.dwParam = 3382;
                                                data.wParam1 = client.Entity.X;
                                                data.wParam2 = client.Entity.Y;
                                                client.Send(data);
                                            }
                                            else
                                            {
                                                item = new ConquerItem(true);
                                                item.ID = itemUsage.dwParam;
                                                item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                item.Color = (PhoenixProject.Game.Enums.Color)3;
                                                item.StackSize = 1;
                                                if (item.ID == 730001)
                                                {
                                                    item.Plus = 1;
                                                }
                                                if (item.ID == 730002)
                                                {
                                                    item.Plus = 2;
                                                }
                                                if (item.ID == 730003)
                                                {
                                                    item.Plus = 3;
                                                }
                                                if (item.ID == 730004)
                                                {
                                                    item.Plus = 4;
                                                }
                                                if (item.ID == 730005)
                                                {
                                                    item.Plus = 5;
                                                }
                                                if (item.ID == 730006)
                                                {
                                                    item.Plus = 6;
                                                }
                                                if (item.ID == 730007)
                                                {
                                                    item.Plus = 7;
                                                }
                                                if (item.ID == 730008)
                                                {
                                                    item.Plus = 8;
                                                }
                                                if (item.ID == 730009)
                                                {
                                                    item.Plus = 9;
                                                }
                                                client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                NewAmount--;
                                                Data data = new Data(true);
                                                data.ID = GamePackets.Data.OpenCustom;
                                                data.UID = client.Entity.UID;
                                                data.TimeStamp = Time32.Now;
                                                data.dwParam = 3382;
                                                data.wParam1 = client.Entity.X;
                                                data.wParam2 = client.Entity.Y;
                                                client.Send(data);
                                            }
                                        }
                                    }
                                    client.Entity.ConquerPoints -= (iteminfo.BaseInformation.ConquerPointsWorth * Amount);
                                    break;
                                }
                                else
                                {
                                    ushort postion = ItemPosition(itemUsage.dwParam);
                                    if (ServerBase.Constants.AllowedBound.Contains(itemUsage.dwParam) || postion == ConquerItem.LeftWeaponAccessory || postion == ConquerItem.Garment)
                                    {
                                        if (iteminfo.BaseInformation.ConquerPointsWorth * Amount > client.Entity.BConquerPoints)
                                            return;
                                        if (client.Entity.BConquerPoints - (iteminfo.BaseInformation.ConquerPointsWorth * Amount) > client.Entity.BConquerPoints)
                                            return;
                                        item.ID = itemUsage.dwParam;
                                        if (item.ID % 730000 <= 12)
                                            item.Plus = (Byte)(item.ID % 730000);
                                        item.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                        item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                        item.Bound = true;
                                        uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                                        while (NewAmount > 0)
                                        {
                                            if (client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
                                            {
                                                if (_ExistingItem.StackSize == 0)
                                                    _ExistingItem.StackSize = 1;

                                                ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                                _StackCount -= (ushort)_ExistingItem.StackSize;

                                                if (_StackCount >= NewAmount)
                                                    _StackCount = (ushort)NewAmount;
                                                _ExistingItem.StackSize += _StackCount;

                                                Database.ConquerItemTable.UpdateStack(_ExistingItem);
                                                _ExistingItem.Mode = Game.Enums.ItemMode.Update;
                                                _ExistingItem.Send(client);
                                                _ExistingItem.Mode = Game.Enums.ItemMode.Default;
                                                NewAmount -= _StackCount;
                                                Data data = new Data(true);
                                                data.ID = GamePackets.Data.OpenCustom;
                                                data.UID = client.Entity.UID;
                                                data.TimeStamp = Time32.Now;
                                                data.dwParam = 3382;
                                                data.wParam1 = client.Entity.X;
                                                data.wParam2 = client.Entity.Y;
                                                client.Send(data);

                                                //uint _TotalItemStacks = Math.Min(1, (itemUsage.dwExtraInfo / iteminfo.BaseInformation.StackSize));
                                            }
                                            else
                                            {
                                                if (iteminfo.BaseInformation.StackSize > 1 && itemUsage.dwExtraInfo > 1)
                                                {
                                                    item = new ConquerItem(true);
                                                    item.ID = itemUsage.dwParam;
                                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                    item.Color = (PhoenixProject.Game.Enums.Color)3;
                                                    ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                                    if (NewAmount <= iteminfo.BaseInformation.StackSize)
                                                        _StackCount = (ushort)NewAmount;
                                                    item.StackSize = (ushort)_StackCount;
                                                    if (item.ID == 730001)
                                                    {
                                                        item.Plus = 1;
                                                    }
                                                    if (item.ID == 730002)
                                                    {
                                                        item.Plus = 2;
                                                    }
                                                    if (item.ID == 730003)
                                                    {
                                                        item.Plus = 3;
                                                    }
                                                    if (item.ID == 730004)
                                                    {
                                                        item.Plus = 4;
                                                    }
                                                    if (item.ID == 730005)
                                                    {
                                                        item.Plus = 5;
                                                    }
                                                    if (item.ID == 730006)
                                                    {
                                                        item.Plus = 6;
                                                    }
                                                    if (item.ID == 730007)
                                                    {
                                                        item.Plus = 7;
                                                    }
                                                    if (item.ID == 730008)
                                                    {
                                                        item.Plus = 8;
                                                    }
                                                    if (item.ID == 730009)
                                                    {
                                                        item.Plus = 9;
                                                    }
                                                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                    Database.ConquerItemTable.UpdateStack(item);
                                                    NewAmount -= _StackCount;
                                                    Data data = new Data(true);
                                                    data.ID = GamePackets.Data.OpenCustom;
                                                    data.UID = client.Entity.UID;
                                                    data.TimeStamp = Time32.Now;
                                                    data.dwParam = 3382;
                                                    data.wParam1 = client.Entity.X;
                                                    data.wParam2 = client.Entity.Y;
                                                    client.Send(data);
                                                }
                                                else
                                                {
                                                    item = new ConquerItem(true);
                                                    item.ID = itemUsage.dwParam;
                                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                    item.Color = (PhoenixProject.Game.Enums.Color)3;
                                                    item.StackSize = 1;
                                                    if (item.ID == 730001)
                                                    {
                                                        item.Plus = 1;
                                                    }
                                                    if (item.ID == 730002)
                                                    {
                                                        item.Plus = 2;
                                                    }
                                                    if (item.ID == 730003)
                                                    {
                                                        item.Plus = 3;
                                                    }
                                                    if (item.ID == 730004)
                                                    {
                                                        item.Plus = 4;
                                                    }
                                                    if (item.ID == 730005)
                                                    {
                                                        item.Plus = 5;
                                                    }
                                                    if (item.ID == 730006)
                                                    {
                                                        item.Plus = 6;
                                                    }
                                                    if (item.ID == 730007)
                                                    {
                                                        item.Plus = 7;
                                                    }
                                                    if (item.ID == 730008)
                                                    {
                                                        item.Plus = 8;
                                                    }
                                                    if (item.ID == 730009)
                                                    {
                                                        item.Plus = 9;
                                                    }
                                                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                    NewAmount--;
                                                    Data data = new Data(true);
                                                    data.ID = GamePackets.Data.OpenCustom;
                                                    data.UID = client.Entity.UID;
                                                    data.TimeStamp = Time32.Now;
                                                    data.dwParam = 3382;
                                                    data.wParam1 = client.Entity.X;
                                                    data.wParam2 = client.Entity.Y;
                                                    client.Send(data);
                                                }
                                            }
                                        }
                                        client.Entity.BConquerPoints -= (iteminfo.BaseInformation.ConquerPointsWorth * Amount);
                                        itemUsage.dwParam = 1;
                                        client.Send(itemUsage);
                                    }
                                    else
                                    {
                                        itemUsage.dwParam = 0;
                                        client.Send(itemUsage);
                                    }
                                    break;
                                }
                            }

                    }
                    Amount--;
                }
            }
        }
        static unsafe void HandlePacket(byte[] packet, Client.GameState client)
        {
            try
            {

                if (packet == null)
                    return;
                if (client == null)
                    return;
                fixed (byte* ptr = packet)
                {
                    var type = *((ushort*)(ptr + 2));
                    ushort Length = BitConverter.ToUInt16(packet, 0);
                    ushort ID = BitConverter.ToUInt16(packet, 2);

                    ushort ID2 = BitConverter.ToUInt16(packet, 4);
                    switch (ID)
                    {
                        #region Packet Spook Mob
                        case 2400:
                            {
                                client.Send(new NpcReply(NpcReply.MessageBox, "The Thrilling Spooks are sealed up, inside here Better speak to the Heavenly Master ,if you want more detalis"));
                                #region
                                client.OnMessageBoxOK =
                                delegate
                                {
                                    client.Entity.Teleport(8892, 28, 26);
                                };
                                client.OnMessageBoxCANCEL =
                                    delegate
                                    {
                                        client.OnMessageBoxEventParams = new object[0];
                                    };
                                #endregion

                                break;
                            }
                        #endregion
                        #region Arsenal [2201][2202][2203]
                        case 2202:
                            {
                                if (packet[16] == 0) packet[16] = 8;
                                client.Send(ArsenalPacket.ArsenalInscribedPage(client, packet, (PhoenixProject.Game.Features.Arsenal_ID)packet[16]));
                                break;
                            }
                        case 2203:
                            {
                                client.Send(ArsenalPacket.GuildArsenal(client));
                                if (client.Guild != null)
                                    if (client.Guild.Arsenal != null)
                                        client.Guild.Arsenal.Update(client.Guild);
                                byte pType = packet[4];
                                byte i_type = packet[8];
                                uint i_Uid = BitConverter.ToUInt32(packet, 12);

                                if (i_type == 0) i_type = 8;
                                switch (pType)
                                {
                                    case 0:
                                        {
                                            if (client.Guild != null)
                                                client.Guild.Arsenal.UnlockArsenal(client, (PhoenixProject.Game.Features.Arsenal_ID)i_type);
                                            break;
                                        }
                                    case 1:
                                        {
                                            PhoenixProject.Interfaces.IConquerItem Item = null;
                                            if (client.Inventory.TryGetItem(i_Uid, out Item))
                                            {
                                                if (client != null)
                                                {
                                                    if (Item != null)
                                                    {
                                                        if (i_type != 0 && i_type <= 8)
                                                        {
                                                            if (client.Guild != null)
                                                            {
                                                                if (client.Guild.Arsenal != null)
                                                                {
                                                                    client.Guild.Arsenal.InscribeItem(client, Item, (PhoenixProject.Game.Features.Arsenal_ID)i_type);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    case 2://Uninscribe
                                        {
                                            PhoenixProject.Game.Features.Arsenal_Client ac = null;
                                            if (client.Guild.Arsenal.Arsenals[(PhoenixProject.Game.Features.Arsenal_ID)i_type].Inscribed.TryGetValue(i_Uid, out ac))
                                                client.Guild.Arsenal.RemoveItem(client, ac.Item, (PhoenixProject.Game.Features.Arsenal_ID)i_type);
                                            break;
                                        }
                                    case 4:
                                        {
                                            client.Send(ArsenalPacket.GuildArsenal(client));
                                            break;
                                        }
                                }
                                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 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 PhoenixProject.Database.ConquerItemInformation(ItemAdd, 0);
                                                    Dictionary<uint, uint> amount = new Dictionary<uint, uint>();//packet[20]);
                                                    for (ushort i = 84; 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 -= (uint)add_cps;
                                                            foreach (uint key in amount.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.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, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                        }
                                                        client.Inventory.Add(ItemAdd, 0, 1);

                                                    }
                                                }
                                                break;
                                            }
                                        case 52:
                                            {
                                                var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                                item.Mode = PhoenixProject.Game.Enums.ItemMode.ChatItem;
                                                item.Send(client);
                                                break;
                                            }
                                        case 41:
                                            {
                                                // var item = Database.ConquerItemTable.LoadItem(usage.UID);
                                                usage.dwParam = 1;
                                                client.Send(usage);
                                                break;
                                            }
                                        case ItemUsage.SwitchEquipsBack:
                                        case ItemUsage.SwitchEquips:
                                            {
                                                client.AlternateEquipment = usage.ID == ItemUsage.SwitchEquips;
                                                if (usage.ID == 45)
                                                {
                                                    ClientEquip equips = new ClientEquip(client);
                                                    client.Send(equips);
                                                    client.Equipment.UpdateEntityPacket2();

                                                    client.LoadItemStats2(client.Entity);
                                                    client.CalculateStatBonus();
                                                    client.CalculateHPBonus();
                                                    client.Send(WindowStats(client));
                                                }
                                                else
                                                {
                                                    ClientEquip equips = new ClientEquip();
                                                    equips.DoEquips(client);
                                                    client.Send(equips);
                                                    client.Equipment.UpdateEntityPacket();

                                                    client.LoadItemStats(client.Entity);
                                                    client.CalculateStatBonus();
                                                    client.CalculateHPBonus();
                                                    client.Send(WindowStats(client));
                                                }
                                                usage.dwParam = 1;
                                                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)
                                                    {
                                                        client.Send(new Message("Speed hack detected!", System.Drawing.Color.BlanchedAlmond, Message.TopLeft));
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                }

                                                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));
                                                client.Send(usage);

                                                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 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.Red, Message.TopLeft));

                                                        return;
                                                    }
                                                    if (client.Entity.ConquerPoints >= item.ConquerPointsCost)
                                                    {
                                                        client.Entity.ConquerPoints -= item.ConquerPointsCost;
                                                        Database.EntityTable.UpdateCps(client);

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

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

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

                                                        if (ServerBase.Kernel.GamePool.ContainsKey(item.GainerUID))
                                                        {
                                                            GameState pClient;
                                                            if (ServerBase.Kernel.GamePool.TryGetValue(item.GainerUID, out pClient))
                                                            {
                                                                if (pClient.Entity != null)
                                                                {
                                                                    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(" " + client.Entity.Name + " has redeemed his Gear and Pay " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                        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.Red, Message.TopLeft));
                                                }
                                                break;
                                            }
                                        case ItemUsage.ClaimGear:
                                            {
                                                // Console.WriteLine(" usage " + usage.UID + "");
                                                var item = client.ClaimableItem[usage.UID];
                                                // Console.WriteLine(" usage i  " + item.UID + "");
                                                if (item != null)
                                                {
                                                    if (item.Bound)
                                                    {
                                                        client.Send(new Message("Unnclaimable item!", System.Drawing.Color.Red, 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.Red, Message.TopLeft));
                                                        return;
                                                    }
                                                    if (item.OwnerUID == 500)
                                                        client.Entity.ConquerPoints += item.ConquerPointsCost;
                                                    else
                                                    {
                                                        client.Inventory.Add(item.Item, PhoenixProject.Game.Enums.ItemUse.Move);
                                                        Message message = new Message("Thank you for arresting " + item.OwnerName + " , " + item.GainerName + ". The arrested one has redeemed his items and you have received a great deal of ConquerPoints as reward. Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                        ServerBase.Kernel.SendWorldMessage(message, ServerBase.Kernel.GamePool.Values);
                                                    }
                                                    Database.ClaimItemTable.Claim(usage.UID, client);
                                                    client.ClaimableItem.Remove(item.UID);

                                                    usage.dwParam = client.Entity.UID;
                                                    usage.dwExtraInfo3 = item.ConquerPointsCost;
                                                    //Database.EntityTable.UpdateCps(client);
                                                    client.Send(usage);
                                                    Message message2 = new Message("Thank you for arresting red/black name players " + client.Entity.Name + " has recived " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
                                                    ServerBase.Kernel.SendWorldMessage(message2, ServerBase.Kernel.GamePool.Values);
                                                }
                                                else
                                                {
                                                    client.Send(new Message("The item you want to claim has already been claimed.", System.Drawing.Color.Red, Message.TopLeft));
                                                }
                                                break;
                                            }
                                        case 43:
                                            {
                                                uint UID = BitConverter.ToUInt32(packet, 4);
                                                if (packet[20] == 1)
                                                {
                                                    if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, 84)))//76
                                                    {
                                                        Interfaces.IConquerItem item = null;
                                                        if (client.Inventory.TryGetItem(UID, out item))
                                                        {
                                                            UInt32 iType = item.ID / 1000;
                                                            Positions pos = GetPositionFromID(item.ID);
                                                            if (pos == Positions.Garment)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.RightAccessory)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.LeftAccessory)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.Bottle)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.Steed)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.SteedArmor)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.SteedTalisman)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.AttackTalisman)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (pos == Positions.DefenceTalisman)
                                                            {
                                                                client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                                client.Account.Savekimo();
                                                                client.Disconnect();
                                                                return;
                                                            }
                                                            if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                            {
                                                                if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                {
                                                                    if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                        item.SocketOne = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                                    client.Inventory.Remove(BitConverter.ToUInt32(packet, 84), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                    item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                                    item.Send(client);
                                                                    usage.dwParam = 1;
                                                                    client.LoadItemStats(client.Entity);
                                                                    client.CalculateStatBonus();
                                                                    client.CalculateHPBonus();
                                                                    Database.ConquerItemTable.UpdateSockets(item);
                                                                }
                                                            }
                                                            else if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                            {
                                                                uint rand = (uint)PhoenixProject.ServerBase.Kernel.Random.Next(1, 700);
                                                                if (rand > 320)
                                                                // if (PhoenixProject.ServerBase.Kernel.PercentSuccess(30))
                                                                {
                                                                    if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                        item.SocketTwo = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                                    client.Inventory.Remove(BitConverter.ToUInt32(packet, 84), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                    item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                                    item.Send(client);
                                                                    usage.dwParam = 1;
                                                                    client.LoadItemStats(client.Entity);
                                                                    client.CalculateStatBonus();
                                                                    client.CalculateHPBonus();
                                                                    Database.ConquerItemTable.UpdateSockets(item);
                                                                }
                                                                else
                                                                {
                                                                    usage.dwParam = 0;
                                                                    client.Inventory.Add(1200006, 0, 1);
                                                                    client.Inventory.Remove(BitConverter.ToUInt32(packet, 84), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                }
                                                            }
                                                            /*&  }
                                                              else
                                                              {
                                                                  if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                      item.SocketOne = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                                  client.Inventory.Remove(BitConverter.ToUInt32(packet, 80), PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                                  item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                                  item.Send(client);
                                                                  client.LoadItemStats(item);
                                                                  Database.ConquerItemTable.UpdateItem(item, client);
                                                              }*/
                                                        }
                                                    }
                                                }
                                                if (packet[20] == 5)
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(UID, out item))
                                                    {
                                                        Dictionary<uint, uint> dbs = new Dictionary<uint, uint>();//packet[20]);
                                                        for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                        {
                                                            if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, i)))
                                                            {
                                                                dbs.Add(BitConverter.ToUInt32(packet, i), i);
                                                            }
                                                        }

                                                        if (client.Inventory.Contains(1088000, 5))
                                                        {
                                                            if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                return;
                                                            if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                item.SocketTwo = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                            foreach (uint key in dbs.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                            }
                                                            usage.dwParam = 1;
                                                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                            item.Send(client);
                                                            client.LoadItemStats(client.Entity);
                                                            client.CalculateStatBonus();
                                                            client.CalculateHPBonus();
                                                            Database.ConquerItemTable.UpdateSockets(item);
                                                        }
                                                    }
                                                }
                                                if (packet[20] == 7)
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(UID, out item))
                                                    {
                                                        if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                            return;

                                                        Dictionary<uint, uint> drill = new Dictionary<uint, uint>();//packet[20]);
                                                        for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                        {
                                                            if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, i)))
                                                            {
                                                                drill.Add(BitConverter.ToUInt32(packet, i), i);
                                                            }
                                                        }

                                                        if (client.Inventory.Contains(1200006, 7))
                                                        {

                                                            if (item.SocketTwo == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                item.SocketTwo = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                            foreach (uint key in drill.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                            }
                                                            usage.dwParam = 1;
                                                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                            item.Send(client);
                                                            client.LoadItemStats(client.Entity);
                                                            client.CalculateStatBonus();
                                                            client.CalculateHPBonus();
                                                            Database.ConquerItemTable.UpdateSockets(item);
                                                        }
                                                    }
                                                }
                                                if (packet[20] == 12)
                                                {
                                                    Interfaces.IConquerItem item = null;
                                                    if (client.Inventory.TryGetItem(UID, out item))
                                                    {
                                                        Dictionary<uint, uint> dbs = new Dictionary<uint, uint>();//packet[20]);
                                                        for (ushort i = 84; i < 84 + 4 * packet[20]; i += 4)
                                                        {
                                                            if (client.Inventory.ContainsUID(BitConverter.ToUInt32(packet, i)))
                                                            {
                                                                dbs.Add(BitConverter.ToUInt32(packet, i), i);
                                                            }
                                                        }

                                                        if (client.Inventory.Contains(1088000, 12))
                                                        {
                                                            if (item.SocketOne != PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                return;
                                                            if (item.SocketOne == PhoenixProject.Game.Enums.Gem.NoSocket)
                                                                item.SocketOne = PhoenixProject.Game.Enums.Gem.EmptySocket;
                                                            foreach (uint key in dbs.Keys)
                                                            {
                                                                if (client.Inventory.ContainsUID(key))
                                                                    client.Inventory.Remove(key, PhoenixProject.Game.Enums.ItemUse.Remove, true);
                                                            }
                                                            usage.dwParam = 1;
                                                            //client.Inventory.Remove(DragonBall, 12);
                                                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                            item.Send(client);
                                                            client.LoadItemStats(client.Entity);
                                                            client.CalculateStatBonus();
                                                            client.CalculateHPBonus();
                                                            Database.ConquerItemTable.UpdateSockets(item);
                                                        }
                                                    }

                                                }
                                                client.Send(packet);
                                                break;
                                            }
                                        case 40:
                                            {
                                                uint ItemAdd = (uint)((packet[4] & 0xFF) | ((packet[5] & 0xFF) << 8) | ((packet[6] & 0xFF) << 16) | ((packet[7] & 0xFF) << 24));

                                                Interfaces.IConquerItem item_new = null;
                                                if (client.Inventory.TryGetItem(ItemAdd, out item_new))
                                                {
                                                    UInt32 iType = item_new.ID / 1000;
                                                    Positions pos = GetPositionFromID(item_new.ID);
                                                    if (pos == Positions.Garment)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.RightAccessory)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.LeftAccessory)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.Bottle)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.Steed)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.SteedArmor)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.SteedTalisman)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.AttackTalisman)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    if (pos == Positions.DefenceTalisman)
                                                    {
                                                        client.Account.State = Database.AccountTable.AccountState.Cheat;
                                                        client.Account.Savekimo();
                                                        client.Disconnect();
                                                        return;
                                                    }
                                                    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(), PhoenixProject.Game.Enums.ItemUse.Remove, true);

                                                    item_new.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                    item_new.Send(client);
                                                    usage.dwParam = 1;
                                                    Database.ConquerItemTable.UpdateBless(item_new);
                                                }
                                                client.Send(packet);
                                                break;
                                            }
                                        case ItemUsage.GemCompose:
                                            {
                                                #region GemCompose
                                                UInt32 Ident = usage.UID;
                                                client.Inventory.Remove(Ident, 15);
                                                client.Inventory.Add(Ident + 1, 0, 1);
                                                usage.dwParam = 1;
                                                client.Send(usage);
                                                #endregion
                                                break;
                                            }
                                        case ItemUsage.ToristSuper:
                                            {
                                                #region GemCompose
                                                if (client.Entity.Money >= 100000)
                                                {
                                                    client.Inventory.Remove(700002, 1);
                                                    client.Inventory.Remove(700012, 1);
                                                    client.Inventory.Remove(700022, 1);
                                                    client.Inventory.Remove(700032, 1);
                                                    client.Inventory.Remove(700042, 1);
                                                    client.Inventory.Remove(700052, 1);
                                                    client.Inventory.Remove(700062, 1);
                                                    client.Entity.Money -= 100000;
                                                    client.Inventory.Add(700072, 0, 1);

                                                    usage.dwParam = 1;
                                                    client.Send(usage);
                                                }
                                                usage.dwParam = 0;
                                                client.Send(usage);
                                                #endregion
                                                break;
                                            }
                                        case ItemUsage.SplitStack:
                                            {
                                                Interfaces.IConquerItem mainItem = null;
                                                Interfaces.IConquerItem minorItem = new ConquerItem(true);
                                                Database.ConquerItemInformation infos = null;
                                                minorItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                if (client.Inventory.TryGetItem(usage.UID, out mainItem))
                                                {
                                                    infos = new PhoenixProject.Database.ConquerItemInformation(mainItem.ID, 0);
                                                    if (mainItem.StackSize > 1 && mainItem.StackSize <= infos.BaseInformation.StackSize)
                                                    {
                                                        if (client.Inventory.Count < 40)
                                                        {
                                                            client.SpiltStack = false;
                                                            ushort Amount = (ushort)usage.dwParam;

                                                            mainItem.StackSize -= Amount;
                                                            mainItem.Mode = Game.Enums.ItemMode.Update;
                                                            mainItem.Send(client);
                                                            mainItem.Mode = Game.Enums.ItemMode.Default;
                                                            Database.ConquerItemTable.UpdateStack(mainItem);
                                                            minorItem.ID = mainItem.ID;
                                                            minorItem.StackSize += Amount;
                                                            minorItem.Durability = mainItem.Durability;
                                                            client.Inventory.Add(minorItem, Game.Enums.ItemUse.CreateAndAdd);

                                                        }
                                                    }
                                                }
                                                break;
                                            }
                                        case ItemUsage.MergeStackableItems:
                                            {
                                                Interfaces.IConquerItem mainItem = null;
                                                Interfaces.IConquerItem minorItem = new ConquerItem(true);
                                                Database.ConquerItemInformation infos = null;
                                                minorItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                if (client.Inventory.TryGetItem(usage.UID, out mainItem) && client.Inventory.TryGetItem(usage.dwParam, out minorItem))
                                                {
                                                    if (mainItem.ID == minorItem.ID)
                                                    {
                                                        infos = new PhoenixProject.Database.ConquerItemInformation(mainItem.ID, 0);
                                                        if (mainItem.StackSize < 1)
                                                            mainItem.StackSize = 1;
                                                        if (minorItem.StackSize < 1)
                                                            minorItem.StackSize = 1;

                                                        if ((mainItem.StackSize + minorItem.StackSize) <= infos.BaseInformation.StackSize)
                                                        {
                                                            mainItem.StackSize += minorItem.StackSize;
                                                            mainItem.Mode = Game.Enums.ItemMode.Update;
                                                            mainItem.Send(client);
                                                            mainItem.Mode = Game.Enums.ItemMode.Default;
                                                            Database.ConquerItemTable.UpdateStack(mainItem);

                                                            client.Inventory.Remove(minorItem, Game.Enums.ItemUse.Remove);
                                                        }
                                                    }
                                                }
                                                break;
                                            }
                                        case 34:
                                            {
                                                break;
                                            }
                                        case 54://downgrade
                                            {
                                                Interfaces.IConquerItem item = null;
                                                Interfaces.IConquerItem minorItem = new ConquerItem(true);
                                                //Database.ConquerItemInformation infos = null;
                                                // uint newid = infos.LowestID(infos.BaseInformation.Level);

                                                //minorItem.Color = (PhoenixProject.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                                if (client.Inventory.TryGetItem(usage.UID, out item) && client.Entity.ConquerPoints >= 54)
                                                {
                                                    Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);

                                                    uint kimzz = 0;
                                                    kimzz = item.ID;

                                                Kimozzz:
                                                    uint kimo = kimzz - 10;
                                                    uint kimo2 = kimzz - 20;
                                                    uint kimo3 = kimzz - 30;
                                                    ushort postion = ItemPosition(kimo);
                                                    ushort postion2 = ItemPosition(kimo2);
                                                    ushort postion3 = ItemPosition(kimo3);
                                                    Database.ConquerItemInformation cii1 = new PhoenixProject.Database.ConquerItemInformation(kimo, 0);
                                                    Database.ConquerItemInformation cii2 = new PhoenixProject.Database.ConquerItemInformation(kimo2, 0);
                                                    Database.ConquerItemInformation cii3 = new PhoenixProject.Database.ConquerItemInformation(kimo3, 0);

                                                    if (Database.ConquerItemInformation.BaseInformations.ContainsKey(kimo))
                                                    {
                                                        if (cii1.BaseInformation.Level >= 10 && postion != 4 && postion != 5)
                                                        {
                                                            kimzz = kimo;
                                                            goto Kimozzz;
                                                        }
                                                        else
                                                        {
                                                            if (cii1.BaseInformation.Level > 10)
                                                            {
                                                                kimzz = kimo;
                                                                goto Kimozzz;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (Database.ConquerItemInformation.BaseInformations.ContainsKey(kimo2))
                                                        {
                                                            if (cii2.BaseInformation.Level >= 10 && postion2 != 4 && postion2 != 5)
                                                            {
                                                                kimzz = kimo2;
                                                                goto Kimozzz;
                                                            }
                                                            else
                                                            {
                                                                if (cii2.BaseInformation.Level > 10)
                                                                {
                                                                    kimzz = kimo2;
                                                                    goto Kimozzz;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (Database.ConquerItemInformation.BaseInformations.ContainsKey(kimo3))
                                                            {
                                                                if (cii3.BaseInformation.Level >= 10 && postion3 != 4 && postion3 != 5)
                                                                {
                                                                    kimzz = kimo3;
                                                                    goto Kimozzz;
                                                                }
                                                                else
                                                                {
                                                                    if (cii3.BaseInformation.Level > 10)
                                                                    {
                                                                        kimzz = kimo3;
                                                                        goto Kimozzz;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {

                                                                // return;
                                                            }
                                                        }
                                                    }

                                                    item.ID = kimzz;

                                                    PhoenixProject.Database.ConquerItemTable.UpdateItemID(item, client);
                                                    item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                                    item.Send(client);
                                                    client.Entity.ConquerPoints -= 54;
                                                }
                                                else
                                                {
                                                    usage.dwParam = 2;
                                                }
                                                break;
                                            }
                                        default:
                                            {
                                                Console.WriteLine("Unhandled item usage type : " + usage.ID);
                                                break;
                                            }
                                    }
                                }
                                break;
                            }
                        #endregion
                        #region String (1015)
                        case 1015:
                            {
                                if (client.Action == 2)
                                {
                                    _String str2 = new _String(false);
                                    str2.Deserialize(packet);
                                    if ((str2.Type == 0x1a) && (str2.Texts.Count > 0))
                                    {
                                        IEnumerator enumerator = Kernel.GamePool.Values.GetEnumerator();
                                        enumerator.MoveNext();
                                        int count = Kernel.GamePool.Count;
                                        for (uint i = 0; i < count; i++)
                                        {
                                            if (i >= count)
                                            {
                                                break;
                                            }
                                            current = enumerator.Current as GameState;
                                            if (current.Entity.Name == str2.Texts[0])
                                            {
                                                string str3 = "";
                                                str3 = ((str3 + current.Entity.UID + " ") + current.Entity.Level + " ") + current.Entity.BattlePower + " #";
                                                if (current.Entity.GuildID != 0)
                                                {
                                                    str3 = str3 + current.Guild.Name + " fNone# ";
                                                }
                                                else
                                                {
                                                    str3 = str3 + "None fNone# ";
                                                }
                                                str3 = (str3 + current.Entity.Spouse + " ") + ((byte)current.Entity.NobilityRank) + " ";
                                                if ((current.Entity.Body % 10) < 3)
                                                {
                                                    str3 = str3 + "1";
                                                }
                                                else
                                                {
                                                    str3 = str3 + "0";
                                                }
                                                str2.Texts.Add(str3);
                                                client.Send(str2);
                                            }
                                            enumerator.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 Vote /Attack
                        case 1022:
                            {

                                if (client.Action != 2)
                                    return;
                                uint dmg = BitConverter.ToUInt32(packet, 24);
                                uint AttackType = BitConverter.ToUInt32(packet, 20);
                                uint AttackType2 = BitConverter.ToUInt32(packet, 26);

                                switch (AttackType)
                                {
                                    case 36:
                                        {
                                            GamePackets.Attack attack2 = new Attack(false);
                                            attack2.Deserialize(packet);
                                            CloudSaintsJar.Execute(client, attack2);
                                            break;
                                        }
                                    case 39:
                                        {
                                            if (!Kernel.VotePool.ContainsKey(client.Account.IP))
                                            {
                                                if (!Kernel.VotePoolUid.ContainsKey(client.Entity.UID))
                                                {
                                                    client.Entity.ConquerPoints += Database.rates.VotePrize;
                                                    PhoenixProject.Game.ConquerStructures.PlayersVot Vot = new PhoenixProject.Game.ConquerStructures.PlayersVot();
                                                    Vot.AdressIp = client.Account.IP;
                                                    Vot.Uid = client.Entity.UID;
                                                    Kernel.VotePool.Add(Vot.AdressIp, Vot);
                                                    Kernel.VotePoolUid.Add(Vot.Uid, Vot);
                                                    Database.EntityTable.SavePlayersVot(Vot);
                                                    client.Send(new Message("" + PhoenixProject.Database.rates.VoteUrl + "", System.Drawing.Color.Red, Network.GamePackets.Message.Website));
                                                }
                                                else
                                                {
                                                    client.Send(new Message("" + PhoenixProject.Database.rates.VoteUrl + "", System.Drawing.Color.Red, Network.GamePackets.Message.Website));
                                                }
                                            }
                                            else
                                            {
                                                client.Send(new Message("" + PhoenixProject.Database.rates.VoteUrl + "", System.Drawing.Color.Red, Network.GamePackets.Message.Website));

                                            }
                                            break;
                                        }
                                    default:
                                        {
                                            if (client.Entity.MapID == 8880 || client.Entity.MapID == 8881) return;
                                            GamePackets.Attack attack = new Attack(false);
                                            attack.Deserialize(packet);
                                            Attack(attack, client);
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region ChiSystem
                        case 2533:
                            {

                                ChiSystem2.Handle(packet, client);
                                break;
                            }
                        #endregion
                        #region CountryFlag
                        case 2430:
                            {
                                KimoCountryFlag kimo = new KimoCountryFlag(false);
                                kimo.Deserialize(packet);
                                client.Entity.CountryFlag = kimo.FlagID;
                                kimo.UID = client.Entity.UID;
                                client.SendScreen(kimo, true);
                                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:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.ForbidJoin = true;
                                                    Teammate.Send(teamPacket);
                                                }

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

                                            break;
                                        }
                                    case Team.LootMoneyOff:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.PickupMoney = false;
                                                    Teammate.Send(teamPacket);
                                                }
                                            break;
                                        }
                                    case Team.LootMoneyOn:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.PickupMoney = true;
                                                    Teammate.Send(teamPacket);
                                                }
                                            break;
                                        }
                                    case Team.LootItemsOn:
                                        {
                                            foreach (Client.GameState Teammate in client.Team.Teammates)
                                                if (Teammate != null)
                                                {
                                                    Teammate.Team.PickupItems = true;
                                                    Teammate.Send(teamPacket);
                                                }
                                            break;
                                        }
                                    case Team.LootItemsOff:
                                        {
                                            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;
                                uint AddStr = BitConverter.ToUInt32(packet, 8);
                                uint AddAgi = BitConverter.ToUInt32(packet, 12);
                                uint AddVit = BitConverter.ToUInt32(packet, 16);
                                uint AddSpi = BitConverter.ToUInt32(packet, 20);
                                if (client.Entity.Atributes == 0)
                                    return;

                                uint TotalStatPoints = AddStr + AddAgi + AddVit + AddSpi;

                                if (client.Entity.Atributes >= TotalStatPoints)
                                {
                                    client.Entity.Strength += (ushort)AddStr;
                                    client.Entity.Agility += (ushort)AddAgi;
                                    client.Entity.Vitality += (ushort)AddVit;
                                    client.Entity.Spirit += (ushort)AddSpi;
                                    client.Entity.Atributes -= (ushort)TotalStatPoints;
                                    client.Send(packet);
                                }
                                client.CalculateStatBonus();
                                client.CalculateHPBonus();
                                client.GemAlgorithm();
                                break;
                            }
                        #endregion
                        #region Socketing (1027)
                        case 1027:
                            {
                                EmbedSocket socket = new EmbedSocket(false);
                                socket.Deserialize(packet);
                                SocketItem(socket, client);
                                break;
                            }
                        #endregion
                        #region Character Statistics (1040)
                        case 1040:
                            {
                                uint UID = BitConverter.ToUInt32(packet, 4);
                                Client.GameState Client;
                                if (ServerBase.Kernel.GamePool.TryGetValue(UID, out Client))
                                {
                                    client.Send(WindowStats(Client));
                                }
                                break;
                            }
                        #endregion
                        #region LoginPacket (1052)
                        case 1052:
                            {
                                if (client.Action == 1)
                                {
                                    Connect connect = new Connect();
                                    connect.Deserialize(packet);
                                    AppendConnect(connect, client);
                                }
                                else
                                {
                                    //Console.WriteLine(" yes");
                                    client.Disconnect();
                                    //DoLogin(client);
                                }
                                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 Trade (1056)
                        #region Floor items (1101)
                        case 1101:
                            {
                                if (client.Action != 2)
                                    return;
                                FloorItem floorItem = new FloorItem(false);
                                floorItem.Deserialize(packet);
                                client.SpiltStack = true;
                                PickupItem(floorItem, client);
                                client.SpiltStack = false;
                                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[(PhoenixProject.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:
                                        {
                                            if (client.Booth != null)
                                            {
                                                Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Sorry you cant add items into your warehouse while you in Booth");
                                                npc.OptionID = 255;
                                                client.Send(npc.ToArray());
                                                return;
                                            }
                                            Game.ConquerStructures.Warehouse wh = client.Warehouses[(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID)warehousepacket.NpcID];
                                            if (wh == null) return;
                                            Interfaces.IConquerItem item = null;
                                            if (client.Inventory.TryGetItem(warehousepacket.UID, out item))
                                            {
                                                if (item.ID >= 729960 && item.ID <= 729970)
                                                    return;
                                                if (item.ID == 750000)
                                                    return;
                                                if (!ConquerItem.isRune(item.UID))
                                                {
                                                    if (wh.Add(item))
                                                    {
                                                        warehousepacket.UID = 0;
                                                        warehousepacket.Count = 1;
                                                        warehousepacket.Append(item);
                                                        client.Send(warehousepacket);
                                                        return;
                                                    }
                                                }
                                                else client.Send(new Message("You can not store Flame Stone Rune's in Warehouse", System.Drawing.Color.Red, Message.TopLeft));
                                            }
                                            break;
                                        }
                                    case Warehouse.RemoveItem:
                                        {
                                            Game.ConquerStructures.Warehouse wh = client.Warehouses[(PhoenixProject.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 GuildCommands (1107)
                        case 1107:
                            {
                                GuildCommand command = new GuildCommand(false);
                                command.Deserialize(packet);
                                switch (command.Type)
                                {
                                    case GuildCommand.Neutral1:
                                    case GuildCommand.Neutral2:
                                        {
                                            string name = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.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.Encoding.UTF8.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    AllyGuilds(name, client);
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.Enemied:
                                        {
                                            string name = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    client.Guild.AddEnemy(name);
                                                }
                                            }
                                            break;
                                        }
                                    default:
                                        {
                                            client.Send(packet);
                                            break;
                                        }
                                    case GuildCommand.Bulletin:
                                        {
                                            string message = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.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.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    var member = client.Guild.GetMemberByName(name);
                                                    if (member != null)
                                                    {
                                                        if (member.ID != client.Entity.UID)
                                                        {
                                                            if (member.Rank == PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                            {
                                                                client.Guild.DeputyLeaderCount--;
                                                                member.Rank = PhoenixProject.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 == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                {
                                                    if (client.Guild.Members.ContainsKey(command.dwParam))
                                                    {
                                                        var member = client.Guild.Members[command.dwParam];
                                                        if (member.Rank == PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            member.Rank = PhoenixProject.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 == PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                        {
                                                            member.Rank = PhoenixProject.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 = PhoenixProject.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 != PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            Client.Guild.AddMember(client);
                                                            Client.OnHoldGuildJoin = 0;
                                                            client.OnHoldGuildJoin = 0;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (client.AsMember.Rank != PhoenixProject.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 != PhoenixProject.Game.Enums.GuildMemberRank.Member)
                                                        {
                                                            Client.Guild.AddMember(client);
                                                            Client.OnHoldGuildJoin = 0;
                                                            client.OnHoldGuildJoin = 0;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (client.AsMember.Rank != PhoenixProject.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 = 0;
                                                    client.OnHoldGuildJoin = Client.OnHoldGuildJoin;
                                                }
                                            }
                                            break;
                                        }
                                    case GuildCommand.Quit:
                                        {
                                            if (client.Guild != null)
                                            {
                                                if (client.AsMember.Rank != PhoenixProject.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.Red, 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.Red, 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.Red, Message.TopLeft));
                                    }
                                }
                                break;
                            }
                        #endregion
                        #region QuizShow (2068)
                        case 2068:
                            {
                                try
                                {

                                    byte Answered = (byte)(packet[8] - 1);

                                    int L = Environment.TickCount;
                                    int Now = (L - client.QuizInfo.LastAnswer) / 1000 + 1;
                                    ushort qn = PhoenixProject.Game.ConquerStructures.QuizShow.QuestionNO;
                                    if ((ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points) > 0)
                                    {
                                        client.QuizInfo.Time += (ushort)Now;
                                        client.QuizInfo.Score += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points);
                                        client.Entity.QuizPoints += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points);
                                        client.Entity.ConquerPoints += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points * 10);
                                        client.Send(new Message("You have won " + ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points).ToString() + " quiz points and " + ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points * 10).ToString() + " ConquerPoints", System.Drawing.Color.Red, Message.TopLeft));
                                        uint exp = 1000;
                                        exp = (uint)(exp * ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points));
                                        client.IncreaseExperience((ulong)exp, false);
                                        Program.kimo3 = Answered;
                                    }
                                    else
                                    {
                                        client.QuizInfo.Time += (ushort)Now;
                                        client.QuizInfo.Score += (ushort)((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points);
                                        uint exp = 1000;
                                        exp = (uint)(exp * ((30 - Now) * PhoenixProject.Game.ConquerStructures.QuizShow.Questions[(ushort)(qn - 1)].Answers[Answered].Points));
                                        client.IncreaseExperience((ulong)exp, false);
                                        client.Send(new Message("Ops Wrong Answer try Google if you dont know www.Google.com!!", System.Drawing.Color.Red, Message.TopLeft));

                                    }
                                    if (client.QuizInfo.Score >= 0)
                                    {
                                        /* int MyPlace = 0;
                                         for (int i = 0; i < 499; i++)
                                         {
                                             if (client.QuizInfo.Score < PhoenixProject.Game.ConquerStructures.QuizShow.Scores[i].Score)
                                             {
                                                 MyPlace++;
                                             }
                                             else
                                             {
                                                 if (client.Entity.UID == PhoenixProject.Game.ConquerStructures.QuizShow.Scores[i].EntityID)
                                                 {
                                                 }
                                                 else
                                                 {
                                                     if (client.QuizInfo.Score == PhoenixProject.Game.ConquerStructures.QuizShow.Scores[i].Score)
                                                     {
                                                         MyPlace++;
                                                     }
                                                 }
                                             }
                                         }*/
                                        if (client.QuizInfo.Score >= Kernel.MainQuiz.Score[0])
                                        {
                                            Kernel.MainQuiz.Name[0] = client.Entity.Name;
                                            Kernel.MainQuiz.Score[0] = client.QuizInfo.Score;
                                            Kernel.MainQuiz.Time[0] = client.QuizInfo.Time;
                                        }
                                        client.Send(new GamePackets.QuizInfo().InfoBuffer(client.QuizInfo.Score, client.QuizInfo.Time, client.QuizInfo.Rank));

                                    }

                                }
                                catch { }
                                break;
                            }
                        #endregion
                        #region NPC Dialog (2031 + 2032)
                        case 2031:
                        case 2032:
                            {
                                if (client.Action != 2)
                                    return;
                                NpcRequest req = new NpcRequest();
                                req.Deserialize(packet);
                                #region CaptureFlag
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 234 && client.Map.BaseID != 700)//CaptureFlag
                                {
                                    client.Entity.Teleport(1002, 384, 348);
                                }
                                #endregion
                                #region DemonCave
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 235 && client.Map.BaseID != 700)//DemonCave
                                {
                                    if (DateTime.Now.Hour == Game.KimoEvents.DemonHour && DateTime.Now.Minute < 5)
                                    {
                                        if (!client.DemonCave)
                                        {
                                            client.DemonCave = true;
                                            client.Entity.Teleport(1, 77, 69);
                                            client.Entity.DemonCave1 = 0;
                                            client.Entity.DemonCave2 = 0;
                                            client.Entity.DemonCave3 = 0;
                                            Data data = new Data(true);
                                            data.ID = Data.OpenCustom;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = 3378;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);
                                        }
                                    }
                                }
                                #endregion
                                #region SkillTeam
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 236 && client.Map.BaseID != 700)//SkillTeamPK
                                {
                                    client.Entity.Teleport(1002, 460, 367);
                                }
                                #endregion
                                #region DonationWar
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 237 && client.Map.BaseID != 700)//dONATION
                                {
                                    client.Entity.Teleport(1002, 428, 392);
                                }
                                #endregion
                                #region ElitePk
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 249 && client.Map.BaseID != 700)//ElitePk
                                {
                                    if (DateTime.Now.Hour == Game.KimoEvents.EBHour && DateTime.Now.Minute >= 5 && DateTime.Now.Minute < 20)
                                    {
                                        if (!Game.Tournaments.EliteTournament.Top8.ContainsKey(client.Entity.UID))
                                        {
                                            Game.Tournaments.EliteTournament.AddMap(client);
                                            Data data = new Data(true);
                                            data.ID = Data.OpenCustom;
                                            data.UID = client.Entity.UID;
                                            data.TimeStamp = Time32.Now;
                                            data.dwParam = 3378;
                                            data.wParam1 = client.Entity.X;
                                            data.wParam2 = client.Entity.Y;
                                            client.Send(data);
                                        }
                                    }
                                }
                                #endregion
                                #region classpk
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 248 && client.Map.BaseID != 700)//ClassPk
                                {
                                    if (DateTime.Now.Hour == Game.KimoEvents.ClassHour && DateTime.Now.Minute < 05)
                                    {
                                        if (client.Entity.Class >= 10 && client.Entity.Class <= 15)
                                        {
                                            client.Entity.Teleport(7001, 25, 40);
                                        }
                                        if (client.Entity.Class >= 20 && client.Entity.Class <= 25)
                                        {
                                            client.Entity.Teleport(4500, 25, 40);
                                        }
                                        if (client.Entity.Class >= 40 && client.Entity.Class <= 45)
                                        {
                                            client.Entity.Teleport(4501, 25, 40);
                                        }
                                        if (client.Entity.Class >= 50 && client.Entity.Class <= 55)
                                        {
                                            client.Entity.Teleport(4502, 25, 40);
                                        }
                                        if (client.Entity.Class >= 60 && client.Entity.Class <= 65)
                                        {
                                            client.Entity.Teleport(4503, 25, 40);
                                        }
                                        if (client.Entity.Class >= 70 && client.Entity.Class <= 75)
                                        {
                                            client.Entity.Teleport(4504, 25, 40);
                                        }
                                        if (client.Entity.Class >= 132 && client.Entity.Class <= 135)
                                        {
                                            client.Entity.Teleport(4505, 25, 40);
                                        }
                                        if (client.Entity.Class >= 142 && client.Entity.Class <= 145)
                                        {
                                            client.Entity.Teleport(4506, 25, 40);
                                        }
                                        Data data = new Data(true);
                                        data.ID = Data.OpenCustom;
                                        data.UID = client.Entity.UID;
                                        data.TimeStamp = Time32.Now;
                                        data.dwParam = 3378;
                                        data.wParam1 = client.Entity.X;
                                        data.wParam2 = client.Entity.Y;
                                        client.Send(data);

                                    }
                                }
                                #endregion
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 247 && client.Map.BaseID != 700 && client.Entity.invite)//WeeklyPk
                                {
                                    client.Entity.Teleport(1002, 453, 294);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 246 && client.Map.BaseID != 700)//MonthlyPk
                                {
                                    client.Entity.Teleport(1002, 428, 243);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 245 && client.Map.BaseID != 700)//DisCity
                                {
                                    client.Entity.Teleport(1020, 534, 484);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 244 && client.Map.BaseID != 700)//GuildWar
                                {
                                    client.Disconnect();
                                    return;
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 233 && client.Map.BaseID != 700)//ClanWar
                                {
                                    client.Entity.Teleport(1002, 413, 246);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 198 && client.Map.BaseID != 700)//ClanWar
                                {
                                    client.Entity.Teleport(1002, 450, 372);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 196 && client.Map.BaseID != 700)//ClanWar
                                {
                                    client.Entity.Teleport(1002, 425, 385);
                                }
                                #region DailyPk
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 243 && client.Map.BaseID != 700)//DailyPk
                                {
                                    if (DateTime.Now.Minute >= 00 && DateTime.Now.Minute < 05)
                                    {
                                        client.Entity.Teleport(8877, 52, 44);
                                        Data data = new Data(true);
                                        data.ID = Data.OpenCustom;
                                        data.UID = client.Entity.UID;
                                        data.TimeStamp = Time32.Now;
                                        data.dwParam = 3378;
                                        data.wParam1 = client.Entity.X;
                                        data.wParam2 = client.Entity.Y;
                                        client.Send(data);
                                    }
                                }
                                #endregion
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 242 && client.Map.BaseID != 700)//SteedRace
                                {
                                    client.Entity.Teleport(1002, 423, 245);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 241 && client.Map.BaseID != 700)//SpouseWar
                                {
                                    client.Entity.Teleport(1002, 421, 292);
                                }
                                #region LastMan
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 240 && client.Map.BaseID != 700)//LastMan
                                {
                                    if (DateTime.Now.Minute >= 30 && DateTime.Now.Minute <= 32)
                                    {
                                        Random R = new Random();
                                        int Nr = R.Next(1, 10);
                                        if (Nr == 1) client.Entity.Teleport(3333, 51, 73);
                                        if (Nr == 2) client.Entity.Teleport(3333, 33, 34);
                                        if (Nr == 3) client.Entity.Teleport(3333, 67, 34);
                                        if (Nr == 4) client.Entity.Teleport(3333, 51, 73);
                                        if (Nr == 5) client.Entity.Teleport(3333, 33, 34);
                                        if (Nr == 6) client.Entity.Teleport(3333, 67, 34);
                                        if (Nr == 7) client.Entity.Teleport(3333, 51, 73);
                                        if (Nr == 8) client.Entity.Teleport(3333, 33, 34);
                                        if (Nr == 9) client.Entity.Teleport(3333, 67, 34);
                                        if (Nr == 10) client.Entity.Teleport(3333, 68, 57);

                                        Data data = new Data(true);
                                        data.ID = Data.OpenCustom;
                                        data.UID = client.Entity.UID;
                                        data.TimeStamp = Time32.Now;
                                        data.dwParam = 3378;
                                        data.wParam1 = client.Entity.X;
                                        data.wParam2 = client.Entity.Y;
                                        client.Send(data);
                                    }
                                }
                                #endregion
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 239 && client.Map.BaseID != 700)//EliteGW
                                {
                                    client.Entity.Teleport(1002, 414, 259);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 238 && client.Map.BaseID != 700)//TreasueBox
                                {
                                    client.Entity.Teleport(1002, 441, 352);
                                }
                                if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead && req.OptionID == 233 && client.Map.BaseID != 700)//LordsWar
                                {
                                    client.Entity.Teleport(1002, 382, 394);
                                }
                                if (req.InteractType == NpcReply.MessageBox)
                                {
                                    if (client.Entity.ActivePOPUP == 99995)
                                    {
                                        client.Entity.ActivePOPUP = 0;
                                        break;
                                    }
                                    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;
                                        }
                                    }
                                }
                                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.Send(data);
                                            break;
                                        }
                                    }
                                    Interfaces.INpc npc = null;
                                    if (req.InteractType == 102)
                                    {
                                        if (client.Guild != null)
                                        {
                                            if (client.AsMember.Rank == PhoenixProject.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;
                                        if (client.Entity.Dead)
                                            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:
                                        {
                                            if (client.Map.BaseID == 6000 || client.Map.BaseID == 6001 || client.Entity.Dead)
                                            {
                                                return;
                                            }
                                            if (client.Entity.MapID == 1036 || client.Entity.MapID == 1039 || ServerBase.Constants.OfflineTG.Contains(client.Entity.MapID))
                                            {
                                                switch (client.Entity.PreviousMapID)
                                                {

                                                    case 1000:
                                                        {
                                                            client.Entity.PreviousMapID = 1000;
                                                            client.Entity.PrevX = 500;
                                                            client.Entity.PrevY = 560;
                                                            break;
                                                        }
                                                    case 1020:
                                                        {
                                                            client.Entity.PreviousMapID = 1020;
                                                            client.Entity.PrevX = 565;
                                                            client.Entity.PrevY = 562;
                                                            //client.Entity.Teleport(1020, 565, 562);
                                                            break;
                                                        }
                                                    case 1011:
                                                        {
                                                            client.Entity.PreviousMapID = 1011;
                                                            client.Entity.PrevX = 188;
                                                            client.Entity.PrevY = 264;
                                                            //client.Entity.Teleport(1011, 188, 264);
                                                            break;
                                                        }
                                                    case 1015:
                                                        {
                                                            client.Entity.PreviousMapID = 1015;
                                                            client.Entity.PrevX = 717;
                                                            client.Entity.PrevY = 571;
                                                            // client.Entity.Teleport(1015, 717, 571);
                                                            break;
                                                        }
                                                    default:
                                                        {
                                                            client.Entity.PreviousMapID = 1002;
                                                            client.Entity.PrevX = 429;
                                                            client.Entity.PrevY = 378;
                                                            //client.Entity.Teleport(1002, 429, 378);
                                                            break;
                                                        }
                                                }
                                                client.Entity.PreviousMapID = client.Entity.PreviousMapID;
                                                //client.Entity.PrevX = client.Entity.PrevX;
                                                //client.Entity.PrevY = client.Entity.PrevY;
                                            }
                                            else
                                            {
                                                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.Entity.PreviousMapID == 1036 || client.Entity.PreviousMapID == 1039)
                                                switch (client.Entity.PreviousMapID)
                                                {

                                                    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 1015:
                                                        {
                                                            client.Entity.Teleport(1015, 717, 571);
                                                            break;
                                                        }
                                                    default:
                                                        {
                                                            client.Entity.Teleport(1002, 429, 378);
                                                            break;
                                                        }
                                                }
                                            else
                                            {
                                                client.Entity.Teleport(client.Entity.PreviousMapID, client.Entity.PrevX, client.Entity.PrevY);
                                            }
                                            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 (client.Trade.InTrade)
                                            {
                                                client.Send(new Message("You cannot send any broadcasts While you inTrade.", System.Drawing.Color.Red, Message.TopLeft));
                                                break;
                                            }
                                            if (client.Entity.MapID == 3031)
                                            {
                                                client.Send(new Message("You cannot send any broadcasts while you in LordsWar Tourment.", System.Drawing.Color.Red, Message.TopLeft));
                                                break;
                                            }
                                            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 -= 5;
                                                Game.ConquerStructures.Broadcast.BroadcastStr broadcast = new PhoenixProject.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 -= 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 -= 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 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)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                if (client.AsMember.SilverDonation > client.Guild.SilverFund)
                                                {
                                                    client.Guild.SilverFund = (uint)client.AsMember.SilverDonation;
                                                    client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.OSupervisor;
                                                    client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                }

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

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

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

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

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

                                            Writer.WriteUInt32((uint)client.Entity.Flowers.Orchads, 40, packet);
                                            if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                                if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                                    if (client.Entity.Flowers.Orchads > client.Guild.orchid_donation)
                                                    {
                                                        client.Guild.orchid_donation = (uint)client.Entity.Flowers.Orchads;
                                                        client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.OrchidFollower;
                                                        client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                                    }
                                            Writer.WriteUInt32((uint)(client.Entity.Flowers.Orchads
                                                + (uint)client.Entity.Flowers.RedRoses
                                                + (uint)client.Entity.Flowers.Tulips
                                                + (uint)client.Entity.Flowers.Lilies), 44, packet);
                                        }
                                    if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                                        if (client.Entity.GuildRank != (ushort)PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                                        {
                                            if (client.Entity.Name == client.Guild.LeaderName)
                                            {
                                                client.Entity.GuildRank = (ushort)PhoenixProject.Game.Enums.GuildMemberRank.LeaderSpouse;
                                                client.AsMember.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)client.Entity.GuildRank;
                                            }
                                        }
                                    if (client.Guild != null)
                                        client.Guild.SendGuild(client);
                                    client.Send(packet);
                                }
                                break;
                            }
                        #endregion
                        #region Flowers (1150 & 1151)
                        case 1150:
                            {
                                new Game.Features.Flowers.FlowerSystem(packet, client);
                                break;
                            }
                        #endregion
                        #region Flowers (1150 & 1151)
                        case 1151:
                            {
                                int subtype = packet[4];
                                AddFlowers(client, packet);

                                break;
                            }
                        #endregion
                        #region Mentor prize (2067)
                        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 ElitePk Tournament 2223 | 2219
                        case 2223:
                            {
                                if (client.Entity.MapID == 6002)
                                    break;

                                if (Game.Tournaments.EliteTournament.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);
                                break;
                            }
                        /* case 2224:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 2232:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 2242:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 2243:
                             {
                                 client.Send(packet);
                                 break;
                             }*/
                        /*case 2242://Request Arena ranking List 2245 2242 2244
                            {
                                //Code snippet that belongs to Ultimation
                                Game.ConquerStructures.TeamArena.Statistics.ShowWiners(client);
                                break;
                            }
                        case 2245:
                            {
                                client.TeamArenaStatistic.Send(client);
                                break;
                            }*/
                        /*case 2245:
                            {
                                client.Send(packet);
                                break;
                            }*/
                        /* case 2233:
                             {
                                 GamePackets.Team_Pk pk = new Team_Pk(client.Entity.UID);
                                 pk.Send(client);
                                 break;
                             }*/
                        /* case 2252:
                             {
                                 client.Send(packet);
                                 break;
                             }*/
                        /* case 2253:
                             {
                                 GamePackets.Team_PkComun pk = new Team_PkComun(client.Entity.UID);
                                 pk.Send(client);
                                 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 vipteleport
                        case 1128:
                            {
                                p1128 vp = new p1128(false);
                                vp.Deserialize(packet);
                                if (ServerBase.Constants.VipNo.Contains(client.Entity.MapID))
                                    return;
                                if (client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Ghost))
                                    return;
                                switch (vp.UID)
                                {
                                    case 0://player city teleport
                                        {
                                            switch (vp.UID2)
                                            {
                                                ////////////////////////////////////////////////////////////////////////////////////////////////////
                                                case 1://tc
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1002, 429, 378);
                                                    break;
                                                case 2://pc
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1011, 188, 264);
                                                    break;
                                                case 3://ac
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1020, 565, 562);
                                                    break;
                                                case 4://dc
                                                    if (client.Map.BaseID != 700)
                                                        client.Entity.Teleport(1000, 500, 650);
                                                    break;
                                                case 5://bc
                                                    if (client.Map.BaseID != 700)
                                                        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)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1002, 429, 378);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        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)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1011, 188, 264);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        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)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1020, 565, 562);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        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)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1000, 500, 650);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        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)
                                                        {
                                                            if (client.Map.BaseID != 700)
                                                            {
                                                                teammate.Entity.Teleport(1015, 717, 571);
                                                            }
                                                        }
                                                    }
                                                    if (client.Map.BaseID != 700)
                                                        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;
                            }
                        #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 Guild members (2102)
                        case 2102:
                            {
                                ushort Page = BitConverter.ToUInt16(packet, 8);
                                if (client.Guild != null)
                                {
                                    if (client.AsMember != null)
                                        client.Guild.SendMembers(client, Page);
                                }
                                break;
                            }
                        #endregion
                        #region Arena (2207<->2211)
                        case 2207://Request Arena ranking List 2245 2242 2244
                            {
                                //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:
                            {//bug in console
                                client.ArenaStatistic.Send(client);
                                break;
                            }
                        case 2211:
                            {
                                if (client.Map.BaseID == 6001 || client.Map.BaseID == 6000)
                                    return;
                                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
                        //24 2533 53 152 1 0 0 0 84
                        //60 0 229 9 50 151 152 0 1 0 0 0 0 0 0 0 84 81 83 101 114 118 101 114
                        //3c 00 e5 09 32 97 98 00 01 00 00 00 00 00 00 00 54 51 53 65 72 76 65 72
                        /* case 2533:
                             {
                                 KimoChi prize = new KimoChi(false);
                                 prize.Deserialize(packet);
                                 client.Send(packet);
                                 client.Send(prize);
                                 break;

                             }*/
                        #region Lottery2
                        case 1314://1314
                            {

                                Game.Lottery.Handle(packet, client);
                                break;
                            }
                        #endregion
                        #region New AutoInvite
                        case 1126://1314
                            {

                                EventAlert2.Handle(packet, client);
                                break;
                            }
                        #endregion
                        #region ClanWar inv (1313)
                        case 1313://1313
                            {
                                if (packet[4] == 8)
                                {
                                    client.Entity.Teleport(1002, 413, 246);
                                }

                                return;
                            }
                        #endregion //packet[8] = 1;

                        #region ChangeName (2080)
                        case 2080:
                            {
                                NameChange prize = new NameChange(false);
                                //prize.EditAllowed = 1;
                                //prize.EditCount = 1;
                                prize.Deserialize(packet);

                                switch (prize.Action)//string name = System.Text.Encoding.UTF7.GetString(packet, 26, packet[25]);
                                {

                                    case PhoenixProject.Network.GamePackets.NameChange.NameChangeAction.Request:
                                        {
                                            string newname = System.Text.Encoding.UTF7.GetString(packet, 10, 16).TrimEnd('\0');

                                            packet[6] = (byte)client.Entity.EditeName;
                                            packet[8] = (byte)(5 - client.Entity.EditeName);
                                            prize.Send(client);
                                            client.Send(prize);
                                            if (newname != "")
                                            {
                                                if (newname == "")
                                                    return;
                                                if (newname.Contains("[") && newname.Contains("]"))
                                                    return;
                                                if (Dialogs.InvalidCharacters(newname) && Dialogs.InvalidCharacters3(newname) && !newname.Contains("[") && !newname.Contains("]"))
                                                {
                                                    PhoenixProject.Database.MySqlCommand cmd2 = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.SELECT).Select("entities").Where("name", newname);//debug and test!
                                                    PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd2);
                                                    if (!r.Read())//wait
                                                    {
                                                        if (client.Entity.ConquerPoints >= PhoenixProject.Database.rates.ChangeName)
                                                        {
                                                            client.Entity.ConquerPoints -= PhoenixProject.Database.rates.ChangeName;

                                                            // PhoenixProject.Database.MySqlCommand cmd = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.UPDATE);
                                                            //  cmd.Update("entities").Set("namechange", newname).Where("UID", client.Entity.UID).Execute();
                                                            r.Close();
                                                            r.Dispose();
                                                            client.Entity.NewName = newname;

                                                            // Console.WriteLine(client.Entity.Name + ", Changed hes Name to : " + newname);
                                                            ServerBase.Kernel.SendWorldMessage(new Message(client.Entity.Name + ", Changed He's/Hers Name to " + newname + ", Will be affected after  Relogin.",
                                                                System.Drawing.Color.Red, Message.Talk), ServerBase.Kernel.GamePool.Values);

                                                            // client.Edita = 0;
                                                            // client.Edite = 1;
                                                            client.Entity.EditeName += 1;
                                                            packet[4] = 1;
                                                            prize.Send(client);
                                                            client.Send(prize);
                                                            Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Your new name is : " + newname + ", After relog You will get your new name, Want to Relog?");
                                                            npc.OptionID = 244;
                                                            client.Send(npc.ToArray());
                                                        }
                                                        else
                                                        {
                                                            Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Come back when you have " + PhoenixProject.Database.rates.ChangeName + " CPS.");
                                                            npc.OptionID = 255;
                                                            client.Send(npc.ToArray());
                                                            r.Close();
                                                            r.Dispose();

                                                        }
                                                    }
                                                    else
                                                    {
                                                        packet[4] = 2;
                                                        prize.Send(client);
                                                        client.Send(prize);
                                                        r.Close();
                                                        r.Dispose();

                                                    }
                                                }
                                                else
                                                {
                                                    Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "im sorry not allowed now close the dialog and try again");
                                                    npc.OptionID = 255;
                                                    client.Send(npc.ToArray());
                                                    //r.Close();
                                                    //r.Dispose();

                                                }
                                            }
                                            break;
                                        }
                                }
                                //packet[8] = 1;
                                //byte NewClass = packet[4];
                                //ushort NewBody = packet[8];

                                break;
                            }
                        #endregion

                        #region Reincarnation (1066)
                        case 1066:
                            {
                                if (client.Entity.Reborn != 2) return;
                                if (ServerBase.Kernel.ReincarnatedCharacters.ContainsKey(client.Entity.UID))
                                    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.ConquerPoints >= PhoenixProject.Database.rates.Riencration)
                                {
                                    client.Entity.Body = NewBody;
                                    new PacketHandler.Reincarnation(client, NewClass);
                                    client.Inventory.Remove(711083, 1);
                                    client.Entity.ConquerPoints -= PhoenixProject.Database.rates.Riencration;
                                }
                                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.ItemArtifact:
                                        PurifyRefinery(ps, client); break;
                                    //case Purification.Stabilaze:
                                    //new Game.Features.Refinery.Handle(packet, client); break;
                                }
                                break;
                            }
                        #endregion
                        #region KimoClans
                        case 1312:
                            {
                                //GameState targets;
                                switch (packet[4])
                                {
                                    case 21:
                                        {

                                            if (client.Entity.Myclan != null)
                                            {
                                                try
                                                {
                                                    uint lider = 0;
                                                    string name_receive = System.Text.Encoding.UTF7.GetString(packet, 18, packet[17]);

                                                    foreach (Client.GameState clien in ServerBase.Kernel.GamePool.Values)
                                                    {

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

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

                                                        if (PhoenixProject.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                        {
                                                            if (PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].Members.ContainsKey(aClient.Entity.UID))
                                                            {
                                                                PhoenixProject.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 = 10;
                                                                client.Entity.Myclan.Members[client.Entity.UID].Rank = 10;
                                                                Database.Clans.SaveClan(aClient.Entity.Myclan);
                                                                //Database.Clans.JoinClan(client);
                                                                Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                                client.Send(cl.ToArray());
                                                                ClanMembers clan = new ClanMembers(client);
                                                                client.Send(clan.ToArray());
                                                                Network.GamePackets.Clan cls = new PhoenixProject.Network.GamePackets.Clan(aClient, 1);
                                                                aClient.Send(cls.ToArray());
                                                                ClanMembers clans = new ClanMembers(aClient);
                                                                aClient.Send(clans.ToArray());
                                                                ServerBase.Kernel.GamePool[aClient.Entity.UID].Screen.FullWipe();
                                                                ServerBase.Kernel.GamePool[aClient.Entity.UID].Screen.Reload(null);
                                                                ServerBase.Kernel.GamePool[client.Entity.UID].Screen.FullWipe();
                                                                ServerBase.Kernel.GamePool[client.Entity.UID].Screen.Reload(null);
                                                            }
                                                        }

                                                    }
                                                    else
                                                    {
                                                        PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanLider = name_receive;
                                                        client.Entity.ClanRank = 10;
                                                        client.Entity.Myclan.Members[client.Entity.UID].Rank = 10;
                                                        Database.Clans.SaveClan(client.Entity.Myclan);
                                                        Database.Clans.TransferClan(name_receive);
                                                        Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                        client.Send(cl.ToArray());
                                                        ClanMembers clan = new ClanMembers(client);
                                                        client.Send(clan.ToArray());
                                                        ServerBase.Kernel.GamePool[client.Entity.UID].Screen.FullWipe();
                                                        ServerBase.Kernel.GamePool[client.Entity.UID].Screen.Reload(null);
                                                        //Console.WriteLine("gggf");

                                                    }
                                                }
                                                catch (Exception e)
                                                {
                                                    Program.SaveException(e);
                                                }
                                            }
                                            break;
                                        }

                                    case (byte)Game.Clan_Typ.Quit:
                                        {
                                            if (client.Entity.Myclan != null)
                                            {
                                                if (client.Entity.ClanRank != 100)
                                                {
                                                    client.Entity.Myclan.ExpelMember(client.Entity.Name, true);
                                                }
                                            }

                                            break;
                                        }
                                    case 25:
                                        {
                                            if (client.Entity.Myclan == null) return;
                                            string buletin = System.Text.Encoding.UTF7.GetString(packet, 18, packet[17]);
                                            if (PhoenixProject.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanBuletion = buletin;
                                            Database.Clans.SaveClan(PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                            client.Send(packet);
                                            break;
                                        }
                                    case 22:
                                        {
                                            if (client.Entity.Myclan != null)
                                            {
                                                if (client.Entity.ClanRank == 100)
                                                {
                                                    string name = System.Text.Encoding.UTF7.GetString(packet, 18, packet[17]);
                                                    if (client.Entity.Myclan != null)
                                                    {
                                                        if (client.Entity.ClanRank == 100)
                                                        {
                                                            client.Entity.Myclan.ExpelMember(name, false);
                                                            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;
                                                if (PhoenixProject.ServerBase.Kernel.ServerClans.ContainsKey(client.Entity.Myclan.ClanId))
                                                    PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId].ClanDonation += money;
                                                Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                client.Send(cl.ToArray());
                                                Database.Clans.SaveClientDonation(client);
                                                Database.Clans.SaveClan(PhoenixProject.ServerBase.Kernel.ServerClans[client.Entity.Myclan.ClanId]);
                                            }
                                            break;
                                        }
                                    case 11:
                                        {

                                            uint lider = BitConverter.ToUInt32(packet, 8);
                                            if (PhoenixProject.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 (PhoenixProject.ServerBase.Kernel.GamePool[lider].Entity.Myclan != null)
                                                    PhoenixProject.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.Members.Count < 7)
                                                            {

                                                                uint memeber = BitConverter.ToUInt32(packet, 8);
                                                                if (ServerBase.Kernel.GamePool.ContainsKey(memeber))
                                                                {
                                                                    Game.ClanMembers member = new PhoenixProject.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 = 10;
                                                                    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);
                                                                    Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                                                                    client.Send(cl.ToArray());
                                                                    ClanMembers clan = new ClanMembers(client);
                                                                    client.Send(clan.ToArray());
                                                                }
                                                            }
                                                        }
                                                    }
                                            }
                                            break;
                                        }
                                    case 4:
                                        {
                                            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 PhoenixProject.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 Amount of Allies You can Have is 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 Amount of Allies the Target Clan can Have is 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("The 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.UTF7.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 is 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;
                            }
                        #endregion
                        #region SubClass (2320)
                        case 2320:
                            {
                                byte[] Packet = null;
                                switch (packet[4])
                                {
                                    //9 = learn 10= upgrade pro
                                    #region [Restore/Switch]
                                    case 0:
                                        byte To = packet[6];
                                        Packet = new byte[0];
                                        client.Send(packet);
                                        if (To > 0)//Switch
                                        {
                                            /*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;
                                            client.Entity.SubClassesActive = To;
                                            // Console.WriteLine("s " + To + "");
                                        }
                                        else//Restore
                                        {
                                            client.Entity.SubClass = 0;
                                            //client.Entity.SubClassLevel = 0;
                                            client.Entity.SubClasses.Active = 0;
                                            client.Entity.SubClassesActive = 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;
                                            Statement.SubClass Sc = client.Entity.SubClasses.Classes[Class];
                                            #region [Set Required]
                                            switch ((Statement.ClassID)Sc.ID)
                                            {
                                                case Statement.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 Statement.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 Statement.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 Statement.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 Statement.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 Statement.ClassID.Wrangler:
                                                case Statement.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);
                                            }
                                            break;
                                        }
                                    #endregion
                                    #region [Info]
                                    case 6:
                                        Game.Entity Owner = client.Entity;
                                        if (Owner.SubClasses.Classes.Count > 0)
                                        {
                                            Statement.SubClass[] Classes = new Statement.SubClass[Owner.SubClasses.Classes.Count];
                                            Owner.SubClasses.Classes.Values.CopyTo(Classes, 0);
                                            foreach (Statement.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
                                    #region [Learn]
                                    case 9://class type packet6
                                        byte Class1 = packet[6];
                                        if (PacketHandler.PassLearn((byte)packet[6], client.Entity))
                                        {
                                            if (!client.Entity.SubClasses.Classes.ContainsKey((byte)packet[6]))
                                            {
                                                {
                                                    client.Entity.SubClasses.Classes.Add((byte)packet[6], new PhoenixProject.Statement.SubClass() { ID = (byte)packet[6], Level = 1, Phase = 1 });
                                                    PhoenixProject.Database.SubClassTable.Insert(client.Entity, (byte)packet[6]);
                                                    Packet = new byte[0];
                                                    Packet = new SubClassShowFull(true) { ID = 1, Class = Class1, Level = client.Entity.SubClasses.Classes[Class1].Level }.ToArray();
                                                    client.Send(Packet);
                                                    Packet = new SubClass(client.Entity).ToArray();
                                                    client.Send(Packet);
                                                }
                                            }
                                        }

                                        break;
                                    #endregion
                                    #region [UpgradePro]
                                    case 10:
                                        byte Class2 = packet[6];

                                        if (client.Entity.SubClasses.Classes[(byte)Class2].Phase < client.Entity.SubClasses.Classes[(byte)Class2].Level)
                                        {
                                            client.Entity.SubClasses.Classes[(byte)Class2].Phase++;
                                            Database.SubClassTable.Update(client.Entity, client.Entity.SubClasses.Classes[(byte)Class2]);
                                            Packet = new byte[0];
                                            Packet = new SubClassShowFull(true) { ID = 1, Class = Class2, Level = client.Entity.SubClasses.Classes[Class2].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 ItemAdding Stabilization
                        case 1038:
                            {
                                ItemAddingStabilization stabilization = new ItemAddingStabilization(false);
                                stabilization.Deserialize(packet);
                                StabilazeArtifact(stabilization, client);
                                break;
                            }
                        #endregion
                        #region Data (10010)
                        case 10010:
                            {

                                if (client.Action != 2)
                                    return;
                                Data gData = new Data(false);
                                gData.Deserialize(packet);
                                if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                                {
                                    client.Send(new Message("Data ID: " + gData.ID, System.Drawing.Color.CadetBlue, Message.Talk));
                                }
                                switch (gData.ID)
                                {
                                    /*case Data.AllowAnimation:
                                        {
                                            LoginMessages(client);
                                            client.Send(new FlowerPacket(client.Entity.Flowers));
                                            //Database.SubClassTable.Load(client.Entity);
                                            ClientEquip equips = new ClientEquip();
                                            equips.DoEquips(client);
                                            client.Send(equips);
                                            client.Send(packet);
                                        }
                                        break;*/
                                    #region Appearance
                                    case 0xb2:
                                        {
                                            byte appearance = (byte)gData.dwParam;
                                            Data app = new Data(true)
                                            {
                                                ID = 0xb2,
                                                UID = client.Entity.UID,
                                                dwParam = appearance,
                                                wParam1 = client.Entity.X,
                                                wParam2 = client.Entity.Y
                                            };
                                            client.Send(gData);
                                            client.Send(app);
                                            client.SendScreen(gData, true);
                                            client.SendScreen(app, true);
                                            return;
                                        }
                                    #endregion
                                    case 132:
                                        {
                                            // Console.WriteLine(" this ");
                                            client.Disconnect();
                                            break;
                                        }
                                    /* case Data.KimoGearDis:
                                         {
                                             Console.WriteLine("data " + gData.dwParam + "");
                                             break;
                                         }*/
                                    case Data.UpdateProf:
                                        if (client != null)
                                        {
                                            ushort UplevelProficiency;
                                            UplevelProficiency = (ushort)gData.dwParam;

                                            var prof = client.Proficiencies[UplevelProficiency];

                                            if ((prof.Level >= 1) && (prof.Level <= 19))
                                            {
                                                if (prof.Level == 19 && client.Entity.ConquerPoints >= 1420)
                                                {
                                                    client.Entity.ConquerPoints -= 1420;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 18 && client.Entity.ConquerPoints >= 1154)
                                                {
                                                    client.Entity.ConquerPoints -= 1154;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 17 && client.Entity.ConquerPoints >= 799)
                                                {
                                                    client.Entity.ConquerPoints -= 799;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 16 && client.Entity.ConquerPoints >= 548)
                                                {
                                                    client.Entity.ConquerPoints -= 548;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 15 && client.Entity.ConquerPoints >= 375)
                                                {
                                                    client.Entity.ConquerPoints -= 375;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level >= 11 && prof.Level <= 14 && client.Entity.ConquerPoints >= 324)
                                                {
                                                    client.Entity.ConquerPoints -= 324;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 10 && client.Entity.ConquerPoints >= 270)
                                                {
                                                    client.Entity.ConquerPoints -= 270;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 9 && client.Entity.ConquerPoints >= 162)
                                                {
                                                    client.Entity.ConquerPoints -= 162;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 8 && client.Entity.ConquerPoints >= 135)
                                                {
                                                    client.Entity.ConquerPoints -= 135;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 7 && client.Entity.ConquerPoints >= 81)
                                                {
                                                    client.Entity.ConquerPoints -= 81;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 6 && client.Entity.ConquerPoints >= 54)
                                                {
                                                    client.Entity.ConquerPoints -= 54;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level >= 2 && prof.Level <= 5 && client.Entity.ConquerPoints >= 27)
                                                {
                                                    client.Entity.ConquerPoints -= 27;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                                if (prof.Level == 1)
                                                {
                                                    client.Entity.ConquerPoints -= 22;

                                                    prof.Level++;
                                                    prof.Experience = 0;
                                                    prof.Send(client);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //break;
                                        }
                                        break;
                                    case Data.UpdateSpell:
                                        if (client != null)
                                        {
                                            ushort UplevelProficiency;
                                            UplevelProficiency = (ushort)gData.dwParam;
                                            if (client.Spells.ContainsKey(UplevelProficiency))
                                            {
                                                var prof = client.Spells[UplevelProficiency];
                                                if (prof != null)
                                                {
                                                    int num2 = (int)Database.SpellTable.SpellInformations[UplevelProficiency][prof.Level].CPUpgradeRatio;
                                                    int num3 = Math.Max((int)prof.Experience, 1);
                                                    int num4 = 100 - ((int)(((ulong)num3) / ((ulong)Math.Max((uint)(Database.SpellTable.SpellInformations[UplevelProficiency][prof.Level].NeedExperience / 100), (uint)1))));
                                                    uint num = (uint)(((double)((num2 * num4) / 100)) / 22.2);
                                                    if (client.Entity.ConquerPoints >= num)
                                                    {

                                                        client.Entity.ConquerPoints -= num;
                                                        // Console.WriteLine(" " + num + "");
                                                        prof.Level++;
                                                        prof.Experience = 0;
                                                        prof.Send(client);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "Sorry you dont have " + num + " cps i cant help you!");
                                                        npc.OptionID = 255;
                                                        client.Send(npc.ToArray());
                                                        break;
                                                        //sorry you dont have 100 cps
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                        else
                                        {
                                            //break;
                                        }
                                        break;
                                    case Data.SwingPickaxe:
                                        client.Mining = true;
                                        break;
                                    case Data.Revive:
                                        Revive(gData, client);
                                        break;
                                    case Data.UsePortal:
                                        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 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.IProf 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 = (ushort)client.Map.BaseID, ID = (uint)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);
                                        client.Entity.MapRegion = Region.Region.FindRegion((uint)client.Map.BaseID, client.Entity.X, client.Entity.Y);
                                        break;
                                    case Data.Jump:
                                        {
                                            PlayerJump(gData, client);

                                            break;
                                        }
                                    case Data.BlueCountdown:
                                        {
                                            // 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;
                                                for (int x = 0; x < client.Map.Entities.Count; x++)
                                                {
                                                    if (x >= client.Map.Entities.Count)
                                                        break;
                                                    if (client.Map.Entities[x] != null)
                                                    {
                                                        if (client.Map.Entities[x].UID == gData.dwParam)
                                                        {
                                                            monster = client.Map.Entities[x];
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (monster != null)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= ServerBase.Constants.pScreenDistance)
                                                    {
                                                        monster.SendSpawn(client, false);
                                                    }
                                                }
                                                for (int x = 0; x < client.Map.Companions.Count; x++)
                                                {
                                                    if (x >= client.Map.Companions.Count)
                                                        break;
                                                    if (client.Map.Companions[x] != null)
                                                    {
                                                        if (client.Map.Companions[x].UID == gData.dwParam)
                                                        {
                                                            monster = client.Map.Companions[x];
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (monster != null)
                                                {
                                                    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:
                                        {
                                            client.MonsterHunterStats = new MonsterHunterStats(client);
                                            //client.MonsterHunterStats.Kills = (ushort)client.Entity.Status4;
                                            // client.MonsterHunterStats.Load(client);
                                            LoginMessages(client);
                                            Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                                            weather.WeatherType = (uint)Program.WeatherType;
                                            weather.Intensity = 100;
                                            weather.Appearence = 2;
                                            weather.Direction = 4;

                                            client.Send(new FlowerPacket(client.Entity.Flowers));
                                            client.Send(new FlowerPacket3(client));
                                            /*ClientEquip equips = new ClientEquip();
                                            equips.DoEquips(client);
                                            client.Send(equips);*/
                                            client.Send(packet);
                                            client.Send(weather);
                                            break;
                                        }
                                    case Data.ChangeFace:
                                        ChangeFace(gData, client);
                                        break;
                                    case Data.ObserveEquipment:
                                        ObserveEquipment2(gData, client);
                                        break;
                                    case Data.ObserveEquipment2:
                                        ObserveEquipment(gData, client);
                                        break;
                                    case 408:
                                        {
                                            /* if (!client.ChangeGear)
                                             {
                                                 Game.KimoChangeGear.Load(client);
                                             }
                                             else
                                             {

                                                 Game.KimoChangeGear.Load2(client);
                                             }
                                             client.ChangeGear = true;*/
                                            break;
                                        }

                                    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.Confiscator:
                                        client.Send(packet);
                                        break;
                                    case Data.OwnBooth:
                                        {
                                            client.Booth = new PhoenixProject.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.TempID = 400;

                                                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))
                                                {
                                                    // Console.WriteLine(" " + gData.dwParam + "");
                                                    gData.wParam1 = Client.Entity.X;
                                                    gData.wParam2 = Client.Entity.Y;
                                                    gData.Send(client);
                                                }
                                            }
                                            break;
                                        }
                                    default:
                                        if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager || client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                                            client.Send(new Message("Unknown generaldata id: " + gData.ID, System.Drawing.Color.CadetBlue, Message.Talk));
                                        break;
                                }
                                break;
                            }
                        #endregion
                        #region TimePacket (1033)
                        case 1033:
                            {
                                ServerTime time = new ServerTime();
                                time.Year = (uint)DateTime.Now.Year;
                                time.Month = (uint)DateTime.Now.Month;
                                time.DayOfYear = (uint)DateTime.Now.DayOfYear;
                                time.DayOfMonth = (uint)DateTime.Now.Day;
                                time.Hour = (uint)DateTime.Now.Hour;
                                time.Minute = (uint)DateTime.Now.Minute;
                                time.Second = (uint)DateTime.Now.Second;
                                client.Send(time);
                                break;
                            }
                        #endregion
                        #region MemoryAgate
                        case 2110:
                            {
                                uint ItemUID = BitConverter.ToUInt32(packet, 8);
                                switch (packet[4])
                                {
                                    case 1:
                                        {
                                            if (client.Map.IsDynamic()) return;
                                            if (ServerBase.Constants.revnomap.Contains(client.Entity.MapID))
                                                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.UpdateItemAgate(Item);
                                                    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.UpdateItemAgate(Item);
                                                    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.UpdateItemAgate(Item);
                                                        Item.SendAgate(client);
                                                    }
                                                    break;
                                                }
                                            }
                                            break;
                                        }
                                    case 3:
                                        {
                                            if (client.Map.IsDynamic()) return;
                                            if (ServerBase.Constants.revnomap.Contains(client.Entity.MapID))
                                                return;
                                            Interfaces.IConquerItem Item = null;
                                            if (client.Inventory.TryGetItem(ItemUID, out Item))
                                            {

                                                if (Item.Agate_map.ContainsKey(packet[12]))
                                                {
                                                    if (ServerBase.Constants.MemoryAgateNotAllowedMap.Contains(ushort.Parse(Item.Agate_map[packet[12]].Split('~')[0].ToString())))
                                                    {
                                                        return;
                                                    }
                                                    /*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.UpdateItemAgate(Item);
                                                }
                                            }
                                            break;
                                        }
                                    case 4:
                                        {
                                            if (ServerBase.Constants.MemoryAgateNotAllowedMap.Contains(client.Entity.MapID))
                                                return;
                                            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.UpdateItemAgate(Item);
                                                }
                                            }
                                            break;
                                        }
                                }
                                break;
                            }
                        #endregion
                        #region Ayudante
                        case 1321:
                        case 1322:
                        case 1136:
                        case 1320:

                            client.Send(packet);
                            break;
                        case 2261:
                            {
                                client.Send(packet);
                            }
                            break;
                        #endregion
                        #region Advertise
                        case 2226:
                            {
                                byte[] firstpacket = new byte[724]{0xCC,0x02,0xB2,0x08,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00//;̲0x,0x0x0x
            ,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x67,0x01,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x,0xg0x0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x75,0x83,0x83,0x50//;0x0x0x,0x,0xPuƒƒP
            ,0x75,0x83,0x83,0x50,0x61,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;uƒƒPa$$0x0x0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44//;0x0x0x0x0xD
            ,0x65,0x76,0x69,0x6C,0x5F,0x44,0x6F,0x67,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;evil_Dogg0x0x,0x
            ,0x01,0x00,0x00,0x00,0x83,0x00,0x00,0x00,0x81,0xC3,0x15,0x00,0x00,0x00,0x00,0x00//;0xƒ0xÃ0x,0x,0x
            ,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;,0x0x0x0x0x,0x
            ,0x7E,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;~0x0x0x0x,0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x41,0x4F,0x57,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0xAOW0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;0x0x0x0x0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x61,0x61,0x6E,0x00,0x00,0x00,0x00,0x00//;0x0x,0xsaan0x,0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0D,0x00,0x00,0x00//;0x0x,0x,0x0x0x
            ,0xA5,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00//;¥0x,0x,0x,0x0x,0x,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x51,0x53,0x65//;0x0x0x0xTQSe
            ,0x72,0x76,0x65,0x72};//;rver
                                client.Send(firstpacket);
                                byte[] secondpacket = new byte[724]{0xCC,0x02,0xB2,0x08,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00//;̲//////,0x//,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x01,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,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//;////////
            ,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,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,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,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,0x60,0x2A,0x41,0x75,0x74//;//////,0x`*Aut
            ,0x68,0x65,0x6E,0x74,0x69,0x63,0x2A,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;hentic*`////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4E//;//////,0xN
            ,0x61,0x72,0x72,0x63,0x6F,0x74,0x69,0x63,0x7A,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;arrcoticz//,0x
            ,0x01,0x00,0x00,0x00,0x59,0x00,0x00,0x00,0xDF,0xA3,0x59,0x00,0x00,0x00,0x00,0x00//;//,0xY//,0xߣY////,0x
            ,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;,0x////,0x
            ,0x7B,0x01,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,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,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,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,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,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,0x7E,0x2A,0x44,0x65,0x5F,0x41,0x5F,0x74,0x68,0x2A,0x7E,0x00,0x00//;//,0x~*De_A_th*~//
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//;////////
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5E,0x5E,0x5E,0x5E,0x5E,0x32,0x5E,0x5E,0x5E//;//,0x^^^^^2^^^
            ,0x5E,0x5E,0x5E,0x5E,0x5E,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00//;^^^^^//,0x//,0x//,0x
            ,0x10,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00//;'//,0x////,0x
            ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x51,0x53,0x65//;////TQSe
            ,0x72,0x76,0x65,0x72};//////////////;rver
                                client.Send(secondpacket);
                                break;
                            }
                        #endregion
                        #region OneArmedBandit 1351 AboRagab/Kimo/Amro kan bys2f
                        case 1351:
                            {
                                if (packet[4] == 0)
                                {
                                    if (client.Entity.ConquerPoints >= 100 * packet[5])
                                    {
                                        client.Send(packet);
                                        Sendonearmed(client);
                                        //PrintPacket(packet);
                                        client.Entity.ConquerPoints -= (uint)(100 * packet[5]);
                                        //Console.WriteLine("cps " +(uint)(100 * packet[5]));
                                    }
                                }
                                else
                                {
                                    Sendonearmed2(client);
                                    Prize3X(client);
                                    client.Entity.ConquerPoints += client.Entity.CPSS * packet[5];
                                    //Console.WriteLine("Win " + (uint)(client.Entity.CPSS * packet[5]));
                                    //PrintPacket(packet);
                                }
                                break;
                            }

                        #endregion
                        /*case 1044:
                            PrintPacket(packet);
                            client.Send(packet);
                            break;*/
                        /*#region PK Explorer (2220)
                         case 2220:
                             {
                                 PkExplorer pk = new PkExplorer(packet, client);
                                 pk.SubType = 1;
                                 client.Send(pk.Build());
                                 break;
                             }
                         #endregion*/
                        /* #region Cases de Packs
                         case 1034:
                         case 1037:
                             {
                                 client.Send(packet);
                                 break;
                             }
                         case 1135:
                             client.Send(packet);
                             break;
                         case 1134:
                             {
                                 switch (ID2)
                                 {
                                     case 1:
                                         client.Send(packet);
                                         break;
                                     case 2:
                                         client.Send(packet);
                                         break;
                                     case 3:
                                         client.Send(packet);
                                         break;
                                     case 4:
                                         client.Send(packet);
                                         break;
                                     case 5:
                                         client.Send(packet);
                                         break;
                                     case 6:
                                         client.Send(packet);
                                         break;
                                     case 7:
                                         client.Send(packet);
                                         break;
                                     case 8:
                                         client.Send(packet);
                                         break;
                                     case 9:
                                         client.Send(packet);
                                         break;
                                     case 10:
                                         client.Send(packet);
                                         break;
                                 }
                                 break;
                             }
                         #endregion*/
                        /*case 1134:
                            {
                                PhoenixProject.Network.GamePackets.Quest.QuestInfo.Handle(packet, client);
                                break;
                            }
                        case 1135:
                            {
                                PhoenixProject.Network.GamePackets.Quest.QuestQuery2.Handle(packet, client);
                                break;
                            }*/
                        /* case 1136:
                             {
                                 //PrintPacket(packet);
                                 client.Send(packet);
                                // PrintPacket(packet);
                                 break;
                             }*/
                        default:
                            {
                                if (client.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                                {
                                    ushort key = BitConverter.ToUInt16(packet, 2);
                                    //PrintPacket(packet);
                                    Console.WriteLine("[Kimo]=> Unknown Packet: " + key + "");
                                    // Console.WriteLine("[Kimo]=> Unknown Packet: " + key + " " + PacketConstructor.Dump(packet) + "");

                                }

                                break;
                            }
                    }
                }
            }
            catch (Exception e)
            {
                Program.SaveException(e);
            }
        }
            public Reincarnation(Client.GameState client, byte new_class)
            {
                if (client.Entity.Level < 120)
                    return;
                if (ServerBase.Kernel.ReincarnatedCharacters.ContainsKey(client.Entity.UID))
                    return;
                _client = client;
                Database.ReincarnationTable.NewReincarnated(client.Entity);
                Game.Features.Reincarnation.ReincarnateInfo info = new Game.Features.Reincarnation.ReincarnateInfo();
                info.UID = client.Entity.UID;
                info.Level = client.Entity.Level;
                info.Experience = client.Entity.Experience;
                ServerBase.Kernel.ReincarnatedCharacters.Add(info.UID, info);
                client.Entity.FirstRebornClass = client.Entity.SecondRebornClass;
                client.Entity.SecondRebornClass = client.Entity.Class;
                client.Entity.Class = new_class;
                client.Entity.SecondRebornLevel = client.Entity.Level;
                //client.Entity.ReincarnationLev = client.Entity.Level;//kikoz
                client.Entity.Level = 15;
                client.Entity.Experience = 0;
                client.Entity.Atributes =
                 (ushort)(client.ExtraAtributePoints(client.Entity.FirstRebornClass, client.Entity.FirstRebornLevel) +
                  client.ExtraAtributePoints(client.Entity.SecondRebornClass, client.Entity.SecondRebornLevel) + 62);
                #region RemoveAllSpells
                Interfaces.ISkill[] spells = client.Spells.Values.ToArray();
                foreach (Interfaces.ISkill spell in spells)
                {
                    if (!ServerBase.Constants.AvaibleSpells.Contains(spell.ID))
                    {
                        client.RemoveSpell(spell);
                    }
                    //spell.Send(client);
                }
                #endregion
                #region Blessed
                if (client.Entity.Reborn == 2)
                {
                    if (client.Entity.Reborn == 2)
                    {

                        client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                    }
                }
                #endregion

                #region SeconedClassTrojan
                if (client.Entity.SecondRebornClass == 15)
                {
                    if (client.Entity.SecondRebornClass == 15)
                    {
                        client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 1270 });//Robot
                        client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                    }
                }
                #endregion
                #region SeconedClassWarrior
                if (client.Entity.SecondRebornClass == 25)
                {
                    if (client.Entity.SecondRebornClass == 25)
                    {
                        client.AddSpell(new Spell(true) { ID = 1040 });//Raor
                        client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                        client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                        client.AddSpell(new Spell(true) { ID = 1025 });//Superman
                    }
                }
                #endregion
                #region SeconedClassArcher
                if (client.Entity.SecondRebornClass == 45)
                {
                    if (client.Entity.SecondRebornClass == 45)
                    {

                    }
                }
                #endregion
                #region SeconedClassNinja
                if (client.Entity.SecondRebornClass == 55)
                {
                    if (client.Entity.SecondRebornClass == 55)
                    {
                        client.AddSpell(new Spell(true) { ID = 6001 });//ToxicFog
                        client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                    }
                }
                #endregion
                #region SeconedClassMonk
                if (client.Entity.SecondRebornClass == 65)
                {
                    if (client.Entity.SecondRebornClass == 65)
                    {
                        client.AddSpell(new Spell(true) { ID = 10400 });//Serenity
                        client.AddSpell(new Spell(true) { ID = 10425 });//Tranquality
                    }
                }
                #endregion
                #region SeconedClassWater
                if (client.Entity.SecondRebornClass == 135)
                {
                    if (client.Entity.SecondRebornClass == 135)
                    {
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                        client.AddSpell(new Spell(true) { ID = 1085 });//StarOfAccuracy
                        client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                        client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                        client.AddSpell(new Spell(true) { ID = 1075 });//Invisibility
                        //client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                        //client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                    }
                }
                #endregion
                #region SeconedClassFire
                if (client.Entity.SecondRebornClass == 145)
                {
                    if (client.Entity.SecondRebornClass == 145)
                    {
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                    }
                }
                #endregion
                #region SeconedClassPirate
                if (client.Entity.SecondRebornClass == 75)
                {
                    if (client.Entity.SecondRebornClass == 75)
                    {
                        client.AddSpell(new Spell(true) { ID = 11070 });//ScurvyBomb
                    }
                }
                #endregion

                #region FirstClassTrojan
                if (client.Entity.FirstRebornClass == 15)
                {
                    if (client.Entity.FirstRebornClass == 15)
                    {
                        client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 1270 });//Robot
                        client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                    }
                }
                #endregion
                #region FirstClassWarrior
                if (client.Entity.FirstRebornClass == 25)
                {
                    if (client.Entity.FirstRebornClass == 25)
                    {
                        client.AddSpell(new Spell(true) { ID = 1040 });//Raor
                        client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                        client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                        client.AddSpell(new Spell(true) { ID = 1025 });//Superman
                    }
                }
                #endregion
                #region FirstClassArcher
                if (client.Entity.FirstRebornClass == 45)
                {
                    if (client.Entity.FirstRebornClass == 45)
                    {

                    }
                }
                #endregion
                #region FirstClassNinja
                if (client.Entity.FirstRebornClass == 55)
                {
                    if (client.Entity.FirstRebornClass == 55)
                    {
                        client.AddSpell(new Spell(true) { ID = 6001 });//ToxicFog
                        client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                    }
                }
                #endregion
                #region FirstClassMonk
                if (client.Entity.FirstRebornClass == 65)
                {
                    if (client.Entity.FirstRebornClass == 65)
                    {
                        client.AddSpell(new Spell(true) { ID = 10400 });//Serenity
                        client.AddSpell(new Spell(true) { ID = 10425 });//Tranquality
                    }
                }
                #endregion
                #region FirstClassWater
                if (client.Entity.FirstRebornClass == 135)
                {
                    if (client.Entity.FirstRebornClass == 135)
                    {
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                        client.AddSpell(new Spell(true) { ID = 1085 });//StarOfAccuracy
                        client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                        client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                        client.AddSpell(new Spell(true) { ID = 1075 });//Invisibility
                        //client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                        //client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                    }
                }
                #endregion
                #region FirstClassFire
                if (client.Entity.FirstRebornClass == 145)
                {
                    if (client.Entity.FirstRebornClass == 145)
                    {
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        //client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1195 });//Medation
                    }
                }
                #endregion
                #region FirstClassPirate
                if (client.Entity.FirstRebornClass == 75)
                {
                    if (client.Entity.FirstRebornClass == 75)
                    {
                        client.AddSpell(new Spell(true) { ID = 11070 });//GaleBomb
                    }
                }
                #endregion

                #region AddPureTrojanSpell
                if (client.Entity.FirstRebornClass == 15 && client.Entity.SecondRebornClass == 15)
                {
                    if (client.Entity.Class == 11)
                    {
                        client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 1115 });//Hercules
                        client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        client.AddSpell(new Spell(true) { ID = 10315 });//DragonWhirl
                        client.AddSpell(new Spell(true) { ID = 3050 });//CruelShade
                    }
                }
                #endregion
                #region AddPureWarSpell
                if (client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25)
                {
                    if (client.Entity.Class == 21)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10311 });//Perseverance
                        client.AddSpell(new Spell(true) { ID = 7020 });//Rage
                        client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                        client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                        client.AddSpell(new Spell(true) { ID = 1040 });//Roar
                        client.AddSpell(new Spell(true) { ID = 1025 });//SuperMan
                        client.AddSpell(new Spell(true) { ID = 1020 });//Shield
                        client.AddSpell(new Spell(true) { ID = 3060 });//Reflect
                    }
                }
                #endregion
                #region AddPureArcherSpell
                if (client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45)
                {
                    if (client.Entity.Class == 41)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10313 });//StarArrow
                        client.AddSpell(new Spell(true) { ID = 8030 });//ArrowRain
                        client.AddSpell(new Spell(true) { ID = 8002 });//XpFly
                        client.AddSpell(new Spell(true) { ID = 9000 });//INTE
                        client.AddSpell(new Spell(true) { ID = 8003 });//AdvanceFly
                        client.AddSpell(new Spell(true) { ID = 8000 });//RapidFire
                        client.AddSpell(new Spell(true) { ID = 8001 });//Scatter
                        //client.AddSpell(new Spell(true) { ID = 3060 });//Reflect
                    }
                }
                #endregion
                #region AddPureNinjaSpell
                if (client.Entity.FirstRebornClass == 55 && client.Entity.SecondRebornClass == 55)
                {
                    if (client.Entity.Class == 51)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 6003 });//CounterKill
                        client.AddSpell(new Spell(true) { ID = 6000 });//TwoFold
                        client.AddSpell(new Spell(true) { ID = 6001 });//Toxic
                        client.AddSpell(new Spell(true) { ID = 6002 });//PoisnStar
                        client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                        client.AddSpell(new Spell(true) { ID = 6010 });//ShurikenVortex
                        client.AddSpell(new Spell(true) { ID = 6011 });//FatalStrike
                        //client.AddSpell(new Spell(true) { ID = 3060 });//Reflect
                    }
                }
                #endregion
                #region AddPureMonkSpell
                if (client.Entity.FirstRebornClass == 65 && client.Entity.SecondRebornClass == 65)
                {
                    if (client.Entity.Class == 61)
                    {
                        ////client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10405 });//SoulShakle
                        client.AddSpell(new Spell(true) { ID = 10381 });//Radiant
                        client.AddSpell(new Spell(true) { ID = 10390 });//Oblivion
                        client.AddSpell(new Spell(true) { ID = 10400 });//Serinity
                        client.AddSpell(new Spell(true) { ID = 10415 });//Whirld
                        client.AddSpell(new Spell(true) { ID = 10425 });//Tranquilty
                        client.AddSpell(new Spell(true) { ID = 10490 });//TripleAttack
                        client.AddSpell(new Spell(true) { ID = 10430 });//Compassion
                    }
                }
                #endregion
                #region AddPureWaterSpell
                if (client.Entity.FirstRebornClass == 135 && client.Entity.SecondRebornClass == 135)
                {
                    if (client.Entity.Class == 132)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 30000 });//AzureShield
                        client.AddSpell(new Spell(true) { ID = 1280 });//WaterElf
                        client.AddSpell(new Spell(true) { ID = 1050 });//XpReveve
                        client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                        client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                        client.AddSpell(new Spell(true) { ID = 1100 });//Pray
                        client.AddSpell(new Spell(true) { ID = 1075 });//inv
                        client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                        client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                        client.AddSpell(new Spell(true) { ID = 1085 });//Star
                        client.AddSpell(new Spell(true) { ID = 1055 });//HealingRain
                        client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                        client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                    }
                }
                #endregion
                #region AddPureFireSpell
                if (client.Entity.FirstRebornClass == 145 && client.Entity.SecondRebornClass == 145)
                {
                    if (client.Entity.Class == 142)
                    {
                        //client.AddSpell(new Spell(true) { ID = 7001 });//Riding
                        //client.AddSpell(new Spell(true) { ID = 9876 });//Bless
                        client.AddSpell(new Spell(true) { ID = 10310 });//HeavenBlade
                        client.AddSpell(new Spell(true) { ID = 3080 });//Dodge
                        client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                        client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                        client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                        client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                        client.AddSpell(new Spell(true) { ID = 1002 });//Tornado
                        client.AddSpell(new Spell(true) { ID = 1150 });//FireRing
                        client.AddSpell(new Spell(true) { ID = 1180 });//FireMeteor
                        client.AddSpell(new Spell(true) { ID = 1120 });//FireCircle
                        client.AddSpell(new Spell(true) { ID = 1160 });//Bomb
                        client.AddSpell(new Spell(true) { ID = 1165 });//FireOfHell
                        client.AddSpell(new Spell(true) { ID = 1125 });//Volcano
                    }
                }
                #endregion
                #region AddPurePirate
                if (client.Entity.FirstRebornClass == 75 && client.Entity.SecondRebornClass == 75)
                {
                    if (client.Entity.Class == 71)
                    {
                        client.AddSpell(new Spell(true) { ID = 11110 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 11040 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 11050 });//Hercules
                        client.AddSpell(new Spell(true) { ID = 11060 });//Accury
                        client.AddSpell(new Spell(true) { ID = 11070 });//Scatter
                        client.AddSpell(new Spell(true) { ID = 11100 });//SpiritHealing
                        client.AddSpell(new Spell(true) { ID = 11120 });//Cyclone
                        client.AddSpell(new Spell(true) { ID = 11130 });//Hercules//11140
                        client.AddSpell(new Spell(true) { ID = 11140 });//Hercules//11140
                    }
                }
                #endregion

                if (client.Entity.Reborn == 2)
                {
                    #region if water
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 132 && client.Entity.Class <= 135)
                        {
                            //client.AddSpell(new Spell(true) { ID = 30000 });//AzureShield
                            client.AddSpell(new Spell(true) { ID = 1280 });//WaterElf
                            client.AddSpell(new Spell(true) { ID = 1050 });//XpReveve
                            client.AddSpell(new Spell(true) { ID = 1170 });//Nectar
                            client.AddSpell(new Spell(true) { ID = 1175 });//AdvancedCure
                            client.AddSpell(new Spell(true) { ID = 1100 });//Pray
                            client.AddSpell(new Spell(true) { ID = 1075 });//inv
                            client.AddSpell(new Spell(true) { ID = 1095 });//Stigma
                            client.AddSpell(new Spell(true) { ID = 1090 });//MagicShield
                            client.AddSpell(new Spell(true) { ID = 1085 });//Star
                            client.AddSpell(new Spell(true) { ID = 1055 });//HealingRain
                            client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                            client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                            client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                            client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                            client.AddSpell(new Spell(true) { ID = 1350 });//DivenHere
                        }
                    }
                    #endregion
                    #region if Fire
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 142 && client.Entity.Class <= 145)
                        {
                            //client.AddSpell(new Spell(true) { ID = 3080 });//Dodge
                            client.AddSpell(new Spell(true) { ID = 1195 });//Mediation
                            client.AddSpell(new Spell(true) { ID = 1001 });//Fire
                            client.AddSpell(new Spell(true) { ID = 1000 });//Thunder
                            client.AddSpell(new Spell(true) { ID = 1005 });//Cure
                            client.AddSpell(new Spell(true) { ID = 1002 });//Tornado
                            client.AddSpell(new Spell(true) { ID = 1150 });//FireRing
                            client.AddSpell(new Spell(true) { ID = 1180 });//FireMeteor
                            client.AddSpell(new Spell(true) { ID = 1120 });//FireCircle
                            client.AddSpell(new Spell(true) { ID = 1160 });//Bomb
                            client.AddSpell(new Spell(true) { ID = 1165 });//FireOfHell
                            client.AddSpell(new Spell(true) { ID = 1125 });//Volcano
                        }
                    }
                    #endregion
                    #region if Monk
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 60 && client.Entity.Class <= 65)
                        {
                            client.AddSpell(new Spell(true) { ID = 10381 });//Radiant
                            client.AddSpell(new Spell(true) { ID = 10390 });//Oblivion
                            client.AddSpell(new Spell(true) { ID = 10400 });//Serinity
                            client.AddSpell(new Spell(true) { ID = 10415 });//Whirld
                            client.AddSpell(new Spell(true) { ID = 10425 });//Tranquilty
                            client.AddSpell(new Spell(true) { ID = 10490 });//TripleAttack
                            client.AddSpell(new Spell(true) { ID = 10430 });//Compassion

                            client.AddSpell(new Spell(true) { ID = 10420 });//Whirld
                            client.AddSpell(new Spell(true) { ID = 10421 });//Tranquilty
                            client.AddSpell(new Spell(true) { ID = 10422 });//TripleAttack
                            client.AddSpell(new Spell(true) { ID = 10423 });//Compassion
                            client.AddSpell(new Spell(true) { ID = 10424 });//Compassion

                            client.AddSpell(new Spell(true) { ID = 10410 });//Compassion
                            client.AddSpell(new Spell(true) { ID = 10395 });//Compassion
                        }
                    }
                    #endregion
                    #region if Ninja
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 50 && client.Entity.Class <= 55)
                        {
                            client.AddSpell(new Spell(true) { ID = 6000 });//TwoFold
                            client.AddSpell(new Spell(true) { ID = 6001 });//Toxic
                            //client.AddSpell(new Spell(true) { ID = 6002 });//PoisnStar
                            client.AddSpell(new Spell(true) { ID = 6004 });//ArcherBane
                            client.AddSpell(new Spell(true) { ID = 6010 });//ShurikenVortex
                            client.AddSpell(new Spell(true) { ID = 6011 });//FatalStrike
                        }
                    }
                    #endregion
                    #region if Warrior
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 20 && client.Entity.Class <= 21)
                        {
                            client.AddSpell(new Spell(true) { ID = 1051 });//Dash
                            client.AddSpell(new Spell(true) { ID = 1320 });//FlyingMoon
                            client.AddSpell(new Spell(true) { ID = 1040 });//Roar
                            client.AddSpell(new Spell(true) { ID = 1025 });//SuperMan
                            client.AddSpell(new Spell(true) { ID = 1020 });//Shield
                        }
                    }
                    #endregion
                    #region if Archer
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 40 && client.Entity.Class <= 45)
                        {
                            client.AddSpell(new Spell(true) { ID = 8030 });//ArrowRain
                            client.AddSpell(new Spell(true) { ID = 8002 });//XpFly
                            client.AddSpell(new Spell(true) { ID = 9000 });//INTE
                            client.AddSpell(new Spell(true) { ID = 8003 });//AdvanceFly
                            client.AddSpell(new Spell(true) { ID = 8000 });//RapidFire
                            client.AddSpell(new Spell(true) { ID = 8001 });//Scatter
                        }
                    }
                    #endregion
                    #region if Trojan
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 10 && client.Entity.Class <= 15)
                        {
                            client.AddSpell(new Spell(true) { ID = 1190 });//SpiritHealing
                            client.AddSpell(new Spell(true) { ID = 1110 });//Cyclone
                            client.AddSpell(new Spell(true) { ID = 1115 });//Hercules
                            client.AddSpell(new Spell(true) { ID = 1015 });//Accury
                            client.AddSpell(new Spell(true) { ID = 1270 });//Scatter
                        }
                    }
                    #endregion
                    #region if Pirate
                    if (client.Entity.Reborn == 2)
                    {
                        if (client.Entity.Class >= 70 && client.Entity.Class <= 75)
                        {
                            client.AddSpell(new Spell(true) { ID = 11110 });//SpiritHealing
                            // client.AddSpell(new Spell(true) { ID = 11040 });//Cyclone
                            client.AddSpell(new Spell(true) { ID = 11050 });//Hercules
                            client.AddSpell(new Spell(true) { ID = 11060 });//Accury
                            client.AddSpell(new Spell(true) { ID = 11070 });//Scatter
                            //client.AddSpell(new Spell(true) { ID = 11100 });//SpiritHealing
                            client.AddSpell(new Spell(true) { ID = 11120 });//Cyclone
                            client.AddSpell(new Spell(true) { ID = 11130 });//Hercules//11140
                            client.AddSpell(new Spell(true) { ID = 11140 });//Hercules//11140
                            //client.AddSpell(new Spell(true) { ID = 11060 });//Accury
                            //client.AddSpell(new Spell(true) { ID = 11070 });//Scatter
                        }
                    }
                    #endregion
                }

                #region Adding earned skills
                if (client.Entity.SecondRebornClass == 15 && client.Entity.Class == 11)
                {
                    client.AddSpell(new Spell(true) { ID = 3050 });
                }
                if (client.Entity.SecondRebornClass == 75 && client.Entity.Class == 71)
                {
                    client.AddSpell(new Spell(true) { ID = 11100 });
                }
                if (client.Entity.Class == 51)
                {
                    client.AddSpell(new Spell(true) { ID = 11230 });
                }
                if (client.Entity.SecondRebornClass == 55 && client.Entity.Class == 51)
                {
                    client.AddSpell(new Spell(true) { ID = 6002 });
                }
                if (client.Entity.SecondRebornClass == 145 && client.Entity.Class == 142)
                {
                    client.AddSpell(new Spell(true) { ID = 3080 });
                }
                if (client.Entity.SecondRebornClass == 135 && client.Entity.Class == 132)
                {
                    client.AddSpell(new Spell(true) { ID = 3090 });
                }
                if (client.Entity.SecondRebornClass == 55 && client.Entity.FirstRebornClass == 55)
                {
                    client.AddSpell(new Spell(true) { ID = 6002 });
                }
                if (client.Entity.SecondRebornClass == 15 && client.Entity.FirstRebornClass == 15)
                {
                    client.AddSpell(new Spell(true) { ID = 3050 });
                }
                if (client.Entity.SecondRebornClass == 75 && client.Entity.FirstRebornClass == 75)
                {
                    client.AddSpell(new Spell(true) { ID = 11100 });
                }
                if (client.Entity.SecondRebornClass == 25)
                {
                    client.AddSpell(new Spell(true) { ID = 3060 });
                }
                if (client.Entity.SecondRebornClass == 145 && client.Entity.FirstRebornClass == 145)
                {
                    client.AddSpell(new Spell(true) { ID = 3080 });
                }
                if (client.Entity.SecondRebornClass == 135 && client.Entity.FirstRebornClass == 135)
                {
                    client.AddSpell(new Spell(true) { ID = 3090 });
                }
                #endregion

                #region Remove unallow skills skills
                if (client.Entity.Class == 11)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 71)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 41)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });

                }
                if (client.Entity.Class == 51)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 61)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                    client.RemoveSpell(new Spell(true) { ID = 1020 });
                }
                if (client.Entity.Class == 142)
                {
                    client.RemoveSpell(new Spell(true) { ID = 1025 });
                }
                if (client.Entity.Class == 142)
                {
                    client.RemoveSpell(new Spell(true) { ID = 6002 });
                }
                if (client.Entity.Class == 132)
                {
                    client.RemoveSpell(new Spell(true) { ID = 6002 });
                }
                #endregion

                #region Proficiencies
                foreach (Interfaces.ISkill proficiency in client.Proficiencies.Values)
                {
                    proficiency.PreviousLevel = proficiency.Level;
                    proficiency.Level = 0;
                    proficiency.Experience = 0;
                    proficiency.Send(client);
                }
                #endregion
                #region Low level items
                for (byte i = 1; i < 9; i++)
                {
                    if (i != 7)
                    {
                        Interfaces.IConquerItem item = client.Equipment.TryGetItem(i);
                        if (item != null && item.ID != 0)
                        {
                            try
                            {
                                //client.UnloadItemStats(item, false);
                                Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                                item.ID = cii.LowestID(Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
                                item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                item.Send(client);
                                client.LoadItemStats(client.Entity);
                                client.CalculateStatBonus();
                                client.CalculateHPBonus();
                                Database.ConquerItemTable.UpdateItemID(item, client);
                            }
                            catch
                            {
                                Console.WriteLine("Reborn item problem: " + item.ID);
                            }
                        }
                    }
                }
                #region Alt Fix By Amjad
                Interfaces.IConquerItem AltRing = client.Equipment.TryGetItem(26);
                if (AltRing != null)
                {
                    client.Equipment.Remove(26);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltRightHand = client.Equipment.TryGetItem(24);
                if (AltRightHand != null)
                {
                    client.Equipment.Remove(24);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltNecklace = client.Equipment.TryGetItem(22);
                if (AltNecklace != null)
                {
                    client.Equipment.Remove(22);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltHead = client.Equipment.TryGetItem(21);
                if (AltHead != null)
                {
                    client.Equipment.Remove(21);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltLeftHand = client.Equipment.TryGetItem(25);
                if (AltLeftHand != null)
                {
                    client.Equipment.Remove(25);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltBoots = client.Equipment.TryGetItem(28);
                if (AltBoots != null)
                {
                    client.Equipment.Remove(28);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                Interfaces.IConquerItem AltArmor = client.Equipment.TryGetItem(23);
                if (AltArmor != null)
                {
                    client.Equipment.Remove(23);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);

                #endregion
                Interfaces.IConquerItem hand = client.Equipment.TryGetItem(5);
                if (hand != null)
                {
                    client.Equipment.Remove(5);
                    client.CalculateStatBonus();
                    client.CalculateHPBonus();
                    client.SendStatMessage();
                }
                else
                    client.SendScreen(client.Entity.SpawnPacket, false);
                #endregion
                Database.DataHolder.GetStats(client.Entity.Class, client.Entity.Level, client);
                // client.loadi
                client.CalculateStatBonus();
                client.CalculateHPBonus();
                client.GemAlgorithm();
                client.SendStatMessage();
                client.Equipment.UpdateEntityPacket();
                //Database.ReincarnationTable.NewReincarnated(client.Entity);
                Network.PacketHandler.WorldMessage(client.Entity.Name + " has got Reincarnation! Congratulations!");
            }
 static void UpgradeItem(ItemUsage itemUsage, Client.GameState client)
 {
     Interfaces.IConquerItem item = null;
     if (client.Inventory.TryGetItem(itemUsage.UID, out item))
     {
         if (IsArrow(item.ID))
             return;
         Interfaces.IConquerItem upgrade = null;
         if (client.Inventory.TryGetItem(itemUsage.dwParam, out upgrade))
         {
             Database.ConquerItemInformation infos = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
             switch (upgrade.ID)
             {
                 case 1088000:
                     {
                         if (item.ID % 10 == (byte)Game.Enums.ItemQuality.Super)
                             break;
                         byte chance = (byte)(70 - ((infos.BaseInformation.Level - (infos.BaseInformation.Level > 100 ? 30 : 0)) / (10 - item.ID % 10)));
                         if (item.Durability < item.MaximDurability)
                             break;
                         if (ServerBase.Kernel.Rate(chance))
                         {
                             switch ((Game.Enums.ItemQuality)(item.ID % 10))
                             {
                                 case Game.Enums.ItemQuality.Normal:
                                 case Game.Enums.ItemQuality.NormalV1:
                                 case Game.Enums.ItemQuality.NormalV2:
                                 case Game.Enums.ItemQuality.NormalV3: item.ID = (item.ID - (item.ID % 10)) + (byte)Game.Enums.ItemQuality.Refined; break;
                                 default: item.ID++; break;
                             }
                             Database.ConquerItemTable.UpdateItemID(item, client);
                             item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                             item.Send(client);
                         }
                         else
                         {
                             item.Durability = (ushort)(item.Durability / 2);
                             Database.ConquerItemTable.UpdateDurabilityItem(item);
                             item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                             item.Send(client);
                         }
                         item = ItemSocket(item, 1);
                         client.Inventory.Remove(upgrade, PhoenixProject.Game.Enums.ItemUse.Remove);
                         break;
                     }
                 case 1088001:
                     {
                         if (infos.BaseInformation.Level == ItemMaxLevel(ItemPosition(infos.BaseInformation.ID)))
                             break;
                         byte chance = 70;
                         chance -= (byte)(infos.BaseInformation.Level / 10 * 3);
                         chance -= (byte)(((item.ID % 10) + 1) * 3);
                         if (item.Durability < item.MaximDurability)
                             break;
                         uint newid = infos.CalculateUplevel();
                         if (newid != 0 && newid != item.ID)
                         {
                             if (ServerBase.Kernel.Rate(chance))
                             {
                                 item.ID = newid;
                                 infos = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                                 item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
                                 Database.ConquerItemTable.UpdateItemID(item, client);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             else
                             {
                                 item.Durability = (ushort)(item.Durability / 2);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             //item = ItemSocket(item, 2);
                             client.Inventory.Remove(upgrade, PhoenixProject.Game.Enums.ItemUse.Remove);
                         }
                         break;
                     }
                 case 1088002:
                     {
                         ushort postion = ItemPosition(infos.BaseInformation.ID);
                         byte level = ItemMinLevel(postion);
                         if (postion == 6)
                         {
                             if (infos.BaseInformation.ID.ToString()[2] == '1')
                                 level = 13;
                         }
                         if (infos.BaseInformation.Level <= level)
                         {
                             client.Send(new Message("This item's level is too low. It can't be downgraded more.", System.Drawing.Color.MistyRose, Message.TopLeft));
                             break;
                         }
                         byte chance = 100;
                         if (item.Durability < item.MaximDurability)
                             break;
                         uint newid = infos.CalculateDownlevel();
                         if (newid != 0 && newid != item.ID)
                         {
                             if (ServerBase.Kernel.Rate(chance))
                             {
                                 item.ID = newid;
                                 infos = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                                 item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
                                 Database.ConquerItemTable.UpdateItemID(item, client);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             else
                             {
                                 item.Durability = (ushort)(item.Durability / 2);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             //item = ItemSocket(item, 2);
                             client.Inventory.Remove(upgrade, PhoenixProject.Game.Enums.ItemUse.Remove);
                         }
                         break;
                     }
             }
         }
     }
 }
        public bool Add(Interfaces.IConquerItem item, Enums.ItemUse use)
        {
            try {
            if (!Database.ConquerItemInformation.BaseInformations.ContainsKey(item.ID))
                return true;
            if (Count == 40)
            {
                Owner.Send(ServerBase.Constants.FullInventory);
                return false;
            }
            if (!inventory.ContainsKey(item.UID))
            {
                item.Position = 0;
                Interfaces.IConquerItem _ExistingItem;
                Database.ConquerItemInformation iteminfo = new PhoenixProject.Database.ConquerItemInformation(item.ID, 0);
                if (Owner.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem) && Owner.SpiltStack && use !=Enums.ItemUse.None)
                {

                    if (_ExistingItem.StackSize == 0)
                        _ExistingItem.StackSize = 1;
                    ushort _StackCount = iteminfo.BaseInformation.StackSize;
                    _StackCount -= (ushort)_ExistingItem.StackSize;

                    if (_StackCount >= 1)
                        _StackCount += 1;
                    _ExistingItem.StackSize += 1;

                    Database.ConquerItemTable.UpdateStack(_ExistingItem);
                    _ExistingItem.Mode = Game.Enums.ItemMode.Update;
                    _ExistingItem.Send(Owner);
                    _ExistingItem.Mode = Game.Enums.ItemMode.Default;
                    switch (use)
                    {

                        case Enums.ItemUse.Add:
                            Database.ConquerItemTable.DeleteItem(item.UID);
                            break;
                        case Enums.ItemUse.Move:
                            Database.ConquerItemTable.DeleteItem(item.UID);
                            break;
                    }
                    // Owner.SpiltStack = false;
                    return true;

                }
                else
                {
                    switch (use)
                    {
                        case Enums.ItemUse.CreateAndAdd:
                            item.UID = PhoenixProject.Client.AuthState.nextID;
                            PhoenixProject.Client.AuthState.nextID++;
                            Database.ConquerItemTable.AddItem(ref item, Owner);
                            item.MobDropped = false;
                            break;
                        case Enums.ItemUse.Add:
                            Database.ConquerItemTable.UpdateLocation(item, Owner);
                            break;
                        case Enums.ItemUse.Move:
                            item.Position = 0;
                            item.StatsLoaded = false;
                            Database.ConquerItemTable.UpdateLocation(item, Owner);
                            break;
                    }
                    inventory.Add(item.UID, item);
                    objects = inventory.Values.ToArray();
                    item.Mode = Enums.ItemMode.Default;
                    if (use != Enums.ItemUse.None)
                        item.Send(Owner);
                    return true;
                }
            }
            }
            catch (Exception e)
            {
            Program.SaveException(e);
            }
            return false;
        }
        public void LoadItemStats(Game.Entity e)
        {
            #region Set Every Variable to Zero
            Entity.Defence = 0;
            Entity.MagicDefence = 0;
            Entity.Dodge = 0;
            Entity.BaseMagicAttack = 0;
            Entity.WoodResistance = 0;
            Entity.FireResistance = 0;
            Entity.WaterResistance = 0;
            Entity.EarthResistance = 0;
            Entity.MetalResistance = 0;
            Entity.Breaktrough = 0;
            Entity.CriticalStrike = 0;
            Entity.Immunity = 0;
            Entity.Penetration = 0;
            Entity.Counteraction = 0;
            Entity.Block = 0;
            Entity.Detoxication = 0;
            Entity.Intensification = 0;
            Entity.Penetration = 0;
            Entity.SkillCStrike = 0;
            Entity.MaxAttack = 0;
            Entity.MinAttack = 0;
            Entity.PhysicalDamageDecrease = 0;
            Entity.MagicDamageDecrease = 0;
            Entity.MagicDamageIncrease = 0;
            Entity.PhysicalDamageIncrease = 0;
            Entity.MagicDefencePercent = 0;
            Entity.ItemHP = 0;
            Entity.ItemMP = 0;
            Entity.ItemBless = 0;
            Entity.AttackRange = 0;
            Entity.BaseMinAttack = 0;
            Entity.BaseMaxAttack = 0;
            Entity.BaseMagicDefence = 0;
            Entity.BaseDefence = 0;
            Entity.MagicAttack = 0;
            Entity.MagicDefence = 0;
            Entity.DragonGem = 0;
            Entity.PhoenixGem = 0;
            Entity.TortisGem = 0;
            Entity.MagicDefencePercent = 0;
            Entity.MagicDamageIncrease = 0;
            Entity.Gems = new UInt16[10];
            #endregion

            foreach (IConquerItem i in Equipment.Objects)
            {
                if (i != null)
                {

                    if (i.Durability != 0 && i.Position < 20)
                    {
                        if (i.Position != ConquerItem.Garment && i.Position != ConquerItem.LeftWeaponAccessory && i.Position != ConquerItem.RightWeaponAccessory)
                        {
                            if (i.Position != ConquerItem.SteedArmor)
                            {

                                Database.ConquerItemInformation dbi = new Database.ConquerItemInformation(i.ID, i.Plus);
                                if (dbi != null)
                                {
                                    if (i.ID == 0x493e0)
                                    {
                                        byte r = 0;
                                        byte g = 0;
                                        byte b = 0;
                                        r = (byte)i.kimo1;
                                        g = (byte)i.kimo2;
                                        b = (byte)i.kimo3;
                                        i.Color = (PhoenixProject.Game.Enums.Color)b;
                                        i.Bless = g;
                                        i.Unknown40 = r;
                                        //i.Send(e.Owner);
                                    }

                                    #region Give Stats.
                                    Refinery.RefineryItem refine = null;
                                    Database.ConquerItemInformation soulDB = new PhoenixProject.Database.ConquerItemInformation(i.Purification.PurificationItemID, 0);
                                    if (i.RefineItem != 0)
                                        refine = i.RefineStats;
                                    if (soulDB != null)
                                    {
                                        Entity.Defence += soulDB.BaseInformation.PhysicalDefence;

                                        //Entity.Defence += soulDB.BaseInformation.PhysicalDefence;
                                        //Entity.Defence += soulDB.BaseInformation.PhysicalDefence;
                                        Entity.MagicDefence += soulDB.BaseInformation.MagicDefence;
                                        Entity.Dodge += (byte)soulDB.BaseInformation.Dodge;
                                        //Entity.Hitpoints += Infos.ItemHP;
                                        Entity.BaseMagicAttack += soulDB.BaseInformation.MagicAttack;
                                        Entity.BaseMinAttack += soulDB.BaseInformation.MinAttack;
                                        Entity.BaseMaxAttack += soulDB.BaseInformation.MaxAttack;

                                        // Entity.MetalResistance += soulDB.BaseInformation.me;
                                        Entity.WoodResistance += soulDB.BaseInformation.WoodResist;
                                        Entity.FireResistance += soulDB.BaseInformation.FireResist;
                                        Entity.WaterResistance += soulDB.BaseInformation.WaterResist;
                                        Entity.EarthResistance += soulDB.BaseInformation.EarthResist;
                                        Entity.Breaktrough += soulDB.BaseInformation.BreakThrough;
                                        Entity.CriticalStrike += soulDB.BaseInformation.CriticalStrike;
                                        Entity.Immunity += soulDB.BaseInformation.Immunity;
                                        Entity.ItemHP += soulDB.BaseInformation.ItemHP;
                                        Entity.ItemMP += soulDB.BaseInformation.ItemMP;
                                        Entity.Penetration += soulDB.BaseInformation.Penetration;
                                        Entity.Counteraction += soulDB.BaseInformation.CounterAction;
                                        Entity.Block += soulDB.BaseInformation.Block;
                                    }
                                    if (refine != null)
                                    {
                                        switch (refine.Type)
                                        {
                                            case Refinery.RefineryItem.RefineryType.Block:
                                                Entity.Block += (UInt16)(refine.Percent * 100);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.BreakThrough:
                                                Entity.Breaktrough += (UInt16)((refine.Percent * 10) + 100);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.Counteraction:
                                                Entity.Counteraction += (UInt16)(refine.Percent * 10);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.Critical:
                                                Entity.CriticalStrike += (UInt16)((refine.Percent * 100) + 1000);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.Detoxication:
                                                Entity.Detoxication += (UInt16)(refine.Percent);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.Immunity:
                                                Entity.Immunity += (UInt16)(refine.Percent * 100);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.Intensification:
                                                Entity.Intensification += (UInt16)(refine.Percent);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.Penetration:
                                                Entity.Penetration += (UInt16)(refine.Percent * 100);
                                                break;
                                            case Refinery.RefineryItem.RefineryType.SCritical:
                                                Entity.SkillCStrike += (UInt16)(refine.Percent * 100);
                                                break;
                                        }
                                    }
                                    if (i.Position == ConquerItem.Tower)
                                    {
                                        Entity.PhysicalDamageDecrease += dbi.BaseInformation.PhysicalDefence;
                                        Entity.MagicDamageDecrease += dbi.BaseInformation.MagicDefence;
                                    }
                                    else
                                    {
                                        Entity.Defence += dbi.BaseInformation.PhysicalDefence;
                                        Entity.MagicDefencePercent += dbi.BaseInformation.MagicDefence;
                                        Entity.Dodge += (byte)dbi.BaseInformation.Dodge;
                                        if (i.Position != ConquerItem.Fan)
                                            Entity.BaseMagicAttack += dbi.BaseInformation.MagicAttack;
                                    }
                                    Entity.ItemHP += dbi.BaseInformation.ItemHP;
                                    Entity.ItemMP += dbi.BaseInformation.ItemMP;
                                    if (i.ID != 0x493e0)
                                    {
                                        Entity.ItemBless += i.Bless;
                                    }
                                    if (i.Position == ConquerItem.RightWeapon)
                                    {
                                        Entity.AttackRange += dbi.BaseInformation.AttackRange;
                                        if (Network.PacketHandler.IsTwoHand(dbi.BaseInformation.ID))
                                            Entity.AttackRange += 3;
                                        else
                                        {
                                            Entity.AttackRange += 2;
                                        }
                                    }
                                    if (i.Position == ConquerItem.LeftWeapon)
                                    {
                                        Entity.BaseMinAttack += (uint)(dbi.BaseInformation.MinAttack * 0.5F);
                                        Entity.BaseMaxAttack += (uint)(dbi.BaseInformation.MaxAttack * 0.5F);
                                    }
                                    else if (i.Position == ConquerItem.Fan)
                                    {
                                        Entity.PhysicalDamageIncrease += dbi.BaseInformation.MinAttack;
                                        Entity.MagicDamageIncrease += dbi.BaseInformation.MagicAttack;
                                    }
                                    else
                                    {
                                        Entity.BaseMinAttack += dbi.BaseInformation.MinAttack;
                                        Entity.BaseMaxAttack += dbi.BaseInformation.MaxAttack;
                                    }
                                    if (i.Plus != 0)
                                    {
                                        if (i.Position == ConquerItem.Tower)
                                        {
                                            Entity.PhysicalDamageDecrease += dbi.PlusInformation.PhysicalDefence;
                                            Entity.MagicDamageDecrease += (ushort)dbi.PlusInformation.MagicDefence;
                                        }
                                        else if (i.Position == ConquerItem.Fan)
                                        {
                                            Entity.PhysicalDamageIncrease += (ushort)dbi.PlusInformation.MinAttack;
                                            Entity.MagicDamageIncrease += (ushort)dbi.PlusInformation.MagicAttack;
                                        }
                                        else
                                        {

                                            Entity.BaseMinAttack += dbi.PlusInformation.MinAttack;
                                            Entity.BaseMaxAttack += dbi.PlusInformation.MaxAttack;
                                            Entity.BaseMagicAttack += dbi.PlusInformation.MagicAttack;
                                            Entity.Defence += dbi.PlusInformation.PhysicalDefence;
                                            Entity.MagicDefence += dbi.PlusInformation.MagicDefence;
                                            Entity.ItemHP += dbi.PlusInformation.ItemHP;
                                            if (i.Position == ConquerItem.Boots)
                                            {
                                                Entity.Dodge += (byte)dbi.PlusInformation.Dodge;
                                            }
                                            if (i.Position == ConquerItem.Steed)
                                            {
                                                Entity.ExtraVigor += dbi.PlusInformation.Agility;
                                            }
                                        }
                                    }
                                    byte socketone = (byte)i.SocketOne;
                                    byte sockettwo = (byte)i.SocketTwo;
                                    ushort madd = 0, dadd = 0, aatk = 0, matk = 0;
                                    switch (socketone)
                                    {
                                        case 1: Entity.PhoenixGem += 5; break;
                                        case 2: Entity.PhoenixGem += 10; break;
                                        case 3: Entity.PhoenixGem += 15; break;

                                        case 11: Entity.DragonGem += 5; break;
                                        case 12: Entity.DragonGem += 10; break;
                                        case 13: Entity.DragonGem += 15; break;

                                        case 71: Entity.TortisGem += 15; break;
                                        case 72: Entity.TortisGem += 30; break;
                                        case 73: Entity.TortisGem += 50; break;

                                        case 101: aatk = matk += 100; break;
                                        case 102: aatk = matk += 300; break;
                                        case 103: aatk = matk += 500; break;

                                        case 121: madd = dadd += 100; break;
                                        case 122: madd = dadd += 300; break;
                                        case 123: madd = dadd += 500; break;
                                    }
                                    switch (sockettwo)
                                    {
                                        case 1: Entity.PhoenixGem += 5; break;
                                        case 2: Entity.PhoenixGem += 10; break;
                                        case 3: Entity.PhoenixGem += 15; break;

                                        case 11: Entity.DragonGem += 5; break;
                                        case 12: Entity.DragonGem += 10; break;
                                        case 13: Entity.DragonGem += 15; break;

                                        case 71: Entity.TortisGem += 15; break;
                                        case 72: Entity.TortisGem += 30; break;
                                        case 73: Entity.TortisGem += 50; break;

                                        case 101: aatk = matk += 100; break;
                                        case 102: aatk = matk += 300; break;
                                        case 103: aatk = matk += 500; break;

                                        case 121: madd = dadd += 100; break;
                                        case 122: madd = dadd += 300; break;
                                        case 123: madd = dadd += 500; break;
                                    }
                                    Entity.PhysicalDamageDecrease += dadd;
                                    Entity.MagicDamageDecrease += madd;
                                    Entity.PhysicalDamageIncrease += aatk;
                                    Entity.MagicDamageIncrease += matk;

                                    Entity.ItemHP += i.Enchant;
                                    GemAlgorithm();

                                    #endregion
                                }
                            }
                        }
                    }
                }
            }
        }
        public bool Reborn(byte toClass)
        {
            #region Items
            if (Inventory.Count > 38)
                return false;
            switch (toClass)
            {
                case 11:
                case 21:
                case 51:
                case 61:
                case 71:
                    {
                        Inventory.Add(410077, Game.Enums.ItemEffect.Poison);
                        break;
                    }
                case 41:
                    {
                        Inventory.Add(500057, Game.Enums.ItemEffect.Shield);
                        break;
                    }
                case 132:
                case 142:
                    {
                        if (toClass == 132)
                            Inventory.Add(421077, Game.Enums.ItemEffect.MP);
                        else
                            Inventory.Add(421077, Game.Enums.ItemEffect.HP);
                        break;
                    }
            }
            #region Low level items
            for (byte i = 1; i < 9; i++)
            {
                if (i != 7)
                {
                    Interfaces.IConquerItem item = Equipment.TryGetItem(i);
                    if (item != null && item.ID != 0)
                    {
                        try
                        {
                            //UnloadItemStats(item, false);
                            Database.ConquerItemInformation cii = new PhoenixProject.Database.ConquerItemInformation(item.ID, item.Plus);
                            item.ID = cii.LowestID(Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
                            item.Mode = PhoenixProject.Game.Enums.ItemMode.Update;
                            item.Send(this);
                            LoadItemStats(this.Entity);
                            Database.ConquerItemTable.UpdateItemID(item, this);
                        }
                        catch
                        {
                            Console.WriteLine("Reborn item problem: " + item.ID);
                        }
                    }
                }
            }
            #region Alt Fix By Amjad
            Interfaces.IConquerItem AltRing = Equipment.TryGetItem(26);
            if (AltRing != null)
            {
                Equipment.Remove(26);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);
            Interfaces.IConquerItem AltRightHand = Equipment.TryGetItem(24);
            if (AltRightHand != null)
            {
                Equipment.Remove(24);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);
            Interfaces.IConquerItem AltNecklace = Equipment.TryGetItem(22);
            if (AltNecklace != null)
            {
                Equipment.Remove(22);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);
            Interfaces.IConquerItem AltHead = Equipment.TryGetItem(21);
            if (AltHead != null)
            {
                Equipment.Remove(21);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);
            Interfaces.IConquerItem AltLeftHand = Equipment.TryGetItem(25);
            if (AltLeftHand != null)
            {
                Equipment.Remove(25);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);
            Interfaces.IConquerItem AltBoots = Equipment.TryGetItem(28);
            if (AltBoots != null)
            {
                Equipment.Remove(28);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);
            Interfaces.IConquerItem AltArmor = Equipment.TryGetItem(23);
            if (AltArmor != null)
            {
                Equipment.Remove(23);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);

            #endregion
            Interfaces.IConquerItem hand = Equipment.TryGetItem(5);
            if (hand != null)
            {
                Equipment.Remove(5);
                CalculateStatBonus();
                CalculateHPBonus();
            }
            else
                SendScreen(Entity.SpawnPacket, false);
            #endregion
            #endregion
            if (Entity.Reborn == 0)
            {
                Entity.FirstRebornClass = Entity.Class;
                Entity.FirstRebornLevel = Entity.Level;
                Entity.Atributes =
                    (ushort)(ExtraAtributePoints(Entity.FirstRebornClass, Entity.FirstRebornLevel) + 52);
            }
            else
            {
                Entity.SecondRebornClass = Entity.Class;
                Entity.SecondRebornLevel = Entity.Level;
                Entity.Atributes =
                    (ushort)(ExtraAtributePoints(Entity.FirstRebornClass, Entity.FirstRebornLevel) +
                    ExtraAtributePoints(Entity.SecondRebornClass, Entity.SecondRebornLevel) + 62);
            }
            byte PreviousClass = Entity.Class;
            Entity.Reborn++;
            Entity.Class = toClass;
            Entity.Level = 15;
            Entity.Experience = 0;
            #region Spells
            Interfaces.ISkill[] spells = Spells.Values.ToArray();
            foreach (Interfaces.ISkill spell in spells)
            {
                spell.PreviousLevel = spell.Level;
                spell.Level = 0;
                spell.Experience = 0;
                #region Pirate
                if (PreviousClass == 75)
                {
                    if (Entity.Class != 71)
                    {
                        switch (spell.ID)
                        {
                            //BladeTempest =
                            case 11110:
                            //ScurvyBomb =
                            case 11040:
                            //CannonBarrage =
                            case 11050:
                            //BlackbeardRage =
                            case 11060:
                            //GaleBomb =
                            //case 11070:
                            //KrakensRevenge =
                            case 11100:
                            //BlackSpot =
                            case 11120:
                            //AdrenalineRush =
                            case 11130:
                            //PiEagleEye
                            case 11030:
                            case 11140:
                                RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Monk
                if (PreviousClass == 65)
                {
                    if (Entity.Class != 61)
                    {
                        switch (spell.ID)
                        {
                            case 10490:
                            case 10415:
                            case 10381:
                                RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region Warrior
                if (PreviousClass == 25)
                {
                    if (Entity.Class != 21)
                    {
                        switch (spell.ID)
                        {
                            case 1025:
                            case 11160:
                            case 11200:
                                if (spell.ID == 1025)
                                {
                                    if (Entity.Class != 132)
                                        RemoveSpell(spell);
                                }
                                else
                                {
                                    RemoveSpell(spell);
                                }

                                break;
                        }
                    }
                }
                #endregion
                #region Ninja
                if (toClass != 51)
                {
                    switch (spell.ID)
                    {
                        case 6010:
                        case 6000:
                        case 6011:
                        case 11170:
                        case 11180:
                        case 11230:
                            RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region Trojan
                if (toClass != 11)
                {
                    switch (spell.ID)
                    {
                        case 1115:
                            RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region Archer
                if (toClass != 41)
                {
                    switch (spell.ID)
                    {
                        case 8001:
                        case 8000:
                        case 8003:
                        case 9000:
                        case 8002:
                        case 8030:
                            RemoveSpell(spell);
                            break;
                    }
                }
                #endregion
                #region WaterTaoist
                if (PreviousClass == 135)
                {
                    if (toClass != 132)
                    {
                        switch (spell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1010:
                            case 1125:
                            case 1100:
                            case 8030:
                                RemoveSpell(spell);
                                break;
                            case 1050:
                            case 1175:
                            case 1170:
                                if (toClass != 142)
                                    RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                #region FireTaoist
                if (PreviousClass == 145)
                {
                    if (toClass != 142)
                    {
                        switch (spell.ID)
                        {
                            case 1000:
                            case 1001:
                            case 1150:
                            case 1180:
                            case 1120:
                            case 1002:
                            case 1160:
                            case 1165:
                                RemoveSpell(spell);
                                break;
                        }
                    }
                }
                #endregion
                if (Spells.ContainsKey(spell.ID))
                    if (spell.ID != (ushort)Game.Enums.SkillIDs.Reflect)
                        spell.Send(this);
            }
            #endregion
            #region Proficiencies
            foreach (Interfaces.IProf proficiency in Proficiencies.Values)
            {
                proficiency.PreviousLevel = proficiency.Level;
                proficiency.Level = 0;
                proficiency.Experience = 0;
                proficiency.Send(this);
            }
            #endregion
            #region Adding earned skills
            if (Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 9876 });
            if (toClass == 51 && PreviousClass == 55 && Entity.Reborn == 1)
                AddSpell(new Spell(true) { ID = 6002 });
            if (Entity.FirstRebornClass == 15 && Entity.SecondRebornClass == 15 && Entity.Class == 11 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 10315 });
            if (Entity.FirstRebornClass == 25 && Entity.SecondRebornClass == 25 && Entity.Class == 21 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 10311 });
            if (Entity.FirstRebornClass == 45 && Entity.SecondRebornClass == 45 && Entity.Class == 41 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 10313 });
            if (Entity.FirstRebornClass == 55 && Entity.SecondRebornClass == 55 && Entity.Class == 51 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 6003 });
            if (Entity.FirstRebornClass == 65 && Entity.SecondRebornClass == 65 && Entity.Class == 61 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 10405 });
            if (Entity.FirstRebornClass == 135 && Entity.SecondRebornClass == 135 && Entity.Class == 132 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 30000 });
            if (Entity.FirstRebornClass == 145 && Entity.SecondRebornClass == 145 && Entity.Class == 142 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 10310 });
            if (Entity.FirstRebornClass == 75 && Entity.SecondRebornClass == 75 && Entity.Class == 71 && Entity.Reborn == 2)
                AddSpell(new Spell(true) { ID = 11040 });
            if (Entity.Reborn == 1)
            {

                if (Entity.FirstRebornClass == 15 && Entity.Class == 11)
                {
                    AddSpell(new Spell(true) { ID = 3050 });
                }
                if (Entity.FirstRebornClass == 75 && Entity.Class == 71)
                {
                    AddSpell(new Spell(true) { ID = 11100 });
                }
                else if (Entity.FirstRebornClass == 25 && Entity.Class == 21)
                {
                    AddSpell(new Spell(true) { ID = 3060 });
                }
                else if (Entity.FirstRebornClass == 145 && Entity.Class == 142)
                {
                    AddSpell(new Spell(true) { ID = 3080 });
                }
                else if (Entity.FirstRebornClass == 135 && Entity.Class == 132)
                {
                    AddSpell(new Spell(true) { ID = 3090 });
                }
            }
            if (Entity.Reborn == 2)
            {

                if (Entity.SecondRebornClass == 15 && Entity.Class == 11)
                {
                    AddSpell(new Spell(true) { ID = 3050 });
                }
                if (Entity.SecondRebornClass == 75 && Entity.Class == 71)
                {
                    AddSpell(new Spell(true) { ID = 11100 });
                }
                else if (Entity.SecondRebornClass == 25)
                {
                    AddSpell(new Spell(true) { ID = 3060 });
                }
                else if (Entity.SecondRebornClass == 145 && Entity.Class == 142)
                {
                    AddSpell(new Spell(true) { ID = 3080 });
                }
                else if (Entity.SecondRebornClass == 135 && Entity.Class == 132)
                {
                    AddSpell(new Spell(true) { ID = 3090 });
                }
            }
            #endregion

            Database.DataHolder.GetStats(Entity.Class, Entity.Level, this);
            CalculateStatBonus();
            CalculateHPBonus();
            GemAlgorithm();

            Database.EntityTable.SaveEntity(this);

            Database.SkillTable.SaveProficiencies(this);
            Database.SkillTable.SaveSpells(this);

            Equipment.UpdateEntityPacket();
            ServerBase.Kernel.SendWorldMessage(new Message("" + Entity.Name + " has got " + Entity.Reborn + " reborns. Congratulations!", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
            return true;
        }