WEBVTT

00:06.880 --> 00:08.020
Welcome back.

00:08.170 --> 00:12.910
Now that we have damage effect params, it's time to start using them.

00:12.940 --> 00:18.160
So the first place I'd like to start is our aura projectile spell.

00:18.520 --> 00:24.820
If we go into our aura projectile spell, I'm just going to go straight to the private folder and ability

00:24.820 --> 00:28.900
system abilities and open are a projectile spell.

00:29.140 --> 00:34.210
We see that we're spawning a projectile and setting its damage effect spec handle.

00:34.330 --> 00:37.960
So we're assigning set by color magnitudes already here.

00:37.990 --> 00:39.970
Now we don't need to do any of that.

00:39.970 --> 00:45.910
All we have to do is make use of some of these functions and types that we've created to make our lives

00:45.910 --> 00:46.810
easier.

00:46.900 --> 00:54.340
So from the point where we spawn the projectile using spawn actor deferred to the point where we finish

00:54.340 --> 00:57.940
spawning, we can refactor some of this stuff.

00:57.940 --> 01:01.510
In fact, a lot of this stuff is going to be different.

01:01.780 --> 01:04.840
When we were learning about effect context handles.

01:04.870 --> 01:11.420
We set a bunch of things on the effect context handle just because we could for educational purposes.

01:11.510 --> 01:13.500
Now, we don't need to do any of that.

01:13.520 --> 01:17.190
In fact, our projectile doesn't even need a spec handle anymore.

01:17.210 --> 01:21.260
All it really needs is damage effect params that we can set on it.

01:21.470 --> 01:22.850
So here's what I'm going to do.

01:22.850 --> 01:28.040
I'm going to gut out all of this code between spawn actor deferred and finish spawning.

01:28.040 --> 01:29.480
I'm just going to delete it.

01:30.000 --> 01:36.930
We're going to do things a bit differently and projectile can now have some damage effect params instead

01:36.930 --> 01:39.000
of a gameplay effect spec.

01:39.090 --> 01:43.380
The params can contain the gameplay effect class.

01:44.090 --> 01:52.310
So I'm going to go into my actor folder in the public folder in actor, and I'm going to take a projectile

01:52.940 --> 01:53.990
and open it up.

01:54.520 --> 01:59.920
And I think what I'd like to do is close some of these tabs I don't need.

02:00.560 --> 02:04.190
So I don't need most of these.

02:06.160 --> 02:09.670
I just need aura, projectile spell and aura Projectile.

02:10.060 --> 02:13.770
Now aura projectile has damage effect spec handle.

02:13.780 --> 02:15.880
But I'm going to replace this now.

02:15.910 --> 02:23.830
I'm going to replace this with an EF damage effect params and I'm going to add the include for it here

02:24.130 --> 02:27.280
and it's going to be called damage effect params.

02:27.820 --> 02:34.360
Now in my includes I don't need gameplay effect types h so I can remove it and now I have aura ability

02:34.360 --> 02:43.000
types instead and damage effect params can be set in aura projectile spell and then we can go and fix

02:43.000 --> 02:47.410
up aura projectile upkeep because now it's going to have some red text.

02:47.410 --> 02:47.920
Right?

02:48.100 --> 02:49.270
So we'll get to that.

02:49.270 --> 02:56.410
We're going to take aura projectile upkeep and we'll move them off to the left and Aura projectile spell

02:56.410 --> 02:59.830
is going to fill in some information here.

03:00.040 --> 03:02.500
So first we can make some damage effect.

03:02.500 --> 03:12.100
Params we can call this damage effect params and now our damage gameplay ability has a make damage effect

03:12.100 --> 03:14.930
params from class defaults function.

03:14.950 --> 03:21.310
Now it requires the target actor and at this point in the aura projectile spell, we don't know who

03:21.340 --> 03:24.040
the target actor is, so we're going to pass in a null pointer.

03:24.040 --> 03:26.170
In fact, that's null by default.

03:26.170 --> 03:27.940
We don't even have to pass that in.

03:27.970 --> 03:34.270
We just have to make sure that that target actor gets set as soon as our aura projectile overlaps with

03:34.270 --> 03:34.750
it.

03:34.960 --> 03:40.930
Now that we have these damage effect params, we can set the damage effect params on aura projectile

03:41.020 --> 03:49.240
so we can take the projectile that we've just spawned and we can set its damage effect params to our

03:49.240 --> 03:50.650
damage effect params.

03:50.650 --> 03:53.260
And in fact we don't need a local variable for it.

03:53.290 --> 03:59.650
We can just set it equal to the result of make damage effect params from class defaults.

04:00.250 --> 04:07.400
Now the projectile will have its own damage effect params and then we can finish spawning.

04:07.910 --> 04:14.120
So make damage effect params from class defaults and setting damage effect params on the projectile

04:14.150 --> 04:16.580
has reduced our code by quite a great deal.

04:16.580 --> 04:23.240
So it's a nice refactor and it also makes this easy for future gameplay abilities as we don't have to

04:23.240 --> 04:24.610
repeat ourselves a lot.

04:24.620 --> 04:29.210
So now we just have to make sure we're using these effect params in our projectile.

04:29.210 --> 04:33.320
So let's go to Aura Projectile CP and see what we're doing here.

04:33.890 --> 04:39.250
Now, the first thing I'm noticing is about four lines of repeated code here and here.

04:39.260 --> 04:42.710
And I think that would be good to just abstract.

04:42.950 --> 04:48.050
These are things that happen on hit, so I'd like this to be abstracted.

04:48.080 --> 04:51.590
I'm going to go to refactor.

04:51.620 --> 04:52.610
Here it is.

04:53.340 --> 05:05.370
Refactor this and extract method and call this on hit and click next and now on hit is called right

05:05.370 --> 05:06.030
there.

05:06.030 --> 05:08.640
But also that's what these lines are doing.

05:08.640 --> 05:10.320
So we're going to call on hit here.

05:11.400 --> 05:19.260
Now this allows me to condense my code a lot because there's a lot of lines of code but not doing much.

05:19.260 --> 05:19.590
Right.

05:19.590 --> 05:21.390
So we're going to fix it.

05:21.390 --> 05:27.180
In fact, in Destroyed, this is one of those situations where we could just put this all on a single

05:27.180 --> 05:27.990
line.

05:27.990 --> 05:32.940
We don't need four lines to do what one line of code would suffice for.

05:33.120 --> 05:36.660
And now for on sphere Overlap, it's checking.

05:36.660 --> 05:41.730
Let's see what it was doing before it was taking damage effect spec handle, making sure that it was

05:41.730 --> 05:42.540
valid.

05:42.570 --> 05:48.780
Also making sure that the context had an effect causer that was not the other actor.

05:48.780 --> 05:54.850
So the other actor is the actor being overlapped with We're making sure that the effect causer and the

05:54.850 --> 05:57.670
spec handle is not that other actor.

05:57.670 --> 05:58.270
Right?

05:58.300 --> 06:02.650
Well, now things are a little different because we don't even have an effect spec handle.

06:02.650 --> 06:08.170
Instead we have damage effect params and we can check some things in that.

06:08.380 --> 06:15.670
For example, we could check to see if the effect causer or at least the source is not the other actor

06:15.940 --> 06:24.430
because we could take damage effect params dot and we can get the source ability system component and

06:24.430 --> 06:26.500
call get avatar actor.

06:27.370 --> 06:33.130
Now if we store that in a const a actor pointer called source Avatar actor.

06:35.830 --> 06:41.830
Then we can make sure that that source avatar actor isn't the other actor being overlapped with.

06:41.920 --> 06:44.440
Now we don't need to check the effect spec handle.

06:44.440 --> 06:46.380
In fact, one doesn't exist yet.

06:46.390 --> 06:50.680
It's the ability system blueprint library that's going to create all that for us.

06:50.680 --> 06:52.900
So at this point it's too early to check.

06:52.930 --> 06:57.850
All we have to do is see if source Avatar actor is the other actor.

06:57.850 --> 07:00.040
If it is, we can return.

07:00.040 --> 07:02.710
And I'm going to place this all on a single line.

07:03.830 --> 07:06.200
Now we're also checking is not friend.

07:06.200 --> 07:13.190
Remember this checks a couple of tags, not gameplay tags, but name based actor tags to see if it's

07:13.190 --> 07:14.750
friendly fire or not.

07:14.750 --> 07:15.290
Right.

07:15.290 --> 07:17.690
So we're checking is not friend.

07:17.690 --> 07:21.440
And what were we checking before we were checking the effect.

07:21.450 --> 07:24.950
Spec handles Context effect causer.

07:25.710 --> 07:27.240
Against the other actor.

07:27.240 --> 07:31.070
So again, that's the same as our source avatar actor.

07:31.080 --> 07:38.340
So we can check the source Avatar actor here and of course is not friend is not going to be happy with

07:38.340 --> 07:39.570
a const actor.

07:39.570 --> 07:46.290
So we're going to pass in a non const and I'll go ahead and take this return and stick that right there.

07:46.290 --> 07:49.760
And now we have even less lines of code.

07:49.770 --> 07:55.410
Now, if not be hit on hit, that could also be on a single line too.

07:56.130 --> 07:57.990
I'm starting to like how this looks now.

07:57.990 --> 07:59.550
Not so much code.

07:59.760 --> 08:03.450
We can even put this else on a single line like this.

08:05.930 --> 08:11.240
Now all we have to worry about is when we have authority applying the gameplay effect.

08:11.570 --> 08:13.970
So how are we going to do that?

08:13.970 --> 08:19.250
Well, we made a function in our ability system function library.

08:19.870 --> 08:21.250
Let's just open that up.

08:21.250 --> 08:24.100
It's called Apply Damage Effect.

08:24.250 --> 08:25.750
We can call that.

08:26.110 --> 08:32.020
Now, we can't forget the target ability system component hasn't been set on it.

08:32.050 --> 08:35.920
We didn't know until now who the target was.

08:35.950 --> 08:36.970
Now we do.

08:36.970 --> 08:38.260
It's Target ASC.

08:38.290 --> 08:39.760
We're getting it here.

08:40.680 --> 08:44.190
So this is where we can set that on our damage effect.

08:44.190 --> 08:50.670
Params we can take damage effect, params dot target ability system component and set it to target ASC.

08:51.210 --> 08:56.790
And in the future if we add anything else in effect params that needs to be set here, we'll set it

08:56.790 --> 08:57.060
here.

08:57.060 --> 08:59.250
But for now that's all we care about.

08:59.250 --> 09:05.250
That's the only thing that wasn't set because when we made this damage effect params and set it to the

09:05.250 --> 09:10.560
projectile here in aura projectile spell, we made it passing in nothing.

09:10.560 --> 09:15.060
Which means that that target actor has a default null pointer.

09:15.590 --> 09:23.270
And we can just really quickly remind ourselves in or a damage gameplay ability in this make damage

09:23.270 --> 09:25.790
effect params from class defaults.

09:25.790 --> 09:31.310
The target ability system component was set using get ability system component which will return a null

09:31.310 --> 09:33.730
pointer if target actor is null.

09:33.740 --> 09:35.450
So that's something to keep in mind.

09:35.450 --> 09:36.110
Right?

09:36.110 --> 09:39.910
And we kept that in mind and that's why we set the target ASC here.

09:39.920 --> 09:47.870
After that, we can apply the effect by using you or a ability system library apply damage effect passing

09:47.870 --> 09:53.560
in the damage effect params and that should result in the damage being caused.

09:53.570 --> 09:59.000
Now so far, this shouldn't change any behavior we've already been seeing, but the difference is now

09:59.000 --> 10:06.140
this spec, as we can see in Aura ability system library has all these set by color magnitudes in addition

10:06.140 --> 10:14.420
to damage, including all the debuff parameters which we can then use anywhere along the pipeline where

10:14.420 --> 10:15.770
we have the spec.

10:15.770 --> 10:19.040
So we'll use these parameters soon enough.

10:19.040 --> 10:25.640
For now we need to compile and launch the editor and see if our code still works, if we can still cause

10:25.640 --> 10:26.360
damage.

10:29.160 --> 10:32.850
So I'm just going to dig right in and go into combat.

10:34.660 --> 10:38.800
Okay, so I got a breakpoint in exec calc damage.

10:39.070 --> 10:42.610
So this is the whole point of testing, right?

10:42.760 --> 10:50.770
We hit this check right here that says tags to capture defs doesn't contain tag and exec calc damage.

10:50.770 --> 10:59.920
So here in the exec calc, we're taking our damage statics dot tags to capture defs because we created

10:59.920 --> 11:01.810
these resistance tags.

11:01.810 --> 11:08.530
And by the time the exec calc catches wind of this ability, it's going to loop over damage types to

11:08.530 --> 11:09.640
resistances.

11:10.230 --> 11:11.580
Now we see that right here.

11:11.580 --> 11:15.180
Resistance tag is the pair value.

11:15.180 --> 11:23.880
So our damage types to resistance is t map it appears has a debuff tag in it.

11:24.430 --> 11:26.590
That sounds a lot like an error.

11:26.590 --> 11:32.160
So we need to go look at damage types to resistances in for a gameplay tags.

11:32.170 --> 11:38.260
So I'm going to go into aura gameplay tags and here's damage types to resistances.

11:38.290 --> 11:46.420
It appears that I must have put all those debuff tags in the wrong map, so let's make sure that's not

11:46.420 --> 11:47.470
the case.

11:47.470 --> 11:49.090
Oh, look at that.

11:49.650 --> 11:50.580
Wow.

11:50.860 --> 11:56.880
I actually put the arcane debuff and damage types to debuffs, but I didn't actually put the other three.

11:56.910 --> 12:01.260
I must have just kind of replaced this one and neglected the others.

12:01.260 --> 12:03.180
So that's an easy fix.

12:03.270 --> 12:09.690
I'm going to go ahead and replace those and put these tags where they belong and you'll likely have

12:09.690 --> 12:16.770
seen some kind of text and an arrow pointing to this on the screen back when I did this saying, Hey,

12:16.800 --> 12:19.980
don't forget, this is the map that you should use.

12:20.070 --> 12:23.220
So with that, we should be good.

12:23.310 --> 12:26.340
And it's good that we used a check F right?

12:26.340 --> 12:29.040
Because this is telling us really what's going on.

12:29.070 --> 12:32.160
Tags to capture defs doesn't contain that tag.

12:32.160 --> 12:39.810
And then we looked and saw that our damage types to resistances team map contained a debuff tag which

12:39.810 --> 12:41.070
doesn't belong there.

12:42.750 --> 12:43.320
Okay.

12:43.320 --> 12:45.030
So we can try this again.

12:46.600 --> 12:49.660
And we're causing damage as we should.

12:49.690 --> 12:53.330
We can also make sure that the enemies can cause damage to us.

12:53.350 --> 12:55.420
And it looks like they can.

12:55.420 --> 12:59.340
And those slingshot goblins really are ruthless, aren't they?

12:59.350 --> 13:00.190
Look at that.

13:00.220 --> 13:01.660
Look at this little guy.

13:02.550 --> 13:03.780
Let's just roast him.

13:05.040 --> 13:05.430
Yeah.

13:05.430 --> 13:06.690
Take that goblin.

13:08.140 --> 13:16.000
That goblin didn't give me much XP, but that's because we set our XP reward for the spear goblins to

13:16.000 --> 13:17.350
a ridiculously high number.

13:17.350 --> 13:20.200
I believe it was 300.

13:20.320 --> 13:23.080
We did no such thing for the Slingshot Goblin.

13:23.080 --> 13:28.660
So it's not a mistake that the Slingshot goblin didn't give us that much XP, so don't worry.

13:28.690 --> 13:30.250
That was correct.

13:30.490 --> 13:30.940
All right.

13:30.940 --> 13:35.560
Just spending a spell point because I can equipping that next ability.

13:35.560 --> 13:36.400
Because I can.

13:36.400 --> 13:37.720
Because why not soon?

13:37.720 --> 13:40.750
We'll actually be making that ability soon enough.

13:40.750 --> 13:48.400
But for now we have achieved an important milestone and that is to use the damage effect params struct

13:48.400 --> 13:49.390
we created.

13:49.390 --> 13:57.580
And not only that but our gameplay ability, at least those that do damage now has damage effect params

13:57.580 --> 14:00.130
and those are being passed along.

14:00.370 --> 14:08.630
And because they're being passed along we can then take a look at those effect params and use them.

14:08.780 --> 14:15.890
Now the only thing special so far are the debuff params, so we want to see if a successful debuff should

14:15.890 --> 14:16.790
happen.

14:16.790 --> 14:23.840
So we'll be using those debuff params to determine if we got a successful debuff and we'll be doing

14:23.840 --> 14:25.100
that next.

14:25.370 --> 14:26.570
I'll see you soon.
