コード例 #1
0
 public override float GetPriority()
 {
     if (!IsAllowed)
     {
         Priority = 0;
         return(Priority);
     }
     if (!objectiveManager.IsCurrentOrder <AIObjectiveExtinguishFires>() &&
         Character.CharacterList.Any(c => c.CurrentHull == targetHull && !HumanAIController.IsFriendly(c) && HumanAIController.IsActive(c)))
     {
         Priority = 0;
     }
     else
     {
         float yDist = Math.Abs(character.WorldPosition.Y - targetHull.WorldPosition.Y);
         yDist = yDist > 100 ? yDist * 3 : 0;
         float dist           = Math.Abs(character.WorldPosition.X - targetHull.WorldPosition.X) + yDist;
         float distanceFactor = MathHelper.Lerp(1, 0.1f, MathUtils.InverseLerp(0, 5000, dist));
         if (targetHull == character.CurrentHull)
         {
             distanceFactor = 1;
         }
         float severity       = AIObjectiveExtinguishFires.GetFireSeverity(targetHull);
         float severityFactor = MathHelper.Lerp(0, 1, severity / 100);
         float devotion       = CumulatedDevotion / 100;
         Priority = MathHelper.Lerp(0, 100, MathHelper.Clamp(devotion + (severityFactor * distanceFactor * PriorityModifier), 0, 1));
     }
     return(Priority);
 }
コード例 #2
0
        public override float GetPriority()
        {
            if (Character.CharacterList.Any(c => c.CurrentHull == targetHull && !HumanAIController.IsFriendly(c)))
            {
                return(0);
            }
            // Vertical distance matters more than horizontal (climbing up/down is harder than moving horizontally)
            float dist           = Math.Abs(character.WorldPosition.X - targetHull.WorldPosition.X) + Math.Abs(character.WorldPosition.Y - targetHull.WorldPosition.Y) * 2.0f;
            float distanceFactor = MathHelper.Lerp(1, 0.1f, MathUtils.InverseLerp(0, 10000, dist));
            float severity       = AIObjectiveExtinguishFires.GetFireSeverity(targetHull);
            float severityFactor = MathHelper.Lerp(0, 1, severity / 100);
            float devotion       = Math.Min(Priority, 10) / 100;

            return(MathHelper.Lerp(0, 100, MathHelper.Clamp(devotion + severityFactor * distanceFactor, 0, 1)));
        }
コード例 #3
0
        protected override float GetPriority()
        {
            if (!IsAllowed)
            {
                Priority = 0;
                Abandon  = true;
                return(Priority);
            }
            bool isOrder = objectiveManager.HasOrder <AIObjectiveExtinguishFires>();

            if (!isOrder && Character.CharacterList.Any(c => c.CurrentHull == targetHull && !HumanAIController.IsFriendly(c) && HumanAIController.IsActive(c)))
            {
                // Don't go into rooms with any enemies, unless it's an order
                Priority = 0;
                Abandon  = true;
            }
            else
            {
                float yDist = Math.Abs(character.WorldPosition.Y - targetHull.WorldPosition.Y);
                yDist = yDist > 100 ? yDist * 3 : 0;
                float dist           = Math.Abs(character.WorldPosition.X - targetHull.WorldPosition.X) + yDist;
                float distanceFactor = MathHelper.Lerp(1, 0.1f, MathUtils.InverseLerp(0, 5000, dist));
                if (targetHull == character.CurrentHull || HumanAIController.VisibleHulls.Contains(targetHull))
                {
                    distanceFactor = 1;
                }
                float severity = AIObjectiveExtinguishFires.GetFireSeverity(targetHull);
                if (severity > 0.75f && !isOrder &&
                    targetHull.RoomName != null &&
                    !targetHull.RoomName.Contains("reactor", StringComparison.OrdinalIgnoreCase) &&
                    !targetHull.RoomName.Contains("engine", StringComparison.OrdinalIgnoreCase) &&
                    !targetHull.RoomName.Contains("command", StringComparison.OrdinalIgnoreCase))
                {
                    // Ignore severe fires to prevent casualities unless ordered to extinguish.
                    Priority = 0;
                    Abandon  = true;
                }
                else
                {
                    float devotion = CumulatedDevotion / 100;
                    Priority = MathHelper.Lerp(0, 100, MathHelper.Clamp(devotion + (severity * distanceFactor * PriorityModifier), 0, 1));
                }
            }
            return(Priority);
        }
コード例 #4
0
        public override float GetPriority()
        {
            if (!IsAllowed)
            {
                Priority = 0;
                Abandon  = true;
                return(Priority);
            }
            bool isOrder = objectiveManager.HasOrder <AIObjectiveExtinguishFires>();

            if (!isOrder && Character.CharacterList.Any(c => c.CurrentHull == targetHull && !HumanAIController.IsFriendly(c) && HumanAIController.IsActive(c)))
            {
                // Don't go into rooms with any enemies, unless it's an order
                Priority = 0;
                Abandon  = true;
            }
            else
            {
                float yDist = Math.Abs(character.WorldPosition.Y - targetHull.WorldPosition.Y);
                yDist = yDist > 100 ? yDist * 3 : 0;
                float dist           = Math.Abs(character.WorldPosition.X - targetHull.WorldPosition.X) + yDist;
                float distanceFactor = MathHelper.Lerp(1, 0.1f, MathUtils.InverseLerp(0, 5000, dist));
                if (targetHull == character.CurrentHull || HumanAIController.VisibleHulls.Contains(targetHull))
                {
                    distanceFactor = 1;
                }
                float severity = AIObjectiveExtinguishFires.GetFireSeverity(targetHull);
                if (severity > 0.5f && !isOrder)
                {
                    // Ignore severe fires unless ordered. (Let the fire drain all the oxygen instead).
                    Priority = 0;
                    Abandon  = true;
                }
                else
                {
                    float devotion = CumulatedDevotion / 100;
                    Priority = MathHelper.Lerp(0, 100, MathHelper.Clamp(devotion + (severity * distanceFactor * PriorityModifier), 0, 1));
                }
            }
            return(Priority);
        }