Welcome to your next quest.
I'd like you to show the spell points in our spell menu.
We already have spell points and we're already updating them.
It's just up to us to show them in the menu.
And I'd like you to make sure they update when leveling up.
So that's another important aspect of it.
So pause the video and conquer your quest.
Okay.
So what I want is to show my spell points, which means I need them to start off at the correct value
and update every time they change.
So I'm going to go back into C plus plus into my spell menu widget controller.
And here is where I need to do something.
Now for broadcast initial values.
I'm going to need to get the spell points from my player state as that's where they are.
Now I can get or a player state this get aura PS and associated similar functions are very convenient
here.
So get RFPs can allow me to get my spell points and of course or a player state now exists in the spell
menu Widget controller CBP file.
Now what do I do with the spell points?
Well, I'm going to need a delegate I can broadcast my spell points with, so I'm just going to comment
that out and set it aside for a second and take a look at what I've got in my parent class in UI widget
controller or a widget controller.
Why?
Because I have a really nice delegate for broadcasting these integer stats on player stat change signature.
I'm going to put one of those in my spell menu widget Controller.
So in spell menu widget controller, I'm going to go into the header file and just stick one of these
in here on player stat change signature and I'm going to call it spell points changed.
I'm going to make it a new property with Blueprint assignable.
That way we can assign it in blueprint and I'm going to broadcast it right in broadcast initial values.
I'm going to say spell points, change broadcast and pass in the spell points that I get from Aura.
PS the Aura player state.
So broadcasting the initial values was quite easy.
Let's see if it's just as easy to bind a callback or a lambda for when it changes.
Now I'm going to just go ahead and close other tabs.
All but this one and go into my player folder, into aura player controller.
No, not player controller or a player state.
And it looks like we have some delegates broadcast here too.
We have on spell points change delegate.
Let's see if we're actually broadcasting those here in Aura Player State dot CP And it looks like we
are broadcasting these thanks to having already taken care of this stuff.
We have add to spell points and then we're broadcasting the delegate.
I don't think there's even a setter for spell points, so we're pretty sure that on spell points change
delegate is broadcast, so spell menu widget controller can bind to it.
So I'm going to call get Ora plays for Player State.
I'm going to get that spell points change delegate.
It's called on spell points change.
Delegate And I'm going to add a lambda, so let's add a lambda to it.
And what do I need to broadcast?
I just need to broadcast my spell.
Points change delegate.
So basically the same thing I did up there for broadcast initial values.
Now we need to capture this if we're going to broadcast that delegate.
And with that, we now have our lambda bound.
Now we just need to test it out and see if it works.
Okay.
It looks like I was a little hasty here.
Hopefully you weren't this hasty.
We got this error tuple invoke no matching overloaded function found.
Well, that's because we're binding a lambda to a delegate not designed for a lambda or function with
this signature because spell points change delegate is supposed to broadcast an int, which means I
didn't need to call get spell points in here.
I can just receive the int in my lambda.
It takes an int 32 called spell points and I can just use that right here.
So easy mistake to make, but that should fix it.
So back here in the editor.
My spell menu now needs to handle the broadcast of that delegate for spell points.
So here in spell menu, I can open up spell menu.
And right here, this is my framed value.
I'm going to rename it now to framed value underscore spell points and make it a variable.
So now that it's a variable, we'll come back here into our event graph and we need to do something
for our spell points.
And before broadcasting initial values, we need to get our BP spell menu widget controller and we need
to assign on spell points change or just spell points changed.
It's called.
And I'm going to do this before broadcasting initial values.
So we'll add a pen and I'm going to hold control and click this wire and move it to that one.
Isn't that amazing?
And I'll go ahead and stick this one in.
And when spell points change, we need to update our frame value.
Spell points.
So we're going to get that.
And from framed value spell points.
I'm just going to type text and we're going to get text block value.
We're going to call, set, text on it.
And we're going to pass in the new value to this.
And get a two text integer here.
Let's just see if that works.
And we have one spell point.
I think we started off at one.
I'm going to go to the player stage or a player state and see what Yes, we started it off at one spell
point strangely.
That's cool.
And I'm going to level up and see if I get another one.
All right.
Leveled up.
And we have to I'm going to level up again.
There we go.
And I have three.
So it's working as expected.
I didn't expect to start off at one.
I don't know why I started it off at one.
Maybe I said why at the time, but that's okay.
Maybe it'll be easier to test.
The next mechanics will be implementing if we start off with a spell point so that we can spend points
right away.
But either way, our spell points are working.
I'm actually going to relaunch the editor and make sure it works in multiplayer as well.
We'll test it on the client.
Okay.
So setting number of players to two.
Checking it out on the client.
We start off with one spell point.
Let's level up.
We have to spell points.
And then another thing I'd like to really quickly check again is if we level up with those menus open.
So I'm going to go back to my overlay WB overlay and disconnect the call to set input mode only.
And I'm going to level up.
We'll just try the client first with the spell menu open.
We went up to two.
We went up to three.
That looks good and we can try on the server.
I have no reason to think it wouldn't work, but let's try.
We went up to too.
Perfect.
Okay.
I have the feeling I'm going to be doing this many times for testing, but that's okay.
So our spell menu has now taken care of updating spell points when they change.
Excellent.
I'm going to collapse this to a function called.
Spell points changed.
Okay.
And I'll go ahead and comment this on spell points changed.
And now we have spell points in our spell menu that look correct.
I'm going to set this back to one player.
Perfect.
That looks a lot better with the one that 99 or whatever it was looked really awkward and weird.
So this is great because now, as soon as we become eligible for one of our abilities, it's going to
look like this and we should be able to spend a point on it.
That means I'm going to want to click on it and select it and show it selected.
And then if I can click Spend point, it should upgrade it.
If it's eligible, I want it to become unlocked and show its color.
And then after that, I'd like to be able to select it and click, equip and choose a slot to equip
it to.
So lots of really cool things coming up.
Excellent job.
I'll see you in the next video.