Welcome back.
So now that we know about gameplay tags and how to add them to our project and we have a few here,
let's see how we can add gameplay tags to any given ability system component.
We can do this in a number of ways.
One of those ways is gameplay effects.
Now let's see what happens if we take one of our crystals.
Here's a health crystal, I'm going to duplicate one of them and bring it over next to my player start.
Okay, so we know that we can pick one up and for one second our health starts to increase.
And that's thanks to our gameplay effect in that crystal, which is in Blueprints.
Actor Crystal and the Health crystal uses crystal Heal.
Now this is a periodic gameplay effect.
Now gameplay effects can have tags and under the tag section we have a lot of different types of tags
and they all do different things.
This makes the gameplay effect extremely versatile, but also maybe a little bit confusing as you don't
really know which tags to use and when.
So we'll quickly go over all the different types of tags and then we'll add a tag to Crystal Heal and
see how we can add that to Aura's ability system component.
So let's go in order from top to bottom.
First we have gameplay effect asset tag.
And if we expand that, we have combined tags added and removed.
Now, if we hover over these, we get useful comments.
This one says the gameplay effects tags, tags, the gameplay effect has and does not give to the actor.
Okay, so that's good to know if we put some tags here when the gameplay effect gets applied, it's
not going to give those tags to the actors ability system component, it just has the tags.
So why is that useful?
Well, we're going to see very shortly why that is useful.
Now.
Why are there three types combined, added or removed?
Well, hovering over combined says tags that I inherited and tags that I added minus tags that I removed.
This is what we'll see in all tag containers.
And that's what these are, is gameplay tag containers that exist in all the engine classes.
Now, it doesn't make a whole lot of sense here in a gameplay effect because we don't typically subclass
gameplay effects, so we don't create inheritance hierarchies of gameplay effects, but we do sometimes
make inheritance hierarchies of other gas classes.
So we'll see.
This trend now added is the comment, says tags that I have in addition to my parents tags.
So a class will inherit its parents tags, but it can add its own.
So in other words, if we want to add a tag to this container, we would add it here now removed, says
tags that should be removed if my parent had them.
So again, we won't be creating a child from any gameplay effect.
But if we did, if this were a child, for example, it would inherit its parents gameplay tags.
And if we wanted this child to not have one of those inherited tags, we would add that to the removed
section here.
Now we know that adding a tag to gameplay effect asset tag doesn't give that tag to the actor that's
being hit by this effect.
Right?
So let's continue down to the next one which is granted tags, and if we expand it, we see the same
thing combined, added and removed here.
Now hovering over granted, we see these tags are applied to the actor I am applied to.
Okay.
So that means if we put a tag in here, it will be applied, it will be given to whatever we hit with
this effect.
So let's see how that works.
Let's add one and we add one with the added right.
So we can click on the dropdown and let's just add attributes, vital health.
We'll add that and you'll see that as we click on the checkbox for health, we can add the tag and it
appears here now to remove it, we just hit the red X, So adding and removing is pretty simple now
because tags are hierarchical, we could add part of that tag.
For example, attributes vital if we wanted to do that.
And that just is a showcase of how versatile tags can be.
But we're going to add attributes, vital health.
Let's add that now we can add multiple, right?
We can expand the dropdown and check multiple checkboxes.
And as we add them, we'll see them here.
And of course we can hit the X here to remove them or we can expand the dropdown and just uncheck those
checkboxes and that does the same thing.
It also removes them.
So we've added attributes vital health to the granted tags.
Now as soon as I compile, watch the combined tags here, I'm going to hit compile.
And now we see that all of the tags we added to the added section are now in combined tags.
And if the parent class of this had some tags and it's granted tags, we'd see those here too.
But it doesn't.
So we don't.
But because we added one to the added section, it's now in combined tags and we see that as soon as
we compile, if we remove it from added and then compile again, it goes away.
It's no longer in combined tags.
So anyway, let's put that health tag back into the added section we can compile and let's see what
happens.
I'm going to press play and show debug ability system and keep your eye right up here on owned tags
and let's pick up the crystal and there it is.
Attributes vital health.
It was only there for a second because it gets removed as soon as this gameplay effect expires.
To make this a little easier to see, let's change the duration magnitude.
Here's the duration magnitude.
It's set to a second.
Let's set it to four seconds.
That's a little easier.
And then we can press play, show, debug and pick up.
The crystal, keeping our eye on owned tags.
And there it is attributes vital health and notice in parentheses it has a one there.
We can keep count of these now that's because tags can be stacked much like gameplay effects can be
stacked.
But there's a key difference here.
Our crystal health has its stacking type set to aggregate by target with a stack limit count of one.
Okay, so we can only stack one, but let's say we increase that.
Let's say we want to be able to stack four at a time.
You might expect that we would stack those gameplay tags that are granted.
In other words, this attributes vital health tag.
You would expect us to add that tag four times and we'd get four stacks.
But that's not how it works.
You see, if we're applying crystal health and it's stackable, in this case it is.
We're only going to get that tag once because it counts as just a single application of the gameplay
effect.
Only it has stacks, right?
And based on the stacking policy and all of these parameters, the meaning of that depends on all these
settings.
So if I duplicate a few of these, let's have say three of them here and press play and show debug and
pick them all up, we still just have a single health tag until they're all gone and then it's gone.
So with a stackable effect, we just get that tag once because it's the effect that stacks, it's the
effect stack count that goes up when we get multiples.
However, let's say that this is not a stackable effect.
If we take our stacking type and set it to none now, it doesn't stack anymore.
We just apply the effect multiple times and each time counts as a new gameplay effect.
Let's see what happens now.
We'll show debug and pick up all three of these, keeping our eye on the owned tags.
And now we see that we have three of the attributes vital health tags.
And then it went down to two and then down to one when those effects expired.
So that's a key difference between stacked effects and stacked tags.
If our effect doesn't stack, then we'll get multiple effects applied, each of which adds that tag
to the ability system component.
And when the same tag gets added twice, then the tag count goes up.
But if this is a stackable effect, if we set its stacking type to anything other than none, then applying
this effect multiple times means that the effect stack goes up and we're only going to apply that tag
once.
Makes sense.
Okay, so now we know we can add a tag when a duration based effect is added.
So that's nice.
And there are ways to respond to when a tag gets added to an ability system component so that can be
useful.
What happens though, if we add a tag to say, an instant gameplay effect?
We know that these potions have instant gameplay effects.
Let's go back into our potion folder into G potion mana and let's go to our granted tags and let's add
a tag.
Let's add the mana tag to it.
Let's see what happens if we pick up one of the potions.
I'm going to show debug keeping my eye on the own tags.
I'm going to pick up a potion.
Wait a minute, there's nothing there so we don't see anything.
So that tells us something, right?
Granted, tags really only mean something when our effect has a duration, because when the effect is
gone, the tag is removed.
And if it's an instant effect, well, there's no period during which we have the tag.
We don't get it.
So it doesn't matter in an instant gameplay effect.
So I'm just going to clear that doesn't matter.
But what happens if we want to receive a tag anyway?
What happens if we pick up a potion and we want to know based on some gameplay tag that we just picked
up a potion and we want to show something to the screen, we want to display a message that says Picked
up Health Potion.
Well, that's where our gameplay effect asset tag container comes in because we have ways to know when
any type of effect has been applied.
The ability system component has lots of ways to know.
We're going to learn about those ways to know.
In fact, we're going to peek at a couple of them in the code base now and then in the videos to come.
We'll make use of them.
So I'm going to undo what we did by removing that tag from crystal heal.
We don't want to use granted tags.
So removing that tag.
And closing those gameplay effects.
I don't need project settings.
I'm going to close that as well.
Make sure everything is saved here.
I'm going to close out of the editor and I'd like to take a look at the Ability system component class.
Now here in Writer, I can hit shift, shift and search for ability system component.
Here's the header file and it can actually be really informative to just go through this class, right?
It's a big class.
There are almost 2000 lines of code, but it's an informative class.
It's filled with comments everywhere.
This is basically your documentation for gas is the code itself.
It's filled with comments.
This is basically Epic's documentation for gas.
And if you're not pressed for time, I recommend just sitting down and reading through ability system
components.
H Read all the comments, read everything because it's all going to make sense.
And you'll also see the things that the ability system component has.
So while you don't have to, it might sound like torture to you to read 2000 lines of code, but I do
recommend it.
I recommend just sitting through, even just skimming through.
You don't have to look at all the code.
Just look at the comments and the names of the functions and variables.
That's it.
Just skim through the comment, take note of what the function is called and move on.
Skim through the comment and the functions without comments.
Just take note that they're there.
Right?
This is going to let you know just what the ability system component class has in it.
So that way in the future, if you want to do something, you can just think, well, I did see something
back when I skimmed through it.
Related to this, maybe that'll work, right?
So anyways, that's just a piece of advice that I have for you.
Now, after you've done that, I want you to search for your on game play effect applied.
And look at this.
Here's a declare multicast delegate three params called F on gameplay effect applied delegate.
If we keep searching for this same thing, we'll see that.
Here's a function on gameplay effect applied to target apply to self.
And if we scroll just a bit past that, here we see some actual delegate variables.
Now the comments are pretty useful here on gameplay effect.
Applied Delegate to Self has a comment that says called on server.
Whenever a G is applied to self, this includes instant and duration based games or gameplay effects
now called on server.
That's pretty significant and based on our replication policy, we should know whether or not gameplay
effects will be replicated.
In fact, let's pull up that table real quick.
Here we go.
It's good to go back and look at these things because this actually has more meaning for us now, doesn't
it?
Now that we're starting to get into gameplay effects now, we're not using full for anything.
We're using mixed and minimal or uses mixed and the enemies use minimal.
Now we see that in mixed gameplay effects are replicated to the owning client only gameplay cues and
gameplay tags replicated to all clients and for minimal gameplay effects are not replicated.
Gameplay cues and gameplay tags are okay, so that's good to know isn't it?
And here we have a delegate that will be broadcast whenever any gameplay effect is applied to self.
That means to this ability system component.
We also have on gameplay effect applied delegate to target.
So when a gameplay effect is applied to someone else, this includes instant and duration based games,
and when it says duration based, it's counting both duration and infinite.
Now next we have on active gameplay effect added delegate to self.
Now this is gameplay effect added right not just applied but added.
Whenever you see added, that means it's for duration based gameplay effects.
And here it says instant gameplay effects did not trigger this.
So this is only for duration or infinite.
Here we have on periodic gameplay effect, execute delegate on self and it says called on server.
Whenever a periodic gameplay effect executes on self, so say we have a periodic one right?
Every second something is modified.
Well, here's a delegate that will be broadcast on the periodic execution.
And then here we have one for when a periodic GE is executing on a target.
So in other words, we have a lot of different things that we can take advantage of here.
Right.
And.
I like on gameplay effect applied because it includes instant and duration based gameplay effects.
And of course we can do things when effects are removed as well.
Let's search for on gameplay effect removed and we have a lot of things.
Let's keep searching.
Let's search for on any gameplay effect removed.
And here's something that's called when any gameplay effects are removed.
Now this is a function, but it returns the delegate.
It returns a reference to it.
So we'd have to call this function if we want to bind anything to this delegate and these delegates
broadcast info right, we're going to be able to know what effect is being applied, added, removed,
whatever we want.
The ability system component has you covered.
Okay.
So in the videos to come, we're going to bind some stuff to these delegates so we can know and then
we can get those delegates and perhaps see what tags they have.
And that will allow us to retrieve tags for a gameplay effect.
That's perhaps instant, right?
And then we don't have to rely on duration based effects if we want to do something in response to a
gameplay effect applied to us, like showing something in the HUD.
So excellent job.
I hope you at least skim through the ability system component.
If you're super curious, you can go to the CPP file and see the implementation details of it as well.
So do that if you're so inclined, and I'll see you in the next video.