Welcome to your next quest.
In this quest, you're going to implement cost and cooldown for Arcane Shards, so make sure that you
take all the steps into account and then playtest to make sure that your cooldown is reflected in the
HUD as well.
So pause the video and do this now.
Okay, so cost and cooldown.
We need to do a couple things.
For one, I'm going to open up my CT cost because I have curves for both Firebolt and Lightning Electrocute.
Now at this point I'm getting a bit tired of using constant values.
I'd rather use a curve.
So what I'm going to do is just make a new CT cost, and it's going to be a curve table with a different
interpolation type.
So I'm going to go to miscellaneous, create a curve table and it's going to be cubic.
We'll go ahead and create it.
And I'm going to call this CT underscore spell cost.
And I'm going to create curves.
Now taking a look at Firebolt.
We start at 2.5 and at ten we're about 35.
So in spell cost I'm going to rename the curve to Firebolt and add a point.
And this first key is going to have at level one a cost of 2.5.
And we'll go ahead and add another key.
And this is going to be at level 40.
Now I'm going to try a value of say 25.
And see what my curve value is at level two.
It's at 1.5.
And over here I see at level two it was about three.
So I can increase that point here at level 40 to about 40.
And now at two the cost is two.
And if I increase it again to about 50 now at level two my cost is about 3.5.
So we're just about there.
And I can even tweak the shape by making it auto.
Now at level two it's about 2.5 and I can make it increase a little bit faster.
And now at level two, it's about 3.13.06.
So the curve lets me adjust things a little bit easier.
So I kind of like the curve better.
I'm going to also add a curve for electrocute.
Call this electrocute.
We'll add two points.
The first one starts at level one and its mana cost will be one and at level 40.
Let's see what our CT cost has.
It had a mana cost of seven at level ten?
So at level 40 I'm going to go up to about 28.
And at level ten the value is about seven.
Perfect.
So I'm going to go ahead and make this auto and make it a little less snaky.
So almost more linear there and I'll save that.
And finally I can add a curve for arcane shards.
And we'll add two points.
First will be at level one.
What's our mana cost going to be for arcane shards?
Well that depends.
We can set it off at a higher value because this is a little bit more powerful of a spell.
I'm going to set it with a mana cost of ten, and at level 40 we'll have a mana cost of, let's say
85.
So it looks like this.
I'm going to make it a auto curve.
And just like the others, I'm going to straighten it out just a bit and save that.
And now we have CT spellcast instead of CT cost.
And I'm going to use this in all of my spells.
So going back to electrocute I can take a look at my cost gameplay effect class.
I can browse to it and open it and scroll down and change my CT cost to CT spell cost.
And I still have to select a curve.
It's going to be electrocute for the electrocute spell.
I'm going to save that and then I'll go into my abilities fire, open Firebolt and get my GE cost Firebolt
and change its cost as well.
So changing it from CT cost to CT spell cost, choosing Firebolt.
And we're done there.
And I'm going to go over to arcane.
And I don't have an arcane gameplay cost okay.
So I'm ready to make that.
Before we do that though, I'm going to browse to CT cost, close it down and go ahead and just delete
CT cost.
We're not using it anymore.
Now we have spell cost which is better.
And I can go ahead and close out of CT spell cost.
And here in Arcane Shards in its folder I'm going to make a new gameplay effect.
So gameplay effect, we're going to make this and call it GE cost Arcane shards.
We'll open this up.
And just like the other costs, it's going to be an instant and we'll change the mana attribute.
So scrolling down, we're going to leave it at instant.
We're going to add a modifier.
It's going to modify mana.
It's going to add to it.
We're going to have a scalable float.
We're going to set it to negative one scaled by CT spell cost, choosing arcane shards.
And that's it.
We just have to go into arcane shards and go to class defaults and set its cost gameplay effect to cost
arcane shards.
Now for cooldown.
Now cooldown is going to be its own gameplay effect, so we'll make one.
And I'm going to call this GE cool down arcane shards.
I'm going to open it up.
And this one is going to have a duration.
So we set the duration policy to has duration.
And we're going to just hard code a duration for arcane shards.
And I like arcane shards to have a cooldown of about let's say six seconds.
I'd like this to have a longer cooldown.
Now, the cooldown effects have a specific quality, and I'm going to go back to one of our others.
Let's go to Firebolt.
GE cooldown Firebolt just to remind you that even though they have no modifiers, they do have a granted
tag and that's a cooldown tag.
So we need a cooldown tag for Arcane Shards.
We can just add one in project settings and go to Gameplay Tags.
We can go to cooldown and we don't have an arcane sub category, so we're going to make one.
So we're going to add cooldown Dot arcane Dot Arcane Shards.
And now that that tag exists, we can close project settings and go to cooldown, not Firebolt, but
Arcane Shards and add to its granted tags.
And we're going to add cooldown arcane arcane shards.
And with that, we just need to set the cooldown effect on the Arcane Shards ability all the way down
at the bottom.
It's going to be cooldown.
Arcane Shards compile and save.
Now that's almost everything.
The only thing is, for our HUD to work, we need to make sure our data driven systems understand the
cooldown associated with Arcane Shards.
So we have to go to ability system data, ability info, and we have to find arcane shards.
Here it is.
We need to give it its cooldown tag and that's going to be cooldown arcane arcane shards.
With that, we can test this out.
I'm going to press play, I'm going to hit one and I'm going to.
Cast.
Arcane shards.
All right, so I'm getting a big fat error.
Where we're calling store shard spawn location.
All right.
So it looks like we're.
Doing something wrong.
And of course.
If I go back to event graph.
We're using Maxnum shards right here.
But what about when we're getting our number of points right here in git ground points?
We're passing in zero, so we're not getting any ground points.
We actually have to pass that number in.
Maximum shards.
And in fact, we shouldn't use maximum shards, should we?
We should calculate how many shards to spawn based on our level.
So before we get our points from the point collection, get ground points, let's just move these forward
a bit.
And I'm going to get maximum shards.
And we're going to call min.
Integer.
We're going to get the minimum between maximum shards and get ability level.
Now we'll bring that in and we're going to promote this to a variable called num shards.
And we're going to use this.
We're going to use it and get ground points.
And we're going to use it down here.
Instead of the max.
That's going to fix that.
Okay, so we're at level one.
We're spawning one shard.
Perfect.
Okay.
And with that, we're just about ready to test.
The only thing is, we need to commit our cost and our cooldown.
Now, in arcane shards, where do we want to commit our cost and cooldown?
Well, I'd like to commit the cost the first time that we summon a shard.
In other words, right here is our set timer, and we spawn the first shard.
I'd like to commit the ability cost here.
So I'm going to call commit ability cost.
And we should see our mana get spent for this.
Now.
We shouldn't cast the spell at all if we can't afford the cost, and we can check the cost, we can
say check cost and check ability cost checks to see if we can afford the cost, but it doesn't apply
the cost.
We can do that right at the beginning.
So we're going to go all the way up to here.
Check the ability, cost and only if we can afford the ability cost should we do anything.
And we can test that.
So we'll have this branch here.
Will commit the ability cost when we first spawn a shard, and in fact we can commit the cooldown at
this point as well.
Or we can wait until the last of our shards is spawned and commit the cooldown and end the ability there.
I'd like to do that there, so I'm going to remove this delay.
That was just a hack and we're going to destroy the point collection.
Commit the cooldown.
So we'll say commit ability.
Cooldown.
And we can end the ability here.
Let's see how this works.
So there's our cool down.
Can't cast it.
There we go.
Now, just to test out what we did at the beginning of Arcane Shards.
Namely, check the cost.
We can see what happens if we don't have enough mana here.
So to do that, I'm going to go to cost arcane shards.
And scale this by say.
Negative ten instead of negative one.
Now we have just about zero mana.
And if I try to cast the spell once the cooldown is over, I can't cast it.
I can cast my other spells, but I can't cast this one because I can't afford it.
So that's how we can prevent casting inability when we don't have the mana.
I'm going to go back to the cost for arcane shards and set that back to negative one, as I believe
that's a little too expensive.
And with that.
We now have cost and cooldown for Arcane Shards, and Arcane Shards has a bit more of a cooldown than
the others.
Now I can level up.
Oops, I got stunned.
I can't move.
I need to move away.
Okay?
And I'm going to level up my arcane shards.
Now I see it's level two.
And I'm going to cast it.
And we get two shards.
Sweet.
I'm going to level it up again.
And cast it.
And we get three shards.
I'm going to level it up again.
And cast it.
Perfect.
Excellent.
So Arcane Shards is officially done.
Awesome job.
I hope you're ready for another exciting ability.
I'll see you soon.