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))]); Cast<UQuestSystem>(GetWorld()->GetFirstPlayerController()->GetPawn()->GetComponentByClass(UQuestSystem::StaticClass()))->AddQuest(Quests[UKismetStringLibrary::Conv_StringToInt(CurrentDialogueStringPath[DialogueIndex].RightChop(3))]);
DialogueIndex++; 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++; DialogueIndex++;
NextArrow->SetVisibility(ESlateVisibility::Hidden); NextArrow->SetVisibility(ESlateVisibility::Hidden);
@ -201,6 +208,13 @@ UDialoguePath* UDialogueNPC::AddQuest(UDialoguePath* DialoguePath, UQuest* Quest
return DialoguePath; 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() void UDialogueNPC::Choice1()
{ {
CurrentDialoguePath = CurrentDialoguePath->Choices[0]; CurrentDialoguePath = CurrentDialoguePath->Choices[0];

View File

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