Quest ​
Inherits: DatabaseResource < Resource
Main quest resource that handles objectives, rewards, and quest state
Properties ​
int | level | 0 |
FailureBehavior | on_fail | FailureBehavior.USE_DEFAULT |
AbandonRule | abandonable | AbandonRule.USE_DEFAULT |
Array[EventAction] | on_abandon_actions | [] |
Array[QuestObjective] | objectives | [] |
int | last_objective_number | 0 |
Array[Reward] | rewards | [] |
Array[Requirement] | requirements | [] |
bool | requires_hand_in | false |
String | turn_in_text | "": |
SFXSelection | accept_voice_line | null |
SFXSelection | journal_voice_line | null |
SFXSelection | hand_in_voice_line | null |
LessonCost | hand_in_cost | null |
bool | is_repeatable | false |
int | repeat_limit | 0 |
CooldownType | cooldown_type | CooldownType.NONE |
ChronoManager.TimeSource | cooldown_time_source | ChronoManager.TimeSource.GAME |
float | cooldown_duration_hours | 24.0 |
int | cooldown_reset_hour | 6 |
Array[EventAction] | on_start_actions | [] |
Array[EventAction] | on_complete_actions | [] |
Variables ​
QuestState | state | QuestState.INACTIVE |
int | completion_count | 0 |
float | cooldown_start_time | 0.0 |
float | cooldown_end_time | 0.0 |
ChronoManager | chrono_manager | |
GameHost.SystemHub | system_hub |
Methods ​
Signals ​
quest_state_changed( quest: Quest ) ​
Emitted when quest state changes
objective_completed( quest: Quest, objective: QuestObjective ) ​
Emitted when an objective is completed
quest_abandoned( quest: Quest ) ​
Emitted when the player gives the quest up (it is not a failure: nothing that waits for a quest to fail is told)
reward_applied( quest: Quest, reward: Reward ) ​
Emitted when a reward is applied
reward_blocked( quest: Quest, reason: String ) ​
Emitted when a quest could not complete because its rewards do not fit (the player was warned)
quest_cooldown_ended( quest: Quest ) ​
Emitted when quest cooldown ends and can be repeated
Enumerations ​
enum QuestState ​
The options of quest state: inactive, active, ready to hand in, completed, failed, on cooldown.
- INACTIVE =
0 - ACTIVE =
1 - READY_TO_HAND_IN =
2 - COMPLETED =
3 - FAILED =
4 - ON_COOLDOWN =
5
enum FailureBehavior ​
What happens when the quest fails
- USE_DEFAULT =
0- What the gameplay settings say (default_quest_failure) - FINAL =
1- The quest is over: it cannot be taken again - RETRY =
2- The quest can be taken again (it starts from the beginning) - GAME_OVER =
3- Failing the quest ends the game
enum AbandonRule ​
Can the player give the quest up?
- USE_DEFAULT =
0- What the gameplay settings say (allow_quest_abandon) - YES =
1 - NO =
2
enum CooldownType ​
The options of cooldown type: none, duration, clock.
- NONE =
0- No cooldown, can repeat immediately - DURATION =
1- Cooldown based on game time duration - CLOCK =
2- Cooldown resets at specific time of day
Property descriptions ​
int level = 0 ​
The level of player this quest is meant for (0 = the quest has no level). It is only shown to the player: what is needed to start the quest is a requirement
FailureBehavior on_fail = FailureBehavior.USE_DEFAULT ​
What happens when the quest fails
AbandonRule abandonable = AbandonRule.USE_DEFAULT ​
Can the player give this quest up? (the quest goes back to the start and can be taken again)
Array[EventAction] on_abandon_actions = [] ​
Executed when the player gives the quest up (to take back what the quest gave: a quest item, a spawned guard)
Array[QuestObjective] objectives = [] ​
List of objectives that must be completed
int last_objective_number = 0 ​
The highest objective number ever given in this quest: the next new objective gets the number after it, so a number is never used twice (a deleted objective keeps its number empty)
Array[Reward] rewards = [] ​
Rewards granted to the player when quest is completed
Array[Requirement] requirements = [] ​
Requirements the player must meet to accept this quest
bool requires_hand_in = false ​
If true, quest requires manual hand-in after objectives are complete
String turn_in_text = "": ​
Text displayed by NPC when handing in quest
SFXSelection accept_voice_line = null ​
The voice line spoken when the quest is accepted (a voice line: the language folders apply). It plays on the Voice bus, heard from nowhere, with its subtitle
SFXSelection journal_voice_line = null ​
The voice line spoken when the quest is read in the journal
SFXSelection hand_in_voice_line = null ​
The voice line spoken when the quest is handed in (the NPC speaks it with the hand-in text)
LessonCost hand_in_cost = null ​
What the player pays when the quest completes (when it is handed in, for a hand-in quest): items and currency taken from the bag of the player (the shared bag, when the party shares it). The quest does not complete until the player can pay all of it. Null = the quest costs nothing
bool is_repeatable = false ​
If true, quest can be repeated after completion
int repeat_limit = 0 ​
Maximum times this quest can be completed (0 = unlimited)
CooldownType cooldown_type = CooldownType.NONE ​
Type of cooldown between repeats
ChronoManager.TimeSource cooldown_time_source = ChronoManager.TimeSource.GAME ​
The clock the cooldown counts on: the game world (default), the hours of play, or the real clock (UTC). The reset hour of "Reset at Time" is read on the game clock or the real one
float cooldown_duration_hours = 24.0 ​
Duration cooldown in hours of the clock above (only used if cooldown_type == DURATION)
int cooldown_reset_hour = 6 ​
Hour of day when quest resets (0-23, only used if cooldown_type == CLOCK)
Array[EventAction] on_start_actions = [] ​
Triggers executed when quest is activated (for world-state changes)
Array[EventAction] on_complete_actions = [] ​
Triggers executed when quest is completed (for world-state changes)
Variable descriptions ​
QuestState state = QuestState.INACTIVE ​
Current state of the quest
int completion_count = 0 ​
Number of times this quest has been completed
float cooldown_start_time = 0.0 ​
Game time when cooldown started (for duration cooldown)
float cooldown_end_time = 0.0 ​
The running game clock (total game hours, which never wraps) at which the cooldown ends
ChronoManager chrono_manager ​
System Refs
GameHost.SystemHub system_hub ​
The hub of the game systems.
Method descriptions ​
void assign_objective_numbers() ​
Gives every objective a permanent number (what events, conversations and saved games use to find it). The first time, the objectives are numbered by their place (1 is the first); an objective added later gets the next number that was never used, so moving, duplicating or deleting objectives never changes the number of another one and saved games stay right
void set_system_hub( p_system_hub: GameHost.SystemHub ) ​
Gives the quest, its objectives and its rewards the hub of the game systems.
bool can_start() ​
Can the quest be started now? It must be waiting (not running, not handed in, not on a cooldown); a quest that was done once is only taken again when it is repeatable and has repeats left; a failed one only when failing does not end it for good (see get_failure_behavior)
bool activate( forced: bool = false ) ​
Activates the quest and its objectives. False when it cannot start (see can_start). forced is for an event: the event decides, so a quest that was done, failed for good or is on a cooldown starts again from the beginning (a quest that is running stays as it is: false)
bool complete() ​
Marks the quest as completed and grants rewards. False when it did not complete: when the player cannot pay the hand-in cost, or has no room for an item reward, the player is warned and the quest waits (it completes by itself when it is possible, a hand-in quest when it is handed in again)
void fail() ​
Marks the quest as failed
FailureBehavior get_failure_behavior() ​
What failing this quest means: the quest's own setting, or the default of the gameplay settings (FINAL, RETRY or GAME_OVER)
bool is_abandonable() ​
Can the player give this quest up? (the quest's own setting, or the default of the gameplay settings)
bool abandon() ​
The player gives the quest up: it goes back to the start (nothing is kept: not the progress, not a count of completions) and can be taken again. It is not a failure. False when the quest is not running or cannot be given up
void reset_to_initial_state() ​
Everything as in a new game: not started, never completed, no cooldown
void reset() ​
Reset quest to inactive state (used for repeatable quests)
void connect_objectives() ​
Connects signals for all objectives
void on_objective_state_changed( objective: QuestObjective ) ​
Handler for objective state changes
void update_objectives() ​
Checks if all objectives are completed to update quest state
bool complete_objective( objective_id: int ) ​
Completes a specific objective by its number (1 is the first). False when the quest is not running or has no such objective that is still open
bool fail_objective( objective_id: int ) ​
Fails a specific objective by ID
bool is_ready_to_hand_in() ​
Returns true if quest is ready to hand in
String get_turn_in_text() ​
The text of the hand-in (in the language of the player), or "Quest complete." when there is none
bool can_repeat() ​
Check if quest can be repeated
bool can_accept( entity: Entity = null ) ​
Check if an entity meets all requirements to accept this quest
Array[Requirement] get_failed_requirements( entity: Entity = null ) ​
Get all failed requirements for an entity
Array[String] get_requirement_failure_messages( entity: Entity = null ) ​
Get failure messages for all unmet requirements
String get_requirements_summary() ​
Get a summary of all requirements
bool has_requirements() ​
Check if quest has requirements
int get_requirement_count() ​
Get requirement count
bool has_reached_repeat_limit() ​
Check if quest has reached its repeat limit
int get_remaining_repeats() ​
Get remaining repeats (0 = unlimited, -1 = none left)
bool is_on_cooldown() ​
Check if quest is on cooldown
float get_remaining_cooldown_hours() ​
Get remaining cooldown time in game hours (for duration cooldown)
bool has_hand_in_cost() ​
Does the quest cost something when it completes?
String get_hand_in_cost_text() ​
What the hand-in costs, as text ("10 Boar Meat, 5 Gold"; empty when it costs nothing)
String get_hand_in_blocker( player: Player = null ) ​
Why the player cannot pay the hand-in cost ("" = they can, or there is none)
void add_reward( reward: Reward ) ​
Add a reward to this quest
bool remove_reward( reward: Reward ) ​
Remove a reward from this quest
void clear_rewards() ​
Clear all rewards
String get_rewards_summary() ​
Get a summary of all rewards
bool has_rewards() ​
Check if quest has rewards
int get_reward_count() ​
Get reward count
GameplayConfig.QuestLevelDifficulty get_level_difficulty( player_level: int ) ​
How hard the quest is for a player of this level (NORMAL for a quest without a level)
String get_level_text() ​
The level as the player reads it ("[Lv 12]"), empty for a quest without a level or when the settings hide quest levels
String get_display_title( player: Entity = null ) ​
The name of the quest as the HUD shows it: its name with the words <like this> filled in, and its level in front
String get_display_description( player: Entity = null ) ​
The description of the quest with the words <like this> filled in
bool is_completed() ​
Returns true if quest is completed
bool is_failed() ​
Returns true if quest is failed
bool is_active() ​
Returns true if quest is active
bool is_inactive() ​
Returns true if quest is inactive
Array[Dictionary] validate() ​
Checks the quest. Gives the problems found (empty when it is fine).
bool is_valid() ​
Is the quest free of errors?
Dictionary save_quest_data() ​
Creates a dictionary with essential quest state for saving
void load_quest_data( data: Dictionary ) ​
Loads quest state from saved data
Dictionary get_summary() ​
A short summary of the quest (id, name, state ...) as a dictionary.