diff --git a/Barotrauma/Content/Characters/Crawler/crawler.xml b/Barotrauma/Content/Characters/Crawler/crawler.xml index de3270ce2..9d0e1de0f 100644 --- a/Barotrauma/Content/Characters/Crawler/crawler.xml +++ b/Barotrauma/Content/Characters/Crawler/crawler.xml @@ -1,5 +1,5 @@  - + @@ -78,6 +78,7 @@ diff --git a/Barotrauma/Content/Characters/Mantis/mantis.xml b/Barotrauma/Content/Characters/Mantis/mantis.xml index 0dee0b607..cd816f21b 100644 --- a/Barotrauma/Content/Characters/Mantis/mantis.xml +++ b/Barotrauma/Content/Characters/Mantis/mantis.xml @@ -95,6 +95,7 @@ attackprioritystronger="-30" attackcooldown="1.0" sight="0.5" - hearing="1.0"/> + hearing="1.0" + fleehealththreshold="20"/> diff --git a/Barotrauma/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/Source/Characters/AI/EnemyAIController.cs index b2ef38b81..7d9315b8b 100644 --- a/Barotrauma/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/Source/Characters/AI/EnemyAIController.cs @@ -48,6 +48,9 @@ namespace Barotrauma //the limb selected for the current attack private Limb attackingLimb; + + //flee when the health is below this value + private float fleeHealthThreshold; private AITarget selectedAiTarget; private AITargetMemory selectedTargetMemory; @@ -89,6 +92,8 @@ namespace Barotrauma attackWhenProvoked = ToolBox.GetAttributeBool(aiElement, "attackwhenprovoked", false); + fleeHealthThreshold = ToolBox.GetAttributeFloat(aiElement, "fleehealththreshold", 0.0f); + outsideSteering = new SteeringManager(this); insideSteering = new IndoorsSteeringManager(this, false); @@ -146,7 +151,7 @@ namespace Barotrauma } else { - state = (targetValue > 0.0f) ? AiState.Attack : AiState.Escape; + state = (targetValue < 0.0f || Character.Health < fleeHealthThreshold) ? AiState.Escape : AiState.Attack; } //if (coolDownTimer >= 0.0f) return; }