Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,7 +121,7 @@ public bool IsHunkering
{
get
{
if (currentSuppression > (SuppressionThreshold * 10))
if (currentSuppression > (SuppressionThreshold * 10) || (ticksHunkered > 0 && ticksHunkered < hunkeringMinDuration))
{
if (isSuppressed)
{
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
using Verse.AI;

Expand All @@ -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;
}
Expand All @@ -22,20 +23,17 @@ public override IEnumerable<Toil> 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, () =>
{
Expand Down