WEBVTT

00:07.120 --> 00:08.380
Welcome back.

00:08.560 --> 00:14.110
So we've added a death impulse magnitude to aura damage gameplay ability.

00:14.110 --> 00:18.540
And we're setting that in make damage effect params from class defaults.

00:18.550 --> 00:22.930
So the damage effect params will carry that magnitude along.

00:23.080 --> 00:27.700
But we know that by the time our projectile hits something, we're going to have a direction which is

00:27.700 --> 00:32.170
a vector that we want to pass along, perhaps scaled by that magnitude.

00:32.170 --> 00:38.740
And ultimately, when our attribute set determines that damage was fatal, it can handle using that

00:38.740 --> 00:39.700
vector.

00:39.700 --> 00:46.810
For that reason, I'd like our custom gameplay effect context to have a vector, and that involves several

00:46.810 --> 00:47.200
steps.

00:47.200 --> 00:50.380
If we want to add that to our effect context.

00:50.380 --> 00:56.080
And we're going to handle those in this video and see the differences between a vector and the other

00:56.080 --> 00:58.600
types with our effect context.

00:58.600 --> 01:03.880
So we're going to add an f vector member variable called death impulse.

01:05.700 --> 01:08.220
And it's going to get a new property.

01:08.490 --> 01:11.550
And we're going to set this to the zero vector.

01:11.550 --> 01:17.970
So f vector zero vector we want to make sure it's initialized to zero.

01:17.970 --> 01:23.880
Because if we never set this to anything other than zero there's no point in replicating it.

01:23.910 --> 01:29.730
Speaking of replication, we need to handle this variable and net serialize don't we?

01:29.760 --> 01:35.130
So in aura ability type cp and net serialize we need to handle this.

01:35.160 --> 01:42.450
So first of all we want to not flip the next bit if the death impulse is zero.

01:42.450 --> 01:46.560
And by the way notice that we have a lot of bits that we're flipping here.

01:46.560 --> 01:50.010
And that's why we made our rep bits a UNT 32.

01:50.040 --> 01:55.400
Remember the original gameplay effect context uses a smaller one, doesn't it?

01:55.410 --> 01:57.240
It uses a UNT eight.

01:57.320 --> 01:57.610
Right.

01:57.630 --> 02:04.260
So we're using something a little bigger so we can accommodate for more bits, 32 to be exact.

02:04.260 --> 02:11.310
So we're going to flip the 14th bit, but only if our death impulse has been set.

02:11.310 --> 02:17.280
So we can say if not death impulse dot is zero.

02:17.280 --> 02:23.700
And this checks to see if it's exactly zero, which it will be if we've never set it because we're initializing

02:23.700 --> 02:25.140
it to the zero vector.

02:25.500 --> 02:32.820
So if that's the case, if it's not zero, we're going to flip the 14th bit by taking rep bits using

02:32.820 --> 02:38.070
a bitwise Or equals one left shift 14.

02:38.340 --> 02:45.000
Now that means that we can check to see if that bit has been flipped down here where we're serializing.

02:45.000 --> 02:49.740
So just after checking the 13th bit we're going to check the 14th.

02:49.980 --> 02:58.770
So we're going to say if rep bits bitwise and parentheses one left shift 14.

02:59.840 --> 03:04.670
So we'll see if that bit has been flipped and if so, we need to serialize the vector.

03:04.760 --> 03:10.490
Now, I didn't want to give this to you as a challenge, because I didn't want you to get confused and

03:10.490 --> 03:17.810
think that because our damage type, the gameplay tag and our hit result, the hit result are structs

03:17.810 --> 03:23.750
that you'd have to do the same thing with our f vector as you did with the other structs.

03:23.750 --> 03:27.140
Namely, use shared pointers and go through all that.

03:27.170 --> 03:29.670
You really don't have to with a vector.

03:29.690 --> 03:37.520
All you need to do is treat a vector like the other smaller data types, and the f vector actually has

03:37.520 --> 03:39.920
the inherent capability of.

03:39.920 --> 03:41.240
Net serializing.

03:41.240 --> 03:47.600
All we do is take the death impulse vector and call net serialize on it, which can take the archive

03:47.630 --> 03:53.980
we can pass in R, it can take the map, we can pass that in, and a boolean we can pass in B out.

03:53.990 --> 03:57.950
Success and death impulse will be serialized this way.

03:59.460 --> 04:02.700
So now you know how to serialize a vector too.

04:03.030 --> 04:07.770
Okay, so now our effect context has the death impulse.

04:07.800 --> 04:10.320
Now we can set that death impulse.

04:10.590 --> 04:16.950
Now the last crucial step that we can't forget is we have to scroll up to where we're calling serialized

04:16.950 --> 04:17.340
bits.

04:17.340 --> 04:20.010
And now we need to serialize another bit.

04:20.040 --> 04:24.420
We have to change this from a 13 to a 14.

04:24.900 --> 04:27.540
Now if we go back to or a projectile.

04:28.330 --> 04:33.460
We need to figure out how we can set that death impulse on the effect context.

04:33.790 --> 04:38.280
Now we can't really do it after applying the damage effect.

04:38.290 --> 04:40.090
We have to do it before.

04:40.120 --> 04:46.090
So even though we made this apply damage effect, return a gameplay context handle.

04:46.090 --> 04:52.510
If we say stored that in a local variable and then set the death impulse on it after, it would be too

04:52.510 --> 04:56.290
late because applying the damage gameplay effect would happen first.

04:56.380 --> 05:02.500
So we need that context to have its death impulse set before applying the effect.

05:02.500 --> 05:09.310
So for that reason, I'd like our damage effect params to carry that death impulse along with it.

05:09.340 --> 05:16.300
Now we know that it carries along its death impulse magnitude, but what really counts is the actual

05:16.300 --> 05:18.100
death impulse itself.

05:18.100 --> 05:25.990
So the effect params could carry the magnitude up to this point, where on sphere overlap can get the

05:25.990 --> 05:28.390
direction of the projectile.

05:28.390 --> 05:33.760
I'll scale it by that magnitude and then set that death impulse in the effect.

05:33.760 --> 05:40.150
Params which apply damage effect could take in and set it on the context.

05:40.180 --> 05:46.660
So we're going to go back to aura ability types up to the damage effect params.

05:46.660 --> 05:53.260
And not only is it going to have a death impulse magnitude, it's also going to have an f vector called

05:53.260 --> 05:54.460
death impulse.

05:56.470 --> 05:59.800
Now it'll be a zero vector by default.

06:02.080 --> 06:03.850
With its own new property.

06:05.610 --> 06:11.430
And we're going to set this in or a projectile before passing in the damage effect params.

06:11.670 --> 06:15.210
So we're going to make a const f vector.

06:16.630 --> 06:24.430
Called death impulse and we can get the direction of the projectile with get actor forward vector,

06:24.790 --> 06:31.120
but we can scale it by the death impulse magnitude that's carried along in damage effect params.

06:31.150 --> 06:34.740
It's damage effect params dot death impulse magnitude.

06:34.750 --> 06:41.350
Once we have that death impulse, we can take damage effect params dot death impulse and we can set

06:41.350 --> 06:43.000
it to death impulse.

06:43.240 --> 06:48.310
So now apply damage effect is going to take in damage effect params.

06:48.460 --> 06:56.170
So we have a death impulse vector on these params that are a damage gameplay ability doesn't fill in

06:56.170 --> 07:02.800
here, because there's really no way to know what that death impulse direction should be right here.

07:02.800 --> 07:05.740
So that'll be something designed to be set later.

07:05.740 --> 07:13.180
So or a projectile will set it here equal to its own actor forward vector scaled by the magnitude.

07:13.180 --> 07:19.120
Now apply damage effect is going to need to set the death impulse on the effect context.

07:19.120 --> 07:24.910
So if we go back to apply damage effect and aura ability system library.

07:27.810 --> 07:29.340
Here's the h file.

07:29.640 --> 07:34.320
Here's the cpp file, and we can go down to apply damage effect.

07:34.350 --> 07:41.310
We see that we are making an effect context handle, but we're not actually doing anything with it except

07:41.310 --> 07:44.520
adding a source object using the avatar actor.

07:44.520 --> 07:51.960
But what we can do now is we can actually go ahead and set the effect contexts death impulse.

07:52.230 --> 07:59.010
Now, I'd like an easy to use setter for it and an easy to use getter for it here on the ability system

07:59.010 --> 07:59.580
library.

07:59.580 --> 08:04.770
Just like our other variables in the effect context, we have getters and setters so that we don't have

08:04.770 --> 08:08.190
to perform this cast to aura effect context elsewhere.

08:08.340 --> 08:10.170
So we're going to create those.

08:10.170 --> 08:15.780
But those also require getters and setters on the effect context struct itself.

08:15.780 --> 08:22.440
So if we go back to our aura ability types and to do that I'm going to have to close a couple tabs.

08:22.470 --> 08:25.070
Here is aura ability types dot h.

08:25.080 --> 08:29.310
We can go ahead and add getters and setters for the death impulse.

08:30.240 --> 08:31.770
And we can do that really quick.

08:31.770 --> 08:40.470
We can make an f vector returning function called get death impulse, which can be const and can return

08:40.470 --> 08:41.490
death impulse.

08:42.510 --> 08:51.540
And we can make a void function void set death impulse, which can take in a const f vector reference

08:51.540 --> 08:59.100
called in impulse, and we can set death impulse equal to an impulse.

09:00.360 --> 09:02.280
So as simple as that.

09:02.280 --> 09:07.860
And then our ability system library can make some ability system library functions.

09:07.860 --> 09:13.110
We'll make one for get death impulse by copying get damage type.

09:13.110 --> 09:16.530
And all we have to do is change its type to F vector.

09:16.560 --> 09:20.400
Change its name to get death impulse.

09:21.500 --> 09:23.270
And give it a definition.

09:25.390 --> 09:29.620
And it can be actually almost identical to get damage type.

09:30.070 --> 09:33.540
So we can paste that with a couple key differences.

09:33.550 --> 09:40.090
If we can't do a successful cast I'm going to return f vector zero vector.

09:41.710 --> 09:44.740
So not just an empty f vector, but a zero vector.

09:44.950 --> 09:51.760
And once we're inside the if statement, I'm going to return or effect context.

09:51.850 --> 09:53.410
Get death impulse.

09:54.130 --> 09:55.180
That's it.

09:55.890 --> 10:01.770
So now we can make the setter function and it's going to be just like set damage type, which I'm noticing

10:01.770 --> 10:04.350
now doesn't have a new function.

10:04.350 --> 10:12.540
We can just give it the same function as set debuff frequency blueprint callable category this category.

10:12.810 --> 10:15.090
And I'm going to copy this function.

10:15.090 --> 10:18.000
And we'll make our set death impulse function.

10:18.000 --> 10:22.860
So it's going to be called set death impulse.

10:23.580 --> 10:29.010
And it'll take the context handle but not a game play tag.

10:29.010 --> 10:32.250
Instead a const f vector reference called in.

10:32.520 --> 10:34.290
We'll call it an impulse.

10:34.410 --> 10:38.280
And with this we can go ahead and generate the definition.

10:38.490 --> 10:44.790
And looking at set damage type we can copy it, we can paste it.

10:44.790 --> 10:52.980
And the difference here is we're just going to take aura effect context and call set death impulse and

10:52.980 --> 10:55.620
pass in an impulse.

10:55.620 --> 10:56.520
Simple.

10:56.940 --> 10:59.580
So now we have these setters and getters right.

10:59.610 --> 11:01.230
Nice and convenient.

11:01.230 --> 11:07.380
And we know that if we scroll all the way down to apply damage effect, that our damage effect params

11:07.380 --> 11:13.830
should have a death impulse that we can use to set the death impulse on our effect context through its

11:13.830 --> 11:19.680
handle, so we can call set death impulse and pass in effect context.

11:19.680 --> 11:26.700
Handle and pass in the death impulse in damage effect, params, damage effect, params dot death impulse

11:26.700 --> 11:29.790
and with that the context handle will be set.

11:29.790 --> 11:34.920
And if we go all the way back to aura projectile, we know that because we're setting the death impulse

11:34.920 --> 11:41.730
here that when we call apply damage effect, the effect params that we're passing in will have that

11:41.730 --> 11:47.100
death impulse, and the ability system library will handle setting it on the effect context.

11:47.100 --> 11:53.630
And then by the time we get to the attribute set, when we know damage is fatal, we can get that.

11:53.640 --> 12:01.740
So the last piece of this puzzle is to go all the way into aura attribute set right here, and handle

12:01.740 --> 12:02.940
incoming damage.

12:02.940 --> 12:07.110
As soon as damage is fatal, we can use that death impulse.

12:07.110 --> 12:11.400
So right here and if be fatal, we're going to have a to do.

12:14.240 --> 12:19.170
Use death impulse and we'll handle that in the next video.

12:19.190 --> 12:26.150
For this video, that's enough, and hopefully we'll make some enemies fly around upon death.

12:26.690 --> 12:29.390
Excellent job, and I'll see you in the next video.
