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
56
packages/ludic.wildlife/want.ludic
Normal file
56
packages/ludic.wildlife/want.ludic
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# want.ludic - thirst and hunger over sixty send it to the water or the forage the game offers for
|
||||
# it (a hungry one on its way turns to food put down nearer); it drinks or grazes there
|
||||
var wl_spot_ask: WildSpot = null
|
||||
|
||||
function wl_seek(a: WildAnimal, dt: float) -> bool {
|
||||
if a.state == WILD_GO_FEED and wl_attraction(a) and wl_best.kind == WILD_FEED { wl_take_lure(a) }
|
||||
if a.state != WILD_GO_DRINK and a.state != WILD_GO_FEED { return false }
|
||||
if a.spot == 0 or not WildlifeWorld.present(a.spot) {
|
||||
a.spot = 0
|
||||
a.state = WILD_IDLE
|
||||
a.timer = 2.0
|
||||
return true
|
||||
}
|
||||
wl_face(a, a.spot_x, a.spot_z, 2.0, dt)
|
||||
a.speed = wl_sp(a.sp).walk
|
||||
a.tx = a.spot_x
|
||||
a.tz = a.spot_z
|
||||
wl_step(a, dt)
|
||||
if wl_at_target(a, 2.0) {
|
||||
a.state = WILD_DRINK
|
||||
a.timer = 6.0 + wl_rnd() * 10.0
|
||||
}
|
||||
a.timer = a.timer - dt
|
||||
if a.timer < -600.0 {
|
||||
a.state = WILD_IDLE
|
||||
a.timer = 3.0
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
# true while it drinks or grazes, or when it has just set off
|
||||
function wl_drink(a: WildAnimal, dt: float, gh: float) -> bool {
|
||||
if a.state == WILD_DRINK {
|
||||
a.speed = 0.0
|
||||
a.timer = a.timer - dt
|
||||
if a.spot != 0 and a.spot_water { a.thirst = Math.max(a.thirst - 600.0 * gh, 0.0) } else { a.hunger = Math.max(a.hunger - 600.0 * gh, 0.0) }
|
||||
if a.timer < 0.0 or Math.min(a.thirst, a.hunger) < 1.0 {
|
||||
wl_rehome(a)
|
||||
wl_wander(a, 6.0)
|
||||
}
|
||||
return true
|
||||
}
|
||||
if a.state != WILD_IDLE and a.state != WILD_WANDER { return false }
|
||||
if not (a.thirst > 60.0 or a.hunger > 60.0) { return false }
|
||||
if wl_spot_ask == null { wl_spot_ask = new WildSpot }
|
||||
let water = a.thirst > a.hunger
|
||||
if not WildlifeWorld.spot(a, water, wl_spot_ask) { return false }
|
||||
a.spot = wl_spot_ask.uid
|
||||
a.spot_x = wl_spot_ask.x
|
||||
a.spot_z = wl_spot_ask.z
|
||||
a.spot_water = wl_spot_ask.water
|
||||
a.state = WILD_GO_DRINK
|
||||
if not water { a.state = WILD_GO_FEED }
|
||||
a.timer = 120.0
|
||||
return true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue