Exemplo n.º 1
0
        private static void AutoRespone(Entity attacker, Entity attacked, ref int Damage)
        {
            try
            {
                if (attacked.EntityFlag == EntityFlag.Player)
                {
                    if (attacked.CounterKillSwitch && ServerBase.Kernel.Rate(10) && !attacked.ContainsFlag(Update.Flags.Fly) && Time32.Now > attacker.CounterKillStamp.AddSeconds(15))
                    {
                        attacker.CounterKillStamp = Time32.Now;
                        uint damage = Melee(attacked, attacker);
                        Database.SpellInformation information = Database.SpellTable.SpellInformations[6003][attacked.Owner.Spells[6003].Level];
                        damage = (uint)(Percent((int)damage, information.Percent) / 100);
                        Network.GamePackets.Attack attack = new Conquer_Online_Server.Network.GamePackets.Attack(true);
                        attack.Attacked = attacker.UID;
                        attack.Attacker = attacked.UID;
                        attack.AttackType = Network.GamePackets.Attack.Scapegoat;
                        attack.Damage = 0;
                        attack.ResponseDamage = damage;
                        attack.X = attacked.X;
                        attack.Y = attacked.Y;

                        if (attacker.Hitpoints <= damage)
                        {
                            if (attacker.EntityFlag == EntityFlag.Player)
                            {
                                if (attacked.Owner.QualifierGroup != null)
                                    attacked.Owner.QualifierGroup.UpdateDamage(attacked.Owner, attacker.Hitpoints);
                                attacker.Owner.SendScreen(attack, true);
                                attacked.AttackPacket = null;
                            }
                            else
                            {
                                attacker.MonsterInfo.SendScreen(attack);
                            }
                            attacker.Die(attacked);
                        }
                        else
                        {
                            attacker.Hitpoints -= damage;
                            if (attacker.EntityFlag == EntityFlag.Player)
                            {
                                if (attacked.Owner.QualifierGroup != null)
                                    attacked.Owner.QualifierGroup.UpdateDamage(attacked.Owner, damage);
                                attacker.Owner.SendScreen(attack, true);
                            }
                            else
                            {
                                attacker.MonsterInfo.SendScreen(attack);
                            }
                        }
                        Damage = 0;
                    }
                    else if (attacked.Owner.Spells.ContainsKey(3060) && ServerBase.Kernel.Rate(10))
                    {
                        uint damage = (uint)(Damage / 10);
                        if (damage <= 0)
                            damage = 1;
                        Network.GamePackets.Attack attack = new Conquer_Online_Server.Network.GamePackets.Attack(true);
                        attack.Attacked = attacker.UID;
                        attack.Attacker = attacked.UID;
                        attack.AttackType = Network.GamePackets.Attack.Reflect;
                        attack.Damage = damage;
                        attack.ResponseDamage = damage;
                        attack.X = attacked.X;
                        attack.Y = attacked.Y;

                        if (attacker.Hitpoints <= damage)
                        {
                            if (attacker.EntityFlag == EntityFlag.Player)
                            {
                                if (attacked.Owner.QualifierGroup != null)
                                    attacked.Owner.QualifierGroup.UpdateDamage(attacked.Owner, attacker.Hitpoints);
                                attacker.Owner.SendScreen(attack, true);
                                attacked.AttackPacket = null;
                            }
                            else
                            {
                                attacker.MonsterInfo.SendScreen(attack);
                            }
                            attacker.Die(attacked);
                        }
                        else
                        {
                            attacker.Hitpoints -= damage;
                            if (attacker.EntityFlag == EntityFlag.Player)
                            {
                                if (attacked.Owner.QualifierGroup != null)
                                    attacked.Owner.QualifierGroup.UpdateDamage(attacked.Owner, damage);
                                attacker.Owner.SendScreen(attack, true);
                            }
                            else
                            {
                                attacker.MonsterInfo.SendScreen(attack);
                            }
                        }
                        Damage = 0;
                    }
                }
            }
            catch (Exception e) { Program.SaveException(e); }
        }
Exemplo n.º 2
0
        public static uint Ranged(Entity attacker, Entity attacked, Database.SpellInformation spell)
        {
            if (attacked.Name.Contains("Guard1"))
                return 1;
            int Damage = 0;
            Durability(attacker, attacked, null);

            if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                return 1;
            if (attacker.Transformed)
                return 0;
            if (attacker.Name.Contains("Guard1"))
                return 700000;
            Damage = ServerBase.Kernel.Random.Next(Math.Min((int)attacker.MinAttack, (int)attacker.MaxAttack), Math.Max((int)attacker.MinAttack, (int)attacker.MaxAttack) + 1);

            if (attacker.OnSuperman())
                if (attacked.EntityFlag == EntityFlag.Monster)
                    Damage *= 10;
                else
                    Damage *= 2;

            if (attacker.OnFatalStrike())
                if (attacked.EntityFlag == EntityFlag.Monster)
                    Damage *= 5;

            if (!attacked.Transformed)
                Damage -= attacked.Defence;
            else
                Damage -= attacked.TransformationDefence;

            Damage -= Damage * attacked.ItemBless / 100;

            byte dodge = attacked.Dodge;
            if (dodge > 100)
                dodge = 99;
            if (!attacked.Transformed)
                Damage -= Damage * dodge / 100;
            else
                Damage -= Damage * attacked.TransformationDodge / 100;

            if (attacker.OnIntensify && Time32.Now >= attacker.IntensifyStamp.AddSeconds(4))
            {
                Damage *= 2;
                attacker.OnIntensify = false;
            }

            if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                if (!attacker.Transformed)
                    Damage = (int)(Damage * attacker.StigmaIncrease);

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (attacked.MapID < 1351 || attacked.MapID > 1354)
                    Damage = (int)(Damage * (1 + (GetLevelBonus(attacker.Level, attacked.Level) * 0.08)));

                if (attacked.MapID < 1351 || attacked.MapID > 1354)
                    Damage = (int)(Damage * AttackMultiplier(attacker, attacked));
            }
            Damage = BattlePowerCalculation(Damage, attacker.BattlePower - attacked.BattlePower);
            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 (ServerBase.Kernel.Rate(5))
            {
                if (attacked.EntityFlag == EntityFlag.Player)
                {
                    if (attacked.Owner.BlessTime > 0)
                    {
                        Damage = 1;
                        _String str = new _String(true);
                        str.UID = attacker.UID;
                        str.TextsCount = 1;
                        str.Type = _String.Effect;
                        str.Texts.Add("LuckyGuy");
                        attacked.Owner.SendScreen(str, true);
                    }
                }
            }
            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (Damage >= 700 * attacked.MaxHitpoints)
                    Damage = (int)(700 * attacked.MaxHitpoints);
            }

            if (spell.PowerPercent != 0)
                Damage = (int)(Damage * spell.PowerPercent);

            Damage += attacker.PhysicalDamageIncrease;
            Damage -= attacked.PhysicalDamageDecrease;

            if (Damage <= 0)
                Damage = 1;
            AutoRespone(attacker, attacked, ref Damage);
            if (attacked.ContainsFlag(Update.Flags.AzureShield))
            {
                if (Damage >= attacked.AzureDamage)
                {
                    Damage -= attacked.AzureDamage;
                    attacked.AzureDamage = 0;

                }
                else
                {
                    attacked.AzureDamage -= Damage;
                    Damage = 0;
                }
            }
            return (uint)Damage;
        }
Exemplo n.º 3
0
        public static uint Ranged(Entity attacker, SobNpcSpawn attacked)
        {
            int Damage = 0;
            Durability(attacker, null, null);
            if (attacker.Transformed)
                return 0;
            if (attacked.UID == 810 && attacker.Owner.Guild != null)
            {
                if (Game.ConquerStructures.Society.GuildWar.PoleKeeper == attacker.Owner.Guild)
                {
                    return 0;
                }
            }
            Damage = ServerBase.Kernel.Random.Next(Math.Min((int)attacker.MinAttack, (int)attacker.MaxAttack), Math.Max((int)attacker.MinAttack, (int)attacker.MaxAttack) + 1);

            if (attacker.OnIntensify && Time32.Now >= attacker.IntensifyStamp.AddSeconds(4))
            {
                Damage *= 2;

                attacker.OnIntensify = false;
            }

            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.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                if (!attacker.Transformed)
                    Damage = (int)(Damage * attacker.StigmaIncrease);

            Damage += attacker.PhysicalDamageIncrease;
            if (Damage <= 0)
                Damage = 1;
            return (uint)Damage;
        }
Exemplo n.º 4
0
        public static uint Melee(Entity attacker, Entity attacked, Database.SpellInformation spell)
        {
            if (attacked.Name.Contains("Guard1"))
                return 1;
            int Damage = 0;

            if (attacker.EntityFlag == EntityFlag.Monster)
                if (attacked.EntityFlag == EntityFlag.Player)
                    if (ServerBase.Kernel.Rate(Math.Min(60, attacked.Dodge + 30)))
                        return 0;

            Durability(attacker, attacked, null);
            if (attacker.Name.Contains("Guard1"))
                return 700000;
            if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                return 1;
            if (!attacker.Transformed)
                Damage = ServerBase.Kernel.Random.Next(Math.Min((int)attacker.MinAttack, (int)attacker.MaxAttack), Math.Max((int)attacker.MinAttack, (int)attacker.MaxAttack) + 1);
            else
                Damage = ServerBase.Kernel.Random.Next((int)attacker.TransformationMinAttack, (int)attacker.TransformationMaxAttack + 1);

            if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                if (!attacker.Transformed)
                    Damage = (int)(Damage * attacker.StigmaIncrease);

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (attacked.MapID < 1351 || attacked.MapID > 1354)
                    Damage = (int)(Damage * (1 + (GetLevelBonus(attacker.Level, attacked.Level) * 0.08)));
            }
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                if (attacked.EntityFlag == EntityFlag.Monster)
                {
                    if (attacked.MapID < 1351 || attacked.MapID > 1354)
                        if (!attacker.Owner.Equipment.Free(4) && !attacker.Owner.Equipment.Free(5))
                            Damage = (int)(Damage * 1.5);
                }
                if (attacked.EntityFlag == EntityFlag.Monster)
                    if (attacked.MapID < 1351 || attacked.MapID > 1354)
                        Damage = (int)(Damage * AttackMultiplier(attacker, attacked));
                // if (attacker.OnSuperman())
                //     if (attacked.EntityFlag == EntityFlag.Monster)
                //         Damage *= 10;

                if (attacker.OnFatalStrike())
                    if (attacked.EntityFlag == EntityFlag.Monster)
                        Damage *= 5;
            }
            if (!attacked.Transformed)
            {
                if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.MagicShield))
                {
                    if (attacked.ShieldTime > 0)
                        Damage -= (ushort)(attacked.Defence * attacked.ShieldIncrease);
                    else
                        Damage -= (ushort)(attacked.Defence * attacked.MagicShieldIncrease);
                }
                else
                {
                    Damage -= attacked.Defence;
                }
            }
            else
                Damage -= attacked.TransformationDefence;
            Damage = BattlePowerCalculation(Damage, attacker.BattlePower - attacked.BattlePower);
            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 (ServerBase.Kernel.Rate(5))
            {
                if (attacked.EntityFlag == EntityFlag.Player)
                {
                    if (attacked.Owner.BlessTime > 0)
                    {
                        Damage = 1;
                        _String str = new _String(true);
                        str.UID = attacker.UID;
                        str.TextsCount = 1;
                        str.Type = _String.Effect;
                        str.Texts.Add("LuckyGuy");
                        attacked.Owner.SendScreen(str, true);
                    }
                }
            }
            if (spell.ID == 6000 && attacked.EntityFlag == EntityFlag.Monster)
            {
                if (spell.PowerPercent != 0)
                    Damage = (int)(Damage * spell.PowerPercent);
            }
            else if (spell.ID != 6000)
            {
                if (spell.PowerPercent != 0)
                    Damage = (int)(Damage * spell.PowerPercent);
            }
            Damage = RemoveExcessDamage(Damage, attacker, attacked);

            Damage += attacker.PhysicalDamageIncrease;
            Damage -= attacked.PhysicalDamageDecrease;

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (Damage >= 700 * attacked.MaxHitpoints)
                    Damage = (int)(700 * attacked.MaxHitpoints);
            }
            if (Damage <= 0)
                Damage = 1;

            AutoRespone(attacker, attacked, ref Damage);

            if (attacked.ContainsFlag(Update.Flags.AzureShield))
            {
                if (Damage >= attacked.AzureDamage)
                {
                    Damage -= attacked.AzureDamage;
                    attacked.AzureDamage = 0;

                }
                else
                {
                    attacked.AzureDamage -= Damage;
                    Damage = 0;
                }
            }
            if (attacker.OnSuperman())
                if (attacked.EntityFlag == EntityFlag.Monster)
                    Damage *= 10;
            if (attacker.NobilityRank != attacked.NobilityRank)
            {
                int addnobility_damage = 0;
                if ((byte)attacker.NobilityRank == 12)
                    addnobility_damage = (Damage * ((byte)attacker.NobilityRank + 45)) / 100;
                else
                    if ((byte)attacker.NobilityRank > 5)
                        addnobility_damage = (Damage * ((byte)attacker.NobilityRank + 25)) / 100;
                if ((byte)attacked.NobilityRank > 5)
                {
                    if ((addnobility_damage - (uint)((Damage * ((byte)attacked.NobilityRank + 8)) / 100)) > 0)
                    {
                        addnobility_damage -= (int)((Damage * ((byte)attacked.NobilityRank + 8)) / 100);
                    }
                    else
                    {
                        if (Damage > (uint)((Damage * ((byte)attacked.NobilityRank + 8)) / 100))
                        {
                            Damage -= (int)((Damage * ((byte)attacked.NobilityRank + 8)) / 100);
                        }
                        else
                            Damage = 1;
                    }
                }
                if (Damage != 1)
                {
                    Damage += addnobility_damage;
                }
            }
            return (uint)Damage;
        }
Exemplo n.º 5
0
        public static uint Magic(Entity attacker, Entity attacked, Database.SpellInformation spell)
        {
            if (!ServerBase.Kernel.Rate(spell.Percent))
                return 0;
            Durability(attacker, attacked, spell);
            if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                return 1;
            if (attacker.Transformed)
                return 0;
            if (attacker.Name.Contains("Guard1"))
                return 700000;
            int Damage = 0;
            Damage = (int)attacker.MagicAttack;
            Damage += spell.Power;

            if (!attacked.Transformed)
            {
                //(uint)((double)damage * (100 - Attacked.Entity.ItemBless) / 95);
                // Damage -= (int)((uint)(attacked.MagicDefencePercent * Damage / 100));
                if (attacked.ItemBless > 60)
                    attacked.ItemBless = 58;
                Damage = (int)((uint)((double)Damage * (100 - attacked.ItemBless) / 340));
                Damage -= attacked.MagicDefence;

            }
            else
                Damage = (int)(((Damage * 0.75) * (1 - (0 * 0.01))) - attacked.TransformationMagicDefence);

            if (attacked.EntityFlag == EntityFlag.Monster)
                if (attacked.MapID < 1351 || attacked.MapID > 1354)
                    Damage = (int)(Damage * AttackMultiplier(attacker, attacked) / 2);

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                Damage = (int)(Damage * 6.6);
                if (attacked.MapID < 1351 || attacked.MapID > 1354)
                    Damage = (int)(Damage * (1 + (GetLevelBonus(attacker.Level, attacked.Level) * 0.08)));
            }

            Damage = BattlePowerCalculation(Damage, attacker.BattlePower - attacked.BattlePower);

            //  Damage = RemoveExcessDamage(Damage, attacker, attacked);
            //   Console.WriteLine("[3]" + Damage);
            if (ServerBase.Kernel.Rate(5))
            {
                if (attacker.EntityFlag == EntityFlag.Player)
                {
                    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 (ServerBase.Kernel.Rate(5))
            {
                if (attacked.EntityFlag == EntityFlag.Player)
                {
                    if (attacked.Owner.BlessTime > 0)
                    {
                        Damage = 1;
                        _String str = new _String(true);
                        str.UID = attacker.UID;
                        str.TextsCount = 1;
                        str.Type = _String.Effect;
                        str.Texts.Add("LuckyGuy");
                        attacked.Owner.SendScreen(str, true);
                    }
                }
            }

            Damage += attacker.MagicDamageIncrease;
            Damage -= attacked.MagicDamageDecrease;

            if (Damage <= 0)
                Damage = 1;

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (Damage >= 700 * attacked.MaxHitpoints)
                    Damage = (int)(700 * attacked.MaxHitpoints);
            }
            else
            {
                if (attacker.EntityFlag == EntityFlag.Monster)
                {
                    if (attacker.Name.Contains("Guard1"))
                        Damage = (int)attacked.MaxHitpoints + 1;
                }
            }

            AutoRespone(attacker, attacked, ref Damage);
            if (attacked.ContainsFlag(Update.Flags.AzureShield))
            {
                if (Damage >= attacked.AzureDamage)
                {
                    Damage -= attacked.AzureDamage;
                    attacked.AzureDamage = 0;

                }
                else
                {
                    attacked.AzureDamage -= Damage;
                    Damage = 0;
                }
            }
            return (uint)Damage;
        }
Exemplo n.º 6
0
        public static uint Melee(Entity attacker, Entity attacked)
        {
            if (attacked.Name.Contains("Guard1"))
                return 1;
            int Damage = 0;
            if (attacker.MinAttack > attacker.MaxAttack)
            {
                return 0;
            }
            //int Damage = 0;
            //int Damage = Kernel.Rand.Next((int)attacker.MinAttack, (int)attacker.MaxAttack);
            int Leveldiffs = (attacker.Level + 2) - attacked.Level;
            int Damageadds = (int)Math.Floor(1 + (Leveldiffs / 5) * 0.8);
            if (Damageadds > 1)
                Damage = Damageadds * Damage;
            Damage -= attacked.Defence;
            if (attacked.Reborn == 1)
            {
                Damage = (int)Math.Floor(Damage * .7);
            }
            else if (attacked.Reborn == 2)
            {
                Damage = (int)Math.Floor(Damage * .7);
                if (attacker.Reborn < 2)
                    Damage = (int)Math.Floor(Damage * .5);
            }
            double Tort = 0;
            Tort += attacked.Gems[7] * 0.02;
            Tort += attacked.Gems[7] * 0.04;
            Tort += attacked.Gems[7] * 0.06;
            Damage = (int)Math.Floor(Damage * (1 - Tort));
            if (attacked.ItemBless > 0)
            {
                Damage = (int)Math.Floor(Damage * (1 - (attacked.ItemBless * 0.01)));
            }
            //if (attacker.EntityFlag == EntityFlag.Monster)
            //    if (attacked.EntityFlag == EntityFlag.Player)
            //        if (ServerBase.Kernel.Rate(Math.Min(60, attacked.Dodge + 30)))
            //            return 0;

            Durability(attacker, attacked, null);

            if (attacker.Name.Contains("Guard1"))
                return 700000;
            if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                return 1;
            if (!attacker.Transformed)
                Damage = ServerBase.Kernel.Random.Next(Math.Min((int)attacker.MinAttack, (int)attacker.MaxAttack), Math.Max((int)attacker.MinAttack, (int)attacker.MaxAttack) + 1);
            else
                Damage = ServerBase.Kernel.Random.Next((int)attacker.TransformationMinAttack, (int)attacker.TransformationMaxAttack + 1);

            if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                if (!attacker.Transformed)
                    Damage = (int)(Damage * attacker.StigmaIncrease);

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (attacked.MapID < 1351 || attacked.MapID > 1354)
                    Damage = (int)(Damage * (1 + (GetLevelBonus(attacker.Level, attacked.Level) * 0.08)));
            }
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                if (attacked.EntityFlag == EntityFlag.Monster)
                {
                    if (attacked.MapID < 1351 || attacked.MapID > 1354)
                        if (!attacker.Owner.Equipment.Free(4) && !attacker.Owner.Equipment.Free(5))
                            Damage = (int)(Damage * 1.5);
                }
                if (attacked.EntityFlag == EntityFlag.Monster)
                    if (attacked.MapID < 1351 || attacked.MapID > 1354)
                        Damage = (int)(Damage * AttackMultiplier(attacker, attacked));
                if (attacker.OnSuperman())
                    if (attacked.EntityFlag == EntityFlag.Monster)

                        if (attacker.ContainsFlag(Update.Flags.Oblivion))
                            if (attacked.EntityFlag == EntityFlag.Monster)
                                Damage *= 2;

                if (attacker.OnFatalStrike())
                    if (attacked.EntityFlag == EntityFlag.Monster)
                        Damage *= 5;
            }
            if (!attacked.Transformed)
            {
                if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.MagicShield))
                {
                    if (attacked.ShieldTime > 0)
                        Damage -= (ushort)(attacked.Defence * attacked.ShieldIncrease);
                    else
                        Damage -= (ushort)(attacked.Defence * attacked.MagicShieldIncrease);
                }
                else
                {
                    Damage -= attacked.Defence;
                }
            }
            else
                Damage -= attacked.TransformationDefence;

            // Damage = BattlePowerCalculation(Damage, attacker.BattlePower - attacked.BattlePower);

            //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 (ServerBase.Kernel.Rate(5))
            //{
            //    if (attacked.EntityFlag == EntityFlag.Player)
            //    {
            //        if (attacked.Owner.BlessTime > 0)
            //        {
            //            Damage = 1;
            //            _String str = new _String(true);
            //            str.UID = attacker.UID;
            //            str.TextsCount = 1;
            //            str.Type = _String.Effect;
            //            str.Texts.Add("LuckyGuy");
            //            attacked.Owner.SendScreen(str, true);
            //        }
            //    }
            //}

            Damage = RemoveExcessDamage(Damage, attacker, attacked);

            Damage += attacker.PhysicalDamageIncrease;
            Damage -= attacked.PhysicalDamageDecrease;

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (attacked.Name != "Guard1" && attacked.Name != "Guard2")
                {
                    int Leveldiff = (attacker.Level + 2) - attacked.Level;
                    int Damageadd = (int)Math.Floor(1 + (Leveldiff / 5) * 0.8);
                    if (Damageadd > 1)
                        Damage = Damageadd * Damage;
                }
                Damage -= attacked.Defence;
                if (Damage >= 700 * attacked.MaxHitpoints)
                    Damage = (int)(700 * attacked.MaxHitpoints);
            }
            if (Damage <= 0)
                Damage = 1;

            AutoRespone(attacker, attacked, ref Damage);

            if (attacked.ContainsFlag(Update.Flags.AzureShield))
            {
                if (Damage >= attacked.AzureDamage)
                {
                    Damage -= attacked.AzureDamage;
                    attacked.AzureDamage = 0;

                }
                else
                {
                    attacked.AzureDamage -= Damage;
                    Damage = 0;
                }

            }
            return (uint)Damage;
        }
        public static uint Magic(Entity Attacker, Entity Attacked, Database.SpellInformation SInfo, ref Attack Packet)
        {
            if (Attacked.EntityFlag == EntityFlag.Player)
            {
                BlessEffect.Effect(Attacked);
            }
            if (Attacker.EntityFlag == EntityFlag.Player)
            {
                GemEffect.Effect(Attacker);
            }
            Boolean CritImmune = false;
            switch (Attacked.EntityFlag)
            {
                case EntityFlag.Player:
                    {
                        if (Attacker.EntityFlag == EntityFlag.Monster)
                        {
                            if (!Attacked.ContainsFlag(Update.Flags.Stigma) && Attacker.Name == "StigGuard")
                            {
                                Attacked.AddFlag(Update.Flags.Stigma);
                                Attacked.StigmaStamp = Time32.Now;
                                Attacked.StigmaIncrease = 25;
                                Attacked.StigmaTime = (byte)20;
                                if (Attacked.EntityFlag == EntityFlag.Player)
                                    Attacked.Owner.Send(ServerBase.Constants.Stigma(30, 20));
                                return 0;
                            }
                            if (Attacked.ContainsFlag(Update.Flags.Stigma) && Attacker.Name == "StigGuard")
                            {

                                return 0;
                            }
                            if (Attacked.Dead && Attacker.Name == "RevGuard")
                            {
                                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.Send(new MapStatus() { BaseID = (ushort)Attacked.Owner.Map.BaseID, ID = (uint)Attacked.Owner.Map.ID, Status = Database.MapsTable.MapInformations[Attacked.Owner.Map.ID].Status, Weather = Database.MapsTable.MapInformations[Attacked.Owner.Map.ID].Weather });
                                //Attacked.Owner.Entity.Teleport(Attacked.Owner.Entity.MapID, Attacked.Owner.Entity.X, Attacked.Owner.Entity.Y);
                                return 0;
                            }
                        }
                        Int32 Damage = 0;
                        Int32 Defence = 0;
                        if (ChanceSuccess((float)Attacked.Immunity / 100f))
                            CritImmune = true;
                        Int32 Fan = 0, Tower = 0;
                        if (Attacker.EntityFlag == EntityFlag.Player)
                            Fan = Attacker.getFan(true);
                        if (Attacked.EntityFlag == EntityFlag.Player)
                            Tower = Attacked.getTower(true);
                        Damage = (int)Attacker.MagicAttack;
                        
                        if (Attacked.EntityFlag == EntityFlag.Player)
                            if (Attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                                return 1;

                        if (Miss(SInfo.Percent))
                            return 0;

                        Defence = (Int32)Attacked.MagicDefence;
                        Defence = (Int32)Attacked.MagicDamageDecrease;

                      
                       
                        if (Attacked.EntityFlag == EntityFlag.Player)
                        {
                            if (Attacked.Reborn == 1)
                                Damage = (Int32)(Damage * 0.69);
                            if (Attacked.Reborn == 2)
                                Damage = (Int32)(Damage * 0.49);
                        }
                        Damage += Fan;
                        if (Attacker.EntityFlag == EntityFlag.Player)
                            Damage += Attacker.MagicDamageIncrease;
                        //UInt32 bpdmage = 0, bpdefence = 0;
                        //if (Attacked.EntityFlag == EntityFlag.Player)
                            //bpdefence = (UInt32)(Attacked.BattlePower * 3.5);
                        //Damage -= (int)bpdefence;
                        //Damage -= Attacked.MagicDamageDecrease;
                        Damage -= Defence;
                        Damage -= Tower;
                        //if (Damage <= 1) Damage = 1;

                        //return (UInt32)Damage;

                        
                        //if (Damage <= 1) Damage = 1;
                        //return (UInt32)Damage;
                        //the new block offers us the behavior of the melee response.

                        if (!CritImmune)
                        {
                            if (ChanceSuccess((float)Attacker.SkillCStrike / 100f))
                            {
                                Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
                                Damage = (Int32)Math.Floor((float)Damage * 1.3);
                            }
                        }
                        if (Attacked.EntityFlag == EntityFlag.Player)
                        {
                            if (ChanceSuccess((float)Attacked.Block / 100f))
                            {
                                Packet.Effect1 |= Attack.AttackEffects1.Block;
                                Damage = (Int32)Math.Floor((float)Damage / 2);
                            }
                        }

                        if (Damage <= 0)
                            Damage = 1;
                        Damage = Damage / 3;

                        AutoRespone(Attacker, Attacked, ref Damage);
                        if (ServerBase.Constants.Damage1Map.Contains(Attacker.MapID))
                            Damage = 1;
                        
                        //Console.WriteLine(Damage.ToString() + "       7");
                        if (Attacked.ContainsFlag2(Network.GamePackets.Update.Flags2.AzureShield))
                        {

                            if (Attacked.AzureDamage >= Damage)
                            {
                                // Console.WriteLine("^^^^Damage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
                                Attacked.AzureDamage -= Damage;
                                int sec = 60 - (Time32.Now - Attacked.MagicShieldStamp).AllSeconds();
                               // Attacked.Owner.Send(ServerBase.Constants.Shield(Attacked.AzureDamage, sec));
                                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)sec,
                                    Value = (uint)Attacked.AzureDamage,
                                    Level = 4
                                };
                                Attacked.Owner.Send((byte[])packet4);
                                //Console.WriteLine("^^^^Damage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
                                return 0;
                            }
                            else
                            {
                                //Console.WriteLine("XXXXDamage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
                                Damage -= Attacked.AzureDamage;
                                Attacked.AzureDamage = 0;
                                Attacked.RemoveFlag2(Update.Flags2.AzureShield);
                                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 = 0,
                                    Value = 0,
                                    Level = 4
                                };
                                Attacked.Owner.Send((byte[])packet4);
                                // Console.WriteLine("XXXXDamage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
                                //Console.WriteLine(Damage.ToString() + "       8");
                                return (uint)Damage;

                            }

                        }
                        
                        if (ServerBase.Constants.Damage1Map.Contains(Attacker.MapID))
                            Damage = 1;
                        return (uint)Damage;
                    }
                case EntityFlag.Monster:
                    {
                        Int32 Damage = 0;
                        Int32 Defence = 0;

                        Int32 Fan = 0;
                        if (Attacker.EntityFlag == EntityFlag.Player)
                            Fan = Attacker.getFan(true);

                        if (Miss(SInfo.Percent))
                            return 0;
                        Damage = (int)Attacker.MagicAttack;
                        if (SInfo != null)
                            Damage += SInfo.Power;
                        Defence = Attacked.MonsterInfo.Level * 20;

                        if (Attacked.MonsterInfo != null)
                            if (Attacked.Name == "Guard1")
                                Damage = Damage/30;
                      

                        Damage += Fan;
                        if (Attacker.EntityFlag == EntityFlag.Player)
                            Damage += Attacker.MagicDamageIncrease;

                       

                        Damage *= (int)(2.5);

                        //Damage += (int)bpdamage;
                        Damage -= Defence;
                        if (!CritImmune)
                        {
                            if (ChanceSuccess((float)Attacker.SkillCStrike / 100f))
                            {
                                Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
                                Damage = (Int32)Math.Floor((float)Damage * 1.2);
                            }
                        }


                        if (Damage <= 1) Damage = 1;
                        if (ServerBase.Constants.Damage1Map.Contains(Attacker.MapID))
                            Damage = 1;
                        return (UInt32)Damage;
                    }
            }
            return 0;
        }
        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 Melee(Entity attacker, Entity attacked, Database.SpellInformation spell, ref Attack Packet)
        {
           
            int Damage = 0;
            Boolean CritImmune = false;
            Boolean canBT = false;
            if (attacker.EntityFlag == EntityFlag.Monster)
                if (attacked.EntityFlag == EntityFlag.Player)
                    if (ServerBase.Kernel.Rate(Math.Min(60, attacked.Dodge + 30)))
                        return 0;
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                GemEffect.Effect(attacker);
            }
            Durability(attacker, attacked, null);

            if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
                return 1;
            if (!attacker.Transformed)
                Damage = ServerBase.Kernel.Random.Next(Math.Min((int)attacker.MinAttack, (int)attacker.MaxAttack), Math.Max((int)attacker.MinAttack, (int)attacker.MaxAttack) + 1);
            else
                Damage = ServerBase.Kernel.Random.Next((int)attacker.TransformationMinAttack, (int)attacker.TransformationMaxAttack + 1);
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                if (attacker.BattlePower < attacked.BattlePower)
                    canBT = true;
            }
            else canBT = false;
            if (canBT)
            {
                if (canBT)
                {
                    if (ChanceSuccess((float)attacked.Counteraction / 100f))
                        canBT = false;
                }
                if (canBT)
                {
                    if (ChanceSuccess((float)attacker.Breaktrough / 100f) && spell.ID != 1115)
                    {
                        Damage = (Int32)attacker.MaxAttack + 3000;
                        Packet.Effect1 |= Attack.AttackEffects1.Penetration;
                    }
                }
            }
            if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                if (!attacker.Transformed && Damage > 1)
                    Damage = (int)(Damage * 1.30);

            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (attacked.MapID < 1351 || attacked.MapID > 1354)
                    Damage = (int)(Damage * (1 + (GetLevelBonus(attacker.Level, attacked.Level) * 0.08)));
            }
            if (attacker.EntityFlag == EntityFlag.Player)
            {
                if (attacked.EntityFlag == EntityFlag.Monster)
                {
                    if (attacked.MapID < 1351 || attacked.MapID > 1354)
                        if (!attacker.Owner.Equipment.Free(4) && !attacker.Owner.Equipment.Free(5))
                            Damage = (int)(Damage * 1.5);
                }
                if (attacked.EntityFlag == EntityFlag.Monster)
                    if (attacked.MapID < 1351 || attacked.MapID > 1354)
                        Damage = (int)(Damage * AttackMultiplier(attacker, attacked));
                if (attacker.OnSuperman())
                    if (attacked.EntityFlag == EntityFlag.Monster)
                        Damage *= 10;
                  

                if (attacker.OnFatalStrike())
                    if (attacked.EntityFlag == EntityFlag.Monster)
                        Damage *= 5;
            }
            if (!attacked.Transformed)
            {
                if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.MagicShield))
                {
                    if (attacked.ShieldTime > 0)
                        Damage -= 1000;
                    else
                        Damage -= (ushort)(attacked.Defence * attacked.MagicShieldIncrease);
                }
                else
                {
                    Damage -= attacked.Defence;
                }
            }
            else
                Damage -= attacked.TransformationDefence;

            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 (ServerBase.Kernel.Rate(5))
            {
                if (attacked.EntityFlag == EntityFlag.Player)
                {
                    if (attacked.Owner.BlessTime > 0)
                    {
                        Damage = 1;
                        _String str = new _String(true);
                        str.UID = attacker.UID;
                        str.TextsCount = 1;
                        str.Type = _String.Effect;
                        str.Texts.Add("LuckyGuy");
                        attacked.Owner.SendScreen(str, true);
                    }
                }
            }
            if (spell.ID == 6000 && attacked.EntityFlag == EntityFlag.Monster)
            {
                if (spell.PowerPercent != 0)
                    Damage = (int)(Damage * spell.PowerPercent);
            }
            else if (spell.ID != 6000)
            {
                if (spell.PowerPercent != 0)
                    Damage = (int)(Damage * spell.PowerPercent);
            }

            Damage = RemoveExcessDamage(Damage, attacker, attacked);

            Damage += attacker.PhysicalDamageIncrease;
            Damage -= attacked.PhysicalDamageDecrease;
            if (attacker.EntityFlag == EntityFlag.Player && spell.ID != 1115)
            {
                if (!CritImmune)
                {
                    if (ChanceSuccess((float)attacker.CriticalStrike / 200f) && spell.ID != 1115)
                    {
                        Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
                        Damage = (Int32)Math.Floor((float)Damage * 1.2);
                    }
                }
            }
            if (attacked.EntityFlag == EntityFlag.Monster)
            {
                if (Damage >= 700 * attacked.MaxHitpoints)
                    Damage = (int)(700 * attacked.MaxHitpoints);
            }

            //Damage += Damage;
           Damage = (int)(Damage*1.8);//kimoz
            if (spell.ID == 1115 )
                Damage = Damage / 2;
            if (spell.ID == 11110)
                Damage = (int)(Damage / 1.5);

            /*if (spell.ID == 10315 || spell.ID == 11190)
                Damage = Damage / 2;*/
            

            if (Damage <= 0)
                Damage = 1;
           
            AutoRespone(attacker, attacked, ref Damage);
            if (ServerBase.Constants.Damage1Map.Contains(attacker.MapID))
                Damage = 1;
            try
            {
                if (attacked.EntityFlag == EntityFlag.Player && (attacker.BattlePower < attacked.BattlePower))
                {
                    int sub = attacked.BattlePower - attacker.BattlePower;
                    
                    if (sub == 1)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .50);
                    }
                    if (sub == 2)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .49);
                    }
                    if (sub == 3)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .48);
                    }
                    if (sub == 4)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .47);
                    }
                    if (sub == 5)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .46);
                    }
                    if (sub == 6)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .45);
                    }
                    if (sub == 7)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .44);
                    }
                    if (sub == 8)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .43);
                    }
                    if (sub == 9)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .42);
                    }
                    if (sub == 10)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .41);
                    }
                    if (sub == 11)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .40);
                    }
                    if (sub == 12)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .39);
                    }
                    if (sub == 13)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .38);
                    }
                    if (sub == 14)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .37);
                    }
                    if (sub == 15)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .36);
                    }
                    if (sub == 16)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .35);
                    }
                    if (sub == 17)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .34);
                    }
                    if (sub == 18)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .33);
                    }
                    if (sub == 19)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .32);
                    }
                    if (sub == 20)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .31);
                    }
                    if (sub == 21)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .30);
                    }
                    if (sub == 22)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .29);
                    }
                    if (sub == 23)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .28);
                    }
                    if (sub == 24)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .27);
                    }
                    if (sub == 25)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .26);
                    }
                    if (sub == 26)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .25);
                    }
                    if (sub == 27)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .24);
                    }
                    if (sub == 28)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .23);
                    }
                    if (sub == 29)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .22);
                    }
                    if (sub == 30)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .21);
                    }
                    if (sub == 31)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .20);
                    }
                    if (sub == 32)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .19);
                    }
                    if (sub == 33)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .18);
                    }
                    if (sub == 34)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .17);
                    }
                    if (sub == 35)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .16);
                    }
                    if (sub == 36)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .15);
                    }
                    if (sub == 37)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .14);
                    }
                    if (sub == 38)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .13);
                    }
                    if (sub == 39)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .12);
                    }
                    if (sub == 40)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .11);
                    }
                    if (sub == 41)
                    {
                        Damage = (Int32)Math.Floor((float)Damage * .10);
                    }
                    if (sub > 41)
                    {
                        Damage = 1;
                    }
                }
            }
            catch (Exception ex) { Program.SaveException(ex); }
            
            if (attacked.ContainsFlag2(Network.GamePackets.Update.Flags2.AzureShield))
            {

                if (attacked.AzureDamage >= Damage)
                {
                    // Console.WriteLine("^^^^Damage is " + Damage.ToString() + " Azure is : " + attacked.AzureDamage.ToString());
                    attacked.AzureDamage -= Damage;
                    int sec = 60 - (Time32.Now - attacked.MagicShieldStamp).AllSeconds();
                    //attacked.Owner.Send(ServerBase.Constants.Shield(attacked.AzureDamage, sec));
                    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)sec,
                        Value = (uint)attacked.AzureDamage,
                        Level = 4
                    };
                    attacked.Owner.Send((byte[])packet4);
                    //Console.WriteLine("^^^^Damage is " + Damage.ToString() + " Azure is : " + attacked.AzureDamage.ToString());
                    return 0;
                }
                else
                {
                    // Console.WriteLine("XXXXDamage is " + Damage.ToString() + " Azure is : " + attacked.AzureDamage.ToString());
                    Damage -= attacked.AzureDamage;
                    attacked.AzureDamage = 0;
                    attacked.RemoveFlag2(Update.Flags2.AzureShield);
                    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)0,
                        Value = (uint)0,
                        Level = 4
                    };
                    attacked.Owner.Send((byte[])packet4);
                    // Console.WriteLine("XXXXDamage is " + Damage.ToString() + " Azure is : " + attacked.AzureDamage.ToString());
                    return (uint)Damage;

                }

            }
            if (ServerBase.Constants.Damage1Map.Contains(attacker.MapID))
                Damage = 1;
            return (uint)Damage;
        }
        public static void CheckForExtraWeaponPowers2(Client.GameState client, Entity attacked)
        {
            #region Right Hand
            if (client.Equipment.TryGetItem(ConquerItem.AltRightHand) != null)
            {
                if (client.Equipment.TryGetItem(ConquerItem.AltRightHand).ID != 0)
                {
                    var Item = client.Equipment.TryGetItem(ConquerItem.AltRightHand);
                    if (Item.Effect != Enums.ItemEffect.None)
                    {
                        if (ServerBase.Kernel.Rate(30))
                        {
                            switch (Item.Effect)
                            {
                                case Enums.ItemEffect.HP:
                                    {
                                        SpellUse spellUse = new SpellUse(true);
                                        spellUse.SpellID = 1175;
                                        spellUse.SpellLevel = 4;
                                        spellUse.X = client.Entity.X;
                                        spellUse.Y = client.Entity.Y;
                                        spellUse.Targets.Add(client.Entity.UID, 300);
                                        uint damage = Math.Min(300, client.Entity.MaxHitpoints - client.Entity.Hitpoints);
                                        client.Entity.Hitpoints += damage;
                                        client.SendScreen(spellUse, true);
                                        break;
                                    }
                                case Enums.ItemEffect.MP:
                                    {
                                        SpellUse spellUse = new SpellUse(true);
                                        spellUse.SpellID = 1175;
                                        spellUse.SpellLevel = 2;
                                        spellUse.X = client.Entity.X;
                                        spellUse.Y = client.Entity.Y;
                                        spellUse.Targets.Add(client.Entity.UID, 300);
                                        ushort damage = (ushort)Math.Min(300, client.Entity.MaxMana - client.Entity.Mana);
                                        client.Entity.Mana += damage;
                                        client.SendScreen(spellUse, true);
                                        break;
                                    }
                                case Enums.ItemEffect.Shield:
                                    {
                                        if (client.Entity.ContainsFlag(Update.Flags.MagicShield))
                                            return;
                                        SpellUse spellUse = new SpellUse(true);
                                        spellUse.SpellID = 1020;
                                        spellUse.SpellLevel = 0;
                                        spellUse.X = client.Entity.X;
                                        spellUse.Y = client.Entity.Y;
                                        spellUse.Targets.Add(client.Entity.UID, 120);
                                        client.Entity.ShieldTime = 0;
                                        client.Entity.ShieldStamp = Time32.Now;
                                        client.Entity.MagicShieldStamp = Time32.Now;
                                        client.Entity.MagicShieldTime = 0;

                                        client.Entity.AddFlag(Update.Flags.MagicShield);
                                        client.Entity.MagicShieldStamp = Time32.Now;
                                        client.Entity.MagicShieldIncrease = 2;
                                        client.Entity.MagicShieldTime = 120;
                                        if (client.Entity.EntityFlag == EntityFlag.Player)
                                            client.Send(ServerBase.Constants.Shield(2, 120));
                                        client.SendScreen(spellUse, true);
                                        break;
                                    }
                                case Enums.ItemEffect.Poison:
                                    {
                                        if (attacked != null)
                                        {
                                            if (attacked.EntityFlag == EntityFlag.Player)
                                            {
                                                if (attacked.ContainsFlag(Network.GamePackets.Update.Flags2.IceBlock))
                                                {
                                                    return;
                                                }
                                                if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameMaster)
                                                {
                                                    return;
                                                }
                                                if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager)
                                                {
                                                    return;
                                                }
                                                if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameHelper)
                                                {
                                                    return;
                                                }
                                                if (ServerBase.Constants.PKForbiddenMaps.Contains(client.Entity.MapID))
                                                    return;
                                            }

                                            if (client.Map.BaseID == 700)
                                                return;
                                            if (attacked.UID == client.Entity.UID)
                                                return;
                                            if (attacked.ToxicFogLeft > 0)
                                                return;
                                            Attack attack = new Attack(true);
                                            attack.Effect1 = Attack.AttackEffects1.None;
                                            uint damages = Calculate.Melee(client.Entity, attacked, ref attack);
                                            damages = damages / 2;
                                            //uint damage = Math.Min(1, client.Entity.MinAttack);
                                            SpellUse spellUse = new SpellUse(true);
                                            spellUse.SpellID = 5040;
                                            spellUse.Attacker = attacked.UID;
                                            spellUse.SpellLevel = 9;
                                            spellUse.X = attacked.X;
                                            spellUse.Y = attacked.Y;
                                            spellUse.Targets.Add(attacked.UID, damages);
                                            spellUse.Targets[attacked.UID].Hit = true;
                                            attacked.ToxicFogStamp = Time32.Now;
                                            attacked.ToxicFogLeft = 10;
                                            attacked.ToxicFogPercent = 0.05F;
                                            client.SendScreen(spellUse, true);
                                        }
                                        break;
                                    }
                            }
                        }
                    }
                }
            }
            #endregion
            #region Left Hand
            if (client.Equipment.TryGetItem(ConquerItem.AltLeftHand) != null)
            {
                if (client.Equipment.TryGetItem(ConquerItem.AltLeftHand).ID != 0)
                {
                    var Item = client.Equipment.TryGetItem(ConquerItem.AltLeftHand);
                    if (Item.Effect != Enums.ItemEffect.None)
                    {
                        if (ServerBase.Kernel.Rate(30))
                        {
                            switch (Item.Effect)
                            {
                                case Enums.ItemEffect.HP:
                                    {
                                        SpellUse spellUse = new SpellUse(true);
                                        spellUse.SpellID = 1175;
                                        spellUse.SpellLevel = 4;
                                        spellUse.X = client.Entity.X;
                                        spellUse.Y = client.Entity.Y;
                                        spellUse.Targets.Add(client.Entity.UID, 300);
                                        uint damage = Math.Min(300, client.Entity.MaxHitpoints - client.Entity.Hitpoints);
                                        client.Entity.Hitpoints += damage;
                                        client.SendScreen(spellUse, true);
                                        break;
                                    }
                                case Enums.ItemEffect.MP:
                                    {
                                        SpellUse spellUse = new SpellUse(true);
                                        spellUse.SpellID = 1175;
                                        spellUse.SpellLevel = 2;
                                        spellUse.X = client.Entity.X;
                                        spellUse.Y = client.Entity.Y;
                                        spellUse.Targets.Add(client.Entity.UID, 300);
                                        ushort damage = (ushort)Math.Min(300, client.Entity.MaxMana - client.Entity.Mana);
                                        client.Entity.Mana += damage;
                                        client.SendScreen(spellUse, true);
                                        break;
                                    }
                                case Enums.ItemEffect.Shield:
                                    {
                                        if (client.Entity.ContainsFlag(Update.Flags.MagicShield))
                                            return;
                                        SpellUse spellUse = new SpellUse(true);
                                        spellUse.SpellID = 1020;
                                        spellUse.SpellLevel = 0;
                                        spellUse.X = client.Entity.X;
                                        spellUse.Y = client.Entity.Y;
                                        spellUse.Targets.Add(client.Entity.UID, 120);
                                        client.Entity.ShieldTime = 0;
                                        client.Entity.ShieldStamp = Time32.Now;
                                        client.Entity.MagicShieldStamp = Time32.Now;
                                        client.Entity.MagicShieldTime = 0;

                                        client.Entity.AddFlag(Update.Flags.MagicShield);
                                        client.Entity.MagicShieldStamp = Time32.Now;
                                        client.Entity.MagicShieldIncrease = 2;
                                        client.Entity.MagicShieldTime = 120;
                                        if (client.Entity.EntityFlag == EntityFlag.Player)
                                            client.Send(ServerBase.Constants.Shield(2, 120));
                                        client.SendScreen(spellUse, true);
                                        break;
                                    }
                                case Enums.ItemEffect.Poison:
                                    {
                                        if (attacked != null)
                                        {
                                            if (attacked.EntityFlag == EntityFlag.Player)
                                            {
                                                if (attacked.ContainsFlag(Network.GamePackets.Update.Flags2.IceBlock))
                                                {
                                                    return;
                                                }
                                                if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameMaster)
                                                {
                                                    return;
                                                }
                                                if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager)
                                                {
                                                    return;
                                                }
                                                if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameHelper)
                                                {
                                                    return;
                                                }
                                                if (ServerBase.Constants.PKForbiddenMaps.Contains(client.Entity.MapID))
                                                {
                                                    return;
                                                }
                                            }
                                            if (attacked.UID == client.Entity.UID)
                                                return;

                                            if (client.Map.BaseID == 700)
                                                return;
                                            if (attacked.ToxicFogLeft > 0)
                                                return;
                                            Attack attack = new Attack(true);
                                            attack.Effect1 = Attack.AttackEffects1.None;
                                            uint damages = Calculate.Melee(client.Entity, attacked, ref attack);
                                            damages = damages / 2;
                                            //uint damage = Math.Min(1, client.Entity.MinAttack);
                                            SpellUse spellUse = new SpellUse(true);
                                            spellUse.SpellID = 5040;
                                            spellUse.Attacker = attacked.UID;
                                            spellUse.SpellLevel = 9;
                                            spellUse.X = attacked.X;
                                            spellUse.Y = attacked.Y;
                                            spellUse.Targets.Add(attacked.UID, damages);
                                            spellUse.Targets[attacked.UID].Hit = true;
                                            attacked.ToxicFogStamp = Time32.Now;
                                            attacked.ToxicFogLeft = 10;
                                            attacked.ToxicFogPercent = 0.05F;
                                            client.SendScreen(spellUse, true);
                                        }
                                        break;
                                    }
                            }
                        }
                    }
                }
            }
            #endregion
        }