Added Perform Function to Execute Actions from Planner

This commit is contained in:
Philip W 2023-03-20 15:27:06 +00:00
parent acdb4dde0e
commit 3c8ab3b25e
8 changed files with 35 additions and 9 deletions

Binary file not shown.

View File

@ -10,3 +10,11 @@ void UCombo_P::Init()
Effects.Add("PlayerHealth", 15);
Effects.Add("ProbertiumResource", 5);
}
bool UCombo_P::Perform()
{
ATurnBaseCombatV2* CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
CombatSystem->DamagePlayer(15, "P");
return true;
}

View File

@ -16,4 +16,5 @@ class COMP250_1_2101327_AI_API UCombo_P : public UGOAPAction
public:
virtual void Init() override;
virtual bool Perform() override;
};

View File

@ -5,7 +5,15 @@
void UDefaultAttack::Init()
{
ActionCost = 2.0f;
PreConditions.Add("PlayerHealth", 10);
Effects.Add("PlayerHealth", 10);
ActionCost = 5.0f;
PreConditions.Add("PlayerHealth", 1);
Effects.Add("PlayerHealth", 1);
}
bool UDefaultAttack::Perform()
{
ATurnBaseCombatV2* CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
CombatSystem->DamagePlayer(1, "Punch");
return true;
}

View File

@ -16,4 +16,5 @@ class COMP250_1_2101327_AI_API UDefaultAttack : public UGOAPAction
public:
virtual void Init() override;
virtual bool Perform() override;
};

View File

@ -26,3 +26,8 @@ TMap<FString, int> UGOAPAction::ApplyEffects(TMap<FString, int> WorldState)
}
return WorldState;
}
bool UGOAPAction::Perform()
{
return false;
}

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "COMP250_1_2101327_AI/TurnBasedCombatV2/TurnBaseCombatV2.h"
#include "GOAPAction.generated.h"
/**
@ -21,6 +22,8 @@ public:
bool CheckPreConditions(TMap<FString, int> WorldState);
UFUNCTION()
TMap<FString, int> ApplyEffects(TMap<FString, int> WorldState);
UFUNCTION()
virtual bool Perform();
UPROPERTY()
TMap<FString, int> PreConditions;