nathanhoad / godot_dialogue_manager

A powerful nonlinear dialogue system for Godot
MIT License
2.22k stars 170 forks source link

Response polling. #394

Closed teebarjunk closed 1 year ago

teebarjunk commented 1 year ago

Is your feature request related to a problem? Please describe. Allow menu's to poll state objects for responses.

Describe the solution you'd like So instead of doing...

Bob: What do you need?
- Here is the item [if questGotTheItem.is_completed()]
    => quest/bob_got_item
- More health packs [if player.health <= 10]
    => gain_healthpack
- Nevermind

It could simply be:

Bob: What do you need? [#menu=bob]
- Nevermind

And DialogueManager could have a signal like response_requested(menu_id: String, list: Array[DialogueLine]) called inside the get_responses. (Though it would need a reference to the line.)

And then state objects could do:

# quest.gd
func _response_requested(menu_id: String, list: Array[DialogueLine]):
    if menu_id == "bob" and self.is_completed():
        list.append(DialogueManager.create_dialogue_line({
            "type": DialogueConstants.TYPE_RESPONSE,
            "text": "Here is the item",
            "next_id": "quest/bob_got_item"})

# player.gd
func _response_requested(menu_id: String, list: Array[DialogueLine]):
    if menu_id == "bob" and self.health <= 10:
        list.append(DialogueManager.create_dialogue_line({
            "type":DialogueConstants.TYPE_RESPONSE,
            "text": "More health packs",
            "next_id": "gain_healthpack"})

Describe alternatives you've considered I could maybe use the DialogueManager.got_dialogue signal, and then in the DialogueResponsesMenu have it do the polling, but that seems less robust.

Additional context This feature is probably not useful enough for most people, but for me it make quest systems less spagetti.

nathanhoad commented 1 year ago

Thanks for the suggestion but this isn't something that I want to add to the Dialogue Manager. There are users that have implemented something similar in their own games by using mutations.