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
|
|
@ -14,7 +14,7 @@ export function npc_walk(npc_st: mut NpcState, p: NpcPerson, dt: float) -> void
|
|||
np_arrive(npc_st, p)
|
||||
return
|
||||
}
|
||||
if not p.via_on {
|
||||
if not p.via_on and not p.crowd {
|
||||
np_way(p, dt)
|
||||
gx = p.wx
|
||||
gz = p.wz
|
||||
|
|
@ -33,6 +33,10 @@ export function npc_walk(npc_st: mut NpcState, p: NpcPerson, dt: float) -> void
|
|||
var sp = p.speed
|
||||
if sp < 0.1 { sp = 1.2 }
|
||||
if p.stalk { sp = Math.min(sp, 0.7) }
|
||||
if p.crowd {
|
||||
np_crowd_want(p, sp)
|
||||
return
|
||||
}
|
||||
let want = Math.atan2(-dx, -dz)
|
||||
let r = 3.0 * dt
|
||||
p.yaw = p.yaw + Math.clamp(npc_wrap(want - p.yaw), -r, r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue