Welcome back.
In this video, we're going to handle two issues that you may or may not have noticed.
Now, one of those issues is something we can see if we go into our attribute set, where we level up
here, we set our health and mana to their max values.
Now, if you did any testing, you may have noticed that we're not getting those globes filled up.
When we level up, all you have to do is go and get damaged a few times to see that We'll let Aura get
hurt a few times and then we can just level up.
And we should see we would expect to see our Globes to fill.
And they feel slightly, but not all the way.
So why do they not feel all the way up?
Well, we're setting our health and mana to our max health and max mana values.
And these depend on level.
Now we're changing our level.
And you would think because we're adding to our player level first, that our max health and Max Mana
will be adjusted, but it doesn't actually happen right away.
In fact, it doesn't happen until post gameplay effect execute is already finished.
We can see that by pressing play then coming back and placing a breakpoint right at set health and then
we can go into max health and place a breakpoint here.
Now if we go and level up.
We'll see that set health and Setmana get called first.
And if we click resume our is executed after.
So for that reason, we're going to have to go about this a little bit differently.
Now, an MSI like this is applying a modifier to our max health, and when it does so, it changes the
Max Health's current value, not its base value.
Now there are functions on the attribute set to respond to changes to current values.
In fact, we can have something happen after we've set our max health and max mana.
I'm going to go into my H file for Ora attribute set.
I'm going to find you attribute set and click on it so I can go to it and I'm going to search for post
gameplay effect.
And here's post gameplay effect execute.
But notice there are all these other functions pre attribute change which we've overridden.
We have post attribute change.
We also have pre attribute base change in post attribute base change.
Now, in the case of an AMC, we're not changing the base value, so we don't want post attribute base
change.
We want post attribute change.
Here is where we can do something in response to our max health or max mana changing.
So what I'd like to do is copy this line and go back to our attribute set and override this function
post attribute change.
And I'm going to mark it with override here and go ahead and generate a definition for this.
Well, if my max health just changed, then I know I can set my health to max health if we're leveling
up.
Now.
If you only change your max health when you're leveling up, same for your max mana.
You can just check.
Is Max Health the attribute that's changing?
If so, set our health to Max.
Now, in some games you may have changes to your max health when you're not leveling up.
So in that case, we may wish to know if this change is from a level up or not.
It.
So we can have a couple of booleans.
I'll put them down here in the private section.
I'll have be top off health.
It'll be set to false and I'll have a bool called Be top off.
Mana also set to false, but we'll set these to true when we level up right here.
So instead of setting health and mana, we'll set be top off health to true and we'll set be top off
mana to true and when max health and max mana change we'll check those booleans here.
So here in post attribute change since we have the gameplay attribute, it's called attribute we'll
say if attribute is equal to get max health attribute and we can have an end here and check be top off
health.
If these are true, then we can set health equal to the value of max health.
So get max health here.
And we can do the same for Mana.
We can say if attribute equals get max mana attribute.
And be top off mana.
Then we can top off mana.
We can say set mana, get max mana and our mana will be topped off too.
Now, if this is true, be topped off health, then we should consume that boolean.
In other words, we should set it back to false.
So we'll say be top off health equals false here.
And same goes for mana.
We'll set be top off mana.
Equal to false as well.
And that way we can have changes to our max health and Max Mana even when we're not leveling up.
And only if we're leveling up will we max out health and mana.
With that, let's give this a test run and see if our globes get filled up when we level up.
So back in the editor, I'm going to press play.
I'm going to get hurt a little bit.
So just letting the goblins stab me a few times.
I'll let it get down to maybe halfway or so, and then I'll run away and see if I can kill one and level
up.
There we go.
And my health has been topped off.
Now, the most important thing about this is when they hit me again, it should look like the amount
that's being subtracted is correct.
We don't want it to go down to say, almost zero from getting hit once.
So let's see.
Yeah, that looks right.
That looks perfect.
And if we cast a spell, then that also looks correct.
So it looks like we have the effect that we wanted.
Let's try that again by leveling up one more time.
And see if we get topped off here.
Boom, there it goes.
And if we get stabbed.
Then it appears that we're taking the appropriate amount of damage.
Everything is working properly.
So that was the first issue I wanted to take care of.
The next issue can be seen if we press play and dock our output log and we go ahead and start playing
the game.
Let's get a level up.
And there's the issue.
I'm going to hit pause.
Now, we've seen this error before.
It's on the gameplay effects spec.
It has to do with getting set by caller magnitudes that were never set.
Now we're getting set by caller magnitudes that were never set because we're applying a gameplay effect,
event based effect which has five different modifiers, all of which are set by caller magnitude modifiers.
Now, depending on the event tag that we receive in our passive gameplay ability.
Gah.
Listen for events.
When we receive a tag, then we assign a set by color magnitude for that tag.
But we don't assign a set by color magnitude for the other four.
Now in C plus plus, this wasn't a problem because we could suppress that error message as there is
a boolean, but in blueprint we don't have that option to suppress it.
So what we should do is every time we assign a set by color magnitude for one of the tags, we should
assign a set by color magnitude of zero for the other four.
And that way we won't get that pesky little error message.
So here's how I'd like to do it.
First of all, I'm going to have an array of gameplay tags and we'll loop through and for the gameplay
tag that we've received, we'll set it set by color magnitude as we're doing.
But for the other four we'll set it's set by color, magnitude to zero.
So let's add a variable, we'll choose the type gameplay tag.
We'll call this event tags and we'll change its variable type here to an array.
Now I'm going to compile and click plus five times and fill this array with the gameplay tags that are
event based effect has modifiers for the first of those is going to be attributes meta incoming exp
and the other four are our primary attributes.
So for the next one we'll do intelligence.
For the next one we'll do resilience, the next one will be strength and the next one will be vigor.
So now that we have this array, as soon as we've received an event, we'll loop over that array.
So to prevent this blueprint from getting out of control, I'm going to make sure this is nice and organized.
For one, I'm going to delete on end ability.
I don't need it.
Next in Wait gameplay event, when an event is received, I'm going to cache off the event tag and the
event magnitude.
So I'm going to take event tag.
Promote it to a variable.
I can just let it be event tag and I'm going to take event magnitude and promote that to a variable
and let that be called event magnitude.
In addition to that, I'm going to cache off the outgoing spec.
Remember, these blueprint pure nodes are executed every time a node is reached which has a wire connected
to them.
So that can be dangerous.
We don't want to keep making new outgoing effect specs, we just want one.
So I'm going to promote this to a variable called spec.
Now these are being set here every time our ability is activated, but once per activation, we don't
want to set them multiple times per activation.
So we're only setting them here and then reusing them later.
So after setting these, I'm going to loop over our event tags.
So I'm going to get them and use a for each loop.
And in the for each loop body I want to check the array element, which is a gameplay tag.
I want to check it against our event tag and see if they're equal.
So I'm going to just break.
All of these wires and move this out of the way.
And I'm going to make a branch here and in the loop body.
What I'm going to check is to see if my array element, which is a gameplay tag, matches our event
tag.
So I'm going to say matches tag and I want it to match exact.
So I'm going to take my event tag.
Remember, this is the tag that we received from our event.
And as we loop through our event tags, there's five of them.
Once we find the one that matches, that's the one we're setting our set by caller magnitude for.
So we're going to assign tags set by caller magnitude using the event tag as the data tag, our event
magnitude as the magnitude.
And we cashed off our spec handle, we called it spec.
So I'm going to go ahead and break these wires.
And for the true case, this is for the tag we received in our event.
So we're going to hook this up to True.
But for all four of the other tags, we're going to assign tags set by color magnitude for that tag.
The array element here to zero, but we're going to use the same spec handle, so we're going to use
spec for that and we're going to hook up the false case.
So for the one tag in our array that matches the event that we received, we're assigning a set by color
magnitude.
Using that event magnitude we cashed off.
But for the other four, we're setting its magnitude to zero just because we need it set now in the
completed execution pin for the for each loop, we can finally apply the gameplay effect spec to self.
So we're going to hook completed up to apply gameplay effect spec to self, but we need to hook in spec
for the spec handle.
So by the end of this we'll actually have applied the gameplay effect.
Let's go ahead and get this pulled out just a little bit.
And we can organize this just a little bit more.
Like so.
So this has the same effect.
The only difference is we're never omitting to assign a set by color magnitude that exists in the gameplay
effect spec that we're applying.
We're setting the one that matters and we're setting all the others to zero.
So with that, we can press play and we can level up.
Like so and we no longer get that warning.
Well, it's actually an error, so that takes care of that.
Excellent.
So now that we've polished a couple things up, it's time to polish the look and feel of our attribute
menu.
I'd like it to look excellent and sound great.
I'd like some hover sound, some click sounds.
I'd like it to sound and feel like a real menu.
And we'll do that next.
Great job.
I'll see you soon.