M2.6: server rules (PvP, raiding, locks and friends, death penalty, difficulty, wolf grace), chat, admin commands, server console
This commit is contained in:
@@ -164,6 +164,11 @@ func _physics_process(delta: float) -> void:
|
||||
var p: String = t.interact_prompt(player)
|
||||
if t.is_in_group("piece") and t.item_id != "grave":
|
||||
p += " [X] Dismantle"
|
||||
# Online: someone else's piece says whose it is (the server decides
|
||||
# whether you may use it, by its rules).
|
||||
var owner := String(t.get_meta("owner", ""))
|
||||
if not owner.is_empty() and Net.state == "connected" and owner != Net.get_identity().player_id:
|
||||
p = "%s's · %s" % [String(t.get_meta("owner_name", "someone")), p]
|
||||
_set_prompt(p)
|
||||
elif def.has("food"):
|
||||
_set_prompt("[RMB] Eat %s" % def.name)
|
||||
@@ -346,6 +351,9 @@ func _apply_hit() -> void:
|
||||
# Animals first: a short box sweep in front of the camera, so you don't
|
||||
# need pixel-perfect aim at a running rabbit.
|
||||
var animal := melee_target()
|
||||
if animal != null and animal.has_meta("avatar_peer"):
|
||||
Actions.hit_player(player, int(animal.get_meta("avatar_peer")))
|
||||
return
|
||||
if animal != null:
|
||||
Actions.melee(player, animal)
|
||||
return
|
||||
@@ -366,12 +374,14 @@ func melee_target() -> Node3D:
|
||||
var q := PhysicsShapeQueryParameters3D.new()
|
||||
q.shape = box
|
||||
q.transform = Transform3D(cam.global_basis, cam.global_position - cam.global_basis.z * reach * 0.5 - cam.global_basis.y * 0.5)
|
||||
q.collision_mask = 8
|
||||
# Online with PvP on, other players' avatars too (their hitbox, layer 16).
|
||||
var pvp: bool = Net.state == "connected" and bool(Net.server_info.get("pvp", false))
|
||||
q.collision_mask = 8 | (16 if pvp else 0)
|
||||
var best: Node3D = null
|
||||
var best_d := INF
|
||||
for h in cam.get_world_3d().direct_space_state.intersect_shape(q, 8):
|
||||
var c: Node3D = h.collider
|
||||
if c.is_in_group("creature"):
|
||||
if c.is_in_group("creature") or c.has_meta("avatar_peer"):
|
||||
var d := c.global_position.distance_to(cam.global_position)
|
||||
if d < best_d:
|
||||
best_d = d
|
||||
|
||||
@@ -39,6 +39,7 @@ var _rest_build := 0.0
|
||||
var buffs: Dictionary = {}
|
||||
var _hurt_cd := 0.0 ## no natural healing for a few seconds after a hit
|
||||
var cause := "" ## what last hurt you, as the death screen says it ("You froze")
|
||||
var drain_mult := 1.0 ## hunger and diet drain (a server's difficulty, rules.gd)
|
||||
|
||||
signal hurt(amount: float, from: Vector3)
|
||||
const HURT_NO_REGEN := 6.0
|
||||
@@ -111,7 +112,7 @@ func step(dt: float) -> void:
|
||||
# Warm up faster than you cool down: getting to a fire should feel good.
|
||||
warmth = move_toward(warmth, target, (7.0 if target > warmth else 1.6) * dt)
|
||||
|
||||
hunger = maxf(hunger - HUNGER_DRAIN * dt * (1.5 if warmth < 30.0 else 1.0), 0.0)
|
||||
hunger = maxf(hunger - HUNGER_DRAIN * drain_mult * dt * (1.5 if warmth < 30.0 else 1.0), 0.0)
|
||||
|
||||
if _stamina_wait > 0.0:
|
||||
_stamina_wait -= dt
|
||||
@@ -121,7 +122,7 @@ func step(dt: float) -> void:
|
||||
* (0.7 if malnourished else 1.0) * dt, MAX)
|
||||
|
||||
for g in DIET_GROUPS:
|
||||
diet[g] = maxf(float(diet[g]) - DIET_DRAIN * dt, 0.0)
|
||||
diet[g] = maxf(float(diet[g]) - DIET_DRAIN * drain_mult * dt, 0.0)
|
||||
var lacking := diet_lacking()
|
||||
|
||||
for id in buffs.keys():
|
||||
|
||||
Reference in New Issue
Block a user