feat(senses): walkers slide round still things, and lines of sight are the world's to answer

- ludic.wildlife: WildlifeWorld.push / pushed_x / pushed_z (defaults change nothing); a ground
  walker's step is slid clear of a still thing with a body from its species' size and scale, and
  a step that gets nowhere turns away as the water does. Birds are not pushed; no dice added.
- ludic.npc: NpcWorld.push / pushed_x / pushed_z (a person 0.35 m round) in npc_walk, and
  NpcWorld.clear (default true), which npc_line_ok asks at 1 m so a detour does not cut a trunk.
- ludic.aim: AimView.clear replaces AimView.ground and the ground march; the pick asks the line
  a body's width short of where the ray enters the thing (aim_clear_at(t, back)), so a solid
  thing does not hide itself. probe.ludic (the ground-agreement probe) and AimView.dry are gone.
- ludic.photo: PhotoLens.clear replaces PhotoLens.ground, PhotoLens.trunk and the march.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 00:59:39 +03:00
parent d2cd775309
commit 56e4b6d688
24 changed files with 230 additions and 152 deletions

View file

@ -13,14 +13,20 @@ function wl_face(a: WildAnimal, tx: float, tz: float, rate: float, dt: float) ->
a.yaw = a.yaw + Math.clamp(wl_wrap(want - a.yaw), -r, r)
}
# true when it moved
# true when it moved; a walker is slid round a still thing (a trunk, a tent), a bird is not
function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bool {
let d = a.speed * dt
if d < 0.0001 { return false }
let nx = a.x - Math.sin(a.yaw) * d
let nz = a.z - Math.cos(a.yaw) * d
var nx = a.x - Math.sin(a.yaw) * d
var nz = a.z - Math.cos(a.yaw) * d
let s = wl_sp(wildlife_st, a.sp)
if not s.flies and wl_push(wildlife_st, a, s, nx, nz) {
nx = wildlife_st.wl_out_x
nz = wildlife_st.wl_out_z
}
let nh = WildlifeWorld.ground(nx, nz)
if nh < WildlifeWorld.water(nx, nz) + 0.6 or nh - a.y > d * 1.2 {
let moved = Math.abs(nx - a.x) + Math.abs(nz - a.z)
if nh < WildlifeWorld.water(nx, nz) + 0.6 or nh - a.y > d * 1.2 or moved < d * 0.2 {
a.yaw = a.yaw + Math.deg_to_rad(75.0)
a.timer = 0.0
return false
@ -29,13 +35,29 @@ function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bo
a.z = nz
a.y = nh
a.track_d = a.track_d + d
if wl_sp(wildlife_st, a.sp).tracks and a.track_d > 2.8 {
if s.tracks and a.track_d > 2.8 {
a.track_d = 0.0
wl_fact(wildlife_st, WILD_PRINT, a)
}
return true
}
# (x, z) pushed clear of every still thing for a body its size; wl_out_x / _z say where
function wl_push(wildlife_st: mut WildlifeState, a: WildAnimal, s: WildSpecies, x: float, z: float) -> bool {
wildlife_st.wl_ask_x = x
wildlife_st.wl_ask_z = z
let k = Math.clamp(float(s.size), 0.0, 2.0)
let r = (0.2 + 0.2 * k) * s.scale * a.scale
let hit = WildlifeWorld.push(x, z, r, a.y + 0.1, a.y + (0.5 + 0.7 * k) * s.scale * a.scale)
wildlife_st.wl_out_x = x
wildlife_st.wl_out_z = z
if hit {
wildlife_st.wl_out_x = WildlifeWorld.pushed_x()
wildlife_st.wl_out_z = WildlifeWorld.pushed_z()
}
return hit
}
function wl_pick_target(wildlife_st: mut WildlifeState, a: WildAnimal, radius: float) -> void {
let ang = wl_rnd(wildlife_st) * WL_TAU
let d = wl_rnd(wildlife_st) * radius