Пример #1
0
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            int armour = 0;

            switch (type)
            {
                case DefenceType.ACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetDefencePower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.Agility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    break;
            }

            if (armour >= damage) return 0;

            if (damageWeapon)
                attacker.DamageWeapon();

            ShockTime = 0;

            for (int i = PoisonList.Count - 1; i >= 0; i--)
            {
                if (PoisonList[i].PType != PoisonType.LRParalysis) continue;

                PoisonList.RemoveAt(i);
                OperateTime = 0;
            }

            if (Master != null && Master != attacker)
                if (Envir.Time > Master.BrownTime && Master.PKPoints < 200)
                    attacker.BrownTime = Envir.Time + Settings.Minute;

            if (EXPOwner == null || EXPOwner.Dead)
                EXPOwner = attacker;

            if (EXPOwner == attacker)
                EXPOwnerTime = Envir.Time + EXPOwnerDelay;

            Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });
            attacker.GatherElement();
            ChangeHP(-1);

            return 1;
        }
Пример #2
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;

            switch (type)
            {
                case DefenceType.ACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetDefencePower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetDefencePower(MinAC, MaxAC);
                    break;
                case DefenceType.Agility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    break;
            }

            if (armour >= damage) return 0;

            ShockTime = 0;

            for (int i = PoisonList.Count - 1; i >= 0; i--)
            {
                if (PoisonList[i].PType != PoisonType.LRParalysis) continue;

                PoisonList.RemoveAt(i);
                OperateTime = 0;
            }

            if (attacker.Info.AI == 6)
                EXPOwner = null;
            else if (attacker.Master != null)
            {
                if (EXPOwner == null || EXPOwner.Dead)
                    EXPOwner = attacker.Master;

                if (EXPOwner == attacker.Master)
                    EXPOwnerTime = Envir.Time + EXPOwnerDelay;

            }

            Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });

            ChangeHP(-1);
            return 1;
        }
Пример #3
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;

            switch (type)
            {
            case DefenceType.ACAgility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
                break;

            case DefenceType.AC:
                armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
                break;

            case DefenceType.MACAgility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
                break;

            case DefenceType.MAC:
                armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
                break;

            case DefenceType.Agility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                break;
            }

            if (armour >= damage)
            {
                return(0);
            }

            ShockTime = 0;

            for (int i = PoisonList.Count - 1; i >= 0; i--)
            {
                if (PoisonList[i].PType != PoisonType.LRParalysis)
                {
                    continue;
                }

                PoisonList.RemoveAt(i);
                OperateTime = 0;
            }

            if (attacker.Info.AI == 6)
            {
                EXPOwner = null;
            }
            else if (attacker.Master != null)
            {
                if (EXPOwner == null || EXPOwner.Dead)
                {
                    EXPOwner = attacker.Master switch
                    {
                        HeroObject hero => hero.Owner,
                                   _ => attacker.Master
                    }
                }
                ;

                if (EXPOwner == attacker.Master)
                {
                    EXPOwnerTime = Envir.Time + EXPOwnerDelay;
                }
            }

            Broadcast(new S.ObjectStruck {
                ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation
            });

            ChangeHP(-1);
            return(1);
        }
Пример #4
0
        public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            int armour = 0;

            switch (type)
            {
            case DefenceType.ACAgility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
                break;

            case DefenceType.AC:
                armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
                break;

            case DefenceType.MACAgility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
                break;

            case DefenceType.MAC:
                armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
                break;

            case DefenceType.Agility:
                if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy])
                {
                    return(0);
                }
                break;
            }

            if (armour >= damage)
            {
                return(0);
            }

            if (damageWeapon)
            {
                attacker.DamageWeapon();
            }

            ShockTime = 0;

            for (int i = PoisonList.Count - 1; i >= 0; i--)
            {
                if (PoisonList[i].PType != PoisonType.LRParalysis)
                {
                    continue;
                }

                PoisonList.RemoveAt(i);
                OperateTime = 0;
            }

            if (Master != null && Master != attacker)
            {
                if (Envir.Time > Master.BrownTime && Master.PKPoints < 200)
                {
                    attacker.BrownTime = Envir.Time + Settings.Minute;
                }
            }

            if (EXPOwner == null || EXPOwner.Dead)
            {
                EXPOwner = GetAttacker(attacker);
            }

            if (EXPOwner == attacker)
            {
                EXPOwnerTime = Envir.Time + EXPOwnerDelay;
            }

            Broadcast(new S.ObjectStruck {
                ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation
            });
            attacker.GatherElement();
            ChangeHP(-1);

            return(1);
        }