Quest Manager {{ currentPage ? currentPage.title : "" }}

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

  1. Add the Component:

    • Add the AQSQuestManagerComponent to any actor (e.g., PlayerController or GameState).

    • For multiplayer, if quests are shared across players, add it to the GameState.

  2. 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 to true in multiplayer when placed in the GameState.

    • QuestsDB: Assign a UDataTable that holds all quest definitions.

  3. Event Bindings:

    • Use delegate properties like OnQuestStarted, OnQuestEnded, and OnObjectiveCompleted to trigger custom logic during quest events.

Key Features

  1. Quest Management:

    • Start a Quest: Use StartQuest or ServerStartQuest to begin a quest.

    • Stop a Quest: Use StopQuest to interrupt a quest and reset its state.

    • Track a Quest: Use TrackInProgressQuest or TrackInProgressQuestByTag to set a quest as the tracked one.

  2. 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 or IsObjectiveCompletedByTag to check the state of an objective.

  3. Replication:

    • Replicates quest states and updates to ensure synchronization in multiplayer environments.

    • Key replicated properties include:

      • CompletedQuestsTags

      • FailedQuestsTags

      • InProgressQuestsRecords

      • TrackedQuestTag

  4. Database Integration:

    • Quests are retrieved and instantiated from the QuestsDB data table.

    • Objectives and targets can also be accessed through the database.

  5. Target Management:

    • Use GetAllTargetsWithTag or GetAllTargetsWithTags 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.

{{{ content }}}