diff --git a/Source/CombatExtended/CombatExtended/Comps/CompSuppressable.cs b/Source/CombatExtended/CombatExtended/Comps/CompSuppressable.cs index cb018ec67e..d3578ccb65 100755 --- a/Source/CombatExtended/CombatExtended/Comps/CompSuppressable.cs +++ b/Source/CombatExtended/CombatExtended/Comps/CompSuppressable.cs @@ -20,6 +20,7 @@ public class CompSuppressable : ThingComp private const int TicksForDecayStart = 30; // How long since last suppression before decay starts private const float SuppressionDecayRate = 4f; // How much suppression decays per tick private const int TicksPerMote = 150; // How many ticks between throwing a mote + private const int hunkeringMinDuration = 240; // How long in ticks until pawn can try to stop hunkering private const int MinTicksUntilMentalBreak = 600; // How long until pawn can have a mental break private const float ChanceBreakPerTick = 0.001f; // How likely we are to break each tick above the threshold @@ -120,7 +121,7 @@ public bool IsHunkering { get { - if (currentSuppression > (SuppressionThreshold * 10)) + if (currentSuppression > (SuppressionThreshold * 10) || (ticksHunkered > 0 && ticksHunkered < hunkeringMinDuration)) { if (isSuppressed) { @@ -288,7 +289,7 @@ public override void CompTickInterval(int delta) MoteMakerCE.ThrowText(parent.DrawPos, parent.Map, "-" + (SuppressionDecayRate * 30), Color.red); } currentSuppression -= Mathf.Min(SuppressionDecayRate * delta, currentSuppression); - isSuppressed = currentSuppression > 0; + isSuppressed = currentSuppression > 0 || (ticksHunkered > 0 && ticksHunkered < hunkeringMinDuration); // Clear crouch-walking if (!isSuppressed) diff --git a/Source/CombatExtended/CombatExtended/Jobs/JobDriver_HunkerDown.cs b/Source/CombatExtended/CombatExtended/Jobs/JobDriver_HunkerDown.cs index 22be4b570a..ae9ffb89c0 100755 --- a/Source/CombatExtended/CombatExtended/Jobs/JobDriver_HunkerDown.cs +++ b/Source/CombatExtended/CombatExtended/Jobs/JobDriver_HunkerDown.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using RimWorld; +using UnityEngine; using Verse; using Verse.AI; @@ -8,7 +9,7 @@ class JobDriver_HunkerDown : JobDriver { private const int GetUpCheckInterval = 60; - public override void SetInitialPosture() + private void SetPosture() { pawn.jobs.posture = PawnPosture.LayingOnGroundNormal; } @@ -22,20 +23,17 @@ public override IEnumerable MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); - //Define Toil - Toil toilWait = new Toil(); - toilWait.initAction = () => - { - toilWait.actor.pather.StopDead(); - }; + int changePostureDelay = 10 + Mathf.RoundToInt(60f / Mathf.Max(0.6f, pawn.GetStatValue(StatDefOf.MoveSpeed) - 1.25f)); + Toil changePostureToil = Toils_General.Wait(changePostureDelay); + changePostureToil.AddFinishAction(SetPosture); + //Hunkering toil Toil toilNothing = new Toil(); - //toilNothing.initAction = () => {}; toilNothing.defaultCompleteMode = ToilCompleteMode.Delay; toilNothing.defaultDuration = GetUpCheckInterval; - // Start Toil - yield return toilWait; + // Start Toils + yield return changePostureToil; yield return toilNothing; yield return Toils_Jump.JumpIf(toilNothing, () => {