Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix: stand a revived duel fighter up after a late death event (#1062)

Ruben Lütke57ae95988674
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index de9e456201..c522e70394 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -162,7 +162,7 @@ jobs:
# A re-run after a partial upload skips the files PyPI already holds
# (released files are immutable, so they are the ones this tag built).
- name: Publish dodaios
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
packages-dir: dist/dodaios/
skip-existing: true
@@ -188,7 +188,7 @@ jobs:
# The thin package: existing `pip install personal-jarvis` installs and
# stored `uvx --from personal-jarvis` commands follow it to `dodaios`.
- name: Publish personal-jarvis
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
packages-dir: dist/personal-jarvis/
skip-existing: true
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.test.ts b/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.test.ts
index 56c75c7bd0..bd425fd53b 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.test.ts
+++ b/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.test.ts
@@ -193,6 +193,53 @@ describe("fighter animator", () => {
expect(weightOf(f, DUEL_CLIPS.idle)).toBeCloseTo(1);
});
+ it("does not keep the corpse when a death event arrives after the body is alive again", () => {
+ // DuelLayer poses the body, then routes the frame's events. A death from the
+ // round already over must not pin the fallen clip while the next round walks.
+ const a = new FighterAnimator(DEFAULT_LOCO);
+ a.update(dt, input());
+ a.knockedOut(0, 0, 0, -10);
+ a.update(dt, input({ alive: false }));
+ for (let i = 0; i < 40; i += 1) a.update(dt, input({ alive: false }));
+ let f = a.update(dt, input({ alive: true }));
+ a.knockedOut(0, 0, 0, -10);
+ for (let i = 0; i < 180; i += 1) f = a.update(dt, input({ alive: true, vz: 4.8 }));
+ expect(weightOf(f, DUEL_CLIPS.death)).toBe(0);
+ expect(weightOf(f, DUEL_CLIPS.getUp)).toBe(0);
+ expect(weightOf(f, "A_Combat_Run_F")).toBeGreaterThan(0.9);
+ });
+
+ it("does not lay the body down when the death event arrives while the view is still alive", () => {
+ const a = new FighterAnimator(DEFAULT_LOCO);
+ a.update(dt, input());
+ a.knockedOut(0, 0, 0, -10);
+ let f = a.update(dt, input({ alive: true, vz: 4.8 }));
+ for (let i = 0; i < 30; i += 1) f = a.update(dt, input({ alive: true, vz: 4.8 }));
+ expect(weightOf(f, DUEL_CLIPS.death)).toBe(0);
+ expect(weightOf(f, "A_Combat_Run_F")).toBeGreaterThan(0.5);
+ });
+
+ it("turns toward the shooter when the death event arrives in the same frame as the dead view", () => {
+ const a = new FighterAnimator(DEFAULT_LOCO);
+ a.update(dt, input());
+ let f = a.update(dt, input({ alive: false }));
+ a.knockedOut(0, 0, 0, -10);
+ for (let i = 0; i < 200; i += 1) f = a.update(dt, input({ alive: false }));
+ expect(Math.abs(f.legsYaw)).toBeCloseTo(Math.PI, 2);
+ expect(weightOf(f, DUEL_CLIPS.death)).toBeCloseTo(1);
+ });
+
+ it("forgets a fall direction that never became a knockout", () => {
+ const a = new FighterAnimator(DEFAULT_LOCO);
+ a.update(dt, input({ aimYaw: 0 }));
+ a.knockedOut(0, 0, 0, -10);
+ a.update(dt, input({ alive: true }));
+ let f = a.update(dt, input({ alive: false }));
+ for (let i = 0; i < 200; i += 1) f = a.update(dt, input({ alive: false }));
+ expect(Math.abs(f.legsYaw)).toBeLessThan(0.2);
+ expect(weightOf(f, DUEL_CLIPS.death)).toBeCloseTo(1);
+ });
+
it("flinches additively toward the hit and staggers on its own reflected bolt", () => {
const a = new FighterAnimator(DEFAULT_LOCO);
a.update(dt, input());
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.ts b/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.ts
index 7328766524..494f12c275 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.ts
+++ b/dodaios/ui/web/frontend/src/components/society/verse/duel/fighterAnim.ts
@@ -283,6 +283,8 @@ export class FighterAnimator {
private rollW = 0;
private death: { t: number; yaw: number } | null = null;
private getUp: { t: number } | null = null;
+ /** Fall direction from a knockout event that has not yet met a dead view. */
+ private fallYaw: number | null = null;
private wasAlive = true;
private readonly hits = new Map<string, OneShot>();
/** Shots still kicking: age (s) and size. */
@@ -318,11 +320,16 @@ export class FighterAnimator {
this.parryT = 0;
}
- /** Knocked out by a shooter standing at (fromX, fromZ): the body turns to face them and falls back, away. */
+ /**
+ * Knocked out by a shooter standing at (fromX, fromZ). The event only
+ * records the fall direction. The corpse clip follows the view's `alive`
+ * flag, so an event that arrives while the body is already up cannot pin
+ * the fallen pose onto the next round.
+ */
knockedOut(x: number, z: number, fromX: number, fromZ: number): void {
- if (this.death) return;
const yaw = Math.hypot(fromX - x, fromZ - z) > 0.05 ? Math.atan2(fromX - x, fromZ - z) : this.legsYaw;
- this.death = { t: 0, yaw };
+ this.fallYaw = yaw;
+ if (this.death && this.death.t < 0.15) this.death.yaw = yaw;
}
/** Advance by `dt` seconds with this frame's fighter state. */
@@ -332,15 +339,23 @@ export class FighterAnimator {
this.clock += dt;
if (!this.primed) { this.legsYaw = p.aimYaw; this.primed = true; this.wasAlive = p.alive; }
- // Life: a knockout without its event still falls; a revived body gets up.
- if (!p.alive && !this.death) this.death = { t: 0, yaw: this.legsYaw };
- if (p.alive && !this.wasAlive) {
+ // The corpse pose follows the view. A knockout event may arrive a frame
+ // early or a frame late; it only supplies the fall direction.
+ if (!p.alive) {
+ if (!this.death) this.death = { t: 0, yaw: this.fallYaw ?? this.legsYaw };
+ this.getUp = null;
+ } else if (this.death || !this.wasAlive) {
this.death = null;
- this.getUp = { t: 0 };
- this.legsYaw = p.aimYaw;
- this.turn = null;
- this.roll = null;
- this.hits.clear();
+ this.fallYaw = null;
+ if (!this.getUp) {
+ this.getUp = { t: 0 };
+ this.legsYaw = p.aimYaw;
+ this.turn = null;
+ this.roll = null;
+ this.hits.clear();
+ }
+ } else {
+ this.fallYaw = null;
}
this.wasAlive = p.alive;
if (this.death) this.death.t = Math.min(TIMING.death, this.death.t + dt);