Wild flax: fibre plants in meadows and by the lake (2 fibre each)

This commit is contained in:
Paul Bailey
2026-11-04 18:12:56 +00:00
parent 0c18b6d49e
commit 80786ab796
3 changed files with 32 additions and 3 deletions

View File

@@ -19,6 +19,8 @@ const ASH := Color(0.18, 0.17, 0.16)
const BINDING := Color(0.75, 0.68, 0.48)
const FIBER := Color(0.45, 0.55, 0.22)
const FIBER_PLANT := Color(0.68, 0.70, 0.36) ## paler than the grass, so it shows
const FIBER_SEED := Color(0.80, 0.68, 0.40)
const BERRY := Color(0.62, 0.08, 0.16)
const MUSH_CAP := Color(0.72, 0.30, 0.18)
const MUSH_ROAST := Color(0.40, 0.24, 0.12)
@@ -73,6 +75,7 @@ static func build(key: String) -> ArrayMesh:
"trout": m = _fish(TROUT, 0.24, false)
"grilled_perch": m = _fish(PERCH, 0.16, true)
"grilled_trout": m = _fish(TROUT, 0.24, true)
"fiber_plant": m = _fiber_plant()
"berry_bush": m = _berry_bush(true)
"berry_bush_bare": m = _berry_bush(false)
_:
@@ -209,6 +212,22 @@ static func _fiber() -> ArrayMesh:
_box(st, Vector3(0, 0.03, 0), Vector3(0.05, 0.05, 0.08), CLOTH)
return P._commit(st)
## A wild flax clump you pick for fibre: tall pale stalks fanning out of the
## grass, each with a seed head, so it stands out above the meadow.
static func _fiber_plant() -> ArrayMesh:
var st := P._begin()
var r := _rng(53)
for i in range(20):
var a := TAU * i / 20.0 + r.randf_range(-0.2, 0.2)
var lean := r.randf_range(0.12, 0.4)
var h := r.randf_range(1.0, 1.45)
var base := Vector3(cos(a), 0, sin(a)) * r.randf_range(0.03, 0.12)
var top := base + Vector3(cos(a) * lean, h, sin(a) * lean)
var col := P._mul(FIBER_PLANT, r.randf_range(0.85, 1.15))
P._cylinder(st, base, top, 0.022, 0.009, 4, col, r)
P._cylinder(st, top, top + (top - base).normalized() * 0.14, 0.032, 0.006, 4, P._mul(FIBER_SEED, r.randf_range(0.9, 1.1)), r)
return P._commit(st)
static func _berries() -> ArrayMesh:
var st := P._begin()
var r := _rng(43)

View File

@@ -25,6 +25,8 @@ func setup(id: String, mesh: Mesh, material: Material, radius: float) -> void:
add_child(cs)
func interact_prompt(_player: Node) -> String:
if item_id == "fiber" and not dropped:
return "Wild flax [E] Pick %d %s" % [amount, ItemDB.item_name(item_id).to_lower()]
return "[E] Pick up %s%s" % [ItemDB.item_name(item_id), " x%d" % amount if amount > 1 else ""]
func interact(player: Node) -> void:

View File

@@ -14,6 +14,7 @@ const ProcMesh = preload("res://scripts/world/proc_mesh.gd")
const ResourceNodeScript = preload("res://scripts/world/resource_node.gd")
const PickupScript = preload("res://scripts/world/pickup.gd")
const ForageScript = preload("res://scripts/world/forage.gd")
const ItemMeshes = preload("res://scripts/items/item_meshes.gd")
const CELL := 48.0
const GRASS_TILE := 12.0
@@ -590,10 +591,11 @@ func _scatter_pickups() -> void:
var rng := RandomNumberGenerator.new()
rng.seed = world_seed + 6
# Order matters: new kinds go at the END so existing saves keep their ids.
var want := {"stick": 260, "stone": 170, "flint": 80, "mushroom": 110, "feather": 70}
var radius: Dictionary = {"stick": 0.35, "stone": 0.25, "flint": 0.25, "mushroom": 0.25, "feather": 0.25}
var want := {"stick": 260, "stone": 170, "flint": 80, "mushroom": 110, "feather": 70, "fiber": 150}
var radius: Dictionary = {"stick": 0.35, "stone": 0.25, "flint": 0.25, "mushroom": 0.25, "feather": 0.25, "fiber": 0.45}
for id: String in want:
var mesh := ItemDB.mesh_for(id)
# Fibre grows as a plant (wild flax) you pick, 2 fibre a clump.
var mesh: Mesh = ItemMeshes.build("fiber_plant") if id == "fiber" else ItemDB.mesh_for(id)
var placed := 0
var tries := 0
while placed < want[id] and tries < 20000:
@@ -619,6 +621,10 @@ func _scatter_pickups() -> void:
chance = _forest(x, z) * 0.7 # deep forest only
"feather":
chance = 0.1 + (1.0 - _forest(x, z)) * 0.5 # open meadows
"fiber":
# Meadows, and thickest along the lake shore.
var wet := 1.0 - smoothstep(terrain.water_level + 0.5, terrain.water_level + 3.0, h)
chance = 0.05 + (1.0 - _forest(x, z)) * 0.45 + wet * 0.6
# A few right by the spawn so the first craft is quick.
if Vector2(x - _spawn.x, z - _spawn.z).length() < 18.0:
chance += 0.5
@@ -626,6 +632,8 @@ func _scatter_pickups() -> void:
continue
var pk: Area3D = PickupScript.new()
pk.setup(id, mesh, ItemDB.item_material(), radius[id])
if id == "fiber":
pk.amount = 2
pk.uid = "p%d" % pickups.size()
pickups[pk.uid] = pk
pk.taken_now.connect(_on_taken)