WEBVTT

00:07.540 --> 00:09.070
Welcome back.

00:09.190 --> 00:13.840
So our spell menu is coming along, but we still have a few things to change.

00:14.050 --> 00:20.140
Now I'm going to take my nav mesh bounds volume and move it forward so my enemies can't come at me while

00:20.140 --> 00:27.190
I'm testing as it's a little distracting when they're swinging their spears, thrusting them at me while

00:27.190 --> 00:29.110
I'm trying to test something in the HUD.

00:29.290 --> 00:37.000
So I'm going to go ahead and just do that little fix so even I can attack them, but they can't come

00:37.000 --> 00:38.530
to me and that's what I want.

00:39.350 --> 00:39.710
Okay.

00:39.710 --> 00:43.040
So let's talk about what we want to do in this video.

00:43.040 --> 00:45.710
We want to handle these two buttons.

00:45.710 --> 00:49.460
At least we're going to handle enabling and disabling them.

00:49.460 --> 00:52.180
And that's going to depend on a couple factors.

00:52.190 --> 00:58.550
So the first thing is, when I open my spell menu, I'd like them both disabled by default.

00:58.580 --> 01:03.740
That's because if I don't have a spell selected, neither one should be enabled.

01:03.740 --> 01:08.690
I shouldn't be able to spend a point unless I have a spell selected now.

01:08.690 --> 01:15.080
As soon as I click and select one, then we should see some changes depending on the scenario.

01:15.380 --> 01:20.720
Now I just clicked on my firebolt spell which is currently equipped now.

01:20.720 --> 01:27.080
If I have an equipped spell that I've selected, I'd like to be able to spend a point on that equipped

01:27.080 --> 01:32.780
spell and that would allow me to upgrade that spell to the next ability level.

01:32.780 --> 01:40.230
So when I click on an equipped spell, this button should be enabled on top of that, I'd like to be

01:40.260 --> 01:43.020
able to reassign that spell to a different input.

01:43.020 --> 01:45.480
So my equip button should also be enabled.

01:45.480 --> 01:47.610
When I select an equipped spell.

01:47.640 --> 01:51.000
If I click on equip, then I want to be able to reassign it.

01:51.000 --> 01:55.350
So both should be enabled when I click on an equipped spell.

01:55.380 --> 02:01.290
Now, when I click on a spell that's locked, or at least a spell globe that has the locked icon showing,

02:01.290 --> 02:03.690
then spend point should be disabled.

02:03.690 --> 02:08.700
We shouldn't be able to spend a point on a locked spell and so should equip, equip should be disabled

02:08.700 --> 02:09.420
as well.

02:09.420 --> 02:17.070
So those are the probably the two easiest cases for whether or not we should enable or disable the buttons.

02:17.070 --> 02:19.080
But we have other scenarios too.

02:19.110 --> 02:21.150
For example, if I level up.

02:23.030 --> 02:27.080
Then all of a sudden I have a new type of icon.

02:27.110 --> 02:31.970
This spell is actually in the eligible status.

02:32.000 --> 02:33.760
It's not equipped.

02:33.770 --> 02:35.960
It's actually not even unlocked yet.

02:35.990 --> 02:37.310
We can't equip it.

02:37.310 --> 02:42.410
So a eligible spell should not have the equipped button enabled.

02:42.410 --> 02:47.870
It should still be disabled, but we should be able to now spend a point on it to unlock it.

02:47.870 --> 02:50.420
So in that case, spend point should be enabled.

02:50.420 --> 02:56.990
Right now there's another scenario that we can't really test yet, and that's for an unlocked spell.

02:57.140 --> 03:01.030
An unlocked spell is going to appear just like an equipped spell.

03:01.040 --> 03:04.520
It's going to be colorful, not grayed out for the background.

03:04.520 --> 03:11.150
But even though it's not equipped, we should be able to still spend points on it to upgrade it and

03:11.150 --> 03:14.020
we should be able to equip it because it's been unlocked.

03:14.030 --> 03:18.470
So that is the scenario for an unlocked spell.

03:18.470 --> 03:25.620
We should have equip and spend point buttons enabled for an unlocked spell so we can upgrade it and

03:25.650 --> 03:26.820
or equip it.

03:26.820 --> 03:31.560
So unlocked and equipped should have both buttons enabled.

03:31.560 --> 03:37.110
Locked means no buttons enabled equipped means both buttons enabled unlocked.

03:37.110 --> 03:40.650
Also both buttons enabled and eligible means.

03:40.650 --> 03:44.550
We should be able to spend a point on it but not equip it.

03:44.550 --> 03:50.610
So I'm going to give you a quest to handle enabling and disabling the buttons.

03:50.610 --> 03:55.890
But first we're going to make sure that those buttons are disabled by default when the spell menu is

03:55.890 --> 03:57.150
first opened.

03:57.180 --> 04:05.340
That's something we can do in Pre-construct because those buttons can simply be disabled by default.

04:05.340 --> 04:12.030
I'm going to type Pre-construct and get an event Pre-construct out and get those buttons.

04:12.030 --> 04:15.210
We have the spend point button.

04:15.210 --> 04:22.380
We can now check is variable for that and rename it from wide button to spend point button.

04:22.380 --> 04:23.490
Let's do that.

04:25.690 --> 04:32.620
Or we'll call it actually button underscore spin point and we'll take the other button, the equip button,

04:32.620 --> 04:36.250
and we'll rename this one to button, underscore, equip.

04:37.150 --> 04:39.460
And we'll check is variable for that.

04:39.460 --> 04:46.360
So they're both variables now and back in event pre construct we can get button spend point we can get

04:46.360 --> 04:50.080
button equip and we can call set is enabled.

04:52.460 --> 04:55.640
So we'll set both of these to disabled.

04:56.460 --> 04:57.930
An event pre construct.

04:57.930 --> 05:03.600
And that way whenever we open our menu, we know that we won't have any globes selected, right?

05:03.600 --> 05:06.120
So we're just going to disable both of them.

05:07.840 --> 05:11.650
So they should be disabled by default.

05:11.650 --> 05:15.790
And as soon as we open up our spell menu, we see they're both disabled.

05:15.790 --> 05:16.660
That's what I want.

05:16.690 --> 05:23.860
It's only when we start to select things that we change our enabled status on these buttons for an equipped

05:23.860 --> 05:24.100
one.

05:24.100 --> 05:30.790
Again, let's reiterate selecting an equipped spell globe means both of them should be enabled.

05:30.790 --> 05:36.550
Selecting a locked spell globe means both of them should be disabled.

05:37.150 --> 05:40.540
For an eligible spell if I had leveled up here.

05:43.020 --> 05:45.780
We have an eligible spell globe.

05:45.900 --> 05:52.080
When we select this an eligible spell globe cannot be equipped, but it can be unlocked.

05:52.080 --> 05:54.690
So spin point only should be enabled.

05:54.690 --> 06:00.090
And then for a spell globe that's unlocked, which we can't test right now.

06:00.120 --> 06:02.460
They should both be enabled as well.

06:03.440 --> 06:05.690
So I'm going to give you a hint for this quest.

06:05.720 --> 06:13.040
The end result here is that your spell menu should have a delegate to respond to, and that delegate

06:13.040 --> 06:20.600
should broadcast two booleans, one Boolean for setting our spend button point enabled and one boolean

06:20.600 --> 06:22.970
for our button equip enabled.

06:23.000 --> 06:31.190
We need to know those pieces of information and when we click on a spell globe, when it becomes clicked,

06:31.220 --> 06:36.080
we can call a blueprint callable function for when a spell globe is clicked.

06:36.080 --> 06:43.040
So we'll need to add a blueprint callable function in our widget controller that can then make the determination

06:43.040 --> 06:47.150
based on that particular spells status.

06:47.180 --> 06:47.720
Right.

06:47.720 --> 06:50.600
So we're going to need to check the status.

06:50.600 --> 06:54.110
But there's another consideration you have to make as well.

06:54.110 --> 06:57.350
And that's how many spell points we have, right?

06:57.350 --> 07:01.370
If spell points is ever zero, should we ever enable spin point?

07:01.400 --> 07:02.930
No, the button should be grayed out.

07:02.930 --> 07:03.830
Then too.

07:03.840 --> 07:06.120
So take spell points into consideration.

07:06.120 --> 07:12.630
So we have two things to consider the abilities status and our spell points count.

07:12.660 --> 07:14.910
So this is a bigger quest.

07:14.940 --> 07:18.540
This is going to be a larger, more challenging quest.

07:18.570 --> 07:20.250
There are more pieces to it.

07:20.250 --> 07:24.210
So if you're up to the challenge, I'm going to give you that quest now.

07:25.580 --> 07:26.930
So here's your quest.

07:29.680 --> 07:33.850
I'd like you to enable and disable our spell menu buttons.

07:33.880 --> 07:37.600
Now, that means you have to take some information into account, right?

07:37.630 --> 07:43.900
Obviously, you're going to need to account for the spells status, so you need to check that in our

07:43.900 --> 07:45.040
widget controller.

07:45.070 --> 07:48.430
Now another thing you need to account for are the spell points.

07:48.460 --> 07:52.650
You should never enable the spell points button if spell points is zero.

07:52.660 --> 07:55.230
So that's another thing to take into account.

07:55.240 --> 08:01.990
So this is a bigger quest and I'm giving you a lot less guidance here because this is a good opportunity

08:01.990 --> 08:09.250
to try a little bit more of a challenging quest with minimal guidance and just see how much your capabilities

08:09.250 --> 08:10.190
have evolved.

08:10.210 --> 08:11.830
So give it a try.

08:11.860 --> 08:15.010
Pause the video and conquer this quest now.

08:18.090 --> 08:18.450
Okay.

08:18.450 --> 08:20.760
So there are kind of a lot of parts to this.

08:20.760 --> 08:21.540
Quest Right.

08:21.540 --> 08:24.120
But we're going to break this down step by step.

08:24.120 --> 08:27.870
And this is hopefully how you did it, just one step at a time.

08:27.870 --> 08:34.110
If you don't know all of the solutions to all the challenges and aspects to a quest, just take it one

08:34.110 --> 08:35.300
step at a time.

08:35.310 --> 08:37.800
Now, I like to go sequentially in order.

08:37.800 --> 08:41.970
What's the first thing that happens right when we open the spell menu?

08:42.000 --> 08:46.290
Well, we're already disabling those two buttons, so that's the first step.

08:46.290 --> 08:52.080
The next step is what happens when we click on a spell globe when we select one.

08:52.260 --> 08:56.310
Well, I want my spell menu widget controller to know about it.

08:56.310 --> 09:02.070
So we need a blueprint callable function, but the spell menu widget controller also needs to know which

09:02.100 --> 09:06.960
ability is being selected so it can check the status of that ability.

09:06.960 --> 09:13.530
So when we click on one of our globes, we need to inform the spell menu widget controller of which

09:13.560 --> 09:18.490
ability is being selected and we identify those abilities by their ability tag.

09:18.490 --> 09:25.030
So we're going to create a blueprint callable function for when we click or select a spell globe.

09:25.640 --> 09:29.390
So I'm going to go into my spell menu widget controller.

09:29.510 --> 09:34.460
I'm going to create a brand new blueprint callable function here.

09:35.090 --> 09:40.520
So I'm going to call it void spell globe selected.

09:41.640 --> 09:48.870
And it's going to take a const f gameplay tag by reference called ability tag so we know which ability

09:48.900 --> 09:52.310
has been selected and it's going to be blueprint callable.

09:52.320 --> 09:55.020
So we'll give it a new function with blueprint callable.

09:55.140 --> 10:00.420
Let's make sure we have the gameplay tag container header file included.

10:01.230 --> 10:03.990
So gameplay tag containers there.

10:04.140 --> 10:06.450
And now we have a blueprint callable function.

10:06.450 --> 10:09.450
I'll generate the definition of it like that.

10:09.970 --> 10:14.050
Now, when a spell globe is selected, we're going to do some stuff here.

10:14.050 --> 10:17.530
But before we get to that, I don't want to get too far ahead of myself.

10:17.530 --> 10:22.840
I'm going to make sure that I call my blueprint callable function when we click on one of our spell

10:22.870 --> 10:23.590
globes.

10:23.590 --> 10:28.900
So closing the editor, clicking the debug button so we can compile and launch again.

10:28.900 --> 10:32.230
I'm going to go back and make sure we call this function.

10:33.410 --> 10:40.550
So back here in the editor, I'm going to go into my spell globe button and make sure that whenever

10:40.550 --> 10:46.100
we click on one of these that we also call our blueprint callable function on the spell menu widget

10:46.100 --> 10:46.970
controller.

10:47.090 --> 10:52.670
And because we have a BP spell menu widget controller that we're setting, as soon as our widget controller

10:52.670 --> 10:57.680
has been set, we should be able to access that blueprint callable function from it.

10:57.680 --> 11:04.370
So I'm going to get my BP spell menu widget controller and call its blueprint callable function spell

11:04.370 --> 11:05.600
globe selected.

11:07.140 --> 11:12.390
So here's Spell Globe selected, we're going to call it, and it requires an ability tag.

11:12.390 --> 11:16.350
And each of our spell globes has its own ability tag.

11:16.350 --> 11:20.340
So we're going to take that ability tag and we're going to pass it on in.

11:20.340 --> 11:25.770
And now we know in C plus plus we can handle what happens when a spell globe is selected.

11:26.430 --> 11:28.860
So that's that step taken care of.

11:29.130 --> 11:36.240
Now, the ultimate end goal here is for our spell menu to receive a delegate that tells it two things

11:36.240 --> 11:42.090
two Boolean values for setting the enabled status for these two buttons.

11:42.090 --> 11:45.490
So we need a delegate to broadcast to Booleans.

11:45.510 --> 11:48.930
That's our next step, or at least the step I'm going to do next.

11:48.930 --> 11:54.270
I'm going to declare a dynamic multicast delegate that can broadcast two booleans.

11:54.360 --> 11:56.670
So we'll declare it right here and spell menu.

11:56.670 --> 11:57.650
Widget controller.

11:57.660 --> 12:00.230
We'll say declare dynamic.

12:00.240 --> 12:06.120
I'll just let Autocomplete finish this one because the only thing I need to change is I should have

12:06.120 --> 12:11.430
two params, so I'll use two params like that.

12:12.820 --> 12:14.440
So what are we going to call this?

12:14.440 --> 12:20.230
Well, it's going to be when a spell globe is selected, so I'm going to call this F spell globe.

12:21.940 --> 12:24.640
Selected signature.

12:25.880 --> 12:28.730
And it's going to broadcast to Booleans.

12:28.730 --> 12:34.390
And for the dynamic multicast delegates, we can say bool, comma and the name of the bool.

12:34.400 --> 12:44.900
So the first one will be for enabling the spend points button so we can say be spend points button enabled

12:45.710 --> 12:51.410
and a bool called be equip button enabled.

12:52.310 --> 12:58.550
So we have this dynamic multicast delegate that can broadcast to booleans whether or not we want to

12:58.550 --> 13:01.490
enable the spend points button and the equip button.

13:01.490 --> 13:05.870
So we need to create one of these delegates as a blueprint.

13:05.870 --> 13:12.290
Assignable delegate and I'm going to call this spell globe selected delegate.

13:13.070 --> 13:14.900
And we'll make it blueprint assignable.

13:14.900 --> 13:16.820
So now we have that delegate.

13:16.850 --> 13:22.360
We just need to figure out when to broadcast it and with which values to broadcast it.

13:22.370 --> 13:28.580
So we know that Spell Globe Selected will be called when we click on one of our spell globes and we

13:28.580 --> 13:29.990
have the ability tag.

13:30.230 --> 13:37.310
Now when a spell globe is selected, we need a couple of pieces of information we need first of all,

13:37.310 --> 13:38.210
the spell points.

13:38.210 --> 13:40.160
How many spell points do we have?

13:40.310 --> 13:44.440
And we can get that from our player state with Get Aura.

13:44.450 --> 13:50.150
PS and the player state has get spell points, so that one was pretty easy.

13:50.150 --> 13:52.880
We can store that in a const int 32.

13:52.910 --> 13:56.000
So const int 32 spell points.

13:58.610 --> 14:01.820
And there's that information.

14:01.920 --> 14:07.790
Now, we also need the status of our ability, and we need to be careful here because this ability tag

14:07.790 --> 14:12.890
may or may not be set on the globe that we're clicking on.

14:12.920 --> 14:22.040
Now, just to have a specific tag for when a globe has no ability assigned to it, we should probably

14:22.040 --> 14:25.100
have a specific tag for that.

14:25.100 --> 14:25.730
An abilities.

14:25.970 --> 14:28.010
None of sorts.

14:28.740 --> 14:35.010
So if we go to or a gameplay tags, we can make a new ability and this can be the sort of null pointer

14:35.040 --> 14:38.250
of ability tags we can call it abilities none.

14:39.610 --> 14:47.170
So we can create this game play ability tag and it's going to just be abilities none designated for

14:47.170 --> 14:48.040
no ability.

14:48.430 --> 14:50.590
So it's not an unset tag.

14:50.590 --> 14:52.600
So we're going to call this abilities none.

14:52.630 --> 15:04.210
The name will be abilities none and we'll say no ability space like the null pointer for ability tags.

15:05.010 --> 15:07.680
It's not a pointer, but it's like a null pointer.

15:07.680 --> 15:10.030
It's specifically no ability.

15:10.090 --> 15:10.410
Right.

15:10.410 --> 15:17.250
So we can go in and set all of those globes that don't have abilities assigned to them to have abilities.

15:17.520 --> 15:17.910
None.

15:17.910 --> 15:20.250
So just kind of a convenience there.

15:20.950 --> 15:23.540
You didn't have to do that, but I'm going to do it.

15:23.560 --> 15:27.370
So how are we going to handle this situation?

15:27.370 --> 15:32.240
Because if we want to check the status of our ability based on its tag.

15:32.260 --> 15:35.810
Well, we do have some functions on our ability system component.

15:35.830 --> 15:38.590
If we go to our ability system component.

15:39.730 --> 15:46.840
We have get status from spec and we have get spec from ability tag, but get spec from ability tag returns

15:46.840 --> 15:52.140
a null pointer if we don't have that specific ability with that tag.

15:52.150 --> 15:55.420
So we have to take that into account here.

15:55.420 --> 16:01.570
If we're going to get spec from ability tag, we need to check that pointer because if it's null, we

16:01.570 --> 16:04.660
don't have an ability with that tag or we use the tag.

16:04.660 --> 16:05.860
That's not valid.

16:05.860 --> 16:09.160
It could be abilities none or even not set at all.

16:09.520 --> 16:11.980
So what we can do is place an If check here.

16:11.980 --> 16:15.610
We can say if get aura ask.

16:17.740 --> 16:23.470
And we can call get spec from ability tag passing in the ability tag.

16:24.710 --> 16:29.510
Now if this is a null pointer, in other words, equals null pointer here.

16:30.700 --> 16:38.710
Then what we're dealing with is either an ability tag for an ability that we don't have yet or an ability

16:38.710 --> 16:41.320
tag for an ability that doesn't exist.

16:41.320 --> 16:43.930
It could be abilities none, for instance.

16:43.960 --> 16:49.450
So in this case, we need to know what to do with our buttons in the spell menu.

16:49.660 --> 16:52.450
So let's think about all the scenarios that can happen.

16:52.480 --> 16:56.680
The first is that the ability tag is not a valid tag, right?

16:56.710 --> 17:04.510
So in other words, we can say bool be tag valid equals ability tag dot is valid.

17:05.110 --> 17:08.860
We can also say that the ability tag is none.

17:09.310 --> 17:20.260
We can say bool be tag none equals ability tag dot matches tag and we could use f or a gameplay tags

17:21.070 --> 17:24.100
get dot abilities.

17:24.130 --> 17:24.880
None.

17:26.050 --> 17:26.740
Right?

17:26.740 --> 17:28.690
I'm not necessarily going to use these booleans.

17:28.690 --> 17:32.830
I'm just sorting out our thoughts here so we know if the tag is valid.

17:32.830 --> 17:39.160
We know if the tag is none and then we know if we get the spec from the ability tag and it's a null

17:39.160 --> 17:45.760
pointer, we know that in that case we don't have that ability in our activatable abilities.

17:45.850 --> 17:50.980
Now, does that necessarily mean that that ability is locked?

17:51.010 --> 17:58.420
Well, if the ability is eligible, we know that that ability exists on our ability system component.

17:58.750 --> 18:00.940
It is an activatable abilities.

18:00.940 --> 18:04.780
It's just that its status is eligible.

18:04.780 --> 18:05.230
Right?

18:05.230 --> 18:06.700
It's not locked.

18:06.700 --> 18:07.960
It's just eligible.

18:08.560 --> 18:16.450
So if it's not in activatable abilities, in other words, if this is null, then the ability is locked

18:16.630 --> 18:24.790
or this tag doesn't correspond to a valid ability, in which case we can just treat this as if the ability

18:24.790 --> 18:26.020
icon is locked.

18:27.010 --> 18:38.280
So we can say here bool be spec valid and we can say that when we call get spec from ability tag.

18:38.290 --> 18:42.250
If it's not a null pointer, then we have a valid spec too.

18:42.610 --> 18:49.090
So what I'm going to do is I'm going to create a local gameplay tag called ability status.

18:52.770 --> 18:56.700
And I'm going to set that status to locked in a number of scenarios.

18:56.700 --> 19:01.620
One, if the tag is not valid, so I'm going to say not be tag valid.

19:03.300 --> 19:05.100
But I'm going to have an oar here.

19:05.100 --> 19:10.590
And if the tag is none, if it's ability is none, I want to set that status to locked.

19:10.590 --> 19:12.960
So I'm going to say B tag none.

19:13.650 --> 19:17.460
I'm also going to have another or for if the spec is not valid.

19:17.460 --> 19:20.580
So I'm going to say not B spec valid.

19:20.580 --> 19:27.710
In all those cases, I'm going to set ability status equal to abilities none.

19:27.720 --> 19:33.600
So I'm going to go ahead and just create a variable for for a gameplay tags at the top here since I'm

19:33.600 --> 19:34.290
going to reuse it.

19:34.290 --> 19:38.010
So I'm going to say const for gameplay tags.

19:38.010 --> 19:44.610
Gameplay tags equals for a gameplay tags get and I'll use gameplay tags down here.

19:46.010 --> 19:55.040
And I'll also use it where I'm setting ability status to gameplay tags dot and it's going to be abilities

19:55.040 --> 19:56.420
status locked.

19:57.170 --> 20:03.680
So if the tag isn't valid or if it's abilities none or if the spec is not valid, I'm going to treat

20:03.680 --> 20:08.420
this like a locked ability and these can all be constable's.

20:11.700 --> 20:13.240
So that's what I'll do there.

20:13.290 --> 20:21.150
But otherwise we'll have an else here because if the tag is valid and it's not abilities, none.

20:21.150 --> 20:27.660
And the spec here that we get from the ability tag is also not a null pointer.

20:27.690 --> 20:32.190
Then I want to get the status from the ability spec.

20:32.520 --> 20:37.830
So if we don't want to call get spec from ability tag twice, which would be wasteful because it involves

20:37.830 --> 20:45.330
a for loop, we could just create a pointer of type gameplay ability spec here we'll say f gameplay

20:45.720 --> 20:54.630
ability spec, we'll make this pointer called ability spec and we'll set it with get or ask get spec

20:54.630 --> 20:59.940
from ability tag here and then we'll check this pointer right here.

21:01.740 --> 21:03.210
And then we have the spec.

21:03.210 --> 21:12.120
We don't have to call this function twice, and then here we're going to say ability status equals and

21:12.120 --> 21:21.270
we can get our ASC and we can call get status from spec passing in the ability spec which needs to be

21:21.300 --> 21:22.530
dereferenced.

21:22.590 --> 21:26.880
So we'll pass in the dereferenced ability spec right there.

21:26.880 --> 21:33.060
And we know that this is not a null pointer because be spec valid has already been set.

21:33.090 --> 21:37.290
Ability spec is not null pointer if be spec valid is true.

21:38.270 --> 21:41.060
So now we have the ability status as well.

21:41.300 --> 21:47.480
So based on spell points and ability status, we need to set the value of these booleans.

21:47.720 --> 21:54.230
So it'd be handy to have a function that can take in the spell points, the ability status and then

21:54.230 --> 21:55.950
set to booleans.

21:55.970 --> 22:03.200
And we could just pass two booleans in by reference non-const and the function can set them for us.

22:03.780 --> 22:09.430
So I'm going to make a function that can take in two booleans and fill them in.

22:09.450 --> 22:10.710
So let's do it.

22:11.720 --> 22:14.750
I'm going to go back into the widget controller.

22:14.780 --> 22:16.400
This can be a private function.

22:16.400 --> 22:18.710
It's just internal to the widget controller.

22:18.740 --> 22:27.590
It's going to be void and it's going to be we'll call this should enable buttons and this can take in

22:27.590 --> 22:31.550
a const gameplay tag for the status.

22:31.910 --> 22:39.740
We'll pass it in by reference, we'll call it ability status and it'll take in an int 32 called spell

22:39.740 --> 22:44.120
points and two bools by non-const reference.

22:44.120 --> 22:55.940
So a bool reference called B should enable spell points button and b should enable equip button.

22:58.030 --> 23:00.040
And this is also a bull.

23:00.900 --> 23:01.290
Cool.

23:01.290 --> 23:03.810
So we have should enable buttons.

23:03.810 --> 23:08.780
We'll pass in the status the spell points and two bools by non-const reference.

23:08.790 --> 23:15.060
This one should be a reference to that should be filled in by should enable buttons.

23:15.060 --> 23:17.310
Let's define this function.

23:21.010 --> 23:23.770
And we'll just pass into bulls here.

23:24.620 --> 23:27.110
So how is this function going to behave?

23:27.110 --> 23:29.360
Well, we need to check the status.

23:30.350 --> 23:36.920
I'm going to go ahead and copy this line where we're getting gameplay tags and I'm going to check ability

23:36.920 --> 23:37.280
status.

23:37.280 --> 23:44.930
I'm going to say if ability status and I'm just going to use matches, exact matches, tag exact and

23:44.930 --> 23:51.530
match against gameplay tags, dot abilities status and we have the four statuses.

23:51.530 --> 23:53.960
We'll just have an if for each one.

23:53.960 --> 23:59.930
So we'll say equipped first and we'll do an else if.

24:03.850 --> 24:06.070
And we'll check the same tag.

24:07.110 --> 24:16.470
Only we'll see if it's equal to abilities, status and we'll do eligible next and the other two cases

24:16.470 --> 24:17.040
as well.

24:17.040 --> 24:25.320
So we'll do else if and we'll check against the status unlocked and finally we'll do.

24:26.640 --> 24:28.350
A check against status.

24:28.350 --> 24:29.160
Locked.

24:30.960 --> 24:36.090
Now, based on the status we know if we should enable the equip button.

24:36.120 --> 24:41.010
The equip button depends solely on the status, not on the spell points.

24:41.250 --> 24:48.030
And if our ability is equipped already, then the equip button can be enabled.

24:48.150 --> 24:53.460
If it's eligible, it should not be enabled because we haven't unlocked it yet.

24:53.490 --> 24:57.690
If it's unlocked, it should be enabled and if it's locked, it should not.

24:58.080 --> 25:03.720
So we'll just specifically say that the equip button will be enabled.

25:03.720 --> 25:06.330
So we'll set it to true if equipped.

25:06.540 --> 25:09.900
If it's unlocked, we can enable the equip button.

25:09.900 --> 25:13.170
But if it's locked or eligible, it should be false.

25:14.700 --> 25:21.360
So we'll paste in false here for eligible and false for locked.

25:21.600 --> 25:28.680
Now for the spend points button, we have to check both the status and spell points.

25:28.680 --> 25:29.400
Right.

25:29.610 --> 25:37.830
If the abilities status is equipped, then we should enable the spend points button or the spell points

25:37.830 --> 25:41.190
button if we have spell points.

25:41.610 --> 25:43.790
That's why we pass spell points in.

25:43.800 --> 25:47.910
So we'll say if spell points is greater than zero.

25:48.150 --> 25:53.370
In that case the should enable spell points button should be set to true.

25:55.050 --> 25:57.960
And the same goes for eligible.

25:57.960 --> 26:00.960
If we're eligible, we should be able to spend points on it.

26:00.960 --> 26:02.550
If we have spell points.

26:02.550 --> 26:05.460
So we should set the spell points button to enabled.

26:05.460 --> 26:11.820
Then if we have points and if it's unlocked, we should be able to spend points on it.

26:11.820 --> 26:14.770
So we'll say if spell points is greater than zero.

26:14.770 --> 26:16.630
So we'll set it to true then.

26:16.630 --> 26:18.460
But if it's locked, it should be false.

26:18.460 --> 26:24.580
So really we should set it to false first and only set it to true in those circumstances.

26:24.580 --> 26:31.420
So we'll say should enable spell points button equals false first and then we don't have to set it to

26:31.420 --> 26:31.930
false.

26:31.930 --> 26:36.190
We'll only turn it to true in these three cases.

26:36.430 --> 26:43.900
And if you wanted to, you could set both of them to false up here and only flip them to true in the

26:43.900 --> 26:46.600
case that we're changing them to true.

26:46.690 --> 26:52.810
In other words, we could take should enable equip button equals false and do that up here at the top

26:52.810 --> 26:58.450
and then only set them to true and never have to worry about setting them to false because that's their

26:58.450 --> 26:59.650
default state.

26:59.680 --> 27:05.920
That would make this last else if redundant and we could remove it so we could do it that way too.

27:06.220 --> 27:10.410
Now should enable buttons only changes things that we pass into it.

27:10.420 --> 27:16.390
In other words, it doesn't change any state on the widget controller, so it could be a static function.

27:16.390 --> 27:18.460
So we're going to go ahead and make it static.

27:19.360 --> 27:24.460
So now we have should enable buttons and we can determine those boolean values.

27:24.460 --> 27:28.540
Here in spell globe selected, we have to create two local booleans.

27:28.540 --> 27:34.510
One will be be enable spend points.

27:35.650 --> 27:41.410
We'll set it to false by default and bool be enable equip.

27:42.070 --> 27:43.930
We'll set it to false by default.

27:43.960 --> 27:48.250
We're setting them to false by default in this function and then flipping them to true.

27:48.250 --> 27:53.980
So it's a little redundant, but I don't want this static function to just assume that they're coming

27:53.980 --> 27:54.910
in false.

27:54.910 --> 27:59.590
So these two lines will stay and these two lines will stay as well.

27:59.590 --> 28:04.270
So we're going to call should enable buttons passing in the ability status.

28:04.270 --> 28:10.720
So ability status, passing in spell points and the order matters.

28:10.720 --> 28:14.020
Here we have to do the enable spell points button first.

28:14.020 --> 28:16.090
That should say spend points, but that's okay.

28:16.090 --> 28:21.500
We're going to say enable spend points goes in first and then enable.

28:21.500 --> 28:23.750
Equip goes in second.

28:23.900 --> 28:29.870
And after calling this function, these booleans will have the correct values, at which point we can

28:29.870 --> 28:35.780
just broadcast our delegate, which is called spell globe selected delegate.

28:35.780 --> 28:36.710
So let's do it.

28:36.710 --> 28:43.970
Let's broadcast that delegate we'll call broadcast broadcasting and the order matters here to spend

28:43.970 --> 28:45.830
points button enabled is first.

28:45.830 --> 28:50.990
So we're going to say enable spend points goes in first and enable.

28:50.990 --> 28:53.150
Equip goes in second.

28:54.830 --> 29:02.120
So at this point, we're now going to broadcast two Boolean values up to our widget, which will handle

29:02.120 --> 29:02.690
them.

29:02.690 --> 29:06.650
And of course this pointer for the ability spec could also be const.

29:06.650 --> 29:08.120
So we'll do that too.

29:08.120 --> 29:11.380
And that should take care of the code side.

29:11.390 --> 29:13.340
Let's hop back over to Blueprint.

29:15.420 --> 29:19.290
So back in the editor, we can go back into spell menu.

29:20.740 --> 29:25.120
And I can also get my spell globe.

29:25.950 --> 29:32.910
Spell glow button widget here open just to make sure that Onclicked is calling spell globe selected.

29:33.120 --> 29:38.820
Now the first thing I'm going to do is see if those values are correct.

29:39.120 --> 29:44.730
So I'm going to place a breakpoint here just before broadcasting this delegate, before we even assign

29:44.730 --> 29:45.660
anything to it.

29:45.660 --> 29:48.120
And I'm going to see if it broadcasts the correct values.

29:48.120 --> 29:52.860
I'm going to click on an equipped button and see that both of these are true.

29:52.860 --> 29:54.300
So that's correct.

29:54.630 --> 30:00.780
I'm also going to click on one of these that doesn't have a valid ability tag and see what happens there.

30:00.780 --> 30:07.650
And in that case, both Booleans are false and our ability spec is null in that case.

30:07.650 --> 30:10.590
So that's also the correct scenario.

30:10.680 --> 30:13.020
Now I would like to level up.

30:16.050 --> 30:24.000
Now I have one of these that's in the eligible state, and if I click on that well, enable span points

30:24.000 --> 30:28.320
should be true because I have spell points, but enable equip should be false.

30:28.320 --> 30:30.290
So that's also correct.

30:30.300 --> 30:33.330
So it's looking like our booleans are correct.

30:33.360 --> 30:39.930
We can now handle this delegate broadcast in the spell menu and we need to do that after setting our

30:39.930 --> 30:44.400
widget controller variable so we can do it right after we do that.

30:44.430 --> 30:51.480
Let's move these sections down and add a new pin and I'm going to move these three wires down.

30:51.480 --> 30:55.770
I'm going to hold control and click and just move these wires over.

30:55.770 --> 31:03.090
And for this one, I'm going to get my spell menu, widget controller, get that and assign.

31:03.300 --> 31:05.850
And I'm forgetting what the delegate is called.

31:05.850 --> 31:08.310
It's called Spell globe selected Delegate.

31:08.310 --> 31:11.400
And I'm going to remove that breakpoint.

31:12.160 --> 31:16.810
So I'm going to search for spell globe selected delegate.

31:16.840 --> 31:19.240
We're going to assign an event to that.

31:19.330 --> 31:27.600
Hook this up to the second case in my sequence, and we now have two booleans that we can use to set

31:27.610 --> 31:30.820
the enabled state on our buttons.

31:30.820 --> 31:32.650
We have button equip.

31:33.380 --> 31:35.870
And we have button spend point.

31:35.900 --> 31:37.970
We're going to get the spend point button first.

31:37.970 --> 31:43.550
We've been doing that first for everything here we're going to call set is enabled.

31:44.540 --> 31:47.990
And we're going to pass in spend points button enabled to that.

31:48.320 --> 31:49.700
We'll hook that up.

31:50.340 --> 31:56.190
And for button equip we'll call the same function, but we'll hook up, button, equip or equip button

31:56.190 --> 31:59.500
enabled to that one and hook that up.

31:59.520 --> 32:04.320
And this can be collapsed to a nice function called set buttons enabled.

32:04.320 --> 32:09.330
So I'm going to collapse the function called set buttons enabled.

32:10.680 --> 32:12.390
So that's nice and clean.

32:12.390 --> 32:22.560
We can give this a comment and say enable buttons based on ability, status and spell points.

32:23.730 --> 32:30.930
And because we're disabling both of the buttons at the very beginning up here in pre construct, we

32:30.930 --> 32:33.660
can now call set buttons enabled instead.

32:34.220 --> 32:40.310
And these nodes can be replaced by one neat node will pass in false for both.

32:40.920 --> 32:44.280
And we have is in enabled one and two.

32:44.310 --> 32:48.870
So these input parameters should actually be called better names.

32:48.870 --> 32:52.390
So let's just rename those inputs to be nice and clean.

32:52.410 --> 32:54.720
This one will be the spin point.

32:54.720 --> 33:00.570
So we'll say spend points enabled and this one will be equipped.

33:00.570 --> 33:10.890
So we'll say equip enabled like that, we'll compile it and let's see if that broke any of our nodes

33:10.890 --> 33:13.300
and we see that they're looking fine.

33:13.320 --> 33:17.250
Okay, so now we just need to test everything out.

33:17.280 --> 33:19.680
Let's go ahead and open things.

33:19.890 --> 33:20.900
And there we go.

33:20.910 --> 33:22.560
We're enabling both buttons.

33:22.560 --> 33:27.090
When we click on an equipped ability, we're disabling both buttons.

33:27.090 --> 33:33.270
When we click on a locked ability or an ability globe that doesn't have a valid tag.

33:33.300 --> 33:36.690
Now let's level up and get an eligible spell globe.

33:38.270 --> 33:39.350
There's one.

33:39.350 --> 33:44.300
And if we click on it, we can spend a point, but we can't equip it.

33:44.300 --> 33:50.240
And the only other scenario is when we have one unlocked but not equipped, and we can't really test

33:50.240 --> 33:55.340
that yet until we continue implementing more features in our spell menu.

33:55.340 --> 33:59.840
But everything is updating as it should.

33:59.840 --> 34:03.040
So things are looking really nice.

34:03.050 --> 34:06.320
We now have our buttons enabled and disabled.

34:06.320 --> 34:10.280
Depending on the status and the number of spell points we have.

34:10.310 --> 34:17.270
The only other thing we can test is having zero spell points to start out with so we can set our starting

34:17.270 --> 34:18.380
spell points to zero.

34:18.380 --> 34:20.990
And also looks like we're accessing none.

34:20.990 --> 34:30.050
Trying to read BP spell menu widget controller in spell globe selected in our spell globe button.

34:30.050 --> 34:33.230
So let's go to that and see what's going on.

34:33.230 --> 34:38.340
So right here, our spell menu widget controller is null.

34:38.340 --> 34:41.520
So let's see if we can reproduce that error.

34:46.140 --> 34:46.470
Okay.

34:46.470 --> 34:51.240
It was when I clicked on the passive spell menu.

34:51.270 --> 34:52.980
One of the globes in the passive.

34:52.980 --> 34:59.460
So I think I might have not set my passive widget controller for the passive spell menu.

34:59.490 --> 35:02.040
Let's see if we did not do that.

35:02.400 --> 35:02.670
Okay.

35:02.670 --> 35:06.480
We are setting the passive spell trees widget controller.

35:06.480 --> 35:08.790
But let's go to the passive spell tree.

35:10.250 --> 35:13.430
And make sure we're setting the widget controllers for its three globes.

35:13.430 --> 35:15.140
We may not have done that yet.

35:16.110 --> 35:17.730
I don't think I have.

35:17.880 --> 35:21.540
So we do need to make sure we're doing that for the passive spell tree.

35:21.570 --> 35:24.510
So we're going to get event widget controller set.

35:24.540 --> 35:31.440
Sure enough, we haven't yet, so we're going to get our glow buttons and call set widget controller.

35:33.370 --> 35:35.470
And we'll do it for all three of them.

35:38.580 --> 35:41.670
And we'll set them to widget controller.

35:43.500 --> 35:47.720
So we'll get our widget controller variable and we'll set them there.

35:47.730 --> 35:50.040
And I'm going to collapse this to a function.

35:52.100 --> 35:54.230
Set widget controllers.

35:55.870 --> 35:58.510
So now that our passive tree is doing that.

36:00.920 --> 36:02.690
Then we shouldn't get that error.

36:07.620 --> 36:08.880
And that takes care of it.

36:08.880 --> 36:12.570
So one of those subtle things that's easy to forget.

36:12.600 --> 36:14.400
We'll put that up there at the top.

36:14.790 --> 36:17.400
Okay, so things are looking nice.

36:17.400 --> 36:27.090
We now have the spell menu buttons either enabled or disabled, depending on the status and or our number

36:27.090 --> 36:32.640
of spell points, which, by the way, I just said we can test out starting with zero spell point.

36:32.640 --> 36:34.980
So let's just test that really quickly.

36:35.190 --> 36:42.000
I'm going to go to the public folder into player and Ora player state and start us off with zero spell

36:42.000 --> 36:49.140
points and we'll just play test with zero spell points as well and see if the buttons update when we

36:49.140 --> 36:51.000
level up in that case.

36:52.320 --> 36:56.910
And I'm all ready for seeing an edge case that I haven't taken into account.

36:56.910 --> 37:02.220
And that's leveling up with the spell menu open as things are going to change in that case.

37:02.220 --> 37:04.230
So I'm going to open everything back up.

37:04.410 --> 37:06.720
I'm going to press play.

37:06.750 --> 37:14.160
I see that I have zero spell points and if I click on an equipped ability, the spin point button remains

37:14.190 --> 37:16.770
grayed out, which is exactly what I want.

37:16.770 --> 37:19.710
And the equip button is the only thing that should change.

37:19.710 --> 37:21.150
And if I level up.

37:24.910 --> 37:27.010
Then I can click on.

37:27.750 --> 37:32.580
Either one of them and the spend point button becomes enabled and that's great.

37:32.850 --> 37:38.160
Now, I wanted to test when we level up with the menu open.

37:38.160 --> 37:40.230
I think that's an edge case.

37:40.230 --> 37:42.570
That could be an issue.

37:42.570 --> 37:44.310
So what I'm going to do is.

37:45.530 --> 37:50.450
Go into my actually my overlay is where I'm doing it.

37:50.450 --> 37:52.550
I'm going to go into the overlay.

37:53.550 --> 37:55.710
Where we're setting input mode only.

37:55.710 --> 38:01.320
I'm going to disable that so I can still move with the menu open and then I'm going to level up.

38:07.110 --> 38:12.570
Now, I haven't had anything selected, which means these should both still be grayed out.

38:12.570 --> 38:16.080
And of course they update when I click them, so that's fine.

38:16.710 --> 38:20.070
But what if I select one and then level up?

38:23.670 --> 38:29.430
Then nothing really updates until I select it again, which is okay because we shouldn't be leveling

38:29.430 --> 38:30.750
up with the menu open anyway.

38:30.750 --> 38:32.970
But it's possible that we do.

38:33.000 --> 38:38.610
It's possible that we have some fireballs flying this way and then we open it.

38:39.790 --> 38:43.350
And somehow have one selected and then we level up.

38:43.360 --> 38:45.070
It is possible, right?

38:45.070 --> 38:52.570
So we really should be broadcasting this delegate for whichever ability we currently have selected when

38:52.570 --> 38:58.090
we level up, when spell points changes or our ability statuses change.

38:58.090 --> 39:03.070
So that's something we should take care of and I think we'll handle that in the next video.

39:04.030 --> 39:12.310
So I'll go ahead and just leave my node disconnected here for input mode only and we'll handle that

39:12.310 --> 39:14.180
edge case in the next video.

39:14.200 --> 39:15.940
So great job.

39:16.480 --> 39:21.580
I'm proud of you for taking on this big quest, and I'll see you in the next video.
