Reworked the AI Objectives
This commit is contained in:
parent
27964084ff
commit
a6c9909f26
8 changed files with 31 additions and 11 deletions
|
@ -24,3 +24,9 @@ avoidance_enabled = true
|
|||
height = 2.0
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, 0)
|
||||
pixel_size = 0.01
|
||||
billboard = 1
|
||||
no_depth_test = true
|
||||
|
|
|
@ -21,3 +21,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
|||
[node name="Label" type="Label" parent="."]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, 0)
|
||||
pixel_size = 0.01
|
||||
billboard = 1
|
||||
no_depth_test = true
|
||||
text = "SamplePlayer"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bn60ywtwfn7bq"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/maps/rest.gd" id="1_m76x3"]
|
||||
[ext_resource type="Script" path="res://scripts/maps/objectives/objective.gd" id="1_m76x3"]
|
||||
|
||||
[node name="Rest" type="Node3D"]
|
||||
script = ExtResource("1_m76x3")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://cbyee7drds7qu"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/maps/map.gd" id="1_4npcs"]
|
||||
[ext_resource type="Script" path="res://scripts/maps/rest.gd" id="2_yv1d0"]
|
||||
[ext_resource type="Script" path="res://scripts/maps/objectives/objective.gd" id="2_yv1d0"]
|
||||
[ext_resource type="PackedScene" uid="uid://bsghm187n6ykx" path="res://scenes/objects/closet.tscn" id="2_yvpvm"]
|
||||
[ext_resource type="PackedScene" uid="uid://cvnjpnvchvakj" path="res://scenes/entities/npc.tscn" id="3_x3gyc"]
|
||||
|
||||
|
@ -23,7 +23,6 @@ script = ExtResource("1_4npcs")
|
|||
[node name="PlayerSpawn" type="Node3D" parent="."]
|
||||
|
||||
[node name="0" type="Node3D" parent="PlayerSpawn"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17, 3, 0)
|
||||
|
||||
[node name="1" type="Node3D" parent="PlayerSpawn"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 16, 4, 0)
|
||||
|
@ -55,7 +54,7 @@ environment = SubResource("Environment_pq0iv")
|
|||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 10, 2)
|
||||
|
||||
[node name="Npc1" parent="." instance=ExtResource("3_x3gyc")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 20, 40)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 25, 6, -33)
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
|
||||
navigation_mesh = SubResource("NavigationMesh_hqhxb")
|
||||
|
|
|
@ -28,7 +28,10 @@ func _ready() -> void:
|
|||
func _timer_done() -> void:
|
||||
if angry_meter > 0:
|
||||
angry_meter -= 1
|
||||
if target is Objective:
|
||||
($Label3D as Label3D).text = "%s %ds left" % [(target as Objective).displayed, angry_meter]
|
||||
else:
|
||||
($Label3D as Label3D).text = ""
|
||||
timer.stop()
|
||||
phase = 2
|
||||
find_player(99999999999999)
|
||||
|
@ -37,7 +40,7 @@ func _timer_done() -> void:
|
|||
func find_rest() -> void:
|
||||
var lowest_distance: float = 99999999999999
|
||||
for child: Node in get_tree().root.get_node("/root/"+Game.mapname+"/NPCRestPlaces").get_children():
|
||||
if child is Rest and position.distance_to((child as Rest).position) < lowest_distance and !(child as Rest).occupied:
|
||||
if child is Objective and position.distance_to((child as Objective).position) < lowest_distance and !(child as Objective).occupied:
|
||||
target = child
|
||||
|
||||
navigation_agent.set_target_position(target.position)
|
||||
|
@ -59,8 +62,8 @@ func _physics_process(_delta: float) -> void:
|
|||
|
||||
if navigation_agent.is_navigation_finished():
|
||||
if phase == 0:
|
||||
if target is Rest:
|
||||
(target as Rest).occupied = false
|
||||
if target is Objective:
|
||||
(target as Objective).occupied = false
|
||||
phase = 1
|
||||
timer.start()
|
||||
return
|
||||
|
@ -74,5 +77,3 @@ func _physics_process(_delta: float) -> void:
|
|||
pass
|
||||
|
||||
Networking.npc_sync_call(position, rotation, name)
|
||||
|
||||
|
||||
|
|
|
@ -15,11 +15,12 @@ var freecam: bool = false
|
|||
var camera_rotation: Vector2 = Vector2(0,0)
|
||||
|
||||
func _ready() -> void:
|
||||
($Label3D as Label3D).text = name
|
||||
if name == Game.username:
|
||||
activated = true
|
||||
camera.current = true
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
($Label3D as Label3D).hide()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if activated:
|
||||
|
|
5
scripts/maps/objectives/hungry.gd
Normal file
5
scripts/maps/objectives/hungry.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
class_name Hungry
|
||||
extends Objective
|
||||
|
||||
func _ready() -> void:
|
||||
displayed = "Hungry"
|
|
@ -1,7 +1,8 @@
|
|||
## SPDX-License-Identifier: GPL-3.0-or-later
|
||||
## Copyright (c) 2024 interstellardevelopment.org
|
||||
|
||||
class_name Rest
|
||||
class_name Objective
|
||||
extends Node3D
|
||||
|
||||
var occupied: bool = false
|
||||
var displayed: String
|
Loading…
Reference in a new issue