Welcome back.
Now we just cheated and gave this goblin a whole bunch of XP that we can gain when we kill it, and
we saw that when we got a triple level up, we only got one spell point as a reward.
We're going to fix that.
And that also indicates that we probably should have more attribute points.
If we kill this thing, we should probably get three attribute points where we only get one.
So let's go ahead and fix that issue now.
So I'm going to close out of the editor.
And this spell point awarding business is done in our attribute set.
Right.
So we can go into the private ability system folder or an attribute set and search for where we're giving
spell points.
I'm just going to search for spell points and that's in handle incoming XP.
So based on how much XP comes in, that's when we know how many times we've leveled up.
In fact, we have that here.
NUM level ups.
And if it's greater than zero we're leveling up.
But here's the folly.
If I leveled up more than once, it doesn't really matter because I'm calling add to attribute points
passing in our attribute points reward, which we're calculating here from the current level.
So that's not exactly what we want to do.
We want to accumulate our spell points and attribute points for every single level that we just leveled
up.
We want all the credit here.
Right?
Then we can add to player level.
We can add to attribute points, add to spell points.
So we need to do this a little bit differently.
Now add to player level.
That's fine.
We're adding the number of level ups.
But our spell points and attribute points rewards I'm going to move those down below that because those
need to be a little bit different.
So we know the number of level ups I think we should do a for loop this many times.
If we leveled up three times, we should do a for loop with three iterations and find out the attribute
points reward for each level that we've surpassed.
So I'm going to make a for loop here.
And I'm going to say for int 32 I equals zero we'll start off at zero.
We'll have I is less than num level ups.
And plus, plus I or I plus plus whatever is your style.
And we're going to add two spell points reward and attribute points reward.
So I'm actually going to change these to be non-const and start them off at zero.
So attribute points reward is zero, spell points reward is zero.
And we'll go through each level that we've leveled up.
So we can say what's our current level before we've added to it.
Right.
Current level plus I.
The first time it'll be zero.
So we'll get the spell points reward for the current level.
And then when I is one we'll get spell points reward for the current level plus one and so on.
So here's what it can look like.
We can take our spell points reward and say plus equals.
And we can take our AI player interface.
And we can call execute get spell points reward.
And this requires first of all props dot character.
Right.
That's the source character.
And then what level are we evaluating at.
We're evaluating at current level plus AI.
So we'll do this num level ups times.
So we get the reward for the current level before we leveled up.
And then the next one and the next one.
However many times we have leveled up.
And we'll do the same thing for attribute points reward as well.
We'll take attribute points reward plus equals.
We'll say AI player interface execute.
And this time we're going to get attribute points reward using props dot source character.
And we're going to use current level plus AI.
So now we have the right number of spell points and attribute points.
And we're going to add to those down here.
All right.
So that fixes that problem.
At least it should.
We need to test it though.
Let's go ahead and compile and launch.
And then we'll see any other issues we have if there are any.
Okay, so we're back in the editor.
Let's try a multiple level up.
I'm going to press play.
I'm in multiplayer here.
I have zero spell points.
I'm at level one going to kill this thing.
I'm now at level four, so I've leveled up three times.
Look at that.
I have three spell points.
I even have three attribute points.
I can spend those and I can spend my spell points.
I can buy this one, I can buy this one, and I can buy that one.
And we can go ahead and equip them.
And it looks like it's working in the HUD.
But since we're in multiplayer, why don't we just see what happens in multiplayer?
So I'm going to go ahead and level up.
And I have spell points, I'm going to spend a point and equip it.
Oh, what's going on here?
There's an issue.
So when I close it and open it though it's there.
So something isn't working.
Something is, but something is kind of amiss.
So we need to find out what's going on there.
Now whenever we click on one of these buttons in our equipped abilities row, we're calling a blueprint
callable function.
And that blueprint callable function, if we go to our UI widget controller, spell menu, widget controller
and search for globe.
We have spell row globe pressed and this is calling Server Equip ability and server equip ability is
on the ask our ability system component.
And it's a server RPC.
So it's executed on the server.
So I'm going to close spell menu Widget controller and go back to Aura Ability System component in the
cpp file and look for Server Equip ability.
Now here in Server Equip Ability we're gathering some information here.
We're clearing abilities with this slot.
We're clearing the slot of this ability.
We're changing ability tags marking the ability spec dirty.
But really the only reason our spell menu catches wind of all these changes is with client equip ability.
Client seems to imply a client RPC, but when I see the definition of client equip ability, I don't
see an underscore implementation here, which seems to suggest that this is not actually an RPC.
Let's go back and search in the header file for client equip ability.
And sure enough, it's not even a client RPC, so that would help if it were actually an RPC.
And then our client could catch wind of it.
So we're going to add a new function with client reliable.
As these equip spell functions are extremely important.
And with that, we can go back and make sure client equip ability has implementation.
And now it's a proper RPC.
It should be executed on the client when it's called from the server.
So with that we can restart.
So I'm going to make sure that I don't have any unsaved changes.
It looks like I don't.
And from writer I can just hit the rerun which is going to close out of the editor and compile and launch
again for me.
So rerun is a nice little feature.
So again, I mentioned this in a previous video, but rerun is a nice little feature.
Okay, so we're back and I'm going to press play first thing and open up my client window and level
up.
Okay.
Leveled up.
And let's see what happens if I spend a point.
Hit equip.
Select a passive slot.
There we go.
It's in there.
It's looking right.
And we can do the same thing for another ability.
We can even take the ability and push out the other one.
We can buy this ability and we can equip it there.
Our HUD is working.
So as far as the HUD for our passive abilities, things are working right.
This is looking good.
Now here's the problem.
Our passive abilities are not abilities that we're going to activate with our input.
Left mouse button.
Right mouse button.
One key.
Two key.
Those are for offensive abilities.
Our passive abilities, at least the way that I've designed this game project, are going to be activated
when we equip them right down here in our equipped abilities row.
That's how I'd like my passive abilities to work.
That's how most passive abilities work in RPG games, so you don't click while you're running around
in the world with a certain button and say, activate my passive ability.
No, that would be an offensive ability.
Passive abilities are different passive abilities you select in the menu once they're selected.
Once they're equipped, they become active and they stay active.
Now, when do they stop becoming active?
When you push them out of the row.
In this case, it's a column of two abilities.
So say I have the red and the blue here.
They're active and I decide I want the yellow.
So I'm going to click equip and select the red.
Now the red should be deactivated.
We should end that ability.
And the yellow ability Halo of protection it's called should be activated at that point.
That's the behavior that I'd like.
And that's what we're going to implement in the videos to come.
So we'll do that next.
I'll see you soon.