Welcome back.
So now we're determining if we got a block and if we did, we cut the damage in half.
The next calculation I'd like to make is taking armor and armor penetration into account.
Now, the order in which we do these calculations matters, right?
Because if we cut the damage in half first, then that's going to affect how subsequent calculations
are made depending on what those calculations are mathematically.
So the way that I'd like to do it is to determine if there's a block first and foremost, and then from
there, any additional calculations will work based on that result.
If the damage has been cut in half, then the starting amount of damage going into the next calculations
will be half as large.
And the reason for that choice is, well, the choice had to be made and this makes sense to me.
Now we're going to go up to aura damage statics.
We're already capturing armor.
We're going to capture armor penetration Now, as the two of these kind of coincide together, they
work with each other or I should say they work against one another as armor penetration ignores a percentage
of the target's armor of the victim's armor.
So we're going to capture armor penetration, which means we need to use armor penetration with this
macro.
And for the define version of this macro, we're going to also use armor penetration.
But in this case, we're going to capture armor penetration from the source.
Right?
Because armor and block chants, those are for the defending character.
The attacker is what uses the armor penetration.
So we're going to compare the armor penetration of the source with the armor of the target.
Now, we do need to add this to relevant attributes to capture, so we'll do that as well, adding our
armor penetration depth to that array, and then we can scroll down and capture the values of armor
and armor penetration.
And these three lines here are what I'm looking at.
This is how we captured our target block Chance.
We're going to copy those three lines and paste them just beneath here, and we're going to change this
to armor.
And this is going to be armor on the target.
So this can be target armor.
Now, target armor will be initialized to zero, but we're going to pass in to attempt calculate captured
attribute magnitude the armor def.
We're also going to pass in this target armor float and then we're going to use Max on target armor
maxing itself and zero.
So that way we'll never get a negative value.
So that's our target's armor.
We're also going to get the source armor penetration.
So we're going to call this one source armor penetration.
And we're capturing armor penetration, depth.
That's the first input.
And we're passing in source armor penetration.
And then we'll go ahead and do the max trick with source armor penetration as well.
So after damage, we can have a couple of comments here as well.
And right here, this comment if block half the damage, that's really what this line is doing here.
So I'm going to move this comment down to right here.
This is where we're having the damage.
Okay.
So now our comments are a little bit descriptive of our intentions here.
And for this next comment, we're going to say armor penetration ignores a percentage.
Of the targets.
Armor.
So how are we going to implement this mathematically?
Well, here's a way that I'd like to do it.
I'm going to make a const float called Effective Armor, and this will be the amount of armor left over
after we've ignored a percentage of it.
Now, if we're going to ignore a percentage of target armor, then we're going to take target armor
and multiply it by something.
We're going to say times equals here and multiply by some fraction and that fraction can be, Here's
one way to do it.
We can say 100 minus source armor penetration divided by.
100.
Now, if we're doing it this way, we have to be aware of how the mathematics works.
What we're doing is we're taking 100 and subtracting source armor penetration.
So that right there tells you that if source armor penetration is 100, then this right here in the
parentheses will be zero.
It'll be 100 -100 and zero divided by 100 is still zero, which means target armor will be equal to
itself times zero.
So source armor penetration of 100 is basically what we would call max armor penetration.
In other words, it's the ultimate armor penetration, right?
You got 100, you're ignoring 100% of your target's armor for that reason.
Sometimes we scale this value and we scale the value depending on the level of the characters involved,
perhaps, or depending on any other criteria that the game designers choose.
It depends on the game you play.
And if you've played lots of RPGs, you've seen it done in a number of ways.
Some games will say, Let's take source armor penetration and we'll scale it by 0.250. 25F.
For example, if the source character is zero to level 60 and then if the character is level 61 to level
80, then this becomes an even smaller number and then it takes more armor penetration to ignore a percentage
of armor.
And then you can scale it.
You can even scale it using a curve, using a curve table.
It really depends on how you want to implement this.
There's really no end to how you do it.
But if we scale this by 0.25, then that means that we'd have to have 400 armor penetration in order
to ignore 100% of the target's armor.
Right.
And that means well, one armor penetration point is worth 25% of what it was before.
But scaling it here means, well, basically, it takes for armor penetration points to ignore 1% of
the target's armor.
That's how it works.
Now, if for some reason this value here is larger than 100, say we have 500 armor penetration, well
then we're taking 100 -125 because 500 times 0.25 is 125.
And in that case, we have -25 divided by 100.
That's a negative value.
So really, if we wanted to, we could use this math max trick here on this value, or we could just
make sure the source armor penetration is never going to be higher than some kind of threshold.
And that's the way that I like to approach it.
But either way, the point is that source armor penetration is going to reduce the armor, the effective
armor will be some percentage less after this calculation.
Now, after that, we need to reduce the damage that will be caused by the effect of armor in some way.
Now, if each point of the effective armor reduces the damage caused by 1%, then here's what that math
would look like.
We would say damage times equals, and then we could have parentheses and say.
100 minus effective armor, all of that divided by 100.
So if effective armor is 100, we ignore all of the damage.
If effective armor is 50, we ignore 50% of the damage.
Effective armor is ten.
Then we have 100 minus ten, which is 90 divided by 100.
90 divided by 100 is 0.9.
Damage times 0.9 means we do 90% of the damage.
So each point of effective armor ignores 1% of the damage.
And of course, we can scale that if we think that's too OP.
If we think that's too overpowered, we can say effective armor times 0.3 F and then effective armor
is going to ignore a third of the percent roughly.
If this is 0.333, for example, that's a third.
So it would take three points of effective armor to ignore 1% of the damage.
That's how that would work.
And again, you can data drive this any way you like.
I leave that to you as an optional exercise.
For now, we know that at least our armor and our armor penetration are doing something to the damage.
Okay.
So now that we're capturing those attributes and making this calculation, we can play test and see
just how much damage we'll be doing.
Now that armor and armor penetration is taken into account.
Okay, let's go ahead and open up those assets.
We have a secondary attributes test if we'd like to test some values, but I'm going to go ahead and
just launch and look at that.
We got 15 now.
We're truncating these damage values down to integers.
So of course that's going to affect things.
But we can set the secondary attributes to whatever we like.
Now, just to prove that armor is working, we can change armor from attribute based to scalable float
and set it to some higher value like I don't know, 45 and we can see if we're doing less damage because,
well, our enemies have a higher armor.
And we're not because we're not actually using this test attribute, are we?
We have to go into the data asset, go to secondary attributes and change this to secondary attribute
test.
I change that back to the normal one.
Now we're using the test one and now we're doing less damage.
We're doing seven damage.
So this is a nice way to play with the values and see how much damage we do.
Let's change armor to 90, see how much damage we do.
Now we do six because we're ignoring even more of that damage.
And if I set this to to 50, we should see that we're ignoring even more of the damage.
Yeah, we're doing one damage now.
So this gives us a bit of a way to tweak those values and see, you know, this isn't the best way to
test this out, but it's one way.
You know, ideally we could have some kind of automated test that we write that tests a whole bunch
of values and spits out some data for us.
We could always do that, but for now it's enough to know that increasing the armor on the enemy is
resulting in less damage.
That much is clear and I'm happy about that.
So at this point, we're taking block chance armor and armor penetration into account.
And this comment here can go right down here where we're actually ignoring a percentage of the target's
armor.
And we can even add another comment that says armor ignores a percentage of incoming damage.
All right.
So our execution calculation is that much more complete.
But we still have more to go.
And we'll continue in the next video.
I'll see you soon.