mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 16:34:48 +00:00
🐛 use 8-bit integer for synced health, damage scaling and display updates
This commit is contained in:
parent
f1df203a76
commit
547c97bfba
10 changed files with 107 additions and 101 deletions
|
|
@ -17,7 +17,7 @@ class_name ExplosiveDamageComponent extends Area3D
|
|||
## Emitted when the scale tween is finished
|
||||
signal finished
|
||||
|
||||
@export var damage : float = .35
|
||||
@export var damage : float = 89
|
||||
@export var impulse_force : int = 1000
|
||||
var damage_dealer : MatchParticipant
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ class_name HealthComponent extends Area3D
|
|||
|
||||
@export var match_participant : MatchParticipant
|
||||
|
||||
@export var max_health : float = 1.
|
||||
@export var health : float = 1.:
|
||||
set(value):
|
||||
health = value
|
||||
health_changed.emit(value)
|
||||
@export var max_health : int = 255
|
||||
@export var health : int = 255:
|
||||
set(new_health):
|
||||
health = new_health
|
||||
health_changed.emit(new_health)
|
||||
|
||||
signal health_zeroed(killer_id : int)
|
||||
signal health_changed(value : float)
|
||||
signal health_changed(new_health : int)
|
||||
|
||||
func _ready() -> void:
|
||||
# only collide with the "Damage" layer, disable monitoring completely
|
||||
|
|
@ -33,17 +33,17 @@ func _ready() -> void:
|
|||
call_deferred("heal_full")
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func damage(amount : float, damage_dealer_player_id : int, damage_dealer_team_id : int) -> void:
|
||||
func damage(amount : int, damage_dealer_player_id : int, damage_dealer_team_id : int) -> void:
|
||||
if (damage_dealer_team_id == match_participant.team_id) and (damage_dealer_player_id != match_participant.player_id):
|
||||
return
|
||||
|
||||
health = clampf(health - amount, 0.0, max_health)
|
||||
if health == 0.0:
|
||||
health = clampi(health - amount, 0, max_health)
|
||||
if health == 0:
|
||||
health_zeroed.emit(damage_dealer_player_id)
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func _heal(amount : float) -> void:
|
||||
health = clampf(health + amount, 0.0, max_health)
|
||||
func _heal(amount : int) -> void:
|
||||
health = clampi(health + amount, 0, max_health)
|
||||
|
||||
func heal_full() -> void:
|
||||
if not is_multiplayer_authority():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue