wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5ffe50ed02
commit
19fcf60599
459 changed files with 17862 additions and 17603 deletions
|
|
@ -1,27 +1,27 @@
|
|||
# react.ludic - alert (it stops and looks: the window the camera wants), wary (it puts ground between
|
||||
# you without running) and fleeing; true when it is doing one of them, which is all it does this tick
|
||||
function wl_react(a: WildAnimal, np: int, dt: float) -> bool {
|
||||
let s = wl_sp(a.sp)
|
||||
function wl_react(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, np: int, dt: float) -> bool {
|
||||
let s = wl_sp(wildlife_st, a.sp)
|
||||
if a.state == WILD_ALERT {
|
||||
a.speed = 0.0
|
||||
wl_face(a, a.sus_x, a.sus_z, 2.2, dt)
|
||||
if a.timer < 0.0 { wl_wander(a, 3.0 + wl_rnd() * 4.0) }
|
||||
if a.timer < 0.0 { wl_wander(wildlife_st, a, 3.0 + wl_rnd(wildlife_st) * 4.0) }
|
||||
return true
|
||||
}
|
||||
if a.state == WILD_WARY {
|
||||
wl_face(a, a.x + (a.x - a.sus_x), a.z + (a.z - a.sus_z), 2.6, dt)
|
||||
a.speed = s.walk * 0.8
|
||||
wl_step(a, dt)
|
||||
if a.timer < 0.0 { wl_wander(a, 3.0 + wl_rnd() * 4.0) }
|
||||
wl_step(base_st, wildlife_st, a, dt)
|
||||
if a.timer < 0.0 { wl_wander(wildlife_st, a, 3.0 + wl_rnd(wildlife_st) * 4.0) }
|
||||
return true
|
||||
}
|
||||
if a.state == WILD_FLEE {
|
||||
wl_face(a, a.x + (a.x - WildlifeWorld.player_x(np)), a.z + (a.z - WildlifeWorld.player_z(np)), 5.0, dt)
|
||||
a.speed = s.run
|
||||
wl_step(a, dt)
|
||||
wl_step(base_st, wildlife_st, a, dt)
|
||||
if a.timer < 0.0 {
|
||||
wl_rehome(a)
|
||||
wl_wander(a, 5.0)
|
||||
wl_rehome(wildlife_st, a)
|
||||
wl_wander(wildlife_st, a, 5.0)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
@ -29,8 +29,8 @@ function wl_react(a: WildAnimal, np: int, dt: float) -> bool {
|
|||
}
|
||||
|
||||
# walking to (or reached) something set out; true while it is
|
||||
function wl_approach(a: WildAnimal, dt: float) -> bool {
|
||||
if (a.state == WILD_IDLE or a.state == WILD_WANDER) and wl_attraction(a) { wl_take_lure(a) }
|
||||
function wl_approach(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bool {
|
||||
if (a.state == WILD_IDLE or a.state == WILD_WANDER) and wl_attraction(wildlife_st, a) { wl_take_lure(wildlife_st, a) }
|
||||
if a.state != WILD_APPROACH { return false }
|
||||
if a.lure == 0 or not WildlifeWorld.present(a.lure) {
|
||||
a.lure = 0
|
||||
|
|
@ -39,20 +39,20 @@ function wl_approach(a: WildAnimal, dt: float) -> bool {
|
|||
return true
|
||||
}
|
||||
wl_face(a, a.lure_x, a.lure_z, 3.0, dt)
|
||||
a.speed = wl_sp(a.sp).walk
|
||||
a.speed = wl_sp(wildlife_st, a.sp).walk
|
||||
let dx = a.lure_x - a.x
|
||||
let dz = a.lure_z - a.z
|
||||
if Math.sqrt(dx * dx + dz * dz) < 1.3 {
|
||||
a.speed = 0.0
|
||||
wl_arrive(a)
|
||||
wl_arrive(base_st, wildlife_st, a)
|
||||
return true
|
||||
}
|
||||
wl_step(a, dt)
|
||||
wl_step(base_st, wildlife_st, a, dt)
|
||||
return true
|
||||
}
|
||||
|
||||
# at a snare it is held; at food it eats for 14 s; at a lure it stands curious for 9
|
||||
function wl_arrive(a: WildAnimal) -> void {
|
||||
function wl_arrive(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal) -> void {
|
||||
a.state = WILD_EAT
|
||||
a.timer = 9.0
|
||||
if a.lure_kind == WILD_FEED { a.timer = 14.0 }
|
||||
|
|
@ -61,19 +61,19 @@ function wl_arrive(a: WildAnimal) -> void {
|
|||
a.x = a.lure_x
|
||||
a.z = a.lure_z
|
||||
a.y = WildlifeWorld.ground(a.x, a.z)
|
||||
let f = wl_fact(WILD_CAUGHT, a)
|
||||
let f = wl_fact(base_st, wildlife_st, WILD_CAUGHT, a)
|
||||
f.lure = a.lure
|
||||
f.owner = a.lure_owner
|
||||
}
|
||||
|
||||
# eating what it came to; when it is done, food is credited and it wanders off
|
||||
function wl_eat(a: WildAnimal) -> bool {
|
||||
function wl_eat(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal) -> bool {
|
||||
if a.state != WILD_EAT { return false }
|
||||
a.speed = 0.0
|
||||
if a.timer < 0.0 {
|
||||
if a.lure != 0 and a.lure_kind == WILD_FEED and WildlifeWorld.present(a.lure) { wl_ate(a, a.lure, a.lure_owner, wl_sp(a.sp).diet) }
|
||||
if a.lure != 0 and a.lure_kind == WILD_FEED and WildlifeWorld.present(a.lure) { wl_ate(base_st, wildlife_st, a, a.lure, a.lure_owner, wl_sp(wildlife_st, a.sp).diet) }
|
||||
a.lure = 0
|
||||
wl_wander(a, 4.0)
|
||||
wl_wander(wildlife_st, a, 4.0)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue