WEBVTT

00:06.950 --> 00:08.080
Welcome back.

00:08.090 --> 00:15.860
Now, we had our game plan for experience and we're up to the point where we need to reward experience

00:15.860 --> 00:16.730
points.

00:16.910 --> 00:22.970
So basically we need an amount of XP that each enemy gives based on its level and class.

00:23.150 --> 00:27.590
And we also need to actually award XP when killing an enemy.

00:27.710 --> 00:31.790
Now, once we've gotten that handled, we can handle leveling up.

00:31.790 --> 00:35.660
But first we need to handle actually gaining experience.

00:35.870 --> 00:39.830
So this is a system that we're going to need to put some thought into.

00:39.830 --> 00:46.130
And in order to put some thought into it, let's just walk through the process of what happens when

00:46.130 --> 00:50.270
a player gains experience, specifically when it comes to combat.

00:50.480 --> 00:57.290
So we'll have a player, let's say they're controlling some pawn or character and that character attacks

00:57.290 --> 00:58.100
an enemy.

00:58.280 --> 01:02.780
Now, when this happens, typically the enemy will take some damage.

01:03.420 --> 01:10.950
And this act of taking damage is going to trigger a response in the attribute set as they've just received

01:10.950 --> 01:11.770
damage.

01:11.790 --> 01:18.360
The damage meta attribute is going to trigger a response, at which point the attribute set decides

01:18.360 --> 01:19.320
what happens.

01:19.320 --> 01:24.270
And the attribute set knows at this point whether this damage was fatal or not.

01:24.360 --> 01:26.400
Now we need to gain experience.

01:26.400 --> 01:33.810
If the damage was fatal, we've just slain an enemy, which means the enemy needs an amount of experience

01:33.810 --> 01:36.210
to reward the attacker with.

01:36.240 --> 01:40.410
So we already knew that that was a crucial part of all this.

01:40.410 --> 01:48.570
But at this point, the attribute set needs to know how much experience to award and for that matter,

01:48.570 --> 01:50.910
how to award that experience.

01:51.060 --> 01:56.960
Now we know that we can wait for gameplay events and we can send gameplay events to actors.

01:56.970 --> 02:04.180
If our attribute set knows that this damage was fatal and knows how much experience to give to the attacker,

02:04.180 --> 02:09.340
it can send a gameplay event and send that reward value along with it.

02:09.370 --> 02:15.700
Now if we're sending a gameplay event to the attacker, the attacker needs to be able to receive it.

02:15.940 --> 02:22.390
Now we can receive gameplay events if we have some kind of gameplay ability that's waiting for one.

02:22.480 --> 02:24.820
So we can create a gameplay ability.

02:24.850 --> 02:30.700
This can be a passive gameplay ability in a sense that we can activate it at the beginning of the game

02:30.700 --> 02:33.380
and keep it active throughout the game.

02:33.400 --> 02:41.230
We can call this listen for events and this gameplay ability can use wait gameplay event to wait for

02:41.230 --> 02:47.590
any gameplay events that get sent its way and as soon as it receives a gameplay event it can then get

02:47.590 --> 02:50.410
that XP reward and do something with it.

02:50.440 --> 02:53.830
Now what can we do with the XP reward?

02:54.130 --> 03:03.040
Well, our XP is on the player state and we chose not to make it an attribute, but it would be very

03:03.040 --> 03:11.080
convenient if attribute sets could respond to changes in incoming experience points so that it could

03:11.080 --> 03:12.310
act accordingly.

03:12.340 --> 03:19.660
So if we could create a gameplay effect and make a gameplay effect spec that can carry that XP reward,

03:19.690 --> 03:26.020
we can apply that to the self to the ability system component that owns this gameplay ability.

03:26.170 --> 03:32.380
Now if we're using gameplay effects, those are meant to affect attributes, right?

03:32.380 --> 03:36.070
But we chose not to make our XP an attribute.

03:36.100 --> 03:39.040
Rather it's a variable on the player state.

03:39.040 --> 03:42.400
But that doesn't mean that we can't set some kind of attribute.

03:42.430 --> 03:48.340
This is actually a great example of when to use a meta attribute, just like our incoming damage meta

03:48.340 --> 03:49.150
attribute.

03:49.180 --> 03:51.760
This is an attribute that gets consumed.

03:51.760 --> 03:55.660
It's zeroed out and then used to change something.

03:55.900 --> 04:04.360
So if we're setting this incoming XP attribute on the attacker, then its own attribute set can then

04:04.360 --> 04:08.350
add to the XP on the attacker's player state.

04:08.380 --> 04:14.410
Now this can be done through an interface or any other way that we see fit, but this is how the player

04:14.410 --> 04:21.640
state can then get its XP increased and once that happens, the player state will in turn broadcast

04:21.640 --> 04:28.510
its delegate to the widget controller that's responsible for updating widgets such as the XP bar.

04:28.690 --> 04:35.710
So as you can see in an RPG game involving experience, we have a number of moving parts that we need

04:35.710 --> 04:36.730
to set up here.

04:36.730 --> 04:40.660
So for our next steps forward, we have another game plan.

04:40.750 --> 04:45.910
We first need an XP reward on our enemies and a way to get it.

04:45.910 --> 04:49.270
So this could be a variable on the enemy class.

04:49.270 --> 04:56.050
But then we should create some kind of access or function probably on the enemy interface that we can

04:56.050 --> 04:57.100
easily get.

04:57.130 --> 05:04.540
Then after that we need a meta attribute for incoming XP and this is so that we can respond to things

05:04.540 --> 05:06.340
in the attributes set.

05:06.760 --> 05:11.430
Now we're also going to create a gameplay ability that will be passive.

05:11.440 --> 05:17.590
We can call this listen for events and granted in the beginning of the game and this can be something

05:17.590 --> 05:19.300
that we never deactivate.

05:19.300 --> 05:22.390
It's just always going, listening for events.

05:22.390 --> 05:29.620
And as soon as it receives an event with a specific set of data perhaps identified by a gameplay tag,

05:29.620 --> 05:36.510
then it can apply a gameplay effect in response to that event setting that incoming XP.

05:36.880 --> 05:42.430
Now we also need to award the XP and the attribute set whenever the damage is fatal.

05:42.430 --> 05:50.110
So for enemies taking damage as soon as they've taken fatal damage, we need to award the XP by sending

05:50.110 --> 05:57.040
that gameplay event and we also need to handle that incoming XP and the attribute set and increase the

05:57.040 --> 05:58.660
XP on the player state.

05:58.660 --> 06:04.300
So the attribute set will be responsible for changes to XP and two capacities.

06:04.430 --> 06:13.790
One is sending a gameplay event when damage is fatal and two is handling the incoming XP meta attribute

06:13.790 --> 06:17.210
and increasing the real XP on the player state.

06:17.240 --> 06:24.140
Once we've tied all this together, then when slaying an enemy which has its own XP amount, we should

06:24.140 --> 06:27.260
see XP increase on the XP bar.

06:27.260 --> 06:34.280
But most importantly we'll have our XP kept track of and the next step will be handling the situation

06:34.280 --> 06:42.800
when XP rises above that level up requirement for the current level where we can increase the player's

06:42.800 --> 06:45.680
level and reward them for leveling up.

06:45.830 --> 06:50.840
So now that we know the steps forward, let's continue in the next video.
