WEBVTT

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

00:08.270 --> 00:12.490
We now have our own custom gameplay effect context class.

00:12.500 --> 00:15.410
Aura Gameplay Effect Context.

00:15.440 --> 00:22.730
Now the only difference between this and gameplay effect context is that it has two additional variables

00:22.730 --> 00:28.910
booleans for whether we have a blocked hit and whether we have a critical hit.

00:29.000 --> 00:32.750
Now we went through a lot of trouble just to do this right.

00:32.750 --> 00:34.730
We had to create our own struct.

00:34.760 --> 00:42.470
We had to override a couple of functions that existed on the gameplay effect context class, including

00:42.470 --> 00:49.550
net serialize in which we had to learn about what was going on in net serialize in the parent version

00:49.550 --> 00:56.330
so that we could serialize our struct and make sure that our new booleans are serialized along with

00:56.330 --> 00:59.300
the other member variables of this struct.

00:59.390 --> 01:02.120
So that was a really good learning exercise for us.

01:02.120 --> 01:07.350
And in addition to that, we also learned about the struct ops type traits that we needed to define

01:07.350 --> 01:09.950
for our custom effect context.

01:09.960 --> 01:16.530
So a lot of work just to get two additional booleans, but the implications of this are a lot larger

01:16.530 --> 01:17.210
than that.

01:17.220 --> 01:23.580
Yes, we only added two booleans, but now we can add anything we want to our effect context class.

01:23.580 --> 01:27.090
But that doesn't really matter if we can't use it.

01:27.120 --> 01:33.780
We have to be able to actually use this context, and to do that we have to set our project to use this

01:33.780 --> 01:36.270
particular effect context class.

01:36.270 --> 01:38.190
So how do we manage doing that?

01:38.220 --> 01:46.440
Well, one way to do it is to define our own globals class and ability system globals class.

01:46.590 --> 01:53.670
You see, there already exists a class called Ability System Globals and it defines the globals global

01:53.670 --> 02:00.120
variables and such used by the ability system that will always be accessible all throughout our code

02:00.120 --> 02:00.720
base.

02:00.720 --> 02:08.490
But we can subclass that into our own ability system globals class in which we can specify by our own

02:08.490 --> 02:11.400
custom classes and structs to use.

02:11.430 --> 02:16.470
We can specify the gameplay effect context that gas should be using.

02:16.470 --> 02:22.950
We can specify gameplay cues, we can change what's initialized into gameplay cue parameters which we'll

02:22.950 --> 02:24.060
learn about later.

02:24.090 --> 02:27.810
We can change what classes our ability actor info uses.

02:27.810 --> 02:31.980
We have lots of things we can do if we have our own ability system globals class.

02:31.980 --> 02:34.050
So we need to create our own.

02:34.140 --> 02:41.300
So let's go into our C plus plus classes aura public and I'll go into ability system.

02:41.310 --> 02:44.100
We can go ahead and place that new class here.

02:44.550 --> 02:47.880
I'm going to right click and select new C plus plus class.

02:47.880 --> 02:53.200
Choose all classes and search for ability System Globals.

02:53.790 --> 03:00.930
We're going to make a class based on this, and I'm going to call this aura ability system globals,

03:00.930 --> 03:02.910
and we'll put it in ability system.

03:02.910 --> 03:05.340
That's a perfectly fine folder for it.

03:05.340 --> 03:08.760
So let's click Create Class and close down the editor.

03:08.970 --> 03:16.830
So here in ability system, here's my ability system globals CP and my H file.

03:17.130 --> 03:22.170
Now what we're going to do here in Ability System Globals for now is pretty simple.

03:22.170 --> 03:27.360
We're just going to override a single virtual function that exists on the parent class.

03:27.360 --> 03:32.010
So it's virtual and it returns a pointer to a gameplay effect context.

03:32.010 --> 03:44.550
So it returns F gameplay effect context pointer and it's called alloc for allocation gameplay effect

03:44.550 --> 03:45.630
context.

03:46.170 --> 03:48.770
It's const and this is an override.

03:48.780 --> 03:51.930
Now this function should look a little familiar to you.

03:51.960 --> 03:53.350
You have seen it.

03:53.350 --> 03:55.630
Now if you don't remember where you've seen it.

03:55.630 --> 03:57.970
Before we move on, I'm going to show you.

03:58.000 --> 04:06.670
So let's go back to, oh, let's say aura projectile spell dot CP here we're calling make effect context.

04:06.700 --> 04:11.590
Now, recall a few videos ago we right clicked on that and went to the definition of it.

04:11.710 --> 04:13.060
Here it is.

04:13.240 --> 04:16.030
Notice that here in make effect context.

04:16.060 --> 04:22.930
The context that is created as a result of this function call is created right here with the gameplay

04:22.930 --> 04:32.140
effect context handle constructor passing in you ability system globals alloc gameplay effect context.

04:32.170 --> 04:34.420
That's where this function is called.

04:34.420 --> 04:38.890
This is what actually creates a brand new effect context.

04:38.920 --> 04:46.690
Now if we're calling this function to create a new effect context, then this function determines what

04:46.690 --> 04:49.930
class is used to instantiate that object.

04:50.020 --> 04:52.450
And this function is on your ability.

04:52.450 --> 04:55.180
System globals, which were now subclassing.

04:55.180 --> 04:57.730
We now have our ability system globals.

04:57.730 --> 05:02.920
So because we're overriding this, we can choose what is returned from this function.

05:02.920 --> 05:05.680
So let's go ahead and generate the definition.

05:05.680 --> 05:08.640
And what exactly do we want to return?

05:08.650 --> 05:13.570
Well, we want to return a new aura gameplay effect context.

05:13.570 --> 05:21.280
So even though this function returns a pointer to gameplay effect context, we can return an aura gameplay

05:21.280 --> 05:24.640
effect context because it's derived from that type.

05:24.730 --> 05:30.400
So we can return new F aura gameplay effect context.

05:31.350 --> 05:38.820
So now we're determining that Alec gameplay effect context will create a new gameplay effect context

05:38.820 --> 05:41.410
object of our custom type.

05:41.430 --> 05:47.940
Now if we could only manage to tell our project to use this ability system globals instead of the you

05:47.940 --> 05:55.080
ability system globals, then every time an effect context is created in our project that will result

05:55.080 --> 06:03.050
in this function being called on our ability system globals which will return our effect context class.

06:03.060 --> 06:09.660
So the question is how do we configure our project to use our class?

06:09.690 --> 06:14.880
Well, first I'm going to go ahead and compile and make sure everything compiles correctly.

06:16.180 --> 06:17.350
And it does.

06:17.470 --> 06:26.410
And from here, I'm going to close down the editor and go into my config file and open up default game

06:26.410 --> 06:27.430
dot ini.

06:28.060 --> 06:34.540
And here in default game ini we can specify our ability system globals class.

06:34.570 --> 06:38.710
We do that by introducing some new square brackets.

06:38.710 --> 06:46.420
We have a forward slash script forward slash and we're going to have gameplay abilities.

06:46.660 --> 06:47.590
Dot.

06:48.560 --> 06:51.860
Ability System Global's.

06:53.000 --> 06:55.850
So under this category, we're going to have a plus.

06:56.460 --> 07:00.000
And we're going to say ability system globals.

07:00.600 --> 07:03.090
Class name equals.

07:03.090 --> 07:08.610
And in quotes we say forward slash script.

07:08.850 --> 07:14.610
Forward slash followed by the module which contains our project.

07:14.610 --> 07:14.880
That's.

07:15.330 --> 07:22.590
So in my case, my project is called Aura, and then the class name for the ability system global.

07:22.590 --> 07:24.600
So now we don't prefix it with the U.

07:24.600 --> 07:30.150
Instead we just say aura, ability, system globals and that's it.

07:30.180 --> 07:36.560
We save this and now our ability system Globals class is the one that we've chosen.

07:36.570 --> 07:38.400
I'm going to close that down.

07:38.430 --> 07:41.250
Your editor should be closed for this, by the way.

07:41.250 --> 07:47.820
And after doing that, I'm going to right click open my project with writer.

07:49.680 --> 07:55.560
And now my project should be using my custom gameplay effect context class.

07:55.560 --> 07:57.990
So how can we prove that?

07:58.020 --> 08:03.540
Well, going back to Aura Projectile spell, we're creating the effect context here.

08:03.570 --> 08:11.940
We can place a breakpoint after we've created the context and just inspect that context, see what that

08:11.970 --> 08:13.620
object actually is.

08:13.890 --> 08:19.440
So I'm going to go ahead and run in debug mode so that we can hit this breakpoint.

08:21.630 --> 08:26.640
So back in the editor, all I need to do is press play and launch a fireball.

08:26.670 --> 08:31.860
Now, as soon as that happens, we've created our effect context and or projectile spell.

08:31.890 --> 08:35.980
Now all I need to do is see what that effect context is.

08:36.000 --> 08:44.010
So hovering over my effect context handle, I can take a look at data and right away I see is blocked,

08:44.010 --> 08:46.440
hit and is critical hit.

08:46.470 --> 08:54.540
So my effect context has these two booleans and the only way that that is possible is if this effect

08:54.540 --> 09:00.570
context were an object of my custom aura gameplay effect context.

09:00.600 --> 09:08.230
Because the regular gameplay effect context struct does not have is blocked hit or is critical hit.

09:08.250 --> 09:14.940
So this right here tells me that I'm successfully using my gameplay effect context class.

09:14.940 --> 09:18.690
And then of course we have access to all the stuff in the parent class.

09:18.990 --> 09:21.700
So this is a success.

09:21.700 --> 09:30.160
And now that we have these, we can access these in basically anywhere along the pipeline for our gameplay

09:30.160 --> 09:31.300
effect applications.

09:31.300 --> 09:37.210
For example, we can go to aura attribute set and right here in post gameplay effect execute.

09:37.210 --> 09:45.670
I can place a breakpoint here, I'm going to hit resume and we see that we've hit this breakpoint and

09:45.670 --> 09:51.190
because we've hit the breakpoint we have access to things like our effect properties.

09:51.190 --> 09:52.740
This props here.

09:52.750 --> 09:57.160
If I take a look at that, I can see that I have the effect context handle.

09:57.160 --> 10:02.230
Here's data and here's the B is blocked, hit B is critical hit.

10:02.260 --> 10:03.880
We can access that there.

10:03.880 --> 10:10.900
So this is huge because if we set those booleans somewhere along the line, then later on down the line,

10:10.930 --> 10:14.320
say in our attribute set, we can access them here.

10:14.320 --> 10:19.840
In the attribute set, for example, we're showing the damage number with our floating text.

10:19.870 --> 10:22.500
We're calling show floating text here.

10:22.500 --> 10:28.980
What if we could pass along those booleans to show floating text and show the text in a different color?

10:28.980 --> 10:35.670
For example, maybe for a blocked hit, we can show the text as blue and for a critical hit, we can

10:35.670 --> 10:37.020
show it as red.

10:37.050 --> 10:38.970
We can do anything we want here.

10:39.120 --> 10:43.650
So the next step is actually using those booleans.

10:43.650 --> 10:47.370
We need to figure out how we can access and how we can set that data.

10:47.370 --> 10:49.230
So that will be our next step.

10:49.230 --> 10:52.200
For now, this is a great milestone.

10:52.290 --> 10:53.460
Excellent job.

10:53.460 --> 10:56.310
And we have our ability System Globals class.

10:56.310 --> 10:57.720
You can do lots of things here.

10:57.720 --> 11:01.650
You can even create variables for global gameplay tags.

11:01.680 --> 11:05.400
Of course, we've already done that with our gameplay tag singleton.

11:05.400 --> 11:07.530
But here's another place that you could do it.

11:07.560 --> 11:13.950
A Globals class is a nice handy place to put things you want globally accessible.

11:13.950 --> 11:17.010
So great job and I'll see you in the next video.
