Updated Dialogue System to Call Custom Blueprint Functions

This commit is contained in:
Philip W 2023-05-11 06:32:11 +01:00
parent 2ddb44d070
commit fea2ccface
4 changed files with 23 additions and 4 deletions

Binary file not shown.

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

Binary file not shown.

View File

@ -64,6 +64,13 @@ void UDialogueNPC::NextDialogue()
Cast<UQuestSystem>(GetWorld()->GetFirstPlayerController()->GetPawn()->GetComponentByClass(UQuestSystem::StaticClass()))->AddQuest(Quests[UKismetStringLibrary::Conv_StringToInt(CurrentDialogueStringPath[DialogueIndex].RightChop(3))]);
DialogueIndex++;
}
else if (CurrentDialogueStringPath[FMath::Clamp(DialogueIndex + 1, 0, CurrentDialogueStringPath.Num() - 1)].Mid(0, 2) == "@@")
{
FOutputDeviceNull AR;
const FString Command = BlueprintFunctions[UKismetStringLibrary::Conv_StringToInt(CurrentDialogueStringPath[DialogueIndex].RightChop(3))];;
GetOwner()->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
DialogueIndex++;
}
DialogueIndex++;
NextArrow->SetVisibility(ESlateVisibility::Hidden);
@ -201,6 +208,13 @@ UDialoguePath* UDialogueNPC::AddQuest(UDialoguePath* DialoguePath, UQuest* Quest
return DialoguePath;
}
UDialoguePath* UDialogueNPC::CallBlueprintFunction(UDialoguePath* DialoguePath, const FString FunctionName)
{
DialoguePath->Dialogue.Add(FText::FromString("@@ " + FunctionName).ToString());
BlueprintFunctions.Add(BlueprintFunctions.Num(), FunctionName);
return DialoguePath;
}
void UDialogueNPC::Choice1()
{
CurrentDialoguePath = CurrentDialoguePath->Choices[0];

View File

@ -94,6 +94,8 @@ private:
UPROPERTY()
TMap<int, UQuest*> Quests;
UPROPERTY()
TMap<int, FString> BlueprintFunctions;
void ResetDialogueUI();
@ -118,6 +120,9 @@ public:
UFUNCTION(BlueprintCallable)
UDialoguePath* AddQuest(UDialoguePath* DialoguePath, UQuest* Quest);
UFUNCTION(BlueprintCallable)
UDialoguePath* CallBlueprintFunction(UDialoguePath* DialoguePath, FString FunctionName);
UFUNCTION()
void Choice1();