Esempio n. 1
0
        public void HeroDamageRandomization(AttackKind attackKind)
        {
            var game = CreateGame();

            game.Hero.Stats.GetStat(EntityStatKind.Health).Value.Nominal = 500;
            game.Hero.Stats.GetStat(EntityStatKind.Mana).Value.Nominal   = 500;

            var          enemy         = game.GameManager.EnemiesManager.GetEnemies().Where(i => i.PowerKind == EnemyPowerKind.Champion).First();
            List <float> healthChanges = null;

            PlaceCloseToHero(enemy);
            if (attackKind == AttackKind.Unset)
            {
                healthChanges = DoDamage(game.Hero, enemy, (LivingEntity attacker, LivingEntity en) => { en.OnMeleeHitBy(attacker); });
            }
            else if (attackKind == AttackKind.Melee)
            {
                healthChanges = DoDamage(game.Hero, enemy, (LivingEntity attacker, LivingEntity en) => CallDoDamageMelee(attacker, en));
            }
            else if (attackKind == AttackKind.PhysicalProjectile)
            {
                healthChanges = DoDamage(game.Hero, enemy, (LivingEntity attacker, LivingEntity en) => CallDoDamagePhysicalProjectile(attacker, en));
            }
            else if (attackKind == AttackKind.WeaponElementalProjectile)
            {
                healthChanges = DoDamage(game.Hero, enemy, (LivingEntity attacker, LivingEntity en) => CallDoDamageWeaponElementalProjectile(attacker, en));
            }
            else if (attackKind == AttackKind.SpellElementalProjectile)
            {
                healthChanges = DoDamage(game.Hero, enemy, (LivingEntity attacker, LivingEntity en) => CallDoDamageSpellElementalProjectile(attacker, en));
            }
        }
Esempio n. 2
0
        public void DamageFromEnemiesVaries(AttackKind attackKind)
        {
            var game = CreateGame();
            var hero = game.Hero;

            Assert.Greater(ActivePlainEnemies.Count, 0);
            var enemy = ActivePlainEnemies.First();
            var emp   = game.Level.GetEmptyTiles().Where(i => i.DistanceFrom(hero) < 6 && i.DistanceFrom(hero) > 1).First();

            game.Level.SetTile(enemy, emp.point);
            //PlaceCloseToHero(enemy);
            if (attackKind == AttackKind.Unset)
            {
                DoDamage(enemy, game.Hero, (LivingEntity attacker, LivingEntity victim) => { victim.OnMeleeHitBy(attacker); });
            }

            else if (attackKind == AttackKind.PhysicalProjectile)
            {
                var en = enemy as Enemy;
                var fi = en.AddFightItem(FightItemKind.ThrowingKnife);
                fi.Count           = 10;
                en.ActiveFightItem = fi as ProjectileFightItem;
                DoDamage(enemy, game.Hero, (LivingEntity attacker, LivingEntity victim) => CallDoDamagePhysicalProjectile(attacker, victim));
            }
            //else if (attackKind == AttackKind.WeaponElementalProjectile)
            //{
            //  healthChanges = DoDamage(game.Hero, enemy, (LivingEntity attacker, LivingEntity en) => CallDoDamageWeaponElementalProjectile(attacker, en));
            //}
            else if (attackKind == AttackKind.SpellElementalProjectile)
            {
                enemy.ActiveManaPoweredSpellSource = new Scroll(SpellKind.FireBall);
                enemy.Stats.SetNominal(EntityStatKind.Mana, 1000);
                DoDamage(enemy, game.Hero, (LivingEntity attacker, LivingEntity victim) => CallDoDamageSpellElementalProjectile(attacker, victim));
            }
        }
Esempio n. 3
0
 public AttackDescription(LivingEntity ent,
                          bool withVariation    = true,
                          AttackKind attackKind = AttackKind.Unset,//if uset it will be based on current weapon/active fi
                          OffensiveSpell spell  = null)
 {
     fightItem = null;
     Calc(ent, withVariation, ref attackKind, spell);
 }
Esempio n. 4
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 2);

            DamageType damageType = (DamageType)Expressions.Get(args[0], player, target, spell);
            AttackKind attackKind = (AttackKind)Expressions.Get(args[1], player, target, spell);

            player.AddDamageResistance(damageType, attackKind);
            return(null);
        }
 public Projectile(NWCreature creature, NWField field, AttackKind attackKind, int range, Item weapon, Item projectile)
 {
     Kind           = attackKind;
     Range          = range;
     Steps          = 0;
     Creature       = creature;
     Map            = field;
     Weapon         = weapon;
     ProjectileItem = projectile;
 }
Esempio n. 6
0
 /// <summary>
 /// プロパティを設定する
 /// </summary>
 /// <param name="attack">攻撃力</param>
 /// <param name="damageRate">ダメージの振れ幅</param>
 /// <param name="kind">攻撃の種類</param>
 /// <param name="parentPlayer">攻撃を出した親オブジェクト</param>
 public void SetProperties(int attack, float damageRate, AttackKind kind, PlayerChar parentPlayer, int sp = 0)
 {
     // 攻撃力を設定する
     this.attack = attack;
     // 攻撃力の振れ幅を設定する
     this.damageRate = damageRate;
     // 攻撃の種類を設定する
     this.attackKind = kind;
     // 攻撃の親オブジェクトを設定する
     this.parentPlayer = parentPlayer;
     // 加算されるSPの値を入れる
     this.sp = sp;
 }
Esempio n. 7
0
        /// <summary>
        /// Attack the enemy using chosen weapon. </summary>
        /// <param name="attackKind"> Kind of attack, internal. </param>
        /// <param name="enemy"> </param>
        /// <param name="weapon"> </param>
        /// <param name="projectile"> </param>
        /// <returns> Result of attack: true - for successful attack, false - for miss. </returns>
        public override bool AttackTo(AttackKind attackKind, NWCreature enemy, Item weapon, Item projectile)
        {
            try {
                bool result = base.AttackTo(attackKind, enemy, weapon, projectile);

                /*if (result) {
                 * }*/

                return(result);
            } catch (Exception ex) {
                Logger.Write("Player.attackTo(): " + ex.Message);
                return(false);
            }
        }
Esempio n. 8
0
 // TODO: add filtering - includeFilter, excludeFilter
 // for body sizes
 public Damage(DamageType damageType, AttackKind attackKind, string damageRoll, TimePoint damageHits = TimePoint.Immediately, TimePoint saveOpportunity = TimePoint.None, Conditions conditions = Conditions.None, int savingThrowSuccess = int.MaxValue, Ability savingThrowAbility = Ability.None)
 {
     SavingThrowAbility   = savingThrowAbility;
     SavingThrowSuccess   = savingThrowSuccess;
     SaveOpportunity      = saveOpportunity;
     AttackKind           = attackKind;
     DamageType           = damageType;
     DamageRoll           = damageRoll;
     DamageHits           = damageHits;
     Conditions           = conditions;
     IncludeTargetSenses  = Senses.None;
     IncludeCreatureSizes = CreatureSizes.All;
     IncludeCreatures     = CreatureKinds.None;
 }
    //=======================================その他===========================================
    //次の攻撃を乱数で選ぶ
    private AttackKind Select_Next_Attack(AttackKind pre_Attack)
    {
        AttackKind next_Attack = pre_Attack;

        List <AttackKind> kinds = new List <AttackKind> {
            AttackKind.close_Slash, AttackKind.long_Slash, AttackKind.barrier
        };

        kinds.Remove(pre_Attack);

        next_Attack = kinds[Random.Range(0, 2)];

        return(next_Attack);
    }
Esempio n. 10
0
        public void TakeDamage(DamageType damageType, AttackKind attackKind, int damage)
        {
            PercentDamageJustInflicted = 0;
            double beforeTotalHp = TotalHp;

            Creature.TakeDamage(damageType, attackKind, damage);
            double totalDamageTaken = beforeTotalHp - TotalHp;

            if (totalDamageTaken != 0)
            {
                PercentDamageJustInflicted = MathUtils.Clamp(totalDamageTaken / Creature.maxHitPoints, 0, 1);
            }
            UpdateHitPointsStr();
        }
Esempio n. 11
0
    static public IAttackLauncher Create(AttackKind kind, IPlayerAudioManager playerAudioManager, Player player)
    {
        switch (kind)
        {
        case AttackKind.BirdPoop:
            return(new BirdProjectileLauncher(playerAudioManager));

        case AttackKind.CatProjectile:
        default:
            return(new CatProjectileLauncher(playerAudioManager, player));
        }

        return(null);
    }
Esempio n. 12
0
        public Attack(AttackKind kind, Verb verb, int hitValue, int damageValue, int staminaPenalty, int range)
            : this()
        {
            if (verb == null)
            {
                throw new ArgumentNullException("verb");
            }

            this.Kind           = kind;
            this.Verb           = verb;
            this.HitValue       = hitValue;
            this.DamageValue    = damageValue;
            this.StaminaPenalty = staminaPenalty;
            this.Range          = range;
        }
Esempio n. 13
0
        public Attack(AttackKind kind, Verb verb, int hitValue, int damageValue, int staminaPenalty = 0, short range = 0, int rapid1 = 0, int rapid2 = 0)
        {
            Kind = kind;
            Verb = verb
#if DEBUG
                   ?? throw new ArgumentNullException(nameof(verb))
#endif
            ;
            HitValue       = hitValue;
            Hit2Value      = rapid1;
            Hit3Value      = rapid2;
            DamageValue    = damageValue;
            StaminaPenalty = staminaPenalty;
            Range          = range;
            DisarmChance   = 0; // mockup.
        }
Esempio n. 14
0
        virtual public void Hurt(float delta, AttackKind kind)
        {
            switch (kind)
            {
            case AttackKind.Physics:
                delta = Mathf.Min(0, -delta + m_defend);
                break;

            case AttackKind.Magic:
                delta = Mathf.Min(0, -delta + m_magicDefend);
                break;

            case AttackKind.Real:
                delta = Mathf.Min(0, -delta);
                break;
            }
            Health = Mathf.Max(0, delta + Health);
        }
Esempio n. 15
0
        public void TakeSomeDamage(DndGame game, DamageType damageType, AttackKind attackKind, int amount)
        {
            if (amount <= 0)
            {
                return;
            }

            double previousHP = TotalHp;

            Creature.TakeDamage(damageType, attackKind, amount);

            if (game == null)
            {
                return;
            }

            double hpLost = previousHP - TotalHp;

            if (hpLost == 0)
            {
                return;
            }

            string tempHpDetails = string.Empty;

            if (Creature.tempHitPoints > 0)
            {
                tempHpDetails = $" (tempHp: {Creature.tempHitPoints})";
            }

            string message;

            if (hpLost == 1)
            {
                message = $"{Name} just took 1 point of {damageType} damage. HP is now: {Creature.HitPoints}/{Creature.maxHitPoints}{tempHpDetails}";
            }
            else
            {
                message = $"{Name} just took {hpLost} points of {damageType} damage. HP is now: {Creature.HitPoints}/{Creature.maxHitPoints}{tempHpDetails}";
            }

            game.TellDungeonMaster(message);
        }
    private void Phase1_Melody_A(int bullet_Num)
    {
        //次の攻撃を選択する
        AttackKind next_Attack = Select_Next_Attack(pre_Attack);

        pre_Attack = next_Attack;
        //選択した攻撃を開始する
        switch (next_Attack)
        {
        case AttackKind.close_Slash:    _attack_Func.StartCoroutine("Close_Slash_Cor");         break;

        case AttackKind.long_Slash:     _attack_Func.StartCoroutine("Long_Slash_Cor", bullet_Num); break;

        case AttackKind.barrier:        _attack_Func.StartCoroutine("Barrier_Walk_Cor", 200f);  break;
        }

        //攻撃無効化(有効化は攻撃のコルーチン内で行う)
        can_Attack = false;
    }
Esempio n. 17
0
        public static AttackKind DiscoverAttackKind(AttackKind attackKind, Weapon wpn)
        {
            if (attackKind == AttackKind.Unset)
            {
                attackKind = AttackKind.Melee;
                if (wpn != null)
                {
                    if (wpn.IsBowLike)
                    {
                        attackKind = AttackKind.PhysicalProjectile;
                    }
                    else if (wpn.IsMagician)
                    {
                        attackKind = AttackKind.WeaponElementalProjectile;
                    }
                }
            }

            return(attackKind);
        }
Esempio n. 18
0
        void SetAttackSequence(int index)
        {
            Debug.Assert(0 <= index && index < AtkSequences.Length);

//            for(int i = 0;i < ShotParams.Length;i++)
            foreach (var param in ShotParams)
            {
                param.Clear();
            }

            var seq = AtkSequences[index];

            AtkKind     = seq.Kind;
            AtkInterval = seq.IntervalTime;

            int next = index + 1;

            NextHPRate = (next < AtkSequences.Length) ? AtkSequences[next].StartPercent / 100.0f : 0;

            State = (AtkInterval > 0)? StateStatus.Interval : StateStatus.Attack;
        }
 public static Attack RangedAttack(AttackKind kind, Verb verb, int normalHitValue, int rapidFire1HitValue, int rapidFire2HitValue, int damageValue, int range)
 {
     return(new Attack(kind, verb, normalHitValue, rapidFire1HitValue, rapidFire2HitValue, damageValue, 0, 0, range));
 }
Esempio n. 20
0
 public void TakeHalfDamage(Character player, Dictionary <DamageType, int> latestDamage, AttackKind attackKind)
 {
     StartTakingDamage();
     foreach (DamageType damageType in latestDamage.Keys)
     {
         int damageTaken = DndUtils.HalveValue(latestDamage[damageType]);
         TakeSomeDamage(player, damageType, attackKind, damageTaken);
     }
     FinishTakingDamage();
 }
Esempio n. 21
0
 public void TakeDamage(Character player, Dictionary <DamageType, int> latestDamage, AttackKind attackKind)
 {
     StartTakingDamage();
     foreach (DamageType damageType in latestDamage.Keys)
     {
         TakeSomeDamage(player, damageType, attackKind, latestDamage[damageType]);
     }
     FinishTakingDamage();
 }
Esempio n. 22
0
 public bool IsTotallyImmuneToDamage(System.Collections.Generic.Dictionary <DamageType, int> latestDamage, AttackKind attackKind)
 {
     foreach (DamageType damageType in latestDamage.Keys)
     {
         if (!Creature.IsImmuneTo(damageType, attackKind))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 23
0
 public bool Matches(DamageType damageType, AttackKind attackKind)
 {
     return(MatchesDamage(damageType) && MatchesAttackKind(attackKind));
 }
Esempio n. 24
0
 bool MatchesAttackKind(AttackKind attackKind)
 {
     return((attackKind & AttackKind) == attackKind);
 }
Esempio n. 25
0
 /// <summary>
 /// プロパティを設定する
 /// </summary>
 /// <param name="attack">攻撃力</param>
 /// <param name="damageRate">ダメージの振れ幅</param>
 /// <param name="kind">攻撃の種類</param>
 /// <param name="parentPlayer">攻撃を出した親オブジェクト</param>
 public void SetProperties(int attack, float damageRate, AttackKind kind, PlayerChar parentPlayer, int sp = 0)
 {
     // 攻撃力を設定する
     this.attack = attack;
     // 攻撃力の振れ幅を設定する
     this.damageRate = damageRate;
     // 攻撃の種類を設定する
     this.attackKind = kind;
     // 攻撃の親オブジェクトを設定する
     this.parentPlayer = parentPlayer;
     // 加算されるSPの値を入れる
     this.sp = sp;
 }
Esempio n. 26
0
 public Attack AddDamage(DamageType damageType, string damageRoll, AttackKind attackKind, TimePoint damageHits = TimePoint.Immediately, TimePoint saveOpportunity = TimePoint.None, Conditions conditions = Conditions.None, int savingThrowSuccess = int.MaxValue, Ability savingThrowAbility = Ability.none)
 {
     damages.Add(new Damage(damageType, attackKind, damageRoll, damageHits, saveOpportunity, conditions, savingThrowSuccess, savingThrowAbility));
     return(this);
 }
Esempio n. 27
0
 public DamageFilter(DamageType damageType, AttackKind attackKind)
 {
     AttackKind = attackKind;
     DamageType = damageType;
 }
Esempio n. 28
0
        private void CalcMembers
        (
            LivingEntity ent,
            Weapon wpn,
            Dictionary <Weapon.WeaponKind, EntityStatKind> weapons2Esk,
            EntityStatKind attackStat,
            AttackKind attackKind
        )
        {
            if (attackStat != EntityStatKind.Unset)
            {
                Current = ent.GetCurrentValue(attackStat);
            }
            else
            {
                Current = 0;
            }
            OffensiveSpell offensiveSpell = spell;

            if (wpn != null)
            {
                if (wpn.IsBowLike && attackKind == AttackKind.PhysicalProjectile)
                {
                    if (fightItem.IsBowLikeAmmo)
                    {
                        Current += fightItem.Damage;
                    }
                    else
                    {
                        Current -= wpn.Damage;//ammo not matching
                    }
                }
                else if (wpn.IsMagician && attackKind == AttackKind.WeaponElementalProjectile)
                {
                    offensiveSpell = wpn.SpellSource.CreateSpell(ent) as OffensiveSpell;
                }
            }

            if (attackKind == AttackKind.PhysicalProjectile && fightItem != null)
            {
                if (fightItem.FightItemKind == Tiles.Looting.FightItemKind.Stone ||
                    fightItem.FightItemKind == Tiles.Looting.FightItemKind.ThrowingKnife
                    )
                {
                    Current += fightItem.Damage;
                    Current += ent.Stats.Strength / 2;
                }
            }

            CurrentPhysical         = Current;
            CurrentPhysicalVariated = CurrentPhysical;
            if (withVariation)//GUI is not meant to have it changed on character panel
            {
                CurrentPhysicalVariated += CalcVariation(attackKind, true, CurrentPhysical);
            }

            if (CurrentPhysicalVariated < 0)
            {
                CurrentPhysicalVariated = 0;
            }
            if (CurrentPhysical < 0)
            {
                CurrentPhysical = 0;
            }

            var val = CurrentPhysicalVariated;

            //add melee damage
            AddExtraDamage(ent, wpn, weapons2Esk, ref val);
            CurrentPhysicalVariated += val - CurrentPhysicalVariated;

            CurrentTotal = CurrentPhysicalVariated;

            if (offensiveSpell != null &&
                (attackKind == AttackKind.SpellElementalProjectile || attackKind == AttackKind.WeaponElementalProjectile))
            {
                var dmg = offensiveSpell.GetDamage();
                if (withVariation)
                {
                    dmg += CalcVariation(attackKind, true, dmg);
                }
                if (wpn != null && attackKind == AttackKind.WeaponElementalProjectile)
                {
                    //add extra magic projectile damage
                    AddExtraDamage(ent, wpn, weapons2Esk, ref dmg);
                }

                NonPhysical[offensiveSpell.Kind.ToEntityStatKind()] = dmg;
                CurrentTotal += dmg;
            }

            if (attackKind != AttackKind.SpellElementalProjectile)
            {
                var nonPhysical = ent.GetNonPhysicalDamages();
                foreach (var npd in nonPhysical)
                {
                    bool add = true;
                    if (wpn != null)
                    {
                        if (attackKind == AttackKind.WeaponElementalProjectile)
                        {
                            if (wpn.IsMagician)
                            {
                                add = offensiveSpell.Kind.ToEntityStatKind() == npd.Key;
                            }
                        }
                        else if (attackKind == AttackKind.Melee)
                        {
                            add = !wpn.IsBowLike;
                        }

                        if (add)
                        {
                            var addition = npd.Value;
                            AddExtraDamage(ent, wpn, weapons2Esk, ref addition);
                            CurrentTotal += addition;


                            if (!NonPhysical.ContainsKey(npd.Key))
                            {
                                NonPhysical[npd.Key] = 0;
                            }
                            NonPhysical[npd.Key] += addition;
                        }
                    }
                }
            }

            Nominal = ent.Stats.GetStat(attackStat).Value.Nominal;
            Display = Nominal + "/" + CurrentTotal;
        }
Esempio n. 29
0
 public float CalcVariation(AttackKind attackKind, bool signed, float currentDamage)
 {
     return(ent.GetAttackVariation(attackKind, currentDamage, signed));
 }
Esempio n. 30
0
        private void Calc(LivingEntity ent, bool withVariation, ref AttackKind attackKind, OffensiveSpell spell)
        {
            try
            {
                this.withVariation = withVariation;
                this.spell         = spell;
                NonPhysical        = new Dictionary <EntityStatKind, float>();
                this.ent           = ent;
                Weapon wpn = null;
                //if (ent != null)//can be if using WeaponElementalProjectile
                {
                    wpn = ent.GetActiveWeapon();

                    attackKind = DiscoverAttackKind(attackKind, wpn);
                    AttackKind = attackKind;
                }

                if (AttackKind == AttackKind.SpellElementalProjectile && spell == null)
                {
                    return;
                }

                if (attackKind == AttackKind.PhysicalProjectile)
                {
                    fightItem = GetActiveFightItem(ent);
                    if (fightItem == null)
                    {
                        return;
                    }
                }
                if (attackKind == AttackKind.WeaponElementalProjectile)
                {
                    if (wpn != null)
                    {
                        if (wpn.SpellSource == null || wpn.SpellSource.Count == 0)
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                Dictionary <Weapon.WeaponKind, EntityStatKind> weapons2Esk = null;
                EntityStatKind attackStat = EntityStatKind.Unset;
                if (attackKind == AttackKind.Melee)
                {
                    attackStat = EntityStatKind.MeleeAttack;

                    weapons2Esk = AdvancedLivingEntity.MalleeWeapons2Esk;
                    if (wpn != null && wpn.IsMagician)
                    {
                        weapons2Esk = AdvancedLivingEntity.ProjectileWeapons2Esk;
                    }
                }
                else if (attackKind == AttackKind.PhysicalProjectile ||
                         attackKind == AttackKind.WeaponElementalProjectile)
                {
                    attackStat = EntityStatKind.Unset;
                    if (attackKind == AttackKind.PhysicalProjectile)
                    {
                        attackStat = EntityStatKind.PhysicalProjectilesAttack;
                    }
                    else
                    {
                        attackStat = EntityStatKind.ElementalWeaponProjectilesAttack;
                    }
                    weapons2Esk = AdvancedLivingEntity.ProjectileWeapons2Esk;
                }
                CalcMembers(ent, wpn, weapons2Esk, attackStat, attackKind);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// Constructor for actor base melee attacks.
 /// </summary>
 /// <param name="kind"></param>
 /// <param name="verb"></param>
 /// <param name="hitValue"></param>
 /// <param name="damageValue"></param>
 public Attack(AttackKind kind, Verb verb, int hitValue, int damageValue)
     : this(kind, verb, hitValue, hitValue, hitValue, damageValue, 0, 0, 0)
 {
 }