WEBVTT

00:06.810 --> 00:08.010
Welcome back.

00:08.040 --> 00:12.900
In this video, we're going to handle two issues that you may or may not have noticed.

00:12.930 --> 00:20.580
Now, one of those issues is something we can see if we go into our attribute set, where we level up

00:20.580 --> 00:24.670
here, we set our health and mana to their max values.

00:24.690 --> 00:29.760
Now, if you did any testing, you may have noticed that we're not getting those globes filled up.

00:29.760 --> 00:37.260
When we level up, all you have to do is go and get damaged a few times to see that We'll let Aura get

00:37.260 --> 00:41.010
hurt a few times and then we can just level up.

00:43.730 --> 00:47.900
And we should see we would expect to see our Globes to fill.

00:49.070 --> 00:52.190
And they feel slightly, but not all the way.

00:52.250 --> 00:55.790
So why do they not feel all the way up?

00:56.090 --> 01:01.700
Well, we're setting our health and mana to our max health and max mana values.

01:01.940 --> 01:03.890
And these depend on level.

01:04.160 --> 01:06.410
Now we're changing our level.

01:06.410 --> 01:12.710
And you would think because we're adding to our player level first, that our max health and Max Mana

01:12.710 --> 01:16.730
will be adjusted, but it doesn't actually happen right away.

01:16.760 --> 01:21.950
In fact, it doesn't happen until post gameplay effect execute is already finished.

01:22.190 --> 01:30.830
We can see that by pressing play then coming back and placing a breakpoint right at set health and then

01:30.830 --> 01:35.600
we can go into max health and place a breakpoint here.

01:35.630 --> 01:37.550
Now if we go and level up.

01:41.500 --> 01:44.680
We'll see that set health and Setmana get called first.

01:44.680 --> 01:49.220
And if we click resume our is executed after.

01:49.240 --> 01:53.950
So for that reason, we're going to have to go about this a little bit differently.

01:54.100 --> 02:02.560
Now, an MSI like this is applying a modifier to our max health, and when it does so, it changes the

02:02.560 --> 02:05.980
Max Health's current value, not its base value.

02:06.250 --> 02:13.270
Now there are functions on the attribute set to respond to changes to current values.

02:13.270 --> 02:19.390
In fact, we can have something happen after we've set our max health and max mana.

02:19.480 --> 02:23.400
I'm going to go into my H file for Ora attribute set.

02:23.410 --> 02:30.550
I'm going to find you attribute set and click on it so I can go to it and I'm going to search for post

02:30.580 --> 02:32.950
gameplay effect.

02:33.910 --> 02:36.480
And here's post gameplay effect execute.

02:36.490 --> 02:42.690
But notice there are all these other functions pre attribute change which we've overridden.

02:42.700 --> 02:45.070
We have post attribute change.

02:45.160 --> 02:49.960
We also have pre attribute base change in post attribute base change.

02:50.620 --> 02:56.860
Now, in the case of an AMC, we're not changing the base value, so we don't want post attribute base

02:56.860 --> 02:57.520
change.

02:57.520 --> 03:00.070
We want post attribute change.

03:00.070 --> 03:05.650
Here is where we can do something in response to our max health or max mana changing.

03:05.650 --> 03:12.310
So what I'd like to do is copy this line and go back to our attribute set and override this function

03:12.310 --> 03:14.050
post attribute change.

03:14.050 --> 03:20.110
And I'm going to mark it with override here and go ahead and generate a definition for this.

03:20.440 --> 03:27.490
Well, if my max health just changed, then I know I can set my health to max health if we're leveling

03:27.490 --> 03:28.120
up.

03:28.330 --> 03:28.900
Now.

03:28.900 --> 03:33.670
If you only change your max health when you're leveling up, same for your max mana.

03:33.700 --> 03:34.840
You can just check.

03:34.870 --> 03:37.390
Is Max Health the attribute that's changing?

03:37.390 --> 03:39.910
If so, set our health to Max.

03:39.940 --> 03:45.850
Now, in some games you may have changes to your max health when you're not leveling up.

03:45.850 --> 03:50.750
So in that case, we may wish to know if this change is from a level up or not.

03:50.750 --> 03:50.950
It.

03:51.580 --> 03:53.920
So we can have a couple of booleans.

03:54.160 --> 03:56.440
I'll put them down here in the private section.

03:56.440 --> 03:59.800
I'll have be top off health.

04:00.550 --> 04:05.490
It'll be set to false and I'll have a bool called Be top off.

04:05.500 --> 04:10.990
Mana also set to false, but we'll set these to true when we level up right here.

04:10.990 --> 04:18.190
So instead of setting health and mana, we'll set be top off health to true and we'll set be top off

04:18.190 --> 04:25.570
mana to true and when max health and max mana change we'll check those booleans here.

04:25.570 --> 04:31.360
So here in post attribute change since we have the gameplay attribute, it's called attribute we'll

04:31.360 --> 04:40.750
say if attribute is equal to get max health attribute and we can have an end here and check be top off

04:40.750 --> 04:41.530
health.

04:41.530 --> 04:47.500
If these are true, then we can set health equal to the value of max health.

04:47.500 --> 04:49.090
So get max health here.

04:50.360 --> 04:51.890
And we can do the same for Mana.

04:51.890 --> 04:57.500
We can say if attribute equals get max mana attribute.

04:59.960 --> 05:02.330
And be top off mana.

05:03.440 --> 05:05.180
Then we can top off mana.

05:05.990 --> 05:13.520
We can say set mana, get max mana and our mana will be topped off too.

05:13.550 --> 05:19.730
Now, if this is true, be topped off health, then we should consume that boolean.

05:19.730 --> 05:21.790
In other words, we should set it back to false.

05:21.800 --> 05:24.950
So we'll say be top off health equals false here.

05:24.950 --> 05:26.440
And same goes for mana.

05:26.450 --> 05:28.670
We'll set be top off mana.

05:31.570 --> 05:33.000
Equal to false as well.

05:33.010 --> 05:38.860
And that way we can have changes to our max health and Max Mana even when we're not leveling up.

05:38.860 --> 05:43.240
And only if we're leveling up will we max out health and mana.

05:43.270 --> 05:50.200
With that, let's give this a test run and see if our globes get filled up when we level up.

05:51.410 --> 05:54.170
So back in the editor, I'm going to press play.

05:54.200 --> 05:56.390
I'm going to get hurt a little bit.

05:57.050 --> 06:00.830
So just letting the goblins stab me a few times.

06:01.010 --> 06:07.940
I'll let it get down to maybe halfway or so, and then I'll run away and see if I can kill one and level

06:07.940 --> 06:08.330
up.

06:11.200 --> 06:11.950
There we go.

06:11.950 --> 06:13.750
And my health has been topped off.

06:13.750 --> 06:20.290
Now, the most important thing about this is when they hit me again, it should look like the amount

06:20.290 --> 06:23.470
that's being subtracted is correct.

06:23.500 --> 06:28.450
We don't want it to go down to say, almost zero from getting hit once.

06:28.540 --> 06:29.710
So let's see.

06:30.100 --> 06:31.270
Yeah, that looks right.

06:31.270 --> 06:32.590
That looks perfect.

06:32.590 --> 06:36.790
And if we cast a spell, then that also looks correct.

06:36.790 --> 06:40.150
So it looks like we have the effect that we wanted.

06:40.150 --> 06:43.000
Let's try that again by leveling up one more time.

06:44.770 --> 06:46.480
And see if we get topped off here.

06:49.170 --> 06:51.120
Boom, there it goes.

06:51.120 --> 06:52.950
And if we get stabbed.

06:53.780 --> 06:57.310
Then it appears that we're taking the appropriate amount of damage.

06:57.320 --> 07:00.080
Everything is working properly.

07:00.080 --> 07:03.440
So that was the first issue I wanted to take care of.

07:03.590 --> 07:11.720
The next issue can be seen if we press play and dock our output log and we go ahead and start playing

07:11.720 --> 07:12.350
the game.

07:13.300 --> 07:14.770
Let's get a level up.

07:15.590 --> 07:16.910
And there's the issue.

07:16.910 --> 07:18.230
I'm going to hit pause.

07:18.320 --> 07:20.490
Now, we've seen this error before.

07:20.510 --> 07:22.430
It's on the gameplay effects spec.

07:22.460 --> 07:26.780
It has to do with getting set by caller magnitudes that were never set.

07:27.020 --> 07:33.110
Now we're getting set by caller magnitudes that were never set because we're applying a gameplay effect,

07:33.200 --> 07:42.450
event based effect which has five different modifiers, all of which are set by caller magnitude modifiers.

07:42.470 --> 07:49.490
Now, depending on the event tag that we receive in our passive gameplay ability.

07:51.410 --> 07:52.050
Gah.

07:52.190 --> 07:53.840
Listen for events.

07:54.080 --> 07:59.830
When we receive a tag, then we assign a set by color magnitude for that tag.

07:59.840 --> 08:03.680
But we don't assign a set by color magnitude for the other four.

08:03.860 --> 08:10.010
Now in C plus plus, this wasn't a problem because we could suppress that error message as there is

08:10.010 --> 08:13.870
a boolean, but in blueprint we don't have that option to suppress it.

08:13.880 --> 08:20.030
So what we should do is every time we assign a set by color magnitude for one of the tags, we should

08:20.030 --> 08:24.140
assign a set by color magnitude of zero for the other four.

08:24.140 --> 08:28.010
And that way we won't get that pesky little error message.

08:28.040 --> 08:29.780
So here's how I'd like to do it.

08:29.780 --> 08:35.840
First of all, I'm going to have an array of gameplay tags and we'll loop through and for the gameplay

08:35.840 --> 08:40.370
tag that we've received, we'll set it set by color magnitude as we're doing.

08:40.370 --> 08:44.690
But for the other four we'll set it's set by color, magnitude to zero.

08:44.690 --> 08:49.790
So let's add a variable, we'll choose the type gameplay tag.

08:53.260 --> 09:00.490
We'll call this event tags and we'll change its variable type here to an array.

09:01.300 --> 09:09.100
Now I'm going to compile and click plus five times and fill this array with the gameplay tags that are

09:09.100 --> 09:16.900
event based effect has modifiers for the first of those is going to be attributes meta incoming exp

09:17.290 --> 09:20.710
and the other four are our primary attributes.

09:20.710 --> 09:23.230
So for the next one we'll do intelligence.

09:23.230 --> 09:29.530
For the next one we'll do resilience, the next one will be strength and the next one will be vigor.

09:29.650 --> 09:35.830
So now that we have this array, as soon as we've received an event, we'll loop over that array.

09:35.920 --> 09:42.400
So to prevent this blueprint from getting out of control, I'm going to make sure this is nice and organized.

09:42.400 --> 09:44.980
For one, I'm going to delete on end ability.

09:44.980 --> 09:46.090
I don't need it.

09:46.120 --> 09:52.540
Next in Wait gameplay event, when an event is received, I'm going to cache off the event tag and the

09:52.540 --> 09:53.740
event magnitude.

09:53.740 --> 09:55.510
So I'm going to take event tag.

09:55.510 --> 09:57.100
Promote it to a variable.

09:57.100 --> 10:02.870
I can just let it be event tag and I'm going to take event magnitude and promote that to a variable

10:02.870 --> 10:05.600
and let that be called event magnitude.

10:05.810 --> 10:10.250
In addition to that, I'm going to cache off the outgoing spec.

10:10.250 --> 10:17.960
Remember, these blueprint pure nodes are executed every time a node is reached which has a wire connected

10:17.960 --> 10:18.590
to them.

10:18.590 --> 10:20.270
So that can be dangerous.

10:20.270 --> 10:24.350
We don't want to keep making new outgoing effect specs, we just want one.

10:24.350 --> 10:27.560
So I'm going to promote this to a variable called spec.

10:27.620 --> 10:36.830
Now these are being set here every time our ability is activated, but once per activation, we don't

10:36.830 --> 10:39.680
want to set them multiple times per activation.

10:39.680 --> 10:43.730
So we're only setting them here and then reusing them later.

10:44.030 --> 10:49.040
So after setting these, I'm going to loop over our event tags.

10:49.040 --> 10:52.580
So I'm going to get them and use a for each loop.

10:56.570 --> 11:02.450
And in the for each loop body I want to check the array element, which is a gameplay tag.

11:02.450 --> 11:06.620
I want to check it against our event tag and see if they're equal.

11:06.620 --> 11:09.440
So I'm going to just break.

11:10.800 --> 11:14.190
All of these wires and move this out of the way.

11:14.310 --> 11:18.410
And I'm going to make a branch here and in the loop body.

11:18.420 --> 11:24.510
What I'm going to check is to see if my array element, which is a gameplay tag, matches our event

11:24.540 --> 11:25.170
tag.

11:25.170 --> 11:29.390
So I'm going to say matches tag and I want it to match exact.

11:29.400 --> 11:31.380
So I'm going to take my event tag.

11:31.380 --> 11:34.620
Remember, this is the tag that we received from our event.

11:35.220 --> 11:38.690
And as we loop through our event tags, there's five of them.

11:38.700 --> 11:44.510
Once we find the one that matches, that's the one we're setting our set by caller magnitude for.

11:44.520 --> 11:51.840
So we're going to assign tags set by caller magnitude using the event tag as the data tag, our event

11:51.840 --> 11:53.910
magnitude as the magnitude.

11:53.910 --> 11:57.330
And we cashed off our spec handle, we called it spec.

11:59.930 --> 12:02.870
So I'm going to go ahead and break these wires.

12:02.990 --> 12:07.910
And for the true case, this is for the tag we received in our event.

12:07.910 --> 12:10.580
So we're going to hook this up to True.

12:12.410 --> 12:19.560
But for all four of the other tags, we're going to assign tags set by color magnitude for that tag.

12:19.580 --> 12:26.510
The array element here to zero, but we're going to use the same spec handle, so we're going to use

12:26.510 --> 12:29.790
spec for that and we're going to hook up the false case.

12:29.810 --> 12:36.620
So for the one tag in our array that matches the event that we received, we're assigning a set by color

12:36.620 --> 12:37.550
magnitude.

12:37.580 --> 12:40.340
Using that event magnitude we cashed off.

12:40.340 --> 12:47.240
But for the other four, we're setting its magnitude to zero just because we need it set now in the

12:47.240 --> 12:54.170
completed execution pin for the for each loop, we can finally apply the gameplay effect spec to self.

12:54.170 --> 13:01.460
So we're going to hook completed up to apply gameplay effect spec to self, but we need to hook in spec

13:01.460 --> 13:03.050
for the spec handle.

13:03.230 --> 13:08.210
So by the end of this we'll actually have applied the gameplay effect.

13:08.240 --> 13:12.380
Let's go ahead and get this pulled out just a little bit.

13:13.920 --> 13:17.040
And we can organize this just a little bit more.

13:17.900 --> 13:18.890
Like so.

13:19.880 --> 13:22.140
So this has the same effect.

13:22.160 --> 13:29.090
The only difference is we're never omitting to assign a set by color magnitude that exists in the gameplay

13:29.090 --> 13:31.640
effect spec that we're applying.

13:31.640 --> 13:35.540
We're setting the one that matters and we're setting all the others to zero.

13:35.690 --> 13:40.040
So with that, we can press play and we can level up.

13:41.210 --> 13:45.080
Like so and we no longer get that warning.

13:47.110 --> 13:52.750
Well, it's actually an error, so that takes care of that.

13:52.930 --> 13:53.800
Excellent.

13:53.800 --> 14:00.040
So now that we've polished a couple things up, it's time to polish the look and feel of our attribute

14:00.040 --> 14:00.710
menu.

14:00.730 --> 14:03.710
I'd like it to look excellent and sound great.

14:03.730 --> 14:05.860
I'd like some hover sound, some click sounds.

14:05.860 --> 14:08.710
I'd like it to sound and feel like a real menu.

14:08.710 --> 14:10.390
And we'll do that next.

14:10.420 --> 14:11.460
Great job.

14:11.470 --> 14:12.640
I'll see you soon.
