Exposed Quest Flags to Dialogue System

This commit is contained in:
Philip W 2023-05-04 06:31:59 +01:00
parent fc9597ed33
commit daaa624dd9
8 changed files with 33 additions and 9 deletions

Binary file not shown.

Binary file not shown.

BIN
Content/Levels/Build.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -6,6 +6,7 @@
#include "Components/TextBlock.h" #include "Components/TextBlock.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "Kismet/KismetStringLibrary.h" #include "Kismet/KismetStringLibrary.h"
#include "Misc/OutputDeviceNull.h"
#include "the_twilight_abyss/Quest/QuestSystem.h" #include "the_twilight_abyss/Quest/QuestSystem.h"
// Sets default values for this component's properties // Sets default values for this component's properties
@ -115,6 +116,9 @@ void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom
void UDialogueNPC::StartDialogue() void UDialogueNPC::StartDialogue()
{ {
FOutputDeviceNull AR;
const FString Command = FString::Printf(TEXT("SetRootDialoguePath"));
GetOwner()->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
if (IsValid(RootDialoguePath)) CurrentDialogueStringPath = RootDialoguePath->Dialogue; if (IsValid(RootDialoguePath)) CurrentDialogueStringPath = RootDialoguePath->Dialogue;
if (CurrentDialogueStringPath.IsEmpty()) if (CurrentDialogueStringPath.IsEmpty())
{ {
@ -162,8 +166,8 @@ void UDialogueNPC::EndDialogue()
UDialoguePath* UDialogueNPC::CreateRootDialoguePath() UDialoguePath* UDialogueNPC::CreateRootDialoguePath()
{ {
RootDialoguePath = NewObject<UDialoguePath>(); //RootDialoguePath = NewObject<UDialoguePath>();
return RootDialoguePath; return NewObject<UDialoguePath>();
} }
UDialoguePath* UDialogueNPC::AddDialogue(UDialoguePath* DialoguePath, FText TextInput) UDialoguePath* UDialogueNPC::AddDialogue(UDialoguePath* DialoguePath, FText TextInput)

View File

@ -35,7 +35,7 @@ public:
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
FString NPCName; FString NPCName;
UPROPERTY() UPROPERTY(BlueprintReadWrite)
UDialoguePath* RootDialoguePath; UDialoguePath* RootDialoguePath;
UPROPERTY() UPROPERTY()
UDialoguePath* CurrentDialoguePath; UDialoguePath* CurrentDialoguePath;

View File

@ -34,6 +34,10 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Instanced) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Instanced)
TArray<UBaseItem*> Rewards; TArray<UBaseItem*> Rewards;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TMap<FString, bool> QuestFlagsOnAdd;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TMap<FString, bool> QuestFlagsOnComplete;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
bool bShowQuestCompletedNotification = true; bool bShowQuestCompletedNotification = true;
bool CheckConditions(UWorldState* WorldState) const; bool CheckConditions(UWorldState* WorldState) const;

View File

@ -60,6 +60,10 @@ void UQuestSystem::CheckActiveQuestConditions()
{ {
CompletedQuests.Add(Quest); CompletedQuests.Add(Quest);
Quest->ApplyRewards(PlayerInventory); Quest->ApplyRewards(PlayerInventory);
for (TTuple<FString, bool> QuestFlag : Quest->QuestFlagsOnComplete)
{
QuestFlags.Add(QuestFlag.Key, QuestFlag.Value);
}
QuestCompletionTitle->SetText(Quest->Title); QuestCompletionTitle->SetText(Quest->Title);
if (Quest->QuestLine == EQuestLine::Sub) if (Quest->QuestLine == EQuestLine::Sub)
{ {
@ -90,6 +94,10 @@ bool UQuestSystem::AddQuest(UQuest* Quest)
if (HasActiveQuest(Quest)) return false; if (HasActiveQuest(Quest)) return false;
if (!Quest->CheckPreConditions(GetWorldState())) return false; if (!Quest->CheckPreConditions(GetWorldState())) return false;
ActiveQuests.Add(Quest); ActiveQuests.Add(Quest);
for (TTuple<FString, bool> QuestFlag : Quest->QuestFlagsOnAdd)
{
QuestFlags.Add(QuestFlag.Key, QuestFlag.Value);
}
if (Quest->QuestLine == EQuestLine::Sub) if (Quest->QuestLine == EQuestLine::Sub)
{ {
bHasSubQuest = true; bHasSubQuest = true;
@ -123,6 +131,12 @@ bool UQuestSystem::HasActiveQuest(UQuest* Quest) const
return false; return false;
} }
bool UQuestSystem::HasQuestFlag(FString FlagName) const
{
if (QuestFlags.Contains(FlagName)) return true;
return false;
}
void UQuestSystem::UpdateQuestGoalsUI(const UQuest* Quest) const void UQuestSystem::UpdateQuestGoalsUI(const UQuest* Quest) const
{ {
FString GoalsText; FString GoalsText;

View File

@ -61,6 +61,8 @@ public:
bool CheckPreConditions(UQuest* Quest) const; bool CheckPreConditions(UQuest* Quest) const;
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
bool HasActiveQuest(UQuest* Quest) const; bool HasActiveQuest(UQuest* Quest) const;
UFUNCTION(BlueprintCallable)
bool HasQuestFlag(FString FlagName) const;
private: private:
UInventoryComponent* PlayerInventory; UInventoryComponent* PlayerInventory;