Welcome back.
So now we need a data asset and this is going to store all the data for all of the associated character
classes.
So let's make that C plus plus class.
We'll go into Aura public ability system, and we'll stick it right here in data with our other data
asset.
So let's right click new C plus plus class, choose all classes and we're going to search for data asset.
Select data asset.
Click next and this can be called character class info.
Let's create the class and close the editor.
Okay, so we have our character class info.
Here's the CPP and here's the H file.
So now that we have this, we need a way to store data for each character class and we also need an
enum to categorize character classes.
So let's go ahead and create an enum.
I'd like to make an enum class or a scoped enum called A Character Class, and we'll use Uint8 for this
enum.
And I'd like this to be a blueprint type, so that means it needs a U enum with blueprint type and we
can add constants for each character class.
So I'd like an elementalist class.
Basically a sorcerer or wizard type class.
We're going to have a warrior class and we're going to have a Ranger class.
And writer thinks I made a typo, but nope, this is the word that I wanted.
So now we have a way to distinguish between different character classes.
Now I'm also going to want a struct with all the information for each class, so I'm going to make a
new type of struct and this will be for the character class default info.
So that's what I'm going to call it.
F character class default info.
Now this will be a use struct.
And I'm also going to make this a blueprint type struct, and it's going to need the generated body
macro and we can add all the different data associated with a given class.
Now in this struct we're obviously going to need a gameplay effect to apply our primary attributes.
So we're going to have a subclass of capable of storing a new gameplay effect.
Class and I'll go ahead and add the forward declaration for gameplay effect there.
And this will be our primary attributes gameplay effect.
Now this should be a new property so we can set it from our data asset blueprint.
We can make it edit defaults only and we'll stick it in a category of class defaults.
So now we can set the primary attributes here.
Now we could have secondary and vital attribute gameplay effects per class, or we can share the same
secondary and primary attributes gameplay effect among all classes.
That's really up to us.
I'd like to share those, so I'm going to add them down here.
I'm going to make a public section and paste the primary attributes, but this is going to actually
be secondary attributes and this will be our common class defaults.
So we'll go ahead and set the category to common class defaults and we'll have one for secondary and
we'll also have one for vital attributes as well.
So vital attributes.
Okay, so we have a struct and we can set the primary attributes.
Gameplay effect per class.
Now our data asset needs a way to store these structs one for each one of our classes so we can use
a t array.
Or we could use a map.
A map is nice because we could map the enum to the struct, so why don't we do that here in the public
section?
We'll make a t map that maps from the enum character class to the struct character class default info
and we'll call this character class information.
Now I'd like to be able to retrieve the information for any given enum constant, so we'll make a function
to look up the info so this can return an F character class default info and we'll call it get class
default info and it'll take an E character class called character class so we can go ahead and generate
the definition.
And this is going to be simple.
We're going to simply return and we'll perform a lookup in character class information.
We can just use find checked, find checked is nice because it'll perform an assertion and we'll have
an assert.
If we can't find the enum and we're going to pass in character class.
So this function will simply return the information given a character class enum constant.
Okay.
And of course, we're going to want to fill in this map in the editor, so we'll give this a new property
with edit defaults only as well, and we'll just give it the category of class defaults.
We'll make it character class defaults and we can compile, launch and make this data asset.
Okay.
So back in the editor, let's go to blueprints, ability system and data and we'll make this data asset
here so we can go to miscellaneous data asset and we can choose our character class info.
Let's select that and we'll call this a character class info and we can open it up.
And here we have our character class information map and our secondary attributes and our vital attributes
so we can go ahead and click.
Plus we have the Elementalist, which is the default value we can't click.
Plus again, as we'll get this warning, I'll click it again.
It says Cannot add new key to the map.
Well, a key with the default value exists.
So if we want to add all three, we have to change this from elementalist to ranger or warrior and add
another one.
Change this to something else.
So we have Ranger, we have warrior and then finally Elementalist.
And then we can expand these and see that we have the primary attributes gameplay effect to subclass
of.
And then we have secondary and vital which will be shared among all classes.
Unless of course you place those in our class information struct, in which case you could set a different
one for each class.
So now that we have a data asset we can fill these in with gameplay effects and we're going to create
some gameplay effects to fill in in the next video.
So great job and I'll see you soon.