protected override float TargetEvaluation() { int totalLeaks = Targets.Count(); if (totalLeaks == 0) { return(0); } int otherFixers = HumanAIController.CountCrew(c => c != HumanAIController && c.ObjectiveManager.IsCurrentObjective <AIObjectiveFixLeaks>() && !c.Character.IsIncapacitated, onlyBots: true); bool anyFixers = otherFixers > 0; if (objectiveManager.IsOrder(this)) { float ratio = anyFixers ? totalLeaks / (float)otherFixers : 1; return(Targets.Sum(t => GetLeakSeverity(t)) * ratio); } else { int secondaryLeaks = Targets.Count(l => l.IsRoomToRoom); int leaks = totalLeaks - secondaryLeaks; float ratio = leaks == 0 ? 1 : anyFixers ? leaks / otherFixers : 1; if (anyFixers && (ratio <= 1 || otherFixers > 5 || otherFixers / (float)HumanAIController.CountCrew(onlyBots: true) > 0.75f)) { // Enough fixers return(0); } return(Targets.Sum(t => GetLeakSeverity(t)) * ratio); } }
protected override float TargetEvaluation() { if (character.SelectedConstruction != null && Targets.Any(t => character.SelectedConstruction == t && t.ConditionPercentage < 100)) { // Don't stop fixing until done return(100); } int otherFixers = HumanAIController.CountCrew(c => c != HumanAIController && c.ObjectiveManager.IsCurrentObjective <AIObjectiveRepairItems>() && !c.Character.IsIncapacitated, onlyBots: true); int items = Targets.Count; bool anyFixers = otherFixers > 0; float ratio = anyFixers ? items / (float)otherFixers : 1; if (objectiveManager.CurrentOrder == this) { return(Targets.Sum(t => 100 - t.ConditionPercentage) * ratio); } else { if (anyFixers && (ratio <= 1 || otherFixers > 5 || otherFixers / (float)HumanAIController.CountCrew(onlyBots: true) > 0.75f)) { // Enough fixers return(0); } if (RequireAdequateSkills) { return(Targets.Sum(t => GetTargetPriority(t, character, RequiredSuccessFactor)) * ratio); } else { return(Targets.Sum(t => 100 - t.ConditionPercentage) * ratio); } } }
protected override float TargetEvaluation() { int otherRescuers = HumanAIController.CountCrew(c => c != HumanAIController && c.ObjectiveManager.IsCurrentObjective <AIObjectiveRescueAll>(), onlyBots: true); int targetCount = Targets.Count; bool anyRescuers = otherRescuers > 0; float ratio = anyRescuers ? targetCount / (float)otherRescuers : 1; if (objectiveManager.CurrentOrder == this) { return(Targets.Min(t => GetVitalityFactor(t)) / ratio); } else { float multiplier = 1; if (anyRescuers) { float mySkill = character.GetSkillLevel("medical"); int betterRescuers = HumanAIController.CountCrew(c => c != HumanAIController && c.Character.Info.Job.GetSkillLevel("medical") >= mySkill, onlyBots: true); if (targetCount / (float)betterRescuers <= 1) { // Enough rescuers return(100); } else { bool foundOtherMedics = HumanAIController.IsTrueForAnyCrewMember(c => c != HumanAIController && c.Character.Info.Job.Prefab.Identifier == "medicaldoctor"); if (foundOtherMedics) { if (character.Info.Job.Prefab.Identifier != "medicaldoctor") { // Double the vitality factor -> less likely to take action multiplier = 2; } } } } return(Targets.Min(t => GetVitalityFactor(t)) / ratio * multiplier); } }