Welcome back.
Now we're hard coding 50in our set by color magnitude for the damage effect spec handle we're setting
on our projectile now or a projectile spell is going to control the damage.
And rather than hard coding this, we can have a variable.
But we know that abilities have the concept of level.
So if the ability level increases, maybe we'd like our damage to increase as well.
And we've seen a good way to handle increasing values based on level we could use curve tables.
Well, we've also seen that when we select a curve table in a gameplay effect.
For example, let's just pull up an example of this.
We'll go to Actor Potion, GE Potion, Heal, and here we're using a scalable float magnitude where
we've selected a curve table Choosing a curve from that table, we can enter a value and the scalable
float magnitude will be scaled by the value in that curve based on a level we can do something like
this in our gameplay ability.
This scalable float magnitude property here is an F scalable float, and when you have a member variable
of this type, you get these properties, you get the ability to have a magnitude, you get a dropdown
to select a curve table and you get another dropdown to select the curve from that table as well as
a preview slider that allows you to see the magnitude scaled at various levels.
I'd like to have one of these handy properties in my gameplay ability class, so that's what I'm going
to do.
I'm going to go ahead and close the editor saving all, and this is something I think we can have common
to all of our gameplay abilities now.
Yes.
Or a gameplay ability could be used for something other than a damage causing spell and we may have
or a gameplay abilities that don't use the damage property.
And if you really wanted to you could subclass or a gameplay ability and make an aura damage ability
for example.
And then all of our damage abilities can inherit from that.
But I'm just going to give the damage property to aura gameplay ability and then in any abilities that
don't use damage, I just won't use that property as the amount of memory that it takes up will be negligible.
So we're going to go to our public folder into ability system abilities and open my base aura gameplay
ability class.
And I'd like to have a property here for our damage for the ability that can be a scalable float and
we can create curve tables and set those per ability.
So that's what I'm going to do here.
Now to do that, we create an F scalable float variable and I'm just going to call this damage now.
I want to set this from our ability blueprint.
So we're going to make it edit defaults only.
I'd like to make it blueprint read only as well in case we want to use it in the ability blueprint.
And I'm going to set its category to damage now that we have an F scalable float property that's edit
defaults only.
Let's see how this is exposed to the details panel.
We'll see what it looks like so we can go ahead and launch the editor.
And from here in the editor, I'll go ahead and open up those gameplay effects.
I think I'm done with Potion Heal.
I'll keep damage open for a while while we're still dealing with damage.
But I do want to go into blueprints, ability system, gameplay abilities, fire Firebolt and open our
gameplay ability Firebolt As we've now added a new scalable float to this and it should be in the damage
category.
Here it is.
So here's damage, right?
And if we enter a value here, it'll be scaled by the curve table.
Now if we wanted, we could enter a base value like ten and then create a curve table to scale it.
What I usually like to do is set this magnitude value to one and then create a curve table that has
those values that I'd like for each level.
So that's just a personal preference.
But now we can create a damage curve table specific to the firebolt ability and we can create different
curve tables for different abilities.
If we like their damage to scale differently when their level increases.
So all that's left now is to create that curve table and that is going to be your quest.
I'd like you to create a damage curve table, and you can call this CT damage if you like, but create
a curve table and you're of course, going to need to add a curve to it.
Now choose the interpolation type that you like.
And in fact, I'd like you to choose the method that you like to store the data.
You can create a CSV, a Json, or just make the curve table in the editor.
So choose whichever method you like.
Create the damage curve table and scale the damage for firebolt how you see fit.
So pause the video and conquer this quest now.
Okay, so we need a curve table that we can set for our damage.
Now, just for the practice, I think I'll go ahead and make a Json file for this.
Now, whenever you don't remember the exact syntax, you can always go back and look at something that
you've already made to get an example.
Here's our primary attributes Warrior Json file.
And if I want, I can use this as a sort of example of the syntax for a Json file.
Now, really, each of these corresponds to a different curve with a different name, right?
So I only need one so I can delete all but one of these.
And for the name I can assign any name I like.
I'm going to call this Firebolt.
And in fact, I can make this abilities dot firebolt and I can even use this curve table for damage
for non ability type gameplay effects as well if I want to do that.
Now I need to specify values and for level one, let's just say our firebolt can do five damage.
For level five, we can make it ten for level ten, let's make it oh 16 I'm going to change this from
14.9 to 15.
Sometimes we get those inaccuracies when exporting into a Json file.
For level 15, we'll make this 27.
For level 20, we'll make this 41.
And for level 40, why don't we make it something like 80?
Now let's go higher.
We'll do 120 for level 40.
And now we have the makings for a curve table.
Let's go ahead and save this.
And I'll save this as CT damage.
Save and now we have a Json file.
Now I can make a curve table out of this, so I'm going to go to blueprints ability system data and
we'll make our curve table here for damage.
I'm going to right click, I'm going to import.
We could have just clicked on import there.
I'm going to import CT damage dot Json and choose import as curve table.
And for the curve interpolation type I'm going to choose cubic.
We'll get a chance to see what constant looks like in time, but I'm going to choose cubic hit apply.
And now we have CT damage and if I go to abilities dot Firebolt, here's what the damage trend looks
like.
So that looks good.
I'm going to take this handle though, and kind of angle it down like that so that we don't have a fall
off.
I'd like it to just kind of approach like that and I can even take this value and bring it down.
And that way I have a more smooth curve, a smoother trend.
I'm going to go ahead and save that.
And now we have CT damage.
So now that we have a curve table with a firebolt curve, we can assign this in our gameplay ability.
Firebolt So here's my damage f scalable float.
I'm going to set its magnitude to one and open the dropdown and choose CT damage.
And for the curve I'm going to select abilities dot Firebolt.
So now that we have this damage property, we can use this when we're creating our damage effect spec
in our firebolt ability.
So I'm going to save all.
I'm going to close the editor and back here in writer, I'm going to go to my Aura projectile spell
back where I'm creating my gameplay ability and setting our set by color magnitude.
I no longer want to set this to 50, but I want to query my damage.
Scalable float at the level of our gameplay ability and gameplay abilities have a built in concept of
level.
We can always get the ability with get ability level.
This is a built in function and this returns an int 32 for the level.
So how do we get the evaluated value of our damage which we placed in or a gameplay ability this scalable
float?
How do we evaluate that at the ability level?
Well, we have several options.
We have a few functions to choose from.
If we want that ability level as an integer, we can take our damage and use as integer.
We can even use as bool.
And these functions as integer, for example, require a level so we can pass in a level and an optional
context string.
And this returns us an integer, a evaluated on the curve at that level.
That's if we want an integer.
We don't have to take an integer.
We can simply evaluate, we can evaluate at current level, which gets the value and possible curve.
So we'd have to pass in an F real curve pointer by reference.
A pointer by reference might seem a little strange, but it's just passing in a pointer and the function
will change that pointer.
We can also get value at level, which requires a level and returns the scaled value at the given level.
So we're going to call get value at level and just pass in the ability level.
So we're going to call get ability level.
We know this returns an INT 32 and the function requires a float, that's fine, it'll just perform
an implicit conversion.
So this is going to return a float that's scaled by our ability level and we can pass this in as the
magnitude.
I'm going to go ahead and make a const float called scaled Damage and set it equal to this.
And I'd like to go ahead and use an on screen debug message to print this.
So I'm going to use G engine add on screen debug message with a key of negative one time to display
can be three point f f color can be red.
And for the string we're going to make an f string print f formatted string.
That's going to say firebolt damage percent f and we're going to pass in scaled damage.
So this way at least we'll get to see how much damage we're doing.
And we can always change what we're passing in for the level to see that value scaled differently.
Now, we're not going to cover how to set the abilities level just yet, but we will be able to level
up abilities later on in the course.
For now, we can just use our scaled damage, which by the way, we want to change from 50 here in assign
tags set by color magnitude now to scaled damage.
So now damage will be scaled based on ability level.
Let's go ahead and launch.
Okay.
I'll go ahead and open up our asset editors here.
But really, I'd like to cause damage and see what we get printed out to the screen.
Here we go.
And we saw that damage.
And of course, we saw it immediately as soon as we launched the fireball, because we're printing this
message immediately right here in Spawn Projectile.
We're not printing the message.
When the projectile hits, we're printing the message right away when we create the gameplay effect
spec.
And we're seeing that that value is five, which makes sense because if we look at CT damage at level
one, the value is five.
But what if our level was, say, 20?
Well, we should see a value of about 41.
Right.
So we can test that out.
Let's go ahead and close the editor.
I'm going to save all and for scale damage.
Instead of passing in get ability level, we can pass in 20 is what I think I said.
So let's see if we get a different scaled value here.
Okay.
So with an ability level of 20, I'm going to launch the fireball and we have 41.
And as it appears, we're doing a lot more damage based on that health bar there.
So it looks like things are working.
This is looking great.
I'm going to go ahead and change this back from 20 to get ability level A Control Z should do it and
do a quick compile.
And it looks like everything's working all right now.
We don't really need this onscreen debug message, so I'm going to go ahead and remove it for now.
And just to appease Rider, I'm going to go ahead and just make gameplay tags a const variable.
And with that we now have damage assigned based on the ability level thanks to a scalable float that
we added to our gameplay ability.
And now we have a damage curve table set to scale the damage for Firebolt and we can use that same curve
table for any other type of damage, which is great.
So excellent job and I'll see you in the next video.