started working on fog darkness
This commit is contained in:
@@ -309,13 +309,13 @@ func take_damage(amount: float, from_position: Vector2, is_critical: bool = fals
|
||||
print(name, " DODGED the attack! (DEX: ", character_stats.baseStats.dex + character_stats.get_pass("dex"), ", dodge chance: ", dodge_chance * 100.0, "%)")
|
||||
# Show "DODGED" text
|
||||
_show_damage_number(0.0, from_position, false, false, true) # is_dodged = true
|
||||
# Sync dodge visual to clients
|
||||
# Sync dodge visual to clients (pass damage_amount=0.0 and is_dodged=true to indicate dodge)
|
||||
if multiplayer.has_multiplayer_peer() and is_inside_tree():
|
||||
var enemy_name = name
|
||||
var enemy_index = get_meta("enemy_index") if has_meta("enemy_index") else -1
|
||||
var game_world = get_tree().get_first_node_in_group("game_world")
|
||||
if game_world and game_world.has_method("_sync_enemy_damage_visual"):
|
||||
game_world._sync_enemy_damage_visual.rpc(enemy_name, enemy_index)
|
||||
game_world._sync_enemy_damage_visual.rpc(enemy_name, enemy_index, 0.0, from_position, false, true)
|
||||
return # No damage taken, exit early
|
||||
|
||||
# If not dodged, apply damage with DEF reduction
|
||||
@@ -357,10 +357,10 @@ func take_damage(amount: float, from_position: Vector2, is_critical: bool = fals
|
||||
var enemy_index = get_meta("enemy_index") if has_meta("enemy_index") else -1
|
||||
var game_world = get_tree().get_first_node_in_group("game_world")
|
||||
if game_world and game_world.has_method("_sync_enemy_damage_visual"):
|
||||
game_world._sync_enemy_damage_visual.rpc(enemy_name, enemy_index)
|
||||
game_world._sync_enemy_damage_visual.rpc(enemy_name, enemy_index, actual_damage, from_position, is_critical)
|
||||
else:
|
||||
# Fallback: try direct RPC (may fail if node path doesn't match)
|
||||
_sync_damage_visual.rpc()
|
||||
_sync_damage_visual.rpc(actual_damage, from_position, is_critical)
|
||||
|
||||
if current_health <= 0:
|
||||
# Prevent multiple death triggers
|
||||
@@ -655,13 +655,17 @@ func _sync_position(pos: Vector2, vel: Vector2, z_pos: float = 0.0, dir: int = 0
|
||||
_update_client_visuals()
|
||||
|
||||
# This function can be called directly (not just via RPC) when game_world routes the update
|
||||
func _sync_damage_visual():
|
||||
func _sync_damage_visual(damage_amount: float = 0.0, attacker_position: Vector2 = Vector2.ZERO, is_critical: bool = false, is_dodged: bool = false):
|
||||
# Clients receive damage visual sync
|
||||
# Only process if we're not the authority (i.e., we're a client)
|
||||
if is_multiplayer_authority():
|
||||
return # Server ignores its own updates
|
||||
|
||||
_flash_damage()
|
||||
|
||||
# Show damage number on client (even if damage_amount is 0 for dodges/misses)
|
||||
if attacker_position != Vector2.ZERO:
|
||||
_show_damage_number(damage_amount, attacker_position, is_critical, false, is_dodged)
|
||||
|
||||
# This function can be called directly (not just via RPC) when game_world routes the update
|
||||
func _sync_death():
|
||||
|
||||
Reference in New Issue
Block a user