WEBVTT

00:07.890 --> 00:09.000
Welcome back.

00:09.030 --> 00:16.740
Now, as soon as we've spawned an electric beam, it's time to start thinking about doing damage and

00:16.740 --> 00:22.110
committing our ability cost so we can see that a globe start going down.

00:22.320 --> 00:24.450
We're going to handle that in this video.

00:24.450 --> 00:32.070
And the way that I'd like it to happen is as I'm holding this input down and we see those electric beams,

00:32.070 --> 00:39.240
I want to see the man globe going down steadily, say ten times a second or so.

00:39.420 --> 00:42.600
Now that ten times a second, that could be a parameter.

00:42.600 --> 00:49.170
We can make a float and that float I'm going to add right now it's going to be a variable.

00:49.290 --> 00:56.490
And that variable is going to be called I'm going to call it damage delta time.

00:57.160 --> 00:59.620
And change its type to a float.

00:59.620 --> 01:01.360
And it doesn't need to be a map.

01:01.360 --> 01:06.580
So we have to come over here and change it to a single and damage delta time.

01:06.580 --> 01:10.000
If we compile, I'm going to give it a 0.1.

01:10.000 --> 01:16.420
So every 0.1 seconds will not only apply damage but also commit our ability cost.

01:16.450 --> 01:24.130
So what I'm going to do is drag off of spawn electric beam and use set timer by event.

01:26.900 --> 01:28.910
And we can make a custom event.

01:30.880 --> 01:35.200
And this will be called damage and cost.

01:35.560 --> 01:36.850
And we'll hook it in.

01:36.850 --> 01:38.140
And the time.

01:38.800 --> 01:39.790
Can be damaged.

01:39.800 --> 01:40.720
Delta time.

01:42.120 --> 01:51.060
And it's going to be looping, and we're going to store the return value as a timer handle for damaging

01:51.060 --> 01:51.390
costs.

01:51.390 --> 01:53.970
So we'll call it damage and cost timer.

01:53.970 --> 01:55.890
And that's our timer handle.

01:55.890 --> 01:59.220
When we clear and invalidate it, we'll stop the timer.

01:59.550 --> 02:01.230
So here's the thing.

02:01.260 --> 02:07.860
Each time this event occurs we are going to commit the ability cost, which we can do separately.

02:07.860 --> 02:10.140
We can use commit ability cost.

02:10.140 --> 02:13.320
And as soon as we've committed that we can check.

02:13.320 --> 02:20.880
We can use a boolean and see if we have successfully applied that ability cost.

02:21.090 --> 02:24.690
And if we fail, then we can't meet that ability cost.

02:24.720 --> 02:28.110
We're out of mana and we can use.

02:29.300 --> 02:32.750
Prepare to end ability and end ability.

02:36.370 --> 02:42.910
Now each time, if we're not ending the ability, we're going to apply damage and we'll get to that.

02:42.910 --> 02:45.490
For now, let's see if we can commit this ability.

02:45.490 --> 02:46.210
Cost.

02:48.470 --> 02:50.150
So I'm going to cast.

02:50.800 --> 02:52.150
And look at my mana.

02:52.180 --> 02:53.620
See it going down?

02:55.990 --> 02:57.670
That is looking great.

02:59.300 --> 03:04.070
Now we can also just clear and invalidate that timer as well.

03:04.070 --> 03:11.960
We can take our damage and cost timer and use clear and invalidate timer by handle here.

03:13.230 --> 03:14.760
Just before.

03:16.620 --> 03:18.090
We end the ability.

03:20.810 --> 03:23.690
We could even do that inside prepare to end ability.

03:23.690 --> 03:30.800
But anyway, now that we're committing the cost, what we can also do is we can.

03:30.800 --> 03:33.950
As long as we can pay the cost, we can do damage.

03:33.980 --> 03:39.580
Now, applying damage is going to involve a couple things, right?

03:39.590 --> 03:44.840
We need to apply damage to the mouse hit actor, but also to the additional targets.

03:44.840 --> 03:47.540
So I'm going to add a new function here.

03:47.540 --> 03:50.120
And this will be Apply damage.

03:50.900 --> 03:58.190
And apply damage will first apply damage to the mouse hit actor and then apply damage to the additional

03:58.190 --> 03:59.030
targets.

03:59.120 --> 04:02.930
So how are we going to apply damage to the mouse hit actor?

04:02.960 --> 04:08.600
Well, first we need our ability system component so we can get that from actor info.

04:08.600 --> 04:14.600
So we can use get ability system component from actor info.

04:14.600 --> 04:17.330
And we can make an effect context with it.

04:17.480 --> 04:23.600
So we'll use make effect context and and we can also make an outgoing spec.

04:23.810 --> 04:27.860
So make outgoing spec all of this stuff we've done already.

04:27.890 --> 04:32.570
We can hook up that context and we can get our ability level.

04:32.750 --> 04:35.450
So get ability level.

04:36.630 --> 04:38.400
We can hook up our ability level.

04:38.400 --> 04:45.030
That's going to be converted into a float for the outgoing spec, and we can set our damage gameplay

04:45.030 --> 04:49.500
effect class to damage gameplay effect.

04:50.710 --> 04:53.230
It's actually called damage effect class.

04:53.260 --> 04:54.520
We can hook that in.

04:54.790 --> 04:59.140
Now all we're doing is applying the damage gameplay effect.

04:59.140 --> 05:05.770
We haven't actually set any set by color magnitudes or anything, and I don't want to use our ability

05:05.770 --> 05:11.650
system blueprint library function because it's going to require damage effect params.

05:11.650 --> 05:18.520
And if we use make damage effect params from class defaults, then we would end up setting our debuff

05:18.520 --> 05:19.360
chance.

05:19.360 --> 05:24.100
And for each of these little damages, I'll call them.

05:24.100 --> 05:26.680
As we're casting this spell.

05:26.710 --> 05:34.840
I don't want each of these times we're applying damage little by little to have a debuff chance.

05:35.020 --> 05:41.650
I don't want any debuff chance for this only when I apply damage for the very last time when I release.

05:41.650 --> 05:48.820
When I stop casting this spell, do I want to actually apply damage that has those set by color magnitudes

05:48.820 --> 05:49.600
in them?

05:49.690 --> 05:53.170
For debuff chance and all the debuff parameters?

05:53.170 --> 05:59.860
So all I'm going to do with this spec is assign a damage set by color magnitude.

05:59.860 --> 06:04.150
So I'm going to use assign tag set by color magnitude.

06:04.150 --> 06:07.120
And I'm going to choose the damage type.

06:07.120 --> 06:11.110
So it's going to be damage dot lightning right.

06:11.110 --> 06:12.460
So that's the damage type.

06:12.460 --> 06:16.720
And the magnitude is going to be gotten from our damage.

06:16.750 --> 06:20.410
And of course that is right here.

06:20.530 --> 06:25.210
And our damage isn't actually exposed to blueprint.

06:25.210 --> 06:27.790
So I'd like it to be exposed.

06:27.820 --> 06:34.270
Even more useful would be just a function that performs the lookup and returns the float damage at current

06:34.270 --> 06:34.900
level.

06:34.900 --> 06:36.130
So I'd like to do that.

06:36.130 --> 06:39.640
So I'm going to close the editor and go back to Aura Beam spell.

06:39.640 --> 06:44.350
Actually, it would be nice if this were in Aura Damage gameplay ability.

06:44.350 --> 06:52.240
So we can make a blueprint pure function, and this will be a float returning function.

06:52.240 --> 06:54.580
Get damage at level.

06:56.980 --> 07:00.430
So make it a new function blueprint pure.

07:00.430 --> 07:02.980
And we'll go ahead and define this.

07:03.990 --> 07:05.430
And what's it going to be?

07:05.430 --> 07:10.010
Well, we're doing something like this already in Aura Firebolt.

07:10.020 --> 07:13.620
If we go to the cpp file for that.

07:14.210 --> 07:18.810
We'll see that we're already calculating damage and get description.

07:18.830 --> 07:20.240
We have scaled damage.

07:20.240 --> 07:22.640
Its damage get value at level.

07:23.440 --> 07:26.500
I'm going to copy that and we're going to go back.

07:27.160 --> 07:34.390
Two or a damaged gameplay ability, and we're going to return damaged value at level passing in get

07:34.420 --> 07:35.650
ability level.

07:36.570 --> 07:38.670
Now this could be a const function.

07:38.700 --> 07:41.460
Of course it's going to be.

07:43.140 --> 07:45.930
And with that, now we can get that damage.

07:45.930 --> 07:48.540
So let's go ahead and launch again.

07:50.100 --> 07:52.290
All right back into our ability.

07:52.380 --> 07:56.640
I'm going to call get damage at level.

07:57.630 --> 08:01.470
And that is going to be plugged in to magnitude.

08:01.470 --> 08:04.830
So we're assigning a tag set by color magnitude.

08:04.830 --> 08:11.600
And I'm going to apply this to the ability system component of our mouse hit actor.

08:11.610 --> 08:19.440
So I'm going to right click get our mouse hit actor and get the ability system component from it.

08:19.440 --> 08:22.590
So get ability system component.

08:23.250 --> 08:27.600
And from that ability system component I'm going to.

08:28.480 --> 08:30.040
Call apply.

08:30.650 --> 08:32.050
Gameplay effect.

08:32.050 --> 08:33.160
Spec two.

08:33.160 --> 08:33.880
Self.

08:35.040 --> 08:37.470
And we'll hook this up to apply damage here.

08:39.890 --> 08:45.760
And in fact, we need to assign the tag set by color magnitude first and foremost.

08:45.770 --> 08:47.660
And then we can call this.

08:48.790 --> 08:51.520
And let's get our nodes under control.

08:55.220 --> 08:55.980
Okay.

08:56.000 --> 09:05.480
I think it's best if you can minimize the number of crossing wires so that it's really easy to see exactly

09:05.480 --> 09:07.070
where each wire goes.

09:07.190 --> 09:11.000
That is good blueprint organization in my opinion.

09:11.680 --> 09:20.050
Now this function is applying damage to mouse hit actor, but we need to do the same exact thing to

09:20.050 --> 09:21.970
all of the additional targets.

09:22.090 --> 09:28.750
So what I'd like to do is I'm going to take this mouse hit actor, this one here, and drag it way over

09:28.750 --> 09:29.470
here.

09:30.730 --> 09:35.860
Like this, and then I can highlight all of this and collapse it to a function.

09:35.950 --> 09:42.790
I'm just going to collapse it and call the function apply damage single target.

09:43.300 --> 09:47.740
And this function can be used with mouse hit actor.

09:47.740 --> 09:53.330
And it can also be used with all of the additional targets.

09:53.350 --> 09:58.690
If we get those additional targets and we use a for each loop.

10:01.100 --> 10:09.110
Then we can call apply damage single target on all of them in the loop body with the array elements

10:09.110 --> 10:10.340
as the actor.

10:10.820 --> 10:14.240
So now we have apply damage which we can apply.

10:15.040 --> 10:22.970
So we can go back out to the event graph and each time damage and cost is executed.

10:22.990 --> 10:29.980
If we can afford the ability cost, we can call our new function apply damage.

10:31.950 --> 10:35.820
Which will apply damage to all of our enemies.

10:35.850 --> 10:41.250
Now, when the mouse hit actor dies, I would like to end the ability.

10:42.150 --> 10:47.430
So I'm going to make a boolean called target dead.

10:49.870 --> 10:54.100
And I'm going to check it here even before applying the damage effect.

10:54.100 --> 10:58.720
So I'm going to have another branch and we're going to check if target dead.

10:59.480 --> 11:03.710
Now we're not setting it yet, but once we do, we'll know when the target is dead.

11:03.710 --> 11:07.010
And if it's not dead, we'll apply the damage effect.

11:07.900 --> 11:12.610
If it is dead, then we can go ahead and prepare to end ability.

11:12.670 --> 11:16.570
We can do all of this stuff clear and invalidate the timer.

11:17.860 --> 11:19.630
We'll just have it all right here.

11:24.920 --> 11:27.680
And of course, we're repeating ourselves here and here.

11:27.680 --> 11:33.770
We could just collapse these to a function clear timer and end ability.

11:34.280 --> 11:35.210
Let's do that.

11:35.210 --> 11:36.620
Collapse the function.

11:37.070 --> 11:40.160
Clear timer and end ability.

11:40.790 --> 11:42.530
And we'll just use that here.

11:43.280 --> 11:44.810
And we'll use that here.

11:53.500 --> 11:55.920
Now, how do we know when the target has died?

11:55.930 --> 11:57.040
Well, we'll get to that.

11:57.040 --> 11:57.790
Let's just see.

11:57.820 --> 12:05.500
Now, if we're handling damage correctly and it looks like I have an error here, I'm applying the gameplay

12:05.500 --> 12:08.800
effect spec without passing in a spec handle.

12:08.830 --> 12:16.720
I need to pass that spec handle in, and it's actually returned from sign tag set by color magnitude,

12:16.720 --> 12:18.310
so I can plug that in there.

12:19.150 --> 12:23.770
And looking at the inside of this function, I see that it's a little bit.

12:25.310 --> 12:25.970
ifI.

12:27.020 --> 12:31.850
So I'm going to promote this input parameter to a local variable.

12:32.640 --> 12:36.300
We'll call this damaged target.

12:38.650 --> 12:39.670
Like so.

12:43.450 --> 12:46.090
And that can be what we put right here.

12:46.840 --> 12:48.310
Damaged target.

12:52.120 --> 12:55.390
And I'm going to reroute this around these.

13:00.180 --> 13:03.570
Okay, now we're looking a little bit better.

13:06.350 --> 13:07.580
Compiling that.

13:07.610 --> 13:10.820
Let's just see if we are causing damage.

13:13.290 --> 13:14.760
Oh, yes we are.

13:14.790 --> 13:15.750
Look at that.

13:22.220 --> 13:24.020
Pretty crazy.

13:28.650 --> 13:29.520
Okay.

13:29.520 --> 13:30.420
Well.

13:31.440 --> 13:32.670
That's working.

13:41.780 --> 13:42.810
Crazy.

13:42.830 --> 13:44.270
Okay, so that's working.

13:45.720 --> 13:50.880
Now this seems to look pretty good, but there are a few details we still have to take care of.

13:52.040 --> 14:00.050
It's kind of hard to see some of them, but for one, when all of them die, we still see electricity.

14:01.480 --> 14:01.860
Right.

14:01.860 --> 14:04.250
So that's something we have to fix.

14:04.260 --> 14:12.750
In addition to that, we also need to decide when we should end the ability and decide when we should

14:12.750 --> 14:14.670
commit the ability cost.

14:14.670 --> 14:19.110
So there are still a few things left to do and we'll handle those next.

14:19.530 --> 14:20.640
I'll see you soon.
