quickshell: Archie gets tired and takes proper naps, sleeping facing inward

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-04 13:55:59 +01:00
parent 8eda5c82b5
commit 494e92c687

View file

@ -1373,6 +1373,11 @@ in
property real targetX: 0
property string errand: "" // "" | "bowl" | "bed" | "ball"
property int hold: 0
// Ticks since he last got up. Past `tired` he takes himself
// off to bed; the ball resets it, so a throw both wakes him
// and buys him a fresh stretch of being up.
property int awake: 0
readonly property int tired: 2700 // 90s on his feet
// Legs swap on distance covered, not on a tick count, so the
// gait stays in step whether he is ambling or running for the
// ball. 3 cells is exactly how far the feet move in the art.
@ -1443,17 +1448,24 @@ in
function wander() {
mode = "walk";
errand = "";
// Bed is not a random errand any more, it is what he does
// when he has been up long enough. A dog sleeps most of
// the day; pottering about non-stop is the odd bit.
if (awake > tired && !ballCarried) {
errand = "bed";
targetX = bedLieX;
return;
}
let dBowl = Math.abs(px - bowlStandX);
let dBed = Math.abs(px - bedLieX);
// Near enough to be worth it, and not already stood there
// otherwise he marches half a minute for a snack, or
// rolls "go to the bowl" with his head already in it. No
// errands while he has the ball; he is busy.
if (!ballCarried && Math.random() < 0.3 && dBowl > 80 && dBowl < 900) errand = "bowl";
else if (!ballCarried && Math.random() < 0.25 && dBed > 80 && dBed < 900) errand = "bed";
if (errand === "bowl") { targetX = bowlStandX; return; }
if (errand === "bed") { targetX = bedLieX; return; }
if (!ballCarried && Math.random() < 0.3 && dBowl > 80 && dBowl < 900) {
errand = "bowl";
targetX = bowlStandX;
return;
}
let dir = Math.random() < 0.5 ? -1 : 1;
// Turn away from an end he is already near; clamping the
@ -1487,11 +1499,13 @@ in
facing = 1;
} else if (errand === "bed") {
mode = "sleep";
hold = 600 + Math.random() * 900;
facing = 1;
hold = 9000 + Math.random() * 9000; // 5-10 minutes
// Facing into the screen. His bed is in the right
// corner, so unmirrored he sleeps nose-to-the-wall.
facing = -1;
} else {
mode = "idle";
hold = 45 + Math.random() * 130;
hold = 150 + Math.random() * 450; // 5-20s stood about
}
}
@ -1515,8 +1529,13 @@ in
archie.lastBX = archie.ballX;
archie.lastBY = archie.ballY;
// A thrown ball beats whatever else he was doing.
if (archie.ballLoose && archie.errand !== "ball") archie.chase();
// A thrown ball beats whatever else he was doing,
// sleeping included that is how you wake him.
if (archie.ballLoose && archie.errand !== "ball") {
archie.awake = 0;
archie.chase();
}
archie.awake = archie.mode === "sleep" ? 0 : archie.awake + 1;
if (archie.ballCarried && --archie.carry <= 0) {
archie.ballCarried = false;