- 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>
86 lines
3.9 KiB
Text
86 lines
3.9 KiB
Text
# fake - a place for the people: dry flat ground east of x = -50 and a lake west of it, a camp at
|
|
# (40, 0) nobody may stop in, two players, and what the port was asked to draw
|
|
numbers float
|
|
export state NpcTestsFakeState {
|
|
fk_hour: float = 12.0
|
|
fk_day: int = 1
|
|
fk_want: int = 0
|
|
fk_extra: int = -1
|
|
fk_px: []float = null
|
|
fk_pz: []float = null
|
|
fk_on: []bool = null
|
|
fk_born: int = 0
|
|
fk_gone: int = 0
|
|
fk_trunk: bool = false # a trunk 1 m round at (10, 0.3)
|
|
fk_out_x: float = 0.0
|
|
fk_out_z: float = 0.0
|
|
}
|
|
|
|
function fk_setup(npc_st: mut NpcState, npc_tests_fake_st: mut NpcTestsFakeState) -> void {
|
|
npc_tests_fake_st.fk_hour = 12.0
|
|
npc_tests_fake_st.fk_day = 1
|
|
npc_tests_fake_st.fk_want = 0
|
|
npc_tests_fake_st.fk_extra = -1
|
|
npc_tests_fake_st.fk_px = [500.0, 900.0]
|
|
npc_tests_fake_st.fk_pz = [500.0, 900.0]
|
|
npc_tests_fake_st.fk_on = [true, false]
|
|
npc_tests_fake_st.fk_born = 0
|
|
npc_tests_fake_st.fk_gone = 0
|
|
npc_tests_fake_st.fk_trunk = false
|
|
npc_clear(npc_st)
|
|
npc_reset(npc_st)
|
|
npc_seed(npc_st, 7)
|
|
npc_config(npc_st, 10)
|
|
}
|
|
|
|
function fk_ground(x: float, z: float) -> float { return 0.0 }
|
|
function fk_water(x: float, z: float) -> float {
|
|
if x < -50.0 { return 1.0 }
|
|
return -100.0
|
|
}
|
|
function fk_allowed(x: float, z: float) -> bool { return npc_d(x, z, 40.0, 0.0) > 15.0 }
|
|
function fk_hour_now(npc_tests_fake_st: NpcTestsFakeState) -> float { return npc_tests_fake_st.fk_hour }
|
|
function fk_day_now(npc_tests_fake_st: NpcTestsFakeState) -> int { return npc_tests_fake_st.fk_day }
|
|
function fk_players() -> int { return 2 }
|
|
function fk_player_on(npc_tests_fake_st: NpcTestsFakeState, i: int) -> bool { return npc_tests_fake_st.fk_on[i] }
|
|
function fk_x(npc_tests_fake_st: NpcTestsFakeState, i: int) -> float { return npc_tests_fake_st.fk_px[i] }
|
|
function fk_z(npc_tests_fake_st: NpcTestsFakeState, i: int) -> float { return npc_tests_fake_st.fk_pz[i] }
|
|
function fk_wanted(npc_tests_fake_st: NpcTestsFakeState) -> int { return npc_tests_fake_st.fk_want }
|
|
function fk_extra_kind(npc_tests_fake_st: NpcTestsFakeState) -> int { return npc_tests_fake_st.fk_extra }
|
|
function fk_taken(n: string) -> bool { return n == "Ada" }
|
|
function fk_on_born(npc_tests_fake_st: mut NpcTestsFakeState, p: NpcPerson) -> void { npc_tests_fake_st.fk_born += 1 }
|
|
function fk_on_gone(npc_tests_fake_st: mut NpcTestsFakeState, p: NpcPerson) -> void { npc_tests_fake_st.fk_gone += 1 }
|
|
|
|
function fk_player_at(npc_tests_fake_st: mut NpcTestsFakeState, x: float, z: float) -> void {
|
|
npc_tests_fake_st.fk_px[0] = x
|
|
npc_tests_fake_st.fk_pz[0] = z
|
|
}
|
|
|
|
# seconds of the place, in twentieths
|
|
function fk_run(npc_st: mut NpcState, secs: float) -> void { for k in 0 .. int(secs * 20.0) { npc_tick(npc_st, 0.05) } }
|
|
|
|
function fk_count(npc_st: mut NpcState, what: int) -> int {
|
|
let fs = q_drain(npc_facts(npc_st))
|
|
var n = 0
|
|
for i in 0 .. len(fs) { if fs[i].what == what { n += 1 } }
|
|
return n
|
|
}
|
|
|
|
# the trunk, when it stands: a body inside it is pushed straight out from its axis, and a line
|
|
# passing within its radius is not clear
|
|
function fk_push(npc_tests_fake_st: mut NpcTestsFakeState, x: float, z: float, r: float, y0: float, y1: float) -> bool {
|
|
let d = npc_d(x, z, 10.0, 0.3)
|
|
if not npc_tests_fake_st.fk_trunk or d > 1.0 + r or d < 0.0001 { return false }
|
|
npc_tests_fake_st.fk_out_x = 10.0 + (x - 10.0) / d * (1.0 + r)
|
|
npc_tests_fake_st.fk_out_z = 0.3 + (z - 0.3) / d * (1.0 + r)
|
|
return true
|
|
}
|
|
function fk_pushed_x(npc_tests_fake_st: NpcTestsFakeState) -> float { return npc_tests_fake_st.fk_out_x }
|
|
function fk_pushed_z(npc_tests_fake_st: NpcTestsFakeState) -> float { return npc_tests_fake_st.fk_out_z }
|
|
function fk_clear(npc_tests_fake_st: NpcTestsFakeState, ax: float, ay: float, az: float, bx: float, by: float, bz: float) -> bool {
|
|
if not npc_tests_fake_st.fk_trunk { return true }
|
|
let lx = bx - ax
|
|
let lz = bz - az
|
|
let t = Math.clamp(((10.0 - ax) * lx + (0.3 - az) * lz) / Math.max(lx * lx + lz * lz, 0.0001), 0.0, 1.0)
|
|
return npc_d(ax + lx * t, az + lz * t, 10.0, 0.3) > 1.0
|
|
}
|