diff --git a/Content.Server/NPC/HTN/HTNComponent.cs b/Content.Server/NPC/HTN/HTNComponent.cs index 788a347638..43b8a70785 100644 --- a/Content.Server/NPC/HTN/HTNComponent.cs +++ b/Content.Server/NPC/HTN/HTNComponent.cs @@ -37,6 +37,9 @@ public sealed partial class HTNComponent : NPCComponent [ViewVariables(VVAccess.ReadWrite)] public float PlanAccumulator = 0f; + [DataField] + public bool ConstantlyReplan = true; + [ViewVariables] public HTNPlanJob? PlanningJob = null; diff --git a/Content.Server/NPC/HTN/HTNSystem.cs b/Content.Server/NPC/HTN/HTNSystem.cs index ce4b248a0d..89b4ae7786 100644 --- a/Content.Server/NPC/HTN/HTNSystem.cs +++ b/Content.Server/NPC/HTN/HTNSystem.cs @@ -328,7 +328,7 @@ public sealed class HTNSystem : EntitySystem component.PlanAccumulator -= frameTime; // We'll still try re-planning occasionally even when we're updating in case new data comes in. - if (component.PlanAccumulator <= 0f) + if ((component.ConstantlyReplan || component.Plan is null) && component.PlanAccumulator <= 0f) { RequestPlan(component); } @@ -462,7 +462,7 @@ public sealed class HTNSystem : EntitySystem if (component.PlanningJob != null) return; - component.PlanAccumulator += component.PlanCooldown; + component.PlanAccumulator = component.PlanCooldown; var cancelToken = new CancellationTokenSource(); var branchTraversal = component.Plan?.BranchTraversalRecord; diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index a7aca49505..22f818d56b 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -332,6 +332,7 @@ - type: Item size: Tiny - type: HTN + constantlyReplan: false rootTask: task: MouseCompound - type: Physics @@ -1681,6 +1682,7 @@ factions: - Mouse - type: HTN + constantlyReplan: false rootTask: task: MouseCompound - type: Physics diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/asteroid.yml b/Resources/Prototypes/Entities/Mobs/NPCs/asteroid.yml index dcc8c4fbb8..c7279801f0 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/asteroid.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/asteroid.yml @@ -70,6 +70,7 @@ factions: - SimpleHostile - type: HTN + constantlyReplan: false rootTask: task: GoliathCompound blackboard: diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/space.yml b/Resources/Prototypes/Entities/Mobs/NPCs/space.yml index 4ae6813963..9ed92709ea 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/space.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/space.yml @@ -405,6 +405,7 @@ factions: - Mouse - type: HTN + constantlyReplan: false rootTask: task: MouseCompound - type: Physics