Welcome back.
Now things are looking pretty cool.
We have a spell description that shows us how much damage we can do, what level we're at.
And this is nice, but recall that we added more styles to our rich text block data table if we go to
UI data rich text style here in our styles, we have all these different styles and it'd be nice to
make use of more of them.
In this video we're concerned with manacost and cooldown and how to get Ahold of those when we're constructing
our spell descriptions.
So that's what we're going to get started on.
Now.
We added our spell description for Firebolt here in Aura Projectile spell.
But Aura projectile spell is just a generic projectile spell.
I think having a description is reason enough to derive aura projectile spell into an aura.
Firebolt.
That way we can have multiple projectiles, each of which has their own implementation of jet description
and get next level description.
So we're going to move this into a child class and reparent the aura Firebolt Gameplay ability Blueprint.
So here's what we're going to do.
Let's make a new C plus plus class.
And it'll go into abilities and it's going to be based on Aura projectile spell.
So let's make that child class.
And this can be called aura.
Firebolt.
And we'll create the class, we'll close the editor, and all we need to do is implement, get description
and get next level description.
So I'm going to close all other tabs keeping Aura projectile spell open.
I'm going to get the header file too.
And let's get Aura Firebolt open and it's CPP file as well.
And we're going to move some things from aura projectile spell into aura Firebolt.
So aura projectile spell doesn't even need to override, get description and get next level description.
We're just going to cut those out and move them over to Aura Firebolt and we'll implement them here.
So I'm going to get those definitions, both of them.
Cut them out of or a projectile spell and paste them here in aura.
Firebolt.
We do have to change those spell signatures.
They have to say you or a firebolt not projectile spell.
Now we're getting gameplay tags, so we need that include we don't really need it anymore in or a projectile
spell, do we?
I don't think we do.
Oh it looks like we're using it down here.
Yeah.
So we're going to have to leave it in, but we still need to get it over to Aura Firebolt.
So with that or a Firebolt is now implementing these description functions and now we can just reparent
our gameplay ability blueprint to aura Firebolt and it still should all work as aura.
Firebolt inherits everything from aura projectile spell.
So we're going to go into the ability and blueprints, ability, system or abilities.
Fire Firebolt Gar Firebolt.
We're going to open the class settings.
Oh, and I just noticed we had a print string here.
I don't need that anymore.
And we'll go to class settings and it's based on aura projectile spell, but we can now base this on
Aura Firebolt.
Now that we've reparented it, we can just make sure everything still works.
It should.
Including our spell description.
It still works.
This is great because now we can have our firebolt specific description on the Firebolt class specifically.
So I'm going to close Aura projectile spell and here in Aura Firebolt in this video, we're concerned
with getting the manacost and the cooldown.
Now getting the manacost and the cooldown, I think is something that all spells should be able to do.
So I'm going to make some functions on aura gameplay ability to retrieve the manacost and the cooldown
and these can be protected.
And they can return floats.
So I'm going to make a git manacost function and it'll take a float called n level, but I'm going to
set its default value to one point F just in case.
We don't care about passing in a level for any reason.
I'm also going to have a get cooldown.
And this will take in a float called in level as well, but it'll be set to one by default.
Also now I'm going to generate definitions for these.
And now we need to start thinking about how we can get the manacost for any given gameplay ability because
here in Aura, Firebolt and Getdescription, I'd like to format this string to have the manacost inside
the string here.
So let's think about this.
Here in aura gameplay ability.
Just trying to organize my tabs.
How are we going to get our manacost?
Well, first of all, our manacost is a gameplay effect.
It's our cost gameplay effect.
Abilities have a cost gameplay effect that is special, right?
We can always get it if we call get cost gameplay effect.
So that's kind of good to know, right?
And get cost gameplay effect being a new gameplay effect.
Pointer has modifiers so we can access its modifiers by just getting modifiers from the gameplay effect.
But this is a pointer and not all gameplay abilities may necessarily have their cost gameplay effect
set.
So what we'll do is check that pointer.
We'll see if that cost gameplay effect is indeed valid.
I'm going to make a const.
You gameplay effect pointer called cost effect and it's going to be set to get cost gameplay effect
and I'm going to check it in an if statement first thing.
Now that I have cost effect, I don't need to call it again.
And I'm going to get its modifiers and I'm going to loop over them.
So I'm going to say for auto mod and cost effect modifiers and what is mod?
It's an gameplay modifier info.
Now an gameplay modifier info has a lot of things.
Look at this.
We can check its attribute and see if it's the specific attribute we're looking for, such as manacost.
Right.
So if we take that attribute, we can compare it with, say, u or attribute set double colon get mana
attribute.
So if we were to place this in an if statement, then we'd make it inside this.
If we looped through the modifiers on the cost gameplay effect, it should only have one.
But if that cost is a mana cost, well then we'll arrive here.
Now the modifier has a modifier magnitude and we know that modifier magnitudes can be one of several
types.
If it's a scalable float, we can get the magnitude without an effect spec.
Otherwise, lots of these functions require an effect spec, but there's one that we can call called
get static magnitude if possible.
That only requires a level so we can pass in n level here and a float by reference that it will fill
in with that magnitude.
But this only works if it's a scalable float with either a hardcoded value or a value scaled by a curve.
Tables curve.
So if that's the case, then we can get the magnitude.
So I'm going to create a float up at the top called Manacost, set it to zero and pass Manacost in here.
And if we make it this far, then we have the manacost.
We don't need to continue looping over any other modifiers that may or may not be there.
They typically won't in a cost gameplay effect, but we can still break out of this for loop anyway
once we've found the manacost.
And at the very, very end, we can return Manacost.
So now that we have this get manacost, which can be a const function.
So we'll make it const.
Like.
So then we can call git manacost from within or Firebolt to get the manacost.
So here in Aura Firebolt, we have our damage, right?
We can also get our manacost.
So I'm going to make a const float called Manacost and set it equal to get manacost and pass in our
level.
Now that we have manacost, we can format that into our string.
Now, here's the thing.
Look at our string.
This is running off the screen and it's terrible.
That's actually something that really irks me.
I don't like it going off that far.
I don't think anyone does.
So one of the things we can do is, first of all, we can put the string itself on its own line.
Tab.
Well done, Stephen.
You saved us two inches.
Right.
But we can also break this string up into individual parts, too.
All we have to do is put double quotes and writer will give me two for the price of one.
If I just hit that key to give me a quote, it gives me double quotes.
So if we close off the quotes and open up new quotes, then all this other empty space is ignored.
So really we could just break this up.
So we have the title, right?
And then if we wanted to, we could break the rest up.
We say launch is a bolt of fire exploding on impact and dealing.
I'm going to break it up there.
Percent fire damage with a chance to burn.
We can even break fire damage with a chance to burn in half.
This isn't going to create a new line in the widget at all.
It's just going to affect what we see here in the text.
So that's why this is so nice to be able to do.
And what I'd like to do is have each of these parameters on their own lines.
That'll make it easier to read.
So we have the title, it's firebolt.
And really, if we really wanted, we could have this be a member variable, a string on the gameplay
ability class if we really wanted.
That would save us about four seconds of typing every time we create a new description.
I don't care about four seconds of typing.
I'm going to be typing out descriptions for these anyway, so I'm just going to leave it just saying.
So we say launches a bolt of fire exploding on impact and dealing fire damage with a chance to burn.
Okay.
And we haven't implemented Burn yet any debuffs of that kind, but we could say X percent chance to
burn if we wanted to if we wanted to.
But we do have our level and I'm going to have level on its own.
Line two, we're going to say level equals and we'll do it like this.
And really, actually I think I'd like level and all the manacost and other stuff at the top above the
description.
So what I'm going to do is this I'm going to take this part of the string without taking the parentheses.
I'm going to cut it.
I'm going to paste it here and we're going to say level is level, right?
And then we can do the manacost part.
So we're going to say Manacost.
Closing it right away and say, no, actually this is going to be small and we're going to say Manacost.
Colon space and then we'll use the manacost.
We'll say mana cost.
We'll use that style and we're going to use percent F, but I don't want that many decimals.
I only want one decimal to the right.
I want to pad it to the right by one.
So I'm going to say percent point one f.
This will give me as many digits as I need to the left of the decimal, but just one to the right of
it.
That's what I want.
So now that we have the mana cost percent 0.1 f needs to have a float provided and that's going to be
our mana cost.
So we're going to put that right there at the very end.
Not cast cost like so.
And actually, these are in the wrong order now, Right.
I reordered them, so I have to be careful about that.
First is level that goes first.
Then Manacost is second.
Glad Ryder told me about this with these squiggles, then damage.
And we need to make sure that our commas and our parentheses are correct and this looks good.
So we have firebolt level manacost followed by the description here.
We could even make this easy on ourselves and say title deeds now, not deeds.
We can say details and then description.
We can even separate these parts with values, right?
So we're taking up more space, but it looks a little bit more manageable.
We have level, we have manacost, we have the actual description here.
We can even separate where we have those values.
It might actually be useful to just use our comments to indicate where these values are.
So we can say level here, we can say Manacost here, we can just put a comment here that says damage,
right?
We can do it that way if we want it to.
And that way we know this percent D is level, which is down here.
This one is Manacost, which is down here.
This one is damage which is down here.
Right?
So it's up to you how organized you want to get.
But the point is that we got our manacost and we haven't even actually tested that yet.
So why don't we just test this out before continuing?
Let's see if we can see that manacost in our Firebolt.
Oh, and get cooldown must return a value.
Which means I forgot to return something, didn't I?
Get cooldown?
We didn't implement anything.
I'm just going to return zero for now.
Zero F And with that, now we can test our work.
Okay.
I always hit open.
I don't think I needed to hit open.
I'm going to close Firebolt and I'm going to open my spell.
Select the Firebolt and we have level Manacost.
Oh, and by the way, Manacost is a negative value, but that is correct.
2.5 is the manacost for a level one Firebolt don't believe me.
Let's verify.
Let's go to ability system data CT cost.
Open the firebolt and look at this.
Level one is 2.5 and if we upgrade it to level two, we should see a -12.5.
Let's prove it to ourselves.
And let's spend a point and Oh, that's right, we can't because we only implemented it for if the level
is one, that's fine.
Just take my word for it.
Now, we did put new lines after Firebolt, but we didn't put new lines after level manacost so it looked
kind of ugly.
Let's put a couple of new lines, at least one, right?
We'll put a new line character.
After we show the level, we'll put a new line.
After we show the Manacost, we'll put two actually, and then we'll say the launches, a bolt of fire
deal and that's it.
We don't even need those two at the end there.
And we can also do this for the next level.
I'm just going to copy this and right here paste it.
Only it needs to say some other stuff, right?
It needs to say launches percent de bolts of fire.
So we're going to say we're still going to have the level, the manacost, but we're going to have launches
and we're going to have a percent de here.
And this will be the number of firebolts our number of projectiles.
Right?
So number of firebolts.
And that's going to come after Manacost.
Wow, these comments are really coming in handy.
So after Manacost, we're going to put what we had here, which was using F math min, taking the minimum
between level and our number of projectiles that goes right there.
And we get a comma at the end.
And with that, we have that percent d.
So launches percent de bolts.
So it needs to say bolts of fire exploding on impact and dealing damage, fire damage with a chance
to burn like so.
Just getting rid of that space there.
Cool.
So we're showing level Manacost.
Number of firebolts.
There we go.
Okay.
And this is if our level is greater than one, right?
But for next level description, we're going to have the same thing.
So first of all, let's remove this dead line of code.
And we'll take this return, copy it, and we'll use the same thing in get.
Next level Description.
Of course we're going to need to get that Manacost Right.
So let's get our float, our const, local variable manacost and we'll get it here.
Cool.
Now that's going to work.
We're going to test it very soon, but we also need to get our cool down as well.
I'd like to get that.
And we created a get cooldown function.
So how do we get that?
Well, for one, notice that we had a get cost gameplay effect you probably suspected and you'd be right
that we have a get cooldown gameplay effect and we can make a local you gameplay effect pointer and
set it equal to that.
So we'll say cooldown effect equals get cooldown gameplay effect.
So we have that.
We can place that in an if, actually.
And the cooldown gameplay effect is actually an effect with no modifiers, whereas the cost we put a
modifier to specify the magnitude of how much mana to pay and also specified what resource choosing
mana to pay and the cost cooldown effect.
Remember, we don't have any modifiers in it, it's just a duration based gameplay effect with a magnitude.
So if we take our cooldown effect, how do we get its magnitude?
Well, if you thought duration magnitude, you'd think right.
And if you take duration magnitude, you can get the magnitude with the same function that we used up
here, get static magnitude.
If possible, we can call that.
Why?
Because duration magnitude itself is also an gameplay effect modifier magnitude same as modifier magnitude
on the mod up here.
Now, if we get static magnitude, if possible, we can pass in in level now for our cooldown for Firebolt.
It doesn't depend on level.
We're not using a curved table or anything like that.
That's fine.
We'll still get that same value no matter what the level we pass in.
But this function will accommodate for the level just in case any future cooldowns depend on level and
we can pass in a float by reference that this function will fill in.
So we can make a float up here called cooldown, set it equal to zero and pass in cooldown here.
And by the end of the function we can return cooldown.
Simple as that.
We can also make this const.
We can go back and make its declaration const, which we have to do now.
And now we have a jet cooldown.
Cool.
Let's go back to Aura Firebolt and use it.
Let's make a const float called cooldown and call jet cooldown and pass in in level.
Well, just level.
And we have the cooldown.
So what we can do is show it.
We can show after level and manacost.
We can put another comment that says cooldown and we can use the small style.
We'll say cool down.
By the way, this should be in quotes.
And cooldown gets a colon and a space and after cooldown, we're going to say cooldown.
We're going to use the cooldown.
Style and we're going to use a percent F with 0.1.
So one space of padding just like we did for Manacost.
We're going to do that too.
And let's give it to new line characters.
And now Manacost can just have one.
And after Manacost we need cooldown.
So right here after Manacost we'll put cooldown.
And again, organizing it like this is super duper nice because when it was all one line before, it
was just a nightmare, right?
So this is really nice.
And we can add this to the other descriptions.
We'll put one right here after Manacost in the next one with cooldown down here, and we'll go to the
next level description and show the cooldown then as well.
Oh, and I'll remove a new line character so we don't have to two in a rows and we'll put cooldown right
here.
You could see if we were still using one liners, it would be really out of control.
And by the way, it goes level Manacost.
Cooldown.
Oh, I accidentally let autocomplete screw me over.
This should say cooldown, which means we need to get cooldown, don't we?
So we'll get the cooldown the same way we did in our previous function.
We'll get it right here and now.
We can use it.
All right.
Now we have cooldown.
The last thing before we test is I'd like our aura damage ability to have a simple damage function to
get damage, rather than going through all this trouble here.
And it can take in a gameplay tag for the damage type.
So one last function to make.
Let's go to aura damage gameplay ability and we'll make a float returning protected function that gets
damage.
So we're going to say float, get damage.
It could be get damage by damage type.
And it'll take a float called N-level and an F, Let's make it a const F gameplay tag reference called
Damage type.
And it's going to be a simple function, but I still want it to be a function anyway, and it's going
to do what this was doing.
So copy that.
Go back to or damage gameplay ability and paste it only instead of.
Damage.
Fire.
We're going to pass in the damage type here.
And we're going to get the value at N level and we should also do a check.
And make sure that damage types contains.
The damage type.
And if it doesn't, I want a specific message in our crash log.
I want it to say percent s Actually, we'll say gameplay ability percent s does not contain damage type.
Percent s and we'll have get name safe and pass in this and we'll have damage type dot to string and
of course get name safe needs to have the asterisk on it because this is percent s let's be pretty and
put some square brackets around these percent S's and to string this here needs an asterisk too.
Okay.
So we perform a check and then we can return this.
We're getting damage types at damage type, getting the value at the level and returning it.
So now we have get damage by damage type and we can use this an aura firebolt here.
Get damage by damage type passing in level and or a gameplay tags get dot damage fire boom and we can
take this line and replace it where we're getting damage down here.
And with that we can test all these changes.
So let's first of all see if we get a compiler error or not and then play test.
Okay, I'm going to open.
We don't need that cost.
Let's go ahead and just test out what we get.
Okay, so we have firebolt level one Manacost.
Oh, we forgot about the negative cooldown.
And I don't have I don't know why I put the slash n in there.
Maybe I'm just being hasty here, but cooldown.
It should be one of our styles.
It is.
So it's because of that slash in that shouldn't be there.
So two things.
I'm going to make sure that this is never negative and that our cooldown works.
And then notice that our text is above our border there.
We'll fix that too.
But let's go ahead and fix the manacost and make sure that it's never negative.
So we'll say F math abs, abs will get us some sick swole AB muscles.
No, it'll give us the absolute value and we'll put that down here for manacost down on this one.
But we do need to fix our typo for cooldown.
We have cooldown and this should just have a slash, not a slash n And we made the mistake.
We I say we made the mistake.
I'm shifting the blame onto you now.
It's my mistake.
And let's see if we have it down here.
We do.
So we don't want slash n, we just want slash there.
And I left it in there.
Look at what I did.
Okay, Let's see if that fixes it.
And if we have a positive manacost.
All right.
And pressing play.
There we go.
Everything looks good.
We have level one Manacost.
2.5.
Next level should be 12.5 cooldown, 0.5 launches a bolt of fire.
Does nine damage fire.
Bolt down here.
Looks like it should say next level.
Okay, we'll get that.
But level two Manacost 12.5 looks good.
Launches two bolts of fire dealing 17 damage.
It looks good.
All right, let's level up.
And we'll spend a point.
Now we see those values updated.
Looks great.
And next level is level three Manacost 25.
The cooldown doesn't change for this one.
It's constant, but we can see the damage.
Excellent.
Okay.
Now, I'm not going to close the editor to make this next fix.
We'll just get it next time we compile.
But for the next level description, I wanted this to say next level, not firebolt and that comes from
a copy paste laziness.
We call that copypasta.
We'll say next level.
Do we want colon or No colon.
Colon.
No, colon.
I want the colon.
All right.
So next time we compile, we'll get that.
That's not a big deal.
But before wrapping up, the last thing I'd like to take care of are these letters being on top of the
border.
I'd like them to be below.
Behind the border.
Now, if we put them behind the border, then this little scroll bar is going to be barely clickable,
if at all.
So we're going to need to put some padding on the right.
Let's do that now.
I'm going to open up my spell menu.
And we'll get our scroll box.
By the way, this doesn't need default text anymore.
That was pretty ugly.
So the scroll box itself can get some padding on the right, and whatever I do to the top one, I'm
going to do to the bottom one.
So let's get some padding on the right.
I'm going to try about 12.
That should do.
Okay.
And our border image can go on top of the scroll box.
In other words, my scroll box can be put in between the two images.
I'm going to do that for both of them.
So now the scroll box is behind the border.
But notice that we get a very interesting problem when that happens.
We now can't scroll.
And that's because this image is in the way.
And to fix that, we take the image and take its visibility down here and change it to non-hit testable.
Now, self in all children doesn't matter.
It doesn't have any children.
But we can just use self only and we'll do it for both of these.
So this one too, we're going to take that border and we're going to make it non-hit testable.
And then we should be able to still click and use that scroll box.
And we can.
And notice now that the border is covering up the text so the text isn't on top of it anymore.
And that's what I wanted.
Okay.
So it's looking pretty nice.
And just for grins, I'm going to level up and level up the ability and admire the nice work that we've
accomplished.
Everything is looking really, really good.
And with that we have descriptions.
And the only thing we need to do when we create new gameplay abilities is override their description
functions.
And if we just copy and paste this nice formula here with the multiple lines and we have these nice
functions to get this info, it's going to be pretty easy.
All we have to do is just kind of change the description a little bit.
The rest of this stuff can basically remain the same and less.
The gameplay ability is drastically different, but we'll cross that bridge when we get there.
All right, So excellent job.
I'm going to compile and we're going to continue in the next video.
I'll see you soon.