Пример #1
0
        public void _timerCallBack(object obj, System.Timers.ElapsedEventArgs arg)
        {
            try
            {
                Time32 Now = Time32.Now;

                if (this == null || Owner == null)
                    return;

                if (Owner.Alive)
                {

                    if (this.HandleTiming)
                    {

                        #region Training points
                        if (HeavenBlessing > 0 && !Dead)
                        {
                            if (Now > Owner.LastTrainingPointsUp.AddMinutes(10))
                            {
                                Owner.OnlineTrainingPoints += 10;
                                if (Owner.OnlineTrainingPoints >= 30)
                                {
                                    Owner.OnlineTrainingPoints -= 30;
                                    Owner.IncreaseExperience(Owner.ExpBall / 100, false);
                                }
                                Owner.LastTrainingPointsUp = Now;
                                Update(Network.GamePackets.Update.OnlineTraining, Owner.OnlineTrainingPoints, false);
                            }
                        }
                        #endregion
                        #region Minning
                        if (Owner.Mining && !Dead)
                        {
                            if (Now >= Owner.MiningStamp.AddSeconds(2))
                            {
                                Owner.MiningStamp = Now;
                                Game.ConquerStructures.Mining.Mine(Owner);
                            }
                        }
                        #endregion
                        #region MentorPrizeSave
                        if (Now > Owner.LastMentorSave.AddSeconds(5))
                        {
                            Database.KnownPersons.SaveApprenticeInfo(Owner.AsApprentice);
                            Owner.LastMentorSave = Now;
                        }
                        #endregion
                        #region Attackable
                        if (Owner.JustLoggedOn)
                        {
                            Owner.JustLoggedOn = false;
                            Owner.ReviveStamp = Now;
                        }
                        if (!Owner.Attackable)
                        {
                            if (Now > Owner.ReviveStamp.AddSeconds(5))
                            {
                                Owner.Attackable = true;
                            }
                        }
                        #endregion
                        #region DoubleExperience
                        if (DoubleExperienceTime > 0)
                        {
                            if (Now > DoubleExpStamp.AddMilliseconds(1000))
                            {
                                DoubleExpStamp = Now;
                                DoubleExperienceTime--;
                            }
                        }
                        if (DoubleExperienceTime5 > 0)
                        {
                            if (Now > DoubleExpStamp5.AddMilliseconds(1000))
                            {
                                DoubleExpStamp5 = Now;
                                DoubleExperienceTime5--;
                            }
                        }
                        if (DoubleExperienceTime10 > 0)
                        {
                            if (Now > DoubleExpStamp10.AddMilliseconds(1000))
                            {
                                DoubleExpStamp10 = Now;
                                DoubleExperienceTime10--;
                            }
                        }
                        if (DoubleExperienceTime15 > 0)
                        {
                            if (Now > DoubleExpStamp15.AddMilliseconds(1000))
                            {
                                DoubleExpStamp15 = Now;
                                DoubleExperienceTime15--;
                            }
                        }
                        if (DoubleExperienceTimeV1 > 0)
                        {
                            if (Now > CPsStamp.AddMilliseconds(1000))
                            {
                                CPsStamp = Now;
                                DoubleExperienceTimeV1--;
                            }
                        }
                        #endregion
                        #region HeavenBlessing
                        if (HeavenBlessing > 0)
                        {
                            if (Now > HeavenBlessingStamp.AddMilliseconds(1000))
                            {
                                HeavenBlessingStamp = Now;
                                HeavenBlessing--;
                            }
                        }
                        #endregion
                        #region Enlightment
                        if (EnlightmentTime > 0)
                        {
                            if (Now >= EnlightmentStamp.AddMinutes(1))
                            {
                                EnlightmentStamp = Now;
                                EnlightmentTime--;
                                if (EnlightmentTime % 10 == 0 && EnlightmentTime > 0)
                                    Owner.IncreaseExperience(Game.Attacking.Calculate.Percent((int)Owner.ExpBall, .10F), false);
                            }
                        }
                        #endregion
                        #region PKPoints
                        if (Now >= PKPointDecreaseStamp.AddMinutes(5))
                        {
                            PKPointDecreaseStamp = Now;
                            if (PKPoints > 0)
                            {
                                PKPoints--;
                            }
                            else
                                PKPoints = 0;
                        }
                        #endregion
                        #region OverHP
                        if (FullyLoaded)
                        {
                            if (Hitpoints > MaxHitpoints && MaxHitpoints > 1 && !Transformed)
                            {
                                Hitpoints = MaxHitpoints;
                            }
                        }
                        #endregion
                        #region Stamina
                        if (Now > this.StaminaStamp.AddMilliseconds(1500))
                        {
                            if (Owner.Entity.Vigor < Owner.Entity.MaxVigor)
                            {
                                Owner.Entity.Vigor += (ushort)(3 + (Owner.Entity.Action == Game.Enums.ConquerAction.Sit ? 2 : 0));

                                {
                                    Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
                                    vigor.VigorValue = Owner.Entity.Vigor;
                                    vigor.Send(Owner);
                                }
                            }
                            if (!this.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                            {
                                int limit = 0;
                                if (this.HeavenBlessing > 0)
                                    limit = 50;
                                if (this.Stamina != 100 + limit)
                                {
                                    if (this.Action == Game.Enums.ConquerAction.Sit || !this.Owner.Equipment.Free(18))
                                    {
                                        if (this.Stamina <= 93 + limit)
                                        {
                                            this.Stamina += 7;
                                        }
                                        else
                                        {
                                            if (this.Stamina != 100 + limit)
                                                this.Stamina = (byte)(100 + limit);
                                        }
                                    }
                                    else
                                    {
                                        if (this.Stamina <= 97 + limit)
                                        {
                                            this.Stamina += 3;
                                        }
                                        else
                                        {
                                            if (this.Stamina != 100 + limit)
                                                this.Stamina = (byte)(100 + limit);
                                        }
                                    }
                                }
                                this.StaminaStamp = Now;
                            }
                        }
                        #endregion
                        #region SoulShackle
                        if (ContainsFlag(Network.GamePackets.Update.Flags.SoulShackle))
                        {
                            if (Now > ShackleStamp.AddSeconds(ShackleTime))
                            {
                                RemoveFlag(Network.GamePackets.Update.Flags.SoulShackle);
                            }
                        }
                        #endregion
                        #region AzureShield
                        if (ContainsFlag(Network.GamePackets.Update.Flags.AzureShield))
                        {
                            if (Now > AzureStamp.AddSeconds(AzureTime))
                            {
                                RemoveFlag(Network.GamePackets.Update.Flags.AzureShield);
                            }
                        }
                        #endregion
                    }
                }
                AutoAttack();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Program.SaveException(e);
            }
        }
        static void PlayerJump(Data generalData, Client.GameState client)
        {
            // Console.WriteLine("Jump Sec " + DateTime.Now.Second + " Mile " + DateTime.Now.Millisecond + "");
            //Console.WriteLine("" + generalData + "");

            client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
            client.Mining = false;
            /* #region SpeedHack Check
             if (Time32.Now > client.speedsleep.AddSeconds(60))
             {
                 client.speedHackSuspiction += 1;
                 //Console.WriteLine("SpeedHack sus "+client.speedHackSuspiction+" ");
                 if (Time32.Now > client.speedHackTime.AddSeconds(2))
                 {
                     client.speedHackTime = Time32.Now;
                     client.speedHackSuspiction = 0;
                 }
                 if (client.Entity.TransformationID == 0)
                 {
                     if (client.speedHackSuspiction > 5 && !client.Entity.OnCyclone() && !client.Entity.ContainsFlag(Update.Flags2.Oblivion) && !client.Entity.ContainsFlag(Update.Flags.Ride))
                     {
                         if (client.Entity.MapID != 6004)
                         {
                             client.HackTime += 1;
                             client.speedHackTime = Time32.Now;
                             client.speedsleep = Time32.Now;
                             client.speedHackSuspiction = 0;
                             //client.Entity.Teleport(6004, 30, 74);
                             if (client.HackTime < 3)
                             {
                                 PhoenixProject.ServerBase.Kernel.SendWorldMessage(new PhoenixProject.Network.GamePackets.Message("[GM]: " + client.Entity.Name + " is using SpeedHack, Using SpeedHack Times " + client.HackTime + " Time/s he still have " + (3 - client.HackTime) + " Warn then we will kick his/her ass Out!", System.Drawing.Color.Black, PhoenixProject.Network.GamePackets.Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                             }
                             else
                             {
                                 client.HackTime += 1;
                                 client.speedHackTime = Time32.Now;
                                 client.speedHackSuspiction = 0;
                                 client.Entity.Teleport(6004, 30, 74);
                                 PhoenixProject.ServerBase.Kernel.SendWorldMessage(new PhoenixProject.Network.GamePackets.Message("[GM]: " + client.Entity.Name + "  used SpeedHack for Three Times and sent to Botjail ,TakeCare of your account!", System.Drawing.Color.Black, PhoenixProject.Network.GamePackets.Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                             }
                         }
                     }
                 }
             }
             #endregion*/

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

                client.Entity.MagicDefenderTime = 0;
                client.Entity.MagicDefenderIncrease = 0;
                client.Entity.RemoveFlag3(Network.GamePackets.Update.Flags3.MagicDefender);
                SyncPacket packet = new SyncPacket
                {
                    Identifier = client.Entity.UID,
                    Count = 2,
                    Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                    StatusFlag1 = (ulong)client.Entity.StatusFlag,
                    StatusFlag2 = (ulong)client.Entity.StatusFlag2,
                    Unknown1 = 0x31,
                    StatusFlagOffset = 0x80,
                    Time = 0,
                    Value = 0,
                    Level = 0
                };
                client.Entity.Owner.Send((byte[])packet);
                foreach (var Client in client.MagicDef)
                {
                    if (Client.Entity.ContainsFlag2(Update.Flags2.kimo4))
                    {
                        Client.Entity.RemoveFlag2(Update.Flags2.kimo4);
                    }
                }
                client.MagicDef.Clear();
            }
            #endregion

            #region Pray
            if (client.Entity.ContainsFlag(Update.Flags.CastPray))
            {
                client.Entity.RemoveFlag(Update.Flags.CastPray);
                foreach (var Client in client.Prayers)
                {
                    if (Client.Entity.ContainsFlag(Update.Flags.Praying))
                    {
                        Client.Entity.RemoveFlag(Update.Flags.Praying);
                    }
                }
                client.Prayers.Clear();
            }

            if (client.Entity.ContainsFlag(Update.Flags.Praying))
            {
                client.Entity.RemoveFlag(Update.Flags.Praying);
                if (client.PrayLead != null)
                {
                    client.PrayLead.Prayers.Remove(client);
                    client.PrayLead = null;
                }
            }
            #endregion

            Time32 Now = Time32.Now;

            client.Attackable = true;
            if (client.Entity.AttackPacket != null)
            {
                client.Entity.AttackPacket = null;
            }
            if (client.Entity.Dead)
            {
                if (Now > client.Entity.DeathStamp.AddSeconds(4))
                {
                    //client.Disconnect();
                    return;
                }
            }

            ushort new_X = (ushort)(generalData.dwParam & 0xFFFF);
            ushort new_Y = (ushort)(generalData.dwParam >> 16);

            if (client.lastJumpDistance == 0) goto Jump;
            if (client.Entity.ContainsFlag(Update.Flags.Ride))
            {
                int distance = ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
                ushort take = (ushort)(1.5F * (distance / 2));
                if (client.Entity.Vigor >= take)
                {
                    client.Entity.Vigor -= take;
                    Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
                    vigor.VigorValue = client.Entity.Vigor;
                    vigor.Send(client);
                }
                else
                {
                }
            }
            client.LastJumpTime = (int)ServerBase.Kernel.maxJumpTime(client.lastJumpDistance);
            int a1 = Now.GetHashCode() - client.lastJumpTime.GetHashCode();
            int a2 = generalData.TimeStamp.GetHashCode() - client.lastClientJumpTime.GetHashCode();
            bool DOO = false;
            if (a2 - a1 > 1000) DOO = true;
            if (Now < client.lastJumpTime.AddMilliseconds(client.LastJumpTime))
            {
                bool doDisconnect = false;
                if (client.Entity.Transformed)
                    if (client.Entity.TransformationID != 207 && client.Entity.TransformationID != 267)
                        doDisconnect = true;
                if (client.Entity.Transformed && doDisconnect)
                {
                }
                if (client.Entity.Transformed && !doDisconnect)
                {
                    goto Jump;
                }
                if (!client.Entity.OnCyclone() && !client.Entity.ContainsFlag(Update.Flags2.Oblivion) && !client.Entity.ContainsFlag(Update.Flags.Ride) && !DOO)
                {
                }
                else if (client.Entity.ContainsFlag(Update.Flags.Ride))
                {
                    int time = (int)ServerBase.Kernel.maxJumpTime(client.lastJumpDistance);
                    int speedprc = Database.DataHolder.SteedSpeed(client.Equipment.TryGetItem(ConquerItem.Steed).Plus);
                    if (speedprc != 0)
                    {
                        if (Now < client.lastJumpTime.AddMilliseconds(time - (time * speedprc / 100)))
                        {
                        }
                    }
                    else
                    {
                    }
                }
            }
            Jump:
            client.lastJumpDistance = ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
            client.lastClientJumpTime = generalData.TimeStamp;
            client.lastJumpTime = Now;
            Game.Map Map = client.Map;
            if (Map != null)
            {
                if (Map.Floor[new_X, new_Y, Game.MapObjectType.Player, null])
                {
                    if (ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
                    {
                        client.Entity.Action = Game.Enums.ConquerAction.Jump;
                        client.Entity.Facing = ServerBase.Kernel.GetAngle(generalData.wParam1, generalData.wParam2, new_X, new_Y);
                        client.Entity.PX = client.Entity.X;
                        client.Entity.PY = client.Entity.Y;
                        client.Entity.X = new_X;
                        client.Entity.Y = new_Y;
                        client.SendScreen(generalData, true);
                        client.Screen.Reload(generalData);
                        if (client.Entity.MapID == 1005)
                        {
                            if (new_X == 42 && new_Y == 51)//stig
                            {
                                if (!client.Entity.ContainsFlag(Update.Flags.Stigma) && !client.Entity.ContainsFlag(Update.Flags.Ghost))
                                {
                                    SpellUse suse = new SpellUse(true);
                                    suse.Attacker = client.Entity.UID;
                                    suse.SpellID = 1095;
                                    suse.SpellLevel = 3;
                                    suse.X = 42;
                                    suse.Y = 51;
                                    suse.Targets.Add(client.Entity.UID, 0);
                                    client.Entity.AddFlag(Update.Flags.Stigma);
                                    client.Entity.StigmaStamp = Time32.Now;
                                    client.Entity.StigmaIncrease = 25;
                                    client.Entity.StigmaTime = 20;
                                    client.SendScreen(suse, true);
                                    if (client.Entity.EntityFlag == PhoenixProject.Game.EntityFlag.Player)
                                        client.Send(ServerBase.Constants.Stigma(25, 20));
                                }
                            }
                            else
                            {
                                if (new_X == 42 && new_Y == 48)//rev
                                {
                                    if (client.Entity.ContainsFlag(Update.Flags.Ghost))
                                    {
                                        SpellUse suse = new SpellUse(true);
                                        suse.Attacker = client.Entity.UID;
                                        suse.SpellID = 1050;
                                        suse.SpellLevel = 0;
                                        suse.X = 42;
                                        suse.Y = 48;
                                        suse.Targets.Add(client.Entity.UID, 0);
                                        client.SendScreen(suse, true);
                                        client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
                                        client.ReviveStamp = Time32.Now;
                                        client.Attackable = false;
                                        client.Entity.TransformationID = 0;
                                        client.Entity.RemoveFlag(Update.Flags.Dead);
                                        client.Entity.RemoveFlag(Update.Flags.Ghost);
                                        client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                                        client.Entity.Ressurect();

                                    }
                                }

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

                        }

                        if (client.Entity.InteractionInProgress && client.Entity.InteractionSet)
                        {
                            if (client.Entity.Body == 1003 || client.Entity.Body == 1004)
                            {
                                if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                                {
                                    Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];
                                    PhoenixProject.Network.GamePackets.Data general = new PhoenixProject.Network.GamePackets.Data(true);
                                    general.UID = ch.Entity.UID;
                                    general.wParam1 = new_X;
                                    general.wParam2 = new_Y;
                                    general.ID = 0x9c;
                                    ch.Send(general.ToArray());
                                    ch.Entity.Action = Game.Enums.ConquerAction.Jump;
                                    ch.Entity.X = new_X;
                                    ch.Entity.Y = new_Y;
                                    ch.Entity.Facing = ServerBase.Kernel.GetAngle(ch.Entity.X, ch.Entity.Y, new_X, new_Y);
                                    ch.SendScreen(generalData, true);
                                    ch.Screen.Reload(general);
                                    client.SendScreen(generalData, true);
                                    client.Screen.Reload(general);
                                }
                            }
                        }
                    }
                    else
                    {
                        client.Disconnect();
                    }
                }
                else
                {
                    if (client.Entity.Mode == Game.Enums.Mode.None)
                    {
                        client.Entity.Teleport(client.Map.ID, client.Entity.X, client.Entity.Y);
                    }
                }
            }
            else
            {
                if (ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
                {
                    client.Entity.Action = Game.Enums.ConquerAction.Jump;
                    client.Entity.Facing = ServerBase.Kernel.GetAngle(generalData.wParam1, generalData.wParam2, new_X, new_Y);
                    client.Entity.X = new_X;
                    client.Entity.Y = new_Y;
                    client.SendScreen(generalData, true);
                    client.Screen.Reload(generalData);
                }
                else
                {
                    client.Disconnect();
                }
            }
            client.Entity.MapRegion = Region.Region.FindRegion((uint)client.Map.BaseID, client.Entity.X, client.Entity.Y);
        }
Пример #3
0
        static void PlayerJump(Data generalData, Client.GameState client)
        {
            //DateTime timer = DateTime.Now;
            //if (timer >  ManagedThreadPoolChecker.timer.AddSeconds(10))
            //{
            //    Program.startpool();
            //}
            client.Entity.Action = Conquer_Online_Server.Game.Enums.ConquerAction.None;
            client.Mining = false;
            if (client.Entity.ContainsFlag(Update.Flags.CastPray))
            {
                client.Entity.RemoveFlag(Update.Flags.CastPray);
                foreach (var Client in client.Prayers)
                {
                    if (Client.Entity.ContainsFlag(Update.Flags.Praying))
                    {
                        Client.Entity.RemoveFlag(Update.Flags.Praying);
                    }
                }
                client.Prayers.Clear();
            }

            if (client.Entity.ContainsFlag(Update.Flags.Praying))
            {
                client.Entity.RemoveFlag(Update.Flags.Praying);
                if (client.PrayLead != null)
                {
                    client.PrayLead.Prayers.Remove(client);
                    client.PrayLead = null;
                }
            }
            Time32 Now = Time32.Now;

            client.Attackable = true;
            if (client.Entity.AttackPacket != null)
            {
                client.Entity.AttackPacket = null;
            }
            if (client.Entity.Dead)
            {
                if (Now > client.Entity.DeathStamp.AddSeconds(4))
                {
                    client.Disconnect();
                    return;
                }
            }

            ushort new_X = (ushort)(generalData.dwParam & 0xFFFF);
            ushort new_Y = (ushort)(generalData.dwParam >> 16);

            if (client.lastJumpDistance == 0) goto Jump;
            if (client.Entity.ContainsFlag(Update.Flags.Ride))
            {
                int distance = ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
                ushort take = (ushort)(1.5F * (distance / 2));
                if (client.Entity.Vigor >= take)
                {
                    client.Entity.Vigor -= take;
                    Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
                    vigor.VigorValue = client.Entity.Vigor;
                    vigor.Send(client);
                }
                else
                {
                    //client.Entity.Shift(client.Entity.X, client.Entity.Y);
                    //return;
                }
            }
            client.LastJumpTime = (int)ServerBase.Kernel.maxJumpTime(client.lastJumpDistance);
            int a1 = Now.GetHashCode() - client.lastJumpTime.GetHashCode();
            int a2 = generalData.TimeStamp.GetHashCode() - client.lastClientJumpTime.GetHashCode();
            bool DOO = false;
            if (a2 - a1 > 1000) DOO = true;
            if (Now < client.lastJumpTime.AddMilliseconds(client.LastJumpTime))
            {
                bool doDisconnect = false;
                if (client.Entity.Transformed)
                    if (client.Entity.TransformationID != 207 && client.Entity.TransformationID != 267)
                        doDisconnect = true;
                if (client.Entity.Transformed && doDisconnect)
                {
                    //client.Entity.Shift(client.Entity.X, client.Entity.Y);
                    //return;
                }
                if (client.Entity.Transformed && !doDisconnect)
                {
                    goto Jump;
                }
                if (!client.Entity.OnCyclone() && !client.Entity.ContainsFlag(Update.Flags.Oblivion) && !client.Entity.ContainsFlag(Update.Flags.Ride) && !DOO)
                {
                    //client.Entity.Shift(client.Entity.X, client.Entity.Y);
                    //return;
                }
                else if (client.Entity.ContainsFlag(Update.Flags.Ride))
                {
                    int time = (int)ServerBase.Kernel.maxJumpTime(client.lastJumpDistance);
                    int speedprc = Database.DataHolder.SteedSpeed(client.Equipment.TryGetItem(ConquerItem.Steed).Plus);
                    if (speedprc != 0)
                    {
                        if (Now < client.lastJumpTime.AddMilliseconds(time - (time * speedprc / 100)))
                        {
                            //client.Entity.Shift(client.Entity.X, client.Entity.Y);
                            //return;
                        }
                    }
                    else
                    {
                        //client.Entity.Shift(client.Entity.X, client.Entity.Y);
                        //return;
                    }
                }
            }
            Jump:
            client.lastJumpDistance = ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
            client.lastClientJumpTime = generalData.TimeStamp;
            client.lastJumpTime = Now;
            Game.Map Map = client.Map;
            if (Map != null)
            {
                if (Map.Floor[new_X, new_Y, Game.MapObjectType.Player, null])
                {
                    if (ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
                    {
                        client.Entity.Action = Game.Enums.ConquerAction.Jump;
                        client.Entity.Facing = ServerBase.Kernel.GetAngle(generalData.wParam1, generalData.wParam2, new_X, new_Y);
                        client.Entity.PX = client.Entity.X;
                        client.Entity.PY = client.Entity.Y;
                        client.Entity.X = new_X;
                        client.Entity.Y = new_Y;
                        client.SendScreen(generalData, true);
                        client.Screen.Reload(generalData);

                        if (client.Entity.InteractionInProgress && client.Entity.InteractionSet)
                        {
                            if (client.Entity.Body == 1003 || client.Entity.Body == 1004)
                            {
                                if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                                {
                                    Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];
                                    Conquer_Online_Server.Network.GamePackets.Data general = new Conquer_Online_Server.Network.GamePackets.Data(true);
                                    general.UID = ch.Entity.UID;
                                    general.wParam1 = new_X;
                                    general.wParam2 = new_Y;
                                    general.ID = 0x9c;
                                    ch.Send(general.ToArray());
                                    ch.Entity.Action = Game.Enums.ConquerAction.Jump;
                                    ch.Entity.X = new_X;
                                    ch.Entity.Y = new_Y;
                                    ch.Entity.Facing = ServerBase.Kernel.GetAngle(ch.Entity.X, ch.Entity.Y, new_X, new_Y);
                                    ch.SendScreen(generalData, true);
                                    ch.Screen.Reload(general);
                                    client.SendScreen(generalData, true);
                                    client.Screen.Reload(general);
                                }
                            }
                        }
                    }
                    else
                    {
                        client.Disconnect();
                    }
                }
                else
                {
                    if (client.Entity.Mode == Game.Enums.Mode.None)
                    {
                        client.Entity.Teleport(client.Map.ID, client.Entity.X, client.Entity.Y);
                    }
                }
            }
            else
            {
                if (ServerBase.Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
                {
                    client.Entity.Action = Game.Enums.ConquerAction.Jump;
                    client.Entity.Facing = ServerBase.Kernel.GetAngle(generalData.wParam1, generalData.wParam2, new_X, new_Y);
                    client.Entity.X = new_X;
                    client.Entity.Y = new_Y;
                    client.SendScreen(generalData, true);
                    client.Screen.Reload(generalData);
                }
                else
                {
                    client.Disconnect();
                }
            }
        }
Пример #4
0
        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
            }
        }
        public void _timerCallBack(object obj, System.Timers.ElapsedEventArgs arg)
        {
            try
            {
                Time32 Now = Time32.Now;
                if (this == null || Owner == null)
                {
                    Owner.Disconnect();
                    return;
                }
                if (this == null || Owner == null)
                    return;
                if (Owner.Screen == null || Owner.Entity == null)
                {
                    Owner.Disconnect();
                }
                if (Owner != null)
                {

                    if (this.HandleTiming)
                    {

                      #region Training points
                        if (HeavenBlessing > 0 && !Dead)
                        {
                            if (Now > Owner.LastTrainingPointsUp.AddMinutes(10))
                            {
                                Owner.OnlineTrainingPoints += 10;
                                if (Owner.OnlineTrainingPoints >= 30)
                                {
                                    Owner.OnlineTrainingPoints -= 30;
                                    Owner.IncreaseExperience(Owner.ExpBall / 100, false);
                                }
                                Owner.LastTrainingPointsUp = Now;
                                Update(Network.GamePackets.Update.OnlineTraining, Owner.OnlineTrainingPoints, false);
                            }
                        }
                        #endregion
                        #region Minning
                        if (Owner.Mining && !Dead)
                        {
                            if (Now >= Owner.MiningStamp.AddSeconds(2))
                            {
                                Owner.MiningStamp = Now;
                                Game.ConquerStructures.Mining.Mine(Owner);
                            }
                        }
                        #endregion
                        #region MentorPrizeSave
                        if (Now > Owner.LastMentorSave.AddSeconds(5))
                        {
                            Database.KnownPersons.SaveApprenticeInfo(Owner.AsApprentice);
                            Owner.LastMentorSave = Now;
                        }
                        #endregion
                        #region Attackable
                        if (Owner.JustLoggedOn)
                        {
                            Owner.JustLoggedOn = false;
                            Owner.ReviveStamp = Now;
                        }
                        if (!Owner.Attackable)
                        {
                            if (Now > Owner.ReviveStamp.AddSeconds(5))
                            {
                                Owner.Attackable = true;
                            }
                        }
                        #endregion
                        #region DoubleExperience
                        if (Owner.Entity.DoubleExperienceTime > 0)
                        {
                            if (Now > Owner.Entity.DoubleExpStamp.AddMilliseconds(1000))
                            {
                                Owner.Entity.DoubleExpStamp = Now;
                                Owner.Entity.DoubleExperienceTime--;
                            }
                        }
                        #endregion
                        #region HeavenBlessing
                        if (Owner.Entity.HeavenBlessing > 0)
                        {
                            if (Now > Owner.Entity.HeavenBlessingStamp.AddMilliseconds(1000))
                            {
                                Owner.Entity.HeavenBlessingStamp = Now;
                                Owner.Entity.HeavenBlessing--;
                            }
                        }
                        #endregion
                        #region Enlightment
                        if (Owner.Entity.EnlightmentTime > 0)
                        {
                            if (Now >= Owner.Entity.EnlightmentStamp.AddMinutes(1))
                            {
                                Owner.Entity.EnlightmentStamp = Now;
                                Owner.Entity.EnlightmentTime--;
                                if (Owner.Entity.EnlightmentTime % 10 == 0 && Owner.Entity.EnlightmentTime > 0)
                                    Owner.IncreaseExperience(Game.Attacking.Calculate.Percent((int)Owner.ExpBall, .10F), false);
                            }
                        }
                        #endregion
                        #region PKPoints
                        if (Now >= Owner.Entity.PKPointDecreaseStamp.AddMinutes(5))
                        {
                            Owner.Entity.PKPointDecreaseStamp = Now;
                            if (Owner.Entity.PKPoints > 0)
                            {
                                Owner.Entity.PKPoints--;
                            }
                            else
                                Owner.Entity.PKPoints = 0;
                        }
                        #endregion
                        #region OverHP
                        if (Owner.Entity.FullyLoaded)
                        {
                            if (Owner.Entity.Hitpoints > Owner.Entity.MaxHitpoints && Owner.Entity.MaxHitpoints > 1 && !Owner.Entity.Transformed)
                            {
                                Owner.Entity.Hitpoints = Owner.Entity.MaxHitpoints;
                            }
                        }
                        #endregion
                        #region Stamina
                        if (Now > this.StaminaStamp.AddMilliseconds(500))
                        {
                            if (Owner.Entity.Vigor < Owner.Entity.MaxVigor)
                            {
                                if (Owner.Entity.Vigor + 3 < Owner.Entity.MaxVigor)
                                {
                                    Owner.Entity.Vigor += (ushort)(3 + (Owner.Entity.Action == Game.Enums.ConquerAction.Sit ? 2 : 0));

                                    {
                                        Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
                                        vigor.VigorValue = Owner.Entity.Vigor;
                                        vigor.Send(Owner);
                                    }
                                }
                                else
                                {
                                    Owner.Entity.Vigor = (ushort)Owner.Entity.MaxVigor;

                                    {
                                        Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
                                        vigor.VigorValue = Owner.Entity.Vigor;
                                        vigor.Send(Owner);
                                    }
                                }
                            }
                            if (!this.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                            {
                                int limit = 0;
                                if (this.HeavenBlessing > 0)
                                    limit = 50;
                                if (this.Stamina != 100 + limit)
                                {
                                    if (this.Action == Game.Enums.ConquerAction.Sit || !this.Owner.Equipment.Free(18))
                                    {
                                        if (this.Stamina <= 93 + limit)
                                        {
                                            this.Stamina += 7;
                                        }
                                        else
                                        {
                                            if (this.Stamina != 100 + limit)
                                                this.Stamina = (byte)(100 + limit);
                                        }
                                    }
                                    else
                                    {
                                        if (this.Stamina <= 97 + limit)
                                        {
                                            this.Stamina += 3;
                                        }
                                        else
                                        {
                                            if (this.Stamina != 100 + limit)
                                                this.Stamina = (byte)(100 + limit);
                                        }
                                    }
                                }
                                this.StaminaStamp = Now;
                            }
                        }
                        #endregion
                        #region SoulShackle
                        if (Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.SoulShackle))
                        {
                            if (Now > Owner.Entity.ShackleStamp.AddSeconds(Owner.Entity.ShackleTime))
                            {
                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.SoulShackle);
                            }
                        }
                        #endregion
                        #region Freeze
                        if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags2.IceBlock))
                        {
                            if (Now > Owner.Entity.FreezeStamp.AddSeconds(Owner.Entity.FreezeTime))
                            {
                                Owner.Entity.RemoveFlag(Network.GamePackets.Update.Flags2.IceBlock);
                            }
                        }
                        #endregion
                        #region AzureShield
                        if (Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.AzureShield))
                        {
                            if (Now > Owner.Entity.MagicShieldStamp.AddSeconds(Owner.Entity.MagicShieldTime))
                            {
                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.AzureShield);
                            }
                        }
                        #endregion
                        #region Die Delay
                        if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Dead) && !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Ghost))
                        {
                            if (Now > Owner.Entity.DeathStamp.AddSeconds(2))
                            {
                                Owner.Entity.AddFlag(Network.GamePackets.Update.Flags.Ghost);
                                if (Owner.Entity.Body % 10 < 3)
                                    Owner.Entity.TransformationID = 99;
                                else
                                    Owner.Entity.TransformationID = 98;

                                Owner.SendScreenSpawn(Owner.Entity, true);
                            }
                        }
                        #endregion
                        #region SkillTeam
                        if (Owner.Entity.MapID == 7009)
                        {
                            if (Owner.Entity.MapID == 7009)
                            {
                                Game.KimoSkillWar.SkillTeamRes(Owner);
                            }
                        }
                        #endregion
                        #region CaptureFlag
                        if (Owner.Entity.MapID == 2060)
                        {
                            if (Owner.Entity.MapID == 2060)
                            {
                                Game.Team.CaptureRes(Owner);
                            }
                        }
                        #endregion

                    }
                }
                //AutoAttack();
            }
            catch { }
            {
            }
        }
        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 && attacker.MonsterInfo.SpellID != 1050)
                        return;

                    if (attacker.MonsterInfo.SpellID == 0)// from this bracket to the next die delay replce this with urs
                    {
                        attack = new Attack(true);
                        attack.Effect1 = Attack.AttackEffects1.None;
                        uint damage = Calculate.Melee(attacker, attacked, ref attack);
                        attack.Attacker = attacker.UID;
                        attack.Attacked = attacked.UID;
                        attack.AttackType = Attack.Melee;
                        attack.Damage = damage;
                        attack.X = attacked.X;
                        attack.Y = attacked.Y;
                        BlessEffect.Effect(attacked);
                        if (attacked.EntityFlag == EntityFlag.Player)
                        {
                            if (attacked.Action == Enums.ConquerAction.Sit)
                                if (attacked.Stamina > 20)
                                    attacked.Stamina -= 20;
                                else
                                    attacked.Stamina = 0;
                            attacked.Action = Enums.ConquerAction.None;
                            //Console.WriteLine("ssS");
                        }
                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Owner.SendScreen(attack, true);
                            attacked.Die(attacker);
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                            attacked.Owner.SendScreen(attack, true);
                        }
                    }
                    else
                    {
                        SpellUse suse = new SpellUse(true);
                        attack = new Attack(true);
                        attack.Effect1 = Attack.AttackEffects1.None;
                        uint damage = Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0, ref attack);
                        suse.Effect1 = attack.Effect1;
                        if (attacked.EntityFlag == EntityFlag.Player)
                        {
                            if (attacked.Action == Enums.ConquerAction.Sit)
                                if (attacked.Stamina > 20)
                                    attacked.Stamina -= 20;
                                else
                                    attacked.Stamina = 0;
                            attacked.Action = Enums.ConquerAction.None;
                            //Console.WriteLine("ssS");
                        }
                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Die(attacker);
                        }
                        else
                        {
                            attacked.Hitpoints -= damage;
                        }
                        if (attacker.Companion)
                            attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), 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)
                    {
                        attack = new Attack(true);
                        attack.Effect1 = Attack.AttackEffects1.None;
                        uint damage = Calculate.Melee(attacker, attacked, ref attack);
                        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
                    {
                        SpellUse suse = new SpellUse(true);
                        if (attack != null) attack.Effect1 = Attack.AttackEffects1.None;
                        uint damage = Calculate.Magic(attacker, attacked, attacker.MonsterInfo.SpellID, 0, ref attack);
                        if (attack != null) suse.Effect1 = attack.Effect1;

                        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);

                                    foreach (Client.GameState client in ServerBase.Kernel.GamePool.Values)
                                    {
                                        client.Send(message);
                                    }

                                    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
                #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 = 1;

                    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.Owner.Equipment.TryGetItem(18) == null)
                    {
                        if (attack.AttackType != Attack.Magic)
                            attacker.RemoveFlag(Update.Flags.Ride);
                        else
                            if (!(SpellID == 7003 || SpellID == 7002))
                                attacker.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);


                    #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);
                        for (int c = 0; c < attacker.Owner.Screen.Objects.Count; c++)
                        {
                            if (c >= attacker.Owner.Screen.Objects.Count)
                                break;
                            //List<IMapObject> list = new List<IMapObject>();
                            IMapObject obj = attacker.Owner.Screen.Objects[c];
                            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(30))
                                {
                                    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))
                        {
                            if (!attacker.Owner.AlternateEquipment)
                            {
                                CheckForExtraWeaponPowers(attacker.Owner, attacked);
                            }
                            else
                            {
                                CheckForExtraWeaponPowers2(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)
                            {
                                attack.Effect1 = Attack.AttackEffects1.None;
                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, ref attack);
                                attack.Damage = damage;
                                if (attacker.OnFatalStrike())
                                {
                                    if (attacked.EntityFlag == EntityFlag.Monster)
                                    {
                                        if (!attacker.Owner.AlternateEquipment)
                                        {
                                            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 (!attacker.Owner.Equipment.Free((byte)ConquerItem.RightWeapon))
                                                if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.RightWeapon).ID / 1000 == 511)
                                                    can = true;
                                            if (!attacker.Owner.Equipment.Free((byte)ConquerItem.LeftWeapon))
                                                if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.LeftWeapon).ID / 1000 == 511)
                                                    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;
                                        }
                                        else
                                        {
                                            bool can = false;
                                            if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltRightHand))
                                                if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltRightHand).ID / 1000 == 601)
                                                    can = true;
                                            if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltLeftHand))
                                                if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltLeftHand).ID / 1000 == 601)
                                                    can = true;
                                            if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltRightHand))
                                                if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltRightHand).ID / 1000 == 511)
                                                    can = true;
                                            if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltLeftHand))
                                                if (attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltLeftHand).ID / 1000 == 511)
                                                    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.AlternateEquipment)
                                {
                                    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 = 420;
                                        }
                                        if (wep1subyte == 511)
                                        {
                                            wep1bs = true;
                                            wep1subyte = 601;
                                        }*/
                                        ushort wep1spellid = 0, wep2spellid = 0;
                                        if (Database.SpellTable.WeaponSpells.ContainsKey(wep1subyte))
                                        {
                                            wep1spellid = Database.SpellTable.WeaponSpells[wep1subyte];
                                        }
                                        /*if (wep1subyte == 601 || wep1subyte == 511)
                                        {
                                            if (Database.SpellTable.WeaponSpells.ContainsKey(11230))
                                            {
                                                wep1spellid = 11230;
                                            }
                                        }*/
                                        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];
                                            if (wep1spell != null)
                                            {
                                                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 = 420;
                                                 }
                                                 if (wep2subyte == 511)
                                                 {
                                                     wep2bs = true;
                                                     wep2subyte=601;
                                                 }*/
                                                if (wep2subyte == 900 || leftweapon.ID == 1050002)
                                                {
                                                    return;
                                                }

                                                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];
                                                    if (wep2spell != null)
                                                    {
                                                        doWep2Spell = ServerBase.Kernel.Rate(wep2spell.Percent);
                                                    }

                                                }

                                            }
                                        }

                                        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);
                                                }
                                        }
                                    }
                                }
                                else
                                {
                                    if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltRightHand))
                                    {
                                        Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltRightHand);
                                        ushort wep1subyte = (ushort)(rightweapon.ID / 1000), wep2subyte = 0;
                                        bool wep1bs = false, wep2bs = false;
                                        /* if (wep1subyte == 421)
                                         {
                                             wep1bs = true;
                                             wep1subyte = 420;
                                         }
                                         if (wep1subyte == 511)
                                         {
                                             wep1bs = true;
                                             wep1subyte = 601;
                                         }*/

                                        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.AltLeftHand))
                                            {
                                                Interfaces.IConquerItem leftweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltLeftHand);
                                                wep2subyte = (ushort)(leftweapon.ID / 1000);
                                                /* if (wep2subyte == 421)
                                                 {
                                                     wep2bs = true;
                                                     wep2subyte = 420;
                                                 }
                                                 if (wep2subyte == 511)
                                                 {
                                                     wep2bs = true;
                                                     wep2subyte = 601;
                                                 }*/
                                                if (wep2subyte == 900 || leftweapon.ID == 1050002)
                                                {
                                                    return;
                                                }
                                                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 = 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))
                        {
                            // Console.WriteLine("Ss");
                            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)
                                {
                                    attack.Effect1 = Attack.AttackEffects1.None;
                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);

                                    if (!attacker.Owner.AlternateEquipment)
                                    {
                                        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=420;
                                             }
                                             if (wep1subyte == 511)
                                             {
                                                 wep1bs = true;
                                                 wep1subyte=601;
                                             }*/
                                            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 = 420;
                                                     }
                                                     if (wep2subyte == 511)
                                                     {
                                                         wep2bs = true;
                                                         wep2subyte = 601;
                                                     }*/
                                                    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);
                                                            }
                                                        }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltRightHand))
                                        {
                                            Interfaces.IConquerItem rightweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltRightHand);
                                            ushort wep1subyte = (ushort)(rightweapon.ID / 1000), wep2subyte = 0;
                                            bool wep1bs = false, wep2bs = false;
                                            /*if (wep1subyte == 421)
                                            {
                                                wep1bs = true;
                                                wep1subyte = 420;
                                            }
                                            if (wep1subyte == 511)
                                            {
                                                wep1bs = true;
                                                wep1subyte = 601;
                                            }*/
                                            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.AltLeftHand))
                                                {
                                                    Interfaces.IConquerItem leftweapon = attacker.Owner.Equipment.TryGetItem((byte)ConquerItem.AltLeftHand);
                                                    wep2subyte = (ushort)(leftweapon.ID / 1000);
                                                    /* if (wep2subyte == 421)
                                                     {
                                                         wep2bs = true;
                                                         wep2subyte = 420;
                                                     }
                                                     if (wep2subyte == 511)
                                                     {
                                                         wep2bs = true;
                                                         wep2subyte = 601;
                                                     }*/
                                                    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))
                        {
                            if (!attacker.Owner.AlternateEquipment)
                            {
                                CheckForExtraWeaponPowers(attacker.Owner, attacked);
                            }
                            else
                            {
                                CheckForExtraWeaponPowers2(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.AlternateEquipment)
                            {
                                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);
                                    }
                                }
                            }
                            else
                            {
                                if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltLeftHand))
                                {
                                    Interfaces.IConquerItem arrow = attacker.Owner.Equipment.TryGetItem(ConquerItem.AltLeftHand);
                                    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.AltLeftHand), attacker.Owner);
                                    }
                                }
                            }
                            if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attacked.X, attacked.Y) <= ServerBase.Constants.pScreenDistance)
                            {
                                attack.Effect1 = Attack.AttackEffects1.None;
                                uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked, ref attack);

                                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.AlternateEquipment)
                                    {
                                        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);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!attacker.Owner.Equipment.Free((byte)ConquerItem.AltLeftHand))
                                        {
                                            Interfaces.IConquerItem arrow = attacker.Owner.Equipment.TryGetItem(ConquerItem.AltLeftHand);
                                            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.AltLeftHand), attacker.Owner);
                                            }
                                        }
                                    }
                                }
                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= ServerBase.Constants.pScreenDistance)
                                {
                                    attack.Effect1 = Attack.AttackEffects1.None;
                                    uint damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob, ref attack);
                                    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)
                    {
                        if (!attacker.Owner.AlternateEquipment)
                        {
                            CheckForExtraWeaponPowers(attacker.Owner, attacked);
                        }
                        else
                        {
                            CheckForExtraWeaponPowers2(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, PhoenixProject.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 && spell.ID != 10425)
                                {
                                    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 == 1)
                                    {
                                        if (attacked.MonsterInfo.InSight == 0)
                                        {
                                            attacked.MonsterInfo.InSight = attacker.UID;
                                        }
                                    }
                                }
                            }
                            if (!attacker.Owner.Spells.ContainsKey(spellID))
                            {
                                if (spellID != 6012)
                                    return;
                            }
                            if (spell != null)
                            {
                                if (!attacker.Owner.AlternateEquipment)
                                {
                                    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;
                                        }
                                    }
                                    else
                                    {
                                        if (spell.OnlyWithThisWeaponSubtype != 0)
                                        {
                                            uint firstwepsubtype, secondwepsubtype;

                                            if (!attacker.Owner.Equipment.Free(24))
                                            {
                                                firstwepsubtype = attacker.Owner.Equipment.Objects[23].ID / 1000;
                                                if (!attacker.Owner.Equipment.Free(24) && attacker.Owner.Equipment.Objects[24] != null)
                                                {
                                                    secondwepsubtype = attacker.Owner.Equipment.Objects[24].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;
                                            }
                                        }

                                    }
                                }
                                if (attacker.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.Coder)
                                {
                                    attacker.Owner.Send(new Message("Spell ID: " + spellID, System.Drawing.Color.CadetBlue, Message.Talk));
                                }
                                switch (spellID)
                                {
                                    #region Single magic damage spells
                                    case 1000:
                                    case 1001:
                                    case 1002:
                                    case 1150:
                                    case 1160:
                                    case 1180:
                                    case 1320:
                                    case 10310:
                                    case 11180:
                                        //case 11040:
                                        //case 10381:
                                        {
                                            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);

                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);
                                                            suse.Effect1 = attack.Effect1;

                                                            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);
                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell, ref attack);
                                                            suse.Effect1 = attack.Effect1;

                                                            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 (attacker.MapID == 2071)
                                                        break;
                                                    if (attacker.MapID == 1509)
                                                        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 == 1)
                                                    {
                                                        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.Constants.revnomap.Contains(attacker.MapID))
                                                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.Action = PhoenixProject.Game.Enums.ConquerAction.None;
                                                    //attacked.Owner.ReviveStamp = Time32.Now;
                                                    //attacked.Owner.Attackable = false;

                                                    attacked.Owner.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
                                                    attacked.Owner.ReviveStamp = Time32.Now;
                                                    attacked.Owner.Attackable = false;

                                                    attacked.Owner.Entity.TransformationID = 0;
                                                    attacked.Owner.Entity.RemoveFlag(Update.Flags.Dead);
                                                    attacked.Owner.Entity.RemoveFlag(Update.Flags.Ghost);
                                                    attacked.Owner.Entity.Hitpoints = attacked.Owner.Entity.MaxHitpoints;

                                                    attacked.Ressurect();

                                                    attacked.Owner.SendScreen(suse, true);
                                                }
                                            }
                                            break;
                                        }
                                    #endregion
                                    #region Linear spells
                                    case 1045:
                                    case 1046:
                                    // case 11110:
                                    case 1260:
                                    case 11000:
                                    case 11005:
                                        {

                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                Game.Attacking.InLineAlgorithm ila = new PhoenixProject.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;
                                                int xx = 0;
                                                int yy = 0;
                                                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 (attacked.X != xx && attacked.Y != yy)
                                                            {
                                                                if (!CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                    continue;

                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                                suse.Effect1 = attack.Effect1;

                                                                attack.Damage = damage;
                                                                xx = attacked.X;
                                                                yy = attacked.Y;
                                                                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;

                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                            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 BladeTempst

                                    case 11110:
                                        {

                                            bool yes = true;
                                            Game.Map Map = attacker.Owner.Map;
                                            // ushort rr = ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y);
                                            Game.Attacking.InLineAlgorithm ila = new PhoenixProject.Game.Attacking.InLineAlgorithm(attacker.X,
                                               X, attacker.Y, Y, (byte)ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y), InLineAlgorithm.Algorithm.DDA);
                                            List<InLineAlgorithm.coords>.Enumerator enumerator6;
                                            ushort x = 0;
                                            ushort y = 0;
                                            using (enumerator6 = ila.getCoords.GetEnumerator())
                                            {
                                                while (enumerator6.MoveNext())
                                                {
                                                    if (yes)
                                                    {
                                                        Func<IMapObject, bool> func4 = null;
                                                        InLineAlgorithm.coords coord = enumerator6.Current;

                                                        if (Map.Floor[coord.X, coord.Y, Game.MapObjectType.Player, null])
                                                        {
                                                            if (attacker.MapID == 1038)
                                                            {
                                                                if (attacker.X > 223 && attacker.Y < 185 && coord.X < 224)
                                                                {
                                                                    // Console.WriteLine(" r " + PhoenixProject.Game.ConquerStructures.Society.GuildWar.RightGate.Mesh + "");
                                                                    if (PhoenixProject.Game.ConquerStructures.Society.GuildWar.RightGate.Mesh == 271)
                                                                    {
                                                                        yes = false;
                                                                    }
                                                                    else
                                                                    {
                                                                        yes = true;
                                                                        x = (ushort)coord.X;
                                                                        y = (ushort)coord.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((ushort)coord.X, (ushort)coord.Y, attacked.X, attacked.Y) <= 1)
                                                                                {
                                                                                    attacked.CanBlade = true;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    //Console.WriteLine(" r " + PhoenixProject.Game.ConquerStructures.Society.GuildWar.LeftGate.Mesh + "");
                                                                    if (attacker.X < 170 && attacker.Y > 210 && coord.Y < 211)
                                                                    {
                                                                        if (PhoenixProject.Game.ConquerStructures.Society.GuildWar.LeftGate.Mesh == 241)
                                                                        {
                                                                            yes = false;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        yes = true;
                                                                        x = (ushort)coord.X;
                                                                        y = (ushort)coord.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((ushort)coord.X, (ushort)coord.Y, attacked.X, attacked.Y) <= 1)
                                                                                {
                                                                                    attacked.CanBlade = true;
                                                                                }
                                                                            }
                                                                        }
                                                                    }

                                                                }



                                                            }
                                                            else
                                                            {
                                                                yes = true;
                                                                x = (ushort)coord.X;
                                                                y = (ushort)coord.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((ushort)coord.X, (ushort)coord.Y, attacked.X, attacked.Y) <= 1)
                                                                        {
                                                                            attacked.CanBlade = true;
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                        }
                                                        else
                                                        {
                                                            yes = false;
                                                        }
                                                    }
                                                }
                                            }
                                            yes = true;
                                            X = x;
                                            Y = y;

                                            if (Map.Floor[X, Y, Game.MapObjectType.Player, null] && yes)
                                            {
                                                if (CanUseSpell(spell, attacker.Owner))
                                                {
                                                    PrepareSpell(spell, attacker.Owner);

                                                    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;
                                                    int xx = 0;
                                                    int yy = 0;
                                                    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 (attacked.CanBlade)
                                                            {

                                                                // if (attacked.X != xx && attacked.Y != yy)
                                                                // {
                                                                if (!CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                    continue;

                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                               // uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                                suse.Effect1 = attack.Effect1;

                                                                attack.Damage = damage;
                                                                // xx = attacked.X;
                                                                // yy = attacked.Y;
                                                                ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                                suse.Targets.Add(attacked.UID, damage);
                                                                attacked.CanBlade = false;
                                                                if (!attacked.Dead)
                                                                {
                                                                    if (attacker.Owner.Spells.ContainsKey(11120))
                                                                    {
                                                                        BlackSpot spot = new BlackSpot
                                                                        {
                                                                            Remove = 0,
                                                                            Identifier = attacked.UID
                                                                        };
                                                                        attacker.Owner.Send((byte[])spot);

                                                                        attacked.BlackSpotTime = Time32.Now;
                                                                        attacked.BlackSpotTime2 = 8;
                                                                        attacked.BlackSpots = true;
                                                                        attacker.Owner.IncreaseSpellExperience(80, 11120);
                                                                    }
                                                                }
                                                                // }
                                                            }
                                                        }
                                                        else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                        {
                                                            attackedsob = _obj as SobNpcSpawn;

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

                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                                damage = (uint)(damage * spell.PowerPercent);
                                                                attack.Damage = damage;

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

                                                                suse.Targets.Add(attackedsob.UID, damage);
                                                            }
                                                        }
                                                    }
                                                    attacker.X = X;
                                                    attacker.Y = Y;
                                                    attacker.Owner.SendScreen(attack, true);
                                                    attacker.Owner.SendScreen(suse, true);
                                                    attacker.Owner.Screen.Reload(attack);
                                                }
                                            }
                                            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)
                                                {
                                                    attacker.FatalStrikeStamp = Time32.Now;
                                                    attacker.FatalStrikeTime = 60;
                                                    attacker.AddFlag(Update.Flags.FatalStrike);
                                                    attacker.RemoveFlag(Update.Flags.Ride);
                                                }
                                                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 11170:
                                    case 10315:
                                    case 11190:
                                        //case 11050:
                                        {
                                            // Console.WriteLine("xx3");
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                //Console.WriteLine("x4");
                                                PrepareSpell(spell, attacker.Owner);
                                                //Console.WriteLine("xx5");
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                UInt16 ox, oy;
                                                ox = attacker.X;
                                                oy = attacker.Y;
                                                if (spellID == 10315 || spellID == 11190)
                                                {
                                                    /* if (attacker.MapID == 1950)
                                                     {
                                                         break;
                                                     }*/
                                                    bool yes = true;
                                                    Game.Map Map = attacker.Owner.Map;

                                                    Game.Attacking.InLineAlgorithm ila = new PhoenixProject.Game.Attacking.InLineAlgorithm(attacker.X,
                                                       X, attacker.Y, Y, (byte)spell.Range, InLineAlgorithm.Algorithm.DDA);
                                                    List<InLineAlgorithm.coords>.Enumerator enumerator6;
                                                    ushort x = 0;
                                                    ushort y = 0;
                                                    using (enumerator6 = ila.getCoords.GetEnumerator())
                                                    {
                                                        while (enumerator6.MoveNext())
                                                        {
                                                            if (yes)
                                                            {
                                                                Func<IMapObject, bool> func4 = null;
                                                                InLineAlgorithm.coords coord = enumerator6.Current;
                                                                if (Map.Floor[coord.X, coord.Y, Game.MapObjectType.Player, null])
                                                                {
                                                                    if (attacker.MapID == 1038)
                                                                    {
                                                                        if (attacker.X > 223 && attacker.Y < 185 && coord.X < 224)
                                                                        {
                                                                            // Console.WriteLine(" r " + PhoenixProject.Game.ConquerStructures.Society.GuildWar.RightGate.Mesh + "");
                                                                            if (PhoenixProject.Game.ConquerStructures.Society.GuildWar.RightGate.Mesh == 271)
                                                                            {
                                                                                yes = false;
                                                                            }
                                                                            else
                                                                            {
                                                                                yes = true;
                                                                                x = (ushort)coord.X;
                                                                                y = (ushort)coord.Y;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            //Console.WriteLine(" r " + PhoenixProject.Game.ConquerStructures.Society.GuildWar.LeftGate.Mesh + "");
                                                                            if (attacker.X < 170 && attacker.Y > 210 && coord.Y < 211)
                                                                            {
                                                                                if (PhoenixProject.Game.ConquerStructures.Society.GuildWar.LeftGate.Mesh == 241)
                                                                                {
                                                                                    yes = false;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                yes = true;
                                                                                x = (ushort)coord.X;
                                                                                y = (ushort)coord.Y;
                                                                            }

                                                                        }


                                                                    }
                                                                    else
                                                                    {
                                                                        yes = true;
                                                                        x = (ushort)coord.X;
                                                                        y = (ushort)coord.Y;
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    yes = false;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    yes = true;
                                                    X = x;
                                                    Y = y;

                                                    Attack npacket = new Attack(true);
                                                    npacket.Attacker = attacker.UID;
                                                    npacket.AttackType = 53;
                                                    npacket.X = X;
                                                    npacket.Y = Y;
                                                    Writer.WriteUInt16(spell.ID, 24, npacket.ToArray());
                                                    Writer.WriteByte(spell.Level, 26, npacket.ToArray());
                                                    attacker.Owner.SendScreen(npacket, true);
                                                    attacker.X = X;
                                                    attacker.Y = Y;
                                                    attacker.SendSpawn(attacker.Owner);
                                                    attacker.Owner.Screen.Reload(npacket);
                                                }

                                                List<IMapObject> objects = new List<IMapObject>();
                                                if (attacker.Owner.Screen.Objects.Count() > 0)
                                                    objects = GetObjects(ox, oy, attacker.Owner);
                                                if (objects != null)
                                                {
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Range)
                                                    {
                                                        if (spellID == 10315 || spellID == 11190)
                                                        {
                                                            foreach (IMapObject objs in objects.ToArray())
                                                            {
                                                                if (objs == null)
                                                                    continue;

                                                                if (objs.MapObjType == MapObjectType.Monster || objs.MapObjType == MapObjectType.Player)
                                                                {
                                                                    attacked = objs 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))
                                                                        {
                                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, ref attack);
                                                                            suse.Effect1 = attack.Effect1;
                                                                            if (spell.Power > 0)
                                                                            {
                                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                                damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                                                //damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);
                                                                                suse.Effect1 = attack.Effect1;
                                                                            }
                                                                            if (spell.ID == 8030)
                                                                            {
                                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                                damage = Game.Attacking.Calculate.Ranged(attacker, attacked, ref attack);
                                                                            }

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

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

                                                                            suse.Targets.Add(attackedsob.UID, damage);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            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))
                                                                        {
                                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, ref attack);
                                                                            suse.Effect1 = attack.Effect1;
                                                                            if (spell.Power > 0)
                                                                            {
                                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                                damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);
                                                                                suse.Effect1 = attack.Effect1;
                                                                            }
                                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                                            if (spell.ID == 8030)
                                                                                damage = Game.Attacking.Calculate.Ranged(attacker, attacked, ref attack);
                                                                            if (spell.ID == 1115)
                                                                                damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);


                                                                            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))
                                                                        {
                                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                                            if (spell.Power > 0)
                                                                                damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell, ref attack);
                                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                                            if (spell.ID == 8030)
                                                                                damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob, ref attack);

                                                                            suse.Effect1 = attack.Effect1;
                                                                            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:
                                    case 10405://this is not what I edited yesterday...
                                    case 30000:
                                    case 11160:
                                    case 11200:
                                        {
                                            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((int)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((int)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, (int)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, (int)spell.Duration));
                                                            }
                                                            else if (spell.ID == 11200)
                                                            {

                                                                if (attacker.ContainsFlag(Update.Flags.Ride))
                                                                {
                                                                    attacker.RemoveFlag(Update.Flags.Ride);
                                                                }
                                                                attacker.AddFlag3(Update.Flags3.MagicDefender);
                                                                attacker.MagicDefenderStamp = Time32.Now;
                                                                attacker.MagicDefenderIncrease = spell.PowerPercent;
                                                                attacker.MagicDefenderTime = (byte)spell.Duration;

                                                                if (attacker.EntityFlag == EntityFlag.Player)
                                                                {

                                                                    attacker.Owner.SendScreen(suse, true);
                                                                    SyncPacket packet = new SyncPacket
                                                                    {
                                                                        Identifier = attacker.UID,
                                                                        Count = 2,
                                                                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                                                                        StatusFlag1 = (ulong)attacker.StatusFlag,
                                                                        StatusFlag2 = (ulong)attacker.StatusFlag2,
                                                                        Unknown1 = 0x31,
                                                                        StatusFlagOffset = 0x80,
                                                                        Time = (uint)spell.Duration,
                                                                        Value = 10,
                                                                        Level = spell.Level
                                                                    };
                                                                    attacker.Owner.Send((byte[])packet);
                                                                }
                                                                break;
                                                            }
                                                            else if (spell.ID == 11160)
                                                            {
                                                                if (attacker.DefensiveStanceTime != 0)
                                                                {
                                                                    attacker.DefensiveStanceTime = 0;
                                                                    attacker.DefensiveStanceIncrease = 0;
                                                                    attacker.RemoveFlag2(Network.GamePackets.Update.Flags2.WarriorWalk);
                                                                }
                                                                else
                                                                {
                                                                    if (attacker.ContainsFlag(Update.Flags.Ride))
                                                                    {
                                                                        attacker.RemoveFlag(Update.Flags.Ride);
                                                                    }
                                                                    attacker.AddFlag2(Update.Flags2.WarriorWalk);
                                                                    attacker.DefensiveStanceStamp = Time32.Now;
                                                                    attacker.DefensiveStanceIncrease = spell.PowerPercent;
                                                                    attacker.DefensiveStanceTime = (byte)spell.Duration;

                                                                    if (attacker.EntityFlag == EntityFlag.Player)
                                                                    {
                                                                        attacker.Owner.Send(ServerBase.Constants.DefensiveStance(spell.Percent, (int)spell.Duration));

                                                                        attacker.Owner.SendScreen(suse, true);
                                                                    }
                                                                }
                                                                break;
                                                            }
                                                            else if (spell.ID == 30000)
                                                            {

                                                                if (attacked.ContainsFlag2(Update.Flags2.AzureShield))
                                                                {
                                                                    return;
                                                                }
                                                                //attack.AttackType = Attack.kimo2;
                                                                attacked.ShieldTime = 0;
                                                                attacked.ShieldStamp = Time32.Now;
                                                                attacked.MagicShieldStamp = Time32.Now;
                                                                attacked.MagicShieldTime = 0;
                                                                //Console.WriteLine("The Dodge is :" + attacked.Dodge.ToString());
                                                                attacked.AddFlag2(Update.Flags2.AzureShield);
                                                                attacked.MagicShieldStamp = Time32.Now;
                                                                attacked.AzureDamage = 12000;
                                                                //Console.WriteLine("AzureShiled granted " + 12000 + "  The Dodge is :" + attacked.Dodge.ToString());
                                                                attacked.MagicShieldIncrease = spell.PowerPercent;
                                                                attacked.MagicShieldTime = 60;
                                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                                {
                                                                    attacked.Owner.Send(ServerBase.Constants.AzureShield(12000, 30));

                                                                    SyncPacket packet4 = new SyncPacket
                                                                    {
                                                                        Identifier = attacked.UID,
                                                                        Count = 2,
                                                                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                                                                        StatusFlag1 = (ulong)attacked.StatusFlag,
                                                                        StatusFlag2 = (ulong)attacked.StatusFlag2,
                                                                        Unknown1 = 0x31,
                                                                        StatusFlagOffset = 0x5d,
                                                                        Time = (uint)60,
                                                                        Value = (uint)attacked.AzureDamage,
                                                                        Level = spell.Level
                                                                    };
                                                                    attacked.Owner.Send((byte[])packet4);
                                                                }
                                                            }
                                                            if (spell.ID == 10405 && attacked.Dead)
                                                            {
                                                                if ((attacked.BattlePower - attacker.BattlePower) >= 10)
                                                                    return;
                                                                attacked.AddFlag(Update.Flags.Dead);//Flag them as dead... should not be needed. This is no movement
                                                                attacked.ShackleStamp = Time32.Now;//Set stamp so source can remove the flag after X seconds
                                                                attacked.ShackleTime = (short)(30 + 15 * spell.Level);//double checking here. Could be db has this wrong.
                                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                                {
                                                                    attacked.Owner.Send(ServerBase.Constants.Shackled(attacked.ShackleTime));

                                                                    attacked.AddFlag2(Update.Flags2.SoulShackle);//Give them shackeld effect   

                                                                    SyncPacket packet3 = new SyncPacket
                                                                    {
                                                                        Identifier = attacked.UID,
                                                                        Count = 2,
                                                                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                                                                        StatusFlag1 = (ulong)attacked.StatusFlag,
                                                                        StatusFlag2 = (ulong)attacked.StatusFlag2,
                                                                        Unknown1 = 0x36,
                                                                        StatusFlagOffset = 0x6f,
                                                                        Time = (uint)spell.Duration,
                                                                        Value = 10,
                                                                        Level = spell.Level
                                                                    };
                                                                    attacked.Owner.Send((byte[])packet3);

                                                                }
                                                            }
                                                        }
                                                        attacker.Owner.IncreaseSpellExperience(Experience, spellID);
                                                        if (attacked.EntityFlag == EntityFlag.Player)
                                                            attacked.Owner.SendScreen(suse, true);
                                                        else
                                                            attacked.MonsterInfo.SendScreen(suse);

                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    #endregion
                                    #region Percent
                                    case 3050:
                                        // case 11230:
                                        {
                                            //Console.WriteLine("1");
                                            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 WeaponSpells
                                    #region Circle
                                    case 5010:
                                    case 7020:

                                        //case 11110:
                                        //case 10490:
                                        {

                                            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 (attacked.ContainsFlag(Update.Flags.Fly))
                                                                    return;
                                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                {
                                                                    PrepareSpell(spell, attacker.Owner);

                                                                    //attack.Effect1 = Attack.AttackEffects1.None;
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                                    //suse.Effect1 = attack.Effect1;

                                                                    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);
                                                                    // attack.Effect1 = Attack.AttackEffects1.None;
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                                    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:
                                    case 11140:
                                        //case 11230:
                                        {
                                            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, ref attack);
                                                                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, ref attack);
                                                                if (damage > attacked.Hitpoints)
                                                                    damage = attacked.Hitpoints;
                                                                ReceiveAttack(attacker, attacked, attack, damage, spell);

                                                                suse.Targets.Add(attacked.UID + c, damage);
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                            break;
                                        }
                                    case 1290:
                                    case 5030:
                                    case 5040:
                                    case 7000:
                                    case 7010:
                                    case 7030:
                                    case 7040:
                                    case 11230:
                                        //case 10381:

                                        //case 10490:
                                        {
                                            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);
                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                            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);

                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                            suse.Effect1 = attack.Effect1;

                                                            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))
                                                                {
                                                                    attack.Effect1 = Attack.AttackEffects1.None;
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                                    suse.Effect1 = attack.Effect1;

                                                                    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))
                                                                {
                                                                    attack.Effect1 = Attack.AttackEffects1.None;
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                                    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))
                                            {
                                                if (attacker.MapID == 1950)
                                                    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;
                                                attacked.FlyStamp = Time32.Now;
                                                attacked.FlyTime = (byte)spell.Duration;

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

                                                attacker.AddFlag(Update.Flags.Fly);
                                                attacker.RemoveFlag(Update.Flags.Ride);
                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                            break;
                                        }
                                    #endregion
                                    #region Pirate Spells
                                    #region Xp Skills
                                    case 10309: //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;
                                                if (!attacker.ContainsFlag2(Update.Flags2.ChainBoltActive))
                                                {
                                                    //attacker.RemoveFlag(Update.Flags.XPList);
                                                    attacker.ChainBoltStamp = Time32.Now;
                                                    attacker.ChainBoltTime = 30;
                                                    attacker.AddFlag2(Update.Flags2.ChainBoltActive);
                                                }

                                                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, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);
                                                                    if (spell.ID == 8030)
                                                                        damage = Game.Attacking.Calculate.Ranged(attacker, attacked, ref attack);
                                                                    ReceiveAttack(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, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell, ref attack);
                                                                    if (spell.ID == 8030)
                                                                        damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob, ref attack);
                                                                    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 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;
                                                if (!attacker.ContainsFlag2(Update.Flags2.CannonBraga))
                                                {
                                                    // attacker.RemoveFlag(Update.Flags.XPList);
                                                    attacker.CannonBarageStamp = Time32.Now;
                                                    attacker.Cannonbarage = 30;
                                                    attacker.AddFlag2(Update.Flags2.CannonBraga);
                                                }

                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= 10)
                                                {
                                                    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) <= 10)
                                                            {
                                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                {
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);
                                                                    if (spell.ID == 8030)
                                                                        damage = Game.Attacking.Calculate.Ranged(attacker, attacked, ref attack);
                                                                    ReceiveAttack(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) <= 10)
                                                            {
                                                                if (CanAttack(attacker, attackedsob, spell))
                                                                {
                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell, ref attack);
                                                                    if (spell.ID == 8030)
                                                                        damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob, ref attack);
                                                                    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;
                                                if (!attacker.ContainsFlag2(Update.Flags2.BlackBread))
                                                {
                                                    //attacker.RemoveFlag(Update.Flags.XPList);
                                                    attacker.BlackBeardStamp = Time32.Now;
                                                    attacker.Blackbeard = 30;
                                                    attacker.AddFlag2(Update.Flags2.BlackBread);
                                                }
                                                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, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);
                                                                    if (spell.ID == 8030)
                                                                        damage = Game.Attacking.Calculate.Ranged(attacker, attacked, ref attack);
                                                                    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, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell, ref attack);
                                                                    if (spell.ID == 8030)
                                                                        damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob, ref attack);
                                                                    ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                                    suse.Targets.Add(attackedsob.UID, damage);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                            break;
                                        }
                                    #endregion

                                    #region Auto On Skills
                                    case 11130: //Adrenaline Rush
                                        //case 11130: //BlackSpot
                                        {
                                            spell.RemoveCooldown(0x2b16);
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PhoenixProject.Network.GamePackets.Quest.Target target5 = new PhoenixProject.Network.GamePackets.Quest.Target
                                                {
                                                    Obj = attacker,
                                                    Damage = 0x2b16,
                                                    DamageType = HitType.NoDamage,
                                                    Hit = true
                                                };
                                                if (spell.CoolDown > 0)
                                                {
                                                    spell.AddCooldown(spell.ID, (int)spell.CoolDown);
                                                }


                                            }
                                            break;
                                        }
                                    #endregion // Doesnt Work // Doest 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) <= 5)
                                            {

                                                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;

                                                    Game.Map Map = ServerBase.Kernel.Maps[attacker.MapID];
                                                    if (Map.SelectCoordonates(ref X, ref Y))
                                                    {

                                                        //attacker.X = X;
                                                        // attacker.Y = Y;
                                                        if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= 5)
                                                        {
                                                            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(X, Y, attacked.X, attacked.Y) <= 1)
                                                                    {

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

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

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

                                    #region Single damage Skill
                                    case 11120:
                                        {
                                            if (attacked != null)
                                            {
                                                if (attacked.EntityFlag == EntityFlag.Player || attacked.EntityFlag == EntityFlag.Monster)
                                                {
                                                    if (!attacked.Dead)
                                                    {
                                                        BlackSpot spot = new BlackSpot
                                                        {
                                                            Remove = 0,
                                                            Identifier = attacked.UID
                                                        };
                                                        attacker.Owner.Send((byte[])spot);

                                                        attacked.BlackSpotTime = Time32.Now;
                                                        attacked.BlackSpotTime2 = 12;
                                                        attacked.BlackSpots = true;
                                                        attacker.Owner.IncreaseSpellExperience(80, 11120);
                                                    }
                                                }

                                            }
                                            break;
                                        }
                                    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.Effect1 = 0;
                                            bool kimo = false;
                                            //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, ref attack);
                                                        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))
                                                    {
                                                        kimo = attacked.BlackSpots;
                                                        PrepareSpell(spell, attacker.Owner);
                                                        uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                        ReceiveAttack(attacker, attacked, attack, damage, spell);
                                                        suse.Targets.Add(attacked.UID, damage);

                                                    }
                                                }
                                            }

                                            if (attacker.Owner.Spells.ContainsKey(11130))
                                            {
                                                if (kimo)
                                                {
                                                    suse.SpellID = 11060;
                                                    attacker.Owner.SendScreen(suse, true);
                                                    suse.Attacker = attacker.UID;
                                                    suse.SpellID = 11130;
                                                    suse.SpellLevel = attacker.Owner.Spells[11130].Level;
                                                    suse.X = attacker.X;
                                                    suse.Y = attacker.X;

                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                    suse.Targets.Add(attacked.UID, damage);
                                                    attacker.Owner.SendScreen(suse, true);
                                                    attacker.Owner.IncreaseSpellExperience(80, 11130);
                                                    break;

                                                }
                                            }
                                            if (attacker.Owner.Spells.ContainsKey(11130))
                                            {
                                                if (ServerBase.Kernel.Rate(5))
                                                {
                                                    ////spell.Duration = 0;
                                                    attacker.Update(_String.Effect, "RapidReplace", true);
                                                    suse.SpellID = 11060;
                                                    attacker.Owner.SendScreen(suse, true);

                                                }
                                                else
                                                {
                                                    //// spell.Duration = 0;
                                                    //attacker.Update(_String.Effect, "RapidReplace", true); 
                                                    attacker.Owner.SendScreen(suse, true);
                                                }
                                            }
                                            else
                                            {
                                                // spell.Duration = 0;
                                                // attacker.Update(_String.Effect, "RapidReplace", true); 
                                                attacker.Owner.SendScreen(suse, true);
                                            }


                                        }
                                        break;
                                    #endregion

                                    #region Region Damage Skills
                                    case 11100: //kracken revenge
                                        {
                                            //Console.WriteLine("0");
                                            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;
                                                //Console.WriteLine("1");
                                                int counts = 0;
                                                if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= 5)
                                                {
                                                    for (int c = 0; c < attacker.Owner.Screen.Objects.Count(); c++)
                                                    {
                                                        // Console.WriteLine("2");
                                                        if (counts < 5)
                                                        {
                                                            //Console.WriteLine("3");
                                                            //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;
                                                            //Console.WriteLine("4");
                                                            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) <= 5)
                                                                {
                                                                    // Console.WriteLine("5");
                                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                    {
                                                                        if (attacked.EntityFlag == EntityFlag.Monster)
                                                                        {

                                                                            BlackSpot spot = new BlackSpot
                                                                            {
                                                                                Remove = 0,
                                                                                Identifier = attacked.UID
                                                                            };
                                                                            attacker.Owner.Send((byte[])spot);

                                                                            attacked.BlackSpotTime = Time32.Now;
                                                                            attacked.BlackSpotTime2 = (byte)spell.Duration;
                                                                            attacked.BlackSpots = true;
                                                                            counts += 1;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (!ServerBase.Constants.BlackSpotNo.Contains(attacker.MapID))
                                                                            {

                                                                                BlackSpot spot = new BlackSpot
                                                                                {
                                                                                    Remove = 0,
                                                                                    Identifier = attacked.UID
                                                                                };
                                                                                attacker.Owner.Send((byte[])spot);

                                                                                attacked.BlackSpotTime = Time32.Now;
                                                                                attacked.BlackSpotTime2 = (byte)spell.Duration;
                                                                                attacked.BlackSpots = true;
                                                                                counts += 1;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                                attacker.Owner.SendScreen(suse, true);
                                                attacker.Owner.IncreaseSpellExperience(80, spellID);
                                            }
                                            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, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);

                                                                    ReceiveAttack(attacker, attacked, attack, damage, spell);
                                                                    suse.Targets.Add(attacked.UID, damage);
                                                                    attacker.Owner.SendScreen(suse, 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, ref attack);
                                                                    if (spell.Power > 0)
                                                                        damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell, ref attack);

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

                                            }
                                            break;
                                        }
                                    case 11070: // Gale Bomb
                                        {
                                            if (Time32.Now >= attacker.MagikAttackTimeAtaque.AddMilliseconds(200))
                                            {
                                                attacker.MagikAttackTimeAtaque = Time32.Now;
                                                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 = attack.X;
                                                    suse.Y = attack.Y;

                                                    attack.AttackType = 0x1b;
                                                    byte MaxDistance = (byte)spell.UnknownPush;
                                                    int counts = 0;
                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= attacker.AttackRange + 3)
                                                    {
                                                        foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                                        {
                                                            if (counts < 3)
                                                            {
                                                                if (_obj == null)
                                                                    continue;

                                                                if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
                                                                {
                                                                    attacked = _obj as Entity;
                                                                    if (ServerBase.Kernel.GetDistance(X, Y, attacked.X, attacked.Y) <= 5)
                                                                    {
                                                                        if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                        {

                                                                            if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                            {
                                                                                if (Misc.Distance(_obj.X, _obj.Y, (ushort)attack.X, (ushort)attack.Y) < (int)MaxDistance)
                                                                                {

                                                                                    var direction = ServerBase.Kernel.GetAngle(attacker.X, attacker.Y, attacked.X, attacked.Y);
                                                                                    attack = new Attack(true);
                                                                                    byte angle = (byte)(attack.Attacked % 8);
                                                                                    attack.Effect1 = Attack.AttackEffects1.None;
                                                                                    uint damage = Calculate.Melee(attacker, attacked, ref attack);
                                                                                    attack.AttackType = 0x1b;
                                                                                    attack.X = attacker.X;
                                                                                    attack.Y = attacker.Y;
                                                                                    attack.PushBack = angle;
                                                                                    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);
                                                                                    counts++;
                                                                                    // attacker.Owner.SendScreen(attack, true);
                                                                                    attacker.Owner.SendScreen(suse, true);
                                                                                    //attacker.X = attacker.X;

                                                                                }
                                                                                else
                                                                                    break;



                                                                            }
                                                                            else
                                                                            {
                                                                                suse.Targets.Add(attacked.UID, 0);
                                                                                suse.Targets[attacked.UID].Hit = false;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else if (_obj.MapObjType == MapObjectType.SobNpc)
                                                                {
                                                                    attackedsob = _obj as SobNpcSpawn;
                                                                    if (ServerBase.Kernel.GetDistance(attacker.X, attacker.Y, attackedsob.X, attackedsob.Y) <= 5)
                                                                    {
                                                                        if (CanAttack(attacker, attackedsob, spell))
                                                                        {
                                                                            if (ServerBase.Kernel.Rate(100))
                                                                            {
                                                                                if (CanAttack(attacker, attackedsob, spell))
                                                                                {
                                                                                    uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                                                    ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                                                    counts++;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                suse.Targets.Add(attacked.UID, 0);
                                                                                suse.Targets[attacked.UID].Hit = false;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        attacker.AttackPacket = null;
                                                    }
                                                    attacker.Owner.SendScreen(suse, true);
                                                }
                                            }
                                            break;
                                        }
                                    #endregion

                                    #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.RemoveFlag(Update.Flags.Ride);
                                                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, spell, ref attack);

                                                            suse.Effect1 = attack.Effect1;

                                                            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))
                                                        {
                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attackedsob, ref attack);
                                                            suse.Effect1 = attack.Effect1;
                                                            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.Player)
                                                        {
                                                            attacked = _obj as Entity;
                                                            if (ServerBase.Kernel.GetDistance(X, Y, attacked.X, attacked.Y) <= spell.Range)
                                                            {
                                                                if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                {
                                                                    int potDifference = attacker.BattlePower - attacked.BattlePower;

                                                                    int rate = spell.Percent + potDifference - 20;

                                                                    if (ServerBase.Kernel.Rate(rate))
                                                                    {
                                                                        attacked.ToxicFogStamp = Time32.Now;
                                                                        attacked.ToxicFogLeft = 20;
                                                                        attacked.ToxicFogPercent = spell.PowerPercent;
                                                                        suse.Targets.Add(attacked.UID, 1);
                                                                    }
                                                                    if (attacker.BattlePower - attacked.BattlePower > 0)
                                                                    {
                                                                        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;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (_obj.MapObjType == MapObjectType.Monster)
                                                            {
                                                                attacked = _obj as Entity;
                                                                if (!ServerBase.Constants.NoFog.Contains(attacked.Name))
                                                                {

                                                                    if (ServerBase.Kernel.GetDistance(X, Y, attacked.X, attacked.Y) <= spell.Range)
                                                                    {
                                                                        if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                                        {
                                                                            int potDifference = attacker.BattlePower - attacked.BattlePower;

                                                                            int rate = spell.Percent + potDifference - 20;

                                                                            if (ServerBase.Kernel.Rate(rate))
                                                                            {
                                                                                attacked.ToxicFogStamp = Time32.Now;
                                                                                attacked.ToxicFogLeft = 20;
                                                                                attacked.ToxicFogPercent = spell.PowerPercent;
                                                                                suse.Targets.Add(attacked.UID, 1);
                                                                            }
                                                                            if (attacker.BattlePower - attacked.BattlePower > 0)
                                                                            {
                                                                                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;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.AttackPacket = null;
                                                }
                                                attacker.Owner.IncreaseSpellExperience(80, spellID);
                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                            break;
                                        }
                                    case 6000:
                                    case 10381:
                                        {
                                            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))
                                                        {
                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Game.Attacking.Calculate.Melee(attacker, attacked, spell, ref attack);
                                                            suse.Effect1 = attack.Effect1;

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

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

                                                            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)
                                                            {
                                                                attacker.Owner.IncreaseSpellExperience(80, spellID);
                                                                attacked.Owner.Send(ServerBase.Constants.NoDrugs((int)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.ContainsFlag2(Update.Flags2.WarriorWalk))
                                                return;
                                            if (attacker.ContainsFlag(Update.Flags.ShurikenVortex))
                                                return;
                                            if (ServerBase.Constants.steedguard.Contains(attacker.MapID))
                                                return;
                                            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.Equipment.TryGetItem((byte)12).Plus < attacker.MapRegion.Lineage)
                                                        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;
                                                        attacker.Vigor = (ushort)attacker.MaxVigor;
                                                        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))
                                                    {
                                                        attack = new Attack(true);
                                                        attack.Effect1 = Attack.AttackEffects1.None;
                                                        uint damage = Calculate.Melee(attacker, attacked, ref attack);
                                                        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;
                                                        attack.Effect1 = Attack.AttackEffects1.None;
                                                        uint damage = Calculate.Ranged(attacker, attackedsob, ref attack);
                                                        suse.Effect1 = attack.Effect1;
                                                        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;
                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Calculate.Ranged(attacker, attacked, ref attack);
                                                            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:
                                    case 7014:
                                    case 7012:
                                    case 9971:
                                    case 7017:
                                    case 7015:
                                    case 7013:
                                    case 10360:
                                    case 9966:
                                    case 30010:
                                        {
                                            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))
                                                            {
                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Magic(attacker, attacked, spell, ref attack);
                                                                suse.Effect1 = attack.Effect1;

                                                                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))
                                                            {
                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Magic(attacker, attackedsob, spell, ref attack);
                                                                suse.Effect1 = attack.Effect1;
                                                                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;
                                                if (attacker.xx == attacker.X && attacker.yy == attacker.Y)
                                                {
                                                    attacker.scatter += 1;
                                                    if (attacker.scatter > 30)
                                                    {
                                                        attacker.Owner.Disconnect();
                                                    }
                                                }
                                                else
                                                {
                                                    attacker.xx = attacker.X;
                                                    attacker.yy = attacker.Y;
                                                    attacker.scatter = 0;
                                                }

                                                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))
                                                            {
                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked, spell, ref attack);

                                                                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))
                                                            {
                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob, ref attack);
                                                                suse.Effect1 = attack.Effect1;
                                                                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 StarArrow
                                    case 10313:
                                        {
                                            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))
                                                            {
                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Ranged(attacker, attacked, spell, ref attack);

                                                                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))
                                                            {
                                                                attack.Effect1 = Attack.AttackEffects1.None;
                                                                uint damage = Game.Attacking.Calculate.Ranged(attacker, attackedsob, ref attack);
                                                                suse.Effect1 = attack.Effect1;
                                                                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 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 (ServerBase.Constants.steedguard.Contains(attacker.MapID))
                                                    return;
                                                if (attacker.Owner.Map.BaseID == 700)
                                                    return;
                                                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 PhoenixProject.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; //10000181 - 1000006

                                                attacker.Owner.Companion.UID = (uint)ServerBase.Kernel.Random.Next(900300, 970350);

                                                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
                                    //Compassion
                                    case 10395:
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                if (attacker.Owner.Team != null)
                                                {
                                                    foreach (Client.GameState c in attacker.Owner.Team.Teammates)
                                                    {
                                                        if (c.Entity.MapID == attacker.MapID)
                                                        {
                                                            short distance = Kernel.GetDistance(c.Entity.X, c.Entity.Y, attacker.X, attacker.Y);
                                                            if (distance < ServerBase.Constants.pScreenDistance)
                                                            {
                                                                if (c.Entity.UID != attacker.UID)
                                                                {
                                                                    if (!c.AlternateEquipment)
                                                                    {
                                                                        c.LoadItemStats(c.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        c.LoadItemStats2(c.Entity);
                                                                    }

                                                                    c.Entity.AuraStamp = Time32.Now;
                                                                    c.Entity.AuraTime = 20;
                                                                    // attacked.MaxAttack += 1000;
                                                                    c.Entity.CriticalStrike += 10;
                                                                    //Console.WriteLine("sk" + attacked.CriticalStrike + "");
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FendAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.MetalAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WoodAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WaterAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.EarthAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FireAura);
                                                                    c.Entity.AddFlag2(Update.Flags2.TyrantAura);
                                                                    //Update ud = new Update(true);
                                                                    //ud.Aura(attacked, attacked.CriticalStrike, spell.Level, (byte)spell.Duration);
                                                                    PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                    switch (spell.ID)
                                                                    {
                                                                        case 0x28b4:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                                            break;

                                                                        case 0x28b5:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                                            break;

                                                                        case 0x28b6:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                                            break;

                                                                        case 0x28b7:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                                            break;

                                                                        case 0x28b8:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                                            break;

                                                                        case 0x2bc0:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                                            break;

                                                                        case 0x289b:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                            break;

                                                                        case 0x28aa:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                                            break;
                                                                    }
                                                                    StatusIconData data2 = new StatusIconData
                                                                    {
                                                                        AuraLevel = spell.Level,
                                                                        AuraPower = spell.Power,
                                                                        AuraType2 = tyrantAura,
                                                                        Identifier = c.Entity.UID,
                                                                        Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                                    };
                                                                    c.Entity.Owner.Send((byte[])data2);
                                                                }
                                                            }
                                                        }

                                                    }
                                                }
                                                if (!attacked.Owner.AlternateEquipment)
                                                {
                                                    attacked.Owner.LoadItemStats(attacked.Owner.Entity);
                                                }
                                                else
                                                {
                                                    attacked.Owner.LoadItemStats2(attacked.Owner.Entity);
                                                }
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                attacker.Owner.SendScreen(suse, true);
                                                attacked.AuraStamp = Time32.Now;
                                                attacked.AuraTime = 20;
                                                // attacked.MaxAttack += 1000;
                                                attacked.CriticalStrike += 10;
                                                //Console.WriteLine("sk" + attacked.CriticalStrike + "");
                                                attacked.RemoveFlag2(Update.Flags2.FendAura);
                                                attacked.RemoveFlag2(Update.Flags2.MetalAura);
                                                attacked.RemoveFlag2(Update.Flags2.WoodAura);
                                                attacked.RemoveFlag2(Update.Flags2.WaterAura);
                                                attacked.RemoveFlag2(Update.Flags2.EarthAura);
                                                attacked.RemoveFlag2(Update.Flags2.FireAura);
                                                attacked.AddFlag2(Update.Flags2.TyrantAura);
                                                //Update ud = new Update(true);
                                                //ud.Aura(attacked, attacked.CriticalStrike, spell.Level, (byte)spell.Duration);
                                                PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                switch (spell.ID)
                                                {
                                                    case 0x28b4:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                        break;

                                                    case 0x28b5:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                        break;

                                                    case 0x28b6:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                        break;

                                                    case 0x28b7:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                        break;

                                                    case 0x28b8:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                        break;

                                                    case 0x2bc0:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                        break;

                                                    case 0x289b:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                        break;

                                                    case 0x28aa:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                        break;
                                                }
                                                StatusIconData data = new StatusIconData
                                                {
                                                    AuraLevel = spell.Level,
                                                    AuraPower = spell.Power,
                                                    AuraType2 = tyrantAura2,
                                                    Identifier = attacker.UID,
                                                    Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                };
                                                attacker.Owner.Send((byte[])data);
                                            }
                                            break;
                                        }
                                    case 10410:
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                if (attacker.Owner.Team != null)
                                                {
                                                    foreach (Client.GameState c in attacker.Owner.Team.Teammates)
                                                    {
                                                        if (c.Entity.MapID == attacker.MapID)
                                                        {
                                                            short distance = Kernel.GetDistance(c.Entity.X, c.Entity.Y, attacker.X, attacker.Y);
                                                            if (distance < ServerBase.Constants.pScreenDistance)
                                                            {
                                                                if (c.Entity.UID != attacker.UID)
                                                                {
                                                                    if (!c.AlternateEquipment)
                                                                    {
                                                                        c.LoadItemStats(c.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        c.LoadItemStats2(c.Entity);
                                                                    }

                                                                    c.Entity.AuraStamp = Time32.Now;
                                                                    c.Entity.AuraTime = 20;
                                                                    c.Entity.SkillCStrike += 10;
                                                                    c.Entity.CriticalStrike += 10;
                                                                    // attacked.MaxAttack += 100;
                                                                    c.Entity.RemoveFlag2(Update.Flags2.TyrantAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.MetalAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WoodAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WaterAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.EarthAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FireAura);
                                                                    c.Entity.AddFlag2(Update.Flags2.FendAura);
                                                                    PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                    switch (spell.ID)
                                                                    {
                                                                        case 0x28b4:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                                            break;

                                                                        case 0x28b5:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                                            break;

                                                                        case 0x28b6:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                                            break;

                                                                        case 0x28b7:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                                            break;

                                                                        case 0x28b8:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                                            break;

                                                                        case 0x2bc0:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                                            break;

                                                                        case 0x289b:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                            break;

                                                                        case 0x28aa:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                                            break;
                                                                    }
                                                                    StatusIconData data2 = new StatusIconData
                                                                    {
                                                                        AuraLevel = spell.Level,
                                                                        AuraPower = spell.Power,
                                                                        AuraType2 = tyrantAura2,
                                                                        Identifier = c.Entity.UID,
                                                                        Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                                    };
                                                                    c.Entity.Owner.Send((byte[])data2);
                                                                }
                                                            }
                                                        }

                                                    }
                                                }
                                                if (!attacked.Owner.AlternateEquipment)
                                                {
                                                    attacked.Owner.LoadItemStats(attacked.Owner.Entity);
                                                }
                                                else
                                                {
                                                    attacked.Owner.LoadItemStats2(attacked.Owner.Entity);
                                                }
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                attacker.Owner.SendScreen(suse, true);
                                                attacked.AuraStamp = Time32.Now;
                                                attacked.AuraTime = 20;
                                                attacked.SkillCStrike += 10;
                                                attacked.CriticalStrike += 10;
                                                // attacked.MaxAttack += 100;
                                                attacked.RemoveFlag2(Update.Flags2.TyrantAura);
                                                attacked.RemoveFlag2(Update.Flags2.MetalAura);
                                                attacked.RemoveFlag2(Update.Flags2.WoodAura);
                                                attacked.RemoveFlag2(Update.Flags2.WaterAura);
                                                attacked.RemoveFlag2(Update.Flags2.EarthAura);
                                                attacked.RemoveFlag2(Update.Flags2.FireAura);
                                                attacked.AddFlag2(Update.Flags2.FendAura);
                                                PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                switch (spell.ID)
                                                {
                                                    case 0x28b4:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                        break;

                                                    case 0x28b5:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                        break;

                                                    case 0x28b6:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                        break;

                                                    case 0x28b7:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                        break;

                                                    case 0x28b8:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                        break;

                                                    case 0x2bc0:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                        break;

                                                    case 0x289b:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                        break;

                                                    case 0x28aa:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                        break;
                                                }
                                                StatusIconData data = new StatusIconData
                                                {
                                                    AuraLevel = spell.Level,
                                                    AuraPower = spell.Power,
                                                    AuraType2 = tyrantAura,
                                                    Identifier = attacker.UID,
                                                    Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                };
                                                attacker.Owner.Send((byte[])data);
                                                //Update ud = new Update(true);
                                                //ud.Aura(attacked, attacked.SkillCStrike, spell.Level, (byte)spell.Duration);
                                            }
                                            break;
                                        }
                                    case 10420:
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                if (attacker.Owner.Team != null)
                                                {
                                                    foreach (Client.GameState c in attacker.Owner.Team.Teammates)
                                                    {
                                                        if (c.Entity.MapID == attacker.MapID)
                                                        {
                                                            short distance = Kernel.GetDistance(c.Entity.X, c.Entity.Y, attacker.X, attacker.Y);
                                                            if (distance < ServerBase.Constants.pScreenDistance)
                                                            {
                                                                if (c.Entity.UID != attacker.UID)
                                                                {
                                                                    if (!c.AlternateEquipment)
                                                                    {
                                                                        c.LoadItemStats(c.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        c.LoadItemStats2(c.Entity);
                                                                    }

                                                                    c.Entity.AuraStamp = Time32.Now;
                                                                    c.Entity.AuraTime = 20;
                                                                    c.Entity.MetalResistance += 30;
                                                                    c.Entity.RemoveFlag2(Update.Flags2.TyrantAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FendAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WoodAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WaterAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.EarthAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FireAura);
                                                                    c.Entity.AddFlag2(Update.Flags2.MetalAura);
                                                                    PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                    switch (spell.ID)
                                                                    {
                                                                        case 0x28b4:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                                            break;

                                                                        case 0x28b5:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                                            break;

                                                                        case 0x28b6:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                                            break;

                                                                        case 0x28b7:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                                            break;

                                                                        case 0x28b8:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                                            break;

                                                                        case 0x2bc0:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                                            break;

                                                                        case 0x289b:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                            break;

                                                                        case 0x28aa:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                                            break;
                                                                    }
                                                                    StatusIconData data2 = new StatusIconData
                                                                    {
                                                                        AuraLevel = spell.Level,
                                                                        AuraPower = spell.Power,
                                                                        AuraType2 = tyrantAura2,
                                                                        Identifier = c.Entity.UID,
                                                                        Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                                    };
                                                                    c.Entity.Owner.Send((byte[])data2);
                                                                }
                                                            }
                                                        }

                                                    }
                                                }
                                                if (!attacked.Owner.AlternateEquipment)
                                                {
                                                    attacked.Owner.LoadItemStats(attacked.Owner.Entity);
                                                }
                                                else
                                                {
                                                    attacked.Owner.LoadItemStats2(attacked.Owner.Entity);
                                                }
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                attacker.Owner.SendScreen(suse, true);
                                                attacked.AuraStamp = Time32.Now;
                                                attacked.AuraTime = 20;
                                                attacked.MetalResistance += 30;
                                                attacked.RemoveFlag2(Update.Flags2.TyrantAura);
                                                attacked.RemoveFlag2(Update.Flags2.FendAura);
                                                attacked.RemoveFlag2(Update.Flags2.WoodAura);
                                                attacked.RemoveFlag2(Update.Flags2.WaterAura);
                                                attacked.RemoveFlag2(Update.Flags2.EarthAura);
                                                attacked.RemoveFlag2(Update.Flags2.FireAura);
                                                attacked.AddFlag2(Update.Flags2.MetalAura);
                                                PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                switch (spell.ID)
                                                {
                                                    case 0x28b4:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                        break;

                                                    case 0x28b5:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                        break;

                                                    case 0x28b6:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                        break;

                                                    case 0x28b7:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                        break;

                                                    case 0x28b8:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                        break;

                                                    case 0x2bc0:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                        break;

                                                    case 0x289b:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                        break;

                                                    case 0x28aa:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                        break;
                                                }
                                                StatusIconData data = new StatusIconData
                                                {
                                                    AuraLevel = spell.Level,
                                                    AuraPower = spell.Power,
                                                    AuraType2 = tyrantAura,
                                                    Identifier = attacker.UID,
                                                    Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                };
                                                attacker.Owner.Send((byte[])data);
                                            }
                                            //Update ud = new Update(true);
                                            //ud.Aura(attacked, attacked.MetalResistance, spell.Level, (byte)spell.Duration);
                                            break;
                                        }
                                    case 10421:
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                if (attacker.Owner.Team != null)
                                                {
                                                    foreach (Client.GameState c in attacker.Owner.Team.Teammates)
                                                    {
                                                        if (c.Entity.MapID == attacker.MapID)
                                                        {
                                                            short distance = Kernel.GetDistance(c.Entity.X, c.Entity.Y, attacker.X, attacker.Y);
                                                            if (distance < ServerBase.Constants.pScreenDistance)
                                                            {
                                                                if (c.Entity.UID != attacker.UID)
                                                                {
                                                                    if (!c.AlternateEquipment)
                                                                    {
                                                                        c.LoadItemStats(c.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        c.LoadItemStats2(c.Entity);
                                                                    }

                                                                    c.Entity.AuraStamp = Time32.Now;
                                                                    c.Entity.AuraTime = 20;
                                                                    c.Entity.WoodResistance += 30;
                                                                    c.Entity.RemoveFlag2(Update.Flags2.TyrantAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FendAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.MetalAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WaterAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.EarthAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FireAura);
                                                                    c.Entity.AddFlag2(Update.Flags2.WoodAura);
                                                                    PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                    switch (spell.ID)
                                                                    {
                                                                        case 0x28b4:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                                            break;

                                                                        case 0x28b5:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                                            break;

                                                                        case 0x28b6:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                                            break;

                                                                        case 0x28b7:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                                            break;

                                                                        case 0x28b8:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                                            break;

                                                                        case 0x2bc0:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                                            break;

                                                                        case 0x289b:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                            break;

                                                                        case 0x28aa:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                                            break;
                                                                    }
                                                                    StatusIconData data2 = new StatusIconData
                                                                    {
                                                                        AuraLevel = spell.Level,
                                                                        AuraPower = spell.Power,
                                                                        AuraType2 = tyrantAura2,
                                                                        Identifier = c.Entity.UID,
                                                                        Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                                    };
                                                                    c.Entity.Owner.Send((byte[])data2);
                                                                }
                                                            }
                                                        }

                                                    }
                                                }
                                                if (!attacked.Owner.AlternateEquipment)
                                                {
                                                    attacked.Owner.LoadItemStats(attacked.Owner.Entity);
                                                }
                                                else
                                                {
                                                    attacked.Owner.LoadItemStats2(attacked.Owner.Entity);
                                                }
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                attacker.Owner.SendScreen(suse, true);
                                                attacked.AuraStamp = Time32.Now;
                                                attacked.AuraTime = 20;
                                                attacked.WoodResistance += 30;
                                                attacked.RemoveFlag2(Update.Flags2.TyrantAura);
                                                attacked.RemoveFlag2(Update.Flags2.FendAura);
                                                attacked.RemoveFlag2(Update.Flags2.MetalAura);
                                                attacked.RemoveFlag2(Update.Flags2.WaterAura);
                                                attacked.RemoveFlag2(Update.Flags2.EarthAura);
                                                attacked.RemoveFlag2(Update.Flags2.FireAura);
                                                attacked.AddFlag2(Update.Flags2.WoodAura);
                                                PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                switch (spell.ID)
                                                {
                                                    case 0x28b4:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                        break;

                                                    case 0x28b5:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                        break;

                                                    case 0x28b6:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                        break;

                                                    case 0x28b7:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                        break;

                                                    case 0x28b8:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                        break;

                                                    case 0x2bc0:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                        break;

                                                    case 0x289b:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                        break;

                                                    case 0x28aa:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                        break;
                                                }
                                                StatusIconData data = new StatusIconData
                                                {
                                                    AuraLevel = spell.Level,
                                                    AuraPower = spell.Power,
                                                    AuraType2 = tyrantAura,
                                                    Identifier = attacker.UID,
                                                    Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                };
                                                attacker.Owner.Send((byte[])data);
                                                //Update ud = new Update(true);
                                            }
                                            //ud.Aura(attacked, attacked.WoodResistance, spell.Level, (byte)spell.Duration);
                                            break;
                                        }
                                    case 10422:
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                if (attacker.Owner.Team != null)
                                                {
                                                    foreach (Client.GameState c in attacker.Owner.Team.Teammates)
                                                    {
                                                        if (c.Entity.MapID == attacker.MapID)
                                                        {
                                                            short distance = Kernel.GetDistance(c.Entity.X, c.Entity.Y, attacker.X, attacker.Y);
                                                            if (distance < ServerBase.Constants.pScreenDistance)
                                                            {
                                                                if (c.Entity.UID != attacker.UID)
                                                                {
                                                                    if (!c.AlternateEquipment)
                                                                    {
                                                                        c.LoadItemStats(c.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        c.LoadItemStats2(c.Entity);
                                                                    }

                                                                    c.Entity.AuraStamp = Time32.Now;
                                                                    c.Entity.AuraTime = 20;
                                                                    c.Entity.WaterResistance += 30;
                                                                    c.Entity.RemoveFlag2(Update.Flags2.TyrantAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FendAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.MetalAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WoodAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.EarthAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FireAura);
                                                                    c.Entity.AddFlag2(Update.Flags2.WaterAura);
                                                                    PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                    switch (spell.ID)
                                                                    {
                                                                        case 0x28b4:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                                            break;

                                                                        case 0x28b5:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                                            break;

                                                                        case 0x28b6:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                                            break;

                                                                        case 0x28b7:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                                            break;

                                                                        case 0x28b8:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                                            break;

                                                                        case 0x2bc0:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                                            break;

                                                                        case 0x289b:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                            break;

                                                                        case 0x28aa:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                                            break;
                                                                    }
                                                                    StatusIconData data2 = new StatusIconData
                                                                    {
                                                                        AuraLevel = spell.Level,
                                                                        AuraPower = spell.Power,
                                                                        AuraType2 = tyrantAura2,
                                                                        Identifier = c.Entity.UID,
                                                                        Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                                    };
                                                                    c.Entity.Owner.Send((byte[])data2);
                                                                }
                                                            }
                                                        }

                                                    }
                                                }
                                                if (!attacked.Owner.AlternateEquipment)
                                                {
                                                    attacked.Owner.LoadItemStats(attacked.Owner.Entity);
                                                }
                                                else
                                                {
                                                    attacked.Owner.LoadItemStats2(attacked.Owner.Entity);
                                                }
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                attacker.Owner.SendScreen(suse, true);
                                                attacked.AuraStamp = Time32.Now;
                                                attacked.AuraTime = 20;
                                                attacked.WaterResistance += 30;
                                                attacked.RemoveFlag2(Update.Flags2.TyrantAura);
                                                attacked.RemoveFlag2(Update.Flags2.FendAura);
                                                attacked.RemoveFlag2(Update.Flags2.MetalAura);
                                                attacked.RemoveFlag2(Update.Flags2.WoodAura);
                                                attacked.RemoveFlag2(Update.Flags2.EarthAura);
                                                attacked.RemoveFlag2(Update.Flags2.FireAura);
                                                attacked.AddFlag2(Update.Flags2.WaterAura);
                                                PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                switch (spell.ID)
                                                {
                                                    case 0x28b4:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                        break;

                                                    case 0x28b5:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                        break;

                                                    case 0x28b6:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                        break;

                                                    case 0x28b7:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                        break;

                                                    case 0x28b8:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                        break;

                                                    case 0x2bc0:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                        break;

                                                    case 0x289b:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                        break;

                                                    case 0x28aa:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                        break;
                                                }
                                                StatusIconData data = new StatusIconData
                                                {
                                                    AuraLevel = spell.Level,
                                                    AuraPower = spell.Power,
                                                    AuraType2 = tyrantAura,
                                                    Identifier = attacker.UID,
                                                    Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                };
                                                attacker.Owner.Send((byte[])data);
                                                //Update ud = new Update(true);
                                            }
                                            //ud.Aura(attacked, attacked.WaterResistance, spell.Level, (byte)spell.Duration);
                                            break;
                                        }

                                    case 10424:
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                if (attacker.Owner.Team != null)
                                                {
                                                    foreach (Client.GameState c in attacker.Owner.Team.Teammates)
                                                    {
                                                        if (c.Entity.MapID == attacker.MapID)
                                                        {
                                                            short distance = Kernel.GetDistance(c.Entity.X, c.Entity.Y, attacker.X, attacker.Y);
                                                            if (distance < ServerBase.Constants.pScreenDistance)
                                                            {
                                                                if (c.Entity.UID != attacker.UID)
                                                                {
                                                                    if (!c.AlternateEquipment)
                                                                    {
                                                                        c.LoadItemStats(c.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        c.LoadItemStats2(c.Entity);
                                                                    }

                                                                    c.Entity.AuraStamp = Time32.Now;
                                                                    c.Entity.AuraTime = 20;
                                                                    c.Entity.EarthResistance += 30;
                                                                    c.Entity.RemoveFlag2(Update.Flags2.TyrantAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FendAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.MetalAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WoodAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WaterAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FireAura);
                                                                    c.Entity.AddFlag2(Update.Flags2.EarthAura);
                                                                    PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                    switch (spell.ID)
                                                                    {
                                                                        case 0x28b4:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                                            break;

                                                                        case 0x28b5:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                                            break;

                                                                        case 0x28b6:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                                            break;

                                                                        case 0x28b7:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                                            break;

                                                                        case 0x28b8:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                                            break;

                                                                        case 0x2bc0:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                                            break;

                                                                        case 0x289b:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                            break;

                                                                        case 0x28aa:
                                                                            tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                                            break;
                                                                    }
                                                                    StatusIconData data2 = new StatusIconData
                                                                    {
                                                                        AuraLevel = spell.Level,
                                                                        AuraPower = spell.Power,
                                                                        AuraType2 = tyrantAura,
                                                                        Identifier = c.Entity.UID,
                                                                        Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                                    };
                                                                    c.Entity.Owner.Send((byte[])data2);

                                                                }
                                                            }
                                                        }

                                                    }
                                                }
                                                if (!attacked.Owner.AlternateEquipment)
                                                {
                                                    attacked.Owner.LoadItemStats(attacked.Owner.Entity);
                                                }
                                                else
                                                {
                                                    attacked.Owner.LoadItemStats2(attacked.Owner.Entity);
                                                }
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                attacker.Owner.SendScreen(suse, true);
                                                attacked.AuraStamp = Time32.Now;
                                                attacked.AuraTime = 20;
                                                attacked.EarthResistance += 30;
                                                attacked.RemoveFlag2(Update.Flags2.TyrantAura);
                                                attacked.RemoveFlag2(Update.Flags2.FendAura);
                                                attacked.RemoveFlag2(Update.Flags2.MetalAura);
                                                attacked.RemoveFlag2(Update.Flags2.WoodAura);
                                                attacked.RemoveFlag2(Update.Flags2.WaterAura);
                                                attacked.RemoveFlag2(Update.Flags2.FireAura);
                                                attacked.AddFlag2(Update.Flags2.EarthAura);
                                                PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                switch (spell.ID)
                                                {
                                                    case 0x28b4:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                        break;

                                                    case 0x28b5:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                        break;

                                                    case 0x28b6:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                        break;

                                                    case 0x28b7:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                        break;

                                                    case 0x28b8:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                        break;

                                                    case 0x2bc0:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                        break;

                                                    case 0x289b:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                        break;

                                                    case 0x28aa:
                                                        tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                        break;
                                                }
                                                StatusIconData data = new StatusIconData
                                                {
                                                    AuraLevel = spell.Level,
                                                    AuraPower = spell.Power,
                                                    AuraType2 = tyrantAura2,
                                                    Identifier = attacker.UID,
                                                    Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                };
                                                attacker.Owner.Send((byte[])data);
                                                //Update ud = new Update(true);
                                            }
                                            ///ud.Aura(attacked, attacked.EarthResistance, spell.Level, (byte)spell.Duration);
                                            break;
                                        }
                                    case 10423:
                                        {
                                            if (CanUseSpell(spell, attacker.Owner))
                                            {
                                                PrepareSpell(spell, attacker.Owner);
                                                if (attacker.Owner.Team != null)
                                                {
                                                    foreach (Client.GameState c in attacker.Owner.Team.Teammates)
                                                    {
                                                        if (c.Entity.MapID == attacker.MapID)
                                                        {
                                                            short distance = Kernel.GetDistance(c.Entity.X, c.Entity.Y, attacker.X, attacker.Y);
                                                            if (distance < ServerBase.Constants.pScreenDistance)
                                                            {
                                                                if (c.Entity.UID != attacker.UID)
                                                                {
                                                                    if (!c.AlternateEquipment)
                                                                    {
                                                                        c.LoadItemStats(c.Entity);
                                                                    }
                                                                    else
                                                                    {
                                                                        c.LoadItemStats2(c.Entity);
                                                                    }

                                                                    c.Entity.AuraStamp = Time32.Now;
                                                                    c.Entity.AuraTime = 20;
                                                                    c.Entity.FireResistance += 30;
                                                                    c.Entity.RemoveFlag2(Update.Flags2.TyrantAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.FendAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.MetalAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WoodAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.WaterAura);
                                                                    c.Entity.RemoveFlag2(Update.Flags2.EarthAura);
                                                                    c.Entity.AddFlag2(Update.Flags2.FireAura);
                                                                    PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                    switch (spell.ID)
                                                                    {
                                                                        case 0x28b4:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                                            break;

                                                                        case 0x28b5:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                                            break;

                                                                        case 0x28b6:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                                            break;

                                                                        case 0x28b7:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                                            break;

                                                                        case 0x28b8:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                                            break;

                                                                        case 0x2bc0:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                                            break;

                                                                        case 0x289b:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                                            break;

                                                                        case 0x28aa:
                                                                            tyrantAura2 = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                                            break;
                                                                    }
                                                                    StatusIconData data2 = new StatusIconData
                                                                    {
                                                                        AuraLevel = spell.Level,
                                                                        AuraPower = spell.Power,
                                                                        AuraType2 = tyrantAura2,
                                                                        Identifier = c.Entity.UID,
                                                                        Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                                    };
                                                                    c.Entity.Owner.Send((byte[])data2);

                                                                }
                                                            }
                                                        }

                                                    }
                                                }
                                                if (!attacked.Owner.AlternateEquipment)
                                                {
                                                    attacked.Owner.LoadItemStats(attacked.Owner.Entity);
                                                }
                                                else
                                                {
                                                    attacked.Owner.LoadItemStats2(attacked.Owner.Entity);
                                                }
                                                SpellUse suse = new SpellUse(true);
                                                suse.Attacker = attacker.UID;
                                                suse.SpellID = spell.ID;
                                                suse.SpellLevel = spell.Level;
                                                suse.X = X;
                                                suse.Y = Y;
                                                attacker.Owner.SendScreen(suse, true);
                                                attacked.AuraStamp = Time32.Now;
                                                attacked.AuraTime = 20;
                                                attacked.FireResistance += 30;
                                                attacked.RemoveFlag2(Update.Flags2.TyrantAura);
                                                attacked.RemoveFlag2(Update.Flags2.FendAura);
                                                attacked.RemoveFlag2(Update.Flags2.MetalAura);
                                                attacked.RemoveFlag2(Update.Flags2.WoodAura);
                                                attacked.RemoveFlag2(Update.Flags2.WaterAura);
                                                attacked.RemoveFlag2(Update.Flags2.EarthAura);
                                                attacked.AddFlag2(Update.Flags2.FireAura);
                                                PhoenixProject.Network.GamePackets.StatusIconData.AuraType tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                switch (spell.ID)
                                                {
                                                    case 0x28b4:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MetalAura;
                                                        break;

                                                    case 0x28b5:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WoodAura;
                                                        break;

                                                    case 0x28b6:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.WaterAura;
                                                        break;

                                                    case 0x28b7:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FireAura;
                                                        break;

                                                    case 0x28b8:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.EarthAura;
                                                        break;

                                                    case 0x2bc0:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.MagicDefender;
                                                        break;

                                                    case 0x289b:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.TyrantAura;
                                                        break;

                                                    case 0x28aa:
                                                        tyrantAura = PhoenixProject.Network.GamePackets.StatusIconData.AuraType.FendAura;
                                                        break;
                                                }
                                                StatusIconData data = new StatusIconData
                                                {
                                                    AuraLevel = spell.Level,
                                                    AuraPower = spell.Power,
                                                    AuraType2 = tyrantAura,
                                                    Identifier = attacker.UID,
                                                    Type = PhoenixProject.Network.GamePackets.StatusIconData.AuraDataTypes.Add
                                                };
                                                attacker.Owner.Send((byte[])data);
                                            }
                                            // Update ud = new Update(true);
                                            // ud.Aura(attacked, attacked.FireResistance, spell.Level, (byte)spell.Duration);
                                            break;
                                        }
                                    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.NoDrugsTime = 0;
                                                attacker.RemoveFlag2(Update.Flags2.SoulShackle);
                                                SyncPacket packet3 = new SyncPacket
                                                {
                                                    Identifier = attacked.UID,
                                                    Count = 2,
                                                    Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                                                    StatusFlag1 = (ulong)attacked.StatusFlag,
                                                    StatusFlag2 = (ulong)attacked.StatusFlag2,
                                                    Unknown1 = 0x36,
                                                    StatusFlagOffset = 0x6f,
                                                    Time = 0,
                                                    Value = 0,
                                                    Level = spell.Level
                                                };
                                                attacked.Owner.Send((byte[])packet3);
                                                attacker.Owner.SendScreen(suse, true);
                                            }
                                            attacker.AttackPacket = null;
                                            break;
                                        }
                                    //Tranquility
                                    case 10425:
                                        {
                                            if (attacked == null) return;

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

                                                if (attacked == 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(attacked.UID, 1);

                                                attacked.ToxicFogLeft = 0;
                                                attacked.ShackleTime = 0;
                                                attacked.NoDrugsTime = 0;
                                                attacked.RemoveFlag2(Update.Flags2.SoulShackle);
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                {
                                                    SyncPacket packet3 = new SyncPacket
                                                    {
                                                        Identifier = attacked.UID,
                                                        Count = 2,
                                                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                                                        StatusFlag1 = (ulong)attacked.StatusFlag,
                                                        StatusFlag2 = (ulong)attacked.StatusFlag2,
                                                        Unknown1 = 0x36,
                                                        StatusFlagOffset = 0x6f,
                                                        Time = 0,
                                                        Value = 0,
                                                        Level = spell.Level
                                                    };
                                                    attacked.Owner.Send((byte[])packet3);
                                                }
                                                if (attacked.EntityFlag == EntityFlag.Player)
                                                    attacked.Owner.SendScreen(suse, true);
                                                else
                                                    attacked.MonsterInfo.SendScreen(suse);
                                            }
                                            attacker.AttackPacket = null;
                                            break;
                                        }

                                    //WhirlwindKick
                                    case 10415:
                                        {
                                            if (Time32.Now < attacker.WhilrwindKick.AddMilliseconds(1200))
                                            { 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.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, spell, ref attack);

                                                                        suse.Effect1 = attack.Effect1;
                                                                        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;
                                        }
                                    #endregion
                                    default:
                                        if (attacker.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager)
                                            attacker.Owner.Send(new Message("Unknown spell id: " + spell.ID, System.Drawing.Color.CadetBlue, Message.Talk));
                                        break;

                                }

                                if (spell.CanKill == 0)
                                {
                                    attacker.Owner.IncreaseSpellExperience(80, spellID);
                                }
                                //  attacker.Owner.IncreaseSpellExperience(Experience, spellID);//kimo
                                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

                }
            #endregion
            }
        }