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 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 00:32:25 +03:00
parent 24c16ebee4
commit 9ec1b3a9bf
6 changed files with 13 additions and 5 deletions

View file

@ -53,6 +53,7 @@ export property NpcPerson {
wtz: float = 0.0 wtz: float = 0.0
way_t: float = 0.0 # seconds until it asks the way again 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: 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_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_z: float = 0.0
goal_speed: float = 0.0 goal_speed: float = 0.0

View file

@ -87,7 +87,7 @@ program NpcWayTest {
npc_tests_fake_st.fk_want = 1 npc_tests_fake_st.fk_want = 1
let p = npc_spawn(npc_st, NPCK_HIKER) let p = npc_spawn(npc_st, NPCK_HIKER)
npc_set_at(p, 0.0, 0.0) 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) npc_go(npc_st, p, 38.0, -25.0, NPCA_SIT, 30.0)
for k in 0 .. 60 { npc_tick(npc_st, 0.05) } for k in 0 .. 60 { npc_tick(npc_st, 0.05) }
expect_eq(p.x, 0.0) expect_eq(p.x, 0.0)

View file

@ -64,7 +64,10 @@ function np_crowd_want(p: NpcPerson, speed: float) -> void {
p.goal_z = p.tz p.goal_z = p.tz
p.goal_speed = speed 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 { export function npc_moved(p: NpcPerson, x: float, z: float, vx: float, vz: float) -> void {
let dx = x - p.x let dx = x - p.x
let dz = z - p.z let dz = z - p.z

View file

@ -45,6 +45,7 @@ export property WildAnimal {
wz: float = 0.0 wz: float = 0.0
way_t: float = 0.0 # seconds until it asks the way again; 0 asks at once 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: 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_x: float = 0.0 # where it walks this tick and how fast: what a crowd is handed
goal_z: float = 0.0 goal_z: float = 0.0
goal_speed: float = 0.0 goal_speed: float = 0.0

View file

@ -42,7 +42,7 @@ program WildCrowdTest {
wildlife_tests_fake_st.fk_px[0] = 400.0 wildlife_tests_fake_st.fk_px[0] = 400.0
wildlife_tests_fake_st.fk_pz[0] = 0.0 wildlife_tests_fake_st.fk_pz[0] = 0.0
wildlife_tests_fake_st.fk_hidden = true wildlife_tests_fake_st.fk_hidden = true
wildlife_set_crowd(a, true) wildlife_set_crowd(a, 0)
return a return a
} }

View file

@ -23,8 +23,11 @@ function wl_crowd_step(a: WildAnimal) -> bool {
return true return true
} }
# walked by a crowd, or by its own step again (off, it keeps where the crowd left it) # 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, on: bool) -> void { a.crowd = on } 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 # 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 # ground from the world's, and its prints as it goes