Welcome back.
So now that we have an understanding about the order of operations of our modifiers, let's talk a little
bit more about some of these settings, specifically the coefficient and these pre and post multiply
additive values.
You see just being able to multiply, add, subtract or divide an attribute by another attribute isn't
quite enough.
What if you wanted to add to your health a value equal to strength times ten or strength times 0.1 or
strength times 0.1 plus 12.
These are where we can do this kind of thing.
Now I'm going to remove that fourth modifier there.
So we just have the three.
Let's talk about what happens if we start to set those coefficient values.
So the three parameters we're interested in are the coefficient, the pre multiply additive value and
the post multiply additive value.
Let's talk about exactly how these work.
Now we have a modifier.
Let's say it's backed by vigor and its modifier operation is Add and Vigor has a value of nine.
Now an attribute based modifier has these three parameters, right?
Well, the amount added to our health is going to be affected by these three parameters as follows.
Vigor has a value of nine.
We first add the pre multiply additive value, then this result is multiplied by the coefficient and
the result of that has the post multiply additive value added to it, which makes sense.
Vigor is multiplied by a coefficient.
It just happens that we can add a value to vigor before multiplying by that coefficient and then we
can add a value after all that.
So we can add a value before multiplying the coefficient and we can add a value after multiplying the
coefficient.
This gives us some flexibility.
So we have this formula applied right?
And let's say we have a modifier backed by health modifier op add with a coefficient of 0.1, a pre
multiply additive value of two and a post multiply additive value of five.
So what does this modifier return?
Well, first we take the nine and add the pre multiply additive value, which is to the result of that
which is 11 gets multiplied by the coefficient 0.1.
So 11 times 0.1 would give us 1.1.
The result of this then gets the post multiply additive value added to it.
So 1.1 plus five and the result of this is 6.1.
So that's how it works.
So if we have these three modifier hours each with their own modifier operations and backed by different
attributes, all targeting health and we give them each these parameters, then each of them will get
this same formula applied and the result returned from them will be the result of this math.
So let's just say that we want these coefficients and these pre and post multiply additive values for
the modifiers that we have.
If we do have those values and these are the results returned from those modifiers, then we should
expect our health to be added to by 2.2.
The result of this should be multiplied by 19.
The result of this should be divided by resilience, and that should all come out to 7.26.
As long as we use these parameters for each of our modifiers.
So I'd like to make sure that this math checks out.
So as we can see, our first modifier backed by vigor is going to need a coefficient of 0.1, a pre
multiply value of three and a post multiply value of one.
So let's get our first modifier.
We'll expand modifier magnitude, expand attribute based and set the coefficient to 0.1.
The pre multiply additive value to three and the post multiply additive value to one.
Now, according to the math that I did, this should come out to 2.29 plus three is 11.
11 times 0.1 is 1.1.
1.1 plus one is 2.2.
Feel free to double check any of this math if you like.
Now for the next modifier backed by strength.
We want a coefficient of 0.5, a pre value of six and a post value of 11.
So let's open up that second modifier, expand our dropdowns and set the coefficient to 0.5.
Set the pre multiply additive to six and the post multiply additive to 11.
And we see that that should come out to 19.
And for our last modifier, we'll use the values 2.10.5 and 5.7.
So let's expand our dropdowns for our last modifier.
And use 2.1 for the coefficient 0.5 for the pre multiply and 5.7 for the post multiply.
Now as we see the result of all of this should come out to 7.26.
Let's see if that's what we get.
We'll press play, show, debug and overlap and there I get 7.26 just as expected.
So as you can see, we have some freedom when it comes to backing our attributes by other attributes.
And this is quite nice and it gives us a lot of flexibility, although it's not complete flexibility.
We can't just create some arbitrarily complex calculation this way.
To do that, there are other methods available to us in gas that we'll get to soon enough, but this
way, at least we know we can have attributes backed by other attributes, and we're going to learn
in the videos to come how we can have derived attributes which will always be derived from the values
of other attributes.
So when it's backing attributes change, it will change automatically and we'll see how to do that very
shortly.
So excellent job and I'll see you soon.