Compare commits

..

No commits in common. "d62d10e7e0fe4da51427be6b27fa517c3045e644" and "16d31becb503bd97c29c13a2444fe5736df283de" have entirely different histories.

3 changed files with 40 additions and 42 deletions

View File

@ -1,24 +1,18 @@
extends SharedSlime extends SharedSlime
class_name Cultist class_name Cultist
var victim const SPEED = 5.0
const JUMP_VELOCITY = 4.
func _process(delta): func _on_area_3d_body_entered(body):
super._process(delta) var items_in_range = $Area3D.get_overlapping_bodies()
var villagers = []
for item in items_in_range:
if is_class("Villager"):
villagers.append(item)
var rng = RandomNumberGenerator.new()
var victim_num = rng.randi_range(0, villagers.size())
if task == "corrupt":
pass
# For corruption detection range.
func _on_target_radius_body_entered(body):
if body.is_class("Villager"):
victim = body
walk_speed = 2 * walk_speed
target_location_xz = victim.location_xz
task = "walk"
# For collision with other slimes.
func _on_collision_detection_body_entered(body):
if body.is_class("Villager"):
task = "corrupt"

View File

@ -1,34 +1,31 @@
[gd_scene load_steps=6 format=3 uid="uid://e0s4phx2jiit"] [gd_scene load_steps=7 format=3 uid="uid://e0s4phx2jiit"]
[ext_resource type="Script" path="res://cultist.gd" id="1_k6djk"] [ext_resource type="Script" path="res://cultist.gd" id="1_k6djk"]
[ext_resource type="PackedScene" uid="uid://c3q6fva1c1baa" path="res://Models/slime.tscn" id="2_004fn"] [ext_resource type="Texture2D" uid="uid://df0xror4t3gbc" path="res://Default Purple.png" id="1_x8j7f"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_y0hcm"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vxnad"]
albedo_texture = ExtResource("1_x8j7f")
[sub_resource type="CapsuleMesh" id="CapsuleMesh_17ljq"]
material = SubResource("StandardMaterial3D_vxnad")
[sub_resource type="SphereShape3D" id="SphereShape3D_rypky"] [sub_resource type="SphereShape3D" id="SphereShape3D_rypky"]
radius = 5.0 radius = 20.0
[sub_resource type="SphereShape3D" id="SphereShape3D_pa038"]
radius = 3.0
[sub_resource type="SphereShape3D" id="SphereShape3D_bmc5i"]
radius = 0.3
[node name="Cultist" type="CharacterBody3D"] [node name="Cultist" type="CharacterBody3D"]
script = ExtResource("1_k6djk") script = ExtResource("1_k6djk")
[node name="TargetRadius" type="Area3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_y0hcm")
[node name="CollisionShape3D" type="CollisionShape3D" parent="TargetRadius"] [node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D"]
mesh = SubResource("CapsuleMesh_17ljq")
[node name="Area3D" type="Area3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
shape = SubResource("SphereShape3D_rypky") shape = SubResource("SphereShape3D_rypky")
[node name="slime" parent="." instance=ExtResource("2_004fn")] [connection signal="body_entered" from="Area3D" to="." method="_on_area_3d_body_entered"]
[node name="CollisionDetection" type="Area3D" parent="."]
[node name="collision_ range" type="CollisionShape3D" parent="CollisionDetection"]
shape = SubResource("SphereShape3D_pa038")
[node name="cultist_collision" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_bmc5i")
[connection signal="body_entered" from="TargetRadius" to="." method="_on_target_radius_body_entered"]
[connection signal="body_entered" from="CollisionDetection" to="." method="_on_collision_detection_body_entered"]

View File

@ -8,3 +8,10 @@ radius = 0.1
[node name="villager" instance=ExtResource("1_qm1jp")] [node name="villager" instance=ExtResource("1_qm1jp")]
script = ExtResource("2_uf6mh") script = ExtResource("2_uf6mh")
[node name="Area3D" type="Area3D" parent="." index="2"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D" index="0"]
shape = SubResource("SphereShape3D_0wi6w")
[connection signal="body_entered" from="Area3D" to="." method="_on_area_3d_body_entered"]