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:
Orkun ÇAKILKAYA 2026-09-25 06:54:58 +03:00
parent 80f3468ff8
commit c9dc592dcc
28 changed files with 1956 additions and 0 deletions

View file

@ -0,0 +1,108 @@
# fake.ludic - a toy valley for the tests: flat ground at 10 m with a lake west of x = -300 (its
# surface at 10.5), forest north of z = 400, up to two players, and a table of things set out
var fk_px: []float = null
var fk_pz: []float = null
var fk_on: []bool = null
var fk_noise: float = 0.0
var fk_scent: float = 0.0
var fk_still: int = 0
var fk_hidden: bool = false
var fk_blocked: bool = false
var fk_wind: float = 0.0
var fk_wind_dir: float = 0.0
var fk_winter: float = 0.0
var fk_about: int = 0
var fk_born: int = 0
var fk_lures: []WildLure = null
var fk_gone: int = 0 # a uid the port says is no longer there
function fk_setup() -> void {
fk_px = floats(2)
fk_pz = floats(2)
fk_on = new []bool
push(fk_on, true)
push(fk_on, false)
fk_px[0] = 5000.0
fk_pz[0] = 5000.0
fk_lures = new []WildLure
wildlife_clear()
wildlife_species_clear()
fk_species()
}
# 0 deer (meadow, tracks, medium), 1 bear (forest, charges), 2 hare (small), 3 jay (flies)
function fk_species() -> void {
let d = new WildSpecies
d.key = "deer"
d.walk = 1.1
d.run = 7.0
d.flee = 34.0
d.tracks = true
d.size = 1
d.range = 150.0
d.keep_away = 120.0
wildlife_species_add(d)
let b = new WildSpecies
b.key = "bear"
b.habitat = WILD_FOREST
b.charges = true
b.size = 2
b.diet = WILD_FISH
b.forget = 1.6
b.run = 6.0
wildlife_species_add(b)
let h = new WildSpecies
h.key = "hare"
wildlife_species_add(h)
let j = new WildSpecies
j.key = "jay"
j.flies = true
j.walk = 4.0
j.flee = 8.0
j.land_shy = 0.0
j.land_chance = 1.0
wildlife_species_add(j)
}
function fk_ground(x: float, z: float) -> float { return 10.0 }
function fk_water(x: float, z: float) -> float {
if x < -300.0 { return 10.5 }
return 0.0
}
function fk_forest(x: float, z: float) -> bool { return z > 400.0 }
function fk_sight(ax: float, ay: float, az: float, bx: float, by: float, bz: float) -> bool { return not fk_blocked }
function fk_players() -> int { return 2 }
function fk_player_on(p: int) -> bool { return fk_on[p] }
function fk_x(p: int) -> float { return fk_px[p] }
function fk_y(p: int) -> float { return 10.0 }
function fk_z(p: int) -> float { return fk_pz[p] }
function fk_is_hidden(p: int) -> bool { return fk_hidden }
function fk_noise_of(p: int) -> float { return fk_noise }
function fk_scent_of(p: int) -> float { return fk_scent }
function fk_still_of(p: int) -> int { return fk_still }
function fk_wind_of() -> float { return fk_wind }
function fk_wind_to() -> float { return fk_wind_dir }
function fk_winter_of() -> float { return fk_winter }
function fk_about_of(a: WildAnimal) -> int { return fk_about }
function fk_one(sp: int) -> int { return 1 }
function fk_count() -> int { return len(fk_lures) }
function fk_lure(i: int, l: WildLure) -> bool {
let f = fk_lures[i]
l.uid = f.uid
l.kind = f.kind
l.diet = f.diet
l.size = f.size
l.x = f.x
l.z = f.z
l.owner = f.owner
return f.uid != fk_gone
}
function fk_present(uid: int) -> bool { return uid != fk_gone }
function fk_on_born(a: WildAnimal) -> void { fk_born += 1 }
function fk_spot(a: WildAnimal, water: bool, s: WildSpot) -> bool {
s.uid = 900
s.x = a.x + 30.0
s.z = a.z
s.water = water
return true
}