Quest Manager
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
AQSQuestManagerComponentto thePlayerController.
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 totruein multiplayer when placed in theGameState.QuestsDB: Assign aUDataTablethat holds all quest definitions.
Event Bindings:
Use delegate properties like
OnQuestStarted,OnQuestEnded, andOnObjectiveCompletedto trigger custom logic during quest events.
Key Features
Quest Management:
Start a Quest: Use
StartQuestorServerStartQuestto begin a quest.Stop a Quest: Use
StopQuestto interrupt a quest and reset its state.Track a Quest: Use
TrackInProgressQuestorTrackInProgressQuestByTagto set a quest as the tracked one.
Objective Management:
Complete Objective: Use
CompleteObjectiveto complete an objective in a quest.Complete Branched Objective: Use
CompleteBranchedObjectiveto complete objectives with specific transition filters.Query Objectives: Use
IsObjectiveInProgressorIsObjectiveCompletedByTagto check the state of an objective.
Replication:
Replicates quest states and updates to ensure synchronization in multiplayer environments.
Key replicated properties include:
CompletedQuestsTagsFailedQuestsTagsInProgressQuestsRecordsTrackedQuestTag
Database Integration:
Quests are retrieved and instantiated from the
QuestsDBdata table.Objectives and targets can also be accessed through the database.
Target Management:
Use
GetAllTargetsWithTagorGetAllTargetsWithTagsto 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.
Event Dispatchers
The system supports Blueprint events for dynamic quest interactions.
Events
OnQuestStarted– Triggered when a quest starts.OnQuestEnded– Triggered when a quest ends.OnObjectiveStarted– Triggered when an objective starts.OnObjectiveCompleted– Triggered when an objective is completed.OnObjectiveUpdated– Triggered when an objective is updated.
These events can be used to update UI, play animations, or trigger story sequences dynamically.
Debugging Functions
Debugging tools allow for manual quest progression, objective completion, and removal of quests.
Functions
UFUNCTION(BlueprintCallable, Category = AQS)
void DEBUG_ProceedQuest(const FGameplayTag& inProgressQuest);
UFUNCTION(BlueprintCallable, Category = AQS)
void DEBUG_ProceedTrackedQuest();
UFUNCTION(BlueprintCallable, Category = AQS)
void DEBUG_RemoveInProgressQuest(const FGameplayTag& inProgressQuest);