- Rabbits, deer and boars with procedural meshes and animated legs, a state machine (idle/wander/flee/charge/dead) and heightmap steering that avoids water, cliffs, the world edge, trees and buildings - Spawner keeps a habitat-based budget around the player (6/4/3) - Melee needs a weapon or tool (club, spear, axe, pickaxe); box sweep hits - Wooden spear (thrust or throw) and crude bow with draw-scaled arrows; projectiles stick in the world as saved pickups - Carcasses: E to butcher for meat, hide and embedded arrows - Boars charge and gore when hit; hurt flash and a brief healing pause - Cooked meat gives Well fed (faster stamina and healing); buffs saved - Hide cloak: wear for warmth, saved, goes in the grave on death - Feathers as meadow pickups (appended, existing save ids unchanged) - New test_creatures_combat suite; run_all.sh gets a per-suite time limit
54 lines
1.4 KiB
GDScript
54 lines
1.4 KiB
GDScript
extends Area3D
|
|
## An item lying on the ground (stick, stone, flint). Look at it and press E.
|
|
## Lives on collision layer 2, so the player walks through it but the
|
|
## interaction ray still finds it.
|
|
|
|
var item_id := "stick"
|
|
var amount := 1
|
|
var uid := "" ## stable id for saves (see props.gd)
|
|
var taken := false
|
|
|
|
func setup(id: String, mesh: Mesh, material: Material, radius: float) -> void:
|
|
item_id = id
|
|
collision_layer = 2
|
|
collision_mask = 0
|
|
monitoring = false
|
|
var mi := MeshInstance3D.new()
|
|
mi.mesh = mesh
|
|
mi.material_override = material
|
|
add_child(mi)
|
|
var cs := CollisionShape3D.new()
|
|
var sph := SphereShape3D.new()
|
|
sph.radius = radius
|
|
cs.shape = sph
|
|
cs.position = Vector3(0, radius * 0.5, 0)
|
|
add_child(cs)
|
|
|
|
func interact_prompt(_player: Node) -> String:
|
|
return "[E] Pick up %s%s" % [ItemDB.item_name(item_id), " x%d" % amount if amount > 1 else ""]
|
|
|
|
func interact(player: Node) -> void:
|
|
Actions.pickup(player, self)
|
|
|
|
signal taken_now(pickup: Node)
|
|
|
|
var dropped := false ## dropped by the player (arrows, spears): saved, never regrows
|
|
|
|
## Picked up: hidden (not freed) so it can reappear later (props.gd regrowth).
|
|
## Dropped items just go.
|
|
func collected() -> void:
|
|
if taken:
|
|
return
|
|
taken = true
|
|
if dropped:
|
|
queue_free()
|
|
return
|
|
visible = false
|
|
collision_layer = 0
|
|
taken_now.emit(self)
|
|
|
|
func regrow() -> void:
|
|
taken = false
|
|
visible = true
|
|
collision_layer = 2
|