P3 thieves and barrow: crows and foxes steal food left out; the barrow with its guards, coffin loot and key pieces; blunt club vs bone (protocol 10)

This commit is contained in:
Paul Bailey
2026-11-05 09:23:31 +00:00
parent 96aac29606
commit 9528f91e47
20 changed files with 1695 additions and 21 deletions

View File

@@ -64,6 +64,8 @@ var den: Node3D ## den.gd: the wolves' cave at the foot of the r
var bobber: Node3D ## bobber.gd: the cast fishing float, if any
var wolves: Node3D ## wolf_pack.gd (null if this seed has no den site)
var bears: Node3D ## bear_range.gd: the island's bear (null online as a client)
var thieves: Node3D ## thieves.gd: crows and foxes after food left out
var barrow: Node3D ## barrow.gd: the burial mound and its guards (scenery; guards where creatures run)
var _saved_bear: Dictionary = {} ## its saved state, kept until bears exists (and re-saved if it never does)
var net_sync: Node ## net_sync.gd when playing on a server, else null
var has_bed_spawn := false
@@ -340,6 +342,13 @@ func _on_terrain_ready() -> void:
if den.place(self, props._rock_mat):
props.static_cuts.append([den.global_transform, 2.2, 3.4])
_update_grass_cuts()
# The barrow: scenery too (P3), out on open ground. Its guards only run
# where creatures do (_setup_bear).
barrow = preload("res://scripts/world/barrow.gd").new()
barrow.name = "Barrow"
add_child(barrow)
if barrow.place(self):
_update_grass_cuts()
if DisplayServer.get_name() != "headless":
var fish := preload("res://scripts/fishing/lake_fish.gd").new()
fish.name = "LakeFish"
@@ -392,9 +401,17 @@ func _on_terrain_ready() -> void:
_setup_bear()
_maybe_capture()
## The island's bear and its patch (bear_range.gd). The server runs it for
## everyone; players' games see it through creature_net.gd.
## The island's bear and its patch (bear_range.gd), and the crows and foxes
## after food left out (thieves.gd). The server runs them for everyone;
## players' games see them through creature_net.gd.
func _setup_bear() -> void:
thieves = preload("res://scripts/creatures/thieves.gd").new()
thieves.name = "Thieves"
add_child(thieves)
thieves.setup(self)
thieves.enabled = not "--no-creatures" in OS.get_cmdline_user_args()
if barrow != null and barrow.found and thieves.enabled:
barrow.start()
bears = preload("res://scripts/creatures/bear_range.gd").new()
bears.name = "Bear"
add_child(bears)
@@ -526,6 +543,7 @@ func collect_save() -> Dictionary:
"pickups_taken": taken,
"pieces": pieces,
"bear": bears.save_data() if bears != null else _saved_bear,
"barrow": barrow.save_data() if barrow != null else {},
}
func _shared_state(harvested: Dictionary, regrow: Dictionary, taken: Array, dropped: Array, pieces: Array) -> Dictionary:
@@ -538,6 +556,7 @@ func _shared_state(harvested: Dictionary, regrow: Dictionary, taken: Array, drop
"pickups_taken": taken,
"pieces": pieces,
"bear": bears.save_data() if bears != null else _saved_bear,
"barrow": barrow.save_data() if barrow != null else {},
}
## The live pieces (placed and not being removed).
@@ -664,6 +683,8 @@ func _apply_save(s: Dictionary, with_player: bool) -> void:
props.pickups[uid].collected()
# Regrowth timers (older saves have none: everything gone starts a fresh timer).
props.restore_regrow(s.get("regrow", {}))
if barrow != null:
barrow.load_data(s.get("barrow", {}))
# The bear (bear_range.gd): applied when it's set up, after loading.
_saved_bear = s.get("bear", {})
if bears != null:
@@ -816,6 +837,13 @@ func drop_item(id: String, count: int, xf: Transform3D, extra: Dictionary = {})
return null
return _make_dropped(id, count, xf, extra)
## Something other than a player took a dropped item (the bear ate it, a fox
## ran off with it). On a server, everyone's game is told it's gone.
func take_dropped(pk: Node3D) -> void:
if server_mode and pk.has_meta("nid"):
WorldNet.taken("#%d" % int(pk.get_meta("nid")))
pk.collected()
func _make_dropped(id: String, count: int, xf: Transform3D, extra: Dictionary = {}) -> Node3D:
var pk: Area3D = preload("res://scripts/world/pickup.gd").new()
pk.setup(id, ItemDB.mesh_for(id), ItemDB.item_material(), 0.3)