Skip to content

Commit eddb2ae

Browse files
authored
Fix NPCs without generic dialogs being unable to give quests
1 parent 41372bc commit eddb2ae

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

scenes/characters/Npc.gd

+20-11
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,26 @@ func _ready():
2222
pass # Replace with function body.
2323

2424
func _input(event):
25-
if (
26-
active and not
27-
dialogs.empty() and
28-
event.is_action_pressed("interact") and not
29-
Dialogs.active
30-
):
31-
if has_node("Quest"):
32-
var quest_dialog = get_node("Quest").process()
33-
if quest_dialog != "":
34-
Dialogs.show_dialog(quest_dialog, character_name)
35-
return
25+
# Bail if npc not active (player not inside the collider)
26+
if not active:
27+
return
28+
# Bail if Dialogs singleton is showing another dialog
29+
if Dialogs.active:
30+
return
31+
# Bail if the event is not a pressed "interact" action
32+
if not event.is_action_pressed("interact"):
33+
return
34+
35+
# If the character is a questgiver delegate getting the text
36+
# to the Quest node, show it and end the function
37+
if has_node("Quest"):
38+
var quest_dialog = get_node("Quest").process()
39+
if quest_dialog != "":
40+
Dialogs.show_dialog(quest_dialog, character_name)
41+
return
42+
43+
# If we reached here and there are generic dialogs to show, rotate among them
44+
if not dialogs.empty():
3645
Dialogs.show_dialog(dialogs[current_dialog], character_name)
3746
current_dialog = wrapi(current_dialog + 1, 0, dialogs.size())
3847

0 commit comments

Comments
 (0)