12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- extends Node2D
- export var health_max = 0
- onready var health = health_max
- signal die
- signal damage(dmg)
- export(NodePath) var progressbar
- export(NodePath) var text
- var regen = 0.0
- var regen_time = 7
- var reactive_dmg = 0.0
- var buff = 0
- func _physics_process(delta):
- buff += 1
- if fmod(buff,regen_time*60) == 00:
- print('regen')
- _damage(-regen * health_max ,'',self)
- func _damage(dmg, effect, caller):
- health -= dmg
- health = min(health,health_max)
- # health = clamp(health,0,health_max)
- emit_signal('damage', dmg)
- print('dmg to ' + str(get_path()) + " : " + str(health) + " : " +str(dmg))
- if health <= 0:
- emit_signal('die')
- caller._expgain(get_parent().exppt)
- effect_processor(effect)
- if has_node(progressbar):
- get_node(progressbar).set_value( health )
- get_node(progressbar).set_max( health_max )
- get_node(text).set_text( str(health) )
-
- func _expgain(arg):
- pass
- func _ready():
- if has_node(progressbar):
- get_node(progressbar).set_value( health )
- get_node(progressbar).set_max( health_max )
- get_node(text).set_text( str(health_max) )
- func effect_processor(effect):
- pass
|