Hey there, I want to use a Data Oriented approach for my game.
I have a DataTable that should contain the enemies my game has to offer.
And I am struggling to come up with a structure to implement the Behaviour in a Data-Oriented way.
The Game is turn based, soI think using BlackBoards and Behaviour Trees is way too much.
What I want:
The Struct “Monster” should contain another DataContainer called “Behaviour”
A Behaviour should contain one or more “Conditions”.
Conditions could be:
“Monster HP <= X amount”
“Party contains X member”
“The Current Battle Turn No. is X”
etc.
The Behaviour should then contain the actual Behaviour like
“Attack regularly”
“Attack Party Member with Health lower than X”
“Use Skill X”
How would I set this up so I can have it completely contained within the DataTable?
A class-like approach would be great (Condition could be a class with an abstract function that returns a bool), but using UObject would mean I have to create an UObject in the Content browser for every condition and I could not parametrize it uniquely and put it into the DataTable
I wouldnt be able to define the Behaviour in the DataTable. It would mean I have to create the Data outside of it.
And I also fail to see how I can create different behaviours with UDataAsset. it would mean the same thing I suggested. Different classes for every condition and the Behaviour would be a different class aswell. The DataAsset would be a collection of Conditions and the actual behaviour (Use Skill X, Attack X) would be a different class, too.
I meant data asset instead of data table.
I’m not sure why so many like to use tables lol
Anyway, I would make the skills to be an Enum to define in a behavior data asset.
Then the conditions I would make them also an Enum, but a bitmask enum. Bitmasked enums allows for multiple conditions to be set at once, defining multiple conditions for the same behavior.
Comparing flags of a bitmask enum is clunky at first, but soon it shows its usefulness, specially for RPG stuff.
Everything is in one place instead of scattered in hundreds of separate files and simply text representation maybe.
DataAssets seem to be the correct way to go though. Is there a way to have the DataAsset “inline” instead of separate, basically an instance of it directly in it?
Anyway if you feel like not going forward with the data asset scheme…
You could make your FMonsterBehavior house a FGameplayTagContainer to use as a “Conditions” system and a FGameplayTag to function as the actual skill the behavior activates:
They most definitely do work - I use that pattern rather often. Like Bruno said, I think the root issue is you aren’t exporting those classes so the Editor can’t find them.
Here’s a working example:
UCLASS(EditInlineNew)
class MYGAME_API UMovementState : public UObject
{
GENERATED_BODY()
public:
UMovementState();
virtual ~UMovementState();
// ...
};
class MYGAME_API UGameMovementComponent : public UMovementComponent
{
GENERATED_BODY()
public:
UGameMovementComponent();
virtual ~UGameMovementComponent();
protected:
UPROPERTY(EditAnywhere, Instanced, Category = "Movement", meta = ( DisplayName = "States" ))
TArray<UMovementState*> m_MovementStates;
};