Compare commits
No commits in common. "6f9894ede9d8571914824d005499442d6807a2b9" and "7471d64491929ee61cee5ef4c6067e5b294578a0" have entirely different histories.
6f9894ede9
...
7471d64491
|
@ -1,9 +1,12 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://cdm267rtmop75"]
|
[gd_scene load_steps=7 format=3 uid="uid://cdm267rtmop75"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c4s6y758n77lw" path="res://villager_shared.tscn" id="1_6uu34"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://7utef1nnena8" path="res://player.tscn" id="1_jbc4n"]
|
[ext_resource type="PackedScene" uid="uid://7utef1nnena8" path="res://player.tscn" id="1_jbc4n"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dl4g083w17qh1" path="res://villager.tscn" id="2_i3gws"]
|
||||||
[ext_resource type="PackedScene" uid="uid://e0s4phx2jiit" path="res://cultist.tscn" id="3_renxb"]
|
[ext_resource type="PackedScene" uid="uid://e0s4phx2jiit" path="res://cultist.tscn" id="3_renxb"]
|
||||||
|
|
||||||
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_62oje"]
|
||||||
|
radius = 10.0
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id="CylinderMesh_c2b6h"]
|
[sub_resource type="CylinderMesh" id="CylinderMesh_c2b6h"]
|
||||||
top_radius = 80.23
|
top_radius = 80.23
|
||||||
|
|
||||||
|
@ -12,23 +15,28 @@ data = PackedVector3Array(0, 1, 80.23, 7.8639, 1, 79.8437, 0, 0.6, 64.284, 7.863
|
||||||
|
|
||||||
[node name="Node3D" type="Node3D"]
|
[node name="Node3D" type="Node3D"]
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource("1_jbc4n")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -24, 5, 40)
|
||||||
|
|
||||||
|
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||||
|
shape = SubResource("CylinderShape3D_62oje")
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, -0.523317, 0.852138, 0, -0.852138, -0.523317, 0, 10.6239, 0)
|
transform = Transform3D(1, 0, 0, 0, -0.523317, 0.852138, 0, -0.852138, -0.523317, 0, 10.6239, 0)
|
||||||
|
|
||||||
|
[node name="Node3D" parent="." instance=ExtResource("2_i3gws")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -22, 3, 43)
|
||||||
|
|
||||||
|
[node name="Node3D2" parent="." instance=ExtResource("3_renxb")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29, 4, 33)
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
mesh = SubResource("CylinderMesh_c2b6h")
|
mesh = SubResource("CylinderMesh_c2b6h")
|
||||||
skeleton = NodePath("")
|
skeleton = NodePath("../StaticBody3D/CollisionShape3D")
|
||||||
|
|
||||||
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
|
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
|
||||||
shape = SubResource("ConcavePolygonShape3D_8q044")
|
shape = SubResource("ConcavePolygonShape3D_8q044")
|
||||||
|
|
||||||
[node name="villager" parent="." instance=ExtResource("1_6uu34")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.28115, 0)
|
|
||||||
|
|
||||||
[node name="Cultist" parent="." instance=ExtResource("3_renxb")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.87818, 2, 0.191837)
|
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("1_jbc4n")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.140476, 0.999999, 1.27725)
|
|
||||||
|
|
|
@ -1,47 +1,8 @@
|
||||||
class_name Villager
|
|
||||||
extends SharedSlime
|
extends SharedSlime
|
||||||
|
class_name Villager
|
||||||
|
|
||||||
var color_changes = true
|
var color_changes = true
|
||||||
|
|
||||||
var is_villager = true
|
|
||||||
|
|
||||||
var hp = 100
|
|
||||||
var aggressor
|
|
||||||
|
|
||||||
func _process(delta):
|
|
||||||
super._process(delta)
|
|
||||||
|
|
||||||
if task == "become_corrupted":
|
|
||||||
become_corrupted()
|
|
||||||
|
|
||||||
func become_corrupted():
|
|
||||||
if location_xz.distance_to(aggressor.location_xz) <= 1:
|
|
||||||
print("becoming corrupted")
|
|
||||||
print(hp)
|
|
||||||
# Spin for effect and lose hp.
|
|
||||||
rotate_y(deg_to_rad(-15))
|
|
||||||
hp -= 0.5
|
|
||||||
else:
|
|
||||||
hp = 100
|
|
||||||
task = "idle"
|
|
||||||
print("cultist left")
|
|
||||||
|
|
||||||
# Create a new cultist and then destroy self.
|
|
||||||
if hp <= 0:
|
|
||||||
# Disable hitbox
|
|
||||||
$slime_collision.disabled = true
|
|
||||||
$CollisionDetection/slime_collision.disabled = true
|
|
||||||
|
|
||||||
# Load and instantiate a new cultist.
|
|
||||||
var cultist = load("res://cultist.tscn")
|
|
||||||
cultist = cultist.instantiate()
|
|
||||||
get_parent_node_3d().add_child(cultist)
|
|
||||||
cultist.set_global_position(get_global_position())
|
|
||||||
|
|
||||||
# Destroy self.
|
|
||||||
queue_free()
|
|
||||||
|
|
||||||
func get_color_idx() -> int:
|
func get_color_idx() -> int:
|
||||||
return $slime.color_idx
|
return $slime.color_idx
|
||||||
|
|
||||||
|
@ -63,7 +24,3 @@ func _on_area_3d_body_entered(body):
|
||||||
$slime.change_color(other)
|
$slime.change_color(other)
|
||||||
|
|
||||||
|
|
||||||
func _on_collision_detection_body_entered(body):
|
|
||||||
if "is_cultist" in body:
|
|
||||||
aggressor = body as Cultist
|
|
||||||
task = "become_corrupted"
|
|
||||||
|
|
|
@ -1,38 +1,24 @@
|
||||||
class_name Cultist
|
|
||||||
extends SharedSlime
|
extends SharedSlime
|
||||||
|
class_name Cultist
|
||||||
|
|
||||||
var victim
|
var victim
|
||||||
|
|
||||||
var is_cultist = true
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
super._process(delta)
|
super._process(delta)
|
||||||
|
|
||||||
if task == "corrupt":
|
if task == "corrupt":
|
||||||
corrupt()
|
pass
|
||||||
|
|
||||||
|
|
||||||
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.
|
# For corruption detection range.
|
||||||
func _on_target_radius_body_entered(body):
|
func _on_target_radius_body_entered(body):
|
||||||
if "is_villager" in body:
|
if body.is_class("Villager"):
|
||||||
print("target found")
|
victim = body
|
||||||
victim = body as Villager
|
walk_speed = 2 * walk_speed
|
||||||
target_location_xz = victim.location_xz
|
target_location_xz = victim.location_xz
|
||||||
task = "walk"
|
task = "walk"
|
||||||
|
|
||||||
|
|
||||||
# For collision with other slimes.
|
# For collision with other slimes.
|
||||||
func _on_collision_detection_body_entered(body):
|
func _on_collision_detection_body_entered(body):
|
||||||
if "is_villager" in body:
|
if body.is_class("Villager"):
|
||||||
task = "corrupt"
|
task = "corrupt"
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://e0s4phx2jiit"]
|
[gd_scene load_steps=6 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="PackedScene" uid="uid://c3q6fva1c1baa" path="res://Models/slime.tscn" id="2_004fn"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cxadu5w3jwv0b" path="res://Sounds/evilslime.ogg" id="3_novm4"]
|
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_rypky"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_rypky"]
|
||||||
radius = 2.5
|
radius = 5.0
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_pa038"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_pa038"]
|
||||||
radius = 0.055
|
radius = 3.0
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_bmc5i"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_bmc5i"]
|
||||||
radius = 0.05
|
radius = 0.3
|
||||||
|
|
||||||
[node name="Cultist" type="CharacterBody3D"]
|
[node name="Cultist" type="CharacterBody3D"]
|
||||||
script = ExtResource("1_k6djk")
|
script = ExtResource("1_k6djk")
|
||||||
|
@ -22,21 +21,14 @@ script = ExtResource("1_k6djk")
|
||||||
shape = SubResource("SphereShape3D_rypky")
|
shape = SubResource("SphereShape3D_rypky")
|
||||||
|
|
||||||
[node name="slime" parent="." instance=ExtResource("2_004fn")]
|
[node name="slime" parent="." instance=ExtResource("2_004fn")]
|
||||||
transform = Transform3D(0.035, 0, 0, 0, 0.035, 0, 0, 0, 0.035, 0, 0, 0)
|
|
||||||
|
|
||||||
[node name="CollisionDetection" type="Area3D" parent="."]
|
[node name="CollisionDetection" type="Area3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.03, 0)
|
|
||||||
|
|
||||||
[node name="collision_ range" type="CollisionShape3D" parent="CollisionDetection"]
|
[node name="collision_ range" type="CollisionShape3D" parent="CollisionDetection"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.013, 0)
|
|
||||||
shape = SubResource("SphereShape3D_pa038")
|
shape = SubResource("SphereShape3D_pa038")
|
||||||
|
|
||||||
[node name="cultist_collision" type="CollisionShape3D" parent="."]
|
[node name="cultist_collision" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0429018, 0)
|
|
||||||
shape = SubResource("SphereShape3D_bmc5i")
|
shape = SubResource("SphereShape3D_bmc5i")
|
||||||
|
|
||||||
[node name="evilslime" type="AudioStreamPlayer3D" parent="."]
|
|
||||||
stream = ExtResource("3_novm4")
|
|
||||||
|
|
||||||
[connection signal="body_entered" from="TargetRadius" to="." method="_on_target_radius_body_entered"]
|
[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"]
|
[connection signal="body_entered" from="CollisionDetection" to="." method="_on_collision_detection_body_entered"]
|
||||||
|
|
|
@ -38,7 +38,7 @@ func walk():
|
||||||
# Rotate towards destination at specified percentage rate.
|
# Rotate towards destination at specified percentage rate.
|
||||||
rotate_y(direction_xz.angle_to(target_direction_xz) * dir_correction_rate)
|
rotate_y(direction_xz.angle_to(target_direction_xz) * dir_correction_rate)
|
||||||
|
|
||||||
if location_xz.distance_to(target_location_xz) <= 0.1:
|
if location_xz.distance_to(target_location_xz) <= (Vector2(direction_xz.x, direction_xz.z) * walk_speed).length():
|
||||||
target_direction_xz = direction_xz
|
target_direction_xz = direction_xz
|
||||||
target_location_xz = location_xz
|
target_location_xz = location_xz
|
||||||
task = "idle"
|
task = "idle"
|
||||||
|
@ -89,7 +89,7 @@ func _physics_process(delta):
|
||||||
velocity.y -= gravity * delta
|
velocity.y -= gravity * delta
|
||||||
|
|
||||||
# Walk to target location.
|
# Walk to target location.
|
||||||
if (location_xz.distance_to(target_location_xz) >= 0.1) and task == "walk":
|
if (location_xz.distance_to(target_location_xz) > walk_speed) and task == "walk":
|
||||||
velocity.x = direction_xz.x * walk_speed
|
velocity.x = direction_xz.x * walk_speed
|
||||||
velocity.z = direction_xz.z * walk_speed
|
velocity.z = direction_xz.z * walk_speed
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
[ext_resource type="Script" path="res://Villager.gd" id="2_uf6mh"]
|
[ext_resource type="Script" path="res://Villager.gd" id="2_uf6mh"]
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_k5rhc"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_k5rhc"]
|
||||||
radius = 0.055
|
radius = 0.05
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_wx128"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_wx128"]
|
||||||
radius = 0.1
|
radius = 0.1
|
||||||
|
|
Loading…
Reference in New Issue