From 9ec1b3a9bf067d4cc7d307a25eee5c19daa27f5a Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Mon, 28 Sep 2026 00:32:25 +0300 Subject: [PATCH] ludic.wildlife, ludic.npc (18.3): a crowd walker carries its walker's id (set_crowd(a, id), -1 off) Co-Authored-By: Claude Opus 5.5 --- packages/ludic.npc/defs.ludic | 1 + packages/ludic.npc/tests/way_test.ludic | 2 +- packages/ludic.npc/way.ludic | 5 ++++- packages/ludic.wildlife/animal.ludic | 1 + packages/ludic.wildlife/tests/crowd_test.ludic | 2 +- packages/ludic.wildlife/walked.ludic | 7 +++++-- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/ludic.npc/defs.ludic b/packages/ludic.npc/defs.ludic index f9da8e17..7b68f956 100644 --- a/packages/ludic.npc/defs.ludic +++ b/packages/ludic.npc/defs.ludic @@ -53,6 +53,7 @@ export property NpcPerson { wtz: float = 0.0 way_t: float = 0.0 # seconds until it asks the way again crowd: bool = false # walked by the world's crowd (phase 18): it decides, the crowd moves it + crowd_id: int = -1 # its walker in that crowd, the world's number for it goal_x: float = 0.0 # where it walks this tick and how fast (0 standing): what a crowd is handed goal_z: float = 0.0 goal_speed: float = 0.0 diff --git a/packages/ludic.npc/tests/way_test.ludic b/packages/ludic.npc/tests/way_test.ludic index 256c153b..1f9a8959 100644 --- a/packages/ludic.npc/tests/way_test.ludic +++ b/packages/ludic.npc/tests/way_test.ludic @@ -87,7 +87,7 @@ program NpcWayTest { npc_tests_fake_st.fk_want = 1 let p = npc_spawn(npc_st, NPCK_HIKER) npc_set_at(p, 0.0, 0.0) - npc_set_crowd(p, true) + npc_set_crowd(p, 0) npc_go(npc_st, p, 38.0, -25.0, NPCA_SIT, 30.0) for k in 0 .. 60 { npc_tick(npc_st, 0.05) } expect_eq(p.x, 0.0) diff --git a/packages/ludic.npc/way.ludic b/packages/ludic.npc/way.ludic index e819cdd4..6ac365b3 100644 --- a/packages/ludic.npc/way.ludic +++ b/packages/ludic.npc/way.ludic @@ -64,7 +64,10 @@ function np_crowd_want(p: NpcPerson, speed: float) -> void { p.goal_z = p.tz p.goal_speed = speed } -export function npc_set_crowd(p: NpcPerson, on: bool) -> void { p.crowd = on } +export function npc_set_crowd(p: NpcPerson, id: int) -> void { + p.crowd_id = id + p.crowd = id >= 0 +} export function npc_moved(p: NpcPerson, x: float, z: float, vx: float, vz: float) -> void { let dx = x - p.x let dz = z - p.z diff --git a/packages/ludic.wildlife/animal.ludic b/packages/ludic.wildlife/animal.ludic index 15ae0444..654f169c 100644 --- a/packages/ludic.wildlife/animal.ludic +++ b/packages/ludic.wildlife/animal.ludic @@ -45,6 +45,7 @@ export property WildAnimal { wz: float = 0.0 way_t: float = 0.0 # seconds until it asks the way again; 0 asks at once crowd: bool = false # walked by the world's crowd (phase 18): it decides, the crowd moves it + crowd_id: int = -1 # its walker in that crowd, the world's number for it goal_x: float = 0.0 # where it walks this tick and how fast: what a crowd is handed goal_z: float = 0.0 goal_speed: float = 0.0 diff --git a/packages/ludic.wildlife/tests/crowd_test.ludic b/packages/ludic.wildlife/tests/crowd_test.ludic index ba9396a4..a8fb8e05 100644 --- a/packages/ludic.wildlife/tests/crowd_test.ludic +++ b/packages/ludic.wildlife/tests/crowd_test.ludic @@ -42,7 +42,7 @@ program WildCrowdTest { wildlife_tests_fake_st.fk_px[0] = 400.0 wildlife_tests_fake_st.fk_pz[0] = 0.0 wildlife_tests_fake_st.fk_hidden = true - wildlife_set_crowd(a, true) + wildlife_set_crowd(a, 0) return a } diff --git a/packages/ludic.wildlife/walked.ludic b/packages/ludic.wildlife/walked.ludic index 58c8e2b6..1e0eb584 100644 --- a/packages/ludic.wildlife/walked.ludic +++ b/packages/ludic.wildlife/walked.ludic @@ -23,8 +23,11 @@ function wl_crowd_step(a: WildAnimal) -> bool { return true } -# walked by a crowd, or by its own step again (off, it keeps where the crowd left it) -export function wildlife_set_crowd(a: WildAnimal, on: bool) -> void { a.crowd = on } +# walked by a crowd as its walker `id`, or by its own step again with -1 (it keeps where it was left) +export function wildlife_set_crowd(a: WildAnimal, id: int) -> void { + a.crowd_id = id + a.crowd = id >= 0 +} # where the crowd put a walker, and how fast it went: its place, its heading from its velocity, its # ground from the world's, and its prints as it goes