Overview
The AQSQuestManagerComponent is a core part of the Ascent Quest System, responsible for managing quests, objectives, and their states. It supports both single-player and multiplayer environments, with features such as replication, quest tracking, objective completion, and database integration.
Setup and Configuration
Add the Component:
Add the
AQSQuestManagerComponent
to any actor (e.g.,PlayerController
orGameState
).For multiplayer, if quests are shared across players, add it to the
GameState
.
Configure Properties:
bAutoTrackQuest
: Automatically tracks a new quest if no quest is currently tracked.bTeamQuests
: Allows quests to be completed by any player in a team. Set this totrue
in multiplayer when placed in theGameState
.QuestsDB
: Assign aUDataTable
that holds all quest definitions.
Event Bindings:
Use delegate properties like
OnQuestStarted
,OnQuestEnded
, andOnObjectiveCompleted
to trigger custom logic during quest events.
Key Features
Quest Management:
Start a Quest: Use
StartQuest
orServerStartQuest
to begin a quest.Stop a Quest: Use
StopQuest
to interrupt a quest and reset its state.Track a Quest: Use
TrackInProgressQuest
orTrackInProgressQuestByTag
to set a quest as the tracked one.
Objective Management:
Complete Objective: Use
CompleteObjective
to complete an objective in a quest.Complete Branched Objective: Use
CompleteBranchedObjective
to complete objectives with specific transition filters.Query Objectives: Use
IsObjectiveInProgress
orIsObjectiveCompletedByTag
to check the state of an objective.
Replication:
Replicates quest states and updates to ensure synchronization in multiplayer environments.
Key replicated properties include:
CompletedQuestsTags
FailedQuestsTags
InProgressQuestsRecords
TrackedQuestTag
Database Integration:
Quests are retrieved and instantiated from the
QuestsDB
data table.Objectives and targets can also be accessed through the database.
Target Management:
Use
GetAllTargetsWithTag
orGetAllTargetsWithTags
to retrieve all quest target components with specific tags.QuestManagerComponent* QuestManager = ...; // Retrieve the component FGameplayTag QuestTag = FGameplayTag::RequestGameplayTag(FName("Quest_Example")); if (QuestManager->StartQuest(QuestTag)) { UE_LOG(LogTemp, Log, TEXT("Quest started successfully!")); } else { UE_LOG(LogTemp, Warning, TEXT("Failed to start quest.")); }
Completing an Objective
FGameplayTag ObjectiveTag = FGameplayTag::RequestGameplayTag(FName("Objective_Example"));
if (QuestManager->CompleteObjective(ObjectiveTag)) {
UE_LOG(LogTemp, Log, TEXT("Objective completed successfully!"));
} else {
UE_LOG(LogTemp, Warning, TEXT("Objective completion failed."));
}
Querying Quest State
if (QuestManager->IsQuestInProgressByTag(QuestTag)) {
UE_LOG(LogTemp, Log, TEXT("The quest is in progress."));
} else {
UE_LOG(LogTemp, Log, TEXT("The quest is not in progress."));
}
Blueprint API
Quest Management
StartQuest(FGameplayTag questTag)
: Starts a quest by its tag.StopQuest(FGameplayTag questTag)
: Stops a quest and resets its state.TrackInProgressQuest(UAQSQuest* questToTrack)
: Tracks the specified in-progress quest.
Objective Management
CompleteObjective(FGameplayTag objectiveToComplete)
: Completes an objective in an in-progress quest.CompleteBranchedObjective(FGameplayTag objectiveToComplete, TArray<FName> optionalTransitionFilters)
: Completes a branched objective.
Data Retrieval
GetQuestFromDB(FGameplayTag questTag)
: Retrieves a quest from the database by its tag.GetQuest(FGameplayTag questTag)
: Gets a quest instance by its tag.GetCurrentlyTrackedQuest()
: Gets the currently tracked quest.GetCurrentlyTrackedQuestObjectives()
: Gets objectives of the tracked quest.
Target Management
GetAllTargetsWithTag(FGameplayTag targetTag)
: Retrieves all targets with a specific tag.GetAllTargetsWithTags(TArray<FGameplayTag> targetTags)
: Retrieves all targets with specific tags.