Welcome back.
Now, here in GE damage we're hard coding a 25 for our scalable float magnitude.
Now sometimes we'd like to be able to set the magnitude when we're creating the effect spec or perhaps
applying the effect we'd like more control.
For instance, from our gameplay ability, our ability may have a base damage value that we'd like to
set on the gameplay effect that our ability is causing.
Let's see how we're handling setting the effect or effect spec when we're launching a projectile.
So if we go into abilities and or a projectile spell, we'll see that we're creating a gameplay effect
spec with make outgoing spec and we're taking the spec handle and we're setting that on the projectile.
The projectile has a damage effect spec handle variable that we're setting.
So we're setting the damage gameplay effect for the projectile spell.
But as soon as we set that spec handle for our projectile which will apply it later, that spec handle
should carry the information for how much damage to cause and we should be able to set that here from
the ability if our ability wants to have some kind of value.
In other words, the ability itself should determine how much damage to do, not the effect.
And to do that we can use the set by caller option on the gameplay effect.
So currently our damage gameplay effect uses scalable float for its magnitude calculation type.
And we know that this is great because we can use curve tables to scale the magnitude, but we have
a fourth option that we haven't learned about yet called set by caller.
And it says this magnitude will be set explicitly by the code slash blueprint that creates the spec.
So that's what we'd like to do Now, set by caller magnitudes are pairs their key value pairs where
the key is a gameplay tag.
So we need a gameplay tag to identify the set by caller magnitude.
So first we're going to make a gameplay tag for damage and we can do that by going into our gameplay
tags Singleton class.
So it's here in Aura gameplay tags.
We're going to make a gameplay tag simply called damage.
So just under our inputs, I'm going to make a new gameplay tag called Damage and we need to make sure
that we're creating this native gameplay tag.
So opening the CPP file here is where we're creating all of our gameplay tags and just under input tags
we're going to make damage.
So let's go ahead and just copy and paste the last input tag that we declared.
And this one will be the damage tag and its name is simply going to be damage and the input string can
simply be damage.
So now we've got a native gameplay tag called Damage and we can use this and we're going to use that
in our projectile spell as I'd like to get those gameplay tags or a gameplay tags, I'm going to include
that header file here.
So it's aura and public and aura gameplay tags.
So we can get those gameplay tags.
And I'm going to do this right here before we set the projectiles damage effect spec handle, we're
going to say F or a gameplay tags gameplay tags equals F.
Or a gameplay tags get.
So now we have those tags and now we can use a set by caller magnitude.
Now this is done using the ability system Blueprint library.
So we're going to say you ability system, blueprint library.
And the function we're interested in is called assign tag set by caller magnitude.
Now assign tags set by caller magnitude is going to require a gameplay effect spec handle.
And we have one.
It's called spec handle, so we're going to pass that in next.
It requires a gameplay tag and it's called data tag.
So this is how we identify that magnitude value because you can assign multiple set by caller magnitudes
to a gameplay effect spec.
We're going to set a key value pair where the key is the damage tag.
So we're going to use gameplay tags, dot damage and the magnitude is whatever we decide here.
Our aura projectile spell could have its own damage variable.
But to see how this works, I'm just going to hardcode a value.
Let's use 50 and that's all we have to do to set the set by caller magnitude.
So now this spec handle is carrying along a pair, a key value pair.
The key is the damage gameplay tag and the value is the magnitude 50.
Now we just need to be able to access that key value pair from within our gameplay effect when applying
a modifier.
So let's do that.
Now.
I still have the editor open.
I'm going to go ahead and close it so that I can do a fresh compile and launch and we'll go back into
our gameplay effect.
So I'm going to go ahead and open damage and scroll down and now we're going to change our magnitude
calculation type.
We're going to change it from scalable float to set by caller.
Now, once we do this, we have a set by caller magnitude dropdown which we can expand.
Now, because we can have multiple set by caller magnitudes on a given gameplay effect spec, we need
to choose which one and they're identified by the key the gameplay tag key.
So for the data tag we have to select the tag that we want.
We're going to select damage and as soon as we select damage now this modifier will do 50 damage.
Why?
Because that's the value we associated with this key when we called assign tag set by caller magnitude.
So we should see 50 damage being done.
Let's go ahead and test this out and see if we do more damage than last time.
And in fact, we do.
It looks like we're doing 50 damage.
Great.
So that's how we can use the set by caller magnitude calculation type.
Now, yes, we're moving one hard coded value into another class.
Right now we're hard coding 50, but at least now our gameplay ability has control over how much damage
is done by our projectile.
It's not just set in the gameplay effect itself, it's now something we control from code and we're
going to control that from the gameplay ability.
And I think gameplay abilities can have a base damage property that we can set based on our gameplay
abilities level.
So we're going to handle adding a member variable to the aura gameplay ability class to handle damage
and we'll do that next.
So great job and I'll see you soon.