public static AttackRisk GetRiskKind(float risk)
        {
            AttackRisk result = AttackRisk.Wait;

            if (risk < 1f)
            {
                result = AttackRisk.RunAway;
            }
            if (risk < 0.75f)
            {
                result = AttackRisk.Evade;
            }
            if (risk < 0.6f)
            {
                result = AttackRisk.Wait;
            }
            if (risk < 0.4f)
            {
                result = AttackRisk.Wary;
            }
            if (risk < 0.25f)
            {
                result = AttackRisk.Immediately;
            }
            return(result);
        }
        protected virtual void PrepareEvade(CreatureEntity enemy, AttackRisk risk, bool canMove)
        {
            EnemyEvadeGoal evadeGoal = (EnemyEvadeGoal)FindGoalByKind(GoalKind.gk_EnemyEvade);

            if (evadeGoal == null || !evadeGoal.Enemy.Equals(enemy))
            {
                evadeGoal         = ((EnemyEvadeGoal)CreateGoal(GoalKind.gk_EnemyEvade));
                evadeGoal.Enemy   = enemy;
                evadeGoal.Risk    = risk;
                evadeGoal.CanMove = canMove;
            }
        }
        protected virtual void PrepareChase(CreatureEntity enemy, AttackRisk risk, bool canMove)
        {
            EnemyChaseGoal chaseGoal = (EnemyChaseGoal)FindGoalByKind(GoalKind.gk_EnemyChase);

            if (chaseGoal == null || !chaseGoal.Enemy.Equals(enemy))
            {
                chaseGoal         = ((EnemyChaseGoal)CreateGoal(GoalKind.gk_EnemyChase));
                chaseGoal.Enemy   = enemy;
                chaseGoal.Risk    = risk;
                chaseGoal.CanMove = canMove;
            }
        }
Example #4
0
 protected override void PrepareEvade(CreatureEntity enemy, AttackRisk risk, bool canMove)
 {
     base.PrepareEvade(enemy, risk, canMove);
     SetAlarm();
 }