diff --git a/ai_test_scene.tscn b/ai_test_scene.tscn index 21c286f..d6b74e5 100644 --- a/ai_test_scene.tscn +++ b/ai_test_scene.tscn @@ -14,8 +14,8 @@ size = Vector3(92.25, 82.386, 76.6396) [sub_resource type="NavigationMesh" id="NavigationMesh_wa46b"] -vertices = PackedVector3Array(-2.62451, 1, 8.13086, -2.62451, 1, 1.63086, -4.87451, 1, 1.38086, -18.1245, 1, 8.13086, -4.87451, 1, -1.36914, -2.62451, 1, -1.61914, -2.62451, 1, -8.11914, -18.1245, 1, -8.11914, 2.62549, 1, -1.61914, 2.62549, 1, -8.11914, 4.87549, 1, 1.38086, 2.62549, 1, 1.63086, 2.62549, 1, 8.13086, 18.1255, 1, 8.13086, 4.87549, 1, -1.36914, 18.1255, 1, -8.11914, -3.87451, 4.5, -0.619141, -3.87451, 4.5, 0.630859, 3.87549, 4.5, 0.630859, 3.87549, 4.5, -0.619141, -3.62451, 1, -0.369141, -3.62451, 1, 0.380859, 3.62549, 1, 0.380859, 3.62549, 1, -0.369141) -polygons = [PackedInt32Array(1, 0, 2), PackedInt32Array(2, 0, 3), PackedInt32Array(5, 4, 6), PackedInt32Array(6, 4, 7), PackedInt32Array(2, 3, 4), PackedInt32Array(4, 3, 7), PackedInt32Array(6, 9, 5), PackedInt32Array(5, 9, 8), PackedInt32Array(11, 10, 12), PackedInt32Array(12, 10, 13), PackedInt32Array(8, 9, 14), PackedInt32Array(14, 9, 15), PackedInt32Array(14, 15, 10), PackedInt32Array(10, 15, 13), PackedInt32Array(19, 18, 16), PackedInt32Array(16, 18, 17), PackedInt32Array(23, 22, 20), PackedInt32Array(20, 22, 21), PackedInt32Array(1, 11, 0), PackedInt32Array(0, 11, 12)] +vertices = PackedVector3Array(-19.5, 1, 0, -5, 1, 0, -4.75, 1, -1.5, -2.75, 1, -19.5, -19.5, 1, -19.5, -2.75, 1, -1.5, 2.75, 1, -1.5, 3, 1, -19.5, 5.75, 1, -1.25, 19.5, 1, -1.5, 19.5, 1, -19.5, 6.25, 1, 11.25, 4.5, 1, 11.5, 4.5, 1, 19.5, 19.5, 1, 19.5, 6.25, 1, -1, -4, 4.5, -0.5, -4, 4.5, 0.5, 3, 4.5, 0.5, 3, 4.5, -0.5, -3.75, 1, -0.25, -3.75, 1, 0.25, 3, 1, 0.25, 3, 1, -0.25, 4, 5, -0.25, 4, 5, 10.5, 5.25, 5, 10.5, 5.25, 5, -0.25, 3, 1, 11.25, 3, 1, 1.5, -4.75, 1, 1.5, -19.5, 1, 19.5, 4.25, 1, 1.5, 4.25, 1, 10.25, 5, 1, 10.25, 5, 1, 1.25) +polygons = [PackedInt32Array(1, 0, 2), PackedInt32Array(2, 0, 4), PackedInt32Array(2, 4, 3), PackedInt32Array(3, 5, 2), PackedInt32Array(5, 3, 6), PackedInt32Array(6, 3, 7), PackedInt32Array(8, 6, 9), PackedInt32Array(9, 6, 7), PackedInt32Array(9, 7, 10), PackedInt32Array(12, 11, 13), PackedInt32Array(13, 11, 14), PackedInt32Array(15, 8, 9), PackedInt32Array(15, 9, 11), PackedInt32Array(11, 9, 14), PackedInt32Array(19, 18, 16), PackedInt32Array(16, 18, 17), PackedInt32Array(23, 22, 20), PackedInt32Array(20, 22, 21), PackedInt32Array(27, 26, 24), PackedInt32Array(24, 26, 25), PackedInt32Array(28, 12, 13), PackedInt32Array(30, 29, 28), PackedInt32Array(0, 1, 30), PackedInt32Array(28, 13, 30), PackedInt32Array(30, 13, 0), PackedInt32Array(0, 13, 31), PackedInt32Array(33, 32, 34), PackedInt32Array(34, 32, 35)] [node name="AI Test Scene" type="Node3D"] script = ExtResource("1_wa46b") @@ -39,7 +39,7 @@ navigation_mesh = SubResource("NavigationMesh_wa46b") [node name="CSGBox3D" type="CSGBox3D" parent="NavigationRegion3D"] material_override = ExtResource("4_t6ubg") use_collision = true -size = Vector3(37.249, 1, 17.2383) +size = Vector3(40, 1, 40) material = ExtResource("4_t6ubg") [node name="CSGBox3D2" type="CSGBox3D" parent="NavigationRegion3D"] @@ -49,6 +49,13 @@ use_collision = true size = Vector3(8.57251, 4.69189, 1.95508) material = ExtResource("4_t6ubg") +[node name="CSGBox3D3" type="CSGBox3D" parent="NavigationRegion3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.61646, 2.06702, 5.0637) +material_override = ExtResource("4_t6ubg") +use_collision = true +size = Vector3(2.18811, 5.13403, 11.5242) +material = ExtResource("4_t6ubg") + [node name="Level" type="Node3D" parent="."] script = ExtResource("5_sdike") start_enemies = 1 diff --git a/assets/item_pickup.tscn b/assets/item_pickup.tscn index 1cb9b46..fc38bb7 100644 --- a/assets/item_pickup.tscn +++ b/assets/item_pickup.tscn @@ -571,7 +571,6 @@ collision_mask = 16 shape = SubResource("CapsuleShape3D_om0ey") [node name="CollisionShape3D2" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0294009, 0) shape = SubResource("CapsuleShape3D_om0ey") [node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."] diff --git a/scripts/EnemyAttack.gd b/scripts/EnemyAttack.gd index 138df26..6e6d5b9 100644 --- a/scripts/EnemyAttack.gd +++ b/scripts/EnemyAttack.gd @@ -7,17 +7,16 @@ var heartbeat : float = 3.0 @export var between_shot_time : Vector2 = Vector2(.5,2.0) @export var reload_time : float = 7.0 @export var alarm_sound : AudioStreamPlayer3D -@export var time_before_losing_visual : float = 2.0 +@export var time_before_losing_visual : float = 1.0 -var ammo var initial_timer var shot_timer = 0.0 var visibility_timer func Enter(): super() + visibility_timer = time_before_losing_visual update_waypoint() - ammo = enemy.max_ammo enemy.turret_material.emission_enabled = true initial_timer = initial_wait_time alarm_sound.play() @@ -25,12 +24,21 @@ func Enter(): func update_waypoint(): enemy.nav_agent.set_target_position(enemy.character_follow.global_position) +func current_target(): + if enemy.is_player_visible(): + return enemy.character_follow.global_position + else: + return enemy.point_of_interest + func Update(delta): if !enemy.is_player_visible(): if visibility_timer > 0: visibility_timer -= delta else: - Transitioned.emit(self,"search") + if enemy.ammo <= 4: + Transitioned.emit(self,"reload") + else: + Transitioned.emit(self,"search") else: visibility_timer = time_before_losing_visual @@ -43,7 +51,7 @@ func Update(delta): initial_timer -= delta else: #fire if player in view - if ammo > 0: + if enemy.ammo > 0: if shot_timer > 0: shot_timer -= delta else: @@ -78,7 +86,7 @@ func attack(): enemy.turret_material.emission_enabled = false func fire(barrel): - ammo -= 1 + enemy.ammo -= 1 var instance_bullet = enemy.bullet.instantiate() instance_bullet.position = barrel.global_position instance_bullet.transform.basis = barrel.global_transform.basis diff --git a/scripts/EnemyReload.gd b/scripts/EnemyReload.gd index 33f67d3..0a9b511 100644 --- a/scripts/EnemyReload.gd +++ b/scripts/EnemyReload.gd @@ -17,6 +17,7 @@ func Enter(): func Exit(): super() + enemy.ammo = enemy.max_ammo enemy.servo_single.play() func update_waypoint(): diff --git a/scripts/spider.gd b/scripts/spider.gd index 399484e..28f996b 100644 --- a/scripts/spider.gd +++ b/scripts/spider.gd @@ -75,7 +75,7 @@ var can_die : bool = false var knocked = false var stunned = false var health - +var ammo var point_of_interest var character_follow @@ -83,6 +83,7 @@ var player_last_seen func _ready(): health = start_health + ammo = max_ammo player = level_control.player #health_bar_sprite.visible = false turret_material.emission_enabled = false @@ -130,6 +131,17 @@ func is_player_visible(): return false +func is_player_in_area(): + if visibility_areas != null: + for area in visibility_areas: + var bodies = area.get_overlapping_bodies() + if bodies != null: + for i in bodies: + if i is Player: + return true + + return false + func cache_player_pos(): if line_of_sight_ray.is_colliding(): if line_of_sight_ray.get_collider() is Player: