Welcome back.
Now, we've gone through a lot of trouble just for a couple of Boolean values.
But now that we have those Boolean values, we can show some visuals to the player.
Whenever we cause damage, we can show whether that damage was a blocked hit or a critical hit.
So while that seems like something small, it's actually not.
There's a lot of thought that goes behind blocked and critical hits and how to show them.
Now we know that our attribute set show floating text function receives these values.
Now we need those values to make their way into the widgets.
Now what we're doing to show the damage number is calling the player controller function show damage
number.
Let's take a look at that function.
I'm going to go ahead and go to it.
Here's show damage number.
And in the CPP file, it is way up here, at least in my case.
And look at this implementation seems to indicate that it's an RPC and we know that it is right.
It's a client RPC.
Okay.
So in the player controller here, we see that what we're doing is we're taking the damage amount and
the target character.
We're creating a new You damage text component where registering it, attaching it to the root component
of the target character, detaching it shortly thereafter and then calling set damage text on that you
damage text component.
This is where we pass along that damage amount.
This is where it's at.
This is where we want to pass those booleans across to this damage text component so it can respond.
So we have a few things to change here.
For one, set damage text needs to take those booleans.
For another thing, show damage number needs to take those booleans, look at that extra space there.
And in addition to that, in aura attribute set, we need to pass that info in to show damage number.
So let's start here with show damage numbers so we can pass that info in.
So here in Aura player controller show damage number gets two new booleans actually rather than type
them out, I'm going to be lazy and copy them by going into aura attribute set and getting them right
here.
Bool be blocked, hit bool, be crit hit or critical hit.
I'm going to copy them from here and go back to aura player controller and paste them into show damage
number here.
And then I'm going to go into Aura player controller CP and paste them in here.
And now that I have those, we need set damage text to take in those booleans and that exists on the
damage text component.
So let's go to that.
We're going to go into UI widget damage text component here, set damage text.
We're going to add those booleans here.
It's a blueprint implementable event.
So we don't have a implementation in C plus plus to change.
So that's fine.
We'll have to go into Blueprint to handle it from there.
But now that this has the inputs that we need it to have, we can go back to aura player controller
and pass those booleans through into set damage text.
So first is B blocked, hit second is B critical hit and now those are passed along.
But now show damage number needs those booleans as well.
So we can go back to aura, attribute set and pass along those booleans here.
It's going to be B blocked hit and B critical hit.
Okay.
So now we're all set on the Cplusplus side.
We're getting those values from the effect context.
We're passing them in to show floating text.
Show floating text is passing them into the player.
Controllers show damage number, show damage number is passing them through to the damage, text components,
set damage, text function.
And from there we handle it in blueprint.
So let's go ahead and get this working in Blueprint.
Now it looks like I have my editor open.
I'm going to close it down and compile and launch by hitting the debug button.
Okay.
So back in, the editor where I want to go is in Blueprints UI and the floating text folder.
Here's what I'm concerned with.
I'm going to open up both of these.
Here's my damaged text component blueprint and I'm also going to open up my damage text widget blueprint
here.
And if I go to the graph here, I have an update damage text function.
And if I go to my text component, we have event set damage, text.
And look, it now has blocked, hit and critical hit.
So now that we have access to this information, we need to pass it through to the widget.
So update damage text should take these two booleans now.
So I'm going to go back to update damage text here in my widget and I'm going to add two new inputs.
First is a boolean called Blocked Hit, and next is a Boolean called Critical Hit.
And we just need to pass those through.
I'm going to compile this, go back to my component and we're going to pass these along.
I'm going to take blocked, hit and drag it down to here, get a reroute node, drag it over to here,
get a reroute node and then hook it into blocked hit.
We'll do the same thing for critical hit, get a reroute node, drag it over, get a reroute node and
hook it into critical hit.
So we're passing that info along and I can use the Q key to straighten these out.
And if you're OCD, you're going to probably straighten these all out and make them all evenly spaced.
And if you haven't used electronic nodes and dark nodes, those are a really nice way for you to organize
your blueprint nodes.
Just passing that info along there.
All right.
So now update damage text has the information and if we go to update damage text, we can decide what
to do with that info.
Now we're setting the text damage using this number here.
And what we can do is we can set the color of the text based on whether or not it's a blocked or critical
hit or maybe both.
So I think what I'd like to do is make a nice handy function that can take in both of these booleans
and perhaps return a color, and then we can just use that color as a sort of local variable to set
the color and opacity.
I think that would be a nice, clean solution.
So I'm going to add a new function called get color based on block and crit.
Now, this will require two boolean inputs.
One called is block and another called is crit is crit there.
So a hit can be either blocked.
It can be a critical hit or it can be both.
And depending on whatever combination, our function should output a color.
So I'm going to add an output.
And for the type, I'm going to choose slate color.
The slate color structure is what I'd like to return based on whatever combination we have here.
So I'm going to disconnect that pin for now.
And my return node can be called color.
So let's check the various combinations first.
I'm going to check if is block is true, but I'd also like is block to be true and is crit to not be
true.
So I'm going to use an and boolean.
And for the second condition is crit should not be true.
So I'm going to use a not boolean.
So both is block is true and is crit is not true.
In this case we're going to have a color for a blocked hit that's not crit.
So I think what I need to do here is promote this color to a variable.
It can be a local variable.
So promote a local variable and we're going to call this out color.
And that's what we're returning from.
The function and out color can be set.
So we're going to alt drag out, out color and set it.
And what are we going to set it to?
Well, let's go ahead and just make a slate color structure.
So make slate color.
And what color do we want for a blocked hit?
I'm going to make it something like a light blue, something like that.
Just like that.
Now, in the case that this branch fails, then that means that either is block is false or is crit
is true.
So let's check another one of the possible scenarios.
So I'm going to have another branch after this one.
And for this one, let's check the opposite.
Case is block is not true and is crit is true.
I'm going to go ahead and duplicate these nodes but I'm going to have is block passed into the not.
Like that and is crit passed in directly to the ad?
Now, at this point I have some red spaghetti going on that I don't like, so I'm going to promote.
These two local variables I'm going to take is block promote to local variable called block.
And I'm going to take is crit promote to local variable called crit.
Now that I have these, I don't have to have all these wires because that's a nightmare.
So is Block goes in here.
It's actually blocked now and then is crit which is now crit goes in here.
And then block is block went down into the not down here.
Now it's just block and then is quit now is just quit down here now we're not creating so many nightmarish
crisscrossing lines so this one goes into this branch and these branches should probably have comments
so we know what's going on.
So this one, I'll place a comment and say block, no crit looks good, and then this one will say crit,
no.
Block So if it's a critical hit, then I can set out color to a different color.
So I'm going to duplicate this down here.
Don't think I need the reroute.
Move this out of the way and we're going to set the out color.
If it's a critical hit, maybe to something reddish.
Maybe even all red.
Something like that.
So that's a critical hit.
Now we can have a false case for this because we could have both.
So if that's the case, we're going to have one more branch.
And this will be for when both of these are true.
So I'm going to duplicate the and duplicate block duplicate crit.
And this will be for a blocked critical hit.
We can choose a color for that as well.
So hooking that up.
I'll go ahead and duplicate these nodes.
And for a blocked critical hit, I think I'd like something yellow, perhaps.
Block.
Blocked.
Critical hit.
Something like this.
Color, I think, is fine.
And there is yet another scenario, which is when we don't have a block and we don't have a critical
hit either.
So that's going to be for our last case.
This one should get a comment, though, that says block and crit and then we'll have another one for
the last false case.
This one is going to be no block, no crit, and it's really just the else case, right?
But we can just go ahead and check these conditions anyway.
We can have two knots here.
And we can have block and crit.
We can just check these.
We don't have to, though, because this is just the remaining case.
We don't have to even have a last branch here, but we'll just do it anyway.
And for no block, no crit, let's just make this white.
And we'll just put them both here.
Okay, so all of these scenarios must go into the return node.
So up here this setter goes to the return node and so do all the others.
So they'll all go to the return node.
And when we reach the return node, we'll return out color, which is set in all the different scenarios
here.
Okay.
So I'm just going to really quickly.
Organize this as best I can.
Okay.
I think that's looking pretty good.
So we have block no crit.
That's blue crit, no block That's red block and crit, which is a kind of bone yellow color and no
block no crit, which is white.
And this function returns a color.
So let's go ahead and just save and go back to update damage.
And we can call this function.
So I'm going to call it.
It's just get color based on block and crit.
We're going to pass in block and crit directly in.
Blocked, hit, hit, hit.
And I'll move this out of the way here.
And we'll just go ahead and promote color to a local variable called text color.
That way we have that.
And after setting the text, we can set the text color as well.
So I'm going to take text damage, duplicate it and call set color and opacity.
And this takes in a slate color structure so we can pass in text color.
I'm going to grab that, get it, set it there and that's it.
So this function gives us the color.
Since we're setting the color, we can see if we get a block or a crit.
Last step is to test it.
So let's just cause some damage.
Look at that.
We got a blocked hit.
We can tell because it's blue.
And I'm just now realizing we're only going to get blocked hits because we set the block chance to 100
for these guys.
So I'm going to go back to Blueprints Ability system go to gameplay effects, default attributes.
We got the test secondary attributes here and let's just set the block chance to oh 50%.
And as we know, our Aura character only has a critical hit chance of three.
So it might be a good opportunity now to tweak the relationship between critical hit chance and its
backing attributes.
So we can do that as well.
But let's just cause damage a couple times.
There's a four, there's an eight, and it was white.
Look at that, eight four.
So we're getting some blocked hits, some non blocked hits.
We haven't gotten any critical hits yet.
So I think it's a good opportunity now to make a couple changes.
For one, let's just take a look at aura and secondary attributes and just scroll down to our critical
hit Chance.
Here it is.
It's based on armor penetration and it's got a post-multiply additive value of two.
We could raise that to say ten.
And for every armor penetration point, it looks like we get 0.25 points added.
We could change that to 0.5.
And we can also go look at armor penetration.
Armor penetration is up here.
It's based on resilience and it has a post multiply additive value of three, but we can change that
to say seven.
And for every resilience point we have one added to it and then the coefficient is 0.15.
I think actually adding seven to it is going to increase it quite a bit.
Let's just see.
Critical hit chance is now 14, but we could make that even higher if we'd like.
So we can make armor penetration higher by giving it let's give it about a 25 base value.
Now critical hit chance is 23.
I think that's a good enough chance that we should see at least a couple critical hits.
That was a blocked hit.
Blocked hit.
Oh, that was a blocked critical hit.
I saw 54 in a bone, white color.
There was a critical hit there, 63.
Now, this is quite a contrast.
A blockhead is only four and a blocked crit is 54 and then a non blocked critical hit is pretty high.
63.
That's fine.
These are values that we can always tweak with testing.
But the important part is that we're seeing all of those and we're getting visual feedback in the form
of colors.
So this is great.
This is a great milestone.
But the thing about this is that colors are not all that informative.
They do tell us that something is different, but new players to the game are not necessarily going
to know what a red number is, what a blue number is.
It's also good to show them either a symbol or a message that says what's going on.
So in the case of blocked damage, we could have a message here that says block In the case of a critical
hit, we can say critical hit.
And if it's neither of those, well, we could just have no message.
So I think it would be a good idea to show a message when we have a block, when we have a crit, when
we have both, and we can perhaps animate that message.
So it looks nice on the screen when we're engaging in combat.
So that is the next thing that I'd like to take care of.
We'll do that in the next video.
So excellent job and I'll see you soon.