WEBVTT

00:06.830 --> 00:07.820
Welcome back.

00:08.230 --> 00:11.200
Now we've added some native gameplay tags.

00:11.200 --> 00:15.330
We have montage attack, left hand, right hand and weapon.

00:15.340 --> 00:25.930
So my goal is to be able to get the montage as well as its associated montage tag so we know which socket

00:25.960 --> 00:28.150
to look for for that montage.

00:28.150 --> 00:35.080
And then we can have attack montages for left hand or right hand weapon, whatever, and we'll know

00:35.080 --> 00:41.290
which one corresponds to which gameplay tag which corresponds to a socket.

00:41.320 --> 00:47.020
For that reason I want a struct that links up a montage and a gameplay tag.

00:47.020 --> 00:49.480
Something called a tagged montage.

00:49.510 --> 00:55.960
We can use a struct for that and I'd like to define it in my combat interface because then I could just

00:55.960 --> 01:03.010
call a function on the combat interface for retrieving any tagged montages.

01:03.010 --> 01:04.450
There may be multiple.

01:04.480 --> 01:07.630
Perhaps we'd like an algorithm to pick one at random.

01:07.630 --> 01:14.920
So we're going to make a struct that contains a montage and a gameplay tag and we're going to define

01:14.920 --> 01:22.090
it in the combat interface, and then we'll add a function to retrieve them in the combat interface

01:22.090 --> 01:28.030
so that we can get the montage here and we can know what gameplay tag to listen to and we can send that

01:28.030 --> 01:29.860
gameplay tag in our montage.

01:29.860 --> 01:31.720
So let's get to it.

01:31.840 --> 01:39.460
I'm going to go into my public folder, into interaction, into combat interface, and we're going to

01:39.460 --> 01:41.500
define a new struct here.

01:41.620 --> 01:50.530
This will be all the way up just below the includes we're going to say struct f tagged montage.

01:52.750 --> 01:54.790
This will be a use struct.

01:55.420 --> 02:02.290
We're going to make it a blueprint type and give it a generated body and it's going to get an anim montage.

02:02.320 --> 02:06.160
We're going to forward declare you anim montage.

02:06.190 --> 02:11.920
It's going to be a pointer called montage initialized to a null pointer.

02:11.950 --> 02:17.650
We're going to give it a new property with edit defaults only and blueprint read only.

02:18.430 --> 02:23.670
Now combat interface shows that you anim montage doesn't have to be forward declared.

02:23.680 --> 02:28.960
That's redundant, so I'm going to go ahead and remove that and we'll also have an gameplay tag.

02:29.320 --> 02:38.410
So f gameplay tag, we're going to call this montage tag and we'll also make it edit Defaults only.

02:38.890 --> 02:40.420
Blueprint Read only.

02:40.720 --> 02:44.410
Now that means we need to include gameplay tag container.

02:44.410 --> 02:47.140
So let's include gameplay tag container.

02:48.010 --> 02:51.430
And we now have a tag montage struct.

02:51.730 --> 02:59.900
So now that we have a tagged montage struct, we need an array of these on our character for all attacks.

02:59.900 --> 03:02.560
We're going to call these attack montages.

03:02.570 --> 03:07.850
So we're going to have an array of this, which means we're going to include the combat interface in

03:07.850 --> 03:11.270
our base character class or a character base.

03:11.390 --> 03:13.820
Let's go up to the top to our includes.

03:13.820 --> 03:15.820
We already have combat interface.

03:15.830 --> 03:17.990
Let's go ahead and add a T array.

03:18.290 --> 03:25.700
I'm going to add it in the public section here and it's going to be a T array of type F tagged montage.

03:28.010 --> 03:30.320
Called attack montages.

03:31.860 --> 03:36.240
It's going to get a new property with edit anywhere.

03:37.030 --> 03:38.490
Categorycombat.

03:41.170 --> 03:48.430
And now that we have attack montages, this is something that we'll go ahead and set on a character

03:48.430 --> 03:50.120
by character basis.

03:50.140 --> 03:57.460
So I like the combat interface to have a function that can easily retrieve these attack montages and

03:57.460 --> 04:01.780
perhaps even retrieve a selection from among them at random.

04:01.900 --> 04:06.890
For now, let's just have a function that retrieves the attack montages.

04:06.910 --> 04:17.440
So here in combat interface, we're going to make a function that returns a t array of F tagged montages

04:18.310 --> 04:21.730
called get attack montages.

04:22.690 --> 04:25.990
I'd like this to be blueprint callable and a blueprint native event.

04:25.990 --> 04:34.390
So we're going to copy the U function from get Avatar and we'll implement this in a character base.

04:34.390 --> 04:45.040
By overriding it here, we're going to override virtual t array f tagged montage, get attack montages,

04:45.040 --> 04:52.720
implementation, and here in the definition, we're just going to return attack montages.

04:53.260 --> 05:00.340
So now that our interface has this function, we can retrieve the attack montages from Blueprint and

05:00.340 --> 05:04.750
we can link up any montages with the appropriate tag.

05:04.750 --> 05:07.750
Let's go ahead and compile and launch the editor.

05:09.310 --> 05:09.700
Okay.

05:09.700 --> 05:12.160
So back in the editor, we're going to open up.

05:12.340 --> 05:16.000
Let's open up our Goblin Spear, shall we?

05:16.150 --> 05:18.550
We're going to go to Content Blueprints.

05:18.580 --> 05:19.780
Character.

05:19.810 --> 05:21.070
Goblin, Spear.

05:21.100 --> 05:26.210
Open up, Goblin Spear and search for attack montages.

05:26.230 --> 05:27.330
Here they are.

05:27.340 --> 05:30.960
And our Goblin Spear only needs one element here.

05:30.970 --> 05:38.440
If we expand the dropdown for it, we see that we can choose am attack Goblin spear and for the montage

05:38.440 --> 05:42.280
tag we want montage attack weapon.

05:42.310 --> 05:45.610
That way we know which socket to look for.

05:45.970 --> 05:53.650
So back in the melee attack, instead of just hard coding in that montage, we can get that montage

05:53.680 --> 05:59.500
along with its tag using our static function on the combat interface.

05:59.500 --> 06:03.880
Since this is a blueprint native event get attack montages.

06:04.030 --> 06:10.610
Now this requires the target, which is basically this avatar actor from actor info.

06:10.640 --> 06:17.270
We can go ahead and use that and attack montages retrieves an array, right?

06:17.270 --> 06:21.050
So really we just need to pick one of them.

06:21.050 --> 06:29.780
So if there are more than one, what we should do is pick one at random and it'd be nice to have a built

06:29.780 --> 06:37.940
in function or maybe a blueprint function library function that can just do this for us, get one at

06:37.940 --> 06:38.690
random.

06:38.690 --> 06:40.430
It would do something like this.

06:40.460 --> 06:43.760
It would take the array and get the length of it.

06:43.910 --> 06:47.420
That would be the number of elements in the array.

06:47.480 --> 06:50.000
It would subtract one from it.

06:50.530 --> 07:00.610
Because arrays are indexed starting at zero, and then it would get a random value between zero and

07:00.610 --> 07:03.190
this number length minus one.

07:03.190 --> 07:11.890
So we would say random int in range, random integer in range between zero and this value.

07:12.280 --> 07:16.540
And then it would retrieve an element from this array.

07:16.570 --> 07:21.530
So we could use get and we can get a ref.

07:22.690 --> 07:26.650
So this would be a random selection from that array.

07:26.650 --> 07:31.960
And this random selection is a struct that we can break.

07:32.900 --> 07:34.690
We can break the tagged montage.

07:34.700 --> 07:36.350
Let's make some more room here.

07:39.140 --> 07:44.810
And for the montage we can hook that into montage to play and we can hook this up.

07:44.810 --> 07:51.020
And the montage tag is going to be the tag now that we listen for instead of this one.

07:51.020 --> 07:53.030
So I'm going to take the montage tag.

07:53.030 --> 07:55.370
I'm going to add a couple reroute nodes here.

07:57.030 --> 08:00.090
And hook that into wait gameplay event.

08:00.120 --> 08:06.780
The only thing now we have to do is go into that goblin spear attack.

08:06.960 --> 08:12.560
Let's browse to that and open it up and change the tag that it's sending instead of this one.

08:12.570 --> 08:17.490
It's now going to be a montage attack weapon.

08:17.970 --> 08:22.320
So now that that's happening, our melee attack will be listening for that.

08:22.350 --> 08:27.090
Now we're not taking care of switching which combat socket we're looking for.

08:27.090 --> 08:29.970
We're always looking for the combat socket on the weapon.

08:29.970 --> 08:36.780
But at least now we're getting the montage from the actor using our combat interface function.

08:36.780 --> 08:44.460
And after a little bit of blueprint randomization, if that array of montages has more than one, well,

08:44.460 --> 08:45.840
we'll get one at random.

08:47.150 --> 08:50.840
So, so far, we shouldn't see anything different.

08:50.870 --> 08:53.480
We should be able to get attacked.

08:53.480 --> 08:56.230
And we're being attacked by that melee attacker.

08:56.230 --> 08:57.260
And that's good.

08:57.380 --> 09:03.920
But we are one step closer to having something that will work with other types of enemies, because

09:03.920 --> 09:12.830
now that it's up to the enemy character class itself to have montages and link those up with tags,

09:12.830 --> 09:19.940
then those montages can broadcast that given tag and then we can use that tag to identify which socket

09:19.970 --> 09:22.730
to look for and get combat socket location.

09:22.730 --> 09:28.970
So our next step is to change get combat socket location so it takes a gameplay tag and returns the

09:28.970 --> 09:33.340
location of the correct socket based on that tag and we'll do that next.

09:33.350 --> 09:34.570
So great job.

09:34.580 --> 09:35.780
I'll see you soon.
