Welcome back.
So we just created some animations in equipped spells row and we're going to remove these nodes with
event construct.
We just wanted to see what those animations looked like.
I'm going to unhide both of them and just save that.
And close those textures I'm not using and go back and take a look at the spell menu.
Now, what we do when we click on a spell globe is we're enabling or disabling these two buttons.
And if we're selecting a spell globe that's eligible to be equipped and we click on the equip button,
we're going to want to show the user where they need to click next.
They need to click on an offensive spell globe If they are selecting an offensive ability and a passive
one, if they're selecting a passive one.
For this reason, abilities need to know whether or not they're offensive or passive.
They need an ability type.
And this is something that I'd like to keep set in our data asset.
So in Blueprint's ability system data, I want to go to ability info.
And for each gameplay ability I want a ability type tag.
So we're going to add that to our data asset ability info.
Now in addition to that, when we click on the equip button in the spell menu, we need a blueprint
callable function to call on the widget controller to tell it that we're equipping something.
And in addition to that, as soon as we click on the equip button, we'll be playing those animations.
So we have a couple things that we want to add in C plus plus, so we'll close the editor.
And we'll go ahead and open ability system data and get that ability info open and our aura ability
info struct now needs another gameplay tag.
It needs a ability type tag.
So let's go ahead and add that.
I'll put it after the cooldown tag and we'll call this ability type.
So we'll remember to set that for our abilities.
Now we're going to need a blueprint callable function in our widget controller class.
So let's go to UI, widget controller and open spell menu.
Widget controller.
We're going to add a blueprint callable function for when the equip button is pressed.
We'll call it equip button pressed.
And it'll just be blueprint callable.
So we can define this one.
And what is a button press going to do?
Well, for one, we need to tell the widget our spell menu that it needs to start playing an animation.
What we're really doing is waiting for the user to choose an equip selection.
Basically one of the slots down there that we want to equip to.
So we're going to make a delegate to broadcast for this very reason, and it's just going to broadcast
the ability type.
We need to know the type of the ability we currently have selected.
So let's go to spell menu, widget controller and declare a delegate.
So it's going to be a dynamic multicast and it'll just have one param for the ability type.
So we're going to declare dynamic multicast.
And we'll do a delegate one param and I'm going to call this f wait for equip selection.
And we can tack on signature to it.
And it's one param will be a const f gameplay tag and it's going to be the ability type.
So let's make one of these.
We'll add it.
It'll be right here.
And we'll call it wait for equip, delegate.
And we'll make it blueprint assignable.
So that's what we want to broadcast and equip button pressed.
And that means we need to get the abilities.
Ability type.
So to get the ability type, we need the ability info.
Luckily spell menu widget controller has ability info and we can get find ability info for tag and we
need to get the ability info for our currently selected ability.
So we use selected ability dot ability and once we have that ability info we can get the ability type.
So we can say dot ability type and we can store this in a local gameplay tag.
Const gameplay tag ability type.
Now that we have the ability type, we can broadcast our delegate so we can say wait for equipped delegate
dot broadcast ability type.
Now, in addition, I'd like to have a boolean that we can set to true here so we know we're waiting
for the user to select and equip selection.
So I'll make a private boolean called Be Waiting for equip Selection.
It'll be false by default, but as soon as quit button is pressed, we'll set it to true.
So be waiting for equip selection is true.
Now all we need to do is listen for that delegate and call equip button pressed.
So let's compile and go back to the editor and it looks like I'm missing.
Oh, right.
I should have a comma right there.
Okay, let's try that again.
Okay, so we have a couple things we can't forget.
Before I forget, I'm going to go to ability info and set the ability type to these two abilities.
They need to be in abilities type offensive.
They're both offensive abilities.
So abilities type offensive and we can save and close out of that.
Now next, our spell menu needs to listen to a delegate.
So right here, where we're binding to a delegate already on the spell menu.
Widget controller.
I'd like to bind another one.
Now, this stuff here, this could be easily collapsed to a function.
We're setting description texts, right?
So I'm going to right click collapse two function and just call this set descriptions.
Mike.
So that looks good.
And after that, we're going to get BP spell menu, widget controller, and we're going to look for
that.
Wait for equip delegate.
And this one, I think, can go down on a new line right there.
So I'm going to add a new pin.
And just make sure these don't get out of hand.
So this will now go into the then three.
And then right here, we can decide what happens for our weight, for equip, delegate.
Now our equip spell row has our offensive selection boxes.
With animations, offensive selection, animation, passive selection, animation and so on.
And as soon as we have broadcast this delegate, we've broadcast the ability type for our currently
selected ability and we can check to see if that ability type is offensive or passive.
So what I'd like to do is handle what we do in response to this in a function called on wait for equip.
So let's make that function.
We'll call it on wait for equip and it'll take a gameplay tag as an input.
So we'll change this input type to gameplay tag.
And it's going to be ability type.
We'll compile and save that, and then we'll just call this nice little function on wait for equip and
pass in the ability type.
So what do we do in on wait for equip?
Well, first I want to check to see if the tag is the offensive ability type.
So we're going to say matches tag exact.
Or match his tag with exact match, and I'm going to see if it's equal to abilities type offensive.
Now, whether or not it is is just going to be a Boolean variable I'm going to promote this to it'll
be a local variable called is offensive.
So if the gameplay tag is offensive, so will our boolean be?
Now we can branch off based on this.
But before we do, no matter which one it is offensive or passive, I want to disable the equip button
and the spell point button until we're done waiting.
So we're going to take button equip.
Actually, we don't need to take those buttons.
We have a function that can set buttons enabled.
We're going to call that and set them both to false.
And after that, now we can branch based on is offensive.
So is offensive.
Will be true if it's the offensive ability type.
And if that's the case, we want to take our equipped spell row and get its offensive animation.
So get offensive selection animation and play it.
So we're going to take that and use play animation.
And for loops to play, we're going to use zero because we want this to loop.
Now, on the other hand, if it's not offensive, then we're going to play the passive version.
So we're going to get equipped spells row.
And get passive.
Selection animation, and we're going to play that.
Instead.
Okay, so that's it.
So that handles the delegate.
We're going to go ahead and comment this.
We'll say wait for equipped delegate.
And with that, we just need to call the function.
That we created for when we press the equip button.
Equip button pressed, it's called.
And we can do that right after our spend point button pressed delegate.
So we're going to get our button equip.
We're going to get its button widget.
So get button.
We're going to bind to Onclicked.
So assign Onclicked.
We'll hook that up.
And we'll get our spell menu, widget controller and call equip button pressed.
Just like that.
And this gets a comment as well.
It says equip button pressed.
Okay, so now when we press the equip button, we should be able to see those animations.
Now by default, we see them anyway.
But if I press the button, nothing happens.
And that is because if we look at our play animation nodes, they don't have a user widget object reference.
So we do need to pass one in.
That's going to be the equip spells row.
So let's make sure to pass that in to Target before trying to play the animation.
So if we click, then we see that we play the animation.
Now we should set the render opacity to both of these to zero by default.
So we'll go ahead and do that.
So we don't see those big ugly boxes.
We only want to see them when they're animated like so.
So now we have something showing us we need to click right here.
Now notice that we can't click right here anymore.
What's giving me the hint that I can't click on these buttons is they're not highlighting and I'm moving,
right?
So what I need to do is take both of these and set their visibility to.
Not hit testable.
Both of them.
That way we can still click on those buttons.
Perfect.
Now, we can't really test the passive abilities right now because, well, we don't have the ability
to equip them.
We don't really have any valid ability tags for them.
But we do have these and if we go ahead and level up.
And we take this eligible ability and spend a point on it.
Well, now we can click on equip for this one.
So we have the ability to equip.
Now, the last thing I'd like to handle is canceling this animation.
If we say select a different ability.
So basically when we first select an ability.
Or if we deselect an ability.
So on selecting and deselecting an ability, we should cancel all animations if they're playing on this
row here.
So for that I need another delegate that also takes in the ability type, just like wait for equip delegate.
We're going to make one to stop waiting for equip.
So it'll also pass through a gameplay tag for the ability type.
So let's go ahead and make one of those.
And we can just use the same signature, wait for equip selection signature, and we're going to call
this one stop waiting for equip delegate.
So we're going to call it stop waiting for equip delegate.
And we need to broadcast this in a couple situations.
One is in Globe Deselect, we need to broadcast this and we need to know what the ability type is before
we broadcast it.
So we need an gameplay tag called ability type for the ability type.
And it's going to be our selected ability type and we can get our ability info, data asset and call
find ability info for tag using selected ability dot ability.
And from that we can get the ability type.
So now that we have the selected ability type, we can broadcast stop waiting for equip, delegate,
passing in selected ability type.
So we very much need to know that ability type when we want to stop playing an animation, right?
Now we also want to do this same thing when we're selecting one of our spell globes.
So right here in Spell Globe selected, I want to do this very same thing.
So I'm going to paste these two lines, except I really only need to use the ability tag so I can find
ability info for ability tag.
We can get its ability type here and we can broadcast stop waiting for equip, delegate passing in that
ability type.
So if we're selecting a different ability, we need to actually hit equip before we go and play those
animations.
In the meantime, we stop playing them.
So let's handle this delegate in the spell menu.
So back to the spell menu.
We're going to bind now to this one.
We can do it right after wait for equip delegate.
So we'll get the spell menu.
Widget controller.
And a sign Stop waiting for equip delegate.
Now this will be similar to on wait for equip.
In fact, I want to play those animations in our equip spells row to hide the offensive box and the
passive box based on the ability type passed in.
So I'm going to make a function for stop waiting for equip delegate.
So instead of on wait for equip, we're going to have a new function called Stop waiting for equip.
This will take a gameplay tag.
It's going to be the ability type.
And we're going to check if it matches tag exact offensive.
So abilities type offensive and this will also have a local variable called is offensive.
Now for this one, if we have any animations playing, we want to stop them on the equipped spell row.
So we're going to get the equipped spell row and we can call stop all animations.
And after that we can use a branch.
Checking is offensive.
And if it's true, we can get our equip spells row and get hide offensive box and play that animation.
But if it's false, we'll get hide passive box.
So we'll take that widget animation and call play animation on it and we have to pass the widget itself
in.
We only want to play one loop this time, so if it's an offensive ability type, we're going to hide
the offensive box.
And if it's a passive, we're going to hide the passive box.
So we'll just play this animation once and then stop.
And that's going to fade it out.
So we're going to call stop waiting for equip and response to that delegate.
And we'll pass in the ability type.
Let's just see if this works.
Okay, right away.
I'm seeing that we do play it when we select it.
We should only play it if something is currently equipped.
Right.
But if we press the equip button and we have that animation going and we select something else, it
stops it.
And if we have it going and we deselect the self, it also stops it.
So we just need to make sure we don't play the animation if it's not already playing.
Luckily we know when that is.
It's when we're waiting for an equip selection.
We even have a boolean for it.
So what we'll do is every time we're about to broadcast, stop waiting for equip delegate.
We'll only do so if we're currently waiting for an equip selection.
That's the only time that we're playing those animations.
So we're going to wrap them in if be waiting for equip selection and that's going to be where we broadcast
it here and spell Globe selected and where we broadcast it in Globe Deselect.
So right here, we'll only do this if we're waiting for equip selection.
So if be waiting for equip selection, then we'll broadcast these.
Now, in addition to this, we should also set this Boolean back to false so we can say be waiting for
equip selection equals false and both of these cases.
So we're going to stop waiting for equip, delegate, and we're also going to set that Boolean to false.
And we can test this out.
We'll go ahead and select the Firebolt and click on Equip.
We see the animation, we can deselect it.
It goes away if we select it again, it does not play until we click equip again and then deselecting
it.
It goes away.
If we have the equip animation going and we select something else, it goes away and doesn't come back.
And finally, let's go ahead and just.
Get this one.
There we go.
So I'm going to have it playing and select this one over here.
Okay.
We'll spend a point on it.
We'll click equip.
We can cancel it.
Okay, We're getting the behavior we want.
Excellent.
We're one step closer.
So now that we can click on Equip and it's waiting for us to click down here, the next step is to handle
what happens when we click down here.
And that's going to involve reassigning the input tag for an ability, if it has one, or assigning
an input tag to an ability for the first time and actually making that ability have the status of equipped
if it's not already.
So that's the next thing we need to do and we'll do that next.
I'll see you soon.