Attach E skill Effect on Haesol's Foot. Create ShopAOE/NPCActor cpp class

This commit is contained in:
7heIVIaze 2025-06-02 18:16:58 +09:00
parent ab9fd60b77
commit 051c65fde0
13 changed files with 174 additions and 9 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -31,7 +31,7 @@ public:
FText Action;
UFUNCTION(BlueprintCallable, Category = "Pickup")
FText GetInteractText() const;
virtual FText GetInteractText() const;
protected:
// Called when the game starts or when spawned

View File

@ -0,0 +1,88 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYShopAOE.h"
#include "HYGameStateBase.h"
#include "Engine/DataTable.h"
// Sets default values
AHYShopAOE::AHYShopAOE()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AHYShopAOE::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AHYShopAOE::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
bool AHYShopAOE::RandomizeTradableItemSets(int CurrentHonbaekAmount)
{
AHYGameStateBase* GameState = Cast<AHYGameStateBase>(GetWorld()->GetGameState());
if(GameState == nullptr)
{
return false;
}
UDataTable* ItemDataTable = GameState->GetItemDatabase();
if (ItemDataTable == nullptr)
{
return false;
}
TArray<FInventoryItem*> ItemData;
ItemDataTable->GetAllRows<FInventoryItem>("", ItemData);
if (ItemData.Num() == 0)
{
return false;
}
TArray<FInventoryItem*> FilteredItemData = ItemData.FilterByPredicate([CurrentHonbaekAmount](const FInventoryItem* ItemDataRow)
{
return ItemDataRow->ItemValue <= CurrentHonbaekAmount;
});
int maxLoopNum = FMath::Min(5, FilteredItemData.Num());
for (int i = 0; i < maxLoopNum; ++i)
{
int RandomIdx = FMath::RandRange(0, FilteredItemData.Num() - 1);
FinalItemSets.Add(*FilteredItemData[RandomIdx]);
FilteredItemData.RemoveAt(RandomIdx);
}
if (FinalItemSets.Num() == maxLoopNum)
{
return true;
}
return false;
}
void AHYShopAOE::GetTradableItemSets(TMap<FInventoryItem, int>& Item)
{
TArray<FInventoryItem> TempItems = FinalItemSets.Array();
for (FInventoryItem TempItem : TempItems)
{
int Amount = FMath::RandRange(0, 100);
Item.Add({ TempItem, Amount });
}
return;
}

View File

@ -0,0 +1,39 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "InventoryItem.h"
#include "HYShopAOE.generated.h"
UCLASS()
class HWANYOUNG2_API AHYShopAOE : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AHYShopAOE();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called When Begin Overlapped Event.
UFUNCTION(BlueprintCallable)
virtual bool RandomizeTradableItemSets(int CurrentHonbaekAmount);
// @param Item is NPC Actor's Array.
// Make random amount of the tradable items set.
UFUNCTION(BlueprintCallable)
void GetTradableItemSets(TMap<FInventoryItem, int>& Item);
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Data")
TSet<FInventoryItem> FinalItemSets;
};

View File

@ -0,0 +1,8 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYShopNPCActor.h"
void AHYShopNPCActor::Interact_Implementation(APlayerController* Controller)
{
}

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "HYInteractableActor.h"
#include "InventoryItem.h"
#include "HYShopNPCActor.generated.h"
/**
*
*/
UCLASS()
class HWANYOUNG2_API AHYShopNPCActor : public AHYInteractableActor
{
GENERATED_BODY()
virtual void Interact_Implementation(APlayerController* Controller);
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TMap<FInventoryItem, int> TradableItems;
};