Updated TempCharacter to stop crashes

This commit is contained in:
MarcelHara 2023-05-09 12:50:34 +01:00
parent 0632a1770b
commit b3c83f161f
2 changed files with 20 additions and 12 deletions

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

Binary file not shown.

View File

@ -271,19 +271,27 @@ void ATempCharacter::UseItem(class UBaseItem* Item)
void ATempCharacter::BuyItem(AActor* Item)
{
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
UBaseItem* ItemArray = Item->FindComponentByClass<UInventoryComponent>()->GetItem(0);
if (GoldBalance <= 0)
if (Item == nullptr)
{
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
UE_LOG(LogTemp, Display, TEXT("Item is null"));
return;
}
else if (GoldBalance >= ItemArray->ItemCostPrice)
else
{
GoldBalance -= ItemArray->ItemCostPrice;
Inventory->AddItem(ItemArray);
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
UBaseItem* ItemArray = Item->FindComponentByClass<UInventoryComponent>()->GetItem(0);
if (GoldBalance <= 0)
{
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
}
else if (GoldBalance >= ItemArray->ItemCostPrice)
{
GoldBalance -= ItemArray->ItemCostPrice;
Inventory->AddItem(ItemArray);
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
}
UE_LOG(LogTemp, Display, TEXT("BUY ITEM FIRING"));
TraceDistance = 1000;
LineTraceLogic();
}
// UE_LOG(LogTemp, Display, TEXT("BUY ITEM FIRING"));
// TraceDistance = 1000;
// LineTraceLogic();
}