SlimeoosOdyssey/godot/cultist.gd

39 lines
818 B
GDScript

class_name Cultist
extends SharedSlime
var victim
var is_cultist = true
func _process(delta):
super._process(delta)
if task == "corrupt":
corrupt()
func corrupt():
# Make sure the victim is still next to the cultist.
if location_xz.distance_to(victim.location_xz) <= 0.5 and victim != null:
print("corrupting")
rotate_y(deg_to_rad(15))
if victim.hp <= 0:
$evilslime.play()
task = "idle"
else:
print("target lost")
task = "idle"
# For corruption detection range.
func _on_target_radius_body_entered(body):
if "is_villager" in body:
print("target found")
victim = body as Villager
target_location_xz = victim.location_xz
task = "walk"
# For collision with other slimes.
func _on_collision_detection_body_entered(body):
if "is_villager" in body:
task = "corrupt"