Hello! I’m developing a battle system for a turn-based JRPG, and I’m unsure if I’m on the right path to structuring the character class data.
Initially, I developed in pure C++ to learn the language. When analyzing Unreal’s classes and objects, I realized that some things must be done in a very specific way (which I already imagined!).
At first, I realized that to save data in DataTables (which I imagine is the equivalent of the database I had in C++), it would be necessary to create a Struct. I created CombatActorStruct to save the characters’ base data:
Then, I created two structs that inherited from CombatActorStruct, Hero and Enemy:
The models demonstrated are completely hypothetical! Some attributes may not even be part of the game, the intention was to give as clear an example as possible.
Both Hero and Enemy, then, have their own DataTables with their initial data saved:
(The values are 100% hypothetical, but the idea is that I save the heroes’ initial attributes and scale them with their multipliers as they level up, and that the enemies have fixed values.)
Due to the limitations of UStruct, I realized that I needed to create a UClass for heroes and enemies, since UStructs do not support UFunctions. The classes, then, I would use to manipulate the characters in the menus and battles; their instances would be the data that would go into memory.
Therefore, I planned the CombatActorClass, with the base data and functions for the CombatActors, in addition to having a UStruct to have the CombatActor base data:
Then, I created classes for Hero and Enemy, containing a UStruct to have the base data from the DataTable as well:
I cited very summarized models just with the intention of trying to clarify what is going on in my head in the most graphic way possible.
So, let’s get to the questions:
-
Is having a UStruct within the class as an attribute the most optimized or even safe method of accessing DataTable data? Are there smarter solutions?
-
You can see that I am showing the UStructs as pointers, however, in my tests, I saw that this causes several problems in the engine and that it does not even allow creating a UProperty directly as a pointer. I even did some tests trying to encapsulate a UStruct pointer, but I ended up crashing the engine via Blueprint . I don’t know if it’s necessary since it’s fixed data and should use little amount of memory, but is it possible to manipulate pointers from a DataTable (or even other structs) within blueprints?
-
What “typing” could I use for CombatActorClass, HeroClass and EnemyClass? I tested using UObjects, but I saw that they might be too generic and not suitable for the purpose. I thought about ActorComponent or PlayerState, but it’s still not clear to me. This data controls the states of the characters in battle, not the graphic characters on the screen, since they are just puppets (actors or panws; I think it’s pawns ) that react to the states or commands of the battle instance. It is important to say that I would like to calculate values (such as damage and healing) for heroes and enemies in the same way, making polymorphism for both instances necessary.
-
EXTRA: I wanted to develop a battle system similar to Chrono Trigger, where the battle takes place on the map itself and not in a separate scenario. In this case, should I use a GameStateBase, a GameBase or some other class to manipulate how the game (commands, hud, etc.) will behave in battle or overworld?
Well that’s! I think my questions are a bit too specific, so I tried to leave as many details as possible. Sorry for the length of the post.
Thank you to everyone who took their precious time to help me. I hope you have a great day! (And I’m sorry for any translation issues as well. )