Bugfix Quest System Not Item Matching Correctly

This commit is contained in:
Philip W 2023-05-11 07:40:14 +01:00
parent fea2ccface
commit 814c2d6aaa
2 changed files with 4 additions and 3 deletions

View File

@ -33,7 +33,7 @@ bool UQuest::WorldStateMatch(UWorldState* A, UWorldState* B)
if (A->Items.IsEmpty() && !B->Items.IsEmpty()) return false;
for (UBaseItem* Item : B->Items)
{
if (!A->Items.Contains(Item) && Item->StackCount > A->Items[A->Items.Find(Item)]->StackCount)
if (!A->Items.Contains(Item) && Item->StackCount > A->Items[A->Items.IndexOfByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; })]->StackCount)
{
return false;
}
@ -60,9 +60,9 @@ bool UQuest::FlagTrueMatch(const UWorldState* WorldState, const FString& FlagNam
FString UQuest::GetItemCountAndGoalAmount(const UWorldState* WorldState, UBaseItem* Item) const
{
FString Result;
if (WorldState->Items.Contains(Item))
if (WorldState->Items.ContainsByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; }))
{
Result += FString::FromInt(WorldState->Items[WorldState->Items.Find(Item)]->StackCount);
Result += FString::FromInt(WorldState->Items[WorldState->Items.IndexOfByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; })]->StackCount);
Result += "/";
Result += FString::FromInt(Goals->Items[Goals->Items.Find(Item)]->StackCount);
return Result;

View File

@ -51,6 +51,7 @@ protected:
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(BlueprintCallable)
void CheckActiveQuestConditions();
UWorldState* GetWorldState() const;