feat: implement multiplayer network manager and player movement controller with base game entities and UI
This commit is contained in:
@@ -13,6 +13,7 @@ var shield: float = 100.0
|
||||
var is_dead: bool = false
|
||||
var ragdoll_instance: Node3D = null
|
||||
var pending_impulse: Vector3 = Vector3.ZERO
|
||||
var recent_attackers: Dictionary = {}
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("enemies")
|
||||
@@ -42,6 +43,18 @@ func take_damage(amount: float, hit_position: Vector3, source: Node = null) -> v
|
||||
if is_dead:
|
||||
return
|
||||
|
||||
var attacker_id = 0
|
||||
if source:
|
||||
if source.has_method("get_multiplayer_authority"):
|
||||
attacker_id = source.get_multiplayer_authority()
|
||||
elif "owner_player" in source and source.owner_player:
|
||||
attacker_id = int(str(source.owner_player.name))
|
||||
elif source is CharacterBody3D:
|
||||
attacker_id = int(str(source.name))
|
||||
|
||||
if attacker_id != 0:
|
||||
recent_attackers[attacker_id] = Time.get_ticks_msec() / 1000.0
|
||||
|
||||
var dmg_taken = amount
|
||||
if shield > 0:
|
||||
if shield >= amount:
|
||||
@@ -76,7 +89,14 @@ func take_damage(amount: float, hit_position: Vector3, source: Node = null) -> v
|
||||
|
||||
if source.has_method("get_weapon_name"):
|
||||
weapon_name = source.get_weapon_name()
|
||||
nm.register_kill.rpc(-1, killer_id, weapon_name, "Target Dummy")
|
||||
|
||||
var assist_ids: Array = []
|
||||
var now = Time.get_ticks_msec() / 1000.0
|
||||
for aid in recent_attackers.keys():
|
||||
if now - recent_attackers[aid] <= 10.0:
|
||||
assist_ids.append(aid)
|
||||
|
||||
nm.register_kill.rpc(-1, killer_id, weapon_name, "Target Dummy", assist_ids)
|
||||
else:
|
||||
_wiggle()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user