WEBVTT

00:06.870 --> 00:07.830
Welcome back.

00:08.220 --> 00:13.860
Now that we have all these resistance attributes, it's time to take them into account when it comes

00:13.860 --> 00:14.610
to combat.

00:14.610 --> 00:17.460
So here in calc damage, we can do that.

00:17.490 --> 00:24.210
Now we're getting our damage as a set by call or magnitude, and we're setting the set by caller magnitude

00:24.210 --> 00:26.090
based on the damage type.

00:26.100 --> 00:33.300
So what we're doing here is now we're looping through the team map in our gameplay tags called Damage

00:33.300 --> 00:37.140
Types to Resistances, and we're just using the key for that.

00:37.140 --> 00:39.990
We're getting the set by caller magnitude for that key.

00:39.990 --> 00:44.000
And if it's set, then we're adding that to our damage.

00:44.010 --> 00:51.480
Now we can take resistance into account, which means we need to capture resistance attributes as well

00:51.480 --> 00:57.860
so we can scroll all the way up to our damage statics and we can capture those resistance attributes

00:57.870 --> 01:00.390
we need to capture them from the target, don't we?

01:00.420 --> 01:02.250
So let's do that.

01:02.340 --> 01:08.620
We're going to go ahead and just copy this boilerplate line and paste it here, and we're going to,

01:08.620 --> 01:12.820
instead of critical damage, type in fire resistance.

01:12.850 --> 01:18.340
Now that we plan on capturing fire resistance, we're going to copy one of these lines where we're using

01:18.340 --> 01:21.760
the target and we're going to paste it here.

01:21.760 --> 01:27.550
And instead of critical hit resistance, we're going to use fire resistance captured from the target

01:27.550 --> 01:29.050
without snapshotting.

01:29.050 --> 01:33.190
Now, in addition to fire resistance, we want the other three resistances.

01:33.190 --> 01:36.040
So we're going to go ahead and paste three more times.

01:36.040 --> 01:45.130
And instead of fire resistance, next will be lightning resistance, Next will be arcane resistance.

01:45.130 --> 01:48.700
And next we'll have physical resistance.

01:49.090 --> 01:55.120
And in addition to fire resistance down here, we need to capture three more.

01:55.360 --> 02:01.720
These will be lightning resistance, arcane resistance and physical resistance.

02:01.990 --> 02:04.360
Now, that's not the only thing we need to do, right?

02:04.360 --> 02:09.070
We have to add this to relevant attributes to capture on the exec calc itself.

02:09.070 --> 02:13.540
If so, we're going to do that for our four resistances here as well.

02:14.380 --> 02:16.300
So pasting four times.

02:16.300 --> 02:21.660
First we're going to have fire resistance def remember these have to be def.

02:21.670 --> 02:28.420
Next is lightning resistance def next we have arcane resistance def.

02:29.000 --> 02:31.760
And finally we have physical resistance.

02:31.760 --> 02:32.340
Def.

02:32.360 --> 02:39.350
Okay, so each time we capture an attribute in our exec calc, we have a little bit of boilerplate steps

02:39.350 --> 02:39.840
here.

02:39.860 --> 02:42.860
Now, one more boilerplate step isn't going to hurt.

02:42.890 --> 02:47.750
We already have one, two, three things to do if we add one more.

02:47.780 --> 02:48.890
That's not so bad.

02:48.890 --> 02:55.010
In the places where there are boilerplate steps, it's okay to concentrate all the boilerplate steps

02:55.010 --> 02:56.240
into those places.

02:56.270 --> 03:01.730
Other places that are generalized, that are independent of the number of attributes and things.

03:01.730 --> 03:05.090
We don't want to add boilerplate steps to any of those areas.

03:05.090 --> 03:12.050
But in the case where we're capturing attributes, we have to decide which attributes to capture and

03:12.050 --> 03:13.580
that's specific to damage.

03:13.580 --> 03:14.660
So that's okay.

03:14.690 --> 03:22.850
Now, I mentioned adding one more boilerplate step because these capture defs really need to be associated

03:22.850 --> 03:24.080
with some gameplay tags.

03:24.080 --> 03:27.320
They should be associated with those attribute tags.

03:27.350 --> 03:27.860
Why?

03:27.890 --> 03:30.270
Because we're looping through.

03:30.300 --> 03:32.040
Let me find that for loop.

03:32.040 --> 03:32.460
Here it is.

03:32.460 --> 03:39.630
We're looping through damage types to resistances and we have access to the damage type tag.

03:39.630 --> 03:47.820
We have access to the resistance tag, but we don't know how to get the specific capture def associated

03:47.820 --> 03:49.260
with those tags.

03:49.500 --> 03:53.550
We don't want to do these one by one for each resistance.

03:53.550 --> 04:01.920
We want a general for loop, which means we should map these capture defs to their corresponding attribute

04:01.950 --> 04:02.890
tags.

04:02.910 --> 04:10.440
So I'm going to make a team map in or a damage statics and that way we can map these together.

04:10.560 --> 04:12.570
So I'm going to have a team map right here.

04:13.020 --> 04:22.410
It's going to be team map mapping and gameplay tag to an F gameplay attribute capture definition.

04:24.220 --> 04:26.530
That's what these capture deaths are.

04:26.800 --> 04:31.660
And this is going to be tags to capture deaths.

04:31.750 --> 04:35.890
And that way we can map the gameplay tag to the capture death.

04:35.920 --> 04:40.210
We can do that in aura damage statics right here in the constructor.

04:40.210 --> 04:45.340
And so as we see all the boilerplate steps, then there's nothing to remember.

04:45.340 --> 04:52.420
We just go through all the boilerplate steps together and that's now going to involve mapping the attribute

04:52.450 --> 04:54.610
tags to the capture definitions.

04:54.610 --> 04:57.130
And we should do that for all of these, I think.

04:57.130 --> 05:05.140
So what I'm going to do is take tags to capture deaths, call add on it and we're going to add aura

05:05.170 --> 05:13.660
gameplay tags, get dot attributes, and we'll just start at the top with armor.

05:13.900 --> 05:20.290
So attribute secondary armor and we're going to map that to armor def.

05:21.340 --> 05:29.150
Now, if we don't want to type for a gameplay tags dot get every time we can make a const or a gameplay

05:29.180 --> 05:33.380
tags reference called, we'll just say tags.

05:33.410 --> 05:38.000
We'll set it equal to F aura gameplay tags get.

05:39.110 --> 05:45.560
And here we can simply say tags, dot attributes, secondary armor.

05:45.920 --> 05:52.280
And we'll just really quickly time lapse mapping all of these captured attributes to their capture.

05:52.280 --> 05:52.790
Def.

06:31.540 --> 06:39.880
Okay, so we've added the tags to capture deaths and now damage statics has this map and we always know

06:39.880 --> 06:44.350
which capture death is associated with which resistance tag.

06:44.440 --> 06:51.430
That makes it easy because now when we're looping through to get the set by caller magnitudes, we can

06:51.430 --> 06:56.560
also get the resistances corresponding to that resistance tag.

06:56.560 --> 07:01.430
And we know which damage type is associated with which resistance type.

07:01.450 --> 07:04.570
Thanks to damage types to resistances.

07:04.920 --> 07:08.830
In fact, we can gather our thoughts by creating some local variables.

07:08.830 --> 07:12.310
Here we can say const F gameplay tag.

07:13.190 --> 07:14.570
Damage type.

07:15.330 --> 07:17.310
Equals pair.

07:18.670 --> 07:22.030
And hoops rider Autocompleted something.

07:22.030 --> 07:27.970
I always go up to the top and make sure that we didn't get an unwanted include.

07:27.970 --> 07:29.950
And it looks like I did in this case.

07:29.980 --> 07:35.770
As soon as I remove that and go back up, I see that this include was added automatically.

07:35.800 --> 07:37.570
Not exactly what I wanted.

07:37.810 --> 07:39.430
So I have damage type.

07:39.430 --> 07:42.130
That's going to be pair dot key.

07:42.160 --> 07:42.820
Right.

07:43.060 --> 07:48.580
We can also make a const f gameplay tag called resistance tag.

07:49.710 --> 07:51.200
Or just resistance.

07:51.210 --> 07:53.460
That's going to be pair dot value.

07:53.850 --> 08:02.520
And then we can have a const F gameplay attribute capture definition called capture def.

08:03.170 --> 08:09.110
And that can be equal to damage statics or damage statics.

08:11.100 --> 08:12.720
Calling that function.

08:12.720 --> 08:20.610
And then we can have tags to capture defs and tags to capture defs can be indexed with the resistance

08:20.610 --> 08:23.160
tag so resistance can be passed in there.

08:23.930 --> 08:29.980
Now we have to make sure that we're only trying to index for a tag that exists in here.

08:29.990 --> 08:32.180
So we'll get a crash otherwise.

08:32.180 --> 08:40.460
And if we really want to be explicit with this, we can use a check F what we can check is we can say

08:40.490 --> 08:41.690
or damage statics.

08:41.690 --> 08:45.920
We can call that we can get tags to capture deaths and we can say.

08:46.810 --> 08:47.680
Contains.

08:47.680 --> 08:50.400
We can see if it contains a specific tag.

08:50.410 --> 08:56.310
We're going to use that resistance tag, which means I'm going to want this resistance tag defined first.

08:56.320 --> 09:03.700
I'll move those both up there and we're going to say contains resistance and we're checking this.

09:03.700 --> 09:12.670
So if this fails, then we're going to have a crash log message and we're going to say tags to capture

09:12.700 --> 09:20.410
deaths doesn't contain tag and we'll do a percent s.

09:21.670 --> 09:25.580
In and we'll just say exit calc.

09:26.560 --> 09:32.110
Underscore damage and we're going to have to provide that string for percent s.

09:32.140 --> 09:35.680
That's going to be resistance dot to string.

09:35.890 --> 09:43.300
So if we ever try to index tags to capture deaths with a resistance that doesn't exist in it will crash,

09:43.300 --> 09:46.780
but we'll get a nice handy crash log for that.

09:47.050 --> 09:49.690
So now we have the capture def as well.

09:49.690 --> 09:56.170
Now this is great because here in the for loop we can capture that attribute value.

09:56.260 --> 09:59.710
So how are we going to capture that attribute value?

09:59.740 --> 10:04.330
Well, we do it just like we did with our other attributes we've captured.

10:04.450 --> 10:13.030
So we're going to make a float called resistance, set it equal to zero.

10:13.660 --> 10:15.580
It's not any specific resistance.

10:15.580 --> 10:20.350
Actually, we need to call this something else because our gameplay tag is called resistance.

10:20.380 --> 10:25.240
We're going to call this actually damage type tag and resistance tag here.

10:26.940 --> 10:30.010
And we'll replace resistance with resistance tag.

10:30.030 --> 10:31.290
Everywhere we're using it.

10:31.290 --> 10:38.070
And then this will just be our actual resistance value and we capture it by getting our execution params.

10:39.150 --> 10:44.940
And calling attempt calculate captured attribute magnitude.

10:44.970 --> 10:48.910
We need the capture definition and we have the capture def right here.

10:48.930 --> 10:54.780
So we've looked that up from our map and that's the capture def associated with the resistance tag.

10:54.780 --> 10:55.050
Right?

10:55.050 --> 10:56.910
So we pass that in.

10:56.940 --> 11:03.270
Next, we need our evaluation parameters followed by our resistance local variable.

11:03.870 --> 11:06.030
And now we have our resistance.

11:06.150 --> 11:10.290
Now here's where we can clamp or make sure it's not a negative value.

11:10.320 --> 11:15.590
What I'd like to do is clamp and we should make sure resistance is never greater than 100.

11:15.600 --> 11:20.870
If resistance is a 1 to 1 ratio to percentage reduction for damage.

11:20.880 --> 11:28.320
In other words, if each point in a given resistance type reduces 1% of that type of damage, then resistance

11:28.320 --> 11:29.900
should never be greater than 100.

11:29.910 --> 11:39.030
So we're going to say resistance equals F math clamp and we're going to clamp between 0 and 100.

11:43.550 --> 11:47.540
And of course, resistance has to be the first input there.

11:47.660 --> 11:50.630
So now we have a resistance and we're in a for loop.

11:50.630 --> 11:55.640
So this means we're doing this for each of the resistances, each of the damage types.

11:55.670 --> 12:03.170
Now, because this is a resistance, we want to reduce damage by a certain percentage and we know that

12:03.170 --> 12:10.540
this const float damage type value here is the damage associated with this given damage type.

12:10.550 --> 12:12.740
This is the damage type value.

12:12.830 --> 12:17.150
So what I'd like to do is I'd like to have this value calculated.

12:17.150 --> 12:25.580
First up here, I'd like it to no longer be a const float and we're going to reduce it by resistance

12:25.580 --> 12:26.590
percentage.

12:26.600 --> 12:34.610
So the way we're going to reduce our damage type value is we're going to take damage type value times

12:34.610 --> 12:35.420
equals.

12:35.540 --> 12:38.660
So we're going to set it equal to itself times something.

12:38.660 --> 12:44.220
And that's something is going to be a fraction of what it was before based on resistance.

12:44.220 --> 12:45.720
So here's how we'll do the math.

12:45.720 --> 12:47.520
We've done something like this already.

12:47.550 --> 12:52.920
We're going to take 100 f minus resistance and divide this by 100.

12:53.040 --> 12:59.370
So if resistance is ten, 100 minus ten is 90, 90 over 100 is 0.9.

12:59.370 --> 13:06.600
So we would multiply damage type value by 0.9, set it equal to the result, effectively reducing damage

13:06.600 --> 13:08.430
type value by 10%.

13:08.550 --> 13:14.790
Once we've done this, we add the damage type value to overall total damage and we've now taken resistances

13:14.790 --> 13:17.490
into account and it's as simple as that.

13:17.490 --> 13:23.130
So all that's left now is to see if we're reducing damage by a certain amount.

13:23.160 --> 13:25.020
Let's go ahead and run in debug mode.

13:27.260 --> 13:30.710
Okay, so I'll go ahead and open up what we had open there.

13:30.710 --> 13:35.690
And let's go ahead and just see how much damage we're causing at first.

13:35.840 --> 13:37.970
We'll see if we're reducing any.

13:38.000 --> 13:39.440
It's kind of hard to know.

13:39.440 --> 13:46.970
So what we can do to really see what's going on is place a breakpoint and then launch a fireball.

13:48.110 --> 13:51.980
Now, in the break point, we can see what some of these values are.

13:52.400 --> 13:57.740
So first of all, resistance tag, that's attributes, resistance, arcane.

13:57.770 --> 14:02.990
Now we're looping through all of these damage types and resistances, right?

14:02.990 --> 14:09.700
So we expect the set by caller magnitude to be zero for damage type value and we do see zero.

14:09.710 --> 14:15.730
So that means damage type value ends up being zero and damage gets zero added to it.

14:15.740 --> 14:21.140
Now if we click resume, then we'll pause on the next damage type and resistance.

14:21.140 --> 14:24.740
This is lightning again, that should be zero resuming.

14:24.740 --> 14:28.160
We get physical, that should be zero and resuming.

14:28.160 --> 14:29.420
We get fire.

14:29.450 --> 14:33.140
Now the damage type of the fireball is fire.

14:33.170 --> 14:35.120
So that means we should get a value.

14:35.120 --> 14:39.620
Now we see just about ten for the set by caller magnitude.

14:39.830 --> 14:45.530
Now we're capturing resistance and our enemies have zero resistance.

14:45.530 --> 14:45.830
Right?

14:45.830 --> 14:51.450
That's because we never actually set those modifiers for their resistances.

14:51.450 --> 14:55.230
But what we can do is we can add them to our test attribute.

14:55.320 --> 14:56.250
I'd like to do that.

14:56.250 --> 15:02.100
I'm going to remove the breakpoint and resume and come back into the editor, at least want to see this

15:02.100 --> 15:02.910
working.

15:02.910 --> 15:11.130
So we're going to go to blueprints, Ability system, gameplay effects, default attributes and G secondary

15:11.130 --> 15:12.480
attributes test.

15:12.480 --> 15:16.520
And let's go ahead and just add a fire resistance attribute.

15:16.530 --> 15:21.660
So I'm going to go ahead and collapse some of these and let's add a modifier.

15:22.340 --> 15:26.390
We're going to add the attribute fire resistance.

15:27.790 --> 15:32.500
We're going to make this override, make the modifier magnitude a scalable float.

15:32.500 --> 15:39.310
And why don't we just set the fire resistance to 50 and now we expect half the damage?

15:39.780 --> 15:41.070
From fire.

15:41.730 --> 15:43.500
To not be applied.

15:45.150 --> 15:49.770
And usually Non-blocked non-critical hits were five.

15:49.800 --> 15:51.150
Now we see three.

15:51.150 --> 15:53.640
And of course, we're rounding to integers here.

15:54.240 --> 15:55.590
Critical hit used to be 20.

15:55.620 --> 15:57.840
Now we're seeing 15.

15:57.960 --> 16:00.390
So we're ignoring a percentage of fire damage.

16:00.390 --> 16:04.500
We can place the breakpoint back and see what these values are.

16:04.500 --> 16:05.280
Exactly.

16:05.310 --> 16:08.310
Now, the resistance tag is arcane.

16:08.310 --> 16:14.850
We're going to resume until we see fire and we do damage type is damage.

16:14.850 --> 16:16.950
Fire resistance is resistance.

16:16.950 --> 16:20.150
Fire damage type value 4.999.

16:20.160 --> 16:24.120
Now, of course, this is after reducing the damage by the resistance.

16:24.120 --> 16:25.920
The resistance here is 50.

16:25.950 --> 16:28.380
We set that in the test attribute.

16:28.380 --> 16:34.200
So now we've reduced the damage type value by 50%.

16:34.200 --> 16:39.330
So damage should now be 4.999 or 5, in other words.

16:39.480 --> 16:42.570
So we see that we're effectively reducing damage.

16:44.630 --> 16:45.470
Excellent.

16:46.720 --> 16:49.930
So now we have damage types and they're taken into account.

16:50.110 --> 16:57.970
Now it's a little bit hard to tweak these enemy parameters, isn't it, because we have so many mathematical

16:57.970 --> 17:03.940
interrelationships between our attributes and so that makes it a little bit difficult to tweak these

17:03.940 --> 17:04.720
things.

17:04.750 --> 17:11.860
So throughout the course, we're going to learn ways to fine tune the game and see how we can get all

17:11.860 --> 17:17.140
of our attributes to work together to produce a positive gameplay experience.

17:17.140 --> 17:18.610
But one step at a time.

17:18.610 --> 17:21.240
For now, we have our resistances.

17:21.250 --> 17:28.240
We can see auras, resistances we can't see the enemy's resistances, but we see that aura has her resistances

17:28.240 --> 17:30.010
set all to nine.

17:30.040 --> 17:35.860
They're all based on resilience and the enemies are reducing a percentage of fire damage as well.

17:36.310 --> 17:37.000
Okay.

17:37.000 --> 17:38.130
Excellent job.

17:38.140 --> 17:40.120
We now have resistances.

17:40.240 --> 17:42.160
I'll see you in the next video.
