Death because of death
This commit is contained in:
parent
347a990421
commit
dfcb7020ea
2 changed files with 8 additions and 1 deletions
|
|
@ -20,6 +20,8 @@ const MAX_HP = 100
|
|||
|
||||
@export var hp: int = 100:
|
||||
set(value):
|
||||
if dead:
|
||||
return
|
||||
if value < 0:
|
||||
hp = 0
|
||||
else:
|
||||
|
|
@ -27,10 +29,13 @@ const MAX_HP = 100
|
|||
health_changed.emit(hp)
|
||||
if hp == 0:
|
||||
die()
|
||||
dead = true
|
||||
|
||||
get:
|
||||
return hp
|
||||
|
||||
var dead: bool
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
|
|
@ -58,6 +63,8 @@ func depassive() -> void:
|
|||
passived = false
|
||||
|
||||
func take_damage(damage: int):
|
||||
if dead:
|
||||
return
|
||||
hp -= damage
|
||||
damaged.emit()
|
||||
$DamageAudio.multiplayer_play()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue