ludic.wildlife (17.6): a fleeing or wary animal goes by the world's way

It sets a target straight away from the threat (40 m when it flees, 20 m when it is wary) and heads for it with wl_head, so the way port takes it round water and cliffs. Where the world gives no way, it still runs straight away as before. way_test now has a flee round the wall's end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 22:31:07 +03:00
parent f1153f59a2
commit 61f802e9ad
3 changed files with 40 additions and 2 deletions

View file

@ -103,4 +103,23 @@ program WayTest {
expect_near(a.tx, a.home_x + 7.0, 0.001)
expect_near(a.tz, a.home_z + 3.0, 0.001)
}
test "it runs from the player by the way too: round the wall's end, not into it" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState, way_test_st: WayTestState) {
fk_setup(wildlife_st, wildlife_tests_fake_st)
let a = wildlife_make(wildlife_st, 0, 0.0, 0.0, false, 0.0, 0, 1.0, 1)
wildlife_tests_fake_st.fk_px[0] = 0.0
wildlife_tests_fake_st.fk_pz[0] = 20.0
wildlife_tests_fake_st.fk_hidden = true
a.state = WILD_FLEE
a.timer = 300.0
var east = -100.0
for k in 0 .. 1200 {
wildlife_tick(wildlife_st, 0.05, 0.0)
if a.z > -42.0 and a.z < -38.0 { east = Math.max(east, a.x) }
}
expect_eq(a.state, WILD_FLEE)
expect(east > 29.0)
expect(a.z < -45.0)
expect(way_test_st.asked > 10)
}
}