M2.6: server rules (PvP, raiding, locks and friends, death penalty, difficulty, wolf grace), chat, admin commands, server console
This commit is contained in:
@@ -53,7 +53,10 @@ func step(dt: float) -> void:
|
||||
var ex: Array[RID] = []
|
||||
if shooter != null and is_instance_valid(shooter) and shooter.has_method("get_rid"):
|
||||
ex.append(shooter.get_rid())
|
||||
var q := PhysicsRayQueryParameters3D.create(from, to, 1 | 8, ex)
|
||||
var mask := 1 | 8
|
||||
if world.server_mode and preload("res://scripts/net/rules.gd").pvp():
|
||||
mask |= 16 # other players (server_player.gd); with PvP off arrows pass through them
|
||||
var q := PhysicsRayQueryParameters3D.create(from, to, mask, ex)
|
||||
var hit := get_world_3d().direct_space_state.intersect_ray(q)
|
||||
if not hit.is_empty():
|
||||
_on_hit(hit)
|
||||
@@ -69,6 +72,15 @@ func _on_hit(hit: Dictionary) -> void:
|
||||
if visual:
|
||||
queue_free()
|
||||
return
|
||||
if c != null and c.get("player_id") != null and c.get("survival") != null:
|
||||
# Another player, on a server with PvP on.
|
||||
var k := clampf(velocity.length() / _start_speed, 0.4, 1.0)
|
||||
var by: String = String(shooter.display) if shooter != null and is_instance_valid(shooter) and shooter.get("display") != null else "an arrow"
|
||||
(c as Node).survival.damage(damage * k, global_position - dir, by)
|
||||
Actions.tell(shooter, "Hit %s" % String(c.display))
|
||||
var at: Vector3 = (c as Node3D).global_position + Vector3(0, 0.05, 0)
|
||||
_drop(Transform3D(Basis(Vector3.UP, randf() * TAU) * Basis(Vector3.FORWARD, PI * 0.5), at))
|
||||
return
|
||||
if c != null and (c as Node).is_in_group("creature"):
|
||||
var k := clampf(velocity.length() / _start_speed, 0.4, 1.0)
|
||||
Actions.projectile_hit(shooter, c, damage * k, global_position, item_id if item_id == "arrow" else "")
|
||||
|
||||
Reference in New Issue
Block a user