WEBVTT

00:00.810 --> 00:02.880
Welcome to your next quest.

00:03.210 --> 00:08.370
For this quest, you're going to add attribute points to the player state as a member variable.

00:08.550 --> 00:13.150
Now, make sure you handle all the things that are associated with that.

00:13.170 --> 00:19.500
This is something that will need to be replicated, for example, and broadcast a delegate when the

00:19.500 --> 00:20.760
points change.

00:21.000 --> 00:25.940
Now, since we're broadcasting delegates, we're going to need to receive those delegates.

00:25.950 --> 00:31.650
So receive that delegate that you're going to broadcast in the attribute menu widget controller.

00:31.680 --> 00:39.540
That way we can broadcast up to our widgets and as a bonus, add a spell points variable and handle

00:39.540 --> 00:41.910
everything related to that as well.

00:41.940 --> 00:44.670
Perhaps you can knock these both out at the same time.

00:44.700 --> 00:46.920
Pause the video and conquer this quest.

00:46.950 --> 00:47.790
Now.

00:51.170 --> 00:56.120
Okay, so I'm in my player state class and I'm going to need attribute points.

00:56.140 --> 01:00.710
I'd like to just knock out attribute points and spell points at the same time.

01:00.710 --> 01:03.380
So I'm going to add both of those.

01:03.650 --> 01:12.620
So this one I'm going to rename to attribute points and the rep notify will be on rep attribute points

01:12.620 --> 01:18.650
and I'm going to start it off with a value of zero and the next one will be spell points.

01:19.800 --> 01:23.970
And this will use a rep notify on rep spell points.

01:24.150 --> 01:26.850
Now I can create those rep notifies.

01:27.120 --> 01:35.070
I'm just going to copy on rep level and paste it twice and this one will be on rep attribute points.

01:36.160 --> 01:38.050
Changing its input there.

01:38.050 --> 01:42.700
And this one will be on rep spell points, changing its input as well.

01:42.700 --> 01:47.260
And I can go ahead and generate definitions for both of these.

01:48.080 --> 01:51.460
So now I have a rep notify for both.

01:51.470 --> 01:55.700
I do need to add both to get lifetime replicated props.

01:55.700 --> 01:59.330
So if you forgot that step, make sure to come back and do that.

01:59.360 --> 02:04.250
We need to add both attribute points and spell points.

02:05.690 --> 02:06.530
Okay.

02:06.530 --> 02:11.050
Now we're going to want a couple of delegates to broadcast when these change.

02:11.060 --> 02:14.960
Now we have a delegate that broadcasts in 30 twos.

02:14.960 --> 02:17.860
It's called F on player stat changed.

02:17.870 --> 02:25.220
We're going to make a pair of these one for when attribute points change we'll call it on attribute

02:25.220 --> 02:35.570
points changed delegate and we'll have another one on spell points changed delegate And we just need

02:35.570 --> 02:37.100
to broadcast these.

02:37.100 --> 02:39.400
When these values change.

02:39.410 --> 02:44.330
Now we're going to need some setters and getters for them as well.

02:44.330 --> 02:46.970
So I'm just going to go ahead and create those.

02:47.000 --> 02:49.020
I'll have the getters together here.

02:49.260 --> 02:51.810
I'll go ahead and make the getters force inline.

02:52.680 --> 03:01.170
They'll return in 32 first, we'll have get attribute points, const return attribute points.

03:03.390 --> 03:13.200
And another force in line in 30 to get spell points also const and it'll return spell points.

03:14.280 --> 03:17.900
Now I'm going to create add two functions for both of these.

03:17.910 --> 03:19.850
I don't really think I'll need setters.

03:19.860 --> 03:21.660
We'll see if we need them in the future.

03:21.660 --> 03:23.100
We'll add them if we do.

03:23.100 --> 03:32.040
But for now I'm just going to make a add to attribute points function that takes an int 32 called in

03:32.040 --> 03:36.780
points, we'll call it and a void function add to spell points.

03:38.090 --> 03:41.630
Which will take in in 32 called in points as well.

03:42.670 --> 03:46.540
And I'll go ahead and create definitions for both of these.

03:46.540 --> 03:52.150
And these are going to just add to their corresponding variables attribute points.

03:52.690 --> 04:01.510
We can use plus equals in points and spell points will take spell points plus equals end points.

04:01.510 --> 04:04.900
And we can broadcast delegates for when these change.

04:04.900 --> 04:12.820
So we're going to take our on attribute points change delegate call broadcast, and we'll go ahead and

04:12.820 --> 04:21.400
broadcast the value of attribute points and we'll take on spell points, change, delegate and broadcast

04:21.400 --> 04:23.230
the value of spell points.

04:23.810 --> 04:30.770
Now I'm just noticing that these definitions were created inline, so I'd like to cut them and paste

04:30.770 --> 04:32.820
them into or a player state CPP.

04:33.020 --> 04:39.710
I'd like them down here and I'm going to remove that inline keyword and I'm also going to make sure

04:39.710 --> 04:42.750
that the delegates are broadcast and the rep notifies.

04:42.770 --> 04:50.270
So handling the delegate broadcast for attribute points and it's on rep and handling the delegate broadcast

04:50.270 --> 04:52.370
for spell points and it's on rep.

04:52.370 --> 04:57.260
And with that, we're now broadcasting when our spell points change.

04:57.260 --> 05:02.090
We just need to listen for these in our widget controller and handle it there.

05:02.090 --> 05:09.560
So I'm going to go into UI and I actually think I'll go straight to the private folder into attribute

05:09.560 --> 05:11.450
menu widget controller, CPP.

05:11.870 --> 05:17.800
Now here in the attribute menu, we haven't actually bound anything to our player state.

05:17.810 --> 05:21.080
So what I'm going to do is get my player state.

05:21.260 --> 05:25.380
We'll do this at the bottom of bind callbacks to dependencies.

05:25.380 --> 05:32.100
So I'm going to do basically what I did in overlay widget controller so I can go to overlay widget controller

05:32.100 --> 05:39.210
If I want an example of how I got my player state, I basically use cast checked with Player State,

05:39.480 --> 05:42.750
so I'm going to copy that line and paste it here.

05:42.750 --> 05:49.380
An attribute menu widget controller and I'll use alt enter to include or a player state the header file.

05:49.380 --> 05:53.820
So now that we have the player state, we can bind to one of its delegates.

05:53.820 --> 05:57.570
I want to bind to its attribute points change.

05:57.570 --> 06:04.320
Delegate this one here on attribute points change delegate So here in the attribute menu widget controller

06:04.320 --> 06:10.800
I'm going to take or a player state get on attribute points change delegate and I'm going to bind a

06:10.800 --> 06:11.940
lambda to it.

06:12.180 --> 06:17.040
So using add lambda, I can put a lambda here.

06:19.950 --> 06:21.880
And what is my lambda going to do?

06:21.900 --> 06:29.250
Well, my attribute menu widget controller can simply broadcast the value of my attribute points, so

06:29.250 --> 06:32.280
it's going to need a delegate to broadcast.

06:32.580 --> 06:37.560
Now let's see what we're broadcasting in our overlay widget controller for our level.

06:38.100 --> 06:43.290
I'm going to go to its header file all the way up to the top and take a look at the delegates we have

06:43.290 --> 06:44.010
here.

06:44.310 --> 06:47.280
We have on player stat change signature.

06:47.520 --> 06:53.460
Now, this is something that we can reuse in attribute menu widget controller and if we're going to

06:53.460 --> 07:00.810
reuse it there, well both attribute menu and overlay widget controllers inherit from a widget controller

07:00.810 --> 07:06.300
so we can simply declare this delegate there and use it in both child classes.

07:06.300 --> 07:10.650
So I'm going to control X to cut that and go into aura widget controller.

07:10.680 --> 07:12.450
This is the CPP file.

07:12.450 --> 07:16.840
I need to go to the header file and an aura widget controller dot h.

07:16.860 --> 07:23.970
I'm going to declare on player stat change signature here and then I can simply use this in attribute

07:23.970 --> 07:25.310
menu widget controller.

07:25.320 --> 07:31.170
So after making that change, I'm going to close Aura widget controller and go back to attribute menu

07:31.170 --> 07:38.700
widget controller and open its header file and make a blueprint assignable delegate of this type on

07:38.700 --> 07:47.250
player stat change signature and I'm going to call this attribute points changed delegate and make it

07:47.250 --> 07:48.540
blueprint assignable.

07:50.230 --> 07:56.560
Now, I do want to make sure that this is not the same name as the delegate here on the player state

07:56.560 --> 08:02.290
and the player state has on attribute points change delegate our attribute menu widget controller just

08:02.290 --> 08:04.860
has attribute points change delegate.

08:04.870 --> 08:06.130
So that's fine.

08:06.130 --> 08:13.690
And all I want to do in this lambda is broadcast my new delegate attribute points change delegate dot

08:13.690 --> 08:23.620
broadcast and I want to broadcast the value and this lambda should be capable of receiving an 32 we'll

08:23.620 --> 08:30.880
call it points here, and the square brackets should capture this and we can simply broadcast points.

08:32.910 --> 08:41.100
So now our attribute menu is receiving the attribute points when they change and broadcasting that.

08:41.190 --> 08:44.850
So now that we've set all this up, we can do several things.

08:44.850 --> 08:48.720
Next, we need to actually add to the attribute points.

08:48.720 --> 08:55.760
When they change, we need to receive that change in our widget and update that in the HUD.

08:55.770 --> 09:01.890
We should broadcast our initial values for it in the HUD and we should add to those values when we level

09:01.890 --> 09:02.360
up.

09:02.370 --> 09:03.480
So we'll do those things.

09:03.480 --> 09:08.130
Next, I'm going to close out of the editor so I can do a quick compile.

09:08.130 --> 09:10.770
And with that, I'll see you in the next video.
