WEBVTT

00:06.910 --> 00:08.170
Welcome back.

00:08.410 --> 00:11.110
Now let's take a look at one of our gameplay effects.

00:11.110 --> 00:15.760
I have Crystal Manor open here and I'm going to scroll down.

00:15.760 --> 00:22.990
And because this gameplay effect has duration, we have the ability to configure its stacking options.

00:23.080 --> 00:31.420
Notice we have a stacking section and we have a stacking type and stacking type can be set to none or

00:31.420 --> 00:35.260
aggregate by source or aggregate by target.

00:35.290 --> 00:37.210
Now it's set to none.

00:37.210 --> 00:43.220
And I want to see what happens when we pick up two of these or maybe 3 or 4.

00:43.240 --> 00:51.850
So I'm going to take this man a crystal and duplicate it a few times and I'll have these sort of all

00:51.850 --> 00:55.420
next to each other so we can pick them all up very rapidly.

00:55.570 --> 00:59.620
And let's see what happens with none as the stacking type.

00:59.620 --> 01:02.320
I'm going to pick all three up and look at that.

01:02.320 --> 01:08.680
Our mana goes up and in fact, let's look at the numerical value using show debug.

01:08.690 --> 01:14.120
Our mana is set to ten and if I pick up all three of them, look at that.

01:14.120 --> 01:16.450
It's going up really rapidly.

01:16.460 --> 01:19.310
Now that seems like stacking, doesn't it?

01:19.310 --> 01:23.030
But that's not what stacking really is.

01:23.060 --> 01:27.590
Without any stacking, we just apply the effect three times.

01:27.590 --> 01:34.700
Each one has its own duration and they're all sort of being applied at the same time and we end up getting

01:34.700 --> 01:40.670
three times as much mana as if we were to pick up just a single crystal, right.

01:40.850 --> 01:43.820
So that's the behavior without stacking.

01:44.000 --> 01:47.270
So what behavior do we get with stacking?

01:47.270 --> 01:53.720
Well, if we do have stacking and we choose one of these options, we can choose exactly what type of

01:53.720 --> 01:55.190
behavior we see.

01:55.220 --> 02:01.930
For example, let's say we wanted to pick up one crystal and that crystal has a duration of two seconds.

02:01.940 --> 02:05.960
Well, what if during that two seconds we pick up another crystal?

02:05.990 --> 02:08.160
What behavior would we want to see?

02:08.180 --> 02:11.900
We don't want our mana increasing twice as fast.

02:11.930 --> 02:18.430
Maybe we want to still just increase mana at the same rate, but we want to refresh that duration.

02:18.440 --> 02:24.200
So say we pick up the first crystal and one second in, we pick up the second crystal.

02:24.230 --> 02:30.710
Maybe we just want the duration refreshed so we get our mana increased for another two seconds.

02:30.740 --> 02:37.160
It's things like that that are stacking parameters allow us to configure.

02:37.250 --> 02:44.510
So the first two things we should talk about are these options for the stacking type aggregate by source

02:44.510 --> 02:46.340
and aggregate by target.

02:46.430 --> 02:48.050
How do these work?

02:48.540 --> 02:54.060
So the first stacking type option, aside from none is aggregate by source.

02:54.240 --> 02:55.950
Let's see how this works.

02:55.980 --> 02:59.970
Let's say we set our stack limit count to two.

03:00.300 --> 03:08.370
Well, aggregate by source means that that stack limit count is enforced per source.

03:08.670 --> 03:16.980
So if we have one source and it applies a gameplay effect to the target, we count that as one stack

03:17.010 --> 03:21.990
of the gameplay effect and it's aggregated on the source.

03:21.990 --> 03:28.380
So the source now has one stack count for this gameplay effect applied to the target.

03:28.500 --> 03:33.450
Now the same source applies that same gameplay effect again, right?

03:33.450 --> 03:39.240
And we count this as the second stack and that's aggregated by the source.

03:39.450 --> 03:45.240
Now at this point we have two stacks of the gameplay effect and that's the limit.

03:45.270 --> 03:48.430
We set our stack limit count for this effect to two.

03:48.460 --> 03:56.050
So if the same source applies the same effect, again this would be the third stack, but that exceeds

03:56.050 --> 03:56.740
the limit.

03:56.740 --> 03:59.560
So this effect can't be applied.

03:59.650 --> 04:07.630
Now we're aggregating by source, which means each source keeps a count of the stacks of this particular

04:07.630 --> 04:09.870
effect caused by the source.

04:09.880 --> 04:15.730
So say we get another source in the game that applies this same gameplay effect.

04:15.760 --> 04:18.910
Well, we're aggregating our stacks by source.

04:18.910 --> 04:22.630
So for this source, this is only the first stack.

04:22.630 --> 04:27.370
And so we aggregate that stack by that specific source.

04:27.370 --> 04:34.900
So now the target has two stacks of this effect applied from the first source and one stack applied

04:34.900 --> 04:36.010
from the third.

04:36.580 --> 04:43.780
Now that may seem to exceed the stack limit count, but we're aggregating by source so we can have a

04:43.780 --> 04:48.070
maximum of two stacks per source applied to the target.

04:48.430 --> 04:56.860
Now let's compare this to the other option aggregate by target before we were aggregating by source.

04:56.890 --> 04:59.200
Now we're aggregating by Target.

04:59.200 --> 05:00.640
So say we have a source.

05:00.640 --> 05:02.470
It applies the gameplay effect.

05:02.500 --> 05:10.240
This counts as a single stack and this stack is aggregated by the target this time instead of the source.

05:10.480 --> 05:13.150
Now that same source applies the effect.

05:13.150 --> 05:19.750
Again, this counts as the second stack, and that's added to the stack count which is aggregated by

05:19.750 --> 05:20.740
the target.

05:20.770 --> 05:25.240
Now the same source can attempt to apply another stack.

05:25.270 --> 05:30.460
That would be the third one, but of course that exceeds the stack limit count, right?

05:30.460 --> 05:34.330
So as we'd expect, that stack cannot be applied.

05:34.330 --> 05:40.090
But along comes another source attempting to apply this effect.

05:40.090 --> 05:46.690
And if we were aggregating by source, this source hasn't applied any stacks yet, but we're aggregating

05:46.690 --> 05:50.350
by Target and the target already has two stacks applied.

05:50.350 --> 05:57.250
So for this new source attempting to apply this effect, this would be the third stack on the target

05:57.250 --> 05:59.650
and the stack limit count is two.

05:59.650 --> 06:00.850
This would exceed that.

06:00.850 --> 06:04.180
So this effect cannot be applied.

06:04.540 --> 06:09.400
So that's the difference between aggregating by source and by target.

06:09.400 --> 06:16.690
By source means there's a limit per source, but by target means there's a limit per target.

06:17.050 --> 06:23.470
So in our case, let's say we choose aggregate by source and we set a stack limit count of two.

06:23.980 --> 06:30.310
Now the duration I'd like to set to one second to make our math simple here.

06:30.310 --> 06:38.370
And the period is going to be 0.1 and I'm going to uncheck execute periodic effect on application.

06:38.380 --> 06:45.640
Now, this means that for one second we'll execute our modifiers ten times, and because we're adding

06:45.640 --> 06:53.230
one to our mana, we should see a total of ten added to our mana over the space of a second per mana

06:53.230 --> 06:53.800
crystal.

06:53.830 --> 06:54.550
Right.

06:54.580 --> 06:55.810
That makes sense.

06:55.810 --> 06:59.530
So let's duplicate one of the crystals and move it over here.

06:59.530 --> 07:07.510
Press play show debug ability system and we see that our mana is ten and if I pick up a single health

07:07.510 --> 07:12.040
crystal I should see it go up to 20 within the space of a second.

07:12.070 --> 07:13.240
Makes sense.

07:13.870 --> 07:22.060
Okay, now we set our stacking type to aggregate by source with a stack limit count of two.

07:22.090 --> 07:23.860
Well, what do we mean by source?

07:23.860 --> 07:29.440
Source is referring to actually an ability system component that's causing this.

07:29.440 --> 07:33.400
So we're causing this effect by actors.

07:33.670 --> 07:39.250
So in our case, it doesn't matter if we choose source or target, we're going to get a stack limit

07:39.280 --> 07:40.750
of two and forced.

07:40.750 --> 07:46.570
So we should only see our mana go up by 20 total.

07:46.570 --> 07:47.800
So we have ten.

07:47.980 --> 07:53.320
If we pick up all three, we go up to 30, which is 20 more than we had before.

07:53.530 --> 08:00.280
So once we start having ability system components as the source, we should start being able to test

08:00.280 --> 08:01.330
that out.

08:01.360 --> 08:07.990
Now we have a stack duration refresh policy and it says policy for how the effect duration should be

08:07.990 --> 08:13.540
refreshed while stacking and it's set to refresh on successful application.

08:13.540 --> 08:21.580
If we choose never refresh, then even though we're adding stacks, that duration of one second is what

08:21.580 --> 08:22.240
prevails.

08:22.240 --> 08:30.580
So if we set this to never refresh and we go on to pick up some mana crystals, I'm going to show debug.

08:30.580 --> 08:35.920
We have a mana of ten, I'm going to pick one up and then pick up another notice.

08:35.920 --> 08:43.630
We didn't get all the way up to 30 because that full second had elapsed before we reached 30.

08:43.930 --> 08:48.060
So it doesn't matter how many stacks we have.

08:48.060 --> 08:52.470
This effect will expire at the end of a second, no matter what.

08:53.130 --> 09:01.320
But with refresh on successful application, each time we stack another one on it resets the duration

09:01.320 --> 09:03.270
and you get an additional second.

09:03.450 --> 09:10.560
Now we have a stack period reset policy and this is similar to the duration refresh policy only.

09:10.560 --> 09:13.200
It's for the period itself.

09:13.200 --> 09:21.870
So if you're waiting for the next periodic change to an attribute, when we stack a new stack of this

09:21.870 --> 09:29.790
effect, reset on successful application means reset that period and start waiting for another full

09:29.790 --> 09:30.690
period.

09:30.870 --> 09:38.300
Otherwise, never reset means well, we won't reset that period and expiration policy is set to clear

09:38.310 --> 09:45.690
entire stack, which means as soon as this effect expires, all of the stacks are cleared.

09:45.690 --> 09:53.380
But you can choose to set this to remove single stack and refresh duration, which means that as the

09:53.380 --> 10:00.130
duration finishes, we remove a single stack and then the duration starts over again.

10:00.370 --> 10:06.760
So you can have two of these effects stacked on and when the duration expires, the stack count goes

10:06.760 --> 10:11.680
down to one and then the duration count starts over again.

10:11.830 --> 10:16.510
So as you can see, we have a lot of options when it comes to stacking.

10:16.510 --> 10:20.890
And it really just depends on how you want these things to stack in your game.

10:20.890 --> 10:26.590
And throughout the project, we'll be creating lots of effects and choosing how they can stack.

10:26.710 --> 10:33.310
For now, for the Manna Crystal, I'd like to leave it at aggregate by Target with a stack limit count

10:33.310 --> 10:34.460
of two.

10:34.480 --> 10:39.220
I'd like to refresh the duration on successful application.

10:39.250 --> 10:46.120
I'd like to reset the period on successful application and as soon as a stack expires, I'd like to

10:46.120 --> 10:51.130
clear the whole stack and the duration can be left at one.

10:51.130 --> 10:53.170
And the stack expiration policy.

10:53.170 --> 10:57.130
I'm going to set to remove single stack and refresh duration.

10:57.280 --> 11:04.570
That way, as we pick up more and more crystals, then we extend the duration and we can potentially

11:04.570 --> 11:05.670
gain more mana.

11:05.680 --> 11:12.010
So if I spread these out, we can kind of see the result of this combination of parameters.

11:12.010 --> 11:13.600
So I'm going to press play.

11:14.650 --> 11:17.430
I'm going to show debug and I have ten mana.

11:17.440 --> 11:20.860
If I pick up one, I just get ten more mana.

11:20.860 --> 11:24.340
If I pick up another one and then another one.

11:25.280 --> 11:32.660
I got 20 more, and that's because I refreshed that duration when I got a new stack.

11:32.660 --> 11:37.280
But if I start off with ten and I pick up all four of these.

11:39.840 --> 11:46.230
Notice that I only go up to 56 and that's because I'm picking them up one after the other and each time

11:46.230 --> 11:49.170
I pick it up, I reset that duration.

11:49.350 --> 11:57.330
And notice that no matter how many stacks I have, I'm always just gaining one mana every 10th of a

11:57.330 --> 11:58.230
second.

11:58.260 --> 12:04.680
Whereas if we didn't stack at all, if I set this back to none, then picking up a whole bunch of these

12:04.680 --> 12:13.350
results in a very fast increase in mana and setting it back to say, aggregate by target with a stack

12:13.350 --> 12:21.510
limit count of one, for example, then we can continue prolonging the stack duration but always get

12:21.510 --> 12:24.210
the same rate of increase of mana.

12:24.210 --> 12:30.960
So let's pick up all of these and we'll see that we increase that duration, but we're only ever getting

12:30.960 --> 12:32.010
one mana.

12:33.080 --> 12:37.160
Ten times a second because we're limiting to one stack.

12:37.550 --> 12:44.390
So picking up a crystal before the previous stack expired simply resets the duration.

12:46.910 --> 12:53.690
So I know it's kind of a lot to take in, but we have a lot of options here and we'll see how they can

12:53.690 --> 12:56.990
be combined and set up throughout the course.

12:57.320 --> 13:04.460
Now, the last of the stack expiration policy is refreshed duration, which means that when this stack

13:04.460 --> 13:10.160
expires, refresh the duration, even if it's the one and only stack.

13:10.190 --> 13:15.820
This essentially makes the effect infinite in duration because it keeps refreshing.

13:15.860 --> 13:23.270
So the comment says this can be used to manually handle stack decrements via on stack count change callback.

13:23.860 --> 13:28.030
So there's ways to respond to when the stack count changes and we'll get to that.

13:28.030 --> 13:34.030
But if I set this to refresh duration, watch what happens if I pick up just a single crystal.

13:34.660 --> 13:41.860
We see that it keeps going and it never stops because each time the stack expires, we refresh the duration.

13:41.860 --> 13:46.930
So that's a way to get a sort of infinite duration, periodic effect.

13:47.290 --> 13:51.700
I'm going to go ahead and leave this at clear entire stack.

13:51.880 --> 14:00.220
That way as we can pick up multiple ones, we'll clear the stack completely as soon as that duration

14:00.220 --> 14:01.210
runs out.

14:01.390 --> 14:07.750
And before we wrap up, why don't we just go to the Crystal Heal gameplay effect and set its stacking

14:07.780 --> 14:08.290
type?

14:08.290 --> 14:14.410
I'm going to set it to aggregate by target, set a stack limit count of one and just like Crystal Manna,

14:14.410 --> 14:20.650
we'll leave it at refresh on successful application and reset on successful application.

14:20.650 --> 14:26.360
And just like Crystal Manna, we'll leave it at clear entire stack as well.

14:26.510 --> 14:31.670
And that way we've got a little bit of throttling if we pick up too many at the same time.

14:31.670 --> 14:36.740
So great job we now know about stacking and I'll see you in the next video.
