Exemplo n.º 1
0
        private void MeleeAnimation()
        {
            // Are we in range and facing player? Then start attack.
            if (senses.PlayerInSight)
            {
                // Take the speed of movement during the attack animation into account when deciding if to attack
                EnemyEntity entity      = entityBehaviour.Entity as EnemyEntity;
                float       attackSpeed = ((entity.Stats.LiveSpeed + PlayerSpeedChanger.dfWalkBase) / PlayerSpeedChanger.classicToUnitySpeedUnitRatio) / EnemyMotor.AttackSpeedDivisor;

                if (senses.DistanceToPlayer >= MeleeDistance + attackSpeed)
                {
                    return;
                }

                // Don't attack if not hostile
                if (!motor.IsHostile)
                {
                    return;
                }

                // Set melee animation state
                mobile.ChangeEnemyState(MobileStates.PrimaryAttack);

                // Play melee sound
                if (sounds)
                {
                    sounds.PlayAttackSound();
                }
            }
        }
Exemplo n.º 2
0
        private bool MeleeAnimation()
        {
            // Are we in range and facing target? Then start attack.
            if (senses.TargetInSight && senses.TargetIsWithinYawAngle(22.5f, senses.LastKnownTargetPos))
            {
                float distance = MeleeDistance;
                // Classic uses separate melee distance for targeting player and for targeting other AI
                if (!DaggerfallUnity.Settings.EnhancedCombatAI && senses.Target != GameManager.Instance.PlayerEntityBehaviour)
                {
                    distance = ClassicMeleeDistanceVsAI;
                }

                // Take the rate of target approach into account when deciding if to attack
                if (senses.DistanceToTarget > distance + senses.TargetRateOfApproach)
                {
                    return(false);
                }

                // Set melee animation state
                mobile.ChangeEnemyState(MobileStates.PrimaryAttack);

                // Play melee sound
                if (sounds)
                {
                    sounds.PlayAttackSound();
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        private void MeleeAnimation()
        {
            // Are we in range and facing player? Then start attack.
            if (senses.PlayerInSight)
            {
                // Take the speed of movement during the attack animation and hit frame into account when calculating attack range
                EnemyEntity entity       = entityBehaviour.Entity as EnemyEntity;
                float       attackSpeed  = ((entity.Stats.LiveSpeed + PlayerMotor.dfWalkBase) / PlayerMotor.classicToUnitySpeedUnitRatio) / EnemyMotor.AttackSpeedDivisor;
                float       timeUntilHit = mobile.Summary.Enemy.HitFrame / DaggerfallWorkshop.Utility.EnemyBasics.PrimaryAttackAnimSpeed;

                if (senses.DistanceToPlayer >= (MeleeDistance + (attackSpeed * timeUntilHit)))
                {
                    return;
                }

                // Don't attack if not hostile
                if (!motor.IsHostile)
                {
                    return;
                }

                // Set melee animation state
                mobile.ChangeEnemyState(MobileStates.PrimaryAttack);

                // Play melee sound
                if (sounds)
                {
                    sounds.PlayAttackSound();
                }
            }
        }
Exemplo n.º 4
0
        private bool MeleeAnimation()
        {
            // Are we in range and facing target? Then start attack.
            if (senses.TargetInSight)
            {
                // Take the rate of target approach into account when deciding if to attack
                if (senses.DistanceToTarget >= MeleeDistance + senses.TargetRateOfApproach)
                {
                    return(false);
                }

                // Set melee animation state
                mobile.ChangeEnemyState(MobileStates.PrimaryAttack);

                // Play melee sound
                if (sounds)
                {
                    sounds.PlayAttackSound();
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        private void MeleeAnimation()
        {
            // Are we in range and facing player? Then start attack.
            if (senses.DistanceToPlayer < MeleeDistance && senses.PlayerInSight)
            {
                // Don't attack if not hostile
                if (!motor.IsHostile)
                {
                    return;
                }

                // Set melee animation state
                mobile.ChangeEnemyState(MobileStates.PrimaryAttack);

                // Play melee sound
                if (sounds)
                {
                    sounds.PlayAttackSound();
                }
            }
        }