NPCs can take quests!
This commit is contained in:
@@ -12,7 +12,7 @@ enum Phases {
|
||||
ARRIVE,
|
||||
QUEUE,
|
||||
WAIT,
|
||||
SERVICE,
|
||||
INTERACT,
|
||||
COMPLETE
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func _generate_name() -> String:
|
||||
func _enter() -> void:
|
||||
var eq = Guild.hall.interactables.get(equipment_name)
|
||||
if !eq:
|
||||
printerr("Use Guild Equipment (%s) - %s, '%s' not found!", equipment_name, service_name, equipment_name)
|
||||
printerr("Use Guild Equipment (%s) - %s, '%s' not found!" % [equipment_name, service_name, equipment_name])
|
||||
return
|
||||
equipment = eq
|
||||
queue = equipment.queue
|
||||
@@ -61,11 +61,11 @@ func _tick(delta: float) -> Status:
|
||||
pass
|
||||
Phases.WAIT:
|
||||
pass
|
||||
Phases.SERVICE:
|
||||
Phases.INTERACT:
|
||||
if wait_time_remaining > 0:
|
||||
wait_time_remaining -= delta
|
||||
if wait_time_remaining <= 0:
|
||||
equipment.service_provided.connect(_on_service_complete)
|
||||
equipment.interaction_complete.connect(_on_interaction_complete)
|
||||
equipment.interact(agent, service_name)
|
||||
Phases.COMPLETE:
|
||||
return SUCCESS
|
||||
@@ -81,10 +81,11 @@ func _on_navigation_failed() -> void:
|
||||
wait_time_remaining = randf_range(.5, 2)
|
||||
agent.navigation_finished.disconnect(_on_navigation_complete)
|
||||
|
||||
func use_service():
|
||||
phase = Phases.SERVICE
|
||||
func interact():
|
||||
phase = Phases.INTERACT
|
||||
wait_time_remaining = randf_range(2,5)
|
||||
#TODO: Make them both do the talking emoji
|
||||
equipment.busy = true
|
||||
agent.show_speech_bubble("busy")
|
||||
|
||||
func wait():
|
||||
@@ -98,12 +99,14 @@ func _on_queue_advanced() -> void:
|
||||
if equipment.busy:
|
||||
wait()
|
||||
else:
|
||||
use_service()
|
||||
interact()
|
||||
pass
|
||||
|
||||
func _on_service_complete() -> void:
|
||||
equipment.service_provided.disconnect(_on_service_complete)
|
||||
func _on_interaction_complete() -> void:
|
||||
equipment.interaction_complete.disconnect(_on_interaction_complete)
|
||||
equipment.busy = false
|
||||
agent.show_speech_bubble("")
|
||||
queue.remove_member(agent)
|
||||
phase = Phases.COMPLETE
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extends BTCondition
|
||||
var invert : bool
|
||||
@export var invert : bool
|
||||
func _tick(delta: float) -> Status:
|
||||
if agent.data and ((agent.data.quest == null) == invert):
|
||||
return SUCCESS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_resource type="BehaviorTree" load_steps=42 format=3 uid="uid://dght2flegv70i"]
|
||||
[gd_resource type="BehaviorTree" load_steps=43 format=3 uid="uid://dght2flegv70i"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://h113xg55h4r8" path="res://ai/tasks/actions/go_to.gd" id="1_s3kkm"]
|
||||
[ext_resource type="Script" uid="uid://bsq5dxul0uto" path="res://ai/tasks/actions/use_guild_service.gd" id="2_1441p"]
|
||||
@@ -6,6 +6,7 @@
|
||||
[ext_resource type="Script" uid="uid://b2vuw12mttm40" path="res://ai/tasks/decorators/busy.gd" id="2_mtixs"]
|
||||
[ext_resource type="Script" uid="uid://bcbfnm21rtkuo" path="res://ai/tasks/conditions/is_unregistered.gd" id="3_mtixs"]
|
||||
[ext_resource type="Script" uid="uid://xom38ohdwfms" path="res://ai/tasks/conditions/has_quest.gd" id="4_1441p"]
|
||||
[ext_resource type="Script" uid="uid://bhatmue8jr2ab" path="res://ai/tasks/actions/use_guild_equipment.gd" id="7_nqy1p"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_6h604"]
|
||||
var/pos/name = &"pos"
|
||||
@@ -77,18 +78,19 @@ activity = "Registering as an adventurer"
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_mtixs"]
|
||||
script = ExtResource("4_1441p")
|
||||
invert = true
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_fe6jf"]
|
||||
script = ExtResource("2_1441p")
|
||||
employee_name = "Questboard"
|
||||
service_name = "get_quest"
|
||||
[sub_resource type="BTAction" id="BTAction_8lwgx"]
|
||||
script = ExtResource("7_nqy1p")
|
||||
equipment_name = "Quest Board"
|
||||
service_name = "quest"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_mwsop"]
|
||||
script = ExtResource("2_fe6jf")
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_nqy1p"]
|
||||
custom_name = "Get a Quest"
|
||||
children = [SubResource("BTCondition_mtixs"), SubResource("BTAction_fe6jf"), SubResource("BTAction_mwsop")]
|
||||
children = [SubResource("BTCondition_mtixs"), SubResource("BTAction_8lwgx"), SubResource("BTAction_mwsop")]
|
||||
|
||||
[sub_resource type="BTDecorator" id="BTDecorator_s18yy"]
|
||||
children = [SubResource("BTSequence_nqy1p")]
|
||||
@@ -120,12 +122,14 @@ custom_name = "Idle"
|
||||
|
||||
[sub_resource type="BTProbability" id="BTProbability_gc1l4"]
|
||||
children = [SubResource("BTWait_8lwgx")]
|
||||
_enabled = false
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_jq6fo"]
|
||||
script = ExtResource("2_fe6jf")
|
||||
|
||||
[sub_resource type="BTProbability" id="BTProbability_8lwgx"]
|
||||
children = [SubResource("BTAction_jq6fo")]
|
||||
_enabled = false
|
||||
|
||||
[sub_resource type="BTProbabilitySelector" id="BTProbabilitySelector_mtixs"]
|
||||
children = [SubResource("BTProbability_s3kkm"), SubResource("BTProbability_1441p"), SubResource("BTProbability_gc1l4"), SubResource("BTProbability_8lwgx")]
|
||||
|
||||
34
ai/trees/quest_board.tres
Normal file
34
ai/trees/quest_board.tres
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_resource type="BehaviorTree" load_steps=9 format=3 uid="uid://tr5enbq48w6x"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_7h63t"]
|
||||
|
||||
[sub_resource type="BBVariant" id="BBVariant_7h63t"]
|
||||
type = 1
|
||||
saved_value = false
|
||||
resource_name = "false"
|
||||
|
||||
[sub_resource type="BTCheckAgentProperty" id="BTCheckAgentProperty_un3nm"]
|
||||
property = &"busy"
|
||||
value = SubResource("BBVariant_7h63t")
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_3iu7m"]
|
||||
saved_value = NodePath("Queue")
|
||||
resource_name = "Queue"
|
||||
|
||||
[sub_resource type="BTCallMethod" id="BTCallMethod_8wdsa"]
|
||||
node = SubResource("BBNode_3iu7m")
|
||||
method = &"try_advance"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_26pbt"]
|
||||
children = [SubResource("BTCheckAgentProperty_un3nm"), SubResource("BTCallMethod_8wdsa")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_3glab"]
|
||||
duration = 2.0
|
||||
children = [SubResource("BTSequence_26pbt")]
|
||||
|
||||
[sub_resource type="BTRepeat" id="BTRepeat_hcvsp"]
|
||||
children = [SubResource("BTCooldown_3glab")]
|
||||
|
||||
[resource]
|
||||
blackboard_plan = SubResource("BlackboardPlan_7h63t")
|
||||
root_task = SubResource("BTRepeat_hcvsp")
|
||||
Reference in New Issue
Block a user