WEBVTT

00:00.260 --> 00:02.240
Welcome to your next quest.

00:02.630 --> 00:03.020
All right.

00:03.020 --> 00:10.130
So the next thing we need is for enemies to have an amount of XP that the attacker gets when slaying

00:10.130 --> 00:11.030
that enemy.

00:11.150 --> 00:18.680
So you're going to create an XP reward curve table and you can add curves for each class.

00:18.710 --> 00:22.490
Next, you can decide how to add that to the data asset.

00:22.520 --> 00:26.090
You could add scalable floats for each character class.

00:26.090 --> 00:33.560
So decide if that's the way to go and then add a getter function in our aura ability system library

00:33.560 --> 00:41.510
that takes in the class and the level and returns the amount of XP as the reward for slaying a character

00:41.510 --> 00:43.220
of that class and level.

00:43.220 --> 00:49.850
And then add a get character class function in the combat interface so we can implement that.

00:49.850 --> 00:57.200
Now that means that we may have to take that character class variable out of the enemy class and put

00:57.200 --> 00:59.910
that into the base character class.

00:59.910 --> 01:01.620
So handle that as well.

01:01.650 --> 01:05.460
Pause the video and conquer this quest now.

01:08.490 --> 01:10.430
Okay, so we need a curve table.

01:10.440 --> 01:16.740
I'm going to go into blueprints, ability system data, and we'll put our new curve table here.

01:16.740 --> 01:23.070
So we'll go to miscellaneous curve table and I'm going to choose cubic for this and create this curve

01:23.100 --> 01:23.900
table.

01:23.910 --> 01:29.070
I'm going to call it CT underscore exp underscore reward.

01:29.310 --> 01:36.180
So we have an exp reward data table and I'm going to rename the first curve to elementalist

01:38.490 --> 01:40.560
and then I'll add another curve.

01:40.560 --> 01:43.080
And this one can be for Ranger.

01:43.410 --> 01:47.310
We'll have another curve and this will be for the warrior.

01:48.180 --> 01:53.970
So each of these classes will be worth different amounts of experience based on their level.

01:54.000 --> 01:58.770
The warrior can perhaps be worth the least amount of experience.

01:58.770 --> 02:02.550
So I'm going to add a key to the warrior curve first.

02:03.130 --> 02:10.300
And set its time value to one that's going to be for its level and the amount of experience that a warrior

02:10.330 --> 02:11.010
can give.

02:11.020 --> 02:16.180
I'll just make it 20 and I'm going to go ahead and zoom to fit so I can see it there.

02:16.180 --> 02:17.470
And I'll add another key.

02:17.500 --> 02:20.920
Now I'm going to add a key for level 40.

02:20.920 --> 02:27.280
And at level 40, I think I'm going to make a warrior worth oh, a thousand.

02:27.310 --> 02:33.670
Let's just put a value out there and I'm going to go ahead and go to normalized view mode so I can see

02:33.670 --> 02:38.380
both keys here, select them both and make them auto.

02:38.380 --> 02:41.050
And so here we can see the trend.

02:41.050 --> 02:47.290
And I'm going to make it pretty much linear, but it's going to taper off and enemies will be worth

02:47.290 --> 02:51.470
less and less the closer we get to level 40.

02:51.490 --> 02:54.280
Now, this very much depends on the game.

02:54.280 --> 03:00.400
Okay, So some games you're going to see larger numbers when you get up to these levels.

03:00.400 --> 03:04.070
For some RPGs, 40 is a high level.

03:04.070 --> 03:09.710
For other RPGs, 40 isn't that high, but I'm just going to pick 40.

03:09.740 --> 03:12.530
We could easily have picked 100 or anything else.

03:12.530 --> 03:15.980
But once we get to 40, it stays at 1000.

03:16.010 --> 03:19.190
Now, for the Ranger, I'm going to add a new key.

03:19.190 --> 03:22.340
This one is going to be at level one.

03:22.370 --> 03:30.800
The ranger will give, let's say, 25 experience and we'll have one more key at level 40.

03:31.220 --> 03:35.600
And at level 40, let's say the ranger gives 1500.

03:35.630 --> 03:41.450
And just like for the warrior, I'm going to make it an auto curve and I'll give it just about the same

03:41.450 --> 03:44.360
trend, pretty much linear, but it tapers off.

03:44.360 --> 03:46.890
And for the elementalist we'll add two keys.

03:46.920 --> 03:47.810
I'll just add them both.

03:47.810 --> 03:50.900
Now, the first one will be for level one.

03:50.900 --> 03:54.980
I'm going to make the Elementalist the most valuable enemy to kill.

03:55.010 --> 04:04.430
I'll give it 35 exp at level one, and for level 40 we'll change this second key to a time value of

04:04.430 --> 04:05.210
40.

04:05.240 --> 04:12.710
At level 40, it's going to be worth 2500 and selecting both keys, making them auto.

04:12.710 --> 04:19.190
And again, I'm going to have this shape for my curve and I'll go back to absolute view mode so I can

04:19.190 --> 04:21.230
zoom out and take a look at these.

04:21.230 --> 04:22.790
And they all look the same.

04:22.790 --> 04:26.000
They just have slightly different values.

04:26.090 --> 04:31.820
So now that we have this curve table, we need a way to get that curve table.

04:31.820 --> 04:35.960
And where we're going to have it is our data asset.

04:35.960 --> 04:42.170
So we're going to go to our character class info data asset, and we can see it right here.

04:42.560 --> 04:49.340
And one of the things we could do is have a scalable float property in our class info struct.

04:49.370 --> 04:55.910
That way each of these will have one and we can set them to the appropriate curve from the curve table.

04:55.940 --> 05:02.300
Another option is to just have the curve table as we have our damage calculation coefficients curve

05:02.330 --> 05:02.780
table.

05:02.780 --> 05:09.140
We can remind ourselves how we're using that one by going back and searching our project for damage

05:09.140 --> 05:10.850
calculation coefficients.

05:10.850 --> 05:15.710
And we can see that we're using those in our exact calc.

05:15.770 --> 05:22.550
So if we go to our damage execution calculation, we can see that we're getting the character class

05:22.550 --> 05:30.110
info which we've created a nice getter for in our blueprint function library and accessing that curve

05:30.140 --> 05:38.090
table, finding the curve based on the name and then evaluating that curve based on the level passed

05:38.090 --> 05:38.600
in.

05:38.630 --> 05:44.330
Now we could do that, although this does require us to specify an F name.

05:44.330 --> 05:51.830
What would be easier if we could simply look up that curve as a scalable float and we know how to query

05:51.860 --> 05:53.570
scalable floats, right?

05:53.600 --> 05:57.380
We've done that in our aura projectile spell.

05:57.380 --> 06:04.210
If we go to abilities and in the private folder or a projectile spell in abilities and we come down

06:04.210 --> 06:12.340
here to our damage types, which is a T map, we're getting an F scalable float that's the pair in our

06:12.340 --> 06:16.990
loop through the T map and calling get value at level.

06:16.990 --> 06:18.760
So either way is okay.

06:18.760 --> 06:24.490
I think I'd prefer to put a scalable float in our data asset for each of these.

06:24.520 --> 06:31.000
And that way we're performing a lookup based on an enum rather than having to hardcode f names into

06:31.000 --> 06:31.810
our code.

06:31.810 --> 06:38.860
So what I'm going to do is add a scalable float into our data asset for each of our different character

06:38.860 --> 06:39.790
classes.

06:40.000 --> 06:49.450
So I'm going to go ahead and close my tabs, close my folders and open up my ability system data, character

06:49.450 --> 06:51.340
class info, data asset.

06:51.340 --> 06:57.220
And here we have character class default info where we can put a scalable float.

06:57.220 --> 07:02.050
So I'm going to make an F scalable float.

07:02.530 --> 07:06.760
And this is going to be XP reward.

07:07.810 --> 07:11.230
We'll set it equal to a default scalable float.

07:14.790 --> 07:22.530
But we're going to set this in blueprint with edit defaults only and give it the category of class defaults.

07:23.040 --> 07:29.700
So now that our scalable float will exist in our data asset, we need an easy to use function to look

07:29.700 --> 07:30.250
it up.

07:30.270 --> 07:36.510
So we're going to open our aura ability system library and we're going to make a nice new static function

07:36.510 --> 07:37.380
for this.

07:37.410 --> 07:40.890
Now, this is going to return a value, isn't it?

07:41.220 --> 07:43.830
We need to get the XP reward.

07:44.010 --> 07:51.240
Now, since these exist on curves that may or may not be on exact integers, we'll go ahead and return

07:51.240 --> 07:57.510
a float and then we can round that float as we see fit in our calculations.

07:57.840 --> 07:59.640
So this will be a static function.

07:59.640 --> 08:07.860
It'll return an int 32 and we're going to call this get XP reward for class and level.

08:08.910 --> 08:14.660
And you could specify character class as this is the kind of class.

08:14.680 --> 08:17.440
Now it's going to take an E character class.

08:17.800 --> 08:22.720
And if we search for E character class here, we'll see that we're using it up here.

08:22.720 --> 08:28.080
So we don't need to worry about including anything for character class.

08:28.090 --> 08:31.360
So first is E character class.

08:31.540 --> 08:35.410
Next is the level and we're going to use an int 32 for level.

08:35.410 --> 08:37.450
We'll call this character level.

08:38.020 --> 08:45.190
And because we're going to need to access our game mode to get that data asset, we're going to add

08:45.190 --> 08:52.480
a world context object as we're going to need a world context object to use a gameplay statics function

08:52.480 --> 08:54.130
to get the game mode.

08:54.160 --> 08:55.420
So we have this function.

08:55.420 --> 08:58.450
Let's go ahead and create a definition for it.

08:58.780 --> 09:02.380
And first thing we need to get the game mode.

09:02.410 --> 09:08.020
So I'm going to go ahead and cut this function definition and paste it somewhere up here where we're

09:08.020 --> 09:12.910
doing something similar, where we're getting our data asset from the game mode.

09:12.940 --> 09:15.160
Give startup abilities is a good example.

09:15.160 --> 09:20.410
So I'm going to paste it right here and let's get this all on one line and the first thing I'm going

09:20.410 --> 09:25.300
to do is look to give startup abilities to see how we got character class info.

09:25.330 --> 09:29.530
Looks like we got character class info using get character class info.

09:29.560 --> 09:34.660
One of our functions here, we can see it down there now it could return a null pointer.

09:34.660 --> 09:41.350
So we're going to do a null check and return if it's null and if it's null, we'll go ahead and return

09:41.350 --> 09:43.780
zero after that.

09:43.810 --> 09:46.060
We have our character class info.

09:46.090 --> 09:49.930
Now we need to perform a lookup in character class info.

09:49.960 --> 09:53.160
Let's take a look at character class info dot h.

09:53.170 --> 09:58.930
And I'm seeing red squiggles because F scalable float is incomplete, so we're definitely going to need

09:58.930 --> 10:00.610
to include something for that.

10:01.130 --> 10:02.390
Going to its definition.

10:02.390 --> 10:04.130
It's in scalable float h.

10:04.160 --> 10:10.640
If I hover over that, I see it's in gameplay ability slash public, so I should be able to just include

10:10.670 --> 10:11.780
scalable float.

10:11.990 --> 10:14.360
H So I'm going to go ahead and do that.

10:16.700 --> 10:19.130
And that should take care of that.

10:19.160 --> 10:26.090
But we came to this class so that we could take a look at how we can access XP reward that's scalable

10:26.090 --> 10:26.870
float.

10:27.050 --> 10:34.940
Now we know we have a team app filled with character class information that's struct and we have a function

10:34.940 --> 10:38.510
to get character class info based on a character class.

10:38.540 --> 10:40.430
We're going to use that function.

10:40.580 --> 10:43.220
So we're going to take character class info.

10:45.540 --> 10:52.950
And on character class info we want to call get class default info and that takes the character class.

10:52.980 --> 10:53.760
We have that.

10:53.760 --> 10:58.710
We're going to pass it in and spelling it carefully there.

10:58.740 --> 11:05.130
Now this returns an F character class default info which we're going to store in a local F character

11:05.130 --> 11:10.470
class default info, and we'll call this info.

11:12.600 --> 11:17.070
So now that we have that struct, we can then access the scalable float.

11:17.070 --> 11:23.460
And again we can see an example of how to evaluate a scalable float in or a projectile spell.

11:23.490 --> 11:26.850
We see that a scalable float has getvalue at level.

11:26.850 --> 11:28.230
That's what we want to do.

11:28.260 --> 11:31.200
So we'll access that scalable float.

11:31.230 --> 11:40.380
That's an info and it's called exp reward and we're going to call get value at level and the level we

11:40.380 --> 11:46.140
need to pass in we have access to here, it's character level, the input parameter.

11:46.140 --> 11:50.340
So we're going to pass that in and we now have a value.

11:50.340 --> 11:51.570
Now that's a float.

11:51.570 --> 11:55.110
So we'll say float exp reward.

11:57.690 --> 12:05.160
And since we have this in the form of a float, we can just cast it to an integer and we'll lose any

12:05.160 --> 12:08.010
information to the right of a decimal point.

12:08.010 --> 12:13.390
But in this game, fractions of an experience point are not going to matter.

12:13.410 --> 12:18.300
If they mattered in your game, you would make this a float returning function.

12:18.300 --> 12:23.850
So I'm going to return a static cast to n 32.

12:26.130 --> 12:27.360
XRP reward.

12:30.540 --> 12:36.030
This can be a const and so can character class default info.

12:36.060 --> 12:38.010
It can even be a const reference.

12:38.100 --> 12:42.660
Okay, so now we have a get exp reward for class and level.

12:42.690 --> 12:48.900
The last of our tasks is to create a nice getter function in the combat interface to get the character

12:48.900 --> 12:49.610
class.

12:49.620 --> 12:58.230
So let's go to our combat interface and interaction combat interface and make a function to return the

12:58.230 --> 12:59.370
character class.

12:59.400 --> 13:05.640
If we're going to use the character class enum type, we're going to have to include the file that it's

13:05.640 --> 13:06.860
defined in.

13:06.870 --> 13:11.040
We can figure out what that is by searching our project.

13:11.190 --> 13:19.500
It's defined in character class info, So we'll go ahead and just include ability system slash data,

13:20.130 --> 13:25.770
slash character class info dot h and we'll create a function that returns this type.

13:25.770 --> 13:28.500
So we'll go all the way down to the bottom.

13:28.500 --> 13:32.730
This function will return an E character class enum.

13:32.740 --> 13:35.440
We're going to call this get character class

13:37.810 --> 13:41.350
and it'll be a blueprint Native event Blueprint callable.

13:41.350 --> 13:46.000
And we just need to override get character class implementation.

13:46.000 --> 13:51.940
And let's go to Aura character base because if we search for character class here.

13:55.250 --> 13:56.810
We actually don't see it.

13:56.810 --> 13:59.270
That's because it's an enemy, isn't it?

13:59.450 --> 14:01.940
We have a character class there.

14:02.150 --> 14:06.090
Well, we could just put this in character base instead.

14:06.110 --> 14:06.950
Let's do that.

14:06.950 --> 14:13.490
I'm going to go ahead and cut it and move it into a character base and the protected section, we'll

14:13.490 --> 14:19.940
put it right here and we'll also override the function on the combat interface.

14:19.940 --> 14:26.870
So we'll say virtual character class, get character class implementation.

14:26.900 --> 14:33.440
That's an override and we're going to have to include the character class info.

14:34.730 --> 14:36.770
So we'll put that here in character base.

14:36.770 --> 14:38.840
It was an aura enemy, actually.

14:39.880 --> 14:45.400
Right there so we can cut that out of or an enemy put it in or a character base.

14:45.640 --> 14:52.630
Now we can use the character class and let's go ahead and create the definition and return the character

14:52.630 --> 14:53.320
class.

14:54.040 --> 14:58.360
That way, if we ever need to get the character class of aura, we can.

14:58.360 --> 15:01.570
But aura is going to be an Elementalist.

15:01.570 --> 15:08.620
So really quickly, I'm just going to go to private character or a character, and in the constructor

15:08.620 --> 15:15.010
I'm just going to set character class equal to E character class Elementalist.

15:15.130 --> 15:15.610
Okay.

15:15.610 --> 15:18.340
So that's going to conclude everything.

15:18.340 --> 15:27.340
I think the last thing to do is to actually set the curve table in character class info, the data asset,

15:27.340 --> 15:28.420
so we can do that.

15:28.420 --> 15:31.270
Now let's go ahead and launch and debug mode.

15:32.690 --> 15:34.130
So back in the editor.

15:34.130 --> 15:36.320
Let's go to character class info.

15:36.320 --> 15:42.410
And in each of our character classes it looks like we have XP reward.

15:42.440 --> 15:48.890
Now I'm going to set the value to one, but use our XP reward curve table and set the curve for the

15:48.890 --> 15:49.490
Ranger.

15:49.490 --> 15:52.490
I'm selecting the Ranger curve for the warrior.

15:52.520 --> 15:53.210
Same thing.

15:53.210 --> 15:56.450
Setting it to one choosing XP reward.

15:56.450 --> 16:03.440
But for the warrior we choose warrior and for the elementalist set it to one Choose XP reward and choose

16:03.440 --> 16:04.460
elementalist.

16:04.490 --> 16:07.490
Now they all have their scalable floats set.

16:08.000 --> 16:16.340
Okay, we're one step closer now that we have defined amounts of experience for each of our enemy types

16:16.340 --> 16:24.290
and an aura ability system library function that can take in a level and a character class.

16:24.320 --> 16:29.270
We can then see what value we get when we slay one of these enemies.

16:29.270 --> 16:32.790
So that's a very important component to experience.

16:33.150 --> 16:33.930
Excellent job.

16:33.930 --> 16:35.910
We'll continue in the next video.
