WEBVTT

00:06.830 --> 00:07.880
Welcome back.

00:07.910 --> 00:10.790
Now here's my gameplay effect G damage.

00:10.820 --> 00:13.940
It's set to modify incoming damage.

00:13.940 --> 00:15.470
That's our meta attribute.

00:15.500 --> 00:20.270
We're adding to it and the magnitude calculation type is set by caller.

00:20.270 --> 00:27.470
So we've seen that we can set a set by caller magnitude from game logic either in C plus plus or it

00:27.470 --> 00:32.330
can be done in blueprint and that's the magnitude calculation type.

00:32.510 --> 00:37.340
But we can also set this to a custom calculation class if we like.

00:37.340 --> 00:44.030
And execution calculations are another choice for our custom calculation class.

00:44.030 --> 00:50.900
In addition to MKs, we're going to make one for damage because our damage calculation is going to be

00:50.900 --> 00:55.670
quite a bit more complex than simply setting a value directly.

00:55.670 --> 00:57.560
So let's make that class.

00:57.560 --> 01:03.770
We're going to go into C plus plus classes, Aura, public ability system.

01:03.860 --> 01:10.440
And here's a mod mag calc folder where we could have called this custom calculations and just keep all

01:10.440 --> 01:16.470
our custom calcs in there, but we're going to make a new C plus plus class in a new folder.

01:16.590 --> 01:23.340
So for this it's going to be a gameplay effect execution calculation.

01:23.730 --> 01:30.240
So we'll choose that type and we'll place it in ability system slash exec calc.

01:30.270 --> 01:36.270
So that's a shorthand way of referring to an execution calculation.

01:36.270 --> 01:38.280
We often call them exec Calcs.

01:38.550 --> 01:45.810
Now I'm going to prefix this with exec calc underscore, and I'm going to call this damage.

01:45.810 --> 01:48.480
So we'll have a exec calc damage.

01:48.480 --> 01:50.490
Let's go ahead and create the class.

01:50.490 --> 01:52.800
And I'm going to close the editor down.

01:52.800 --> 02:00.030
And this should show up right in my ability system and exec calc folder so I can go ahead and close

02:00.030 --> 02:05.460
all the tabs and open the exec calc and CPP files.

02:05.550 --> 02:13.410
So here's our custom calculation class based on you gameplay effect execution calculation.

02:13.410 --> 02:15.840
It's called you exec calc damage.

02:15.840 --> 02:20.760
And we've seen in the last slide just what this type of class is capable of.

02:20.790 --> 02:23.850
We just don't know yet how to implement that.

02:23.850 --> 02:27.300
So here are the things we have to do just by default.

02:27.300 --> 02:34.320
The first things to do are, first, we need a constructor, so we're going to add a public section.

02:35.910 --> 02:41.010
And we'll add a constructor and we'll define the constructor.

02:41.100 --> 02:42.510
So that's step one.

02:42.510 --> 02:51.120
And then we need to decide what happens when this custom calculation class is executed, what type of

02:51.120 --> 02:57.030
calculations are going to occur, And for that we override a virtual function.

02:57.030 --> 03:03.420
It's a virtual void function and it's called execute underscore implementation.

03:03.780 --> 03:11.400
Now, if I let writer complete this, for me it's a function with a couple of input parameters.

03:11.400 --> 03:20.100
First is an input called execution params, it's an gameplay effect custom execution parameters.

03:20.250 --> 03:24.140
So it's a little struct that contains some information.

03:24.150 --> 03:28.890
We also have an gameplay effect custom execution output.

03:28.890 --> 03:36.690
It's called out execution output and that's not const, that's just by reference indicating that perhaps

03:36.690 --> 03:44.850
we can change this struct in some way and it will be used somewhere later after this function has been

03:44.850 --> 03:45.690
executed.

03:45.690 --> 03:50.100
So we have this function, we can generate a definition for it.

03:51.040 --> 03:52.390
So here we have it.

03:52.390 --> 03:53.950
And we don't have to call super.

03:53.950 --> 03:57.920
We can just decide exactly what happens here.

03:57.940 --> 04:06.340
And what we're deciding is how this execution calculation is going to affect any other attributes by

04:06.340 --> 04:07.790
setting their values.

04:07.810 --> 04:11.050
So remember, this belongs in a gameplay effect.

04:11.050 --> 04:18.040
So if we add a modifier to the gameplay effect, then by setting a custom calculation class, it's really

04:18.040 --> 04:25.120
this custom calculation class that determines what's going to happen when we apply that gameplay effect.

04:25.240 --> 04:33.460
So here we can decide how to change various attributes and we can capture attributes and we can also

04:33.460 --> 04:39.880
get information about the gameplay effect concerning who caused the effect and who the effect is targeting

04:39.880 --> 04:41.930
at the time of application.

04:41.950 --> 04:49.600
So we're just going to start off by retrieving some data that's available to us thanks to these input

04:49.600 --> 04:51.980
parameters that we have at our disposal.

04:52.100 --> 04:57.680
We're going to take a look at the execution params, so let's type execution params.

04:59.100 --> 05:01.020
And have a dot here.

05:01.020 --> 05:06.420
And notice that as soon as we hit dot, we have lots and lots of cool functions.

05:06.540 --> 05:12.810
Some of the most notable are look at this git owning spec, the gameplay effect spec that owns this

05:12.810 --> 05:13.860
calculation.

05:14.070 --> 05:16.170
There's the prediction key.

05:17.160 --> 05:22.950
We have some functions that sound like they're related to capturing attributes and their magnitudes.

05:23.190 --> 05:27.300
And we also have things like get source ability system component.

05:29.250 --> 05:31.680
And get target ability system component.

05:31.680 --> 05:35.280
These are really nice and convenient functions for us.

05:35.280 --> 05:38.180
Let's say we'd like the source ability system component.

05:38.190 --> 05:39.210
Well here it is.

05:39.210 --> 05:46.860
We can call that function and we can even store it in a const you ability system component pointer called

05:46.860 --> 05:49.830
source ASC for example.

05:50.190 --> 05:52.440
We can also do that with the target.

05:52.440 --> 06:02.130
So we can say const you ability system component target ASC equals execution params dot get target ability

06:02.130 --> 06:03.360
system component.

06:03.360 --> 06:08.400
So right there we've already got the ability system components of the source and the target.

06:08.610 --> 06:13.140
Now because we have these, we can also get the Avatar actors.

06:13.140 --> 06:21.900
If we need those, for example, we can make an A actor pointer called Source Avatar for example, and

06:21.900 --> 06:24.570
we can get that from the source ability system component.

06:24.600 --> 06:30.610
Now in the case that the source ability system component is null, then we'll just set this source actor

06:30.610 --> 06:31.120
to null.

06:31.150 --> 06:32.020
How about that?

06:32.020 --> 06:37.660
So we can use the ternary operator and say source ASC question mark.

06:37.660 --> 06:45.670
And if that is not null, then we'll take source ASC and call get Avatar actor and if it is null, we'll

06:45.670 --> 06:52.810
set this source avatar to a null pointer and we can do that for the source and the target for now we

06:52.810 --> 06:54.130
can make them const.

06:54.750 --> 06:56.760
So const a actor.

06:58.600 --> 07:05.530
And we'll make a target avatar and we'll check Target ask question mark.

07:06.400 --> 07:08.770
If it's valid, we'll take target.

07:08.800 --> 07:12.190
Ask and call get Avatar actor.

07:12.220 --> 07:14.770
Otherwise we'll set it to null pointer.

07:15.640 --> 07:22.030
So right there we have the ability system components and the avatar actors for the source and the target

07:22.060 --> 07:25.450
of the gameplay effect using this custom calculation.

07:25.570 --> 07:32.350
We can also get the effect spec as we've seen, so we can make a const gameplay effect spec.

07:32.470 --> 07:39.250
I'm going to make it a const reference called spec and we can get that from the execution params with

07:39.250 --> 07:40.690
get owning spec.

07:40.780 --> 07:44.710
So that right there has tons of information inside of it.

07:44.920 --> 07:45.700
All right.

07:45.700 --> 07:52.960
So now that we know that we can access source and target ability system component and avatar actors

07:52.960 --> 07:58.540
as well as lots of other information in the effects spec, we need to know how we can capture attributes

07:58.690 --> 08:04.890
and use them and set them and really make this execution calculation do its thing.

08:04.900 --> 08:09.220
Now, at some point it looks like writer Auto included something up there that's not used for me.

08:09.220 --> 08:10.780
I'm going to go ahead and remove it.

08:10.990 --> 08:12.070
There we go.

08:12.460 --> 08:20.320
So next, we need to actually capture some attributes and then decide how we're going to use those to

08:20.320 --> 08:22.180
change other attributes.

08:22.180 --> 08:28.870
Ultimately, this damage exec calc is going to want to set the damage meta attribute on the target.

08:28.870 --> 08:31.270
So that's one of the next things we need to do.

08:31.270 --> 08:37.780
So in the next video, we're going to learn how we can start capturing attributes in our execution calculation.

08:38.200 --> 08:39.340
I'll see you soon.
