Example #1
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (DragonLink)
            {
                if (Envir.DragonSystem.LinkedMonster != null)
                {
                    MonsterObject ob = Envir.DragonSystem.LinkedMonster;
                    if (attacker.Info.AI == 6)
                        EXPOwner = null;

                    else if (attacker.Master != null)
                    {
                        if (!Functions.InRange(attacker.CurrentLocation, attacker.Master.CurrentLocation, Globals.DataRange))
                            ob.EXPOwner = null;
                        else
                        {

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

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

                    }
                }
                Envir.DragonSystem.GainExp(Envir.Random.Next(1, 50));
                return 1;
            }

            return 0;
        }
Example #2
0
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            int currentMoveDistance = 0;

            Point target = Functions.PointMove(CurrentLocation, attacker.Direction, _ballMoveDistance);

            MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, target);

            while (currentMoveDistance < _ballMoveDistance)
            {
                Point location = Functions.PointMove(CurrentLocation, dir, 1);

                if (location.X < 0 || location.Y < 0 || location.X >= CurrentMap.Width || location.Y >= CurrentMap.Height) break;

                currentMoveDistance++;

                if (!CurrentMap.GetCell(location).Valid)
                {
                    dir = Functions.ReverseDirection(dir);
                    continue;
                }

                Walk(dir);
                MoveTime = 0;
                ActionTime = 0;
            }

            return 0;
        }
Example #3
0
        // Player attacking trainer.
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = false)
        {
            if (attacker == null) return 0;

            if (_currentAttacker != null && _currentAttacker != attacker)
            {
                OutputAverage();
                ResetStats();
            }
            damage += attacker.AttackBonus;
            _currentAttacker = attacker;
            _hitCount++;
            _totalDamage += damage;
            _lastAttackTime = Envir.Time;

            switch (type)
            {
                case DefenceType.ACAgility:
                    attacker.ReceiveChat(damage + " Physical Agility Damage inflicted on the trainer.", ChatType.Trainer);
                    break;
                case DefenceType.AC:
                    attacker.ReceiveChat(damage + " Physical Damage inflicted on the trainer.", ChatType.Trainer);
                    break;
                case DefenceType.MACAgility:
                    attacker.ReceiveChat(damage + " Magic Agility Damage inflicted on the trainer.", ChatType.Trainer);
                    break;
                case DefenceType.MAC:
                    attacker.ReceiveChat(damage + " Magic Damage inflicted on the trainer.", ChatType.Trainer);
                    break;
                case DefenceType.Agility:
                    attacker.ReceiveChat(damage + " Agility Damage inflicted on the trainer.", ChatType.Trainer);
                    break;
            }
            return 1;
        }
Example #4
0
        // Pet attacking trainer.
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            byte _masterLevel = attacker.Master.Level; // max 256
            byte _masterMaxMC = attacker.Master.MaxMC; // max 256
            int _total = (_masterLevel * 10) + _masterMaxMC;

            switch (type)
            {
                case DefenceType.ACAgility:
                    attacker.Master.ReceiveChat(damage + " AC Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.AC:
                    attacker.Master.ReceiveChat(damage + " AC Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.MACAgility:
                    attacker.Master.ReceiveChat(damage + " MAC Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.MAC:
                    attacker.Master.ReceiveChat(damage + " MAC Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
                case DefenceType.Agility:
                    attacker.Master.ReceiveChat(damage + " Agility Damage inflicted on the trainer by your pet.", ChatType.Trainer);
                    break;
            }

            attacker.PetExp((uint)_total);
            return 1;
        }
Example #5
0
File: Wall.cs Project: Pete107/Mir2
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            CheckDirection();

            if (!Conquest.WarIsOn || attacker.MyGuild != null && Conquest.Owner == attacker.MyGuild.Guildindex) damage = 0;

            return base.Attacked(attacker, damage, type, damageWeapon);
        }
Example #6
0
File: Wall.cs Project: Pete107/Mir2
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            CheckDirection();

            if (!Conquest.WarIsOn) damage = 0;

            return base.Attacked(attacker, damage, type);
        }
Example #7
0
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
 {
     if (ChildRock) ParentRock.FirstAttack = false;
     if (!ChildRock && FirstAttack == true)
     {
         Die();
         return 0;
     }
     return base.Attacked(attacker, damage, type, damageWeapon);
 }
Example #8
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 = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetAttackPower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetAttackPower(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;
        }
Example #9
0
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            MirDirection newDirection = (MirDirection)(3 - GetDamageLevel());

            if (newDirection != Direction)
            {
                Direction = newDirection;
                Broadcast(new S.ObjectTurn { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
            }

            return base.Attacked(attacker, damage, type, damageWeapon);
        }
Example #10
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;

            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;
        }
Example #11
0
    //TODO: Place for model data.
    void Start()
    {
        Material Red = (Material)Resources.Load("Temp/Materials/Redfish_MT");
        Material Blue = (Material)Resources.Load("Temp/Materials/Purpfish_MT");
        Material Green = (Material)Resources.Load("Temp/Materials/Goldfish_MT");
        //TODO: Load Model Data
        //TODO: Calculate complexity

        species = GenUtil.species(Random.Range(1,40),complexity:75, targets: Targets.Smaller);
        //Debug.Log (species);

        //Unpack species string
        string[] temp = species.Split(new char[] {' '});
        speciesName = temp[0];
        Diet = (DietType)System.Enum.Parse(typeof(DietType),temp[1]);
        dimensions.x = float.Parse(temp[2]);
        dimensions.y = float.Parse(temp[3]);
        dimensions.z = float.Parse(temp[4]);
        AttType = (AttackType)System.Enum.Parse(typeof(AttackType),temp[5]);
        DefType = (DefenceType)System.Enum.Parse(typeof(DefenceType),temp[6]);
        MovType = (MovementType)System.Enum.Parse(typeof(MovementType),temp[7]);
        targets = (Targets)System.Enum.Parse(typeof(Targets),temp[8]);
        speed = float.Parse(temp[9]);
        if(temp.Length > 10){
            for(int i = 10;i<temp.Length;i++){
                gameObject.AddComponent(temp[i]);
            }
        }
        size = (dimensions.x+dimensions.y+dimensions.z)/3;

        //Switch Color based on Diet
        switch(Diet){
        case DietType.Omnivore:
            renderer.material = Blue;
            break;
        case DietType.Herbivore:
            renderer.material = Green;
            break;
        case DietType.Carnivore:
            renderer.material = Red;
            break;
        }
    }
Example #12
0
        // Player attacking trainer.
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = false)
        {
            if (attacker == null) return 0;

            if (_currentAttacker != null && _currentAttacker != attacker)
            {
                OutputAverage();
                ResetStats();
            }

            damage += attacker.AttackBonus;
            int armour = 0;
            //deal with trainers defense
            switch (type)
            {
                case DefenceType.AC:
                case DefenceType.ACAgility:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.MAC:
                case DefenceType.MACAgility:
                    armour = GetAttackPower(MinMAC, MaxMAC);
                    break;
            }
            if (armour >= damage)
            {
                BroadcastDamageIndicator(DamageType.Miss);
                return 0;
            }
            damage -= armour;

            if (_currentAttacker == null)
                _StartTime = Envir.Time;
            _currentAttacker = attacker;
            _hitCount++;
            _totalDamage += damage;
            _lastAttackTime = Envir.Time;
            
            ReportDamage(damage, type, false);
            return 1;
        }
Example #13
0
 // Player attacking trainer.
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = false)
 {
     switch (type)
     {
         case DefenceType.ACAgility:
             attacker.ReceiveChat(damage + " AC Agility Damage inflicted on the trainer.", ChatType.Trainer);
             break;
         case DefenceType.AC:
             attacker.ReceiveChat(damage + " AC Damage inflicted on the trainer.", ChatType.Trainer);
             break;
         case DefenceType.MACAgility:
             attacker.ReceiveChat(damage + " MAC Agility Damage inflicted on the trainer.", ChatType.Trainer);
             break;
         case DefenceType.MAC:
             attacker.ReceiveChat(damage + " MAC Damage inflicted on the trainer.", ChatType.Trainer);
             break;
         case DefenceType.Agility:
             attacker.ReceiveChat(damage + " Agility Damage inflicted on the trainer.", ChatType.Trainer);
             break;
     }
     return 1;
 }
Example #14
0
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            if (DragonLink)
            {
                if (Envir.DragonSystem.LinkedMonster != null)
                {
                    MonsterObject ob = Envir.DragonSystem.LinkedMonster;
                    if (ob.EXPOwner == null || ob.EXPOwner.Dead)
                        ob.EXPOwner = attacker;

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

                if (damageWeapon)
                    attacker.DamageWeapon();

                Envir.DragonSystem.GainExp(Envir.Random.Next(1, 50));
                return 1;
            }

            return 0;
        }
Example #15
0
 public abstract int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true);
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (type != DefenceType.Repulsion) return 0;

            return base.Attacked(attacker, damage, type);
        }
Example #17
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     return(0);
 }
Example #18
0
 public abstract int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility);
Example #19
0
 public PersonDefenceItem(DefenceType type, PersonRuleLevel level)
 {
     Type  = type;
     Level = level;
 }
Example #20
0
        public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;
            if (Hidden)
            {
                for (int i = 0; i < Buffs.Count; i++)
                {
                    switch (Buffs[i].Type)
                    {
                        //case BuffType.Hiding:
                        case BuffType.MoonLight:
                        case BuffType.DarkBody:
                            Buffs[i].ExpireTime = 0;
                            break;
                    }
                }
            }

            switch (type)
            {
                case DefenceType.ACAgility:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    armour = GetAttackPower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.Agility:
                    break;
            }

            armour = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(armour * ArmourRate))));
            damage = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(damage * DamageRate))));

            if (MagicShield)
                damage -= damage * (MagicShieldLv + 2) / 10;

            if (ElementalBarrier)
                damage -= damage * (ElementalBarrierLv + 1) / 10;

            if (armour >= damage) return 0;

            if (MagicShield)
            {
                MagicShieldTime -= (damage - armour) * 60;
                AddBuff(new Buff { Type = BuffType.MagicShield, Caster = this, ExpireTime = MagicShieldTime });
            }

            ElementalBarrierTime -= (damage - armour) * 60;
            RegenTime = Envir.Time + RegenDelay;
            LogTime = Envir.Time + Globals.LogDelay;

            DamageDura();
            ActiveBlizzard = false;
            ActiveReincarnation = false;
            Enqueue(new S.Struck { AttackerID = 0 });
            Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = 0, Direction = Direction, Location = CurrentLocation });

            ChangeHP(armour - damage);
            return damage - armour;
        }
Example #21
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     return(Sleeping ? 0 : base.Attacked(attacker, damage, type));
 }
 public string GetLocalizedName(DefenceType type)
 {
     return(Get(nameof(DefenceType), type.ToString()));
 }
Example #23
0
        protected override void LineAttack(int damage, int distance, int additionalDelay = 500, DefenceType defenceType = DefenceType.ACAgility, bool push = false)
        {
            for (int i = 1; i <= distance; i++)
            {
                Point target = Functions.PointMove(CurrentLocation, Direction, i);

                if (!CurrentMap.ValidPoint(target))
                {
                    continue;
                }

                Cell cell = CurrentMap.GetCell(target);
                if (cell.Objects == null)
                {
                    continue;
                }

                for (int o = 0; o < cell.Objects.Count; o++)
                {
                    MapObject ob = cell.Objects[o];
                    if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
                    {
                        if (!ob.IsAttackTarget(this))
                        {
                            continue;
                        }

                        if (Envir.Random.Next(Settings.MagicResistWeight) >= ob.Stats[Stat.MagicResist])
                        {
                            int           delay  = Functions.MaxDistance(CurrentLocation, ob.CurrentLocation) * 50 + additionalDelay; //50 MS per Step
                            DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, defenceType, true);
                            ActionList.Add(action);
                        }
                    }
                    else
                    {
                        continue;
                    }

                    break;
                }
            }
        }
Example #24
0
 public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
 {
     //Doesn't flinch? O.o idk
     return(0);
 }
Example #25
0
        public void ExtractAttackDetails()
        {
            if (this.fAttack != null)
            {
                return;
            }
            if (!this.fDetails.Contains("vs"))
            {
                return;
            }
            string str = this.fDetails;

            string[] strArrays  = new string[] { ";" };
            string[] strArrays1 = str.Split(strArrays, StringSplitOptions.RemoveEmptyEntries);
            this.fDetails = "";
            string[] strArrays2 = strArrays1;
            for (int i = 0; i < (int)strArrays2.Length; i++)
            {
                string str1 = strArrays2[i].Trim();
                bool   flag = false;
                int    num  = str1.IndexOf("vs");
                if (num != -1 && this.fAttack == null)
                {
                    string str2 = str1.Substring(0, num);
                    string str3 = str1.Substring(num);
                    int    num1 = str2.LastIndexOfAny("1234567890".ToCharArray());
                    if (num1 != -1)
                    {
                        int         num2        = 0;
                        DefenceType defenceType = DefenceType.AC;
                        bool        flag1       = false;
                        bool        flag2       = false;
                        if (str3.Contains("AC"))
                        {
                            defenceType = DefenceType.AC;
                            flag2       = true;
                        }
                        if (str3.Contains("Fort"))
                        {
                            defenceType = DefenceType.Fortitude;
                            flag2       = true;
                        }
                        if (str3.Contains("Ref"))
                        {
                            defenceType = DefenceType.Reflex;
                            flag2       = true;
                        }
                        if (str3.Contains("Will"))
                        {
                            defenceType = DefenceType.Will;
                            flag2       = true;
                        }
                        if (flag2)
                        {
                            try
                            {
                                num1  = Math.Max(0, num1 - 2);
                                num2  = int.Parse(str2.Substring(num1));
                                flag1 = true;
                            }
                            catch
                            {
                                flag1 = false;
                            }
                        }
                        if (flag1 && flag2)
                        {
                            this.fAttack = new PowerAttack()
                            {
                                Bonus   = num2,
                                Defence = defenceType
                            };
                            flag = true;
                        }
                    }
                }
                if (!flag)
                {
                    if (this.fDetails != "")
                    {
                        CreaturePower creaturePower = this;
                        creaturePower.fDetails = string.Concat(creaturePower.fDetails, "; ");
                    }
                    CreaturePower creaturePower1 = this;
                    creaturePower1.fDetails = string.Concat(creaturePower1.fDetails, str1);
                }
            }
        }
 public float GetDamageScale(AttackForm attackForm, DefenceType defenceType)
 {
     return(GetDamageScale((int)attackForm, (int)defenceType));
 }
Example #27
0
        // Pet attacking trainer.
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (attacker == null || attacker.Master == null)
            {
                return(0);
            }

            if (_currentAttacker != null && _currentAttacker != attacker.Master)
            {
                OutputAverage();
                ResetStats();
            }



            int armour = 0;

            //deal with trainers defense
            switch (type)
            {
            case DefenceType.AC:
            case DefenceType.ACAgility:
                armour = GetDefencePower(MinAC, MaxAC);
                break;

            case DefenceType.MAC:
            case DefenceType.MACAgility:
                armour = GetDefencePower(MinMAC, MaxMAC);
                break;
            }
            if (armour >= damage)
            {
                BroadcastDamageIndicator(DamageType.Miss);
                return(0);
            }
            damage -= armour;

            if (_currentAttacker == null)
            {
                _StartTime = Envir.Time;
            }


            MapObject tmpAttacker = attacker.Master;

            while (true)
            {
                if (tmpAttacker.Master != null)
                {
                    tmpAttacker = tmpAttacker.Master;
                    continue;
                }
                break;
            }

            _currentAttacker = (PlayerObject)tmpAttacker;

            _hitCount++;
            _totalDamage   += damage;
            _lastAttackTime = Envir.Time;

            ReportDamage(damage, type, true);
            return(1);
        }
Example #28
0
        private void SuggestBtn_Click(object sender, EventArgs e)
        {
            DefenceType selectedItem = (DefenceType)this.DefenceBox.SelectedItem;

            this.BonusBox.Value = Statistics.AttackBonus(selectedItem, this.fLevel, this.fRole);
        }
Example #29
0
 public abstract int Struck(int damage, DefenceType type = DefenceType.ACAgility);
Example #30
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     throw new NotSupportedException();
 }
 public void SetLocalizedName(DefenceType type, string value)
 {
     Set(nameof(DefenceType), type.ToString(), value);
 }
Example #32
0
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
 {
     return(Sleeping ? 0 : base.Attacked(attacker, damage, type, damageWeapon));
 }
Example #33
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     //  returns 0 when it's asleep (I.E takes no damage)
     return(Sleeping ? 0 : base.Attacked(attacker, damage, type));
 }
Example #34
0
 public MonsterDefenceItemSubScheme(DefenceType type, PersonRuleLevel level)
 {
     Type  = type;
     Level = level;
 }
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     return 0;
 }
 public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
 {
     return(0);
 }
Example #37
0
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
 {
     return Parent.Attacked(attacker, damage, type, damageWeapon);
 }
Example #38
0
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
 {
     return(0);
 }
Example #39
0
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
 {
     throw new NotSupportedException();
 }
Example #40
0
 public abstract int Attacked(PlayerObject attacker, int damage, DefenceType type  = DefenceType.ACAgility, bool damageWeapon = true);
Example #41
0
 public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
 {
     throw new NotSupportedException();
 }
Example #42
0
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = false)
 {
     LastPlayerHitter = attacker.Name;
     return base.Attacked(attacker, damage, type);
 }
Example #43
0
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            if (Target == null && attacker.IsAttackTarget(this))
            {
                Target = attacker;
            }

            int armour = 0;

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

            armour = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(armour * ArmourRate))));
            damage = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(damage * DamageRate))));

            if (damageWeapon)
                attacker.DamageWeapon();
            damage += attacker.AttackBonus;

            if ((attacker.CriticalRate * Settings.CriticalRateWeight) > Envir.Random.Next(100))
            {
                Broadcast(new S.ObjectEffect { ObjectID = ObjectID, Effect = SpellEffect.Critical});
                damage = Math.Min(int.MaxValue, damage + (int)Math.Floor(damage * (((double)attacker.CriticalDamage / (double)Settings.CriticalDamageWeight) * 10)));
            }

            if (armour >= damage)
            {
                BroadcastDamageIndicator(DamageType.Miss);
                return 0;
            }

            if (attacker.LifeOnHit > 0)
                attacker.ChangeHP(attacker.LifeOnHit);

            if (Target != this && attacker.IsAttackTarget(this))
            {
                if (attacker.Info.MentalState == 2)
                {
                    if (Functions.MaxDistance(CurrentLocation, attacker.CurrentLocation) < (8 - attacker.Info.MentalStateLvl))
                        Target = attacker;
                }
                else
                    Target = attacker;
            }

            if (BindingShotCenter) ReleaseBindingShot();
            ShockTime = 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;

            ushort LevelOffset = (ushort)(Level > attacker.Level ? 0 : Math.Min(10, attacker.Level - Level));

            if (attacker.HasParalysisRing && type != DefenceType.MAC && type != DefenceType.MACAgility && 1 == Envir.Random.Next(1, 15))
            {
                ApplyPoison(new Poison { PType = PoisonType.Paralysis, Duration = 5, TickSpeed = 1000 }, attacker);
            }

            if (attacker.Freezing > 0 && type != DefenceType.MAC && type != DefenceType.MACAgility)
            {
                if ((Envir.Random.Next(Settings.FreezingAttackWeight) < attacker.Freezing) && (Envir.Random.Next(LevelOffset) == 0))
                    ApplyPoison(new Poison { PType = PoisonType.Slow, Duration = Math.Min(10, (3 + Envir.Random.Next(attacker.Freezing))), TickSpeed = 1000 }, attacker);
            }

            if (attacker.PoisonAttack > 0 && type != DefenceType.MAC && type != DefenceType.MACAgility)
            {
                if ((Envir.Random.Next(Settings.PoisonAttackWeight) < attacker.PoisonAttack) && (Envir.Random.Next(LevelOffset) == 0))
                    ApplyPoison(new Poison { PType = PoisonType.Green, Duration = 5, TickSpeed = 1000, Value = Math.Min(10, 3 + Envir.Random.Next(attacker.PoisonAttack)) }, attacker);
            }

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

            if (attacker.HpDrainRate > 0)
            {
                attacker.HpDrain += Math.Max(0, ((float)(damage - armour) / 100) * attacker.HpDrainRate);
                if (attacker.HpDrain > 2)
                {
                    int HpGain = (int)Math.Floor(attacker.HpDrain);
                    attacker.ChangeHP(HpGain);
                    attacker.HpDrain -= HpGain;

                }
            }

            attacker.GatherElement();

            if (attacker.Info.Mentor != 0 && attacker.Info.isMentor)
            {
                Buff buff = attacker.Buffs.Where(e => e.Type == BuffType.Mentor).FirstOrDefault();
                if (buff != null)
                {
                    CharacterInfo Mentee = Envir.GetCharacterInfo(attacker.Info.Mentor);
                    PlayerObject player = Envir.GetPlayer(Mentee.Name);
                    if (player.CurrentMap == attacker.CurrentMap && Functions.InRange(player.CurrentLocation, attacker.CurrentLocation, Globals.DataRange) && !player.Dead)
                    {
                        damage += ((damage / 100) * Settings.MentorDamageBoost);
                    }
                }
            }

            BroadcastDamageIndicator(DamageType.Hit, armour - damage);

            ChangeHP(armour - damage);
            return armour - damage;
        }
Example #44
0
 public abstract int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility);
Example #45
0
        /// <summary>
        /// Parses the power details field to find the attack data (+N vs Defence).
        /// </summary>
        public void ExtractAttackDetails()
        {
            if (fAttack != null)
            {
                return;
            }

            if (!fDetails.Contains("vs"))
            {
                return;
            }

            string[] sections = fDetails.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            fDetails = "";

            foreach (string section in sections)
            {
                string str = section.Trim();

                bool added_attack = false;

                int index = str.IndexOf("vs");
                if ((index != -1) && (fAttack == null))
                {
                    string prefix = str.Substring(0, index);
                    string suffix = str.Substring(index);

                    string digits = "1234567890";
                    int    start  = prefix.LastIndexOfAny(digits.ToCharArray());
                    if (start != -1)
                    {
                        int         bonus         = 0;
                        DefenceType defence       = DefenceType.AC;
                        bool        found_bonus   = false;
                        bool        found_defence = false;

                        if (suffix.Contains("AC"))
                        {
                            defence       = DefenceType.AC;
                            found_defence = true;
                        }
                        if (suffix.Contains("Fort"))
                        {
                            defence       = DefenceType.Fortitude;
                            found_defence = true;
                        }
                        if (suffix.Contains("Ref"))
                        {
                            defence       = DefenceType.Reflex;
                            found_defence = true;
                        }
                        if (suffix.Contains("Will"))
                        {
                            defence       = DefenceType.Will;
                            found_defence = true;
                        }

                        if (found_defence)
                        {
                            try
                            {
                                start = Math.Max(0, start - 2);
                                string bonus_str = prefix.Substring(start);
                                bonus       = int.Parse(bonus_str);
                                found_bonus = true;
                            }
                            catch
                            {
                                found_bonus = false;
                            }
                        }

                        if (found_bonus && found_defence)
                        {
                            fAttack         = new PowerAttack();
                            fAttack.Bonus   = bonus;
                            fAttack.Defence = defence;

                            added_attack = true;
                        }
                    }
                }

                if (!added_attack)
                {
                    if (fDetails != "")
                    {
                        fDetails += "; ";
                    }

                    fDetails += str;
                }
            }
        }
        public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
        {
            if (type != DefenceType.Repulsion) return 0;

            return base.Attacked(attacker, damage, type, damageWeapon);
        }
Example #47
0
 public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
 {
     return(base.Attacked(attacker, damage, type, damageWeapon));
 }
Example #48
0
 public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
 {
     throw new NotSupportedException();
 }
Example #49
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);
        }
 public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
 {
     return 0;
 }
Example #51
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);
        }
Example #52
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 = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    if (Envir.Random.Next(Agility + 1) > attacker.Accuracy) return 0;
                    armour = GetAttackPower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetAttackPower(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;

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

            ChangeHP(-1);

            return 1;
        }
Example #53
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(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;

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

            if (Envir.Random.Next(3) == 0)
            {
                CloseAttack(damage);
            }

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

            return(1);
        }
Example #54
0
 public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
 {
     throw new NotSupportedException();
 }
Example #55
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;

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

            if (Envir.Random.Next(3) == 0)
            {
                CloseAttack(damage);
            }

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

            ChangeHP(-1);
            return(1);
        }
Example #56
0
        public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
        {
            int armour = 0;

            switch (type)
            {
                case DefenceType.ACAgility:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.AC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.MACAgility:
                    armour = GetAttackPower(MinMAC, MaxMAC);
                    break;
                case DefenceType.MAC:
                    armour = GetAttackPower(MinAC, MaxAC);
                    break;
                case DefenceType.Agility:
                    break;
            }

            armour = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(armour * ArmourRate))));
            damage = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(damage * DamageRate))));

            if (armour >= damage) return 0;
            Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = 0, Direction = Direction, Location = CurrentLocation });

            ChangeHP(armour - damage);
            return damage - armour;
        }
Example #57
0
 public override int Attacked(PlayerObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
 {
     throw new NotSupportedException();
 }
Example #58
0
        public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
        {
            if (Target == null && attacker.IsAttackTarget(this))
                Target = attacker;

            int armour = 0;

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

            armour = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(armour * ArmourRate))));
            damage = (int)Math.Max(int.MinValue, (Math.Min(int.MaxValue, (decimal)(damage * DamageRate))));

            if (armour >= damage)
            {
                BroadcastDamageIndicator(DamageType.Miss);
                return 0;
            }

            if (Target != this && attacker.IsAttackTarget(this))
                Target = attacker;

            if (BindingShotCenter) ReleaseBindingShot();
            ShockTime = 0;

            if (attacker.Info.AI == 6 || attacker.Info.AI == 58)
                EXPOwner = null;

            else if (attacker.Master != null)
            {
                if (!Functions.InRange(attacker.CurrentLocation, attacker.Master.CurrentLocation, Globals.DataRange))
                    EXPOwner = null;
                else
                {

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

            BroadcastDamageIndicator(DamageType.Hit, armour - damage);

            ChangeHP(armour - damage);
            return damage - armour;
        }
Example #59
0
        private void SuggestBtn_Click(object sender, EventArgs e)
        {
            DefenceType dt = (DefenceType)DefenceBox.SelectedItem;

            BonusBox.Value = Statistics.AttackBonus(dt, fLevel, fRole);
        }