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