示例#1
0
 public void IncreaseThreat(Creature threat, uint amount)
 {
     ThreatTable[threat] += amount;
 }
示例#2
0
 public void DecreaseThreat(Creature threat, uint amount)
 {
     ThreatTable[threat] -= amount;
 }
示例#3
0
        //public virtual bool AddItem(Item item, bool updateWeight = true) { return false; }
        //public virtual bool AddItem(Item item, int slot, bool updateWeight = true) { return false; }
        //public virtual bool RemoveItem(int slot, bool updateWeight = true) { return false; }
        //public virtual bool RemoveItem(int slot, int count, bool updateWeight = true) { return false; }
        //public virtual bool AddEquipment(Item item) { return false; }
        //public virtual bool AddEquipment(Item item, byte slot, bool sendUpdate = true) { return false; }
        //public virtual bool RemoveEquipment(byte slot) { return false; }
        public virtual void Damage(double damage, Element element = Element.None, DamageType damageType = DamageType.Direct, Creature attacker = null)
        {
            if (damageType == DamageType.Physical && (AbsoluteImmortal || PhysicalImmortal))
                return;

            if (damageType == DamageType.Magical && (AbsoluteImmortal || MagicalImmortal))
                return;

            if (damageType != DamageType.Direct)
            {
                double armor = Ac * -1 + 100;
                double resist = Game.ElementTable[(int)element, 0];
                double reduction = damage * (armor / (armor + 50));
                damage = (damage - reduction) * resist;
            }

            if (attacker != null)
                _mLastHitter = attacker.Id;

            var normalized = (uint)damage;

            if (normalized > Hp)
                normalized = Hp;

            Hp -= normalized;
        }
示例#4
0
 public uint this[Creature threat]
 {
     get { return(ThreatTable[threat]); }
     set { ThreatTable[threat] = value; }
 }
示例#5
0
 public bool ContainsThreat(Creature threat)
 {
     return(ThreatTable.ContainsKey(threat));
 }
示例#6
0
 public virtual void Attack(Castable castObject, Creature target)
 {
     //do spell?
 }
示例#7
0
 public virtual void Attack(Direction direction, XSD.Castable castObject, Creature target = null)
 {
     //do something?
 }
示例#8
0
        public void Cast(Creature aggroTarget, UserGroup targetGroup)
        {
            if (CanCast)
            {
                //need to determine what it should do, and what is available to it.
                var     interval         = 0;
                decimal currentHpPercent = ((decimal)Stats.Hp / Stats.MaximumHp) * 100m;

                if (currentHpPercent < 1)
                {
                    //ondeath does not need an interval check
                    var selectedCastable = SelectSpawnCastable(SpawnCastType.OnDeath);
                    if (selectedCastable == null)
                    {
                        return;
                    }

                    if (selectedCastable.Target == Xml.TargetType.Attacker)
                    {
                        Cast(aggroTarget, selectedCastable);
                    }

                    if (selectedCastable.Target == Xml.TargetType.Group || selectedCastable.Target == Xml.TargetType.Random)
                    {
                        if (targetGroup != null)
                        {
                            Cast(targetGroup, selectedCastable, selectedCastable.Target);
                        }
                        else
                        {
                            Cast(aggroTarget, selectedCastable);
                        }
                    }
                }

                if (currentHpPercent <= Castables.NearDeath.HealthPercent)
                {
                    interval = _castables.NearDeath.Interval;

                    var selectedCastable = SelectSpawnCastable(SpawnCastType.NearDeath);

                    if (selectedCastable == null)
                    {
                        return;
                    }

                    if (selectedCastable.Target == Xml.TargetType.Attacker)
                    {
                        if (_castables.NearDeath.LastCast.AddSeconds(interval) < DateTime.Now)
                        {
                            Cast(aggroTarget, selectedCastable);
                            _castables.NearDeath.LastCast = DateTime.Now;
                        }
                    }

                    if (selectedCastable.Target == Xml.TargetType.Group || selectedCastable.Target == Xml.TargetType.Random)
                    {
                        if (targetGroup != null)
                        {
                            if (_castables.NearDeath.LastCast.AddSeconds(interval) < DateTime.Now)
                            {
                                Cast(targetGroup, selectedCastable, selectedCastable.Target);
                                _castables.NearDeath.LastCast = DateTime.Now;
                            }
                        }
                        else
                        {
                            if (_castables.NearDeath.LastCast.AddSeconds(interval) < DateTime.Now)
                            {
                                Cast(aggroTarget, selectedCastable);
                                _castables.NearDeath.LastCast = DateTime.Now;
                            }
                        }
                    }
                }

                var nextChoice = _random.Next(0, 2);

                if (nextChoice == 0) //offense
                {
                    interval = _castables.Offense.Interval;
                    var selectedCastable = SelectSpawnCastable(SpawnCastType.Offensive);
                    if (selectedCastable == null)
                    {
                        return;
                    }

                    if (selectedCastable.Target == Xml.TargetType.Attacker)
                    {
                        if (_castables.Offense.LastCast.AddSeconds(interval) < DateTime.Now)
                        {
                            Cast(aggroTarget, selectedCastable);
                            _castables.Offense.LastCast = DateTime.Now;
                        }
                    }

                    if (selectedCastable.Target == Xml.TargetType.Group || selectedCastable.Target == Xml.TargetType.Random)
                    {
                        if (targetGroup != null)
                        {
                            if (_castables.Offense.LastCast.AddSeconds(interval) < DateTime.Now)
                            {
                                Cast(targetGroup, selectedCastable, selectedCastable.Target);
                                _castables.Offense.LastCast = DateTime.Now;
                            }
                        }
                        else
                        {
                            if (_castables.Offense.LastCast.AddSeconds(interval) < DateTime.Now)
                            {
                                Cast(aggroTarget, selectedCastable);
                                _castables.Offense.LastCast = DateTime.Now;
                            }
                        }
                    }
                }

                if (nextChoice == 1) //defense
                {
                    //not sure how to handle this one
                }
            }
        }
示例#9
0
文件: User.cs 项目: DomGrieco/server
 public override void Attack(Castable castObject, Creature target = null)
 {
     base.Attack(castObject, target);
 }
示例#10
0
文件: User.cs 项目: DomGrieco/server
        public void AssailAttack(Direction direction, Creature target = null)
        {
            if (target == null)
            {
                //try to get the creature we're facing and set it as the target.
            }

            foreach (Castable c in SkillBook)
            {
                if(c.Isassail == "true") //i do not like that this is a string. I'll probablt update it at some point to return a simple type of boolean.
                {
                    Attack(direction, c, target);
                }
            }
            //animation handled here as to not repeatedly send assails.
            SendAnimation(0x01, 25, 0x01);

        }
示例#11
0
文件: User.cs 项目: DomGrieco/server
        public override void Attack(Direction direction, Castable castObject = null, Creature target = null)
        {
            if (target != null)
            {
                var damage = castObject.Effects.Damage;

                if (damage.Formula == null) //will need to be expanded. also will need to account for damage scripts
                {
                    var simple = damage.Simple;
                    var damageType = EnumUtil.ParseEnum<Enums.DamageType>(damage.Type.ToString(), Enums.DamageType.Magical);
                    Random rand = new Random();
                    var dmg = rand.Next(Convert.ToInt32(simple.Min), Convert.ToInt32(simple.Max)); //these need to be set to integers as attributes. note to fix.
                    target.Damage(dmg, OffensiveElement, damageType, this);
                }
                else
                {
                    var formula = damage.Formula;
                    var damageType = EnumUtil.ParseEnum<Enums.DamageType>(damage.Type.ToString(), Enums.DamageType.Magical);
                    FormulaParser parser = new FormulaParser(this, castObject, target);
                    var dmg = parser.Eval(formula);
                    target.Damage(dmg, OffensiveElement, damageType, this);
                }
            }
        }
示例#12
0
 public FormulaParser(Creature caster, Castable castable, Creature target = null)
 {
     _caster = caster;
     _castable = castable;
     _target = target;
 }
示例#13
0
        public virtual void Damage(double damage, Enums.Element element = Enums.Element.None, Enums.DamageType damageType = Enums.DamageType.Direct, Creature attacker = null)
        {
            if (damageType == Enums.DamageType.Physical && (AbsoluteImmortal || PhysicalImmortal))
            {
                return;
            }

            if (damageType == Enums.DamageType.Magical && (AbsoluteImmortal || MagicalImmortal))
            {
                return;
            }

            if (damageType != Enums.DamageType.Direct)
            {
                double armor     = Ac * -1 + 100;
                var    resist    = Game.ElementTable[(int)element, 0];
                var    reduction = damage * (armor / (armor + 50));
                damage = (damage - reduction) * resist;
            }

            if (attacker != null)
            {
                _mLastHitter = attacker.Id;
            }

            var normalized = (uint)damage;

            if (normalized > Hp)
            {
                normalized = Hp;
            }

            Hp -= normalized;

            SendDamageUpdate(this);

            if (Hp == 0)
            {
                OnDeath();
            }
        }
示例#14
0
 public void WipeThreat(Creature threat)
 {
     ThreatTable[threat] = 0;
 }
示例#15
0
 public virtual void Attack(XSD.Castable castObject, Creature target = null)
 {
     //do spell?
 }
示例#16
0
 public void AddNewThreat(Creature newThreat, uint amount = 0)
 {
     ThreatTable.Add(newThreat, amount);
 }
示例#17
0
 public override void Attack(Direction direction, XSD.Castable castObject = null, Creature target = null)
 {
     //do monster attack.
 }
示例#18
0
 public void RemoveThreat(Creature threat)
 {
     ThreatTable.Remove(threat);
 }
示例#19
0
 public override void Attack(Castable castObject, Creature target = null)
 {
     //do monster spell
 }
示例#20
0
 /// <summary>
 /// A simple directional attack by a monster (equivalent of straight assail).
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="target"></param>
 public void SimpleAttack(Creature target) => target?.Damage(_simpleDamage, Stats.BaseOffensiveElement, Xml.DamageType.Physical, Xml.DamageFlags.None, this);
示例#21
0
 public virtual void Attack(Direction direction, Castable castObject, Creature target = null)
 {
     //do something?
 }