Fish per water type in data/fish.json; worldlets design

- data/fish.json: fish, weights, dawn/dusk odds, bite timing and minimum
  depth per water type; ItemDB.define_water() registers them
- world.water_at(x, z) answers lake / sea / dry land; the float uses it,
  so a worldlet with a sea only needs a "sea" entry
- Clear messages for shallow water and water with nothing to catch
- Lake fish: more of them, bigger, nearer the shore, jumping with splash rings
- docs/WORLDLETS_DESIGN.md: proposal for data-defined world types
This commit is contained in:
Paul Bailey
2026-11-04 11:41:04 +00:00
parent f174221268
commit 4630ea5d44
7 changed files with 294 additions and 19 deletions

View File

@@ -12,9 +12,11 @@ extends Node3D
## A line is drawn from the rod tip each frame (hands.gd gives the tip).
const BITE_WINDOW := 1.5
const MIN_DEPTH := 0.5 ## water this deep under the float, or no fish
const LINE_LENGTH := 26.0
var water_type := "" ## "lake", "sea"... (world.water_at)
var table: Dictionary = {} ## that water's fishing table (ItemDB.water_fishing)
var world: Node3D
var player: Node3D
var state := "flying"
@@ -59,20 +61,34 @@ func _physics_process(delta: float) -> void:
func _process(_delta: float) -> void:
_draw_line()
## How long until the next bite (seconds).
func _next_wait() -> float:
func _dawn_dusk() -> bool:
var h: float = world.day_night.hours()
var k := 1.0
if (h > 5.0 and h < 8.5) or (h > 17.0 and h < 20.5):
k *= 0.6 # fish feed at dawn and dusk
if world.weather.precip > 0.3:
k *= 0.8
return rng.randf_range(5.0, 14.0) * k
return (h > 5.0 and h < 8.5) or (h > 17.0 and h < 20.5)
## How long until the next bite (seconds), from data/fish.json.
func _next_wait() -> float:
var mods: Dictionary = ItemDB.fishing.modifiers
var w: Array = table.get("bite_wait", [5.0, 14.0])
var k := 1.0
if _dawn_dusk():
k *= float(mods.get("dawn_dusk_wait", 0.6)) # fish feed at dawn and dusk
if world.weather.precip > 0.3:
k *= float(mods.get("rain_wait", 0.8))
return rng.randf_range(w[0], w[1]) * k
## A weighted pick from this water's fish (dawn/dusk weights when they apply).
func _pick_fish() -> String:
var h: float = world.day_night.hours()
var trout := 0.4 if (h > 5.0 and h < 8.5) or (h > 17.0 and h < 20.5) else 0.22
return "trout" if rng.randf() < trout else "perch"
var fish: Array = table.get("fish", [])
var key := "dawn_dusk" if _dawn_dusk() else "weight"
var total := 0.0
for f in fish:
total += float(f[key])
var roll := rng.randf() * total
for f in fish:
roll -= float(f[key])
if roll <= 0.0:
return f.id
return fish[-1].id if not fish.is_empty() else ""
func step(dt: float) -> void:
_t += dt
@@ -86,14 +102,24 @@ func step(dt: float) -> void:
velocity.y -= 9.8 * dt
var p := global_position + velocity * dt
var ground: float = terrain.sample_height(p.x, p.z)
if p.y <= terrain.water_level and ground < terrain.water_level - MIN_DEPTH:
p.y = terrain.water_level
state = "floating"
wait_left = _next_wait()
var water: Dictionary = world.water_at(p.x, p.z)
if not water.is_empty() and p.y <= float(water.surface):
p.y = water.surface
water_type = water.type
table = ItemDB.water_fishing(water_type)
if table.is_empty() or table.fish.is_empty():
state = "landed"
Actions.notify.emit("Nothing to catch here")
elif float(water.depth) < float(table.min_depth):
state = "landed"
Actions.notify.emit("Too shallow here: cast further out")
else:
state = "floating"
wait_left = _next_wait()
elif p.y <= ground + 0.03:
p.y = ground + 0.03
state = "landed"
Actions.notify.emit("Cast into the water (deeper than this)" if ground < terrain.water_level else "Cast into the water")
Actions.notify.emit("Cast into the water")
global_position = p
"floating":
wait_left -= dt
@@ -110,7 +136,7 @@ func step(dt: float) -> void:
if bite_left <= 0.0:
state = "floating"
fish = ""
wait_left = _next_wait() * 1.3
wait_left = _next_wait() * float(ItemDB.fishing.modifiers.get("missed_wait", 1.3))
_mesh.position.y = 0.0
Actions.notify.emit("It got away")