ludic.npc (18.2): a person a crowd moves
npc_set_crowd hands a person to a crowd. Its walk no longer steps or asks the way: its want is goal_x / goal_z / goal_speed (0 when it is not walking). npc_moved hands back the crowd's place: position, ground, heading from velocity, gait. Arrival, the act and the give-up after twenty seconds without progress are unchanged. Nothing allocates. npc 16/16. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
81b6782c9d
commit
074f10f302
5 changed files with 48 additions and 1 deletions
|
|
@ -81,4 +81,24 @@ program NpcWayTest {
|
|||
let fs = q_drain(npc_facts(npc_st))
|
||||
for i in 0 .. len(fs) { expect(fs[i].what != NPC_F_STUCK) }
|
||||
}
|
||||
|
||||
test "a crowd walker says where and how fast, is moved by hand to its target, and begins there" (npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState, way_test_st: WayTestState) {
|
||||
fk_setup(npc_st, npc_tests_fake_st)
|
||||
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_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)
|
||||
expect_eq(p.z, 0.0)
|
||||
expect_eq(p.goal_x, 38.0)
|
||||
expect_eq(p.goal_z, -25.0)
|
||||
expect(p.goal_speed > 0.5)
|
||||
expect_eq(way_test_st.asked, 0)
|
||||
for k in 1 .. 101 { npc_moved(p, 0.38 * float(k), -0.25 * float(k), 1.0, -0.66) }
|
||||
npc_tick(npc_st, 0.05)
|
||||
expect_eq(p.act, NPCA_SIT)
|
||||
expect(p.phase > 100.0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue