Welcome back.
So now we know that we can print a debug message whenever an effect is applied, but debug messages
aren't enough for us, are they?
Where you want to see something in the HUD or, you know, do something more interesting?
So let's close out of the editor and decide how we're going to handle this.
We know that debug messages are out and showing stuff in the HUD is in.
Now to show stuff in the HUD, we have to think about our dependencies, right?
Because our aura ability system component knows nothing about our widget controller, but our widget
controller is what broadcasts data to the widgets.
And if we want to show something to the screen that's in the view domain, it needs to receive something
from the middleman, the widget controller, which needs to receive something from the ability system
component.
So that means our ability system component should have a delegate.
Now what is our delegate going to broadcast?
What information do we want?
Well, a good way to identify things is with gameplay tags.
If we have a gameplay tag that can be broadcast from whatever effect was applied.
If that effect carries that tag, we can broadcast that to the widget controller, which can then broadcast
it to the HUD.
So we want to find out what gameplay tags the effect has.
That's what we'd like to do and then get those tags and broadcast those in a delegate.
So we have a few things to do here.
So how do we get any gameplay tags that an effect might have?
Well, we have our effect spec and if we just type effect spec dot, then we have lots of things at
our disposal here.
Well, if we scroll through these, we see that we have a bunch of getters related to tags.
We have all asset tags, all granted tags, and remember we could add those on the gameplay effect.
We can add those granted tags.
We've seen what happens when we do that and we saw that the asset tags are not given to the actor that
the effect is applied to.
They're just kind of carried along with the effect.
And because granted, tags are only granted with duration based effects, the asset tags is something
that we could use to pass along some kind of tag that we'd want to know about once an effect is applied.
So we can call, get all asset tags to get those tags.
If there are any tags.
Now get all asset tags, takes an gameplay tag container.
Remember, we don't store tags in an array, we store them in an gameplay tag container.
This is more optimized than a t array for gameplay tags.
It's just better all around.
And that's what we're going to be using whenever we need a container of tags.
Now this takes one in by Non-const reference and it's going to fill it in with any tags that this effect
has.
So we need a gameplay tag container.
So we're going to say F gameplay tag container and we're going to call this tag container.
And by the way, if you're getting any sort of errors regarding these types not being defined, remember
that all the gameplay tag stuff is in a specific module that we added to our build file.
We have gameplay tags.
We added that to our private dependency module names.
So remember that you have to have that module if you're going to want to use these types, right?
So get all asset tags, takes a tag container, we're going to pass ours in and after this tag container
will have all those tags.
Now there may be one or more.
And what I'd like to do is make a broadcast to our widget controller for every single tag that's in
this container.
That way, as we add any tags to our gameplay effects, we can get those tags and broadcast them and
use those to display some kind of message to the screen and we'll get to how to do that soon enough.
We'll do it in a nice, efficient way.
But for now, let's just loop through those tags we're going to say for and if I say auto tag in tag
container, what does auto have the type of Well, it's a gameplay tag.
So we're going to say F gameplay tag and we'll make it a reference so we don't copy the tag.
And if we make it a reference, it's got to be a const reference.
So now here we can do anything we like with this tag.
I'm just going to add a to do here and it's going to be to broadcast the tag.
To the widget controller.
So that's the next thing we want to do.
So when any effect is applied, we can get all asset tags associated with that effect that we've added
in the gameplay effect blueprint and do anything we like with those.
Now I know we want to broadcast to the widget controller and that debug messages are lame and all that,
but I'd like to use a debug message to show you that we can print the name of a tag.
Tags have an internal name that represents the tag and we can say print messages to the screen.
So I'm going to say Gee engine.
Add on screen debug message for the key.
I'm going to use negative one.
That way newer messages don't replace older ones.
Time to display will do.
Eight seconds eight dot f for color.
We'll do f color blue for lack of a better color.
And for the string.
I'd like to format a string and I'll just make one here.
I'm going to make a const f string msg for message equals f string print f.
And I'm going to format this to say G tag percent s and what is going to be the string that we replace
percent s with?
Well, we have the tag.
It's called tag and tag has.
Look at this git tag name.
It also has two string.
So git tag name.
If we just check that it returns an f name, but we also have two string.
And of course, this returns an F string.
So we have a couple of options here.
So let's just say we use two string and we have to use that star there to convert a string to a wide
character array or an array of cars to be exact.
But this message should now have the gameplay tag converted to a string and we're going to pass that
in as the debug message.
So why don't we go ahead and test this out.
I'm going to go ahead and hit debug and we can add some tags to our gameplay effects and just see what
we get printed to the screen.
Okay, so I'm going to add some tags to our effects.
I'm going to go into the actor folder and into Crystal and into Crystal Heal and to the tag section
here.
Now, we know that granted tags will actually grant the tag right, but the gameplay effect asset tag,
that's what we're retrieving in C plus plus.
That's because we're using get all asset tags and not get all granted tags.
So these are all different containers.
So since we're getting the asset tags, we're going to want to add our tag to the asset tags.
So for Crystal Heal, I'm going to add the health tag, but this is a duration based effect.
I want to test out how this works with instant effects.
In other words, potions.
These apply instant effects.
So I'm going to go to Potion Heal and go to my gameplay effect assets tag.
Very important assets not granted tags and we're going to add the health tag to that one.
And why not?
Let's go to Potion mana and add the mana tag to that one.
So we have tags in the health crystal, the mana potion and the health potion.
Let's hit play and get a crystal and look at that.
Gee tag attributes vital health.
Let's get a mana potion attributes.
Vital Mana is now printed to the screen and let's get a health potion.
There's attributes vital dot health.
So now we're getting these messages printed to the screen showing us that we've actually retrieved those
tags.
And the cool thing is that we can have multiple tags.
If I go to my potion mana, let's just say I want to add another tag to it.
Let's add Max Mana as well.
And because this is a for loop looping through all the tags in the asset tags, let's get all asset
tags.
We'll get multiple messages if there are multiple tags.
Now GE Potion Mana has multiple tags.
Let's just quickly test that out by picking up a single potion.
And there we have two messages because we retrieved both tags in that gameplay tag container.
So this works with multiple tags.
Now this is great because now a given effect can have multiple tags and if we loop through all of those
and do something for each one, we can say print different messages to the screen, show different widgets,
kick off any logic we like, we really have the power to do whatever we want here.
So I'd like to broadcast the gameplay tag over to the widget controller and that'll be our next step.
So we'll do that next.
For now, we'll go ahead and close out of the editor, save all and make sure that if we're using source
control, we make a commit.
And I'll see you in the next video.