M2.3: the shared world (trees, pickups, pieces, chests, fires, doors, graves, clock on the server)
This commit is contained in:
@@ -56,15 +56,26 @@ func interact_prompt(player: Node) -> String:
|
||||
## Applies one hit. Returns the items earned by this hit.
|
||||
func hit(damage: float, point: Vector3, from: Vector3) -> Dictionary:
|
||||
var out := {}
|
||||
hp -= damage
|
||||
for id in drops_per_hit:
|
||||
out[id] = drops_per_hit[id]
|
||||
_burst(point, chip_color, 14)
|
||||
if hp <= 0.0:
|
||||
depleted = true
|
||||
if hp - damage <= 0.0:
|
||||
for id in drops_final:
|
||||
var r: Array = drops_final[id]
|
||||
out[id] = out.get(id, 0) + rng.randi_range(int(r[0]), int(r[1]))
|
||||
_show_hit(hp - damage, point, from)
|
||||
return out
|
||||
|
||||
## A hit someone else's game reported, via the server (world_net.gd): the
|
||||
## same chips, shake and fall, with no drops.
|
||||
func apply_remote(new_hp: float, point: Vector3, from: Vector3) -> void:
|
||||
if not depleted:
|
||||
_show_hit(new_hp, point, from)
|
||||
|
||||
func _show_hit(new_hp: float, point: Vector3, from: Vector3) -> void:
|
||||
hp = new_hp
|
||||
_burst(point, chip_color, 14)
|
||||
if hp <= 0.0:
|
||||
depleted = true
|
||||
_deplete(from)
|
||||
else:
|
||||
_shake = 1.0
|
||||
@@ -73,7 +84,6 @@ func hit(damage: float, point: Vector3, from: Vector3) -> Dictionary:
|
||||
_shake_axis = away.normalized().cross(Vector3.UP) if away.length() > 0.01 else Vector3.RIGHT
|
||||
if kind == "rock":
|
||||
_set_instance(_rock_xf())
|
||||
return out
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _shake <= 0.0 or depleted:
|
||||
|
||||
Reference in New Issue
Block a user