M2.6: server rules (PvP, raiding, locks and friends, death penalty, difficulty, wolf grace), chat, admin commands, server console

This commit is contained in:
Paul Bailey
2026-11-04 22:54:40 +00:00
parent 47fc116839
commit 2ab79b68c6
26 changed files with 1195 additions and 57 deletions

View File

@@ -67,14 +67,22 @@ func is_night() -> bool:
var h: float = world.day_night.hours()
return h >= 19.5 or h < 5.5
static func pack_size(day: int) -> int:
if day < DEN_DAY:
## The pack grows 3 and 6 days after it arrives (2, 3, then 4 wolves), plus
## or minus one for a server's difficulty.
func pack_size(day: int) -> int:
if day < den_day:
return 0
if day < 6:
return 2
if day < 9:
return 3
return 4
var n := 4
if day < den_day + 3:
n = 2
elif day < den_day + 6:
n = 3
return clampi(n + pack_bonus, 1, 5)
## The schedule (a server sets it from its rules; single-player keeps 3/4).
var den_day := DEN_DAY
var hunt_day := HUNT_DAY
var pack_bonus := 0
func alive() -> Array:
var out := []
@@ -95,8 +103,8 @@ func step(dt: float) -> void:
var day := effective_day()
var night := is_night()
var want := "none"
if day >= DEN_DAY:
want = "hunt" if night and day >= HUNT_DAY else "den"
if day >= den_day:
want = "hunt" if night and day >= hunt_day else "den"
if want != mode:
_enter(want, day)
if mode == "none":
@@ -123,7 +131,7 @@ func step(dt: float) -> void:
m.global_position = den.slot_pos(m.slot)
m.wounded = false
m.state = "rest"
if night and day >= DEN_DAY:
if night and day >= den_day:
_howl_left -= dt
if _howl_left <= 0.0:
_howl_left = _rng.randf_range(50.0, 110.0)
@@ -148,9 +156,9 @@ func _warn(day: int) -> void:
if _warned.has(day):
return
_warned[day] = true
if day == DEN_DAY:
if day == den_day:
Actions.tell_all("Wolves are howling up in the hills. They'll come hunting soon.")
elif day == HUNT_DAY:
elif day == hunt_day:
Actions.tell_all("The wolves are hunting tonight. Stay near a fire or behind closed walls.")
_howl_left = _rng.randf_range(2.0, 6.0)