giants-godot/characters/vimp2.gd

25 lines
686 B
GDScript

extends Character
func body_entered(body: Node):
if state != States.Alive:
return
if body is GenericProjectile:
take_damage(body.BULLET_DAMAGE)
if state == States.Alive:
var audios = [
preload("res://assets/audio/Sounds/VI_INJR2.xx_vimp.gzp.wav"),
preload("res://assets/audio/Sounds/VI_INJR1.xx_vimp.gzp.wav")
]
var audioindex = randi() % 2
var audio = audios[audioindex]
$HitSound.stream = audio
$HitSound.play()
func die():
var deathaudio = preload("res://assets/audio/Sounds/EX_BDYL2.xx_permanentaliens.gzp.wav")
var hitsnd = $HitSound
hitsnd.stop()
hitsnd.stream = deathaudio
hitsnd.play()
hitsnd.connect("finished", hitsnd, "queue_free")