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:
parent
8eda5c82b5
commit
494e92c687
1 changed files with 30 additions and 11 deletions
|
|
@ -1373,6 +1373,11 @@ in
|
||||||
property real targetX: 0
|
property real targetX: 0
|
||||||
property string errand: "" // "" | "bowl" | "bed" | "ball"
|
property string errand: "" // "" | "bowl" | "bed" | "ball"
|
||||||
property int hold: 0
|
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
|
// Legs swap on distance covered, not on a tick count, so the
|
||||||
// gait stays in step whether he is ambling or running for 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.
|
// ball. 3 cells is exactly how far the feet move in the art.
|
||||||
|
|
@ -1443,17 +1448,24 @@ in
|
||||||
function wander() {
|
function wander() {
|
||||||
mode = "walk";
|
mode = "walk";
|
||||||
errand = "";
|
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 dBowl = Math.abs(px - bowlStandX);
|
||||||
let dBed = Math.abs(px - bedLieX);
|
|
||||||
// Near enough to be worth it, and not already stood there
|
// Near enough to be worth it, and not already stood there
|
||||||
// — otherwise he marches half a minute for a snack, or
|
// — otherwise he marches half a minute for a snack, or
|
||||||
// rolls "go to the bowl" with his head already in it. No
|
// rolls "go to the bowl" with his head already in it. No
|
||||||
// errands while he has the ball; he is busy.
|
// errands while he has the ball; he is busy.
|
||||||
if (!ballCarried && Math.random() < 0.3 && dBowl > 80 && dBowl < 900) errand = "bowl";
|
if (!ballCarried && Math.random() < 0.3 && dBowl > 80 && dBowl < 900) {
|
||||||
else if (!ballCarried && Math.random() < 0.25 && dBed > 80 && dBed < 900) errand = "bed";
|
errand = "bowl";
|
||||||
|
targetX = bowlStandX;
|
||||||
if (errand === "bowl") { targetX = bowlStandX; return; }
|
return;
|
||||||
if (errand === "bed") { targetX = bedLieX; return; }
|
}
|
||||||
|
|
||||||
let dir = Math.random() < 0.5 ? -1 : 1;
|
let dir = Math.random() < 0.5 ? -1 : 1;
|
||||||
// Turn away from an end he is already near; clamping the
|
// Turn away from an end he is already near; clamping the
|
||||||
|
|
@ -1487,11 +1499,13 @@ in
|
||||||
facing = 1;
|
facing = 1;
|
||||||
} else if (errand === "bed") {
|
} else if (errand === "bed") {
|
||||||
mode = "sleep";
|
mode = "sleep";
|
||||||
hold = 600 + Math.random() * 900;
|
hold = 9000 + Math.random() * 9000; // 5-10 minutes
|
||||||
facing = 1;
|
// Facing into the screen. His bed is in the right
|
||||||
|
// corner, so unmirrored he sleeps nose-to-the-wall.
|
||||||
|
facing = -1;
|
||||||
} else {
|
} else {
|
||||||
mode = "idle";
|
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.lastBX = archie.ballX;
|
||||||
archie.lastBY = archie.ballY;
|
archie.lastBY = archie.ballY;
|
||||||
|
|
||||||
// A thrown ball beats whatever else he was doing.
|
// A thrown ball beats whatever else he was doing,
|
||||||
if (archie.ballLoose && archie.errand !== "ball") archie.chase();
|
// 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) {
|
if (archie.ballCarried && --archie.carry <= 0) {
|
||||||
archie.ballCarried = false;
|
archie.ballCarried = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue