WEBVTT

00:07.080 --> 00:08.190
Welcome back.

00:08.220 --> 00:15.150
Now we're gaining experience and we made a level up function which currently does nothing, but we'll

00:15.150 --> 00:19.720
fill that in with functionality, but we currently don't know when we should level up.

00:19.740 --> 00:21.860
That's something we should figure out.

00:21.870 --> 00:23.580
So I'm going to close the editor.

00:23.970 --> 00:32.070
I'm going to go to my aura attribute set and close all other tabs and right here in post gameplay effect

00:32.070 --> 00:33.000
execute.

00:33.000 --> 00:39.360
As we're checking the incoming exp, we have a to do to check to see if we should level up.

00:39.360 --> 00:46.050
So we have to decide if we should level up and we're going to do that inside of our if statement.

00:46.170 --> 00:51.660
Once we know that our source character implements the player interface because if the source character

00:51.660 --> 00:57.990
doesn't implement the player interface, there's no point as my enemies aren't going to level up in

00:57.990 --> 00:58.590
your game.

00:58.590 --> 00:59.910
That might be different.

00:59.910 --> 01:05.520
You may wish to level up your enemies, which would require a minor adjustment.

01:05.550 --> 01:10.450
What I would like my enemies to not level up so only my character.

01:10.450 --> 01:18.100
And for incoming exp that's going to be the source character as the source character is the one applying

01:18.100 --> 01:19.510
the gameplay effect.

01:19.720 --> 01:26.260
Remember we have a passive gameplay ability with a gameplay effect and we're applying the spec to self.

01:26.470 --> 01:30.220
In case this might be something you may be confused with.

01:30.220 --> 01:32.890
I'm just going to clarify that in a comment here.

01:32.890 --> 01:36.580
We're going to say source character is the owner.

01:36.970 --> 01:51.310
Since gar listen for events applies g event based effect adding to incoming exp.

01:52.240 --> 01:55.750
So this just makes it clear in case we get confused.

01:55.900 --> 01:59.110
All right, so how do we check to see if we should level up?

01:59.180 --> 02:04.810
Well, I'm going to check before we add to our exp, we want to add to our exp regardless, but I want

02:04.810 --> 02:07.030
to know if a level up is in order.

02:07.360 --> 02:07.930
Now.

02:07.930 --> 02:13.660
Now in order to check to see if we should level up, we need to know our current level so I'm going

02:13.660 --> 02:24.250
to make a const int 32 called current level and we're going to use a combat interface and call execute

02:24.280 --> 02:28.150
get player level passing in props dot source character.

02:28.390 --> 02:30.310
Now we have our current level.

02:30.760 --> 02:37.810
I'd also like to get our current exp, so I'm going to make a const int 32 called current exp as well.

02:37.810 --> 02:42.580
And for this we need to get our exp.

02:42.610 --> 02:44.260
Now how do we get our exp?

02:44.590 --> 02:46.870
What's an easy way to do it?

02:46.900 --> 02:51.190
Because our exp exists on the player state, right?

02:51.190 --> 02:55.120
And we can't really just dig into the player state.

02:55.240 --> 02:58.480
The player state already depends on our attribute set.

02:58.510 --> 03:00.520
We don't want a circular dependency.

03:00.610 --> 03:03.820
Let's take a look at what our player interface has.

03:03.850 --> 03:04.660
Oh look at this.

03:04.660 --> 03:06.190
We have an add to exp.

03:06.580 --> 03:09.640
We could easily have a get exp.

03:10.480 --> 03:12.220
That's what I'd like to do.

03:12.220 --> 03:14.410
So let's make a getter for our exp.

03:14.830 --> 03:23.740
I'm just going to copy add to exp and paste up here and change this from a void function to an int 32

03:23.740 --> 03:25.990
returning function called get exp.

03:27.730 --> 03:33.130
It does not need to take any input parameters, it can even be const.

03:33.460 --> 03:39.160
So now that we have this blueprint native events, we can override the implementation version of it

03:39.160 --> 03:41.260
in our character.

03:41.350 --> 03:45.580
So let's go to our character and implement it here in the player interface.

03:45.580 --> 03:49.540
Looks like my comment says Player's interface.

03:49.840 --> 03:57.610
I'm going to change that to player interface and we're going to override virtual int 32 get Exp implementation

03:57.790 --> 03:59.670
and this will be pretty simple.

03:59.680 --> 04:08.410
We're going to generate the definition and get our player state just like we did in get player level

04:08.410 --> 04:09.370
implementation.

04:10.970 --> 04:16.340
And after checking the player state, we're going to get our player state and call get exp.

04:17.690 --> 04:20.360
And this is what we can return from the function.

04:20.870 --> 04:23.960
So now we have git exp implementation.

04:23.990 --> 04:29.540
So back in our attribute set we can call that I player interface.

04:30.540 --> 04:31.620
Execute.

04:31.740 --> 04:32.760
Get exp.

04:33.270 --> 04:35.010
Passing in Props.

04:35.220 --> 04:36.190
Source Character.

04:36.210 --> 04:39.930
Now I just noticed we're checking if we implement you player interface.

04:39.960 --> 04:42.520
We're not checking for combat interface.

04:42.540 --> 04:47.970
We know that if we implement player interface, we definitely do implement combat interface because

04:47.970 --> 04:50.550
players and enemies both implement it.

04:50.550 --> 04:56.340
But we could just place a check here just to show that we care about checking.

04:56.340 --> 05:00.360
So we're going to say props, dot source character implements.

05:01.740 --> 05:04.530
And we can use you combat interface as well.

05:05.010 --> 05:05.340
Okay.

05:05.340 --> 05:12.540
So once we have our current level and current XP, what we should do is we should see what level corresponds

05:12.540 --> 05:15.230
to our new XP amount.

05:15.240 --> 05:22.590
In other words, if we take our current XP and we add this incoming XP to it, what level would that

05:22.590 --> 05:23.830
correspond to?

05:23.850 --> 05:29.370
In other words, if we make a const int 32 called new level, what would that be?

05:29.460 --> 05:36.210
Well, we have the capability to find that out because we created a data asset that can do that.

05:36.240 --> 05:44.580
If we go into our public folder, into ability system data and find level up info, we have this find

05:44.610 --> 05:46.050
level for XP.

05:46.230 --> 05:50.070
Now our level up info exists on our player state.

05:50.100 --> 05:57.210
If we go to player or a player state, we have that level up info data asset right here.

05:57.210 --> 06:02.740
And once again ora attribute set does not depend on the player state.

06:02.830 --> 06:10.150
So what we can do is just make a function on our interface for performing that lookup.

06:10.420 --> 06:18.400
We can go into interaction player interface and just create a function that can do this for us.

06:18.400 --> 06:22.060
So we can call this function find level for XP.

06:23.090 --> 06:26.030
It can take an INT 32 called NXP.

06:26.600 --> 06:31.880
It can also be const and we can implement this in a character.

06:31.970 --> 06:40.610
So virtual int 32 find level for NXP implementation and we can go ahead and generate the definition.

06:40.610 --> 06:42.590
We can get our player state.

06:43.490 --> 06:46.810
So copying that from get XP implementation.

06:46.820 --> 06:51.110
After we get our aura player state, we can take Aura player state.

06:53.340 --> 07:02.940
Get level up info and we can call find level for exp passing in NXP and we can return this value.

07:04.170 --> 07:08.920
And now we have an interface function we can call an attribute set.

07:08.940 --> 07:12.750
So new level is going to be a player interface.

07:14.490 --> 07:17.520
Execute find level for XP.

07:17.940 --> 07:19.990
Now we want to find the new level.

07:20.010 --> 07:26.340
The level for the amount of XP that we would have after adding incoming XP to current XP.

07:26.370 --> 07:33.420
So the amount we're going to pass in here is current XP plus our local incoming XP.

07:36.500 --> 07:41.570
And of course the first input has to be props source character, doesn't it?

07:43.070 --> 07:46.050
So first we pass in the source character.

07:46.070 --> 07:48.260
Then we pass in the N 32.

07:48.290 --> 07:54.590
So this is the new amount of XP that we're going to add to our XP.

07:55.130 --> 08:01.400
So now that we know the new level, this is how we're going to know if we should level up because we

08:01.400 --> 08:08.090
know our current level and the new level that corresponds to our new amount of XP that we're about to

08:08.090 --> 08:13.250
have, we can take the difference between these and that will tell us how many times we should level

08:13.250 --> 08:13.830
up.

08:13.850 --> 08:23.780
So we can make a const int 32 called number of level ups or even just num level ups.

08:27.160 --> 08:30.760
And that's equal to new level minus current level.

08:31.680 --> 08:39.810
Now, if we call this function with not enough XP to level up, let's say we were at 100 and we only

08:39.810 --> 08:44.460
went up to 120, we need 300 to go up to level two.

08:44.490 --> 08:51.150
Well, this will return the same level that we're at, which would be one and new level minus current

08:51.150 --> 08:52.260
level would be zero.

08:52.260 --> 08:54.810
So the number of times we've leveled up was zero.

08:54.840 --> 09:01.830
So we know based on this value, if we leveled up or not, it's if this value is greater than zero.

09:01.830 --> 09:09.030
So we can say if num level ups oops writer auto completed and auto included something for me.

09:09.100 --> 09:12.450
Looks like I have several dead includes that I can remove here.

09:12.450 --> 09:18.480
I don't need gameplay statics currently I don't need or log channels and I don't need this header that

09:18.480 --> 09:20.100
was just auto included.

09:20.100 --> 09:21.480
So all right.

09:21.480 --> 09:22.860
Back to what I was doing though.

09:22.860 --> 09:30.990
We need to check num level ups and if that's greater than zero, we're leveling up potentially multiple

09:30.990 --> 09:32.050
times, right?

09:32.140 --> 09:34.390
So what do we do in that case?

09:34.390 --> 09:41.380
Well, for one, we can call our characters level up function so we can take AI player interface.

09:43.220 --> 09:47.360
Execute level up passing in props source character.

09:47.780 --> 09:51.620
That's one thing that functions currently empty and doesn't do anything.

09:51.620 --> 09:57.920
But since we're leveling up, we can call that and then we can do any other mathematical perks that

09:57.920 --> 09:58.670
we want.

09:58.700 --> 10:03.780
For one, we're going to have an attribute point reward and a spell point reward.

10:03.800 --> 10:08.510
We're also going to add to our player level on our player state.

10:08.540 --> 10:11.570
We're going to add to all of those things.

10:11.780 --> 10:18.770
So what I'd like to do is, first of all, get our level up info to tell us what our attribute point

10:18.770 --> 10:20.060
and spell point rewards are.

10:20.090 --> 10:21.050
Let's make a Todo here.

10:21.050 --> 10:34.790
We'll say get attribute points, reward and spell points reward and we'll continue this comment and

10:34.790 --> 10:37.280
say add to player level.

10:38.180 --> 10:47.150
We'll have another one to add to attribute points and spell points and we also need to add to XP, but

10:47.150 --> 10:50.900
we're doing that already, so that's taken care of.

10:50.930 --> 10:57.380
But we want to add to player level attribute points and spell points and of course execute level up.

10:57.410 --> 11:00.950
Now when we level up, we typically fill up the health and mana.

11:00.950 --> 11:04.660
So we'll also say fill up health and mana.

11:04.670 --> 11:07.340
So quite a few things to do when we level up.

11:07.340 --> 11:14.150
Right now, if we want to get our attribute points, reward and spell points reward those exist on level

11:14.150 --> 11:17.330
up info which exists on the player state.

11:17.330 --> 11:20.600
So these would be good interface functions to have.

11:20.630 --> 11:26.570
Adding to the player level attribute points, spell points, all of that stuff is also stuff that requires

11:26.570 --> 11:27.530
the player state.

11:27.530 --> 11:30.810
So we need functions on our player interface for all of these.

11:30.830 --> 11:34.970
In other words, get attribute points, reward and get spell points.

11:34.970 --> 11:36.590
Reward should be functions.

11:36.590 --> 11:44.010
So in our to do, I'm just going to list the functions we need to make get attribute points reward.

11:45.700 --> 11:48.820
I'm just going to say we need to make that function.

11:49.150 --> 11:50.890
Get spell points reward.

11:51.760 --> 11:53.560
I'm going to say that we need that.

11:56.380 --> 11:57.830
Add to player level.

11:57.850 --> 11:59.530
That should be a function.

11:59.920 --> 12:01.690
Add to player level.

12:01.960 --> 12:04.450
And then of course add to attribute points.

12:04.450 --> 12:05.800
Add to spell points.

12:06.400 --> 12:08.890
So we'll say add two attribute points.

12:11.200 --> 12:13.270
Add to spell points.

12:14.320 --> 12:17.750
So these can all be functions on our player interface.

12:17.770 --> 12:19.540
So let's start at the top.

12:19.540 --> 12:22.990
We need get attribute points and spell points rewards.

12:23.200 --> 12:26.920
We'll go into player interface and make getters for those.

12:27.130 --> 12:31.240
I'm going to put all my getters together, so I'm going to put it right under get exp.

12:31.660 --> 12:39.370
So this will be an int 32, not 4332 called get attribute points reward.

12:41.720 --> 12:43.160
And it can be const.

12:43.670 --> 12:46.880
So I'd like this to be a blueprint native event.

12:48.230 --> 12:52.700
I'd also like the spell points version of this, so I'm going to copy and paste it.

12:52.850 --> 12:57.290
And this one will be get spell points reward.

12:57.920 --> 13:03.620
So we're going to have to implement those, but I'm going to go ahead and declare all the functions

13:03.620 --> 13:04.710
we should implement.

13:04.730 --> 13:07.010
So we got these two.

13:07.100 --> 13:12.360
We need add to player level and the add to attribute points and spell points.

13:12.380 --> 13:14.300
Let's declare those.

13:15.230 --> 13:19.790
So just after add to XP, we are going to have three more.

13:19.790 --> 13:22.610
We'll start with add to player level.

13:25.170 --> 13:27.570
We'll call the input in player level.

13:29.900 --> 13:33.830
And then we'll have add to attribute points.

13:36.500 --> 13:39.470
And the input will be in attribute points.

13:41.380 --> 13:43.900
And we'll have an ad to spell points.

13:45.840 --> 13:52.560
So we'll call this add to spell points and the input will be called in spell points.

13:53.850 --> 14:01.260
Okay, so we have a number of functions we should implement the implementation versions of in or a character

14:01.290 --> 14:03.660
that will be here in the player interface.

14:03.660 --> 14:05.880
So I can look at my comment here.

14:05.880 --> 14:09.420
We have get attribute points reward, let's implement that.

14:09.450 --> 14:16.200
So virtual int 32 get attribute points reward implementation.

14:16.840 --> 14:19.540
Next we have get spell points reward.

14:20.800 --> 14:22.690
Virtual and 32.

14:23.410 --> 14:26.230
Get spell points Reward implementation.

14:26.680 --> 14:29.420
Next we have add to player level.

14:29.440 --> 14:39.460
Add to attribute points add to spell points so we have virtual void add to player level.

14:41.650 --> 14:47.470
Virtual void add to spell points and add to attribute points.

14:47.470 --> 14:49.030
I'm going to put that one first.

14:50.020 --> 14:51.640
After fixing my typo.

14:52.860 --> 14:56.520
So virtual void add to attribute points.

14:56.970 --> 14:59.670
All right, let's get those definitions generated.

15:02.220 --> 15:06.660
And these are going to all just get our aura player state.

15:06.990 --> 15:10.680
So I'm going to get those two lines.

15:11.760 --> 15:13.560
And then get attribute points.

15:13.560 --> 15:24.390
Reward is going to return or a player state or a player state level up info level up information.

15:24.390 --> 15:30.390
And we actually need to know the level to get the attribute points reward, don't we?

15:30.420 --> 15:37.450
So get attribute points, reward and spell points reward need to take in an int 32 for the level.

15:37.500 --> 15:38.550
So let's do that.

15:38.550 --> 15:41.670
We'll go back to the player interface, get attribute points.

15:41.670 --> 15:45.810
Reward needs to take in an int 32 called level.

15:47.590 --> 15:48.520
Get spell points.

15:48.520 --> 15:51.670
Reward needs an N 32 called level as well.

15:51.760 --> 15:53.350
So we'll fix that.

15:53.380 --> 16:00.040
We'll go to our character and make sure these two functions take in 30 twos and then back in the CPP

16:00.040 --> 16:00.400
file.

16:00.400 --> 16:03.700
We'll make sure that they take in 30 twos and level up.

16:03.700 --> 16:06.190
Information can be indexed at level.

16:06.940 --> 16:10.330
We can use Dot and get attribute point reward.

16:10.810 --> 16:14.470
So this will be similar and get spell point reward.

16:14.470 --> 16:16.390
We're going to paste that all.

16:16.420 --> 16:21.410
The only difference is we're going to get our spell point reward instead for that level.

16:21.430 --> 16:28.450
Now for add to player level, this is going to get our player state and we're going to add to the player

16:28.450 --> 16:34.540
level and or a player state has add to level so we can handle that here.

16:34.690 --> 16:41.020
So first we're going to get our player state, take our player state and call add to level.

16:42.650 --> 16:48.290
And of course this cannot be const if we're going to call add to level and we're going to pass in in

16:48.290 --> 16:54.620
player level, really this should be called in level amount to add or something like that.

16:54.620 --> 17:01.790
But add to implies that well we're adding to the level now, add to attribute points and add to spell

17:01.820 --> 17:02.240
points.

17:02.240 --> 17:04.190
Let's see if we had created those.

17:04.190 --> 17:07.790
We don't have add to attribute points or spell points.

17:07.790 --> 17:14.450
In fact, our aura player state doesn't have attribute points and spell points, so we'll go ahead and

17:14.450 --> 17:16.010
create those later.

17:16.010 --> 17:18.740
And for now we'll just put a to do on these.

17:18.740 --> 17:27.410
We'll say comment to do add attribute points to player state.

17:28.100 --> 17:31.220
I'd like those to be variables on the player state.

17:31.250 --> 17:35.480
We'll do the same thing for to do add spell points.

17:36.860 --> 17:38.900
Two player state.

17:39.230 --> 17:41.750
So only so much we can do all at once.

17:41.750 --> 17:43.940
We can't go on too many tangents right now.

17:43.940 --> 17:47.660
For now, though, we have these interface functions and they're implemented.

17:47.660 --> 17:50.510
So back in attribute set, we can take care of this.

17:50.510 --> 17:56.420
To do so, we created get attribute points, reward and spell points, rewards.

17:56.420 --> 18:01.700
We can get those so we can say in 32 attribute points

18:03.800 --> 18:08.000
reward and we can use AI player interface.

18:10.780 --> 18:17.620
Execute get attribute points reward passing in props dot source character.

18:18.430 --> 18:23.170
And we can pass in the level for the attribute points reward.

18:23.470 --> 18:30.850
So for each level in our data asset, we put an attribute points reward for leveling up at that level

18:30.850 --> 18:35.350
so we can pass in our current level here and that can be const.

18:35.530 --> 18:41.230
We can also make a const int 32 called spell points reward.

18:42.680 --> 18:45.350
And we can use AI player interface.

18:45.560 --> 18:53.180
Execute Get spell points reward passing in both props, dot source character and current level here

18:53.180 --> 18:53.870
as well.

18:55.120 --> 19:02.290
Now that we have those, we can do these other things like add to player level so we can take our AI

19:02.320 --> 19:05.680
player interface and execute.

19:05.710 --> 19:07.420
Add to player level.

19:08.500 --> 19:15.540
So first we pass in props dot source character and we want to add to the current level how much?

19:15.550 --> 19:17.470
Well, the number of level ups.

19:17.470 --> 19:19.180
So num level ups.

19:20.240 --> 19:22.310
So that takes care of that to do.

19:22.580 --> 19:26.000
And then we want to add to our attribute points and spell points.

19:26.000 --> 19:32.380
And again, our character doesn't do anything for this yet, but we'll go ahead and call those functions.

19:32.390 --> 19:35.150
So we'll say AI player interface.

19:36.610 --> 19:45.670
Execute add to attribute points and we're going to go ahead and pass in props, dot source character.

19:45.670 --> 19:48.190
And how much do we want to add to our attribute points?

19:48.190 --> 19:55.450
We want to add our attribute points, reward that we looked up and then we can take AI player interface

19:56.260 --> 20:00.040
and execute add to spell points.

20:00.190 --> 20:06.280
And again, we're going to pass in props dot source character and our spell points reward.

20:08.140 --> 20:09.880
So that takes care of those.

20:10.330 --> 20:16.000
Now we can fill up our health and mana and that is actually something we already can do.

20:16.000 --> 20:16.480
From here.

20:16.480 --> 20:24.670
We can just call set health and we can set it to the max health, get max health like so, and we can

20:24.670 --> 20:27.520
set mana to its max as well.

20:27.520 --> 20:29.560
Set mana to get max mana.

20:32.130 --> 20:32.550
That way.

20:32.550 --> 20:33.540
We're all filled up.

20:33.540 --> 20:36.990
We're topped off Our health and Mana globes will be filled.

20:37.440 --> 20:43.290
So now we're handling all the level up stuff, so we don't need this to do to see if we should level

20:43.290 --> 20:43.770
up.

20:44.750 --> 20:51.650
Now post gameplay effect execute is looking a little unruly so we could really refactor these into each

20:51.650 --> 20:53.000
their own functions.

20:53.000 --> 20:54.860
That's fine for now.

20:54.860 --> 21:01.910
We'll refactor it in a little bit because this video is getting long, but at least now we're executing

21:01.910 --> 21:09.380
this level up capability and really all we're doing here is executing these interface functions and

21:09.380 --> 21:15.470
or a character implements them such that we're calling functions on the player state, such as add to

21:15.470 --> 21:16.540
player level.

21:16.550 --> 21:21.590
So we're going to want to show our player level in the HUD and our player state.

21:21.590 --> 21:27.680
If we go to our player state and take a look at its add to player level and other add to functions where

21:27.680 --> 21:29.390
broadcasting delegates.

21:29.390 --> 21:36.290
So it's already set up so that once we add to the player level, those delegates will be broadcast and

21:36.290 --> 21:43.210
then we can very easily respond to these in our widget controller and therefore our widgets.

21:43.220 --> 21:45.990
So this is a great stopping point.

21:45.990 --> 21:50.370
Let's just compile, make sure that there's no compiler errors we might have missed.

21:51.110 --> 21:53.060
And with a successful compile.

21:53.060 --> 21:54.950
We'll continue in the next video.

21:54.980 --> 21:56.090
I'll see you soon.
