ConversationInstance ​
Inherits: RefCounted
Runtime instance of a Conversation resource Keeps the underlying resource immutable by tracking all mutable state here
Variables ​
Conversation | conversation | |
Dictionary | response_states | {} |
Dictionary | response_history | {} |
int | starting_chat_override | 0 |
ConversationChat | active_chat | null |
Entity | active_player | null |
Variant | source_entity | null |
bool | is_active | false |
Quest | active_hand_in_quest | null |
Quest | active_offer_quest | null |
Dictionary | cached_interactions | {} |
EventManager | event_manager |
Methods ​
void | reset_to_defaults() |
void | initialize_interactions( system_hub: GameHost.SystemHub ) |
Interaction | get_cached_interaction( interaction_resource: Interaction ) |
bool | is_response_active( response_id: int ) |
void | set_response_state( response_id: int, state: bool ) |
Dictionary | get_response_states() |
void | load_response_states( states: Dictionary ) |
void | mark_response_seen( response_id: int ) |
bool | has_response_been_seen( response_id: int ) |
Array[int] | get_seen_responses() |
Dictionary | get_response_history() |
void | load_response_history( history: Dictionary ) |
void | set_starting_chat_override( chat_id: int ) |
int | get_starting_chat_override() |
void | clear_starting_chat_override() |
int | get_id() |
ConversationChat | get_chat_by_id( chat_id: int ) |
ConversationChat | get_first_chat() |
int | get_next_chat_id() |
ConversationResponse | get_response_by_id( response_id: int ) |
int | get_next_response_id() |
Array[ConversationResponse] | get_responses_for_chat( chat_id: int ) |
ConversationDiceRoll | get_dice_roll_by_id( dice_roll_id: int ) |
int | get_next_dice_roll_id() |
Array[Quest] | get_available_hand_in_quests() |
bool | has_available_hand_in_quests() |
bool | is_in_hand_in_state() |
void | start_quest_hand_in( quest: Quest ) |
void | complete_quest_hand_in() |
void | cancel_quest_hand_in() |
Array[Quest] | get_available_offer_quests() |
bool | has_available_offer_quests() |
bool | is_in_offer_state() |
void | start_quest_offer( quest: Quest ) |
void | accept_quest_offer() |
void | decline_quest_offer() |
ConversationChat | start_conversation( player: Entity, npc: NPC = null ) |
void | end_conversation() |
void | proceed_to_chat( target_chat: ConversationChat, _player: Entity ) |
Array[Dictionary] | get_response_data_for_current_chat() |
Array[Dictionary] | get_response_data_for_chat( chat: ConversationChat, player: Entity ) |
Array[ConversationResponse] | get_available_responses_for_current_chat() |
Array[ConversationResponse] | get_available_responses_for_chat( chat: ConversationChat, player: Entity ) |
void | execute_response_actions( response: ConversationResponse, player: Entity ) |
Dictionary | get_save_data() |
void | load_save_data( data: Dictionary ) |
Signals ​
conversation_started( starting_chat: ConversationChat ) ​
========== SIGNALS ==========
conversation_ended() ​
Emitted when the conversation ends.
chat_changed( new_chat: ConversationChat ) ​
Emitted when the conversation moves to another chat (a line of the NPC).
dice_roll_completed( roll_result: Dictionary ) ​
Emitted when a dice roll of the conversation is rolled, with its result.
switch_interaction_requested( target_interaction: Interaction, player: Entity ) ​
Emitted when the conversation asks to continue in another interaction of the NPC (a vendor, a trainer ...).
quest_hand_in_started( quest: Quest ) ​
Emitted when the player starts to hand in a quest in the conversation.
quest_hand_in_completed( quest: Quest ) ​
Emitted when the quest is handed in.
quest_offer_started( quest: Quest ) ​
Emitted when the NPC offers a quest.
quest_offer_accepted( quest: Quest ) ​
Emitted when the player accepts the offered quest.
quest_offer_declined( quest: Quest ) ​
Emitted when the player declines the offered quest.
Variable descriptions ​
Conversation conversation ​
The underlying conversation resource (immutable)
Dictionary response_states = ​
Runtime state - response active states (response_id -> bool)
Dictionary response_history = ​
Response history - tracks which responses the player has selected (response_id -> true)
int starting_chat_override = 0 ​
Override for starting chat (0 = use default start_entries evaluation)
ConversationChat active_chat = null ​
Current conversation state
Entity active_player = null ​
The player who is talking.
Variant source_entity = null ​
The NPC or entity this conversation belongs to
bool is_active = false ​
True while the conversation runs.
Quest active_hand_in_quest = null ​
Quest hand-in state
Quest active_offer_quest = null ​
Quest offer state
Dictionary cached_interactions = ​
Cached interactions that can be triggered from this conversation Key: Interaction resource, Value: Initialized interaction instance
EventManager event_manager ​
SystemRefs
Method descriptions ​
void reset_to_defaults() ​
Reset all runtime state to defaults (for loading saves)
void initialize_interactions( system_hub: GameHost.SystemHub ) ​
Initialize all interactions referenced in conversation actions Should be called after source_entity is set
Interaction get_cached_interaction( interaction_resource: Interaction ) ​
Get a cached interaction instance by its resource
bool is_response_active( response_id: int ) ​
Get whether a response is currently active
void set_response_state( response_id: int, state: bool ) ​
Set a response's active state
Dictionary get_response_states() ​
Get all response states for serialization
void load_response_states( states: Dictionary ) ​
Load response states from save data (a save is JSON: the ids come back as text)
void mark_response_seen( response_id: int ) ​
Mark a response as seen/selected by the player
bool has_response_been_seen( response_id: int ) ​
Check if a response has been seen/selected by the player
Array[int] get_seen_responses() ​
Get all seen response IDs
Dictionary get_response_history() ​
Get response history for serialization
void load_response_history( history: Dictionary ) ​
Load response history from save data
void set_starting_chat_override( chat_id: int ) ​
Set which chat the conversation should start from (overrides start_entries)
int get_starting_chat_override() ​
Get the current starting chat override (0 = none)
void clear_starting_chat_override() ​
Clear the starting chat override (revert to start_entries evaluation)
int get_id() ​
The id of the conversation.
ConversationChat get_chat_by_id( chat_id: int ) ​
The chat (a line of the NPC) with this id.
ConversationChat get_first_chat() ​
The chat the conversation starts with.
int get_next_chat_id() ​
The next free chat id (for the editor).
ConversationResponse get_response_by_id( response_id: int ) ​
The response (an answer of the player) with this id.
int get_next_response_id() ​
The next free response id (for the editor).
Array[ConversationResponse] get_responses_for_chat( chat_id: int ) ​
The responses of a chat.
ConversationDiceRoll get_dice_roll_by_id( dice_roll_id: int ) ​
The dice roll with this id.
int get_next_dice_roll_id() ​
The next free dice roll id (for the editor).
Array[Quest] get_available_hand_in_quests() ​
Get all quests that are ready to hand in for this conversation
bool has_available_hand_in_quests() ​
Check if there are any quests available for hand-in
bool is_in_hand_in_state() ​
Check if we're currently in a quest hand-in state
void start_quest_hand_in( quest: Quest ) ​
Start the quest hand-in process for a specific quest
void complete_quest_hand_in() ​
Complete the current quest hand-in and end the conversation
void cancel_quest_hand_in() ​
Cancel the quest hand-in and return to normal conversation
Array[Quest] get_available_offer_quests() ​
Get all quests that can be offered (player meets requirements and the quest can be started)
bool has_available_offer_quests() ​
Check if there are any quests available for offer
bool is_in_offer_state() ​
Check if we're currently in a quest offer state
void start_quest_offer( quest: Quest ) ​
Start the quest offer process for a specific quest
void accept_quest_offer() ​
Accept the current quest offer
void decline_quest_offer() ​
Decline the current quest offer and return to normal conversation
ConversationChat start_conversation( player: Entity, npc: NPC = null ) ​
Start the conversation with a player
void end_conversation() ​
End the conversation and cleanup
void proceed_to_chat( target_chat: ConversationChat, _player: Entity ) ​
Proceed to a new chat
Array[Dictionary] get_response_data_for_current_chat() ​
Get response data for the current chat with requirement status Returns Array[Dictionary] with format: {"response": ConversationResponse, "requirements_met": bool}
Array[Dictionary] get_response_data_for_chat( chat: ConversationChat, player: Entity ) ​
Get response data for a specific chat with requirement status Returns Array[Dictionary] with format: {"response": ConversationResponse, "requirements_met": bool} Skips responses where runtime state is inactive
Array[ConversationResponse] get_available_responses_for_current_chat() ​
Get available responses for the current chat (only those that pass requirements)
Array[ConversationResponse] get_available_responses_for_chat( chat: ConversationChat, player: Entity ) ​
Get available responses for a specific chat
void execute_response_actions( response: ConversationResponse, player: Entity ) ​
Execute a response's actions
Dictionary get_save_data() ​
Get save data for this conversation instance
void load_save_data( data: Dictionary ) ​
Load state from save data