Welcome back.
Thus far, our gameplay effects that affect our health are reaching in to our attribute sets and changing
the value of health directly.
Now, in more complicated RPG style games with gas, this is not typically the way we do it.
And that's because whenever we apply damage to an enemy, for example, there are a number of calculations
that should be made, and those calculations have to do with attributes both on the attacker and the
victim.
For this reason, to keep the mathematics simple, we often use a placeholder attribute that behaves
as an intermediary, allowing us to perform all of the math that we need to perform before actually
setting the value of the health.
In the case of damage, these intermediary values are referred to as meta attributes.
Now, here's the difference between a meta attribute and a normal attribute.
A normal attribute is often replicated and it can be changed on the server and replicated down to clients.
Whereas a meta attribute, on the other hand is not replicated and it's really just a temporary placeholder.
We only use these on the server to perform calculations and after those calculations are performed we
can then apply the change to the real attribute that matters.
Now, in the case of damage, for example, we may have a meta attribute called incoming damage.
Now it's not replicated.
This is a meta attribute.
Now here's how it works.
Let's say a gameplay effect is going to apply damage.
Let's say this gameplay effect says I'm applying 11 damage to you.
Now, rather than subtracting 11 from the health of the victim, the gameplay effect is going to add
11 points to the incoming damage meta attribute.
Now we have ways to respond to attribute changes in the attribute set.
For example, we can use post gameplay effect, execute and check to see if that attribute that's changed
is the incoming damage meta attribute.
Now if it is, we can perform any necessary calculations.
We can determine if there was a block by taking in the victim's block chance we can determine if there
was a critical hit, if there needs to be an intelligence bonus in the case of magical damage, for
example, or does there need to be a strength bonus?
Maybe it's physical damage and strength boosts physical damage.
Whatever the case, we perform any of those calculations to determine the final real amount of damage
that should be caused.
And then we take that attribute in this case health and subtract that number from the health.
So the gameplay effect is not the actual decider of how much health is subtracted from the health attribute.
It's the rules that we set based on those mathematical equations that determines the final value.
So this incoming damage meta attribute will be set by these damage gameplay effects and the attribute
set will perform any calculations it needs to and then zero out that incoming damage meta attribute.
In a sense, it'll consume that value in its calculations and set the value of health and also respond
in any other ways that we need to respond in.
For example, when taking damage, perhaps we need to show some floating text popping up on the screen.
Maybe that floating text is a different color depending on if there was a block or a critical hit.
Maybe the attribute set determines that there was a debuff in response.
If it was fire damage, maybe the victim will be burned for a moment.
Or if it was lightning damage, the victim will be stunned for a moment.
These are things we can do in response to receiving a change in our incoming damage meta attribute.
So meta attributes are the way that we often see gas projects handling damage, and that's how we're
going to implement damage in our project.
So we'll do that next.
I'll see you soon.