From 902163d4fe56f7b2a6538a146287175b9ab8339a Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Thu, 11 May 2023 08:52:30 +0100 Subject: [PATCH] Updated Merchant for Pendant Quest & Attempted to Replace Open Dialogue --- .../Characters/Merchant/AMerchant.uasset | 4 +- .../Combat_UI/CombatCharacter.uasset | 4 +- .../Quests/Quest_SistersPendant.uasset | 4 +- .../Quests/Quest_SistersPendant_PT2.uasset | 3 + Content/Dialogue/SM_Merchant_Blueprint.uasset | 4 +- Content/Levels/Build.umap | 4 +- .../Dialogue/DialogueNPC.cpp | 46 +++++++++++++--- .../the_twilight_abyss/Dialogue/DialogueNPC.h | 15 ++++- .../Dialogue/InteractNPC.cpp | 5 +- .../MerchantInteraction/Interaction.cpp | 55 ++++++++++--------- .../MerchantInteraction/Interaction.h | 5 +- .../PlayerTemp/TempCharacter.cpp | 26 ++++----- .../the_twilight_abyss/Quest/QuestSystem.cpp | 9 ++- 13 files changed, 121 insertions(+), 63 deletions(-) create mode 100644 Content/Blueprints/Quests/Quest_SistersPendant_PT2.uasset diff --git a/Content/Assets/Characters/Merchant/AMerchant.uasset b/Content/Assets/Characters/Merchant/AMerchant.uasset index e39f4ca..926a431 100644 --- a/Content/Assets/Characters/Merchant/AMerchant.uasset +++ b/Content/Assets/Characters/Merchant/AMerchant.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dfd31ff659a23fe62ed9dd69bcf5a4c79ef917400e90740025d13ea40228bf6c -size 31278 +oid sha256:2f600ced864f7a102cf58d11ea26742ee91fb11649a561d28cce90d1044947b1 +size 122614 diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index 7bce521..719c678 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:afa219a774a7b87b1d8d7bf0ae37a4c149d1953526d7472ee547409e709abc44 -size 193210 +oid sha256:5d4955d5f8fd084bdfc0eca37a040b6284cfe5cc1c0ce35b6b07ed55de1a503f +size 193514 diff --git a/Content/Blueprints/Quests/Quest_SistersPendant.uasset b/Content/Blueprints/Quests/Quest_SistersPendant.uasset index 76c0fa3..f2c5d50 100644 --- a/Content/Blueprints/Quests/Quest_SistersPendant.uasset +++ b/Content/Blueprints/Quests/Quest_SistersPendant.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e60dcfd0881fa73694406b7d23aec8fdd4d5f88d52603702b90cacccefe40d99 -size 7354 +oid sha256:721b604f0a5c80f562cb7a86636e8a36898a580c3c8bb7ebc39104a41159c2fe +size 6976 diff --git a/Content/Blueprints/Quests/Quest_SistersPendant_PT2.uasset b/Content/Blueprints/Quests/Quest_SistersPendant_PT2.uasset new file mode 100644 index 0000000..7345bf8 --- /dev/null +++ b/Content/Blueprints/Quests/Quest_SistersPendant_PT2.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5b181ff3dd542e3e1773dd8e3a060dadcf3ce0a49c8e28d9c6fb6eef86399fc +size 7395 diff --git a/Content/Dialogue/SM_Merchant_Blueprint.uasset b/Content/Dialogue/SM_Merchant_Blueprint.uasset index ee0fec6..b4fd246 100644 --- a/Content/Dialogue/SM_Merchant_Blueprint.uasset +++ b/Content/Dialogue/SM_Merchant_Blueprint.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:067c534fc59af2ef7daf2b0a5b83c5c3406f3ce74d3aaea5b4cb2e1a9dcc8a18 -size 135164 +oid sha256:3b6be7b129b9972ac16f78d74e1f4ef2d78b51ef35d5c8db7bb074f7d855ddcb +size 138852 diff --git a/Content/Levels/Build.umap b/Content/Levels/Build.umap index a3cfeb0..c640827 100644 --- a/Content/Levels/Build.umap +++ b/Content/Levels/Build.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26c1966525a49ea2ca0e927f142117b8911ad729e8bc2cf7b1ed78228471a7e0 -size 3464831 +oid sha256:68e971da64c020713e1a94799292bb7c0ea575bf17584b69b96714aa99c2ba9b +size 3466781 diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp index 89b8928..4004a22 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp @@ -7,6 +7,7 @@ #include "GameFramework/Character.h" #include "Kismet/KismetStringLibrary.h" #include "Misc/OutputDeviceNull.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "the_twilight_abyss/Quest/QuestSystem.h" // Sets default values for this component's properties @@ -69,6 +70,17 @@ void UDialogueNPC::NextDialogue() FOutputDeviceNull AR; const FString Command = BlueprintFunctions[UKismetStringLibrary::Conv_StringToInt(CurrentDialogueStringPath[DialogueIndex].RightChop(3))];; GetOwner()->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); + if (Command == "OpenShop") bInShop = true; + DialogueIndex++; + } + else if (CurrentDialogueStringPath[FMath::Clamp(DialogueIndex + 1, 0, CurrentDialogueStringPath.Num() - 1)].Mid(0, 2) == "$$") + { + Cast(GetWorld()->GetFirstPlayerController()->GetPawn()->GetComponentByClass(UInventoryComponent::StaticClass()))->AddItem(ItemsToGive[UKismetStringLibrary::Conv_StringToInt(CurrentDialogueStringPath[DialogueIndex].RightChop(3))]); + DialogueIndex++; + } + else if (CurrentDialogueStringPath[FMath::Clamp(DialogueIndex + 1, 0, CurrentDialogueStringPath.Num() - 1)].Mid(0, 2) == "%%") + { + Cast(GetWorld()->GetFirstPlayerController()->GetPawn()->GetComponentByClass(UQuestSystem::StaticClass()))->AddQuestFlag(QuestFlags[UKismetStringLibrary::Conv_StringToInt(CurrentDialogueStringPath[DialogueIndex].RightChop(3))], true); DialogueIndex++; } @@ -127,6 +139,7 @@ void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom void UDialogueNPC::StartDialogue() { Quests.Empty(); + bInShop = false; FOutputDeviceNull AR; const FString Command = FString::Printf(TEXT("SetRootDialoguePath")); GetOwner()->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); @@ -165,15 +178,18 @@ void UDialogueNPC::EndDialogue() TextAnimationTimerHandle.Invalidate(); DialogueWidgetInstance->RemoveFromParent(); - //Enable Character Movement - if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) + if (!bInShop) { - PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); + //Enable Character Movement + if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) + { + PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); + } + //Reset UI Mode + APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); + PlayerController->SetInputMode(FInputModeGameOnly()); + PlayerController->bShowMouseCursor = false; } - //Reset UI Mode - APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); - PlayerController->SetInputMode(FInputModeGameOnly()); - PlayerController->bShowMouseCursor = false; } UDialoguePath* UDialogueNPC::CreateRootDialoguePath() @@ -210,11 +226,25 @@ UDialoguePath* UDialogueNPC::AddQuest(UDialoguePath* DialoguePath, UQuest* Quest UDialoguePath* UDialogueNPC::CallBlueprintFunction(UDialoguePath* DialoguePath, const FString FunctionName) { - DialoguePath->Dialogue.Add(FText::FromString("@@ " + FunctionName).ToString()); + DialoguePath->Dialogue.Add(FText::FromString("@@ " + FString::FromInt(BlueprintFunctions.Num())).ToString()); BlueprintFunctions.Add(BlueprintFunctions.Num(), FunctionName); return DialoguePath; } +UDialoguePath* UDialogueNPC::AddItem(UDialoguePath* DialoguePath, const int ItemIndex) +{ + DialoguePath->Dialogue.Add(FText::FromString("$$ " + FString::FromInt(ItemIndexes.Num())).ToString()); + ItemIndexes.Add(ItemIndexes.Num(), ItemIndex); + return DialoguePath; +} + +UDialoguePath* UDialogueNPC::AddQuestFlag(UDialoguePath* DialoguePath, FString Flag) +{ + DialoguePath->Dialogue.Add(FText::FromString("%% " + FString::FromInt(QuestFlags.Num())).ToString()); + QuestFlags.Add(QuestFlags.Num(), Flag); + return DialoguePath; +} + void UDialogueNPC::Choice1() { CurrentDialoguePath = CurrentDialoguePath->Choices[0]; diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h index ee5222d..e213c32 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h @@ -44,6 +44,9 @@ public: UPROPERTY(EditAnywhere) UTexture2D* NPCPortrait; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Instanced) + TArray ItemsToGive; + UPROPERTY(EditAnywhere) float TextAnimationSpeed = 0.05f; @@ -96,6 +99,13 @@ private: TMap Quests; UPROPERTY() TMap BlueprintFunctions; + UPROPERTY() + TMap ItemIndexes; + UPROPERTY() + TMap QuestFlags; + + UPROPERTY() + bool bInShop = false; void ResetDialogueUI(); @@ -120,9 +130,12 @@ public: UFUNCTION(BlueprintCallable) UDialoguePath* AddQuest(UDialoguePath* DialoguePath, UQuest* Quest); - UFUNCTION(BlueprintCallable) UDialoguePath* CallBlueprintFunction(UDialoguePath* DialoguePath, FString FunctionName); + UFUNCTION(BlueprintCallable) + UDialoguePath* AddItem(UDialoguePath* DialoguePath, int ItemIndex); + UFUNCTION(BlueprintCallable) + UDialoguePath* AddQuestFlag(UDialoguePath* DialoguePath, FString Flag); UFUNCTION() void Choice1(); diff --git a/Source/the_twilight_abyss/Dialogue/InteractNPC.cpp b/Source/the_twilight_abyss/Dialogue/InteractNPC.cpp index 32ba171..042b946 100644 --- a/Source/the_twilight_abyss/Dialogue/InteractNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/InteractNPC.cpp @@ -3,6 +3,7 @@ #include "InteractNPC.h" #include "DialogueNPC.h" +#include "Camera/CameraComponent.h" // Sets default values for this component's properties @@ -36,8 +37,8 @@ void UInteractNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom void UInteractNPC::Interact() { - FVector Start = GetOwner()->GetActorLocation(); - FVector End = GetOwner()->GetActorForwardVector() * 100.0f + Start; + FVector Start = Cast(GetOwner()->FindComponentByClass())->GetComponentLocation(); + FVector End = GetOwner()->GetActorForwardVector() * 300.0f + Start; FCollisionQueryParams CollisionParams; CollisionParams.AddIgnoredActor(GetOwner()); if (FHitResult HitResult; GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Pawn, CollisionParams)) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index e9dbe65..2ce2fdd 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -10,6 +10,7 @@ #include "Components/WidgetComponent.h" #include "Kismet/KismetMathLibrary.h" #include "the_twilight_abyss/PlayerTemp/TempCharacter.h" +#include "the_twilight_abyss/Quest/QuestSystem.h" // Sets default values @@ -69,40 +70,41 @@ void AInteraction::Tick(float DeltaTime) void AInteraction::OnInteract() { - bDisableShopDialMove = true; - if (ShopDialogWidget == nullptr) - { - UE_LOG(LogTemp, Display, TEXT("ShopDialogWidget is null")); - return; - } - else - { - //Shop Widget to visible - ShopDialogWidget->SetVisibility(ESlateVisibility::Visible); - //Call a custom event in a blueprint called "PlayText" - ShopDialogWidget->CallFunctionByNameWithArguments(TEXT("PlayText"), *GLog, nullptr, true); - } - //handles the widget disappearing from the viewport - FTimerHandle WidgetTimer; - GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, WaitTimer, false); + // bDisableShopDialMove = true; + // if (ShopDialogWidget == nullptr) + // { + // UE_LOG(LogTemp, Display, TEXT("ShopDialogWidget is null")); + // return; + // } + // else + // { + // //Shop Widget to visible + // ShopDialogWidget->SetVisibility(ESlateVisibility::Visible); + // //Call a custom event in a blueprint called "PlayText" + // ShopDialogWidget->CallFunctionByNameWithArguments(TEXT("PlayText"), *GLog, nullptr, true); + // } + // //handles the widget disappearing from the viewport + // FTimerHandle WidgetTimer; + // GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, WaitTimer, false); } void AInteraction::RemoveWidget() { + bDisableShopDialMove = true; bisDisabled = true; //Setting ShopWidgetText back to hidden - ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden); - if (ShopDialogWidget->IsVisible()) - { - return; - } - else - { - UE_LOG(LogTemp, Display, TEXT("You cant open this widget when this widget is open")); - } + // ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden); + // if (ShopDialogWidget->IsVisible()) + // { + // return; + // } + // else + // { + // UE_LOG(LogTemp, Display, TEXT("You cant open this widget when this widget is open")); + // } UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true")); - + Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden); if (Property == nullptr) { UE_LOG(LogTemp, Error, TEXT("Property not found")); @@ -209,6 +211,7 @@ void AInteraction::ExitScreen() { TempCharacterRef->InputEnabler(); ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); + Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::HitTestInvisible); } } diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 76af4db..7481d80 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -28,7 +28,7 @@ public: UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf ShopDialog; - UPROPERTY(EditAnywhere, Category= "Widgets") + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Widgets") TSubclassOf ItemSelector; UPROPERTY(EditAnywhere, Category = "Widgets") @@ -38,7 +38,8 @@ public: TSubclassOf BuyHealingText; virtual void OnInteract(); - + + UFUNCTION(BlueprintCallable) virtual void RemoveWidget(); UPROPERTY() diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index e358e9e..12181d9 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -202,19 +202,19 @@ void ATempCharacter::LineTraceLogic() else { //DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); - MyInteractable->OnInteract(); - UE_LOG(LogTemp, Display, TEXT("OnInteract activated")); - UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); - - // While loop to check bisDisabled var until it changes to true - while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false) - { - if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true) - { - InputDisabler(); - break; - } - } + // MyInteractable->OnInteract(); + // UE_LOG(LogTemp, Display, TEXT("OnInteract activated")); + // UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); + // + // // While loop to check bisDisabled var until it changes to true + // while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false) + // { + // if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true) + // { + // InputDisabler(); + // break; + // } + // } } } } diff --git a/Source/the_twilight_abyss/Quest/QuestSystem.cpp b/Source/the_twilight_abyss/Quest/QuestSystem.cpp index 54dcbf0..cf23d06 100644 --- a/Source/the_twilight_abyss/Quest/QuestSystem.cpp +++ b/Source/the_twilight_abyss/Quest/QuestSystem.cpp @@ -115,7 +115,14 @@ bool UQuestSystem::AddQuest(UQuest* Quest) void UQuestSystem::AddQuestFlag(const FString FlagName, const bool FlagValue) { - QuestFlags.Add(FlagName, FlagValue); + if (HasQuestFlag(FlagName)) + { + QuestFlags[FlagName] = FlagValue; + } + else + { + QuestFlags.Add(FlagName, FlagValue); + } CheckActiveQuestConditions(); }