From b0e9ad546bf48afc5438583dd106eca220f0df37 Mon Sep 17 00:00:00 2001 From: MarcelHara Date: Tue, 9 May 2023 13:50:23 +0100 Subject: [PATCH 1/3] Replaced mining crystals with the assets --- Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset | 4 ++-- Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset | 4 ++-- Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset index b258efa..501da09 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0bbd54a7ea6d9bb800d06bf1534e9c2c34d573df79b09621984714de201fa9f7 -size 32219 +oid sha256:218c1e1abb52d79ee0a855d573bc7b8d2bb203ff3503c643f8500c9b09773107 +size 29309 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset index 38cdd02..69548c5 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8978cc1273cc732a6c994b47f40eec7facd06989723ee169bca4f3be98a9aeed -size 32668 +oid sha256:dc570407694c572b3cce6254dfc498fa53ef3c61638344f473b138603903f319 +size 29398 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset index a83b723..fae48da 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0134465b90f3930c3f007072f3d6f10aec678577f2d00ed32858d0d3aa0b3f5e -size 32046 +oid sha256:6d99da4ac4717b672848646555b5a0b0cd6f3f9899d4ab4a0ad3dee239821c48 +size 29292 From fc25c8adf0ecea486f809e6c3f302d938510d886 Mon Sep 17 00:00:00 2001 From: MarcelHara Date: Tue, 9 May 2023 16:22:35 +0100 Subject: [PATCH 2/3] Updated TempCharacter to start fixing bugs --- .../Items/ItemsInWorld/BP_Azos.uasset | 4 ++-- .../Items/ItemsInWorld/BP_Eis.uasset | 4 ++-- .../Items/ItemsInWorld/BP_Iroquoid.uasset | 4 ++-- .../Items/ItemsInWorld/BP_Probertium.uasset | 4 ++-- .../PlayerTemp/TempCharacter.cpp | 23 +++++++++++++------ 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset index 501da09..143e77a 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:218c1e1abb52d79ee0a855d573bc7b8d2bb203ff3503c643f8500c9b09773107 -size 29309 +oid sha256:9e4a5a27055688ae5dd4677261d21d5fca582bf3ab9e51db438164de8a48aebb +size 29367 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset index 2c22049..69e0b03 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40b1b3aba3e44f2ae79359b14e31f68e79ca1dd18de2737374f36c4c6d9711b4 -size 31932 +oid sha256:abd42ce36414c2273ef4f2a220b0923a01c019c6d6d3c725c3750fb2ed82a9b7 +size 30253 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset index 69548c5..4e91987 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dc570407694c572b3cce6254dfc498fa53ef3c61638344f473b138603903f319 -size 29398 +oid sha256:22c938e0f7c03dff887dcfdeb66b9b17a6abf0623f7ae0b95e2a10779b8240d2 +size 29472 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset index fae48da..20b25f2 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d99da4ac4717b672848646555b5a0b0cd6f3f9899d4ab4a0ad3dee239821c48 -size 29292 +oid sha256:89ac9fd992de872aa3c69bd388f455780a3c6e59ad3c64bcc4a35912eabc86a8 +size 29350 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 644df2d..4c0cba6 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -142,18 +142,31 @@ void ATempCharacter::LineTraceLogic() FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector(); FCollisionQueryParams TraceParams; TraceParams.AddIgnoredActor(this); - bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams); if (bHit) { - //we store the GetItem function from InventoryComponent into ItemArray variable - if (OutHit.GetActor() == nullptr) { return; } if (OutHit.GetActor()->FindComponentByClass()) { + if(OutHit.GetActor()->ActorHasTag(TEXT("Probertium"))) + { + OutHit.GetActor()->Destroy(); + } + else if(OutHit.GetActor()->ActorHasTag(TEXT("Iroquid"))) + { + OutHit.GetActor()->Destroy(); + } + else if (OutHit.GetActor()->ActorHasTag(TEXT("Azos"))) + { + OutHit.GetActor()->Destroy(); + } + else if (OutHit.GetActor()->ActorHasTag(TEXT("Eis"))) + { + OutHit.GetActor()->Destroy(); + } UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); if (GoldBalance >= ItemArray->ItemCostPrice) @@ -166,10 +179,6 @@ void ATempCharacter::LineTraceLogic() { UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); } - if (OutHit.GetActor()->ActorHasTag(Ammo)) - { - OutHit.GetActor()->Destroy(); - } } // if the actor hit has the interaction component/script then it will activate the code From 4ad0959f08ad9eecc76dd15676f8d2b91d12d768 Mon Sep 17 00:00:00 2001 From: MarcelHara Date: Wed, 10 May 2023 13:27:27 +0100 Subject: [PATCH 3/3] Bug Fixed Mining crashing the game When pressing E on the crystals it kept on crashing due to destroy being executed before pointer checks --- .../PlayerTemp/TempCharacter.cpp | 58 +++++++++++++------ .../PlayerTemp/TempCharacter.h | 6 ++ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 4c0cba6..e358e9e 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -26,7 +26,6 @@ ATempCharacter::ATempCharacter() void ATempCharacter::BeginPlay() { Super::BeginPlay(); - FirstPlayerController = GetWorld()->GetFirstPlayerController(); CombatSystem = Cast(GetWorld()->GetGameState()); WidgetPointer = Cast(this->GetComponentByClass(UWidgetInteractionComponent::StaticClass())); @@ -136,7 +135,6 @@ void ATempCharacter::LineTraceLogic() { //UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated")); float GlobalTrace = TraceDistance; - FHitResult OutHit; ThisCamera = Cast(this->FindComponentByClass()); FVector Start = ThisCamera->GetComponentLocation(); FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector(); @@ -149,24 +147,28 @@ void ATempCharacter::LineTraceLogic() { return; } + if(OutHit.GetActor()->ActorHasTag(TEXT("Probertium"))) + { + AddToInventory(); + return; + } + if(OutHit.GetActor()->ActorHasTag(TEXT("Iroquid"))) + { + AddToInventory(); + return; + } + if (OutHit.GetActor()->ActorHasTag(TEXT("Azos"))) + { + AddToInventory(); + return; + } + if (OutHit.GetActor()->ActorHasTag(TEXT("Eis"))) + { + AddToInventory(); + return; + } if (OutHit.GetActor()->FindComponentByClass()) { - if(OutHit.GetActor()->ActorHasTag(TEXT("Probertium"))) - { - OutHit.GetActor()->Destroy(); - } - else if(OutHit.GetActor()->ActorHasTag(TEXT("Iroquid"))) - { - OutHit.GetActor()->Destroy(); - } - else if (OutHit.GetActor()->ActorHasTag(TEXT("Azos"))) - { - OutHit.GetActor()->Destroy(); - } - else if (OutHit.GetActor()->ActorHasTag(TEXT("Eis"))) - { - OutHit.GetActor()->Destroy(); - } UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); if (GoldBalance >= ItemArray->ItemCostPrice) @@ -219,6 +221,26 @@ void ATempCharacter::LineTraceLogic() } } +void ATempCharacter::AddToInventory() +{ + if (OutHit.GetActor()->FindComponentByClass()) + { + UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); + auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); + if (GoldBalance >= ItemArray->ItemCostPrice) + { + GoldBalance -= ItemArray->ItemCostPrice; + Inventory->AddItem(ItemArray); + UE_LOG(LogTemp, Display, TEXT("Item Purchased")); + } + if (GoldBalance <= 0) + { + UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); + } + OutHit.GetActor()->Destroy(); + } +} + void ATempCharacter::InputDisabler() { //Disable Character Movement diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index eaf8e2c..1a8b284 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -128,5 +128,11 @@ public: UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf CrossHairSub; +private: + UPROPERTY() + FHitResult OutHit; + + UFUNCTION() + void AddToInventory(); };