//private Handler CTF;
        //public GenericActionList<DelayedActionType> DelayedActions;
        public Team(TeamType us, ushort X, ushort Y, uint FlagUID)
        {
            //DelayedActions = new GenericActionList<DelayedActionType>();
            TeamName = us;
            Flag = new SobNpcSpawn
            {
                Name = TeamName.ToString() + "Flag",
                UID = FlagUID,
                MapID = 2060,
                X = X,
                Y = Y,
                MaxHitpoints = 5000,
                Hitpoints = 5000,
                Mesh = 8684,
                //Sort = 21,
                Type = Enums.NpcType.Stake,
            };

            GroundFlag = new SobNpcSpawn
            {
                Name = TeamName.ToString() + "Flag",
                UID = FlagUID + 10,
                MapID = 2060,
                X = X,
                Y = Y,
                MaxHitpoints = 20000,
                Hitpoints = 20000,
                Mesh = 8910,
                //Sort = 21,
                Type = Enums.NpcType.Stake,
            };
            Map.AddNpc(Flag);
        }
 public Booth(Client.GameState client, Data data)
 {
     Owner = client;
     Owner.Booth = this;
     Owner.Entity.Action = Enums.ConquerAction.Sit;
     ItemList = new SafeDictionary<uint, BoothItem>(20);
     Base = new SobNpcSpawn();
     Base.Owner = Owner;
     Base.UID = (uint)((Owner.Entity.UID % 1000000) + ((Owner.Entity.UID / 1000000) * 100000));
     Base.Mesh = 406;
     Base.Type = Game.Enums.NpcType.Booth;
     Base.ShowName = true;
     Base.Name = Name;
     Base.X = (ushort)(Owner.Entity.X + 1);
     Base.Y = Owner.Entity.Y;
     Owner.SendScreenSpawn(Base, true);
     data.dwParam = Base.UID;
     data.wParam1 = Base.X;
     data.wParam2 = Base.Y;
     data.ID = Data.OwnBooth;
     Owner.Send(data);
 }
        /*public static void Initiate2()
        {
            var Map = ServerBase.Kernel.Maps[1036];
            Pole2 = (SobNpcSpawn)Map.Npcs[813];

        }*/
        public static void EliteGwint()
        {
            var Map = ServerBase.Kernel.Maps[2071];
            Poles = (SobNpcSpawn)Map.Npcs[811];
        }
 private static void UpdatePole(SobNpcSpawn pole)
 {
     new Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.UPDATE)
     .Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
 }
 public static void Initiate()
 {
     var Map = ServerBase.Kernel.Maps[1038];
     Pole = (SobNpcSpawn)Map.Npcs[810];
     LeftGate = (SobNpcSpawn)Map.Npcs[516074];
     RightGate = (SobNpcSpawn)Map.Npcs[516075];
 }
 public static uint Percent(SobNpcSpawn attacked, float percent)
 {
     return (uint)(attacked.Hitpoints * percent);
 }
        public static uint Melee(Entity attacker, SobNpcSpawn attacked, ref Attack Packet)
        {

            int Damage = 0;
            Boolean CritImmune = false;

            Durability(attacker, null, null);
            if (!attacker.Transformed)
                Damage = ServerBase.Kernel.Random.Next((int)attacker.MinAttack, (int)attacker.MaxAttack + 1);
            else
                Damage = ServerBase.Kernel.Random.Next(Math.Min((int)attacker.MinAttack, (int)attacker.MaxAttack), Math.Max((int)attacker.MinAttack, (int)attacker.MaxAttack) + 1);
            if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                if (!attacker.Transformed)
                    Damage = (int)(Damage * 1.30);
            Damage += attacker.PhysicalDamageIncrease;
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                GemEffect.Effect(attacker);
            }
            if (ServerBase.Kernel.Rate(5))
            {
                if (attacker.EntityFlag == EntityFlag.Player)
                {
                    if (attacker.Owner.BlessTime > 0)
                    {
                        Damage *= 2;
                        _String str = new _String(true);
                        str.UID = attacker.UID;
                        str.TextsCount = 1;
                        str.Type = _String.Effect;
                        str.Texts.Add("LuckyGuy");
                        attacker.Owner.SendScreen(str, true);
                    }
                }
            }
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                if (!CritImmune)
                {
                    if (ChanceSuccess((float)attacker.CriticalStrike / 100f))
                    {
                        Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
                        Damage = (Int32)Math.Floor((float)Damage * 1.2);
                    }
                }
            }

           
           Damage = (int)(Damage*1.8);//kimoz

            if (Damage <= 0)
                Damage = 1;
            
            if (ServerBase.Constants.Damage1Map.Contains(attacker.MapID))
                Damage = 1;


            return (uint)Damage;
        }
        public static uint Magic(Entity attacker, SobNpcSpawn attacked, Database.SpellInformation spell, ref Attack Packet)
        {
            if (spell != null)
                if (!ServerBase.Kernel.Rate(spell.Percent))
                    return 0;
            if (spell != null)
                Durability(attacker, null, spell);
            if (attacker.Transformed)
                return 0;
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                GemEffect.Effect(attacker);
            }
            int Damage = 0;
            Damage = (int)attacker.MagicAttack;
            if (spell != null)
                Damage += spell.Power;
            if (ServerBase.Kernel.Rate(5))
            {
                if (attacker.EntityFlag == EntityFlag.Player)
                {
                    if (attacker.Owner.BlessTime > 0)
                    {
                        Damage *= 2;
                        _String str = new _String(true);
                        str.UID = attacker.UID;
                        str.TextsCount = 1;
                        str.Type = _String.Effect;
                        str.Texts.Add("LuckyGuy");
                        attacker.Owner.SendScreen(str, true);
                    }
                }
            }


            Damage += attacker.MagicDamageIncrease;
            if (ChanceSuccess((float)attacker.SkillCStrike / 100f))
            {
                Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
                Damage = (Int32)Math.Floor((float)Damage * 1.2);
            }

            if (Damage <= 0)
                Damage = 1;
            if (ServerBase.Constants.Damage1Map.Contains(attacker.MapID))
                Damage = 1;
            if (attacker.MonsterInfo != null)
                if (attacker.MonsterInfo.Name == "Guard1")
                    Damage = (int)attacked.MaxHitpoints + 1;
            if (ServerBase.Constants.Damage1Map.Contains(attacker.MapID))
                Damage = 1;
            return (uint)Damage;
        }
        public static void Initiate2()
        {
            var Map = ServerBase.Kernel.Maps[1002];
            ClanFlag2 = (SobNpcSpawn)Map.Npcs[814];

        }
 public static void Initiate()
 {
     var Map = ServerBase.Kernel.Maps[1509];
     ClanFlag = (SobNpcSpawn)Map.Npcs[812];
     
 }
        public static bool CanAttack(Game.Entity attacker, SobNpcSpawn attacked, Database.SpellInformation spell)
        {
            if (attacker.MapID == 2060)
            {
                if (attacked.UID >= 10021 && attacked.UID <= 10024)
                {
                    return false;
                }
            }
            if (attacker.MapID == 2060)
            {
                if (attacked.UID == 10001 && attacker.Owner.CaptureR)
                {
                    return false;
                }
            }
            if (attacker.MapID == 2060)
            {
                if (attacked.UID == 10002 && attacker.Owner.CaptureB)
                {
                    return false;
                }
            }
            if (attacker.MapID == 2060)
            {
                if (attacked.UID == 10003 && attacker.Owner.CaptureW)
                {
                    return false;
                }
            }
            if (attacker.MapID == 2060)
            {
                if (attacked.UID == 10004 && attacker.Owner.CaptureBL)
                {
                    return false;
                }
            }
            if (attacker.MapID == 1038)
            {
                if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday && DateTime.Now.Hour >= Game.KimoEvents.GWEEndHour)
                {
                    if (attacked.UID == 810)
                    {
                        return false;
                    }
                }
                if (attacker.GuildID == 0 || !Game.ConquerStructures.Society.GuildWar.IsWar)
                {
                    if (attacked.UID == 810)
                    {
                        return false;
                    }
                }
                if (Game.ConquerStructures.Society.GuildWar.PoleKeeper != null)
                {
                    if (Game.ConquerStructures.Society.GuildWar.PoleKeeper == attacker.Owner.Guild)
                    {
                        if (attacked.UID == 810)
                        {
                            return false;
                        }
                    }
                    else if (attacked.UID == 516075 || attacked.UID == 516074)
                    {
                        if (Game.ConquerStructures.Society.GuildWar.PoleKeeper == attacker.Owner.Guild)
                        {
                            if (attacker.PKMode == Enums.PKMode.Team)
                                return false;
                        }
                    }
                }
            }
            if (attacker.MapID == 2071)
            {
                if (DateTime.Now.Hour >= 17 && DateTime.Now.Hour < 18)
                {
                    if (attacked.UID == 811)
                    {
                       // return false;
                    }
                }
                else
                {
                    if (attacked.UID == 811)
                    {
                        return false;
                    }
                }
                if (attacker.GuildID == 0 || !Game.ConquerStructures.Society.EliteGuildWar.IsWar)
                {
                    if (attacked.UID == 811)
                    {
                        return false;
                    }
                }
                if (Game.ConquerStructures.Society.EliteGuildWar.PoleKeeper != null)
                {
                    if (Game.ConquerStructures.Society.EliteGuildWar.PoleKeeper == attacker.Owner.Guild)
                    {
                        if (attacked.UID == 811)
                        {
                            return false;
                        }
                    }
                }
            }
            if (attacked.UID == 813)
            {
                return false;
            }
            if (attacked.UID == 814)
            {
                return false;
            }
            if (attacker.MapID == 1509)
            {
                if (DateTime.Now.Hour >= Game.KimoEvents.ClanEndHour)
                {
                    if (attacked.UID == 812)
                    {
                        return false;
                    }
                }
                if (attacker.ClanId == 0 || !Game.ClanWar.IsWar)
                {
                    if (attacked.UID == 812)
                    {
                        return false;
                    }
                }
                if (Game.ClanWar.PoleKeeper != null)
                {
                    if (Game.ClanWar.PoleKeeper == attacker.Myclan)
                    {
                        if (attacked.UID == 812)
                        {
                            return false;
                        }
                    }
                    
                }
            }
            if (attacker.MapID == 1039)
            {
                bool stake = true;
                if (attacked.Name.ToLower().Contains("crow"))
                    stake = false;

                ushort levelbase = (ushort)(attacked.Mesh / 10);
                if (stake)
                    levelbase -= 42;
                else
                    levelbase -= 43;

                byte level = (byte)(20 + (levelbase / 3) * 5);
                if (levelbase == 108 || levelbase == 109)
                    level = 125;
                if (attacker.Level >= level)
                    return true;
                else
                {
                    attacker.AttackPacket = null;
                    attacker.Owner.Send(ServerBase.Constants.DummyLevelTooHigh());
                    return false;
                }
            }
            return true;
        }
        public static void ReceiveAttack(Game.Entity attacker, SobNpcSpawn attacked, Attack attack, uint damage, Database.SpellInformation spell)
        {

            if (attacker.EntityFlag == EntityFlag.Player)
            {
                
                if (damage > attacked.Hitpoints)
                {
                   // if (attacker.MapID == 1039)
                      //  attacker.Owner.IncreaseExperience(Math.Min(damage, attacked.Hitpoints), true);
                    if (spell != null)
                        attacker.Owner.IncreaseSpellExperience(Math.Min(damage, attacked.Hitpoints), spell.ID);
                }
                else
                {
                   // if (attacker.MapID == 1039)
                     //   attacker.Owner.IncreaseExperience(damage, true);
                    if (spell != null)
                        attacker.Owner.IncreaseSpellExperience(damage, spell.ID);
                }
                if (attacker.MapID == 1038)
                {
                    if (attacked.UID == 810)
                    {
                        if (Game.ConquerStructures.Society.GuildWar.PoleKeeper == attacker.Owner.Guild)
                            return;
                        if (attacked.Hitpoints <= damage)
                            attacked.Hitpoints = 0;
                        Game.ConquerStructures.Society.GuildWar.AddScore(damage, attacker.Owner.Guild);
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10001)
                    {
                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Hitpoints = 0;
                            if (Game.Team.RScore > 0)
                            {
                                Game.Team.RScore -= 1;
                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("[CaptureTheFlag] RedFlag has Destroyed and RedTeam losed 1 Points and  Score Now for RedTeam:" + Game.Team.RScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                            }
                        }
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10002)
                    {
                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Hitpoints = 0;
                            if (Game.Team.BScore > 0)
                            {
                                Game.Team.BScore -= 1;
                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("[CaptureTheFlag] BlueFlag has Destroyed and BlueTeam losed 1 Points and  Score Now for BlueTeam:" + Game.Team.BScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                            }
                        }
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10003)
                    {
                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Hitpoints = 0;
                            if (Game.Team.WScore > 0)
                            {
                                Game.Team.WScore -= 1;
                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("[CaptureTheFlag] WhiteFlag has Destroyed and WhiteTeam losed 1 Points and  Score Now for WhiteTeam:" + Game.Team.WScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                            }
                        }
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10004)
                    {
                        if (attacked.Hitpoints <= damage)
                        {
                            attacked.Hitpoints = 0;
                            if (Game.Team.BLScore > 0)
                            {
                                Game.Team.BLScore -= 1;
                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("[CaptureTheFlag] BlackFlag has Destroyed and BlackTeam losed 1 Points and  Score Now for BlackTeam:" + Game.Team.BLScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                            }
                        }
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10011)
                    {
                        if (attacked.Hitpoints <= damage)
                            attacked.Hitpoints = 0;
                        attacker.AddFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                        Game.Team.RedCapture = true;
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10012)
                    {
                        if (attacked.Hitpoints <= damage)
                            attacked.Hitpoints = 0;
                        attacker.AddFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                        Game.Team.BlueCapture = true;
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10013)
                    {
                        if (attacked.Hitpoints <= damage)
                            attacked.Hitpoints = 0;
                        attacker.AddFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                        Game.Team.WhiteCapture = true;
                    }
                }
                if (attacker.MapID == 2060)
                {
                    if (attacked.UID == 10014)
                    {
                        if (attacked.Hitpoints <= damage)
                            attacked.Hitpoints = 0;
                        attacker.AddFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                        Game.Team.BlackCapture = true;
                    }
                }
                if (attacker.MapID == 2071)
                {
                    if (attacked.UID == 811)
                    {
                        if (Game.ConquerStructures.Society.EliteGuildWar.PoleKeeper == attacker.Owner.Guild)
                            return;
                        if (attacked.Hitpoints <= damage)
                            attacked.Hitpoints = 0;
                        Game.ConquerStructures.Society.EliteGuildWar.AddScore(damage, attacker.Owner.Guild);
                    }
                }
                if (attacker.MapID == 1509)
                {
                    if (attacked.UID == 812)
                    {
                        if (Game.ClanWar.PoleKeeper == attacker.Myclan)
                            return;
                        if (attacked.Hitpoints <= damage)
                            attacked.Hitpoints = 0;
                        Game.ClanWar.AddScore(damage, attacker.Myclan);
                    }
                }
                if (attack.AttackType == Attack.Magic)
                {
                    if (attacked.Hitpoints <= damage)
                    {
                        attacked.Die(attacker);
                    }
                    else
                    {
                        attacked.Hitpoints -= damage;
                    }
                }
                else
                {
                    attacker.Owner.SendScreen(attack, true);
                    if (attacked.Hitpoints <= damage)
                    {
                        attacked.Die(attacker);
                    }
                    else
                    {
                        attacked.Hitpoints -= damage;
                        attacker.AttackPacket = attack;
                        attacker.AttackStamp = Time32.Now;
                    }
                }
            }
        }