feat(packages): ludic.wildlife - a valley's animals: species handed in as data, ranges placed against the ground and moved with the season, the day's steering, the senses and a net alert that settles, feeding, lures and snares, birds, spawning and repopulation, its own dice, facts and a save section
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
80f3468ff8
commit
c9dc592dcc
28 changed files with 1956 additions and 0 deletions
58
packages/ludic.wildlife/run.ludic
Normal file
58
packages/ludic.wildlife/run.ludic
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# run.ludic - one step of every animal: the port says whether it is about at this hour; anything
|
||||
# within 900 m of a player thinks; the gait follows the ground covered; player 0 sees what is near
|
||||
export function wildlife_tick(dt: float, gh: float) -> void {
|
||||
wl_seed_scan(dt)
|
||||
let all = wildlife_all()
|
||||
for i in 0 .. len(all) { wl_tick_one(all[i], dt, gh) }
|
||||
}
|
||||
|
||||
function wl_tick_one(a: WildAnimal, dt: float, gh: float) -> void {
|
||||
if not a.alive { return }
|
||||
let about = WildlifeWorld.about(a)
|
||||
if about == WILD_AWAY {
|
||||
a.shown = false
|
||||
return
|
||||
}
|
||||
if about == WILD_GONE {
|
||||
wildlife_remove(a)
|
||||
wl_fact(WILD_WENT, a)
|
||||
return
|
||||
}
|
||||
a.shown = true
|
||||
let dh = wl_near(a.x, a.z)
|
||||
if dh > 900.0 { return }
|
||||
let s = wl_sp(a.sp)
|
||||
if wl_hold { }
|
||||
else if a.pinned { a.speed = 0.0 }
|
||||
else if s.flies { wildlife_tick_bird(a, dt) } else { wildlife_tick_ground(a, dt, gh) }
|
||||
var stride = 1.2 * a.scale
|
||||
if s.flies { stride = 0.6 }
|
||||
a.phase = (a.phase + a.speed * dt / stride * WL_TAU) % WL_TAU
|
||||
if WildlifeWorld.player_on(0) and wl_pdist(0, a) < 60.0 and wildlife_saw(a.sp) { wl_fact(WILD_SPOTTED, a) }
|
||||
}
|
||||
|
||||
# the gait advanced by a copy the game moves itself (a guest's copy of the host's animal)
|
||||
export function wildlife_stride(a: WildAnimal, dt: float) -> void {
|
||||
var stride = 1.2 * a.scale
|
||||
if wl_sp(a.sp).flies { stride = 0.6 }
|
||||
a.phase = (a.phase + a.speed * dt / stride * WL_TAU) % WL_TAU
|
||||
}
|
||||
|
||||
# a snare's catch let go: it bolts, and it holds nothing against anyone
|
||||
export function wildlife_release(a: WildAnimal) -> void {
|
||||
if a == null { return }
|
||||
a.state = WILD_FLEE
|
||||
a.timer = 4.0
|
||||
a.calm = 0.0
|
||||
a.lure = 0
|
||||
}
|
||||
|
||||
# the animal a snare holds, by the snare's uid
|
||||
export function wildlife_in_snare(uid: int) -> WildAnimal {
|
||||
let all = wildlife_all()
|
||||
for i in 0 .. len(all) {
|
||||
let a = all[i]
|
||||
if a.alive and a.state == WILD_TRAPPED and a.lure == uid { return a }
|
||||
}
|
||||
return null
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue