The pirate treasure: each player's own mound at their X, dug with a pickaxe; the drowned crew rise at night or when the chest comes up; the ship's compass, a spyglass, a cutlass and pirate gold; online too
This commit is contained in:
47
scripts/world/crew_site.gd
Normal file
47
scripts/world/crew_site.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends Node3D
|
||||
## Where a band of the drowned crew rose (treasure.gd): what their guard
|
||||
## brains (guard.gd) ask of their "barrow". They're up and angry from the
|
||||
## start, chase whoever's nearest within LEASH of the dig, and go back to
|
||||
## stand round it when nobody is. By day, once nobody's been near for a
|
||||
## while, they sink back into the ground.
|
||||
|
||||
const LEASH := 20.0
|
||||
const SINK_AFTER := 30.0 ## seconds with nobody near, by day
|
||||
|
||||
var world: Node3D
|
||||
var spot := Vector3.ZERO
|
||||
var alarmed := true
|
||||
var crew: Array = []
|
||||
var _alone := 0.0
|
||||
|
||||
func center() -> Vector3:
|
||||
return spot
|
||||
|
||||
func wakes_for(p: Node3D) -> bool:
|
||||
return alarmed and not p.survival.dead
|
||||
|
||||
func alarm() -> void:
|
||||
alarmed = true
|
||||
|
||||
## (Out in the open: they walk on the ground.)
|
||||
func floor_y_at(_p: Vector3) -> float:
|
||||
return -INF
|
||||
|
||||
func is_night() -> bool:
|
||||
var h: float = world.day_night.hours()
|
||||
return h >= 19.5 or h < 5.5
|
||||
|
||||
func alive() -> Array:
|
||||
return crew.filter(func(g): return is_instance_valid(g) and not g.is_dead())
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var anyone := false
|
||||
for p in world.players():
|
||||
if not p.survival.dead and p.global_position.distance_to(spot) < LEASH:
|
||||
anyone = true
|
||||
_alone = 0.0 if anyone or is_night() else _alone + delta
|
||||
if alive().is_empty() or _alone > SINK_AFTER:
|
||||
for g in crew:
|
||||
if is_instance_valid(g) and not g.is_dead():
|
||||
g.queue_free()
|
||||
queue_free()
|
||||
Reference in New Issue
Block a user