コード例 #1
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void LoginMessages(Client.GameState client)
        {
            if (client.WentToComplete)
                return;

            // ServerBase.Kernel.Elite_PK_Tournament.LoginClient(client);
            if (client.Entity.MapID == 6002)
                ServerBase.Kernel.Elite_PK_Tournament.ObtinedOutCoord(client);
            //client.Account.State = Database.AccountTable.AccountState.Player;
            client.WentToComplete = true;
            client.Entity.SendUpdates = true;
            Data datas = new Data(true);
            datas.UID = client.Entity.UID;
            datas.ID = 116;
            datas.dwParam = 1197;
            client.Send(datas);
            if (client.Entity.VIPLevel > 0)
            {
                VIPAdvanced vp = new VIPAdvanced(true);
                vp.UID = 65535;
                client.Send(vp);
            }
            #region Game Updates

            client.Send(new GameUpdates(GameUpdates.Header, "Sharpness-Co Updates" + DateTime.Now.ToString()));
            //clients.Send(new GameUpdates(GameUpdates.Body, ""));
            client.Send(new GameUpdates(GameUpdates.Body, "All Events now Fixed"));
            client.Send(new GameUpdates(GameUpdates.Body, "1.Ping now is Now fixed enjoy"));
            client.Send(new GameUpdates(GameUpdates.Body, "2.Pirate 95% done still need reborn and skills"));
            client.Send(new GameUpdates(GameUpdates.Body, "3.Clan system now fixed "));
            client.Send(new GameUpdates(GameUpdates.Body, "4.Attack now fixed"));
            client.Send(new GameUpdates(GameUpdates.Body, "5.MemoryAgate now works"));
            client.Send(new GameUpdates(GameUpdates.Body, "6.Refinery now works good"));
            client.Send(new GameUpdates(GameUpdates.Body, "7.DecreasePK NPC in TwinCity now can less your pk fast"));
            client.Send(new GameUpdates(GameUpdates.Body, "8.All characters can take +6 items from twin city"));
            client.Send(new GameUpdates(GameUpdates.Body, "9.Cheak every thing  about Donation on game site "));
            client.Send(new GameUpdates(GameUpdates.Body, "10.Only PM number 0115641487 for donate"));
            client.Send(new GameUpdates(GameUpdates.Footer, "There is only 2[PM] has [PM] of  endes on his name dont trust any one else"));
            #endregion
            //#region SubClass

            ////client.Send(new SubClass(client.Entity).ToArray());

            //SubClassShowFull sub = new SubClassShowFull(true);
            //sub.ID = 1;
            //sub.Level = client.Entity.SubClassLevel;
            //sub.Class = client.Entity.SubClass;
            //#region [Effects-Addition]
            //switch ((Conquer_Online_Server.Game.ClassID)client.Entity.SubClass)
            //{
            //    case Conquer_Online_Server.Game.ClassID.Apothecary:
            //        {
            //            //

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

            //}

            //#endregion

            //client.Send(sub);
            //#endregion
            if (client.Entity.Myclan != null)
            {
                Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1);
                client.Send(cl.ToArray());
            }
            foreach (var Guild in ServerBase.Kernel.Guilds.Values)
            {
                Guild.SendName(client);
            }
            if (client.Entity.ElitePK == 1)
            {
                client.Entity.TitleActivated = 14;
                Database.SubClassTable.Update56(client.Entity);
                Conquer_Online_Server.Database.EntityTable.SaveTop(client.Entity);
            }
            //foreach (Client.GameState clients in ServerBase.Kernel.GamePool.Values)
            //{
            //    clients.Entity.Owner.Send(new Conquer_Online_Server.Network.GamePackets.Message("Name= [" + client.Entity.Name + "] Level= [" + client.Entity.Level + "] Reborn= [" + client.Entity.Reborn + "] CPS= [" + client.Entity.ConquerPoints + "] VIPLevel= [" + client.Entity.VIPLevel + "] " + " Has Logged On and " + " Players online= [" + ServerBase.Kernel.GamePool.Count + "]", System.Drawing.Color.White, 2005));

            //}
            if (client.Entity.AddFlower == 1)
                if (client.Entity.Body.ToString().EndsWith("3") || client.Entity.Body.ToString().EndsWith("4"))
                    client.Send(new Network.GamePackets.FlowerPacket(new Game.Struct.Flowers()).ToArray());

            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);
            client.Entity.Spouse = client.Entity.Spouse;

            if (client.Guild != null)
            {
                if (client.Entity.GuildRank == (ushort)Game.Enums.GuildMemberRank.DeputyLeader)
                {
                    if (client.Guild.Name == Game.ConquerStructures.Society.GuildWar.Pole.Name)
                    {
                        client.Entity.AddFlag(Update.Flags.TopDeputyLeader);
                    }
                }
                else if (client.Entity.GuildRank == (ushort)Game.Enums.GuildMemberRank.GuildLeader)
                {
                    if (client.Guild.Name == Game.ConquerStructures.Society.GuildWar.Pole.Name)
                    {
                        client.Entity.AddFlag(Update.Flags.TopGuildLeader);
                    }
                }

            }

            client.Entity.DoubleExperienceTimeV1 = (ushort)(client.Entity.DoubleExperienceTimeV1 + (1 - 1));
            client.Entity.DoubleExperienceTime = (ushort)(client.Entity.DoubleExperienceTime + (1 - 1));
            client.Entity.DoubleExperienceTime5 = (ushort)(client.Entity.DoubleExperienceTime5 + (1 - 1));
            client.Entity.DoubleExperienceTime10 = (ushort)(client.Entity.DoubleExperienceTime10 + (1 - 1));
            client.Entity.DoubleExperienceTime15 = (ushort)(client.Entity.DoubleExperienceTime15 + (1 - 1));
            client.Entity.HeavenBlessing = (ushort)(client.Entity.HeavenBlessing + (1 - 1));

            if (client.Mentor != null)
            {
                if (client.Mentor.IsOnline)
                {
                    MentorInformation Information = new MentorInformation(true);
                    Information.Mentor_Type = 1;
                    Information.Mentor_ID = client.Mentor.Client.Entity.UID;
                    Information.Apprentice_ID = client.Entity.UID;
                    Information.Enrole_Date = client.Mentor.EnroleDate;
                    Information.Mentor_Level = client.Mentor.Client.Entity.Level;
                    Information.Mentor_Class = client.Mentor.Client.Entity.Class;
                    Information.Mentor_PkPoints = client.Mentor.Client.Entity.PKPoints;
                    Information.Mentor_Mesh = client.Mentor.Client.Entity.Mesh;
                    Information.Mentor_Online = true;
                    Information.Shared_Battle_Power = (uint)(((client.Mentor.Client.Entity.BattlePower - client.Mentor.Client.Entity.ExtraBattlePower) - (client.Entity.BattlePower - client.Entity.ExtraBattlePower)) / 3.3F);
                    Information.String_Count = 3;
                    Information.Mentor_Name = client.Mentor.Client.Entity.Name;
                    Information.Apprentice_Name = client.Entity.Name;
                    Information.Mentor_Spouse_Name = client.Mentor.Client.Entity.Spouse;
                    client.ReviewMentor();
                    client.Send(Information);

                    ApprenticeInformation AppInfo = new ApprenticeInformation();
                    AppInfo.Apprentice_ID = client.Entity.UID;
                    AppInfo.Apprentice_Level = client.Entity.Level;
                    AppInfo.Apprentice_Class = client.Entity.Class;
                    AppInfo.Apprentice_PkPoints = client.Entity.PKPoints;
                    AppInfo.Apprentice_Experience = client.AsApprentice.Actual_Experience;
                    AppInfo.Apprentice_Composing = client.AsApprentice.Actual_Plus;
                    AppInfo.Apprentice_Blessing = client.AsApprentice.Actual_HeavenBlessing;
                    AppInfo.Apprentice_Name = client.Entity.Name;
                    AppInfo.Apprentice_Online = true;
                    AppInfo.Apprentice_Spouse_Name = client.Entity.Spouse;
                    AppInfo.Enrole_date = client.Mentor.EnroleDate;
                    AppInfo.Mentor_ID = client.Mentor.ID;
                    AppInfo.Mentor_Mesh = client.Mentor.Client.Entity.Mesh;
                    AppInfo.Mentor_Name = client.Mentor.Name;
                    AppInfo.Type = 2;
                    client.Mentor.Client.Send(AppInfo);
                }
                else
                {
                    MentorInformation Information = new MentorInformation(true);
                    Information.Mentor_Type = 1;
                    Information.Mentor_ID = client.Mentor.ID;
                    Information.Apprentice_ID = client.Entity.UID;
                    Information.Enrole_Date = client.Mentor.EnroleDate;
                    Information.Mentor_Online = false;
                    Information.String_Count = 2;
                    Information.Mentor_Name = client.Mentor.Name;
                    Information.Apprentice_Name = client.Entity.Name;

                    client.Send(Information);
                }
            }
            NobilityInfo update = new NobilityInfo(true);
            update.Type = NobilityInfo.Icon;
            update.dwParam = client.NobilityInformation.EntityUID;
            update.UpdateString(client.NobilityInformation);
            client.Send(update);
            client.Entity.Update(Update.Merchant, 255, false);

            client.Entity.Stamina = 100;
            //client.Send(new Message("Welcome to the Reborn of " + ServerBase.Constants.ServerName + "Conquer ! Same staff here", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("All monster drop CpsBag! With random Cps! ", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("If you need help! Use Service Chat", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("GuildWar Start: Saturday Hour: 18", System.Drawing.Color.Red, Message.Talk));
            //client.Send(new Message("GuildWar Finish: Sunday Hour: 10", System.Drawing.Color.Red, Message.Talk));
            string[] wm = File.ReadAllLines(ServerBase.Constants.WelcomeMessages);
            foreach (string line in wm)
            {
                if (line.Length == 0)
                    continue;
                if (line[0] == ';')
                    continue;
                client.Send(new Message(line, System.Drawing.Color.Red, Message.Talk));
            }

            //if (Database.VoteTable.CanVote(client))
            //{
            //    client.OnMessageBoxOK = delegate
            //    {
            //        Network.GamePackets.Data data = new Network.GamePackets.Data(true);
            //        data.UID = client.Entity.UID;
            //        data.ID = Network.GamePackets.Data.OpenCustom;
            //        data.dwParam = Network.GamePackets.Data.CustomCommands.Minimize;
            //        client.Send(data);
            //        client.Send(new Message(ServerBase.Constants.ServerWebsite + ServerBase.Constants.WebAccExt + ServerBase.Constants.WebVoteExt, System.Drawing.Color.Red, Network.GamePackets.Message.Website));
            //    };
            //    client.Send(new NpcReply(NpcReply.MessageBox, "Would you like to consider voting for us? With more votes we will be come a bigger community."));
            //}

            /*if (client.Entity.VIPLevel != 0)
            {
                Database.PremiumTable.getVipInfo(client);
                if (client.VIPDays != 0)
                {
                    if (DateTime.Now >= client.VIPDate.AddDays(client.VIPDays))
                    {
                        client.Entity.VIPLevel = 0;
                        client.Send(ServerBase.Constants.VIPExpired);
                    }
                    else
                    {
                        DateTime VipEnds = client.VIPDate.AddDays(client.VIPDays);
                        TimeSpan span = VipEnds.Subtract(DateTime.Now);
                        client.Send(ServerBase.Constants.VIPRemaining(span.Days.ToString(), span.Hours.ToString()));
                    }
                }
                else
                    client.Send(ServerBase.Constants.VIPLifetime);
            }*/
            //if (Program.Today == DayOfWeek.Saturday || Program.Today == DayOfWeek.Sunday)
            //    client.Send(new Message("Double experience is on.", System.Drawing.Color.Red, Message.World));

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

            if (client.Entity.Hitpoints == 0)
                client.Entity.Hitpoints = 1;
            client.Entity.VIPLevel = (byte)(client.Entity.VIPLevel + 0);
            client.Entity.HandleTiming = true;
            if (client.Entity.ExtraBattlePower != 0)
                client.Entity.Update(Network.GamePackets.Update.ExtraBattlePower, client.Entity.ExtraBattlePower, false);
            if (client.Guild != null)
                client.Guild.SendAllyAndEnemy(client);
            if (Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID > 2)
                client.Send(new Network.GamePackets.Message(Game.ConquerStructures.Broadcast.CurrentBroadcast.Message, "ALLUSERS", Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityName, System.Drawing.Color.Red, Network.GamePackets.Message.BroadcastMessage));
            client.Entity.Update(Network.GamePackets.Update.LuckyTimeTimer, client.BlessTime, false);
            if (client.Entity.HeavenBlessing != 0)
                client.Entity.Update(Network.GamePackets.Update.OnlineTraining, client.OnlineTrainingPoints, false);
            if (client.ClaimableItem.Count > 0)
                foreach (var item in client.ClaimableItem.Values)
                    item.Send(client);
            if (client.DeatinedItem.Count > 0)
                foreach (var item in client.DeatinedItem.Values)
                    item.Send(client);

            foreach (Interfaces.IConquerItem item in client.Inventory.Objects)
                item.Send(client);

            foreach (Interfaces.IConquerItem item in client.Equipment.Objects)
                if (item != null)
                {
                    if (Database.ConquerItemInformation.BaseInformations.ContainsKey(item.ID))
                    {
                        item.Send(client);
                        ItemUsage usage = new ItemUsage(true) { ID = ItemUsage.EquipItem };
                        usage.UID = item.UID;
                        usage.dwParam = item.Position;
                        client.Send(usage);
                        client.LoadItemStats(item);
                    }
                    else
                    {
                        client.Equipment.DestroyArrow(item.Position);
                        Console.WriteLine("Announcement: Item have been removed because of invalid info. UID: " + item.UID + ". OWNER: " + client.Entity.Name);
                    }
                }
            if (!client.Equipment.Free(5))
            {
                if (IsArrow(client.Equipment.TryGetItem(5).ID))
                {
                    if (client.Equipment.Free(4))
                        client.Equipment.DestroyArrow(5);
                    else
                    {
                        if (client.Equipment.TryGetItem(4).ID / 1000 != 500)
                            client.Equipment.DestroyArrow(5);
                    }
                }
            }
            client.GemAlgorithm();
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.SendStatMessage();
            // Conquer_Online_Server.Game.Attacking.Calculate.Vitals(client.Entity, true);
            client.Equipment.UpdateEntityPacket();
            EntityEquipment equips = new EntityEquipment(true);
            equips.ParseHero(client);
            client.Send(equips);
            System.Threading.Thread.Sleep(3500);
            //if ((int)client.Account.State >= 3)
            //    client.Entity.AddFlag(Update.Flags.Flashy);
        }
コード例 #2
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void HandleRepair(ItemUsage itemUsage, Client.GameState client)
        {
            Interfaces.IConquerItem item = null;
            if (client.Inventory.TryGetItem(itemUsage.UID, out item))
            {
                if (item.Suspicious)
                    return;
                if (IsArrow(item.ID))
                    return;
                if (item.Durability > 0 && item.Durability < item.MaximDurability)
                {
                    uint Price = new Database.ConquerItemInformation(item.ID, 0).BaseInformation.GoldWorth;
                    byte Quality = (byte)(item.ID % 10);
                    double QualityMultipier = 0;

                    switch (Quality)
                    {
                        case 9: QualityMultipier = 1.125; break;
                        case 8: QualityMultipier = 0.975; break;
                        case 7: QualityMultipier = 0.9; break;
                        case 6: QualityMultipier = 0.825; break;
                        default: QualityMultipier = 0.75; break;
                    }

                    int nRepairCost = 0;
                    if (Price > 0)
                        nRepairCost = (int)Math.Ceiling((Price * (item.MaximDurability - item.Durability) / item.MaximDurability) * QualityMultipier);

                    nRepairCost = Math.Max(1, nRepairCost);
                    if (client.Entity.Money >= nRepairCost)
                    {
                        client.Entity.Money -= (uint)nRepairCost;
                        item.Durability = item.MaximDurability;
                        item.Mode = Game.Enums.ItemMode.Update;
                        item.Send(client);
                        Database.ConquerItemTable.UpdateDurabilityItem(item);
                    }
                }
                else if (item.Durability == 0)
                {
                    if (client.Inventory.Remove(1088001, 5))
                    {
                        item.Durability = item.MaximDurability;
                        item.Mode = Game.Enums.ItemMode.Update;
                        item.Send(client);
                        Database.ConquerItemTable.UpdateDurabilityItem(item);
                    }
                }
            }
        }
コード例 #3
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void HandleSellToNPC(ItemUsage itemUsage, Client.GameState client)
 {
     Interfaces.INpc npc = null;
     if (client.Map.Npcs.TryGetValue(itemUsage.UID, out npc))
     {
         if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, npc.X, npc.Y) > 17)
             return;
         Interfaces.IConquerItem item = null;
         if (client.Inventory.TryGetItem(itemUsage.dwParam, out item))
         {
             if (item.Lock != 0 || item.Suspicious)
                 return;
             uint Price = new Database.ConquerItemInformation(item.ID, 0).BaseInformation.GoldWorth;
             Price = Price / 3;
             if (item.Durability > 0 && item.Durability < item.MaximDurability)
                 Price = (Price * item.Durability) / item.MaximDurability;
             item.StackSize = 0;
             if (item.Durability > 0 && item.Durability <= item.MaximDurability)
             {
                 client.Inventory.Remove(item, Game.Enums.ItemUse.Delete);
                 client.Entity.Money += Price;
             }
             else
             {
                 client.Inventory.Remove(item, Game.Enums.ItemUse.Delete);
             }
         }
     }
 }
コード例 #4
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void HandleBuyFromNPC(ItemUsage itemUsage, Client.GameState client)
        {
            if (itemUsage == null)
                return;
            if (client == null)
                return;
            if (itemUsage.UID == 141)
            {
                if (itemUsage.dwParam == 721157 || itemUsage.dwParam == 721158)
                {
                    uint cost = 5000;
                    Interfaces.IConquerItem item = new ConquerItem(true);
                    if (cost > client.Entity.Money)
                        return;
                    if (client.Entity.Money - cost > client.Entity.Money)
                        return;
                    item.ID = itemUsage.dwParam;
                    item.Durability = item.MaximDurability = 100;
                    item.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                    if (client.Inventory.ContainsUID(item.UID) || item.StackSize == 1)
                        client.Entity.Money -= cost;
                }
            }
            if (itemUsage.UID == 2888)
            {
                if (itemUsage.dwParam == 203009)
                {
                    uint cost = 1290;
                    if (cost > client.Entity.ConquerPoints)
                        return;
                    if (client.Entity.ConquerPoints - cost > client.Entity.ConquerPoints)
                        return;
                    Interfaces.IConquerItem item = new ConquerItem(true);
                    item.ID = itemUsage.dwParam;

                    item.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                    item.Durability = item.MaximDurability = 100;//iteminfo.BaseInformation.Durability;
                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                    if (client.Inventory.ContainsUID(item.UID) || item.StackSize == 1)
                        client.Entity.ConquerPoints = (uint)Math.Max(0, (uint)((uint)client.Entity.ConquerPoints - (uint)cost));
                }
            }

            if (itemUsage.UID == 6000)//honorshop
            {
                if (client.Inventory.Count == 40)
                    return;
                uint price = 0;
                switch (itemUsage.dwParam)
                {
                    case 200006: price = 300000; break;
                    case 200207: price = 500000; break;

                    case 200208: price = 800000; break;
                    case 200007: price = 2000000; break;
                    case 200309: price = 550000; break;
                    case 200308: price = 900000; break;
                    case 200103: price = 1300000; break;
                    case 200107: price = 2000000; break;
                    case 720842: price = 8000; break;
                    case 711083: price = 50000; break;
                    case 720598: price = 20000; break;
                    case 720774: price = 10000; break;
                    case 723651: price = 25000; break;
                    case 723652: price = 62400; break;
                    case 723653: price = 156000; break;
                    case 723654: price = 12500; break;
                    case 723655: price = 31200; break;
                    case 723656: price = 78000; break;
                    case 723657: price = 25000; break;
                    case 723658: price = 62400; break;
                    case 723659: price = 156000; break;
                    case 723660: price = 5000; break;
                    case 723661: price = 12500; break;
                    case 723662: price = 31200; break;
                    case 723663: price = 10000; break;
                    case 723664: price = 25000; break;
                    case 723665: price = 62400; break;
                    case 723666: price = 10000; break;
                    case 723667: price = 25000; break;
                    case 723668: price = 62400; break;
                    case 723669: price = 12500; break;
                    case 723670: price = 31200; break;
                    case 723671: price = 78000; break;
                    case 723672: price = 16000; break;
                    case 723673: price = 41000; break;
                    case 723674: price = 104000; break;
                    case 723675: price = 16000; break;
                    case 723676: price = 41000; break;
                    case 723677: price = 104000; break;
                    case 723678: price = 13000; break;
                    case 723679: price = 33000; break;
                    case 723680: price = 83000; break;
                    case 723681: price = 13000; break;
                    case 723682: price = 33000; break;
                    case 723683: price = 83000; break;
                    case 723690: price = 13000; break;
                    case 723691: price = 33000; break;
                    case 723692: price = 83000; break;
                    case 723684: price = 10000; break;
                    case 723685: price = 25000; break;
                    case 723686: price = 62400; break;
                    case 723130: price = 10000; break;
                    case 723131: price = 25000; break;
                    case 723132: price = 62400; break;
                    case 723133: price = 25000; break;
                    case 723134: price = 62400; break;
                    case 723135: price = 156000; break;
                }
                Interfaces.IConquerItem item = new ConquerItem(true);
                Database.ConquerItemInformation iteminfo = new Conquer_Online_Server.Database.ConquerItemInformation(itemUsage.dwParam, 0);
                if (price > client.ArenaStatistic.CurrentHonor)
                    return;
                if (client.ArenaStatistic.CurrentHonor - price > client.ArenaStatistic.CurrentHonor)
                    return;
                item.ID = itemUsage.dwParam;
                item.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                client.ArenaStatistic.CurrentHonor -= price;
                Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic);
                return;
            }
            Interfaces.INpc npc = null;
            if (client.Map.Npcs.TryGetValue(itemUsage.UID, out npc) || itemUsage.UID == 2888)
            {
                if (client.Inventory.Count == 40)
                    return;
                if (itemUsage.UID != 2888)
                    if (ServerBase.Kernel.GetDistance(client.Entity.X, client.Entity.Y, npc.X, npc.Y) > 17)
                        return;

                Database.ShopFile.Shop shop = new Conquer_Online_Server.Database.ShopFile.Shop();
                if (Database.ShopFile.Shops.TryGetValue(itemUsage.UID, out shop))
                {
                    if (shop.UID == 0)
                        return;
                    if (!shop.Items.Contains(itemUsage.dwParam))
                        return;
                    Database.ConquerItemInformation iteminfo = new Conquer_Online_Server.Database.ConquerItemInformation(itemUsage.dwParam, 0);
                    uint Amount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                    while (Amount > 0 && client.Inventory.Count != 40)
                    {
                        Interfaces.IConquerItem item = new ConquerItem(true);

                        switch (shop.MoneyType)
                        {
                            case Conquer_Online_Server.Database.ShopFile.MoneyType.Gold:
                                {
                                    if (iteminfo.BaseInformation.GoldWorth > client.Entity.Money)
                                        return;
                                    if (client.Entity.Money - iteminfo.BaseInformation.GoldWorth > client.Entity.Money)
                                        return;
                                    item.ID = itemUsage.dwParam;
                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                    if (!IsEquipment(item.ID))
                                    {
                                        if (iteminfo.BaseInformation.StackSize != 0)
                                        {
                                            item.StackSize = 1;
                                            item.MaxStackSize = iteminfo.BaseInformation.StackSize;
                                        }
                                    }
                                    item.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                    if (client.Inventory.ContainsUID(item.UID) || item.StackSize == 1)
                                        client.Entity.Money -= iteminfo.BaseInformation.GoldWorth;
                                    break;
                                }
                            case Conquer_Online_Server.Database.ShopFile.MoneyType.ConquerPoints:
                                {
                                    if (iteminfo.BaseInformation.ConquerPointsWorth > client.Entity.ConquerPoints)
                                        return;
                                    if (client.Entity.ConquerPoints - iteminfo.BaseInformation.ConquerPointsWorth > client.Entity.ConquerPoints)
                                        return;
                                    item.ID = itemUsage.dwParam;
                                    if (item.ID >= 730001 && item.ID <= 730008)
                                        item.Plus = (byte)(item.ID % 10);
                                    item.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                    if (!IsEquipment(item.ID))
                                    {
                                        if (iteminfo.BaseInformation.StackSize != 0)
                                        {
                                            item.StackSize = 1;
                                            item.MaxStackSize = iteminfo.BaseInformation.StackSize;
                                        }
                                    }
                                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                    if (client.Inventory.ContainsUID(item.UID) || item.StackSize == 1)
                                        client.Entity.ConquerPoints = (uint)Math.Max(0, (uint)((uint)client.Entity.ConquerPoints - (uint)iteminfo.BaseInformation.ConquerPointsWorth));
                                    break;
                                }
                        }
                        Amount--;
                    }
                }
                else
                {
                    if (Database.EShopFile.Shops.TryGetValue(itemUsage.UID, out shop))
                    {
                        if (shop.UID == 0)
                            return;
                        if (!shop.Items.Contains(itemUsage.dwParam))
                            return;
                        Database.ConquerItemInformation iteminfo = new Conquer_Online_Server.Database.ConquerItemInformation(itemUsage.dwParam, 0);
                        uint Amount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                        while (Amount > 0 && client.Inventory.Count != 40)
                        {

                            Interfaces.IConquerItem item = new ConquerItem(true);
                            switch (shop.MoneyType)
                            {
                                case Conquer_Online_Server.Database.ShopFile.MoneyType.Gold:
                                    {
                                        if (iteminfo.BaseInformation.GoldWorth > client.Entity.Money)
                                            return;
                                        if (client.Entity.Money - iteminfo.BaseInformation.GoldWorth > client.Entity.Money)
                                            return;
                                        item.ID = itemUsage.dwParam;
                                        item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;

                                        item.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                        client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                        if (client.Inventory.ContainsUID(item.UID) || item.StackSize == 1)
                                            client.Entity.Money -= iteminfo.BaseInformation.GoldWorth;
                                        break;
                                    }
                                case Conquer_Online_Server.Database.ShopFile.MoneyType.ConquerPoints:
                                    {
                                        if (iteminfo.BaseInformation.ConquerPointsWorth > client.Entity.ConquerPoints)
                                            return;
                                        if (client.Entity.ConquerPoints - iteminfo.BaseInformation.ConquerPointsWorth > client.Entity.ConquerPoints)
                                            return;
                                        item.ID = itemUsage.dwParam;
                                        if (item.ID >= 730001 && item.ID <= 730008)
                                            item.Plus = (byte)(item.ID % 10);
                                        item.Color = (Conquer_Online_Server.Game.Enums.Color)ServerBase.Kernel.Random.Next(4, 8);
                                        item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;

                                        client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                        if (client.Inventory.ContainsUID(item.UID) || item.StackSize == 1)
                                            client.Entity.ConquerPoints = (uint)Math.Max(0, (uint)((uint)client.Entity.ConquerPoints - (int)iteminfo.BaseInformation.ConquerPointsWorth));
                                        break;
                                    }
                            }
                            Amount--;
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void HandlePacket(byte[] packet, Client.GameState client)
        {
            if (packet == null)
                return;
            if (client == null)
                return;
            ushort Length = BitConverter.ToUInt16(packet, 0);
            ushort ID = BitConverter.ToUInt16(packet, 2);
            ushort ID2 = BitConverter.ToUInt16(packet, 4);
            switch (ID)
            {
                #region market quest
                case 2400:
                    {
                        if (client.Entity.QQ1 == 0)
                        {
                            client.Entity.Teleport(1068, 053, 055);
                        }
                        else
                        {
                            client.Send(new Message("you can only make quest once in day", Color.AntiqueWhite, 2005));
                        }

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

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

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

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

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

                    }
                case 2224:
                    {

                        client.Send(packet);
                        break;

                    }
                case 2232:
                    {

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

                    }
                case 2233:
                    {

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

                    }
                case 2252:
                    {

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

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

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

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

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

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

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

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

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

                                        break;
                                    }
                                case ItemUsage.ShowBoothItems:
                                    {
                                        ShowBoothItems(usage, client);
                                        break;
                                    }
                                case ItemUsage.AddItemOnBoothForSilvers:
                                case ItemUsage.AddItemOnBoothForConquerPoints:
                                    {
                                        AddItemOnBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.BuyFromBooth:
                                    {
                                        BuyFromBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.RemoveItemFromBooth:
                                    {
                                        RemoveItemFromBooth(usage, client);
                                        break;
                                    }
                                case ItemUsage.EquipItem:
                                    {
                                        EquipItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.UnequipItem:
                                    {
                                        UnequipItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.BuyFromNPC:
                                    {
                                        HandleBuyFromNPC(usage, client);
                                        break;
                                    }
                                case ItemUsage.SellToNPC:
                                    {
                                        HandleSellToNPC(usage, client);
                                        break;
                                    }
                                case ItemUsage.Repair:
                                    {
                                        HandleRepair(usage, client);
                                        break;
                                    }
                                case ItemUsage.MeteorUpgrade:
                                case ItemUsage.DragonBallUpgrade:
                                    {
                                        UpgradeItem(usage, client);
                                        break;
                                    }
                                case ItemUsage.Ping:
                                    {
                                        if (Time32.Now < client.LastPing.AddSeconds(2))
                                        {
                                            client.PingCount++;
                                            if (client.PingCount == 40)
                                            {
                                                client.Send(new Message("Speed hack detected!", System.Drawing.Color.BlanchedAlmond, Message.TopLeft));
                                                client.Disconnect();
                                                return;
                                            }
                                        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                if (ServerBase.Kernel.GamePool.ContainsKey(item.GainerUID))
                                                {
                                                    var pClient = ServerBase.Kernel.GamePool[item.GainerUID];
                                                    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("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);
                                            }
                                        }
                                        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:
                                    {
                                        var item = client.ClaimableItem[usage.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, Conquer_Online_Server.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.DetainedItemTable.Claim(item, client);
                                            client.ClaimableItem.Remove(item.UID);

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

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

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

                                            varr.MoveNext();

                                        }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region KnownPersons (1019)
                case 1019:
                    {
                        KnownPersons knownP = new KnownPersons(false);
                        knownP.Deserialize(packet);
                        switch (knownP.Type)
                        {
                            case KnownPersons.RequestFriendship:
                                {
                                    AddFriend(knownP, client);
                                    break;
                                }
                            case KnownPersons.RemovePerson:
                                {
                                    RemoveFriend(knownP, client);
                                    break;
                                }
                            case KnownPersons.RemoveEnemy:
                                {
                                    RemoveEnemy(knownP, client);
                                    break;
                                }
                        }
                        break;
                    }
                #endregion
                #region Attack (1022)
                case 1022:
                    {
                        if (client.Action != 2)
                            return;
                        uint dmg = BitConverter.ToUInt32(packet, 24);
                        uint AttackType = BitConverter.ToUInt32(packet, 20);
                        switch (AttackType)
                        {
                            case 39:
                                {
                                    if (!Kernel.VotePool.ContainsKey(client.Account.IP))
                                    {
                                        if (!Kernel.VotePoolUid.ContainsKey(client.Entity.UID))
                                        {
                                            client.Entity.ConquerPoints += 1000;
                                            Conquer_Online_Server.Game.ConquerStructures.PlayersVot Vot = new Conquer_Online_Server.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 Conquer_Online_Server.Network.GamePackets.Message("http://5.41.141.216/index.php", 2105));
                                            client.Send(new Message("You Have clamied your Prize 1k Cps Server ", Color.Brown, 1000000));
                                        }
                                        else
                                        {
                                            client.Send(new Conquer_Online_Server.Network.GamePackets.Message("http://5.41.141.216/index.php", 2105));
                                            client.Send(new Message("you can only take prize once in day", Color.Brown, 10000000));
                                        }
                                    }
                                    else
                                    {
                                        client.Send(new Conquer_Online_Server.Network.GamePackets.Message("http://5.41.141.216/index.php", 2105));
                                        client.Send(new Message("you can only take prize once in day", Color.Brown, 10000000));
                                    }

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

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

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

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

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

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

                        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                #region Arsenal Guild
                case 2202:
                    {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        break;
                    }

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

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

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

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

                                            varr.MoveNext();

                                        }

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

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

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

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

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

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

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

                                    break;
                                }

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

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

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

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

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

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

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

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

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

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

                                                                Clan2 clanp = new Clan2();

                                                                clanp.Deserialize(packet);

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

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

                                                                tclan.AllyRequest = clan.ClanId;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            default:
                                Console.WriteLine("Unknown 1128 subtype: " + vp.UID); break;
                        }
                        break;
                    }
                default:
                    {
                        if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager)
                            client.Send(new Message("Unknown type: " + ID + " with length " + packet.Length + "Unknown type: " + ID2, System.Drawing.Color.CadetBlue, Message.Talk));
                        if (ID == 1040)
                            client.Send(packet);
                        break;
                    }
            }
        }
コード例 #6
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void SocketTalismanWithCPs(ItemUsage itemUsage, Client.GameState client)
        {
            Interfaces.IConquerItem talisman = client.Equipment.TryGetItem(itemUsage.UID);
            if (talisman == null)
                return;

            uint price = 0;
            if (talisman.SocketOne == Conquer_Online_Server.Game.Enums.Gem.NoSocket)
            {
                double procent = 100 - (talisman.SocketProgress * 25600 / 2048000);
                if (100 - procent < 25)
                    return;
                price = (uint)(procent * 55);
            }
            else if (talisman.SocketTwo == Conquer_Online_Server.Game.Enums.Gem.NoSocket)
            {
                double procent = 100 - (talisman.SocketProgress * 25600 / 5120000);
                if (100 - procent < 25)
                    return;
                price = (uint)(procent * 110);
            }
            else
                return;
            if (client.Entity.ConquerPoints >= price)
            {
                client.Entity.ConquerPoints = (uint)Math.Max(0, (int)((int)client.Entity.ConquerPoints - (int)price));
                if (talisman.SocketOne == Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                    talisman.SocketOne = Conquer_Online_Server.Game.Enums.Gem.EmptySocket;
                else if (talisman.SocketTwo == Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                    talisman.SocketTwo = Conquer_Online_Server.Game.Enums.Gem.EmptySocket;
                talisman.SocketProgress = 0;
                Database.ConquerItemTable.UpdateSockets(talisman, client);
                talisman.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                talisman.Send(client);
            }
        }
コード例 #7
0
ファイル: Handle.cs プロジェクト: AiiMz/PserverWork
 public static void PrepareSpell(Database.SpellInformation spell, Client.GameState client)
 {
     if (spell.NeedXP == 1)
         client.Entity.RemoveFlag(Update.Flags.XPList);
     if (client.Map.ID != 1039)
     {
         if (spell.UseMana > 0)
             if (client.Entity.Mana >= spell.UseMana)
                 client.Entity.Mana -= spell.UseMana;
         if (spell.UseStamina > 0)
             if (client.Entity.Stamina >= spell.UseStamina)
                 client.Entity.Stamina -= spell.UseStamina;
         if (spell.UseArrows > 0 && isArcherSkill(spell.ID))
         {
             if (!client.Equipment.Free((byte)ConquerItem.LeftWeapon))
             {
                 Interfaces.IConquerItem arrow = client.Equipment.TryGetItem(ConquerItem.LeftWeapon);
                 arrow.Durability -= spell.UseArrows;
                 ItemUsage usage = new ItemUsage(true) { UID = arrow.UID, dwParam = arrow.Durability, ID = ItemUsage.UpdateDurability };
                 usage.Send(client);
                 if (arrow.Durability <= spell.UseArrows || arrow.Durability > 5000)
                 {
                     Network.PacketHandler.ReloadArrows(client.Equipment.TryGetItem(ConquerItem.LeftWeapon), client);
                 }
             }
         }
     }
 }
コード例 #8
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void DropItem(ItemUsage itemUsage, Client.GameState client)
 {
     Interfaces.IConquerItem item = null;
     if (client.Inventory.TryGetItem(itemUsage.UID, out item))
     {
         if (item.ID == 0)
             return;
         Database.ConquerItemInformation infos = new Database.ConquerItemInformation(item.ID, 0);
         if (item.Lock != 0 || item.Suspicious)
             return;
         if (infos.BaseInformation.Type == Database.ConquerItemBaseInformation.ItemType.Dropable && !item.Bound)
         {
             ushort X = client.Entity.X, Y = client.Entity.Y;
             if (client.Map.SelectCoordonates(ref X, ref Y))
             {
                 FloorItem floorItem = new FloorItem(true);
                 floorItem.Item = item;
                 floorItem.ItemID = item.ID;
                 floorItem.ItemColor = item.Color;
                 floorItem.MapID = client.Map.ID;
                 floorItem.MapObjType = Game.MapObjectType.Item;
                 floorItem.X = X;
                 floorItem.Y = Y;
                 floorItem.Type = FloorItem.Drop;
                 floorItem.OnFloor = Time32.Now;
                 floorItem.UID = FloorItem.FloorUID.Next;
                 while (client.Map.Npcs.ContainsKey(floorItem.UID))
                     floorItem.UID = FloorItem.FloorUID.Next;
                 client.SendScreenSpawn(floorItem, true);
                 client.Map.AddFloorItem(floorItem);
                 ushort stack = item.StackSize;
                 item.StackSize = 0;
                 client.Inventory.Remove(item, Game.Enums.ItemUse.Remove);
                 item.StackSize = stack;
             }
         }
         else
             client.Inventory.Remove(item, Game.Enums.ItemUse.Delete);
     }
 }
コード例 #9
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void DropMoney(ItemUsage itemUsage, Client.GameState client)
        {
            if (client.Entity.Money >= itemUsage.UID)
            {
                ushort X = client.Entity.X, Y = client.Entity.Y;
                if (client.Map.SelectCoordonates(ref X, ref Y))
                {
                    uint ItemID = MoneyItemID(itemUsage.UID);
                    FloorItem floorItem = new FloorItem(true);
                    floorItem.ValueType = FloorItem.FloorValueType.Money;
                    floorItem.Value = itemUsage.UID;
                    floorItem.ItemID = ItemID;
                    floorItem.MapID = client.Map.ID;
                    floorItem.MapObjType = Game.MapObjectType.Item;
                    floorItem.X = X;
                    floorItem.Y = Y;
                    floorItem.Type = FloorItem.Drop;
                    floorItem.OnFloor = Time32.Now;
                    floorItem.UID = FloorItem.FloorUID.Next;
                    while (client.Map.Npcs.ContainsKey(floorItem.UID))
                        floorItem.UID = FloorItem.FloorUID.Next;
                    client.SendScreenSpawn(floorItem, true);
                    client.Map.AddFloorItem(floorItem);
                    client.Entity.Money -= itemUsage.UID;

                }
            }
        }
コード例 #10
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void AddItemOnBooth(ItemUsage usage, Client.GameState client)
 {
     if (client.Booth != null)
     {
         if (!client.Booth.ItemList.ContainsKey(usage.UID))
         {
             if (client.Inventory.ContainsUID(usage.UID))
             {
                 Game.ConquerStructures.BoothItem item = new Conquer_Online_Server.Game.ConquerStructures.BoothItem();
                 item.Cost = usage.dwParam;
                 client.Inventory.TryGetItem(usage.UID, out item.Item);
                 Database.ConquerItemInformation infos = new Database.ConquerItemInformation(item.Item.ID, 0);
                 if (item.Item.Lock != 0 || item.Item.Suspicious || item.Item.Bound || infos.BaseInformation.Type != Database.ConquerItemBaseInformation.ItemType.Dropable)
                 {
                     return;
                 }
                 item.Cost_Type = usage.ID == ItemUsage.AddItemOnBoothForSilvers ? Conquer_Online_Server.Game.ConquerStructures.BoothItem.CostType.Silvers : Conquer_Online_Server.Game.ConquerStructures.BoothItem.CostType.ConquerPoints;
                 client.Booth.ItemList.Add(item.Item.UID, item);
                 client.Send(usage);
                 BoothItem Item = new BoothItem(true);
                 Item.Fill(item, client.Booth.Base.UID);
                 client.SendScreen(Item, false);
             }
         }
     }
 }
コード例 #11
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void BuyFromBooth(ItemUsage usage, Client.GameState client)
 {
     Client.GameState Owner = null;
     Game.Entity entity = null;
     if (client.Screen.TryGetValue((uint)((usage.dwParam - (usage.dwParam % 100000)) * 10 + (usage.dwParam % 100000)), out entity))
     {
         Owner = entity.Owner;
         if (Owner != null)
         {
             if (Owner.Entity.UID != client.Entity.UID)
             {
                 if (Owner.Booth.ItemList.ContainsKey(usage.UID))
                 {
                     Game.ConquerStructures.BoothItem item = Owner.Booth.ItemList[usage.UID];
                     if (client.Inventory.Count <= 39)
                     {
                         if (item.Cost_Type == Conquer_Online_Server.Game.ConquerStructures.BoothItem.CostType.Silvers)
                         {
                             if (client.Entity.Money >= item.Cost)
                             {
                                 client.Entity.Money -= item.Cost;
                                 Owner.Entity.Money += item.Cost;
                                 client.Send(usage);
                                 client.Inventory.Add(item.Item, Game.Enums.ItemUse.Move);
                                 usage.ID = ItemUsage.RemoveItemFromBooth;
                                 Owner.Send(usage);
                                 Owner.Inventory.Remove(item.Item.UID, Game.Enums.ItemUse.None, false);
                                 usage.ID = ItemUsage.RemoveInventory;
                                 Owner.Send(usage);
                                 Owner.Booth.ItemList.Remove(item.Item.UID);
                                 Database.ConquerItemInformation infos = new Database.ConquerItemInformation(item.Item.ID, 0);
                                 Owner.Send(ServerBase.Constants.BoothItemSell(client.Entity.Name, infos.BaseInformation.Name, false, item.Cost));
                             }
                         }
                         else
                         {
                             if (client.Entity.ConquerPoints >= item.Cost)
                             {
                                 client.Entity.ConquerPoints -= item.Cost;
                                 Owner.Entity.ConquerPoints += item.Cost;
                                 client.Send(usage);
                                 client.Inventory.Add(item.Item, Game.Enums.ItemUse.Move);
                                 usage.ID = ItemUsage.RemoveItemFromBooth;
                                 Owner.Send(usage);
                                 Owner.Inventory.Remove(item.Item.UID, Game.Enums.ItemUse.None, false);
                                 usage.ID = ItemUsage.RemoveInventory;
                                 Owner.Send(usage);
                                 Owner.Booth.ItemList.Remove(item.Item.UID);
                                 Database.ConquerItemInformation infos = new Database.ConquerItemInformation(item.Item.ID, 0);
                                 Owner.Send(ServerBase.Constants.BoothItemSell(client.Entity.Name, infos.BaseInformation.Name, true, item.Cost));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #12
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 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 Conquer_Online_Server.Database.ConquerItemInformation(item.ID, item.Plus);
             switch (upgrade.ID)
             {
                 case 1088000:
                     {
                         if (item.ID % 10 == (byte)Game.Enums.ItemQuality.Super)
                             break;
                         byte chance = (byte)(100 - ((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 = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                             item.Send(client);
                         }
                         else
                         {
                             item.Durability = (ushort)(item.Durability / 2);
                             Database.ConquerItemTable.UpdateDurabilityItem(item);
                             item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                             item.Send(client);
                         }
                         //item = ItemSocket(item, 1, client);
                         client.Inventory.Remove(upgrade, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
                         break;
                     }
                 case 1088001:
                     {
                         if (infos.BaseInformation.Level > 120)
                             break;
                         byte chance = 100;
                         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 Conquer_Online_Server.Database.ConquerItemInformation(item.ID, item.Plus);
                                 item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
                                 Database.ConquerItemTable.UpdateItemID(item, client);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             else
                             {
                                 item.Durability = (ushort)(item.Durability / 2);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             //item = ItemSocket(item, 2, client);
                             client.Inventory.Remove(upgrade, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
                         }
                         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;
                         chance -= (byte)(infos.BaseInformation.Level / 10 * 4);
                         chance -= (byte)(((item.ID % 10) + 1) * 3);
                         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 Conquer_Online_Server.Database.ConquerItemInformation(item.ID, item.Plus);
                                 item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
                                 Database.ConquerItemTable.UpdateItemID(item, client);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             else
                             {
                                 item.Durability = (ushort)(item.Durability / 2);
                                 Database.ConquerItemTable.UpdateDurabilityItem(item);
                                 item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                                 item.Send(client);
                             }
                             item = ItemSocket(item, 2, client);
                             client.Inventory.Remove(upgrade, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
                         }
                         break;
                     }
             }
         }
     }
 }
コード例 #13
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void UnequipItem(ItemUsage usage, Client.GameState client)
 {
     if (client.Equipment.Remove((byte)usage.dwParam))
     {
         if (client.Map.ID == 1039)
             client.Entity.AttackPacket = null;
         client.CalculateStatBonus();
         client.CalculateHPBonus();
         client.SendStatMessage();
         EntityEquipment equips = new EntityEquipment(true);
         equips.ParseHero(client);
         client.Send(equips);
     }
 }
コード例 #14
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void SocketTalismanWithItem(ItemUsage itemUsage, Client.GameState client)
        {
            Interfaces.IConquerItem talisman = client.Equipment.TryGetItem(itemUsage.UID);
            Interfaces.IConquerItem item = null;
            if (client.Inventory.TryGetItem(itemUsage.dwParam, out item))
            {
                if (talisman == null)
                    return;
                if (item.ID / 1000 == talisman.ID / 1000)
                    return;
                if (item.Bound == true)
                    return;
                if (talisman.SocketTwo != Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                    return;

                ushort Points = 0;
                switch (item.ID % 10)
                {
                    case 6: Points += 5; break;
                    case 7: Points += 10; break;
                    case 8: Points += 40; break;
                    case 9: Points += 1000; break;
                }
                Points += Database.DataHolder.TalismanPlusPoints(item.Plus);

                int position = ItemPosition(item.ID);
                switch (position)
                {
                    case 0: return;
                    case 4:
                    case 5:
                        if (item.ID % 10 >= 8)
                        {
                            if (item.SocketOne != Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                                Points += 160;
                            if (item.SocketTwo != Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                                Points += 800;
                        }
                        break;
                    default:
                        if (item.ID % 10 >= 8)
                        {
                            if (item.SocketOne != Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                                Points += 2000;
                            if (item.SocketTwo != Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                                Points += 6000;
                        }
                        break;
                }
                talisman.SocketProgress += Points;
                if (talisman.SocketOne == Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                {
                    if (talisman.SocketProgress >= 8000)
                    {
                        talisman.SocketProgress -= 8000;
                        talisman.SocketOne = Conquer_Online_Server.Game.Enums.Gem.EmptySocket;

                        talisman.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                        talisman.Send(client);
                    }
                }
                if (talisman.SocketOne != Conquer_Online_Server.Game.Enums.Gem.NoSocket)
                {
                    if (talisman.SocketProgress >= 20000)
                    {
                        talisman.SocketProgress = 0;
                        talisman.SocketTwo = Conquer_Online_Server.Game.Enums.Gem.EmptySocket;
                    }
                }
                Database.ConquerItemTable.UpdateSocketProgress(talisman, client);
                Database.ConquerItemTable.UpdateSockets(talisman, client);
                talisman.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                talisman.Send(client);
                client.Inventory.Remove(item, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
            }
        }
コード例 #15
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void RemoveItemFromBooth(ItemUsage usage, Client.GameState client)
 {
     if (client.Booth.ItemList.ContainsKey(usage.UID))
     {
         client.Booth.ItemList.Remove(usage.UID);
         client.SendScreen(usage, true);
     }
 }
コード例 #16
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void EnchantItem(ItemUsage itemUsage, Client.GameState client)
 {
     Interfaces.IConquerItem Item = null, EnchantGem = null;
     if (client.Inventory.TryGetItem(itemUsage.UID, out Item) && client.Inventory.TryGetItem(itemUsage.dwParam, out EnchantGem))
     {
         byte gemBase = (byte)(EnchantGem.ID % 1000);
         if (Enum.IsDefined(typeof(Game.Enums.Gem), gemBase))
         {
             byte Enchant = 0;
             switch (EnchantGem.ID % 10)
             {
                 case 1:
                     {
                         Enchant = (byte)ServerBase.Kernel.Random.Next(1, 59);
                         break;
                     }
                 case 2:
                     {
                         if (EnchantGem.ID == 700012)
                             Enchant = (byte)ServerBase.Kernel.Random.Next(100, 159);
                         else if (EnchantGem.ID == 700002 || EnchantGem.ID == 700052 || EnchantGem.ID == 700062)
                             Enchant = (byte)ServerBase.Kernel.Random.Next(60, 109);
                         else if (EnchantGem.ID == 700032)
                             Enchant = (byte)ServerBase.Kernel.Random.Next(80, 129);
                         else
                             Enchant = (byte)ServerBase.Kernel.Random.Next(40, 89);
                         break;
                     }
                 default:
                     {
                         if (EnchantGem.ID == 700013)
                             Enchant = (byte)ServerBase.Kernel.Random.Next(200, 255);
                         else if (EnchantGem.ID == 700003 || EnchantGem.ID == 700073 || EnchantGem.ID == 700033)
                             Enchant = (byte)ServerBase.Kernel.Random.Next(170, 229);
                         else if (EnchantGem.ID == 700063 || EnchantGem.ID == 700053)
                             Enchant = (byte)ServerBase.Kernel.Random.Next(140, 199);
                         else if (EnchantGem.ID == 700023)
                             Enchant = (byte)ServerBase.Kernel.Random.Next(90, 149);
                         else
                             Enchant = (byte)ServerBase.Kernel.Random.Next(70, 119);
                         break;
                     }
             }
             client.Send(ServerBase.Constants.Enchant(Item.Enchant, Enchant));
             if (Enchant > Item.Enchant)
             {
                 Item.Enchant = Enchant;
                 Item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                 Item.Send(client);
                 Database.ConquerItemTable.UpdateEnchant(Item, client);
                 client.Inventory.Remove(EnchantGem, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
             }
             else
             {
                 client.Inventory.Remove(EnchantGem, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
             }
         }
     }
 }
コード例 #17
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
 static void ShowBoothItems(ItemUsage usage, Client.GameState client)
 {
     Client.GameState Owner = null;
     Game.Entity entity = null;
     if (client.Screen.TryGetValue((uint)((usage.UID - (usage.UID % 100000)) * 10 + (usage.UID % 100000)), out entity))
     {
         Owner = entity.Owner;
         if (Owner != null)
         {
             if (Owner.Entity.UID != client.Entity.UID)
             {
                 BoothItem Item = new BoothItem(true);
                 if (Owner.Booth != null)
                 {
                     foreach (Game.ConquerStructures.BoothItem item in Owner.Booth.ItemList.Values)
                     {
                         Item.Fill(item, Owner.Booth.Base.UID);
                         client.Send(Item);
                     }
                 }
             }
         }
     }
 }
コード例 #18
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        static void EquipItem(ItemUsage itemUsage, Client.GameState client)
        {
            Interfaces.IConquerItem item = null;
            client.Entity.AttackPacket = null;
            if (client.Inventory.TryGetItem(itemUsage.UID, out item))
            {
                if (item.Suspicious)
                    return;
                switch (item.ID)
                {
                    case 1200000:
                    case 1200001:
                    case 1200002:
                        {
                            UseItem(item, client);
                            return;

                        }
                    default:
                        {
                            if (itemUsage.dwParam == 17 && ItemPosition(item.ID) == 0)
                            {
                                UseItem(item, client);
                                return;
                            }
                            else if (itemUsage.dwParam == 0 && ItemPosition(item.ID) == 0)
                            {
                                UseItem(item, client);
                                return;
                            }
                            break;
                        }
                }
                #region Sanity checks

                bool can2hand = false;
                bool can2wpn = false;
                if (client.Entity.Class >= 11 && client.Entity.Class <= 65)
                    can2hand = true;
                if (client.Entity.Class >= 11 && client.Entity.Class <= 15 || client.Entity.Class >= 51 && client.Entity.Class <= 55 || client.Entity.Class >= 61 && client.Entity.Class <= 65 || client.Entity.Class >= 71 && client.Entity.Class <= 75)
                    can2wpn = true;
                if (!Equipable(item, client))
                    return;
                if (ItemPosition(item.ID) == 5)
                {
                    itemUsage.dwParam = 5;
                    if (!can2hand && !can2wpn)
                        return;
                    if (client.Equipment.Free(4) || (client.Equipment.TryGetItem(4).ID / 1000 != 500 && IsArrow(item.ID)))
                        return;
                }
                if (ItemPosition(item.ID) == 4)
                {
                    if (itemUsage.dwParam == 5)
                        if (!can2hand || !can2wpn)
                            return;
                }
                if (!((itemUsage.dwParam == 4 || itemUsage.dwParam == 5) && (ItemPosition(item.ID) == 4 || ItemPosition(item.ID) == 5)))
                {
                    if (!IsAccessory(item.ID))
                        itemUsage.dwParam = ItemPosition(item.ID);
                }
                bool twohand = IsTwoHand(item.ID);
                if (!twohand && itemUsage.dwParam == 4)
                    if (!client.Equipment.Free(5))
                        if (client.Inventory.Count < 40)
                        {
                            if (IsArrow(client.Equipment.TryGetItem(5).ID))
                                client.Equipment.Remove(5);
                            else
                            {
                                if (client.Equipment.TryGetItem(4) != null)
                                {
                                    if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                                        client.Equipment.Remove(4);
                                }
                            }
                        }
                #endregion

                if (client.Map.ID == 1039)
                    client.Entity.AttackPacket = null;

                item.Position = (ushort)itemUsage.dwParam;
                if (ItemPosition(item.ID) == 5 && !IsArrow(item.ID))
                {
                    if (IsTwoHand(client.Equipment.TryGetItem(4).ID))
                    {
                        if (!client.Spells.ContainsKey(10311))//Perseverance
                        {
                            client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.White, Message.Talk));
                            return;
                        }
                    }
                }

                Database.ConquerItemTable.ClearPosition(client.Entity.UID, (byte)itemUsage.dwParam);
                client.Inventory.Remove(item, Game.Enums.ItemUse.Move);
                if (client.Equipment.Free((byte)itemUsage.dwParam))
                {
                    if (twohand)
                        client.Equipment.Remove(5);
                    item.Position = (byte)itemUsage.dwParam;
                    client.Equipment.Add(item);
                    item.Mode = Game.Enums.ItemMode.Update;
                    item.Send(client);
                }
                else
                {
                    if (twohand)
                        client.Equipment.Remove(5);
                    client.Equipment.Remove((byte)itemUsage.dwParam);
                    item.Position = (byte)itemUsage.dwParam;
                    client.Equipment.Add(item);
                }
                client.CalculateStatBonus();
                client.CalculateHPBonus();
                client.SendStatMessage();
                EntityEquipment equips = new EntityEquipment(true);
                equips.ParseHero(client);
                client.Send(equips);
            }
        }
コード例 #19
0
ファイル: GameState.cs プロジェクト: AiiMz/PserverWork
 public void SendEquipment(bool Others)
 {
     ItemUsage I = new ItemUsage(true);
     I.UID = this.Entity.UID;
     I.ID = 46;
     for (uint Z = 1; Z < 13; Z++)
     {
         if (!this.Equipment.Free(Z))
         {
             Interfaces.IConquerItem Item = this.Equipment.TryGetItem(Z);
             switch (Item.Position)
             {
                 case 1:
                     I.Pos1 = Item.UID;
                     break;
                 case 2:
                     I.Pos2 = Item.UID;
                     break;
                 case 3:
                     I.Pos3 = Item.UID;
                     break;
                 case 4:
                     I.Pos4 = Item.UID;
                     break;
                 case 5:
                     I.Pos5 = Item.UID;
                     break;
                 case 6:
                     I.Pos6 = Item.UID;
                     break;
                 case 7:
                     I.Pos7 = Item.UID;
                     break;
                 case 8:
                     I.Pos8 = Item.UID;
                     break;
                 case 9:
                     I.Pos9 = Item.UID;
                     break;
                 case 10:
                     I.Pos10 = Item.UID;
                     break;
                 case 11:
                     I.Pos11 = Item.UID;
                     break;
             }
         }
     }
     if (Others)
         this.SendScreen(I, true);
     else
         this.Send(I);
 }
コード例 #20
0
ファイル: Handle.cs プロジェクト: AiiMz/PserverWork
        private void Execute()
        {
            #region interactions
            if (attack != null)
            {
                switch (attack.AttackType)
                {
                    case (uint)Network.GamePackets.Attack.InteractionRequest:
                        new InteractionRequest(attack, attacker);
                        return;
                    case (uint)Network.GamePackets.Attack.InteractionEffect:
                        new InteractionEffect(attack, attacker);
                        return;

                    case (uint)Network.GamePackets.Attack.InteractionAccept:
                        new InteractionAccept(attack, attacker);
                        return;
                    case (uint)Network.GamePackets.Attack.InteractionRefuse:
                        new InteractionRefuse(attack, attacker);
                        return;
                    case (uint)Network.GamePackets.Attack.InteractionStopEffect:
                        new InteractionStopEffect(attack, attacker);
                        return;
                }
            }
            #endregion
            #region Monster -> Player \ Monster
            if (attack == null)
            {
                if (attacker.EntityFlag != EntityFlag.Monster)
                    return;
                if (attacker.Companion)
                {
                    if (ServerBase.Constants.PKForbiddenMaps.Contains(attacker.MapID))
                        return;
                }
                if (attacked.EntityFlag == EntityFlag.Player)
                {
                    if (!attacked.Owner.Attackable)
                        return;
                    if (attacked.Dead)
                        return;
                    //uint damageo = Calculate.Melee(attacker, attacked);
                    //uint damageo2 = Calculate.Melee(attacker, attacked);
                    if (attacked.Dead)
                    {
                        attacked.Die();

                        return;
                    }
                    #region New Monster Attack And Spells
                    #region SwordMaster
                    if (attacker.Name == "SwordMaster")
                    {

                        uint rand = (uint)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 4);
                        switch (rand)
                        {

                            case 1:
                                attacker.MonsterInfo.SpellID = 10502;
                                break;
                            case 2:
                                attacker.MonsterInfo.SpellID = 10504;
                                break;
                            case 3:
                                attacker.MonsterInfo.SpellID = 10506;
                                break;

                            case 4:
                                attacker.MonsterInfo.SpellID = 10505;
                                break;
                        }

                        uint damage = 0;//Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0);
                        damage += (uint)ServerBase.Kernel.Random.Next(1200, 1400);
                        // damage += attacker.MagicAttack;
                        //damage -= attacked.PhysicalDamageDecrease;
                        // damage -= attacked.MagicDamageDecrease;
                        //  damage -= attacked.MagicDefence;

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die();
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                        if (attacker.Companion)
                            attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = attacker.UID;
                        suse.SpellID = attacker.MonsterInfo.SpellID;
                        suse.X = attacked.X;
                        suse.Y = attacked.Y;
                        suse.Targets.Add(attacked.UID, damage);
                        attacked.Owner.SendScreen(suse, true);
                    }

                    #endregion
                    #region ThrillingSpook
                    if (attacker.Name == "ThrillingSpook" || attacker.Name == "LavaBeast")
                    {

                        uint rand = (uint)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 4);
                        switch (rand)
                        {

                            case 1:
                                attacker.MonsterInfo.SpellID = 10363;
                                break;
                            case 2:
                                attacker.MonsterInfo.SpellID = 10360;
                                break;
                            case 3:
                                attacker.MonsterInfo.SpellID = 10361;
                                break;

                            case 4:
                                attacker.MonsterInfo.SpellID = 10362;
                                break;
                        }

                        uint damage = 0;//Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0);
                        damage += (uint)ServerBase.Kernel.Random.Next(300, 500);
                        // damage += attacker.MagicAttack;
                        //damage -= attacked.PhysicalDamageDecrease;
                        // damage -= attacked.MagicDamageDecrease;
                        //  damage -= attacked.MagicDefence;

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die();
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                        if (attacker.Companion)
                            attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = attacker.UID;
                        suse.SpellID = attacker.MonsterInfo.SpellID;
                        suse.X = attacked.X;
                        suse.Y = attacked.Y;
                        suse.Targets.Add(attacked.UID, damage);
                        attacked.Owner.SendScreen(suse, true);
                    }

                    #endregion
                    #region SnowBanhe
                    if (attacker.Name == "SnowBanshee")
                    {

                        uint rand = (uint)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 4);
                        switch (rand)
                        {

                            case 1:
                                attacker.MonsterInfo.SpellID = 30010;
                                break;
                            case 2:
                                attacker.MonsterInfo.SpellID = 30011;
                                break;
                            case 3:
                                attacker.MonsterInfo.SpellID = 30012;
                                break;

                            case 4:
                                attacker.MonsterInfo.SpellID = 10001;
                                break;
                        }

                        uint damage = 0;//Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0);
                        damage += (uint)ServerBase.Kernel.Random.Next(1200, 1400);
                        // damage += attacker.MagicAttack;
                        //damage -= attacked.PhysicalDamageDecrease;
                        // damage -= attacked.MagicDamageDecrease;
                        //  damage -= attacked.MagicDefence;

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die();
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                        if (attacker.Companion)
                            attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = attacker.UID;
                        suse.SpellID = attacker.MonsterInfo.SpellID;
                        suse.X = attacked.X;
                        suse.Y = attacked.Y;
                        suse.Targets.Add(attacked.UID, damage);
                        attacked.Owner.SendScreen(suse, true);
                    }
                    #endregion
                    #region TreatoDragon
                    if (attacker.Name == "TeratoDragon")
                    {
                        uint rand = (uint)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 5);
                        switch (rand)
                        {

                            case 1:
                                attacker.MonsterInfo.SpellID = 7012;
                                break;
                            case 2:
                                attacker.MonsterInfo.SpellID = 7013;
                                break;
                            case 3:
                                attacker.MonsterInfo.SpellID = 7015;
                                break;
                            case 4:
                                attacker.MonsterInfo.SpellID = 7016;
                                break;
                            case 5:
                                attacker.MonsterInfo.SpellID = 7017;
                                break;

                        }

                        uint damage = 0;//Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0);
                        damage += (uint)ServerBase.Kernel.Random.Next(1200, 1400);
                        // damage += attacker.MagicAttack;
                        //damage -= attacked.PhysicalDamageDecrease;
                        // damage -= attacked.MagicDamageDecrease;
                        //  damage -= attacked.MagicDefence;

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die();
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                        if (attacker.Companion)
                            attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = attacker.UID;
                        suse.SpellID = attacker.MonsterInfo.SpellID;
                        suse.X = attacked.X;
                        suse.Y = attacked.Y;
                        suse.Targets.Add(attacked.UID, damage);
                        attacked.Owner.SendScreen(suse, true);

                    }
                    #endregion
                    #region Nobility War
                    if (attacker.Name == "KingMonster" || attacker.Name == "PrincesMonster" || attacker.Name == "DukeMonster")
                    {
                        uint rand = (uint)Conquer_Online_Server.ServerBase.Kernel.Random.Next(1, 5);
                        switch (rand)
                        {

                            case 1:
                                attacker.MonsterInfo.SpellID = 7012;
                                break;
                            case 2:
                                attacker.MonsterInfo.SpellID = 7013;
                                break;
                            case 3:
                                attacker.MonsterInfo.SpellID = 7015;
                                break;
                            case 4:
                                attacker.MonsterInfo.SpellID = 7016;
                                break;
                            case 5:
                                attacker.MonsterInfo.SpellID = 7017;
                                break;

                        }

                        uint damage = 0;//Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0);
                        damage += (uint)ServerBase.Kernel.Random.Next(100, 300);
                        // damage += attacker.MagicAttack;
                        //damage -= attacked.PhysicalDamageDecrease;
                        // damage -= attacked.MagicDamageDecrease;
                        //  damage -= attacked.MagicDefence;

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die();
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                        if (attacker.Companion)
                            attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = attacker.UID;
                        suse.SpellID = attacker.MonsterInfo.SpellID;
                        suse.X = attacked.X;
                        suse.Y = attacked.Y;
                        suse.Targets.Add(attacked.UID, damage);
                        attacked.Owner.SendScreen(suse, true);

                    }
                    #endregion

                    #endregion

                    if (attacker.MonsterInfo.SpellID == 0)
                    {
                        uint damage = Calculate.Melee(attacker, attacked);

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die();
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }

                        attack = new Attack(true);
                        attack.Attacker = attacker.UID;
                        attack.Attacked = attacked.UID;
                        attack.AttackType = Attack.Melee;
                        attack.Damage = damage;
                        attack.X = attacked.X;
                        attack.Y = attacked.Y;
                        //attack.FirstEffect = EffectValue.Block;
                        attacked.Owner.SendScreen(attack, true);
                    }
                    else
                    {
                        uint damage = Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0);

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die();
                        }

                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                        if (attacker.Companion)
                            attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);

                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = attacker.UID;
                        suse.SpellID = attacker.MonsterInfo.SpellID;
                        suse.X = attacked.X;
                        suse.Y = attacked.Y;
                        suse.Targets.Add(attacked.UID, damage);
                        attacked.Owner.SendScreen(suse, true);
                    }
                }
                else
                {
                    if (attacker.MonsterInfo.SpellID == 0)
                    {
                        uint damage = Calculate.Melee(attacker, attacked);
                        attack = new Attack(true);
                        attack.Attacker = attacker.UID;
                        attack.Attacked = attacked.UID;
                        attack.AttackType = Attack.Melee;
                        attack.Damage = damage;
                        attack.X = attacked.X;
                        attack.Y = attacked.Y;
                        attacked.MonsterInfo.SendScreen(attack);
                        if (attacker.Companion)
                            if (damage > attacked.Hitpoints)
                                attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                            else
                                attacker.Owner.IncreaseExperience(damage, true);

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die(attacker);
                            attack = new Attack(true);
                            attack.Attacker = attacker.UID;
                            attack.Attacked = attacked.UID;
                            attack.AttackType = Network.GamePackets.Attack.Kill;
                            attack.X = attacked.X;
                            attack.Y = attacked.Y;
                            attacked.MonsterInfo.SendScreen(attack);
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                    }
                    else
                    {
                        uint damage = Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0);
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = attacker.UID;
                        suse.SpellID = attacker.MonsterInfo.SpellID;
                        suse.X = attacked.X;
                        suse.Y = attacked.Y;
                        suse.Targets.Add(attacked.UID, damage);
                        attacked.MonsterInfo.SendScreen(suse);
                        if (attacker.Companion)
                            if (damage > attacked.Hitpoints)
                                attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                            else
                                attacker.Owner.IncreaseExperience(damage, true);

                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die(attacker);
                            attack = new Attack(true);
                            attack.Attacker = attacker.UID;
                            attack.Attacked = attacked.UID;
                            attack.AttackType = Network.GamePackets.Attack.Kill;
                            attack.X = attacked.X;
                            attack.Y = attacked.Y;
                            attacked.MonsterInfo.SendScreen(attack);
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                    }
                }
            }
            #endregion
            #region Player -> Player \ Monster \ Sob Npc
            else
            {
                #region Merchant
                if (attack.AttackType == Attack.MerchantAccept || attack.AttackType == Attack.MerchantRefuse)
                {

                    attacker.AttackPacket = null;
                    return;
                }
                #endregion
                #region Marriage
                if (attack.AttackType == Attack.MarriageAccept || attack.AttackType == Attack.MarriageRequest)
                {
                    if (attack.AttackType == Attack.MarriageRequest)
                    {
                        Client.GameState Spouse = null;
                        uint takeout = attack.Attacked;
                        if (takeout == attacker.UID)
                            takeout = attack.Attacker;
                        if (ServerBase.Kernel.GamePool.TryGetValue(takeout, out Spouse))
                        {
                            if (attacker.Spouse != "None" || Spouse.Entity.Spouse != "None")
                            {
                                attacker.Owner.Send(new Message("You cannot marry someone that is already married with someone else!", System.Drawing.Color.Black, Message.TopLeft));
                            }
                            else
                            {
                                uint id1 = attacker.Mesh % 10, id2 = Spouse.Entity.Mesh % 10;

                                if (id1 <= 2 && id2 >= 3 || id1 >= 2 && id2 <= 3)
                                {

                                    attack.X = Spouse.Entity.X;
                                    attack.Y = Spouse.Entity.Y;

                                    Spouse.Send(attack);
                                }
                                else
                                {
                                    attacker.Owner.Send(new Message("You cannot marry someone of your gender!", System.Drawing.Color.Black, Message.TopLeft));
                                }
                            }
                        }
                    }
                    else
                    {
                        Client.GameState Spouse = null;
                        if (ServerBase.Kernel.GamePool.TryGetValue(attack.Attacked, out Spouse))
                        {
                            if (attacker.Spouse != "None" || Spouse.Entity.Spouse != "None")
                            {
                                attacker.Owner.Send(new Message("You cannot marry someone that is already married with someone else!", System.Drawing.Color.Black, Message.TopLeft));
                            }
                            else
                            {
                                if (attacker.Mesh % 10 <= 2 && Spouse.Entity.Mesh % 10 >= 3 || attacker.Mesh % 10 >= 3 && Spouse.Entity.Mesh % 10 <= 2)
                                {
                                    Spouse.Entity.Spouse = attacker.Name;
                                    attacker.Spouse = Spouse.Entity.Name;
                                    Message message = null;
                                    if (Spouse.Entity.Mesh % 10 >= 3)
                                        message = new Message("Joy and happiness! " + Spouse.Entity.Name + " and " + attacker.Name + " have joined together in the holy marriage. We wish them a stone house.", System.Drawing.Color.BurlyWood, Message.Center);
                                    else
                                        message = new Message("Joy and happiness! " + attacker.Name + " and " + attacker.Spouse + " have joined together in the holy marriage. We wish them a stone house.", System.Drawing.Color.BurlyWood, Message.Center);

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

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

                                        client.Send(message);

                                        varr.MoveNext();

                                    }

                                    Spouse.Entity.Update(_String.Effect, "firework-2love", true);
                                    attacker.Update(_String.Effect, "firework-2love", true);
                                }
                                else
                                {
                                    attacker.Owner.Send(new Message("You cannot marry someone of your gender!", System.Drawing.Color.Black, Message.TopLeft));
                                }
                            }
                        }
                    }
                }
                #endregion
            #endregion

                #region Attacking
                else
                {
                    attacker.Owner.Attackable = true;
                    Entity attacked = null;
                    SobNpcSpawn attackedsob = null;

                    #region Checks
                    if (attack.Attacker != attacker.UID)
                        return;
                    if (attacker.EntityFlag != EntityFlag.Player)
                        return;
                    attacker.RemoveFlag(Update.Flags.Invisibility);

                    bool pass = false;
                    if (attack.AttackType == Attack.Melee)
                    {
                        if (attacker.OnFatalStrike())
                        {
                            if (attack.Attacked < 600000)
                            {
                                pass = true;
                            }
                        }
                    }
                    ushort decrease = 0;
                    if (attacker.OnCyclone())
                        decrease = 700;
                    if (attacker.OnSuperman())
                        decrease = 300;
                    if (!pass)
                    {
                        int milliSeconds = 1000 - attacker.Agility - decrease;
                        if (milliSeconds < 0 || milliSeconds > 5000)
                            milliSeconds = 0;
                        if (Time32.Now < attacker.AttackStamp.AddMilliseconds(milliSeconds))
                            return;
                    }
                    if (attacker.Dead)
                    {
                        if (attacker.AttackPacket != null)
                            attacker.AttackPacket = null;
                        return;
                    }
                    attacker.AttackStamp = Time32.Now;
                    if (attacker.Owner.QualifierGroup != null)
                    {
                        if (Time32.Now < attacker.Owner.QualifierGroup.CreateTime.AddSeconds(12))
                        {
                            return;
                        }
                    }

                restart:

                    #region Extract attack information
                    ushort SpellID = 0, X = 0, Y = 0;
                    uint Target = 0;
                    if (attack.AttackType == Attack.Magic)
                    {
                        if (!attack.Decoded)
                        {
                            #region GetSkillID
                            SpellID = Convert.ToUInt16(((long)attack.ToArray()[24] & 0xFF) | (((long)attack.ToArray()[25] & 0xFF) << 8));
                            SpellID ^= (ushort)0x915d;
                            SpellID ^= (ushort)attacker.UID;
                            SpellID = (ushort)(SpellID << 0x3 | SpellID >> 0xd);
                            SpellID -= 0xeb42;
                            #endregion
                            #region GetCoords
                            X = (ushort)((attack.ToArray()[16] & 0xFF) | ((attack.ToArray()[17] & 0xFF) << 8));
                            X = (ushort)(X ^ (uint)(attacker.UID & 0xffff) ^ 0x2ed6);
                            X = (ushort)(((X << 1) | ((X & 0x8000) >> 15)) & 0xffff);
                            X = (ushort)((X | 0xffff0000) - 0xffff22ee);

                            Y = (ushort)((attack.ToArray()[18] & 0xFF) | ((attack.ToArray()[19] & 0xFF) << 8));
                            Y = (ushort)(Y ^ (uint)(attacker.UID & 0xffff) ^ 0xb99b);
                            Y = (ushort)(((Y << 5) | ((Y & 0xF800) >> 11)) & 0xffff);
                            Y = (ushort)((Y | 0xffff0000) - 0xffff8922);
                            #endregion
                            #region GetTarget
                            Target = ((uint)attack.ToArray()[12] & 0xFF) | (((uint)attack.ToArray()[13] & 0xFF) << 8) | (((uint)attack.ToArray()[14] & 0xFF) << 16) | (((uint)attack.ToArray()[15] & 0xFF) << 24);
                            Target = ((((Target & 0xffffe000) >> 13) | ((Target & 0x1fff) << 19)) ^ 0x5F2D2463 ^ attacker.UID) - 0x746F4AE6;
                            #endregion

                            attack.X = X;
                            attack.Y = Y;
                            attack.Damage = SpellID;
                            attack.Attacked = Target;
                            attack.Decoded = true;
                        }
                        else
                        {
                            X = attack.X;
                            Y = attack.Y;
                            SpellID = (ushort)attack.Damage;
                            Target = attack.Attacked;
                        }
                    }
                    #endregion
                    #endregion

                    if (attacker.ContainsFlag(Update.Flags.Ride))
                    {
                        attacker.Stamina = 100;
                        if (attacker.RidingCropID == 0)
                        {
                            if (attack.AttackType != Attack.Magic)
                                attacker.RemoveFlag(Update.Flags.Ride);
                            else
                                if (!(SpellID == 7003 || SpellID == 7002))
                                    attacker.RemoveFlag(Update.Flags.Ride);
                        }
                    }
                    //if (attacked.ContainsFlag(Update.Flags.Ride))
                    //{
                    //    //if (attack.AttackType != Attack.Magic)
                    //    //    attacker.RemoveFlag(Update.Flags.Ride);
                    //    //else
                    //    if (!(SpellID == 7003 || SpellID == 7002))
                    //        attacked.RemoveFlag(Update.Flags.Ride);
                    //}
                    if (attacker.ContainsFlag(Update.Flags.CastPray))
                        attacker.RemoveFlag(Update.Flags.CastPray);
                    if (attacker.ContainsFlag(Update.Flags.Praying))
                        attacker.RemoveFlag(Update.Flags.Praying);
                    Interfaces.IConquerItem item = new Network.GamePackets.ConquerItem(true);
                    // BlessEffect.Handler(client);

                    #region GemuriEfecte
                    {
                        #region DragonGem
                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.RightWeapon))
                        {
                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.RightWeapon);
                            if (rightweapon.SocketOne == Game.Enums.Gem.SuperDragonGem || rightweapon.SocketTwo == Game.Enums.Gem.SuperDragonGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("goldendragon");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                        {
                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.LeftWeapon);
                            if (rightweapon.SocketOne == Game.Enums.Gem.SuperDragonGem || rightweapon.SocketTwo == Game.Enums.Gem.SuperDragonGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("goldendragon");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Head))
                        {
                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Head);
                            if (rightweapon.SocketOne == Game.Enums.Gem.SuperDragonGem || rightweapon.SocketTwo == Game.Enums.Gem.SuperDragonGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("goldendragon");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Armor))
                        {
                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Armor);
                            if (rightweapon.SocketOne == Game.Enums.Gem.SuperDragonGem || rightweapon.SocketTwo == Game.Enums.Gem.SuperDragonGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("goldendragon");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Boots))
                        {
                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Boots);
                            if (rightweapon.SocketOne == Game.Enums.Gem.SuperDragonGem || rightweapon.SocketTwo == Game.Enums.Gem.SuperDragonGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("goldendragon");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Necklace))
                        {
                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Necklace);
                            if (rightweapon.SocketOne == Game.Enums.Gem.SuperDragonGem || rightweapon.SocketTwo == Game.Enums.Gem.SuperDragonGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("goldendragon");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Ring))
                        {
                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Ring);
                            if (rightweapon.SocketOne == Game.Enums.Gem.SuperDragonGem || rightweapon.SocketTwo == Game.Enums.Gem.SuperDragonGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("goldendragon");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        #endregion
                        #region phoenix Gem
                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.RightWeapon))
                        {
                            Interfaces.IConquerItem rightweapon1 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.RightWeapon);
                            if (rightweapon1.SocketOne == Game.Enums.Gem.SuperPhoenixGem || rightweapon1.SocketTwo == Game.Enums.Gem.SuperPhoenixGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("phoenix");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                        {
                            Interfaces.IConquerItem rightweapon1 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.LeftWeapon);
                            if (rightweapon1.SocketOne == Game.Enums.Gem.SuperPhoenixGem || rightweapon1.SocketTwo == Game.Enums.Gem.SuperPhoenixGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("phoenix");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Head))
                        {
                            Interfaces.IConquerItem rightweapon1 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Head);
                            if (rightweapon1.SocketOne == Game.Enums.Gem.SuperPhoenixGem || rightweapon1.SocketTwo == Game.Enums.Gem.SuperPhoenixGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("phoenix");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Armor))
                        {
                            Interfaces.IConquerItem rightweapon1 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Armor);
                            if (rightweapon1.SocketOne == Game.Enums.Gem.SuperPhoenixGem || rightweapon1.SocketTwo == Game.Enums.Gem.SuperPhoenixGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("phoenix");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Boots))
                        {
                            Interfaces.IConquerItem rightweapon1 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Boots);
                            if (rightweapon1.SocketOne == Game.Enums.Gem.SuperPhoenixGem || rightweapon1.SocketTwo == Game.Enums.Gem.SuperPhoenixGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("phoenix");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Necklace))
                        {
                            Interfaces.IConquerItem rightweapon1 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Necklace);
                            if (rightweapon1.SocketOne == Game.Enums.Gem.SuperPhoenixGem || rightweapon1.SocketTwo == Game.Enums.Gem.SuperPhoenixGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("phoenix");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Ring))
                        {
                            Interfaces.IConquerItem rightweapon1 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Ring);
                            if (rightweapon1.SocketOne == Game.Enums.Gem.SuperPhoenixGem || rightweapon1.SocketTwo == Game.Enums.Gem.SuperPhoenixGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("phoenix");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        #endregion
                        #region RainbowGem Gem
                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.RightWeapon))
                        {
                            Interfaces.IConquerItem rightweapon2 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.RightWeapon);
                            if (rightweapon2.SocketOne == Game.Enums.Gem.SuperRainbowGem || rightweapon2.SocketTwo == Game.Enums.Gem.SuperRainbowGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("rainbow");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                        {
                            Interfaces.IConquerItem rightweapon2 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.LeftWeapon);
                            if (rightweapon2.SocketOne == Game.Enums.Gem.SuperRainbowGem || rightweapon2.SocketTwo == Game.Enums.Gem.SuperRainbowGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("rainbow");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Head))
                        {
                            Interfaces.IConquerItem rightweapon2 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Head);
                            if (rightweapon2.SocketOne == Game.Enums.Gem.SuperRainbowGem || rightweapon2.SocketTwo == Game.Enums.Gem.SuperRainbowGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("rainbow");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Armor))
                        {
                            Interfaces.IConquerItem rightweapon2 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Armor);
                            if (rightweapon2.SocketOne == Game.Enums.Gem.SuperRainbowGem || rightweapon2.SocketTwo == Game.Enums.Gem.SuperRainbowGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("rainbow");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }

                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Boots))
                        {
                            Interfaces.IConquerItem rightweapon2 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Boots);
                            if (rightweapon2.SocketOne == Game.Enums.Gem.SuperRainbowGem || rightweapon2.SocketTwo == Game.Enums.Gem.SuperRainbowGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("rainbow");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Necklace))
                        {
                            Interfaces.IConquerItem rightweapon2 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Necklace);
                            if (rightweapon2.SocketOne == Game.Enums.Gem.SuperRainbowGem || rightweapon2.SocketTwo == Game.Enums.Gem.SuperRainbowGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("rainbow");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        else if (!attacker.Owner.Equipment.Free((byte)ConquerItem.Ring))
                        {
                            Interfaces.IConquerItem rightweapon2 = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.Ring);
                            if (rightweapon2.SocketOne == Game.Enums.Gem.SuperRainbowGem || rightweapon2.SocketTwo == Game.Enums.Gem.SuperRainbowGem)
                            {
                                if (ServerBase.Kernel.Rate(0.5))
                                {
                                    _String str = new _String(true);
                                    str.UID = attacker.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("rainbow");

                                    attacker.Owner.SendScreen(str, true);
                                }
                            }
                        }
                        #endregion

                    }
                    #endregion
                    #region Dash
                    if (SpellID == 1051)
                    {
                        if (ServerBase.Kernel.GetDistance(attack.X, attack.Y, attacker.X, attacker.Y) > 4)
                        {
                            attacker.Owner.Disconnect();
                            return;
                        }
                        attacker.X = attack.X; attacker.Y = attack.Y;
                        ushort x = attacker.X, y = attacker.Y;
                        Game.Map.UpdateCoordonatesForAngle(ref x, ref y, (Enums.ConquerAngle)Target);
                        foreach (Interfaces.IMapObject obj in attacker.Owner.Screen.Objects)
                        {
                            if (obj == null)
                                continue;
                            if (obj.X == x && obj.Y == y && (obj.MapObjType == MapObjectType.Monster || obj.MapObjType == MapObjectType.Player))
                            {
                                Entity entity = obj as Entity;
                                if (!entity.Dead)
                                {
                                    Target = obj.UID;
                                    break;
                                }
                            }
                        }
                    }
                    #endregion
                    #region CounterKill
                    if (attack.AttackType == Attack.CounterKillSwitch)
                    {
                        if (attacked != null)
                            if (attacked.ContainsFlag(Update.Flags.Fly))
                            { attacker.AttackPacket = null; return; }
                        if (attacker != null)
                            if (attacker.ContainsFlag(Update.Flags.Fly))
                            { attacker.AttackPacket = null; return; }
                        if (attacker.Owner.Spells.ContainsKey(6003))
                        {
                            if (!attacker.CounterKillSwitch)
                            {
                                if (Time32.Now >= attacker.CounterKillStamp.AddSeconds(15))
                                {
                                    attacker.CounterKillStamp = Time32.Now;
                                    attacker.CounterKillSwitch = true;
                                    Attack m_attack = new Attack(true);
                                    m_attack.Attacked = attacker.UID;
                                    m_attack.Attacker = attacker.UID;
                                    m_attack.AttackType = Attack.CounterKillSwitch;
                                    m_attack.Damage = 1;
                                    m_attack.X = attacker.X;
                                    m_attack.Y = attacker.Y;
                                    m_attack.Send(attacker.Owner);
                                }
                            }
                            else
                            {
                                attacker.CounterKillSwitch = false;
                                Attack m_attack = new Attack(true);
                                m_attack.Attacked = attacker.UID;
                                m_attack.Attacker = attacker.UID;
                                m_attack.AttackType = Attack.CounterKillSwitch;
                                m_attack.Damage = 0;
                                m_attack.X = attacker.X;
                                m_attack.Y = attacker.Y;
                                m_attack.Send(attacker.Owner);
                            }

                            attacker.Owner.IncreaseSpellExperience(100, 6003);
                            attacker.AttackPacket = null;
                        }
                    }
                    #endregion
                    #region Melee
                    else if (attack.AttackType == Attack.Melee)
                    {
                        if (attacker.Owner.Screen.TryGetValue(attack.Attacked, out attacked))
                        {
                            CheckForExtraWeaponPowers(attacker.Owner, attacked);
                            if (!CanAttack(attacker, attacked, null, attack.AttackType == Attack.Melee))
                                return;
                            pass = false;
                            if (attacker.OnFatalStrike())
                            {
                                if (attacked.EntityFlag == EntityFlag.Monster)
                                {
                                    pass = true;
                                }
                            }
                            ushort range = attacker.AttackRange;
                            if (attacker.Transformed)
                                range = (ushort)attacker.TransformationAttackRange;
                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= range || pass)
                            {
                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                attack.Damage = damage;
                                if (attacker.OnFatalStrike())
                                {
                                    if (attacked.EntityFlag == EntityFlag.Monster)
                                    {
                                        bool can = false;
                                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.RightWeapon))
                                            if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.RightWeapon).ID / 1000 == 601)
                                                can = true;
                                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                                            if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.LeftWeapon).ID / 1000 == 601)
                                                can = true;
                                        if (!can)
                                            return;
                                        ushort x = attacked.X;
                                        ushort y = attacked.Y;
                                        Map.UpdateCoordonatesForAngle(ref x, ref y, ServerBase.Kernel.GetAngle(attacked.X, attacked.Y, attacker.X, attacker.Y));
                                        attacker.Shift(x, y);
                                        attack.X = x;
                                        attack.Y = y;
                                        attack.AttackType = Attack.FatalStrike;
                                    }
                                }
                                //over:
                                if (!attacker.Owner.Equipment.Free((byte)ConquerItem.RightWeapon))
                                {
                                    Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.RightWeapon);
                                    ushort wep1subyte = (ushort)(rightweapon.ID / 1000), wep2subyte = 0;
                                    bool wep1bs = false, wep2bs = false;
                                    if (wep1subyte == 421)
                                    {
                                        wep1bs = true;
                                        wep1subyte--;
                                    }
                                    ushort wep1spellid = 0, wep2spellid = 0;
                                    if (Database.SpellTable.WeaponSpells.ContainsKey(wep1subyte))
                                        wep1spellid = Database.SpellTable.WeaponSpells[wep1subyte];
                                    Database.SpellInformation wep1spell = null, wep2spell = null;
                                    bool doWep1Spell = false, doWep2Spell = false;
                                    if (attacker.Owner.Spells.ContainsKey(wep1spellid) && Database.SpellTable.SpellInformations.ContainsKey(wep1spellid))
                                    {
                                        wep1spell = Database.SpellTable.SpellInformations[wep1spellid][attacker.Owner.Spells[wep1spellid].Level];
                                        doWep1Spell = ServerBase.Kernel.Rate(wep1spell.Percent);
                                        if (attacked.EntityFlag == EntityFlag.Player && wep1spellid == 10490)
                                            doWep1Spell = ServerBase.Kernel.Rate(5);
                                    }
                                    if (!doWep1Spell)
                                    {
                                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                                        {
                                            Interfaces.IConquerItem leftweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.LeftWeapon);
                                            wep2subyte = (ushort)(leftweapon.ID / 1000);
                                            if (wep2subyte == 421)
                                            {
                                                wep2bs = true;
                                                wep2subyte--;
                                            }
                                            if (Database.SpellTable.WeaponSpells.ContainsKey(wep2subyte))
                                                wep2spellid = Database.SpellTable.WeaponSpells[wep2subyte];
                                            if (attacker.Owner.Spells.ContainsKey(wep2spellid) && Database.SpellTable.SpellInformations.ContainsKey(wep2spellid))
                                            {
                                                wep2spell = Database.SpellTable.SpellInformations[wep2spellid][attacker.Owner.Spells[wep2spellid].Level];
                                                doWep2Spell = ServerBase.Kernel.Rate(wep2spell.Percent);
                                                if (attacked.EntityFlag == EntityFlag.Player && wep2spellid == 10490)
                                                    doWep2Spell = ServerBase.Kernel.Rate(5);
                                            }
                                        }
                                    }

                                    if (!attacker.Transformed)
                                    {
                                        if (doWep1Spell)
                                        {
                                            attack.AttackType = Attack.Magic;
                                            attack.Decoded = true;
                                            attack.X = attacked.X;
                                            attack.Y = attacked.Y;
                                            attack.Attacked = attacked.UID;
                                            attack.Damage = wep1spell.ID;
                                            goto restart;
                                        }
                                        if (doWep2Spell)
                                        {
                                            attack.AttackType = Attack.Magic;
                                            attack.Decoded = true;
                                            attack.X = attacked.X;
                                            attack.Y = attacked.Y;
                                            attack.Attacked = attacked.UID;
                                            attack.Damage = wep2spell.ID;
                                            goto restart;
                                        }
                                        if (wep1bs)
                                            wep1subyte++;
                                        if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag != EntityFlag.Player)
                                            if (damage > attacked.Hitpoints)
                                            {
                                                attacker.Owner.IncreaseProficiencyExperience(Math.Min(damage, attacked.Hitpoints), wep1subyte);
                                                if (wep2subyte != 0)
                                                {
                                                    if (wep2bs)
                                                        wep2subyte++;
                                                    attacker.Owner.IncreaseProficiencyExperience(Math.Min(damage, attacked.Hitpoints), wep2subyte);
                                                }
                                            }
                                            else
                                            {
                                                attacker.Owner.IncreaseProficiencyExperience(damage, wep1subyte);
                                                if (wep2subyte != 0)
                                                {
                                                    if (wep2bs)
                                                        wep2subyte++;
                                                    attacker.Owner.IncreaseProficiencyExperience(damage, wep2subyte);
                                                }
                                            }
                                    }
                                }
                                else
                                {
                                    if (!attacker.Transformed)
                                    {
                                        if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag != EntityFlag.Player)
                                            if (damage > attacked.Hitpoints)
                                            {
                                                attacker.Owner.IncreaseProficiencyExperience(Math.Min(damage, attacked.Hitpoints), 0);
                                            }
                                            else
                                            {
                                                attacker.Owner.IncreaseProficiencyExperience(damage, 0);
                                            }
                                    }
                                }
                                ReceiveAttack(attacker, attacked, attack, damage, null);
                                attack.AttackType = Attack.Melee;
                            }
                            else
                            {
                                attacker.AttackPacket = null;
                            }
                        }
                        else if (attacker.Owner.Screen.TryGetSob(attack.Attacked, out attackedsob))
                        {
                            if (CanAttack(attacker, attackedsob, null))
                            {
                                ushort range = attacker.AttackRange;
                                if (attacker.Transformed)
                                    range = (ushort)attacker.TransformationAttackRange;
                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= range)
                                {
                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                    if (!attacker.Owner.Equipment.Free((byte)ConquerItem.RightWeapon))
                                    {
                                        Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.RightWeapon);
                                        ushort wep1subyte = (ushort)(rightweapon.ID / 1000), wep2subyte = 0;
                                        bool wep1bs = false, wep2bs = false;
                                        if (wep1subyte == 421)
                                        {
                                            wep1bs = true;
                                            wep1subyte--;
                                        }
                                        ushort wep1spellid = 0, wep2spellid = 0;
                                        if (Database.SpellTable.WeaponSpells.ContainsKey(wep1subyte))
                                            wep1spellid = Database.SpellTable.WeaponSpells[wep1subyte];
                                        Database.SpellInformation wep1spell = null, wep2spell = null;
                                        bool doWep1Spell = false, doWep2Spell = false;
                                        if (attacker.Owner.Spells.ContainsKey(wep1spellid) && Database.SpellTable.SpellInformations.ContainsKey(wep1spellid))
                                        {
                                            wep1spell = Database.SpellTable.SpellInformations[wep1spellid][attacker.Owner.Spells[wep1spellid].Level];
                                            doWep1Spell = ServerBase.Kernel.Rate(wep1spell.Percent);
                                        }
                                        if (!doWep1Spell)
                                        {
                                            if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                                            {
                                                Interfaces.IConquerItem leftweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.LeftWeapon);
                                                wep2subyte = (ushort)(leftweapon.ID / 1000);
                                                if (wep2subyte == 421)
                                                {
                                                    wep2bs = true;
                                                    wep2subyte--;
                                                }
                                                if (Database.SpellTable.WeaponSpells.ContainsKey(wep2subyte))
                                                    wep2spellid = Database.SpellTable.WeaponSpells[wep2subyte];
                                                if (attacker.Owner.Spells.ContainsKey(wep2spellid) && Database.SpellTable.SpellInformations.ContainsKey(wep2spellid))
                                                {
                                                    wep2spell = Database.SpellTable.SpellInformations[wep2spellid][attacker.Owner.Spells[wep2spellid].Level];
                                                    doWep2Spell = ServerBase.Kernel.Rate(wep2spell.Percent);
                                                }
                                            }
                                        }

                                        if (!attacker.Transformed)
                                        {
                                            if (doWep1Spell)
                                            {
                                                attack.AttackType = Attack.Magic;
                                                attack.Decoded = true;
                                                attack.X = attackedsob.X;
                                                attack.Y = attackedsob.Y;
                                                attack.Attacked = attackedsob.UID;
                                                attack.Damage = wep1spell.ID;
                                                goto restart;
                                            }
                                            if (doWep2Spell)
                                            {
                                                attack.AttackType = Attack.Magic;
                                                attack.Decoded = true;
                                                attack.X = attackedsob.X;
                                                attack.Y = attackedsob.Y;
                                                attack.Attacked = attackedsob.UID;
                                                attack.Damage = wep2spell.ID;
                                                goto restart;
                                            }
                                            if (attacker.MapID == 1039)
                                            {
                                                if (wep1bs)
                                                    wep1subyte++;
                                                if (attacker.EntityFlag == EntityFlag.Player)
                                                    if (damage > attackedsob.Hitpoints)
                                                    {
                                                        attacker.Owner.IncreaseProficiencyExperience(Math.Min(damage, attackedsob.Hitpoints), wep1subyte);
                                                        if (wep2subyte != 0)
                                                        {
                                                            if (wep2bs)
                                                                wep2subyte++;
                                                            attacker.Owner.IncreaseProficiencyExperience(Math.Min(damage, attackedsob.Hitpoints), wep2subyte);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        attacker.Owner.IncreaseProficiencyExperience(damage, wep1subyte);
                                                        if (wep2subyte != 0)
                                                        {
                                                            if (wep2bs)
                                                                wep2subyte++;
                                                            attacker.Owner.IncreaseProficiencyExperience(damage, wep2subyte);
                                                        }
                                                    }
                                            }
                                        }
                                    }
                                    attack.Damage = damage;
                                    ReceiveAttack(attacker, attackedsob, attack, damage, null);
                                }
                                else
                                {
                                    attacker.AttackPacket = null;
                                }
                            }
                        }
                        else
                        {
                            attacker.AttackPacket = null;
                        }
                    }
                    #endregion
                    #region Ranged
                    else if (attack.AttackType == Attack.Ranged)
                    {
                        if (attacker.Owner.Screen.TryGetValue(attack.Attacked, out attacked))
                        {
                            CheckForExtraWeaponPowers(attacker.Owner, attacked);
                            if (attacker.Owner.Equipment.TryGetItem(ConquerItem.LeftWeapon) == null)
                                return;
                            if (!CanAttack(attacker, attacked, null, attack.AttackType == Attack.Melee))
                                return;
                            if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                            {
                                Interfaces.IConquerItem arrow = attacker.Owner.Equipment.TryGetItem(ConquerItem.LeftWeapon);
                                arrow.Durability -= 1;
                                ItemUsage usage = new ItemUsage(true) { UID = arrow.UID, dwParam = arrow.Durability, ID = ItemUsage.UpdateDurability };
                                usage.Send(attacker.Owner);
                                if (arrow.Durability <= 0 || arrow.Durability > 5000)
                                {
                                    Network.PacketHandler.ReloadArrows(attacker.Owner.Equipment.TryGetItem(ConquerItem.LeftWeapon), attacker.Owner);
                                }
                            }
                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= ServerBase.Constants.pScreenDistance)
                            {
                                uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked);
                                attack.Damage = damage;
                                if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag != EntityFlag.Player)
                                    if (damage > attacked.Hitpoints)
                                    {
                                        attacker.Owner.IncreaseProficiencyExperience(Math.Min(damage, attacked.Hitpoints), 500);
                                    }
                                    else
                                    {
                                        attacker.Owner.IncreaseProficiencyExperience(damage, 500);
                                    }
                                ReceiveAttack(attacker, attacked, attack, damage, null);
                            }
                        }
                        else if (attacker.Owner.Screen.TryGetSob(attack.Attacked, out attackedsob))
                        {
                            if (CanAttack(attacker, attackedsob, null))
                            {
                                if (attacker.Owner.Equipment.TryGetItem(ConquerItem.LeftWeapon) == null)
                                    return;
                                if (attacker.MapID != 1039)
                                {
                                    if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                                    {
                                        Interfaces.IConquerItem arrow = attacker.Owner.Equipment.TryGetItem(ConquerItem.LeftWeapon);
                                        arrow.Durability -= 1;
                                        ItemUsage usage = new ItemUsage(true) { UID = arrow.UID, dwParam = arrow.Durability, ID = ItemUsage.UpdateDurability };
                                        usage.Send(attacker.Owner);
                                        if (arrow.Durability <= 0 || arrow.Durability > 5000)
                                        {
                                            Network.PacketHandler.ReloadArrows(attacker.Owner.Equipment.TryGetItem(ConquerItem.LeftWeapon), attacker.Owner);
                                        }
                                    }
                                }
                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= ServerBase.Constants.pScreenDistance)
                                {
                                    uint damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);
                                    attack.Damage = damage;
                                    ReceiveAttack(attacker, attackedsob, attack, damage, null);
                                    if (damage > attackedsob.Hitpoints)
                                    {
                                        attacker.Owner.IncreaseProficiencyExperience(Math.Min(damage, attackedsob.Hitpoints), 500);
                                    }
                                    else
                                    {
                                        attacker.Owner.IncreaseProficiencyExperience(damage, 500);
                                    }
                                }
                            }
                        }
                        else
                        {
                            attacker.AttackPacket = null;
                        }
                    }
                    #endregion
                    #region Magic
                    else if (attack.AttackType == Attack.Magic)
                    {
                        CheckForExtraWeaponPowers(attacker.Owner, attacked);
                        uint Experience = 100;
                        bool shuriken = false;
                        ushort spellID = SpellID;
                        if (SpellID >= 3090 && SpellID <= 3306)
                            spellID = 3090;
                        if (spellID == 6012)
                            shuriken = true;

                        if (attacker == null)
                            return;
                        if (attacker.Owner == null)
                        {
                            attacker.AttackPacket = null;
                            return;
                        }
                        if (attacker.Owner.Spells == null)
                        {
                            attacker.Owner.Spells = new SafeDictionary<ushort, Conquer_Online_Server.Interfaces.ISkill>(10000);
                            attacker.AttackPacket = null;
                            return;
                        }
                        if (attacker.Owner.Spells[spellID] == null && spellID != 6012)
                        {
                            attacker.AttackPacket = null;
                            return;
                        }

                        Database.SpellInformation spell = null;
                        if (shuriken)
                            spell = Database.SpellTable.SpellInformations[6010][0];
                        else
                        {
                            byte choselevel = 0;
                            if (spellID == SpellID)
                                choselevel = attacker.Owner.Spells[spellID].Level;
                            if (Database.SpellTable.SpellInformations[SpellID] != null && !Database.SpellTable.SpellInformations[SpellID].ContainsKey(choselevel))
                                choselevel = (byte)(Database.SpellTable.SpellInformations[SpellID].Count - 1);

                            spell = Database.SpellTable.SpellInformations[SpellID][choselevel];
                        }
                        if (spell == null)
                        {
                            attacker.AttackPacket = null;
                            return;
                        }
                        attacked = null;
                        attackedsob = null;
                        if (attacker.Owner.Screen.TryGetValue(Target, out attacked) || attacker.Owner.Screen.TryGetSob(Target, out attackedsob) || Target == attacker.UID || spell.Sort != 1)
                        {
                            if (Target == attacker.UID)
                                attacked = attacker;
                            if (attacked != null)
                            {
                                if (attacked.Dead && spell.Sort != Database.SpellSort.Revive && spell.ID != 10405)
                                {
                                    attacker.AttackPacket = null;
                                    return;
                                }
                            }
                            if (Target >= 400000 && Target <= 600000 || Target >= 800000)
                            {
                                if (attacked == null && attackedsob == null)
                                    return;
                            }
                            else if (Target != 0 && attackedsob == null)
                                return;
                            if (attacked != null)
                            {
                                if (attacked.EntityFlag == EntityFlag.Monster)
                                {
                                    if (spell.CanKill)
                                    {
                                        if (attacked.MonsterInfo.InSight == 0)
                                        {
                                            attacked.MonsterInfo.InSight = attacker.UID;
                                        }
                                    }
                                }
                            }
                            if (!attacker.Owner.Spells.ContainsKey(spellID))
                            {
                                if (spellID != 6012)
                                    return;
                            }
                            if (spell != null)
                            {
                                if (spell.OnlyWithThisWeaponSubtype != 0)
                                {
                                    uint firstwepsubtype, secondwepsubtype;
                                    if (!attacker.Owner.Equipment.Free(4))
                                    {
                                        firstwepsubtype = attacker.Owner.Equipment.Objects[3].ID / 1000;
                                        if (!attacker.Owner.Equipment.Free(5) && attacker.Owner.Equipment.Objects[4] != null)
                                        {
                                            secondwepsubtype = attacker.Owner.Equipment.Objects[4].ID / 1000;
                                            if (firstwepsubtype != spell.OnlyWithThisWeaponSubtype)
                                            {
                                                if (secondwepsubtype != spell.OnlyWithThisWeaponSubtype)
                                                {
                                                    attacker.AttackPacket = null;
                                                    return;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (firstwepsubtype != spell.OnlyWithThisWeaponSubtype)
                                            {
                                                attacker.AttackPacket = null;
                                                return;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        attacker.AttackPacket = null;
                                        return;
                                    }
                                }
                            }
                          //  Buffers buff = new Buffers();

                            switch (spellID)
                            {
                                #region Single magic damage spells
                                case 1000:
                                case 1001:
                                case 1002:
                                case 1150:
                                case 1160:
                                case 1180:
                                case 1320:

                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            if (attacked != null)
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                        suse.Targets.Add(attacked.UID, damage);

                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                            attacked.Owner.SendScreen(suse, true);
                                                        else
                                                            attacked.MonsterInfo.SendScreen(suse);
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                            else
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);

                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                        suse.Targets.Add(attackedsob.UID, damage);

                                                        attacker.Owner.SendScreen(suse, true);
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            attacker.AttackPacket = null;
                                        }
                                        break;
                                    }
                                #endregion
                                #region Single heal/meditation spells
                                case 1190:
                                case 1195:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            uint damage = spell.Power;
                                            if (spell.ID == 1190)
                                            {
                                                Experience = damage = Math.Min(damage, attacker.MaxHitpoints - attacker.Hitpoints);
                                                attacker.Hitpoints += damage;
                                            }
                                            else
                                            {
                                                Experience = damage = Math.Min(damage, (uint)(attacker.MaxMana - attacker.Mana));
                                                attacker.Mana += (ushort)damage;
                                            }

                                            suse.Targets.Add(attacker.UID, spell.Power);

                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Multi heal spells
                                case 1005:
                                case 1055:
                                case 1170:
                                case 1175:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attackedsob != null)
                                            {
                                                if (attacker.MapID == 1038)
                                                    break;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);

                                                    uint damage = spell.Power;
                                                    damage = Math.Min(damage, attackedsob.MaxHitpoints - attackedsob.Hitpoints);
                                                    attackedsob.Hitpoints += damage;
                                                    Experience += damage;
                                                    suse.Targets.Add(attackedsob.UID, damage);

                                                    attacker.Owner.SendScreen(suse, true);
                                                }
                                            }
                                            else
                                            {
                                                if (spell.Multi)
                                                {
                                                    if (attacker.Owner.Team != null)
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                        {
                                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                            {
                                                                uint damage = spell.Power;
                                                                damage = Math.Min(damage, teammate.Entity.MaxHitpoints - teammate.Entity.Hitpoints);
                                                                teammate.Entity.Hitpoints += damage;
                                                                Experience += damage;
                                                                suse.Targets.Add(teammate.Entity.UID, damage);

                                                                if (spell.NextSpellID != 0)
                                                                {
                                                                    attack.Damage = spell.NextSpellID;
                                                                    attacker.AttackPacket = attack;
                                                                }
                                                                else
                                                                {
                                                                    attacker.AttackPacket = null;
                                                                }
                                                            }
                                                        }
                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                            attacked.Owner.SendScreen(suse, true);
                                                        else
                                                            attacked.MonsterInfo.SendScreen(suse);
                                                    }
                                                    else
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                        {
                                                            PrepareSpell(spell, attacker.Owner);

                                                            uint damage = spell.Power;
                                                            damage = Math.Min(damage, attacked.MaxHitpoints - attacked.Hitpoints);
                                                            attacked.Hitpoints += damage;
                                                            Experience += damage;
                                                            suse.Targets.Add(attacked.UID, damage);

                                                            if (spell.NextSpellID != 0)
                                                            {
                                                                attack.Damage = spell.NextSpellID;
                                                                attacker.AttackPacket = attack;
                                                            }
                                                            else
                                                            {
                                                                attacker.AttackPacket = null;
                                                            }
                                                            if (attacked.EntityFlag == EntityFlag.Player)
                                                                attacked.Owner.SendScreen(suse, true);
                                                            else
                                                                attacked.MonsterInfo.SendScreen(suse);
                                                        }
                                                        else
                                                        {
                                                            attacker.AttackPacket = null;
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);

                                                        uint damage = spell.Power;
                                                        damage = Math.Min(damage, attacked.MaxHitpoints - attacked.Hitpoints);
                                                        attacked.Hitpoints += damage;
                                                        Experience += damage;
                                                        suse.Targets.Add(attacked.UID, damage);

                                                        if (spell.NextSpellID != 0)
                                                        {
                                                            attack.Damage = spell.NextSpellID;
                                                            attacker.AttackPacket = attack;
                                                        }
                                                        else
                                                        {
                                                            attacker.AttackPacket = null;
                                                        }
                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                            attacked.Owner.SendScreen(suse, true);
                                                        else
                                                            attacked.MonsterInfo.SendScreen(suse);
                                                    }
                                                    else
                                                    {
                                                        attacker.AttackPacket = null;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            attacker.AttackPacket = null;
                                        }
                                        break;
                                    }
                                #endregion
                                #region Revive
                                case 1050:
                                case 1100:
                                    {
                                        if (attackedsob != null)
                                            return;
                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;

                                                suse.Targets.Add(attacked.UID, 0);

                                                attacked.Ressurect();

                                                attacked.Owner.SendScreen(suse, true);
                                            }
                                        }
                                        break;
                                    }
                                #endregion
                                #region Linear spells
                                case 1045:
                                case 11000:
                                case 11005:
                                case 1046:
                                case 1260:
                                case 11110:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);
                                            Game.Attacking.InLineAlgorithm ila = new Conquer_Online_Server.Game.Attacking.InLineAlgorithm(attacker.X,
                                        X, attacker.Y, Y, (byte)spell.Range, InLineAlgorithm.Algorithm.DDA);
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = SpellID;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                            {
                                                if (_obj == null)
                                                    continue;
                                                if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                {
                                                    attacked = _obj as Entity;
                                                    if (ila.InLine(attacked.X, attacked.Y))
                                                    {
                                                        if (!CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            continue;

                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);

                                                        attack.Damage = damage;

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                        suse.Targets.Add(attacked.UID, damage);
                                                    }
                                                }
                                                else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                {
                                                    attackedsob = _obj as SobNpcSpawn;

                                                    if (ila.InLine(attackedsob.X, attackedsob.Y))
                                                    {
                                                        if (!CanAttack(attacker, attackedsob, spell))
                                                            continue;

                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                        damage = (uint)(damage * spell.PowerPercent);
                                                        attack.Damage = damage;

                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                        suse.Targets.Add(attackedsob.UID, damage);
                                                    }
                                                }
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion

                                #region XPSpells inofensive
                                case 1015:
                                case 1020:
                                case 1025:
                                case 1110:
                                case 6011:

                                case 10390:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            suse.Targets.Add(attacked.UID, 0);

                                            if (spell.ID == 6011)
                                            {
                                                attacked.FatalStrikeStamp = Time32.Now;
                                                attacked.FatalStrikeTime = 60;
                                                attacked.AddFlag(Update.Flags.CannonBarrage);
                                            }

                                            else
                                            {
                                                if (spell.ID == 1110 || spell.ID == 1025 || spell.ID == 10390)
                                                {
                                                    if (!attacked.OnKOSpell())
                                                        attacked.KOCount = 0;

                                                    attacked.KOSpell = spell.ID;
                                                    if (spell.ID == 1110)
                                                    {
                                                        attacked.CycloneStamp = Time32.Now;
                                                        attacked.CycloneTime = 20;
                                                        attacked.AddFlag(Update.Flags.Cyclone);
                                                    }
                                                    else if (spell.ID == 10390)
                                                    {
                                                        attacked.OblivionStamp = Time32.Now;
                                                        attacked.OblivionTime = 20;
                                                        attacked.AddFlag2(Update.Flags2.Oblivion);
                                                    }
                                                    else
                                                    {
                                                        attacked.SupermanStamp = Time32.Now;
                                                        attacked.SupermanTime = 20;
                                                        attacked.AddFlag(Update.Flags.Superman);
                                                    }
                                                }
                                                else
                                                {
                                                    if (spell.ID == 1020)
                                                    {
                                                        attacked.ShieldTime = 0;
                                                        attacked.ShieldStamp = Time32.Now;
                                                        attacked.MagicShieldStamp = Time32.Now;
                                                        attacked.MagicShieldTime = 0;

                                                        attacked.AddFlag(Update.Flags.MagicShield);
                                                        attacked.ShieldStamp = Time32.Now;
                                                        attacked.ShieldIncrease = spell.PowerPercent;
                                                        attacked.ShieldTime = (byte)spell.Duration;
                                                    }
                                                    else
                                                    {
                                                        attacked.AccuracyStamp = Time32.Now;
                                                        attacked.StarOfAccuracyStamp = Time32.Now;
                                                        attacked.StarOfAccuracyTime = 0;
                                                        attacked.AccuracyTime = 0;

                                                        attacked.AddFlag(Update.Flags.StarOfAccuracy);
                                                        attacked.AccuracyStamp = Time32.Now;
                                                        attacked.AccuracyTime = (byte)spell.Duration;
                                                    }
                                                }
                                            }
                                            attacked.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Circle spells
                                case 1010:
                                case 1115:
                                case 1120:
                                case 1125:
                                case 3090:
                                case 5001:
                                case 8030:
                                case 11040:
                                case 11070:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                            {
                                                foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                                {
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attacked);

                                                                ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                                suse.Targets.Add(attacked.UID, damage);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);

                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Buffers
                                case 1075:
                                case 1085:
                                case 1090:
                                case 1095:
                                case 3080:

                                    {
                                        if (attackedsob != null)
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;

                                                suse.Targets.Add(attackedsob.UID, 0);

                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                        }
                                        else
                                        {
                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                            {
                                                if (CanUseSpell(spell, attacker.Owner))
                                                {
                                                    PrepareSpell(spell, attacker.Owner);

                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    suse.Targets.Add(attacked.UID, 0);

                                                    if (spell.ID == 1075 || spell.ID == 1085)
                                                    {
                                                        if (spell.ID == 1075)
                                                        {
                                                            attacked.AddFlag(Update.Flags.Invisibility);
                                                            attacked.InvisibilityStamp = Time32.Now;
                                                            attacked.InvisibilityTime = (byte)spell.Duration;
                                                            if (attacked.EntityFlag == EntityFlag.Player)
                                                                attacked.Owner.Send(ServerBase.Constants.Invisibility(spell.Duration));
                                                        }
                                                        else
                                                        {
                                                            attacked.AccuracyStamp = Time32.Now;
                                                            attacked.StarOfAccuracyStamp = Time32.Now;
                                                            attacked.StarOfAccuracyTime = 0;
                                                            attacked.AccuracyTime = 0;

                                                            attacked.AddFlag(Update.Flags.StarOfAccuracy);
                                                            attacked.StarOfAccuracyStamp = Time32.Now;
                                                            attacked.StarOfAccuracyTime = (byte)spell.Duration;
                                                            if (attacked.EntityFlag == EntityFlag.Player)
                                                                attacked.Owner.Send(ServerBase.Constants.Accuracy(spell.Duration));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (spell.ID == 1090)
                                                        {
                                                            attacked.ShieldTime = 0;
                                                            attacked.ShieldStamp = Time32.Now;
                                                            attacked.MagicShieldStamp = Time32.Now;
                                                            attacked.MagicShieldTime = 0;

                                                            attacked.AddFlag(Update.Flags.MagicShield);
                                                            attacked.MagicShieldStamp = Time32.Now;
                                                            attacked.MagicShieldIncrease = spell.PowerPercent;
                                                            attacked.MagicShieldTime = (byte)spell.Duration;
                                                            if (attacked.EntityFlag == EntityFlag.Player)
                                                                attacked.Owner.Send(ServerBase.Constants.Shield(spell.PowerPercent, spell.Duration));
                                                        }
                                                        else if (spell.ID == 1095)
                                                        {
                                                            attacked.AddFlag(Update.Flags.Stigma);
                                                            attacked.StigmaStamp = Time32.Now;
                                                            attacked.StigmaIncrease = spell.PowerPercent;
                                                            attacked.StigmaTime = (byte)spell.Duration;
                                                            if (attacked.EntityFlag == EntityFlag.Player)
                                                                attacked.Owner.Send(ServerBase.Constants.Stigma(spell.PowerPercent, spell.Duration));
                                                        }
                                                        else
                                                        {
                                                            attacked.AddFlag(Update.Flags.Dodge);
                                                            attacked.DodgeStamp = Time32.Now;
                                                            attacked.DodgeIncrease = spell.PowerPercent;
                                                            attacked.DodgeTime = (byte)spell.Duration;
                                                            if (attacked.EntityFlag == EntityFlag.Player)
                                                                attacked.Owner.Send(ServerBase.Constants.Dodge(spell.PowerPercent, spell.Duration));
                                                        }

                                                    }

                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                #endregion
                                #region Percent
                                case 3050:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            if (attackedsob != null)
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Percent(attackedsob, spell.PowerPercent);

                                                        attackedsob.Hitpoints -= damage;

                                                        suse.Targets.Add(attackedsob.UID, damage);

                                                        attacker.Owner.SendScreen(suse, true);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Percent(attacked, spell.PowerPercent);

                                                        if (attacker.Owner.QualifierGroup != null)
                                                            attacker.Owner.QualifierGroup.UpdateDamage(attacker.Owner, damage);

                                                        attacked.Hitpoints -= damage;

                                                        suse.Targets.Add(attacked.UID, damage);

                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                            attacked.Owner.SendScreen(suse, true);
                                                        else
                                                            attacked.MonsterInfo.SendScreen(suse);
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                #endregion
                                #region ExtraXP
                                case 1040:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (teammate.Entity.UID != attacker.UID)
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        {
                                                            teammate.XPCount += 20;
                                                            Update update = new Update(true);
                                                            update.UID = teammate.Entity.UID;
                                                            update.Append(Update.XPCircle, teammate.XPCount);
                                                            update.Send(teammate);
                                                            suse.Targets.Add(teammate.Entity.UID, 20);

                                                            if (spell.NextSpellID != 0)
                                                            {
                                                                attack.Damage = spell.NextSpellID;
                                                                attacker.AttackPacket = attack;
                                                            }
                                                            else
                                                            {
                                                                attacker.AttackPacket = null;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            if (attacked.EntityFlag == EntityFlag.Player)
                                                attacked.Owner.SendScreen(suse, true);
                                            else
                                                attacked.MonsterInfo.SendScreen(suse);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Pure Skills
                                //SoulShackle
                                case 10405:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            if (attacked == null) return;
                                            if (attacked.EntityFlag == EntityFlag.Monster)
                                                return;
                                            if (attacked.UID == attacker.UID)
                                                return;
                                            if (!attacked.Dead)
                                                return;

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = SpellID;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (attacked.BattlePower > attacker.BattlePower)
                                            {
                                                int diff = attacked.BattlePower - attacker.BattlePower;
                                                if (ServerBase.Kernel.Rate(100 - diff * 5))
                                                {
                                                    attacked.ShackleStamp = Time32.Now;
                                                    attacked.ShackleTime = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    attacked.AddFlag(Update.Flags.SoulShackle);
                                                    attacked.Owner.SendScreen(suse, true);
                                                }
                                            }
                                            else
                                            {
                                                attacked.ShackleStamp = Time32.Now;
                                                attacked.ShackleTime = (short)spell.Duration;
                                                suse.Targets.Add(attacked.UID, 1);
                                                attacked.AddFlag(Update.Flags.SoulShackle);
                                                attacked.Owner.SendScreen(suse, true);
                                            }
                                        }
                                        break;
                                    }
                                //AzureShield
                                case 30000:
                                    {
                                        if (attacked == null)
                                            return;
                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;

                                                suse.Targets.Add(attacked.UID, 0);
                                                attacked.Owner.SendScreen(suse, true);
                                                attacked.AzureStamp = Time32.Now;
                                                attacked.AzureTime = (short)spell.Duration;
                                                attacked.AzureDamage = spell.Power;
                                                attacked.AddFlag(Update.Flags.AzureShield);
                                            }
                                        }
                                        break;
                                    }
                                //HeavenBlade
                                case 10310:
                                    {
                                        if (attacked == null)
                                            return;
                                        spell.UseStamina = 100;
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            if (attacked != null)
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);
                                                        if (ServerBase.Kernel.Rate(spell.Percent))
                                                        {
                                                            damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);

                                                            suse.Targets.Add(attacked.UID, damage);
                                                        }
                                                        else
                                                        {
                                                            damage = 0;
                                                            suse.Targets.Add(attacked.UID, damage);
                                                        }

                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                            attacked.Owner.SendScreen(suse, true);
                                                        else
                                                            attacked.MonsterInfo.SendScreen(suse);
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                            else
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);
                                                        if (ServerBase.Kernel.Rate(spell.Percent))
                                                        {
                                                            ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                            suse.Targets.Add(attackedsob.UID, damage);
                                                        }
                                                        else
                                                        {
                                                            damage = 0;
                                                            suse.Targets.Add(attackedsob.UID, damage);
                                                        }

                                                        attacker.Owner.SendScreen(suse, true);
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            attacker.AttackPacket = null;
                                        }
                                        break;
                                    }
                                //StarArrow
                                case 10313:
                                    {
                                        spell.UseStamina = 50;
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            if (attacked != null)
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = attacked.X;
                                                    suse.Y = attacked.Y;

                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked, spell);

                                                        damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);

                                                        suse.Targets.Add(attacked.UID, damage);

                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                            attacked.Owner.SendScreen(suse, true);
                                                        else
                                                            attacked.MonsterInfo.SendScreen(suse);
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                            else
                                            {
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Distance)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;

                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);

                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                        suse.Targets.Add(attackedsob.UID, damage);

                                                        attacker.Owner.SendScreen(suse, true);
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            attacker.AttackPacket = null;
                                        }
                                        break;
                                    }
                                //DragonWhirl
                                #region DragonWhirl
                                case 10315:
                                    {
                                        if (attacker.Stamina >= 30)
                                        {
                                            attacker.Stamina -= 30;
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;

                                                attack.X = X;
                                                attack.Y = Y;
                                                attack.Attacker = attacker.UID;
                                                attack.AttackType = 53;
                                                attack.X = X;
                                                attack.Y = Y;
                                                Writer.WriteUInt16(spell.ID, 24, attack.ToArray());
                                                Writer.WriteByte(spell.Level, 26, attack.ToArray());
                                                attacker.Owner.SendScreen(attack, true);
                                                attacker.X = X;
                                                attacker.Y = Y;

                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                                {
                                                    foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                                    {
                                                        if (_obj == null)
                                                            continue;
                                                        if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                        {
                                                            attacked = _obj as Entity;
                                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                            {
                                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                {
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                                                    uint DamageAdd = (damage * 150) / 100;
                                                                    if (spell.Power > 0)
                                                                        damage = (uint)(DamageAdd + Game.Attacking.Calculate.Magic(attacker, attacked, spell));

                                                                    ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                                    suse.Targets.Add(attacked.UID, damage);

                                                                }
                                                            }
                                                        }
                                                        else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                        {
                                                            attackedsob = _obj as SobNpcSpawn;
                                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Distance)
                                                            {
                                                                if (CanAttack(attacker, attackedsob, spell))
                                                                {
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                    uint DamageAdd = (damage * 150) / 100;
                                                                    if (spell.Power > 0)
                                                                        damage = (uint)(DamageAdd + Game.Attacking.Calculate.Magic(attacker, attacked, spell));

                                                                    ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                                    suse.Targets.Add(attackedsob.UID, damage);

                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                        }
                                        break;
                                    }
                                #endregion
                                #endregion

                                #region WeaponSpells
                                #region Circle
                                case 5010:
                                case 7020:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            if (suse.SpellID != 10415)
                                            {
                                                suse.X = X;
                                                suse.Y = Y;
                                            }
                                            else
                                            {
                                                suse.X = 6;
                                            }
                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= attacker.AttackRange + 1)
                                            {
                                                foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                                {
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                PrepareSpell(spell, attacker.Owner);
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);

                                                                ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                                suse.Targets.Add(attacked.UID, damage);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                PrepareSpell(spell, attacker.Owner);
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                damage = (uint)(damage * spell.PowerPercent);
                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }

                                        break;
                                    }
                                #endregion
                                #region Single target
                                case 10490:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            TryTrip suse = new TryTrip(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= attacker.AttackRange + 1)
                                            {
                                                if (attackedsob != null)
                                                {
                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                        damage = (uint)(damage * spell.PowerPercent);
                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                        suse.Damage = damage;
                                                        suse.Attacked = attackedsob.UID;
                                                    }
                                                }
                                                else
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);
                                                        suse.Damage = damage;
                                                        suse.Attacked = attacked.UID;
                                                    }
                                                }
                                                attacker.AttackPacket = null;
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                case 1290:
                                case 5030:
                                case 5040:
                                case 7000:
                                case 7010:
                                case 7030:
                                case 7040:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= attacker.AttackRange)
                                            {
                                                if (attackedsob != null)
                                                {
                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                        damage = (uint)(damage * spell.PowerPercent);
                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                        suse.Targets.Add(attackedsob.UID, damage);
                                                    }
                                                }
                                                else
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                        suse.Targets.Add(attacked.UID, damage);
                                                    }
                                                }
                                                attacker.AttackPacket = null;
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                #endregion
                                #region Sector
                                case 1250:
                                case 5050:
                                case 5020:
                                case 1300:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            Sector sector = new Sector(attacker.X, attacker.Y, X, Y);
                                            sector.Arrange(spell.Sector, spell.Range);
                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Distance + 1)
                                            {
                                                foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                                {
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;

                                                        if (sector.Inside(attacked.X, attacked.Y))
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);

                                                                ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                                suse.Targets.Add(attacked.UID, damage);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;

                                                        if (sector.Inside(attackedsob.X, attackedsob.Y))
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                damage = (uint)(damage * spell.PowerPercent);
                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #endregion
                                #region Fly
                                case 8002:
                                case 8003:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            attacked.FlyStamp = Time32.Now;
                                            attacked.FlyTime = (byte)spell.Duration;

                                            suse.Targets.Add(attacked.UID, attacked.FlyTime);
                                            attacked.RemoveFlag(Update.Flags.Ride);
                                            attacked.AddFlag(Update.Flags.Fly);

                                            attacked.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Ninja Spells
                                case 6010://Vortex
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            attacker.AddFlag(Update.Flags.ShurikenVortex);
                                            attacker.ShurikenVortexStamp = Time32.Now;
                                            attacker.ShurikenVortexTime = 20;

                                            attacker.Owner.SendScreen(suse, true);

                                            attacker.VortexPacket = new Attack(true);
                                            attacker.VortexPacket.Decoded = true;
                                            attacker.VortexPacket.Damage = 6012;
                                            attacker.VortexPacket.AttackType = Attack.Magic;
                                            attacker.VortexPacket.Attacker = attacker.UID;
                                        }
                                        break;
                                    }
                                case 6012://VortexRespone
                                    {
                                        if (!attacker.ContainsFlag(Update.Flags.ShurikenVortex))
                                        {
                                            attacker.AttackPacket = null;
                                            break;
                                        }
                                        SpellUse suse = new SpellUse(true);
                                        suse.Attacker = attacker.UID;
                                        suse.SpellID = spell.ID;
                                        suse.SpellLevel = spell.Level;
                                        suse.X = attacker.X;
                                        suse.Y = attacker.Y;
                                        foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                        {
                                            if (_obj == null)
                                                continue;
                                            if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                            {
                                                attacked = _obj as Entity;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                        suse.Targets.Add(attacked.UID, damage);
                                                    }
                                                }
                                            }
                                            else if (_obj.MapObjType == MapObjectType.SobNpc)
                                            {
                                                attackedsob = _obj as SobNpcSpawn;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                {
                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);

                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                        suse.Targets.Add(attackedsob.UID, damage);
                                                    }
                                                }
                                            }
                                        }
                                        attacker.Owner.SendScreen(suse, true);
                                        break;
                                    }
                                case 6001:
                                    {

                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Distance)
                                            {

                                                foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                                {
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(X, Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (attacked.Name == "TeratoDragon")//SnowBanshee
                                                                continue;
                                                            if (attacked.Name == "SnowBanshee")//SnowBanshee
                                                                continue;
                                                            if (attacked.Name == "ThrillingSpook")//SnowBanshee
                                                                continue;
                                                            if (attacked.Name == "SwordMaster")//SnowBanshee
                                                                continue;
                                                            if (attacked.Name == "LavaBeast")//SnowBanshee
                                                                continue;
                                                            if (attacked.Name == "Guard1")//SnowBanshee
                                                                continue;
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                int potDifference = attacker.BattlePower - attacked.BattlePower;

                                                                int rate = spell.Percent + potDifference;
                                                                // uint dmg = (uint)((attacked.Hitpoints * ((10))) / 100);
                                                                if (attacked.Statistics.Detoxication > 0 && attacked.Statistics.Detoxication < 100)
                                                                    rate = (int)((rate * attacked.Statistics.Detoxication) / 100);
                                                                if (attacked.Statistics.Detoxication >= 100)
                                                                    rate = 0;
                                                                if (ServerBase.Kernel.Rate(rate))
                                                                {
                                                                    attacked.ToxicFogStamp = Time32.Now;
                                                                    attacked.ToxicFogLeft = 20;
                                                                    attacked.ToxicFogPercent = spell.PowerPercent;
                                                                    suse.Targets.Add(attacked.UID, 1);

                                                                }
                                                                else
                                                                {
                                                                    suse.Targets.Add(attacked.UID, 0);
                                                                    suse.Targets[attacked.UID].Hit = false;
                                                                }
                                                                if (attacked.Hitpoints <= 1)
                                                                {
                                                                    //client.Entity.Poison = null;
                                                                    suse.Targets.Add(attacked.UID, 0);
                                                                    suse.Targets[attacked.UID].Hit = false;
                                                                    //attacked.Update(true, false, true, Game.Enums.Poison);

                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                case 6000:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            ushort Xx, Yx;
                                            if (attacked != null)
                                            {
                                                Xx = attacked.X;
                                                Yx = attacked.Y;
                                            }
                                            else
                                            {
                                                Xx = attackedsob.X;
                                                Yx = attackedsob.Y;
                                            }
                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, Xx, Yx) <= spell.Range)
                                            {
                                                if (attackedsob == null)
                                                    if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                        return;
                                                if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                    return;
                                                if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                    return;
                                                PrepareSpell(spell, attacker.Owner);

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;

                                                bool send = false;

                                                if (attackedsob == null)
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                        suse.Targets.Add(attacked.UID, damage);
                                                        send = true;
                                                    }
                                                }
                                                else
                                                {
                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                        damage = (uint)(damage * spell.PowerPercent);
                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                        suse.Targets.Add(attackedsob.UID, damage);
                                                        send = true;
                                                    }
                                                }
                                                if (send)
                                                    attacker.Owner.SendScreen(suse, true);
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                        }
                                        break;
                                    }
                                case 6002:
                                    {
                                        if (attackedsob != null)
                                            return;
                                        if (attacked.EntityFlag == EntityFlag.Monster)
                                            return;
                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);

                                                int potDifference = attacker.BattlePower - attacked.BattlePower;

                                                int rate = spell.Percent + potDifference;

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                if (CanAttack(attacker, attacked, spell, false))
                                                {
                                                    suse.Targets.Add(attacked.UID, 0);
                                                    if (ServerBase.Kernel.Rate(rate))
                                                    {
                                                        attacked.NoDrugsStamp = Time32.Now;
                                                        attacked.NoDrugsTime = (short)spell.Duration;
                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                        {
                                                            attacked.Owner.Send(ServerBase.Constants.NoDrugs(spell.Duration));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        suse.Targets[attacked.UID].Hit = false;
                                                    }

                                                    attacked.Owner.SendScreen(suse, true);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case 6004:
                                    {
                                        if (attackedsob != null)
                                            return;
                                        if (attacked.EntityFlag == EntityFlag.Monster)
                                            return;
                                        if (!attacked.ContainsFlag(Update.Flags.Fly))
                                            return;
                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);

                                                int potDifference = attacker.BattlePower - attacked.BattlePower;

                                                int rate = spell.Percent + potDifference;

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                if (CanAttack(attacker, attacked, spell, false))
                                                {
                                                    uint dmg = Calculate.Percent(attacked, 0.1F);
                                                    suse.Targets.Add(attacked.UID, dmg);

                                                    if (ServerBase.Kernel.Rate(rate))
                                                    {
                                                        attacked.Hitpoints -= dmg;
                                                        attacked.RemoveFlag(Update.Flags.Fly);
                                                    }
                                                    else
                                                    {
                                                        suse.Targets[attacked.UID].Hit = false;
                                                    }

                                                    attacked.Owner.SendScreen(suse, true);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                #endregion
                                #region Riding
                                case 7001:
                                    {
                                        if (!attacker.Owner.Equipment.Free(12))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (attacker.ContainsFlag(Update.Flags.Ride))
                                            {
                                                attacker.RemoveFlag(Update.Flags.Ride);
                                            }
                                            else
                                            {
                                                if (attacker.Owner.Map.ID == 1036 && attacker.Owner.Equipment.TryGetItem((byte)12).Plus < 6)
                                                    break;
                                                if (attacker.Stamina >= 100 && (attacker.Owner.QualifierGroup == null || attacker.Owner.QualifierGroup != null && !attacker.Owner.QualifierGroup.Inside))
                                                {
                                                    attacker.AddFlag(Update.Flags.Ride);
                                                    attacker.Stamina -= 100;
                                                    Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
                                                    vigor.VigorValue = attacker.Owner.Entity.MaxVigor;
                                                    vigor.Send(attacker.Owner);
                                                }
                                            }
                                            suse.Targets.Add(attacker.UID, 0);
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                case 7002:
                                    {//Spook
                                        if (attacked.ContainsFlag(Update.Flags.Ride) && attacker.ContainsFlag(Update.Flags.Ride))
                                        {
                                            Interfaces.IConquerItem attackedSteed = null, attackerSteed = null;
                                            if ((attackedSteed = attacked.Owner.Equipment.TryGetItem(ConquerItem.Steed)) != null)
                                            {
                                                if ((attackerSteed = attacker.Owner.Equipment.TryGetItem(ConquerItem.Steed)) != null)
                                                {
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = X;
                                                    suse.Y = Y;
                                                    suse.Targets.Add(attacked.UID, 0);

                                                    if (attackedSteed.Plus < attackerSteed.Plus)
                                                        attacked.RemoveFlag(Update.Flags.Ride);
                                                    else if (attackedSteed.Plus == attackerSteed.Plus && attackedSteed.PlusProgress <= attackerSteed.PlusProgress)
                                                        attacked.RemoveFlag(Update.Flags.Ride);
                                                    else
                                                        suse.Targets[attacked.UID].Hit = false;
                                                    attacker.Owner.SendScreen(suse, true);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case 7003:
                                    {//WarCry
                                        SpellUse suse = new SpellUse(true);
                                        suse.Attacker = attacker.UID;
                                        suse.SpellID = spell.ID;
                                        suse.SpellLevel = spell.Level;
                                        suse.X = X;
                                        suse.Y = Y;
                                        Interfaces.IConquerItem attackedSteed = null, attackerSteed = null;
                                        foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                        {
                                            if (_obj == null)
                                                continue;
                                            if (_obj.MapObjType == MapObjectType.Player && _obj.UID != attacker.UID)
                                            {
                                                attacked = _obj as Entity;
                                                if ((attackedSteed = attacked.Owner.Equipment.TryGetItem(ConquerItem.Steed)) != null)
                                                {
                                                    if ((attackerSteed = attacker.Owner.Equipment.TryGetItem(ConquerItem.Steed)) != null)
                                                    {
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= attackedSteed.Plus)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                suse.Targets.Add(attacked.UID, 0);
                                                                if (attackedSteed.Plus < attackerSteed.Plus)
                                                                    attacked.RemoveFlag(Update.Flags.Ride);
                                                                else if (attackedSteed.Plus == attackerSteed.Plus && attackedSteed.PlusProgress <= attackerSteed.PlusProgress)
                                                                    attacked.RemoveFlag(Update.Flags.Ride);
                                                                else
                                                                    suse.Targets[attacked.UID].Hit = false;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        attacker.Owner.SendScreen(suse, true);
                                        break;
                                    }
                                #endregion
                                #region Dash
                                case 1051:
                                    {
                                        if (attacked != null)
                                        {
                                            if (!attacked.Dead)
                                            {
                                                var direction = ServerBase.Kernel.GetAngle(attacker.X, attacker.Y, attacked.X, attacked.Y);
                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                {
                                                    uint damage = Calculate.Melee(attacker, attacked);
                                                    attack = new Attack(true);
                                                    attack.AttackType = Attack.Dash;
                                                    attack.X = attacked.X;
                                                    attack.Y = attacked.Y;
                                                    attack.Attacker = attacker.UID;
                                                    attack.Attacked = attacked.UID;
                                                    attack.Damage = damage;
                                                    attack.ToArray()[27] = (byte)direction;
                                                    attacked.Move(direction);
                                                    attacker.Move(direction);

                                                    ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                    attacker.Owner.SendScreen(attack, true);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                #endregion
                                #region RapidFire
                                case 8000:
                                    {
                                        if (attackedsob != null)
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                if (CanAttack(attacker, attackedsob, spell))
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    SpellUse suse = new SpellUse(true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = spell.ID;
                                                    suse.SpellLevel = spell.Level;
                                                    suse.X = attackedsob.X;
                                                    suse.Y = attackedsob.Y;
                                                    uint damage = Calculate.Ranged(attacker, attackedsob);
                                                    damage = (uint)(damage * spell.PowerPercent);
                                                    suse.Targets.Add(attackedsob.UID, damage);

                                                    ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                    attacker.Owner.SendScreen(suse, true);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (!attacked.Dead)
                                            {
                                                if (CanUseSpell(spell, attacker.Owner))
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        SpellUse suse = new SpellUse(true);
                                                        suse.Attacker = attacker.UID;
                                                        suse.SpellID = spell.ID;
                                                        suse.SpellLevel = spell.Level;
                                                        suse.X = attacked.X;
                                                        suse.Y = attacked.Y;
                                                        uint damage = Calculate.Ranged(attacker, attacked);
                                                        damage = (uint)(damage * spell.PowerPercent);
                                                        suse.Targets.Add(attacked.UID, damage);

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                        attacker.Owner.SendScreen(suse, true);
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                #endregion
                                #region FireOfHell
                                case 1165:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            Sector sector = new Sector(attacker.X, attacker.Y, X, Y);
                                            sector.Arrange(spell.Sector, spell.Distance);
                                            foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                            {
                                                if (_obj == null)
                                                    continue;
                                                if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                {
                                                    attacked = _obj as Entity;

                                                    if (sector.Inside(attacked.X, attacked.Y))
                                                    {
                                                        if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);

                                                            ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                            suse.Targets.Add(attacked.UID, damage);
                                                        }
                                                    }
                                                }
                                                else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                {
                                                    attackedsob = _obj as SobNpcSpawn;

                                                    if (sector.Inside(attackedsob.X, attackedsob.Y))
                                                    {
                                                        if (CanAttack(attacker, attackedsob, spell))
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);

                                                            ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                            suse.Targets.Add(attackedsob.UID, damage);
                                                        }
                                                    }
                                                }
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Scatter
                                case 8001:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            Sector sector = new Sector(attacker.X, attacker.Y, X, Y);
                                            sector.Arrange(spell.Sector, spell.Distance);
                                            foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                            {
                                                if (_obj == null)
                                                    continue;
                                                if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                {
                                                    attacked = _obj as Entity;

                                                    if (sector.Inside(attacked.X, attacked.Y))
                                                    {
                                                        if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked, spell);

                                                            ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                            suse.Targets.Add(attacked.UID, damage);
                                                        }
                                                    }
                                                }
                                                else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                {
                                                    attackedsob = _obj as SobNpcSpawn;

                                                    if (sector.Inside(attackedsob.X, attackedsob.Y))
                                                    {
                                                        if (CanAttack(attacker, attackedsob, spell))
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);
                                                            if (damage == 0)
                                                                damage = 1;
                                                            damage = Game.Attacking.Calculate.Percent((int)damage, spell.PowerPercent);

                                                            ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                            suse.Targets.Add(attackedsob.UID, damage);
                                                        }
                                                    }
                                                }
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Intensify
                                case 9000:
                                    {
                                        attacker.IntensifyStamp = Time32.Now;
                                        attacker.OnIntensify = true;
                                        SpellUse suse = new SpellUse(true);
                                        suse.Attacker = attacker.UID;
                                        suse.SpellID = spell.ID;
                                        suse.SpellLevel = spell.Level;
                                        suse.X = X;
                                        suse.Y = Y;
                                        suse.Targets.Add(attacker.UID, 0);
                                        suse.Send(attacker.Owner);
                                        break;
                                    }
                                #endregion

                                #region Pirate Spells

                                #region Xp Skills
                                case 11050: //Cannon Barrage
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            attacker.CannonBarageStamp = Time32.Now;
                                            attacker.Cannonbarage = 30;
                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                            {
                                                for (int c = 0; c < attacker.Owner.Screen.Objects.Count(); c++)
                                                {
                                                    //For a multi threaded application, while we go through the collection
                                                    //the collection might change. We will make sure that we wont go off
                                                    //the limits with a check.
                                                    if (c >= attacker.Owner.Screen.Objects.Count())
                                                        break;
                                                    Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attacked);
                                                                damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                                suse.Targets.Add(attacked.UID, damage);
                                                                //attacked.AddFlag(Update.Effects.CannonBarrage);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);
                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                                //attacked.AddFlag(Update.Effects.CannonBarrage);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                case 11060: // BlackPearl Rage
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            attacker.BlackBeardStamp = Time32.Now;
                                            attacker.Blackbeard = 30;
                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                            {
                                                for (int c = 0; c < attacker.Owner.Screen.Objects.Count(); c++)
                                                {
                                                    //For a multi threaded application, while we go through the collection
                                                    //the collection might change. We will make sure that we wont go off
                                                    //the limits with a check.
                                                    if (c >= attacker.Owner.Screen.Objects.Count())
                                                        break;
                                                    Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attacked);
                                                                damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                                suse.Targets.Add(attacked.UID, damage);
                                                                attacked.AddFlag(Update.Effects.EagleEye);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);
                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                                attacked.AddFlag(Update.Effects.EagleEye);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion

                                #region Auto On Skills
                                case 11120: //Adrenaline Rush
                                case 11130: //BlackSpot
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= attacker.AttackRange + 1)
                                            {
                                                if (attackedsob != null)
                                                {
                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        suse.MakeConst();
                                                        for (uint c = 0; c < 3; c++)
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                            if (damage > attackedsob.Hitpoints)
                                                                damage = attackedsob.Hitpoints;

                                                            ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                            suse.Targets.Add(attackedsob.UID + c, damage);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        suse.MakeConst();
                                                        for (uint c = 0; c < 3; c++)
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);
                                                            if (damage > attacked.Hitpoints)
                                                                damage = attacked.Hitpoints;
                                                            damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);

                                                            suse.Targets.Add(attacked.UID + c, damage);
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion // Doesnt Work // Doest Work

                                #region WeaponSkills
                                case 11140: //windstorm
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= attacker.AttackRange + 1)
                                            {
                                                if (attackedsob != null)
                                                {
                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        suse.MakeConst();
                                                        for (uint c = 0; c < 3; c++)
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                            if (damage > attackedsob.Hitpoints)
                                                                damage = attackedsob.Hitpoints;

                                                            ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                            suse.Targets.Add(attackedsob.UID + c, damage);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        suse.MakeConst();
                                                        for (uint c = 0; c < 3; c++)
                                                        {
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);
                                                            if (damage > attacked.Hitpoints)
                                                                damage = attacked.Hitpoints;
                                                            damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);

                                                            suse.Targets.Add(attacked.UID + c, damage);
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                #endregion // Doesnt Work

                                #region Linear Skills
                                /*case 11110: //Blade Tempest
                                    {
                                        if (Time32.Now < attacker.WhilrwindKick.AddMilliseconds(1500))
                                            return;
                                        attacker.WhilrwindKick = Time32.Now;
                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)//<= 3
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                //suse.X = (ushort)ServerBase.Kernel.Random.Next(3, 10);
                                                suse.X = X;
                                                //suse.Y = 0;
                                                suse.Y = Y;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                                {
                                                    for (int c = 0; c < attacker.Owner.Screen.Objects.Count(); c++)
                                                    {
                                                        //For a multi threaded application, while we go through the collection
                                                        //the collection might change. We will make sure that we wont go off
                                                        //the limits with a check.
                                                        if (c >= attacker.Owner.Screen.Objects.Count())
                                                            break;
                                                        Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                        if (_obj == null)
                                                            continue;
                                                        if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                        {
                                                            attacked = _obj as Entity;
                                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                            {
                                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Ranged))
                                                                {
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);

                                                                    damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                                    attacked.Stunned = true;
                                                                    attacked.StunStamp = Time32.Now;
                                                                    suse.Targets.Add(attacked.UID, damage);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                        }
                                        break;
                                    }*/
                                #endregion

                                #region Single damage Skill
                                case 11030: // Eagle Eye
                                    if (CanUseSpell(spell, attacker.Owner))
                                    {
                                        PrepareSpell(spell, attacker.Owner);

                                        SpellUse suse = new SpellUse(true);
                                        suse.Attacker = attacker.UID;
                                        suse.SpellID = spell.ID;
                                        suse.SpellLevel = spell.Level;
                                        suse.X = X;
                                        suse.Y = Y;
                                        suse.Targets.Add(attacker.UID, spell.Power);
                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Distance)
                                        {
                                            if (attackedsob != null)
                                            {
                                                if (CanAttack(attacker, attackedsob, spell))
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                    damage = (uint)(damage * spell.PowerPercent * 30);
                                                    ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                    suse.Targets.Add(attackedsob.UID, damage);
                                                }
                                            }
                                            else
                                            {
                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);
                                                    damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                    suse.Targets.Add(attacked.UID, damage);
                                                    attacked.AddFlag(Update.Effects.EagleEye);
                                                }
                                            }
                                        }
                                        attacker.Owner.SendScreen(suse, true);
                                    }
                                    break;
                                #endregion

                                #region Region Damage Skills
                                case 11100: //kracken revenge
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                            {
                                                for (int c = 0; c < attacker.Owner.Screen.Objects.Count(); c++)
                                                {
                                                    //For a multi threaded application, while we go through the collection
                                                    //the collection might change. We will make sure that we wont go off
                                                    //the limits with a check.
                                                    if (c >= attacker.Owner.Screen.Objects.Count())
                                                        break;
                                                    Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attacked);
                                                                damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                                suse.Targets.Add(attacked.UID, damage);
                                                                attacked.AddFlag(Update.Effects.KrackenRevenge);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);
                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                                attacked.AddFlag(Update.Effects.KrackenRevenge);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
                                /*case 11040: // Scurvey Bomb
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                            {
                                                for (int c = 0; c < attacker.Owner.Screen.Objects.Count(); c++)
                                                {
                                                    //For a multi threaded application, while we go through the collection
                                                    //the collection might change. We will make sure that we wont go off
                                                    //the limits with a check.
                                                    if (c >= attacker.Owner.Screen.Objects.Count())
                                                        break;
                                                    Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attacked);
                                                                damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                                suse.Targets.Add(attacked.UID, damage);
                                                                attacked.Update(_String.Effect, "pro_gre_assflo", true);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);
                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                                //attacked.Update(_String.Effect, "pro_gre_assflo", true);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }*/
                               /* case 11070: // Gale Bomb
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                            {
                                                for (int c = 0; c < attacker.Owner.Screen.Objects.Count(); c++)
                                                {
                                                    //For a multi threaded application, while we go through the collection
                                                    //the collection might change. We will make sure that we wont go off
                                                    //the limits with a check.
                                                    if (c >= attacker.Owner.Screen.Objects.Count())
                                                        break;
                                                    Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                    if (_obj == null)
                                                        continue;
                                                    if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        attacked = _obj as Entity;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attacked);
                                                                damage = ReceiveAttack(suse, attacker, attacked, attack, damage, spell);
                                                                suse.Targets.Add(attacked.UID, damage);
                                                                attacked.Update(_String.Effect, "pro_tir_assflo", true);
                                                            }
                                                        }
                                                    }
                                                    else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                    {
                                                        attackedsob = _obj as SobNpcSpawn;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attackedsob, spell))
                                                            {
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                                if (spell.Power > 0)
                                                                    damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell);
                                                                if (spell.ID == 8030)
                                                                    damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob);
                                                                ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                                attacked.Update(_String.Effect, "pro_tir_assflo", true);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }*/
                                #endregion

                                #endregion

                                #region Trasnformations
                                case 1270:
                                case 1280:
                                case 1350:
                                case 1360:
                                case 3321:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            if (attacker.MapID == 1036)
                                                return;
                                            bool wasTransformated = attacker.Transformed;
                                            PrepareSpell(spell, attacker.Owner);

                                            #region Atributes
                                            switch (spell.ID)
                                            {
                                                case 1350:
                                                    switch (spell.Level)
                                                    {
                                                        case 0:
                                                            {
                                                                attacker.TransformationMaxAttack = 182;
                                                                attacker.TransformationMinAttack = 122;
                                                                attacker.TransformationDefence = 1300;
                                                                attacker.TransformationMagicDefence = 94;
                                                                attacker.TransformationDodge = 35;
                                                                attacker.TransformationTime = 39;
                                                                attacker.TransformationID = 207;
                                                                break;
                                                            }
                                                        case 1:
                                                            {
                                                                attacker.TransformationMaxAttack = 200;
                                                                attacker.TransformationMinAttack = 134;
                                                                attacker.TransformationDefence = 1400;
                                                                attacker.TransformationMagicDefence = 96;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 49;
                                                                attacker.TransformationID = 207;
                                                                break;
                                                            }
                                                        case 2:
                                                            {
                                                                attacker.TransformationMaxAttack = 240;
                                                                attacker.TransformationMinAttack = 160;
                                                                attacker.TransformationDefence = 1500;
                                                                attacker.TransformationMagicDefence = 97;
                                                                attacker.TransformationDodge = 45;
                                                                attacker.TransformationTime = 59;
                                                                attacker.TransformationID = 207;
                                                                break;
                                                            }
                                                        case 3:
                                                            {
                                                                attacker.TransformationMaxAttack = 258;
                                                                attacker.TransformationMinAttack = 172;
                                                                attacker.TransformationDefence = 1600;
                                                                attacker.TransformationMagicDefence = 98;
                                                                attacker.TransformationDodge = 50;
                                                                attacker.TransformationTime = 69;
                                                                attacker.TransformationID = 267;
                                                                break;
                                                            }
                                                        case 4:
                                                            {
                                                                attacker.TransformationMaxAttack = 300;
                                                                attacker.TransformationMinAttack = 200;
                                                                attacker.TransformationDefence = 1900;
                                                                attacker.TransformationMagicDefence = 99;
                                                                attacker.TransformationDodge = 55;
                                                                attacker.TransformationTime = 79;
                                                                attacker.TransformationID = 267;
                                                                break;
                                                            }
                                                    }
                                                    break;
                                                case 1270:
                                                    switch (spell.Level)
                                                    {
                                                        case 0:
                                                            {
                                                                attacker.TransformationMaxAttack = 282;
                                                                attacker.TransformationMinAttack = 179;
                                                                attacker.TransformationDefence = 73;
                                                                attacker.TransformationMagicDefence = 34;
                                                                attacker.TransformationDodge = 9;
                                                                attacker.TransformationTime = 34;
                                                                attacker.TransformationID = 214;
                                                                break;
                                                            }
                                                        case 1:
                                                            {
                                                                attacker.TransformationMaxAttack = 395;
                                                                attacker.TransformationMinAttack = 245;
                                                                attacker.TransformationDefence = 126;
                                                                attacker.TransformationMagicDefence = 45;
                                                                attacker.TransformationDodge = 12;
                                                                attacker.TransformationTime = 39;
                                                                attacker.TransformationID = 214;
                                                                break;
                                                            }
                                                        case 2:
                                                            {
                                                                attacker.TransformationMaxAttack = 616;
                                                                attacker.TransformationMinAttack = 367;
                                                                attacker.TransformationDefence = 180;
                                                                attacker.TransformationMagicDefence = 53;
                                                                attacker.TransformationDodge = 15;
                                                                attacker.TransformationTime = 44;
                                                                attacker.TransformationID = 214;
                                                                break;
                                                            }
                                                        case 3:
                                                            {
                                                                attacker.TransformationMaxAttack = 724;
                                                                attacker.TransformationMinAttack = 429;
                                                                attacker.TransformationDefence = 247;
                                                                attacker.TransformationMagicDefence = 53;
                                                                attacker.TransformationDodge = 15;
                                                                attacker.TransformationTime = 49;
                                                                attacker.TransformationID = 214;
                                                                break;
                                                            }
                                                        case 4:
                                                            {
                                                                attacker.TransformationMaxAttack = 1231;
                                                                attacker.TransformationMinAttack = 704;
                                                                attacker.TransformationDefence = 499;
                                                                attacker.TransformationMagicDefence = 50;
                                                                attacker.TransformationDodge = 20;
                                                                attacker.TransformationTime = 54;
                                                                attacker.TransformationID = 274;
                                                                break;
                                                            }
                                                        case 5:
                                                            {
                                                                attacker.TransformationMaxAttack = 1573;
                                                                attacker.TransformationMinAttack = 941;
                                                                attacker.TransformationDefence = 601;
                                                                attacker.TransformationMagicDefence = 53;
                                                                attacker.TransformationDodge = 25;
                                                                attacker.TransformationTime = 59;
                                                                attacker.TransformationID = 274;
                                                                break;
                                                            }
                                                        case 6:
                                                            {
                                                                attacker.TransformationMaxAttack = 1991;
                                                                attacker.TransformationMinAttack = 1107;
                                                                attacker.TransformationDefence = 1029;
                                                                attacker.TransformationMagicDefence = 55;
                                                                attacker.TransformationDodge = 30;
                                                                attacker.TransformationTime = 64;
                                                                attacker.TransformationID = 274;
                                                                break;
                                                            }
                                                        case 7:
                                                            {
                                                                attacker.TransformationMaxAttack = 2226;
                                                                attacker.TransformationMinAttack = 1235;
                                                                attacker.TransformationDefence = 1029;
                                                                attacker.TransformationMagicDefence = 55;
                                                                attacker.TransformationDodge = 35;
                                                                attacker.TransformationTime = 69;
                                                                attacker.TransformationID = 274;
                                                                break;
                                                            }
                                                    }
                                                    break;
                                                case 1360:
                                                    switch (spell.Level)
                                                    {
                                                        case 0:
                                                            {
                                                                attacker.TransformationMaxAttack = 1215;
                                                                attacker.TransformationMinAttack = 610;
                                                                attacker.TransformationDefence = 100;
                                                                attacker.TransformationMagicDefence = 96;
                                                                attacker.TransformationDodge = 30;
                                                                attacker.TransformationTime = 59;
                                                                attacker.TransformationID = 217;
                                                                break;
                                                            }
                                                        case 1:
                                                            {
                                                                attacker.TransformationMaxAttack = 1310;
                                                                attacker.TransformationMinAttack = 650;
                                                                attacker.TransformationDefence = 400;
                                                                attacker.TransformationMagicDefence = 97;
                                                                attacker.TransformationDodge = 30;
                                                                attacker.TransformationTime = 79;
                                                                attacker.TransformationID = 217;
                                                                break;
                                                            }
                                                        case 2:
                                                            {
                                                                attacker.TransformationMaxAttack = 1420;
                                                                attacker.TransformationMinAttack = 710;
                                                                attacker.TransformationDefence = 650;
                                                                attacker.TransformationMagicDefence = 98;
                                                                attacker.TransformationDodge = 30;
                                                                attacker.TransformationTime = 89;
                                                                attacker.TransformationID = 217;
                                                                break;
                                                            }
                                                        case 3:
                                                            {
                                                                attacker.TransformationMaxAttack = 1555;
                                                                attacker.TransformationMinAttack = 780;
                                                                attacker.TransformationDefence = 720;
                                                                attacker.TransformationMagicDefence = 98;
                                                                attacker.TransformationDodge = 30;
                                                                attacker.TransformationTime = 99;
                                                                attacker.TransformationID = 277;
                                                                break;
                                                            }
                                                        case 4:
                                                            {
                                                                attacker.TransformationMaxAttack = 1660;
                                                                attacker.TransformationMinAttack = 840;
                                                                attacker.TransformationDefence = 1200;
                                                                attacker.TransformationMagicDefence = 99;
                                                                attacker.TransformationDodge = 30;
                                                                attacker.TransformationTime = 109;
                                                                attacker.TransformationID = 277;
                                                                break;
                                                            }
                                                    }
                                                    break;
                                                case 1280:
                                                    switch (spell.Level)
                                                    {
                                                        case 0:
                                                            {
                                                                attacker.TransformationMaxAttack = 930;
                                                                attacker.TransformationMinAttack = 656;
                                                                attacker.TransformationDefence = 290;
                                                                attacker.TransformationMagicDefence = 45;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 29;
                                                                attacker.TransformationID = 213;
                                                                break;
                                                            }
                                                        case 1:
                                                            {
                                                                attacker.TransformationMaxAttack = 1062;
                                                                attacker.TransformationMinAttack = 750;
                                                                attacker.TransformationDefence = 320;
                                                                attacker.TransformationMagicDefence = 46;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 34;
                                                                attacker.TransformationID = 213;
                                                                break;
                                                            }
                                                        case 2:
                                                            {
                                                                attacker.TransformationMaxAttack = 1292;
                                                                attacker.TransformationMinAttack = 910;
                                                                attacker.TransformationDefence = 510;
                                                                attacker.TransformationMagicDefence = 50;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 39;
                                                                attacker.TransformationID = 213;
                                                                break;
                                                            }
                                                        case 3:
                                                            {
                                                                attacker.TransformationMaxAttack = 1428;
                                                                attacker.TransformationMinAttack = 1000;
                                                                attacker.TransformationDefence = 600;
                                                                attacker.TransformationMagicDefence = 53;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 44;
                                                                attacker.TransformationID = 213;
                                                                break;
                                                            }
                                                        case 4:
                                                            {
                                                                attacker.TransformationMaxAttack = 1570;
                                                                attacker.TransformationMinAttack = 1100;
                                                                attacker.TransformationDefence = 700;
                                                                attacker.TransformationMagicDefence = 55;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 49;
                                                                attacker.TransformationID = 213;
                                                                break;
                                                            }
                                                        case 5:
                                                            {
                                                                attacker.TransformationMaxAttack = 1700;
                                                                attacker.TransformationMinAttack = 1200;
                                                                attacker.TransformationDefence = 880;
                                                                attacker.TransformationMagicDefence = 57;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 54;
                                                                attacker.TransformationID = 273;
                                                                break;
                                                            }
                                                        case 6:
                                                            {
                                                                attacker.TransformationMaxAttack = 1900;
                                                                attacker.TransformationMinAttack = 1300;
                                                                attacker.TransformationDefence = 1540;
                                                                attacker.TransformationMagicDefence = 59;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 59;
                                                                attacker.TransformationID = 273;
                                                                break;
                                                            }
                                                        case 7:
                                                            {
                                                                attacker.TransformationMaxAttack = 2100;
                                                                attacker.TransformationMinAttack = 1500;
                                                                attacker.TransformationDefence = 1880;
                                                                attacker.TransformationMagicDefence = 61;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 59;
                                                                attacker.TransformationID = 273;
                                                                break;
                                                            }
                                                        case 8:
                                                            {
                                                                attacker.TransformationMaxAttack = 2300;
                                                                attacker.TransformationMinAttack = 1600;
                                                                attacker.TransformationDefence = 1970;
                                                                attacker.TransformationMagicDefence = 63;
                                                                attacker.TransformationDodge = 40;
                                                                attacker.TransformationTime = 59;
                                                                attacker.TransformationID = 273;
                                                                break;
                                                            }
                                                    }
                                                    break;

                                                case 3321:
                                                    {
                                                        attacker.TransformationMaxAttack = 2000000;
                                                        attacker.TransformationMinAttack = 2000000;
                                                        attacker.TransformationDefence = 65355;
                                                        attacker.TransformationMagicDefence = 65355;
                                                        attacker.TransformationDodge = 35;
                                                        attacker.TransformationTime = 65355;
                                                        attacker.TransformationID = 223;
                                                        break;
                                                    }

                                            }
                                            #endregion

                                            SpellUse spellUse = new SpellUse(true);
                                            spellUse.Attacker = attacker.UID;
                                            spellUse.SpellID = spell.ID;
                                            spellUse.SpellLevel = spell.Level;
                                            spellUse.X = X;
                                            spellUse.Y = Y;
                                            spellUse.Targets.Add(attacker.UID, (uint)0);
                                            attacker.Owner.SendScreen(spellUse, true);
                                            attacker.TransformationStamp = Time32.Now;
                                            attacker.TransformationMaxHP = 3000;
                                            if (spell.ID == 1270)
                                                attacker.TransformationMaxHP = 50000;
                                            attacker.TransformationAttackRange = 3;
                                            if (spell.ID == 1360)
                                                attacker.TransformationAttackRange = 10;
                                            if (!wasTransformated)
                                            {
                                                double maxHP = attacker.MaxHitpoints;
                                                double HP = attacker.Hitpoints;
                                                double point = HP / maxHP;

                                                attacker.Hitpoints = (uint)(attacker.TransformationMaxHP * point);
                                            }
                                            attacker.Update(Update.MaxHitpoints, attacker.TransformationMaxHP, false);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Bless
                                case 9876:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);
                                            attacker.AddFlag(Update.Flags.CastPray);
                                            SpellUse spellUse = new SpellUse(true);
                                            spellUse.Attacker = attacker.UID;
                                            spellUse.SpellID = spell.ID;
                                            spellUse.SpellLevel = spell.Level;
                                            spellUse.X = X;
                                            spellUse.Y = Y;
                                            spellUse.Targets.Add(attacker.UID, 0);
                                            attacker.Owner.SendScreen(spellUse, true);
                                        }
                                        break;
                                    }
                                #endregion
                                #region Companions
                                case 4000:
                                case 4010:
                                case 4020:
                                case 4050:
                                case 4060:
                                case 4070:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            if (attacker.Owner.Companion != null)
                                            {
                                                if (attacker.Owner.Companion.MonsterInfo != null)
                                                {
                                                    attacker.Owner.Map.RemoveEntity(attacker.Owner.Companion);
                                                    Data data = new Data(true);
                                                    data.UID = attacker.Owner.Companion.UID;
                                                    data.ID = Data.RemoveEntity;
                                                    attacker.Owner.Companion.MonsterInfo.SendScreen(data);
                                                    attacker.Owner.Companion = null;
                                                }
                                            }
                                            PrepareSpell(spell, attacker.Owner);
                                            SpellUse spellUse = new SpellUse(true);
                                            spellUse.Attacker = attacker.UID;
                                            spellUse.SpellID = spell.ID;
                                            spellUse.SpellLevel = spell.Level;
                                            spellUse.X = X;
                                            spellUse.Y = Y;
                                            spellUse.Targets.Add(attacker.UID, 0);
                                            attacker.Owner.SendScreen(spellUse, true);
                                            attacker.Owner.Companion = new Entity(EntityFlag.Monster, true);
                                            attacker.Owner.Companion.MonsterInfo = new Conquer_Online_Server.Database.MonsterInformation();
                                            Database.MonsterInformation mt = Database.MonsterInformation.MonsterInfos[spell.Power];
                                            attacker.Owner.Companion.Owner = attacker.Owner;
                                            attacker.Owner.Companion.MapObjType = MapObjectType.Monster;
                                            attacker.Owner.Companion.MonsterInfo = mt.Copy();
                                            attacker.Owner.Companion.MonsterInfo.Owner = attacker.Owner.Companion;
                                            attacker.Owner.Companion.Name = mt.Name;
                                            attacker.Owner.Companion.MinAttack = mt.MinAttack;
                                            attacker.Owner.Companion.MaxAttack = attacker.Owner.Companion.MagicAttack = mt.MaxAttack;
                                            attacker.Owner.Companion.Hitpoints = attacker.Owner.Companion.MaxHitpoints = mt.Hitpoints;
                                            attacker.Owner.Companion.Body = mt.Mesh;
                                            attacker.Owner.Companion.Level = mt.Level;
                                            attacker.Owner.Companion.UID = (uint)(attacker.UID - 200000);
                                            attacker.Owner.Companion.MapID = attacker.Owner.Map.ID;
                                            attacker.Owner.Companion.SendUpdates = true;
                                            attacker.Owner.Companion.X = attacker.X;
                                            attacker.Owner.Companion.Y = attacker.Y;
                                            attacker.Owner.Map.AddEntity(attacker.Owner.Companion);
                                            attacker.Owner.SendScreenSpawn(attacker.Owner.Companion, true);
                                        }
                                        break;
                                    }
                                #endregion

                                #region MonkSpells
                                //TyrantAura
                                case 10395:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        PrepareSpell(spell, attacker.Owner);
                                                    {

                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FendAura))//FendAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FendAura);//FendAura
                                                            teammate.Entity.Statistics.Immunity -= 200;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                            teammate.Entity.Statistics.MetalResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                            teammate.Entity.Statistics.WoodResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                            teammate.Entity.Statistics.WaterResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                            teammate.Entity.Statistics.FireResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                            teammate.Entity.Statistics.EarthResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.TyrantAura))//TyrantAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.TyrantAura);//TyrantAura
                                                            teammate.Entity.Statistics.CriticalStrike -= 200;
                                                        }

                                                        teammate.Entity.AddFlag2(Update.Flags2.TyrantAura);
                                                        teammate.Entity.Statistics.CriticalStrike += 200;
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                        teammate.Entity.TyrantAura = Time32.Now;
                                                        teammate.Entity.TyrantAuras = (short)spell.Duration;

                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    if (attacker.ContainsFlag2(Update.Flags2.FendAura))//FendAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.FendAura);//FendAura
                                                        attacker.Statistics.Immunity -= 200;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                        attacker.Statistics.MetalResistance -= 30;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                    {
                                                        attacker.Statistics.WoodResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                    {
                                                        attacker.Statistics.WaterResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                    {
                                                        attacker.Statistics.FireResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                    {
                                                        attacker.Statistics.EarthResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                    }
                                                    if (attacked.ContainsFlag2(Update.Flags2.TyrantAura))//TyrantAura
                                                    {
                                                        attacked.RemoveFlag2(Update.Flags2.TyrantAura);//TyrantAura
                                                        attacked.Statistics.CriticalStrike -= 200;

                                                    }
                                                    attacker.AddFlag2(Update.Flags2.TyrantAura);
                                                    attacker.Statistics.CriticalStrike += 200;
                                                    attacker.TyrantAura = Time32.Now;
                                                    attacker.TyrantAuras = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //FendAura
                                case 10410:
                                    {

                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        PrepareSpell(spell, attacker.Owner);
                                                    {

                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                            teammate.Entity.Statistics.CriticalStrike -= 200;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                            teammate.Entity.Statistics.MetalResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                            teammate.Entity.Statistics.WoodResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                            teammate.Entity.Statistics.WaterResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                            teammate.Entity.Statistics.FireResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                            teammate.Entity.Statistics.EarthResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                            teammate.Entity.Statistics.Immunity -= 200;
                                                        }

                                                        teammate.Entity.AddFlag2(Update.Flags2.FendAura);
                                                        teammate.Entity.Statistics.Immunity += 200;
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                        teammate.Entity.TyrantAura = Time32.Now;
                                                        teammate.Entity.TyrantAuras = (short)spell.Duration;

                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    if (attacked.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                    {
                                                        attacked.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                        attacked.Statistics.CriticalStrike -= 200;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                        attacker.Statistics.MetalResistance -= 30;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                    {
                                                        attacker.Statistics.WoodResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                    {
                                                        attacker.Statistics.WaterResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                    {
                                                        attacker.Statistics.FireResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                    {
                                                        attacker.Statistics.EarthResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                        attacker.Statistics.Immunity += 200;

                                                    }
                                                    attacker.AddFlag2(Update.Flags2.FendAura);
                                                    attacker.Statistics.Immunity += 200;
                                                    attacker.TyrantAura = Time32.Now;
                                                    attacker.TyrantAuras = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //ElementalAuraMetal
                                case 10420:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        PrepareSpell(spell, attacker.Owner);
                                                    {

                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                            teammate.Entity.Statistics.CriticalStrike -= 200;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                            teammate.Entity.Statistics.MetalResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                            teammate.Entity.Statistics.WoodResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                            teammate.Entity.Statistics.WaterResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                            teammate.Entity.Statistics.FireResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                            teammate.Entity.Statistics.EarthResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                            teammate.Entity.Statistics.Immunity -= 200;
                                                        }

                                                        teammate.Entity.AddFlag2(Update.Flags2.MetalAura);
                                                        teammate.Entity.Statistics.MetalResistance += 30;
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                        teammate.Entity.TyrantAura = Time32.Now;
                                                        teammate.Entity.TyrantAuras = (short)spell.Duration;

                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    if (attacker.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                        attacker.Statistics.CriticalStrike -= 200;
                                                    }
                                                    if (attacked.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                    {
                                                        attacked.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                        attacked.Statistics.MetalResistance -= 30;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                    {
                                                        attacker.Statistics.WoodResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                    {
                                                        attacker.Statistics.WaterResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                    {
                                                        attacker.Statistics.FireResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                    {
                                                        attacker.Statistics.EarthResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                        attacker.Statistics.Immunity -= 200;

                                                    }
                                                    attacker.AddFlag2(Update.Flags2.MetalAura);
                                                    attacker.Statistics.MetalResistance += 30;
                                                    attacker.TyrantAura = Time32.Now;
                                                    attacker.TyrantAuras = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //ElementalAuraWood
                                case 10421:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        PrepareSpell(spell, attacker.Owner);
                                                    {

                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                            teammate.Entity.Statistics.CriticalStrike -= 200;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                            teammate.Entity.Statistics.MetalResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                            teammate.Entity.Statistics.WoodResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                            teammate.Entity.Statistics.WaterResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                            teammate.Entity.Statistics.FireResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                            teammate.Entity.Statistics.EarthResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                            teammate.Entity.Statistics.Immunity -= 200;
                                                        }

                                                        teammate.Entity.AddFlag2(Update.Flags2.WoodAura);
                                                        teammate.Entity.Statistics.WoodResistance += 30;
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                        teammate.Entity.TyrantAura = Time32.Now;
                                                        teammate.Entity.TyrantAuras = (short)spell.Duration;

                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    if (attacker.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                        attacker.Statistics.CriticalStrike -= 200;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                        attacker.Statistics.MetalResistance -= 30;
                                                    }
                                                    if (attacked.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                    {
                                                        attacked.Statistics.WoodResistance -= 30;
                                                        attacked.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                    {
                                                        attacker.Statistics.WaterResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                    {
                                                        attacker.Statistics.FireResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                    {
                                                        attacker.Statistics.EarthResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                        attacker.Statistics.Immunity -= 200;

                                                    }
                                                    attacker.AddFlag2(Update.Flags2.WoodAura);
                                                    attacker.Statistics.WoodResistance += 30;
                                                    attacker.TyrantAura = Time32.Now;
                                                    attacker.TyrantAuras = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //ElementalAuraWater
                                case 10422:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        PrepareSpell(spell, attacker.Owner);
                                                    {

                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                            teammate.Entity.Statistics.CriticalStrike -= 200;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                            teammate.Entity.Statistics.MetalResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                            teammate.Entity.Statistics.WoodResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                            teammate.Entity.Statistics.WaterResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                            teammate.Entity.Statistics.FireResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                            teammate.Entity.Statistics.EarthResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                            teammate.Entity.Statistics.Immunity -= 200;
                                                        }

                                                        teammate.Entity.AddFlag2(Update.Flags2.WaterAura);
                                                        teammate.Entity.Statistics.WaterResistance += 30;
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                        teammate.Entity.TyrantAura = Time32.Now;
                                                        teammate.Entity.TyrantAuras = (short)spell.Duration;

                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    if (attacker.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                        attacker.Statistics.CriticalStrike -= 200;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                        attacker.Statistics.MetalResistance -= 30;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                    {
                                                        attacker.Statistics.WoodResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                    }
                                                    if (attacked.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                    {
                                                        attacked.Statistics.WaterResistance -= 30;
                                                        attacked.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                    {
                                                        attacker.Statistics.FireResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                    {
                                                        attacker.Statistics.EarthResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                        attacker.Statistics.Immunity -= 200;

                                                    }
                                                    attacker.AddFlag2(Update.Flags2.WaterAura);
                                                    attacker.Statistics.WaterResistance += 30;
                                                    attacker.TyrantAura = Time32.Now;
                                                    attacker.TyrantAuras = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //ElementalAuraFire
                                case 10423:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        PrepareSpell(spell, attacker.Owner);
                                                    {

                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                            teammate.Entity.Statistics.CriticalStrike -= 200;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                            teammate.Entity.Statistics.MetalResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                            teammate.Entity.Statistics.WoodResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                            teammate.Entity.Statistics.WaterResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                            teammate.Entity.Statistics.FireResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                            teammate.Entity.Statistics.EarthResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                            teammate.Entity.Statistics.Immunity -= 200;
                                                        }

                                                        teammate.Entity.AddFlag2(Update.Flags2.FireAura);
                                                        teammate.Entity.Statistics.FireResistance += 30;
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                        teammate.Entity.TyrantAura = Time32.Now;
                                                        teammate.Entity.TyrantAuras = (short)spell.Duration;

                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    if (attacker.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                        attacker.Statistics.CriticalStrike -= 200;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                        attacker.Statistics.MetalResistance -= 30;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                    {
                                                        attacker.Statistics.WoodResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                    {
                                                        attacker.Statistics.WaterResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                    }
                                                    if (attacked.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                    {
                                                        attacked.Statistics.FireResistance -= 30;
                                                        attacked.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                    {
                                                        attacker.Statistics.EarthResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                        attacker.Statistics.Immunity -= 200;

                                                    }
                                                    attacker.AddFlag2(Update.Flags2.FireAura);
                                                    attacker.Statistics.FireResistance += 30;
                                                    attacker.TyrantAura = Time32.Now;
                                                    attacker.TyrantAuras = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //ElementalEarthAura
                                case 10424:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                        PrepareSpell(spell, attacker.Owner);
                                                    {

                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                            teammate.Entity.Statistics.CriticalStrike -= 200;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                            teammate.Entity.Statistics.MetalResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                            teammate.Entity.Statistics.WoodResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                            teammate.Entity.Statistics.WaterResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                            teammate.Entity.Statistics.FireResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                            teammate.Entity.Statistics.EarthResistance -= 30;
                                                        }
                                                        if (teammate.Entity.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                        {
                                                            teammate.Entity.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                            teammate.Entity.Statistics.Immunity -= 200;
                                                        }

                                                        teammate.Entity.AddFlag2(Update.Flags2.EarthAura);
                                                        teammate.Entity.Statistics.EarthResistance += 30;
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                        teammate.Entity.TyrantAura = Time32.Now;
                                                        teammate.Entity.TyrantAuras = (short)spell.Duration;

                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);
                                                    if (attacker.ContainsFlag2(Update.Flags2.TyrantAura))//FendAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.TyrantAura);//FendAura
                                                        attacker.Statistics.CriticalStrike -= 200;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.MetalAura))//MetalAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.MetalAura);//MetalAura
                                                        attacker.Statistics.MetalResistance -= 30;
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WoodAura))//WoodAura
                                                    {
                                                        attacker.Statistics.WoodResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WoodAura);//WoodAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.WaterAura))//WaterAura
                                                    {
                                                        attacker.Statistics.WaterResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.WaterAura);//WaterAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FireAura))//FireAura
                                                    {
                                                        attacker.Statistics.FireResistance -= 30;
                                                        attacker.RemoveFlag2(Update.Flags2.FireAura);//FireAura
                                                    }
                                                    if (attacked.ContainsFlag2(Update.Flags2.EarthAura))//EarthAura
                                                    {
                                                        attacked.Statistics.EarthResistance -= 30;
                                                        attacked.RemoveFlag2(Update.Flags2.EarthAura);//EarthAura
                                                    }
                                                    if (attacker.ContainsFlag2(Update.Flags2.FendAura))//TyrantAura
                                                    {
                                                        attacker.RemoveFlag2(Update.Flags2.FendAura);//TyrantAura
                                                        attacker.Statistics.Immunity -= 200;

                                                    }
                                                    attacker.AddFlag2(Update.Flags2.EarthAura);
                                                    attacker.Statistics.EarthResistance += 30;
                                                    attacker.TyrantAura = Time32.Now;
                                                    attacker.TyrantAuras = (short)spell.Duration;
                                                    suse.Targets.Add(attacked.UID, 1);
                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }

                                //Compassion
                                case 10430:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                    {
                                                        attacker.RemoveFlag(Update.Flags.Poisoned);

                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);

                                                    attacker.RemoveFlag(Update.Flags.Poisoned);

                                                    suse.Targets.Add(attacked.UID, 1);

                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //Serenity
                                case 10400:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            if (attacker == null) return;

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = SpellID;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            suse.Targets.Add(attacker.UID, 1);

                                            attacker.ToxicFogLeft = 0;
                                            //attacker.RemoveFlag(Update.Flags.SoulShackle);
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //Tranquility
                                case 10425:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;

                                            if (attacker.Owner.Team != null)
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                foreach (Client.GameState teammate in attacker.Owner.Team.Teammates)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, teammate.Entity.X, teammate.Entity.Y) <= spell.Distance)
                                                    {
                                                        attacker.RemoveFlag(Update.Flags.SoulShackle);
                                                        attacked.RemoveFlag(Update.Flags.SoulShackle);
                                                        teammate.Entity.RemoveFlag(Update.Flags.SoulShackle);
                                                        suse.Targets.Add(teammate.Entity.UID, 1);
                                                    }
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            else
                                            {
                                                if (attacked == null)
                                                    return;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Distance)
                                                {
                                                    PrepareSpell(spell, attacker.Owner);

                                                    attacker.RemoveFlag(Update.Flags.SoulShackle);

                                                    suse.Targets.Add(attacked.UID, 1);

                                                    if (attacked.EntityFlag == EntityFlag.Player)
                                                        attacked.Owner.SendScreen(suse, true);
                                                    else
                                                        attacked.MonsterInfo.SendScreen(suse);
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                            }
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //Radiant Palm
                                case 10381:
                                    // case 10315:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);
                                            Game.Attacking.InLineAlgorithm ila = new Conquer_Online_Server.Game.Attacking.InLineAlgorithm(attacker.X,
                                        X, attacker.Y, Y, (byte)spell.Range, InLineAlgorithm.Algorithm.DDA);
                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = SpellID;
                                            suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            for (int c = 0; c < attacker.Owner.Screen.Objects.Length; c++)
                                            {
                                                //For a multi threaded application, while we go through the collection
                                                //the collection might change. We will make sure that we wont go off
                                                //the limits with a check.
                                                if (c >= attacker.Owner.Screen.Objects.Length)
                                                    break;
                                                Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                if (_obj == null)
                                                    continue;
                                                if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                {
                                                    attacked = _obj as Entity;
                                                    if (ila.InLine(attacked.X, attacked.Y))
                                                    {
                                                        if (!CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                            continue;

                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell);

                                                        attack.Damage = damage;

                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                        suse.Targets.Add(attacked.UID, damage);
                                                    }
                                                }
                                                else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                {
                                                    attackedsob = _obj as SobNpcSpawn;

                                                    if (ila.InLine(attackedsob.X, attackedsob.Y))
                                                    {
                                                        if (!CanAttack(attacker, attackedsob, spell))
                                                            continue;

                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob);
                                                        damage = (uint)(damage * spell.PowerPercent);
                                                        attack.Damage = damage;

                                                        ReceiveAttack(attacker, attackedsob, attack, damage, spell);

                                                        suse.Targets.Add(attackedsob.UID, damage);
                                                    }
                                                }
                                            }

                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
                                //WhirlwindKick
                                case 10415:
                                    {
                                        if (Time32.Now < attacker.WhilrwindKick.AddMilliseconds(1500))
                                        { attacker.AttackPacket = null; return; }
                                        attacker.WhilrwindKick = Time32.Now;
                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= 3)
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);

                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = 0;
                                                suse.X = (ushort)ServerBase.Kernel.Random.Next(3, 10);
                                                suse.Y = 0;

                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= 3)
                                                {
                                                    for (int c = 0; c < attacker.Owner.Screen.Objects.Length; c++)
                                                    {
                                                        //For a multi threaded application, while we go through the collection
                                                        //the collection might change. We will make sure that we wont go off
                                                        //the limits with a check.
                                                        if (c >= attacker.Owner.Screen.Objects.Length)
                                                            break;
                                                        Interfaces.IMapObject _obj = attacker.Owner.Screen.Objects[c];
                                                        if (_obj == null)
                                                            continue;
                                                        if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                        {
                                                            attacked = _obj as Entity;
                                                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= spell.Range)
                                                            {
                                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Ranged))
                                                                {
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked);

                                                                    ReceiveAttack(attacker, attacked, attack, damage, spell);
                                                                    attacked.Stunned = true;
                                                                    attacked.StunStamp = Time32.Now;
                                                                    suse.Targets.Add(attacked.UID, damage);

                                                                }
                                                            }
                                                        }
                                                    }
                                                    attacker.AttackPacket = null;
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null; return;
                                                }
                                                attacker.Owner.SendScreen(suse, true);
                                                suse.Targets = new SafeDictionary<uint, SpellUse.DamageClass>();
                                                attacker.AttackPacket = null; return;
                                            }
                                            attacker.AttackPacket = null;
                                        }
                                        attacker.AttackPacket = null; return;
                                        //break;
                                    }
                                #endregion

                            }
                            attacker.Owner.IncreaseSpellExperience(Experience, spellID);
                            if (attacker.MapID == 1039)
                            {
                                if (spell.ID == 7001 || spell.ID == 9876)
                                {
                                    attacker.AttackPacket = null;
                                    return;
                                }
                                if (attacker.AttackPacket != null)
                                {
                                    attack.Damage = spell.ID;
                                    attacker.AttackPacket = attack;
                                    if (Database.SpellTable.WeaponSpells.ContainsValue(spell.ID))
                                    {
                                        if (attacker.AttackPacket == null)
                                        {
                                            attack.AttackType = Attack.Melee;
                                            attacker.AttackPacket = attack;
                                        }
                                        else
                                        {
                                            attacker.AttackPacket.AttackType = Attack.Melee;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (spell.NextSpellID != 0)
                                {
                                    if (spell.NextSpellID >= 1000 && spell.NextSpellID <= 1002)
                                        if (Target >= 1000000)
                                        {
                                            attacker.AttackPacket = null;
                                            return;
                                        }
                                    attack.Damage = spell.NextSpellID;
                                    attacker.AttackPacket = attack;
                                }
                                else
                                {
                                    if (!Database.SpellTable.WeaponSpells.ContainsValue(spell.ID) || spell.ID == 9876)
                                        attacker.AttackPacket = null;
                                    else
                                    {
                                        if (attacker.AttackPacket == null)
                                        {
                                            attack.AttackType = Attack.Melee;
                                            attacker.AttackPacket = attack;
                                        }
                                        else
                                        {
                                            attacker.AttackPacket.AttackType = Attack.Melee;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            attacker.AttackPacket = null;
                        }
                    }
                    #endregion
                }
                #endregion
            }
        }