Tweaked some numbers to get a better "swarm"

This commit is contained in:
Douwe Ravers
2024-10-07 23:50:50 +02:00
parent af7a46cd23
commit 7f0591298a
27 changed files with 1403 additions and 26 deletions

View File

@@ -13,6 +13,7 @@ func _on_attack_timer_timeout() -> void:
if ant is EnemyAnt and other_ant is not EnemyAnt:
other_ant.hit(randi_range(0, ant.damage))
attack.emit()
if ant is SoldierAnt: return
for area in get_overlapping_areas():
if area.get_parent() is Building:
var building := area.get_parent() as Building

View File

@@ -5,5 +5,5 @@ extends MeshInstance3D
func _process(delta: float) -> void:
visible = ant.capacity > 0 and \
ant.target == PlayerCamp.instance and \
ant.target is PlayerCamp and \
ant.source_target.type == type

View File

@@ -15,8 +15,6 @@ height = 2.88419
axis_lock_angular_x = true
axis_lock_angular_z = true
script = ExtResource("1_kehry")
damage = 4
max_health = 15
speed = 3.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
@@ -24,7 +22,7 @@ transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.4
shape = SubResource("CapsuleShape3D_bqyr6")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
target_desired_distance = 2.0
target_desired_distance = 3.0
avoidance_enabled = true
debug_path_custom_color = Color(0.3, 0.381667, 1, 1)
@@ -38,9 +36,9 @@ texture = ExtResource("2_hdgws")
[node name="Skeleton3D" parent="enemy/EnemyAnt" index="0"]
bones/0/rotation = Quaternion(-0.151731, -0.023891, -0.015694, 0.988008)
bones/1/rotation = Quaternion(-0.448048, 0.00344809, -0.000394401, 0.894003)
bones/1/rotation = Quaternion(-0.453618, 0.00738223, -0.000844401, 0.891166)
bones/2/rotation = Quaternion(0.597894, 0.051707, -0.697194, 0.392135)
bones/3/rotation = Quaternion(-0.268977, 0.0602213, -0.581107, 0.765729)
bones/3/rotation = Quaternion(-0.261701, 0.0566905, -0.585419, 0.765234)
bones/3/scale = Vector3(1, 1, 1)
bones/4/rotation = Quaternion(-0.185361, 0.0767715, -0.304188, 0.931245)
bones/4/scale = Vector3(1, 1, 1)
@@ -55,10 +53,10 @@ bones/8/rotation = Quaternion(0.731112, 0.216438, -0.270013, 0.587982)
bones/9/rotation = Quaternion(-0.147272, -0.690287, -0.291994, 0.64541)
bones/10/rotation = Quaternion(0.035527, -0.0722718, -0.344413, 0.935358)
bones/10/scale = Vector3(1, 1, 1)
bones/11/rotation = Quaternion(0.582122, -0.384409, 0.688139, 0.199572)
bones/11/rotation = Quaternion(0.58198, -0.38065, 0.688782, 0.204903)
bones/12/rotation = Quaternion(-0.275331, -0.0633099, 0.577289, 0.766108)
bones/12/scale = Vector3(1, 1, 1)
bones/13/rotation = Quaternion(0.0216325, 0.352033, 0.113455, 0.928834)
bones/13/rotation = Quaternion(0.0127256, 0.347415, 0.116465, 0.930364)
bones/13/scale = Vector3(1, 1, 1)
bones/14/position = Vector3(-0.131012, 0.4206, 0.0209323)
bones/14/rotation = Quaternion(0.311801, -0.156763, 0.515707, 0.782465)
@@ -71,7 +69,7 @@ bones/17/rotation = Quaternion(0.742166, -0.221688, 0.264848, 0.574369)
bones/18/rotation = Quaternion(-0.156224, 0.731565, 0.301322, 0.59128)
bones/19/rotation = Quaternion(0.035527, 0.0722718, 0.344413, 0.935358)
bones/19/scale = Vector3(1, 1, 1)
bones/20/rotation = Quaternion(0.000485378, 0.711083, 0.703105, -0.00183471)
bones/20/rotation = Quaternion(0.00103909, 0.715589, 0.69851, -0.00392773)
[node name="AnimationTree" type="AnimationTree" parent="enemy"]
tree_root = ExtResource("4_px4kn")

View File

@@ -76,9 +76,9 @@ stretch_mode = 4
[node name="Skeleton3D" parent="soldier/SoldierAnt" index="0"]
bones/0/rotation = Quaternion(-0.151731, -0.023891, -0.015694, 0.988008)
bones/1/rotation = Quaternion(-0.454449, 0.00797132, -0.000911783, 0.890736)
bones/1/rotation = Quaternion(-0.513811, 0.0510532, -0.00583962, 0.856363)
bones/2/rotation = Quaternion(0.597894, 0.051707, -0.697194, 0.392135)
bones/3/rotation = Quaternion(-0.26061, 0.0561613, -0.58606, 0.765155)
bones/3/rotation = Quaternion(-0.179347, 0.0171244, -0.630019, 0.755392)
bones/3/scale = Vector3(1, 1, 1)
bones/4/rotation = Quaternion(-0.185361, 0.0767715, -0.304188, 0.931245)
bones/4/scale = Vector3(1, 1, 1)
@@ -93,10 +93,10 @@ bones/8/rotation = Quaternion(0.731112, 0.216438, -0.270013, 0.587982)
bones/9/rotation = Quaternion(-0.147272, -0.690287, -0.291994, 0.64541)
bones/10/rotation = Quaternion(0.035527, -0.0722718, -0.344413, 0.935358)
bones/10/scale = Vector3(1, 1, 1)
bones/11/rotation = Quaternion(0.581957, -0.380086, 0.688875, 0.2057)
bones/11/rotation = Quaternion(0.578724, -0.337804, 0.693925, 0.263507)
bones/12/rotation = Quaternion(-0.275331, -0.0633099, 0.577289, 0.766108)
bones/12/scale = Vector3(1, 1, 1)
bones/13/rotation = Quaternion(0.0113916, 0.34672, 0.116915, 0.930584)
bones/13/rotation = Quaternion(-0.0864303, 0.293427, 0.149054, 0.940326)
bones/13/scale = Vector3(1, 1, 1)
bones/14/position = Vector3(-0.131012, 0.4206, 0.0209323)
bones/14/rotation = Quaternion(0.311801, -0.156763, 0.515707, 0.782465)
@@ -109,7 +109,7 @@ bones/17/rotation = Quaternion(0.742166, -0.221688, 0.264848, 0.574369)
bones/18/rotation = Quaternion(-0.156224, 0.731565, 0.301322, 0.59128)
bones/19/rotation = Quaternion(0.035527, 0.0722718, 0.344413, 0.935358)
bones/19/scale = Vector3(1, 1, 1)
bones/20/rotation = Quaternion(0.001122, 0.716261, 0.697819, -0.00424113)
bones/20/rotation = Quaternion(0.00718503, 0.763404, 0.64531, -0.0271591)
[node name="AnimationTree" type="AnimationTree" parent="soldier"]
tree_root = ExtResource("5_c6ikb")

View File

@@ -43,3 +43,23 @@ func _on_target_reached() -> void:
capacity = 0
target = source_target
go_to(target.global_position)
func _on_area_3d_area_entered(area: Area3D) -> void:
if area.get_parent() is CollectableResource:
var resource := area.get_parent() as CollectableResource
capacity = resource.collect(5)
target = PlayerCamp.instance
go_to(target.global_position)
elif area.get_parent() is PlayerCamp:
var camp := area.get_parent() as PlayerCamp
match source_target.type:
CollectableResource.ResourceType.FOOD:
camp.food_capacity += capacity
CollectableResource.ResourceType.WOOD:
camp.wood_capacity += capacity
CollectableResource.ResourceType.STONE:
camp.stone_capacity += capacity
capacity = 0
target = source_target
go_to(target.global_position)

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=4 uid="uid://cbc61u4p4mn05"]
[gd_scene load_steps=24 format=4 uid="uid://cbc61u4p4mn05"]
[ext_resource type="Script" path="res://entities/ants/worker_ant.gd" id="1_hmrg3"]
[ext_resource type="PackedScene" uid="uid://v2kcdfr5npqb" path="res://assets/fbx/base_ant.fbx" id="2_b8awe"]
@@ -123,6 +123,9 @@ fill_to = Vector2(1, 1)
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_uj2kw"]
texture = SubResource("GradientTexture2D_upbt3")
[sub_resource type="BoxShape3D" id="BoxShape3D_6s5hc"]
size = Vector3(3, 3, 3)
[node name="WorkerAnt" type="CharacterBody3D"]
axis_lock_angular_x = true
axis_lock_angular_z = true
@@ -136,7 +139,7 @@ shape = SubResource("CapsuleShape3D_bqyr6")
[node name="Skeleton3D" parent="base_ant/BaseAnt" index="0"]
bones/0/rotation = Quaternion(9.9051e-05, -8.31996e-29, 6.6946e-17, 1)
bones/1/rotation = Quaternion(0.0811275, 0.000963642, -0.206745, 0.975025)
bones/1/rotation = Quaternion(0.0536049, -3.59708e-18, -7.87621e-17, 0.998562)
bones/3/rotation = Quaternion(0.541099, 0.16567, -0.351117, 0.745978)
bones/4/rotation = Quaternion(-0.275331, 0.0633099, -0.577289, 0.766108)
bones/7/rotation = Quaternion(0.674429, 0.240017, -0.247256, 0.652994)
@@ -152,7 +155,7 @@ bones/24/rotation = Quaternion(0.0469251, 0.0954517, 0.66037, 0.74337)
bones/27/rotation = Quaternion(0, 0, 1, 0)
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="base_ant/BaseAnt/Skeleton3D" index="0"]
transform = Transform3D(0.914511, 0.40332, -0.0316663, -0.403001, 0.901318, -0.158797, -0.0355045, 0.157983, 0.986803, 1.16994e-19, 0.00431615, 0.00552689)
transform = Transform3D(1, 2.3791e-17, -1.2808e-18, -2.37911e-17, 0.994232, -0.107253, -1.27823e-18, 0.107253, 0.994232, 1.16994e-19, 0.00431615, 0.00552689)
bone_name = "Head"
bone_idx = 1
@@ -189,7 +192,7 @@ anim_player = NodePath("../AnimationPlayer")
parameters/blend_position = 0.0
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
target_desired_distance = 2.0
target_desired_distance = 3.0
avoidance_enabled = true
debug_path_custom_color = Color(0.3, 0.381667, 1, 1)
@@ -224,9 +227,17 @@ texture = ExtResource("6_l4m2r")
[node name="Node3D" parent="." instance=ExtResource("8_th62q")]
[node name="Area3D" type="Area3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.672495, -2.70862)
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
shape = SubResource("BoxShape3D_6s5hc")
[connection signal="mouse_entered" from="." to="base_ant/BaseAnt/Skeleton3D/Head2" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="base_ant/BaseAnt/Skeleton3D/Head2" method="_on_mouse_exited"]
[connection signal="navigation_finished" from="NavigationAgent3D" to="." method="_on_target_reached"]
[connection signal="velocity_computed" from="NavigationAgent3D" to="." method="_on_velocity_computed"]
[connection signal="area_entered" from="Area3D" to="." method="_on_area_3d_area_entered"]
[editable path="base_ant"]