WEBVTT

00:06.840 --> 00:08.220
Welcome back.

00:08.550 --> 00:14.460
So we know that we're applying a gameplay effect whenever we launch a fireball and that gameplay effect

00:14.460 --> 00:19.170
is going to result in subtracting from the health of the enemy.

00:19.500 --> 00:26.220
Now that we know about damage meta attributes, we're going to use a meta attribute for damage rather

00:26.220 --> 00:31.050
than having our gameplay effect reach in and change the health directly.

00:31.290 --> 00:39.810
So if I go to blueprints ability system gameplay effects and go to my G damage and scroll down, we'll

00:39.810 --> 00:44.610
see that this is an instant gameplay effect set to subtract ten from the health.

00:44.760 --> 00:48.440
So this is very much a placeholder gameplay effect, right?

00:48.450 --> 00:51.020
It's hard coding negative ten.

00:51.030 --> 00:56.940
We're not even using a curve table or anything like that and we're setting the health, but we'd like

00:56.940 --> 01:04.860
to modify the meta attribute and then allow the attribute set to go through any processing of that data

01:04.860 --> 01:06.210
that we'd like it to do.

01:06.210 --> 01:12.670
And we'd also like to use that damage meta attribute in any of our custom calculations as well.

01:12.670 --> 01:19.780
We can change this to a custom calculation class, for example, as damage is going to be one of the

01:19.780 --> 01:22.960
more complicated types of modifiers.

01:23.080 --> 01:28.720
So anyway, we'd like a damage meta attribute and for that we're going to close the editor and head

01:28.720 --> 01:31.090
back over to our attributes set.

01:31.210 --> 01:33.640
So I'm going to open my attribute set.

01:33.640 --> 01:42.190
I'm also going to close other tabs and get my header and CPP files open here and here in my Aura attribute

01:42.190 --> 01:49.570
set, we're going to create a new attribute and this one will be our first meta attribute.

01:49.570 --> 01:56.920
So just below vital attributes, I'm going to make a multi-line comment that says meta attributes.

01:58.190 --> 02:00.080
And we'll have our first one.

02:00.080 --> 02:07.520
So we'll have a gameplay attribute data called Incoming Damage.

02:07.760 --> 02:15.890
And incoming damage is going to get a new property, but it's not going to get replicated.

02:15.890 --> 02:20.720
It will not get a rep notify as meta attributes are not replicated.

02:20.720 --> 02:27.710
We set them on the server and then on the server we process the data and then change any replicated

02:27.710 --> 02:28.340
attributes.

02:28.340 --> 02:35.360
Based on those calculations, we can make it blueprint read only though and we'll give it a category.

02:35.360 --> 02:43.910
But the category is going to be meta attributes and we can make attribute accessors.

02:43.910 --> 02:52.820
So let's go ahead and use our attribute accessors macro passing in you ora attribute set and incoming

02:52.820 --> 02:53.630
damage.

02:54.180 --> 02:57.710
So that takes care of making the meta attribute.

02:57.720 --> 03:00.720
So how do we actually use the meta attribute?

03:00.750 --> 03:03.000
That's the next thing we'd like to handle.

03:03.000 --> 03:13.050
So let's go into our CPP file and we'll go to post gameplay effect, execute right here and here we

03:13.050 --> 03:21.420
can actually check to see if the evaluated data has the attribute incoming damage and then we can respond

03:21.420 --> 03:22.350
accordingly.

03:22.590 --> 03:31.200
So down here at the bottom we'll just place an If check and say if data dot evaluated data dot attribute

03:32.070 --> 03:37.260
equals and we'll use get incoming damage attribute.

03:38.010 --> 03:42.600
So here we know that we're actually getting a change to incoming damage.

03:42.630 --> 03:51.270
Now incoming damage being a meta attribute should be used for its value and then reset or zeroed out.

03:51.270 --> 03:53.980
In other words, we're going to consume that data.

03:53.980 --> 04:01.360
So to do that, we usually make a local float variable that has the value of incoming damage.

04:01.360 --> 04:12.040
So we could make a const float called local incoming damage and set it equal to the result of get incoming

04:12.040 --> 04:12.880
damage.

04:13.060 --> 04:15.460
So we're getting its float value.

04:15.490 --> 04:22.900
So we're caching that value locally and then we can set that meta attribute to zero so we can say set

04:22.900 --> 04:25.750
incoming damage and we can pass in zero.

04:25.750 --> 04:32.080
So now that we have local incoming damage, we can decide what to do with it and we should only really

04:32.080 --> 04:35.230
do anything if its value isn't zero.

04:35.230 --> 04:40.960
So we're going to check if local incoming damage is greater than zero.

04:42.070 --> 04:44.230
And in that case, we can do something.

04:44.230 --> 04:51.700
Now, so far, we have really nothing to do with this meta attribute except to use it to set the health

04:51.700 --> 04:52.450
value.

04:52.480 --> 04:53.710
So we can do that.

04:53.710 --> 04:58.840
We can set the health value and we can even handle any additional clamping as well.

04:58.870 --> 05:07.210
We can make a const float called New Health and calculate what the health should be now and what that

05:07.210 --> 05:13.180
should be is the result of get health minus this local incoming damage.

05:14.450 --> 05:18.920
And we can make sure that that is not going to be a negative value.

05:18.950 --> 05:23.960
So when we call set health, we can call set health with an F math clamp.

05:24.950 --> 05:26.570
Clamping the value.

05:26.600 --> 05:29.210
New health between zero.

05:30.650 --> 05:33.590
And Maxhealth so we can call get Maxhealth.

05:35.090 --> 05:36.470
Now, here's the cool thing.

05:36.470 --> 05:40.620
At this point, we can tell certain things about the damage that has been done.

05:40.640 --> 05:47.660
For example, if new health is now zero, then we know that this damage caused was fatal.

05:47.780 --> 05:54.470
In other words, we could do something like const, bool, be fatal equals new health.

05:56.550 --> 05:58.530
Less than or equal to zero.

05:58.890 --> 06:01.890
Because if new health is less than or equal to zero.

06:01.920 --> 06:04.640
Well, we know that be fatal is going to be true.

06:04.650 --> 06:09.130
If enough damage was done to kill the owner of this attribute set.

06:09.150 --> 06:11.040
So that's kind of neat.

06:11.160 --> 06:16.410
Now we'll be doing more with our meta attribute, but this is the backbone.

06:16.410 --> 06:19.650
This is the basic framework of how it should work.

06:19.680 --> 06:27.060
We use the meta attribute instead of changing health and our gameplay effects that currently affect

06:27.060 --> 06:33.390
health are now going to be changed to affect the meta attribute on the target and they'll be adding

06:33.420 --> 06:33.780
to it.

06:33.780 --> 06:37.500
They won't be subtracting because we do the subtraction here.

06:37.530 --> 06:42.750
Our new health is our health value minus that local incoming damage.

06:42.780 --> 06:48.810
So why don't we change our damage gameplay effect so that it's now using our meta attribute?

06:48.840 --> 06:52.290
We can go ahead and compile and launch the editor.

06:54.460 --> 07:01.330
So back in the editor, we can open up g damage and we can scroll down to its modifier.

07:01.540 --> 07:07.330
And now instead of setting the health attribute, we're going to use incoming damage.

07:07.450 --> 07:12.520
And instead of a negative value, we need this to be a positive value.

07:12.670 --> 07:14.440
I'm going to make it a little larger.

07:14.440 --> 07:19.150
Let's make it 25 and compile and we can do some damage.

07:19.150 --> 07:21.460
I'm going to go ahead and launch a fireball.

07:22.370 --> 07:23.390
And there we go.

07:23.390 --> 07:25.250
We see that it's affecting the health.

07:25.280 --> 07:31.470
We're subtracting 25 from it all because we're adding to that damage meta attribute.

07:31.490 --> 07:39.110
So the damage meta attribute is essentially zeroed out, each frame consumed to be used in calculations

07:39.170 --> 07:41.060
regarding damage.

07:41.180 --> 07:47.790
Now, of course, we can get down to zero life and we haven't programmed anything for death.

07:47.810 --> 07:51.650
We haven't programmed any hit reaction, anything like that.

07:51.650 --> 07:53.380
Those are things that we'll get to.

07:53.390 --> 08:00.660
But now at least we're doing damage with a meta attribute, and that allows us to do lots of things.

08:00.680 --> 08:03.060
We can check the amount of damage done.

08:03.080 --> 08:06.750
We can also perform custom calculations with the damage.

08:06.770 --> 08:08.210
We have options.

08:08.270 --> 08:09.230
All right.

08:09.230 --> 08:11.650
So G damage is looking better.

08:11.660 --> 08:19.520
However, we're still hardcoding 25 for the damage and it would be nice if this damage were somehow

08:19.520 --> 08:22.200
linked to the gameplay ability.

08:22.200 --> 08:28.920
So if the gameplay ability has its own damage variable, how are we going to make sure that our gameplay

08:28.920 --> 08:32.520
effect is using the damage from the gameplay ability?

08:32.550 --> 08:39.390
Well, that's going to bring us to the fourth option for magnitude calculation type, which is set by

08:39.390 --> 08:40.020
caller.

08:40.020 --> 08:42.150
So we'll get into that next.

08:42.180 --> 08:43.290
I'll see you soon.
