WEBVTT

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

00:08.320 --> 00:15.460
So now we know that we can print a debug message whenever an effect is applied, but debug messages

00:15.460 --> 00:17.680
aren't enough for us, are they?

00:17.680 --> 00:22.090
Where you want to see something in the HUD or, you know, do something more interesting?

00:22.510 --> 00:28.320
So let's close out of the editor and decide how we're going to handle this.

00:28.330 --> 00:34.990
We know that debug messages are out and showing stuff in the HUD is in.

00:35.020 --> 00:39.790
Now to show stuff in the HUD, we have to think about our dependencies, right?

00:39.790 --> 00:46.060
Because our aura ability system component knows nothing about our widget controller, but our widget

00:46.060 --> 00:50.290
controller is what broadcasts data to the widgets.

00:50.290 --> 00:56.410
And if we want to show something to the screen that's in the view domain, it needs to receive something

00:56.410 --> 01:02.260
from the middleman, the widget controller, which needs to receive something from the ability system

01:02.260 --> 01:03.100
component.

01:03.190 --> 01:07.730
So that means our ability system component should have a delegate.

01:07.760 --> 01:10.700
Now what is our delegate going to broadcast?

01:10.730 --> 01:13.010
What information do we want?

01:13.040 --> 01:18.050
Well, a good way to identify things is with gameplay tags.

01:18.050 --> 01:25.040
If we have a gameplay tag that can be broadcast from whatever effect was applied.

01:25.040 --> 01:31.880
If that effect carries that tag, we can broadcast that to the widget controller, which can then broadcast

01:31.880 --> 01:33.560
it to the HUD.

01:33.560 --> 01:37.220
So we want to find out what gameplay tags the effect has.

01:37.250 --> 01:42.650
That's what we'd like to do and then get those tags and broadcast those in a delegate.

01:42.650 --> 01:45.200
So we have a few things to do here.

01:45.620 --> 01:50.180
So how do we get any gameplay tags that an effect might have?

01:50.210 --> 01:59.330
Well, we have our effect spec and if we just type effect spec dot, then we have lots of things at

01:59.330 --> 02:00.620
our disposal here.

02:00.740 --> 02:06.020
Well, if we scroll through these, we see that we have a bunch of getters related to tags.

02:06.020 --> 02:11.840
We have all asset tags, all granted tags, and remember we could add those on the gameplay effect.

02:11.840 --> 02:13.550
We can add those granted tags.

02:13.550 --> 02:20.300
We've seen what happens when we do that and we saw that the asset tags are not given to the actor that

02:20.300 --> 02:21.770
the effect is applied to.

02:21.770 --> 02:25.250
They're just kind of carried along with the effect.

02:25.340 --> 02:32.690
And because granted, tags are only granted with duration based effects, the asset tags is something

02:32.690 --> 02:41.420
that we could use to pass along some kind of tag that we'd want to know about once an effect is applied.

02:41.510 --> 02:46.100
So we can call, get all asset tags to get those tags.

02:46.100 --> 02:47.870
If there are any tags.

02:47.960 --> 02:52.760
Now get all asset tags, takes an gameplay tag container.

02:52.760 --> 03:00.920
Remember, we don't store tags in an array, we store them in an gameplay tag container.

03:01.130 --> 03:04.760
This is more optimized than a t array for gameplay tags.

03:04.760 --> 03:06.710
It's just better all around.

03:06.710 --> 03:11.090
And that's what we're going to be using whenever we need a container of tags.

03:11.120 --> 03:16.670
Now this takes one in by Non-const reference and it's going to fill it in with any tags that this effect

03:16.670 --> 03:17.210
has.

03:17.210 --> 03:19.760
So we need a gameplay tag container.

03:19.760 --> 03:26.420
So we're going to say F gameplay tag container and we're going to call this tag container.

03:27.200 --> 03:35.360
And by the way, if you're getting any sort of errors regarding these types not being defined, remember

03:35.360 --> 03:42.410
that all the gameplay tag stuff is in a specific module that we added to our build file.

03:42.650 --> 03:44.270
We have gameplay tags.

03:44.270 --> 03:48.380
We added that to our private dependency module names.

03:48.380 --> 03:54.410
So remember that you have to have that module if you're going to want to use these types, right?

03:54.560 --> 04:02.390
So get all asset tags, takes a tag container, we're going to pass ours in and after this tag container

04:02.390 --> 04:03.920
will have all those tags.

04:03.950 --> 04:06.350
Now there may be one or more.

04:06.350 --> 04:13.640
And what I'd like to do is make a broadcast to our widget controller for every single tag that's in

04:13.640 --> 04:14.780
this container.

04:14.960 --> 04:23.600
That way, as we add any tags to our gameplay effects, we can get those tags and broadcast them and

04:23.600 --> 04:29.960
use those to display some kind of message to the screen and we'll get to how to do that soon enough.

04:29.960 --> 04:32.060
We'll do it in a nice, efficient way.

04:32.060 --> 04:40.310
But for now, let's just loop through those tags we're going to say for and if I say auto tag in tag

04:40.310 --> 04:45.680
container, what does auto have the type of Well, it's a gameplay tag.

04:45.680 --> 04:51.170
So we're going to say F gameplay tag and we'll make it a reference so we don't copy the tag.

04:51.170 --> 04:54.350
And if we make it a reference, it's got to be a const reference.

04:54.380 --> 05:00.140
So now here we can do anything we like with this tag.

05:00.350 --> 05:06.320
I'm just going to add a to do here and it's going to be to broadcast the tag.

05:06.480 --> 05:09.390
To the widget controller.

05:10.320 --> 05:12.460
So that's the next thing we want to do.

05:12.480 --> 05:20.100
So when any effect is applied, we can get all asset tags associated with that effect that we've added

05:20.100 --> 05:24.570
in the gameplay effect blueprint and do anything we like with those.

05:24.600 --> 05:30.540
Now I know we want to broadcast to the widget controller and that debug messages are lame and all that,

05:30.540 --> 05:36.150
but I'd like to use a debug message to show you that we can print the name of a tag.

05:36.180 --> 05:43.380
Tags have an internal name that represents the tag and we can say print messages to the screen.

05:43.380 --> 05:45.510
So I'm going to say Gee engine.

05:47.010 --> 05:50.400
Add on screen debug message for the key.

05:50.400 --> 05:52.530
I'm going to use negative one.

05:52.830 --> 05:55.960
That way newer messages don't replace older ones.

05:55.980 --> 05:57.840
Time to display will do.

05:57.870 --> 06:00.750
Eight seconds eight dot f for color.

06:00.750 --> 06:04.860
We'll do f color blue for lack of a better color.

06:04.860 --> 06:06.780
And for the string.

06:06.780 --> 06:10.680
I'd like to format a string and I'll just make one here.

06:10.680 --> 06:18.330
I'm going to make a const f string msg for message equals f string print f.

06:19.590 --> 06:31.080
And I'm going to format this to say G tag percent s and what is going to be the string that we replace

06:31.080 --> 06:32.210
percent s with?

06:32.220 --> 06:34.320
Well, we have the tag.

06:34.320 --> 06:37.440
It's called tag and tag has.

06:37.470 --> 06:39.420
Look at this git tag name.

06:39.420 --> 06:41.190
It also has two string.

06:41.190 --> 06:42.510
So git tag name.

06:42.510 --> 06:49.440
If we just check that it returns an f name, but we also have two string.

06:50.800 --> 06:54.340
And of course, this returns an F string.

06:54.340 --> 06:56.500
So we have a couple of options here.

06:56.860 --> 07:05.680
So let's just say we use two string and we have to use that star there to convert a string to a wide

07:05.680 --> 07:09.550
character array or an array of cars to be exact.

07:09.550 --> 07:16.750
But this message should now have the gameplay tag converted to a string and we're going to pass that

07:16.750 --> 07:20.190
in as the debug message.

07:20.200 --> 07:23.140
So why don't we go ahead and test this out.

07:23.140 --> 07:31.720
I'm going to go ahead and hit debug and we can add some tags to our gameplay effects and just see what

07:31.720 --> 07:33.310
we get printed to the screen.

07:33.970 --> 07:37.270
Okay, so I'm going to add some tags to our effects.

07:37.270 --> 07:46.030
I'm going to go into the actor folder and into Crystal and into Crystal Heal and to the tag section

07:46.030 --> 07:46.600
here.

07:46.630 --> 07:53.620
Now, we know that granted tags will actually grant the tag right, but the gameplay effect asset tag,

07:53.620 --> 07:56.200
that's what we're retrieving in C plus plus.

07:56.200 --> 08:01.960
That's because we're using get all asset tags and not get all granted tags.

08:01.960 --> 08:04.450
So these are all different containers.

08:04.600 --> 08:10.450
So since we're getting the asset tags, we're going to want to add our tag to the asset tags.

08:10.450 --> 08:18.280
So for Crystal Heal, I'm going to add the health tag, but this is a duration based effect.

08:18.280 --> 08:21.400
I want to test out how this works with instant effects.

08:21.400 --> 08:23.500
In other words, potions.

08:23.800 --> 08:25.720
These apply instant effects.

08:25.720 --> 08:31.030
So I'm going to go to Potion Heal and go to my gameplay effect assets tag.

08:31.030 --> 08:37.190
Very important assets not granted tags and we're going to add the health tag to that one.

08:37.190 --> 08:38.030
And why not?

08:38.030 --> 08:43.340
Let's go to Potion mana and add the mana tag to that one.

08:43.340 --> 08:48.680
So we have tags in the health crystal, the mana potion and the health potion.

08:48.680 --> 08:52.470
Let's hit play and get a crystal and look at that.

08:52.490 --> 08:55.640
Gee tag attributes vital health.

08:55.640 --> 08:57.800
Let's get a mana potion attributes.

08:57.800 --> 09:02.300
Vital Mana is now printed to the screen and let's get a health potion.

09:02.300 --> 09:05.600
There's attributes vital dot health.

09:06.440 --> 09:13.850
So now we're getting these messages printed to the screen showing us that we've actually retrieved those

09:13.850 --> 09:14.770
tags.

09:14.780 --> 09:18.370
And the cool thing is that we can have multiple tags.

09:18.380 --> 09:22.970
If I go to my potion mana, let's just say I want to add another tag to it.

09:22.970 --> 09:25.160
Let's add Max Mana as well.

09:25.160 --> 09:32.090
And because this is a for loop looping through all the tags in the asset tags, let's get all asset

09:32.120 --> 09:32.840
tags.

09:32.840 --> 09:36.710
We'll get multiple messages if there are multiple tags.

09:36.740 --> 09:40.370
Now GE Potion Mana has multiple tags.

09:40.370 --> 09:44.030
Let's just quickly test that out by picking up a single potion.

09:44.030 --> 09:50.660
And there we have two messages because we retrieved both tags in that gameplay tag container.

09:50.660 --> 09:53.270
So this works with multiple tags.

09:53.270 --> 10:00.170
Now this is great because now a given effect can have multiple tags and if we loop through all of those

10:00.170 --> 10:08.160
and do something for each one, we can say print different messages to the screen, show different widgets,

10:08.190 --> 10:13.800
kick off any logic we like, we really have the power to do whatever we want here.

10:14.040 --> 10:21.810
So I'd like to broadcast the gameplay tag over to the widget controller and that'll be our next step.

10:21.810 --> 10:22.830
So we'll do that next.

10:22.830 --> 10:30.360
For now, we'll go ahead and close out of the editor, save all and make sure that if we're using source

10:30.360 --> 10:32.070
control, we make a commit.

10:32.070 --> 10:34.590
And I'll see you in the next video.
