WEBVTT

00:06.920 --> 00:08.120
Welcome back.

00:08.570 --> 00:14.390
Now, in the last video, we've implemented a lot of things and save progress.

00:14.390 --> 00:19.760
Whenever we call save progress, we're now saving eight additional values.

00:19.760 --> 00:25.460
We're saving four on the player state and our four primary attributes.

00:25.850 --> 00:29.690
Now we know that this is being called because our checkpoints are calling it.

00:29.690 --> 00:37.610
If we go to our checkpoint in the private folder in checkpoint in on sphere overlap, we're executing

00:37.610 --> 00:40.250
the save progress interface function.

00:40.250 --> 00:42.800
So we know that this stuff is being saved.

00:42.800 --> 00:45.020
We just have to load it now.

00:45.020 --> 00:47.960
Loading it is going to be done in our character.

00:47.960 --> 00:50.480
And I'd like to do it in Possessed by.

00:50.870 --> 00:56.540
Because at this point we know we're going to have a valid attribute set and ability system component.

00:56.780 --> 01:03.860
Now so far we're calling add character abilities and init ability actor info.

01:03.890 --> 01:11.090
Let's think about how we're actually initializing our primary, secondary and vital attributes as well

01:11.090 --> 01:12.260
as our abilities.

01:12.410 --> 01:16.190
We can go and look at an ability actor info.

01:16.670 --> 01:17.960
Let's take a look.

01:17.960 --> 01:19.640
Here it is for the character.

01:20.120 --> 01:23.060
We're getting our ability system component initializing it.

01:23.060 --> 01:24.170
That's good.

01:24.200 --> 01:27.650
We're casting to our ability system component.

01:27.650 --> 01:34.400
We're setting our ability system component and attribute set subscribing to on as registered.

01:34.640 --> 01:39.680
Taking our ability system component, registering a gameplay tag event to debuff.

01:39.680 --> 01:46.490
We're getting our player controller and knitting the overlay and then initializing our default attributes

01:46.490 --> 01:47.240
here.

01:47.240 --> 01:52.580
So it's an innate ability actor info that we initialize our default attributes.

01:52.580 --> 01:56.690
Now we're going to do this from disk provided that we have saved data.

01:56.690 --> 02:01.190
So we're going to go back up to init ability actor info in possessed by.

02:01.400 --> 02:07.520
And notice we also have on rep player state which is doing the same thing.

02:07.520 --> 02:10.670
Now these eight variables that we're setting here are replicated.

02:10.670 --> 02:12.560
But again we're saving to disk.

02:12.560 --> 02:14.750
This is a single player solution.

02:14.750 --> 02:18.830
In multiplayer we would be retrieving these from a database right.

02:19.160 --> 02:27.740
So in init ability actor info I'd like to remove completely what we're doing when it comes to initializing

02:27.740 --> 02:29.600
our primary attributes.

02:29.600 --> 02:35.810
So down here where we're calling initialize default attributes I'm going to remove this now because

02:35.810 --> 02:37.430
we're going to load it in from disk.

02:37.430 --> 02:40.490
So we can go back to possessed by.

02:40.490 --> 02:42.860
And now after init ability actor info.

02:42.860 --> 02:45.290
Our primary attributes won't be set yet.

02:45.290 --> 02:48.920
Now we're going to want to add character abilities from disk as well.

02:48.920 --> 02:53.180
So this is another thing that we're going to want to change.

02:53.180 --> 02:59.090
We'll have a to do let's say to do load in abilities from disk.

02:59.900 --> 03:03.620
So we'll get to that when we figure out how to save our abilities.

03:03.620 --> 03:07.670
But for now we want to initialize our attributes.

03:07.670 --> 03:11.390
So let's make a function to initialize our attributes.

03:11.390 --> 03:16.310
Let's actually make a function to just load in our info from disk.

03:16.310 --> 03:19.850
Let's make a function here on or a character.

03:19.850 --> 03:23.360
And this can be a protected function.

03:24.620 --> 03:27.050
And we can call this load progress.

03:28.250 --> 03:30.080
So let's generate the definition.

03:30.080 --> 03:32.960
And I'm going to put this right up there by possessed by.

03:33.990 --> 03:36.150
So going up to possessed by.

03:36.240 --> 03:38.070
I'm going to put it right underneath.

03:38.070 --> 03:46.140
That way we can see it and we're going to call load progress after initializing ability actor info here.

03:47.600 --> 03:53.300
So we'll know that we have a valid ability system component at this point, and we can handle loading

03:53.300 --> 03:54.350
our progress here.

03:55.010 --> 03:57.020
So what is load progress going to do.

03:57.050 --> 04:03.080
Well we're definitely going to want to retrieve our saved data from the game mode.

04:03.080 --> 04:04.580
So we need to get the game mode.

04:04.580 --> 04:10.370
I'm just going to search for a game mode and find where I'm getting it down here and save progress.

04:10.370 --> 04:14.030
In fact, Save Progress also has some other things I want to do.

04:14.030 --> 04:18.980
I want to retrieve in game save data, check to see if it's null and all that good stuff.

04:18.980 --> 04:24.470
So I'm just going to copy this whole if statement and go back to load progress and paste it in here.

04:24.950 --> 04:29.870
So the only thing I'm concerned with with our save data is the stats.

04:29.870 --> 04:34.730
For now I'm going to start setting things on my player state.

04:34.730 --> 04:37.010
So that means I need my player state.

04:37.010 --> 04:41.060
I'm going to say if a or a player state.

04:42.300 --> 04:48.390
Or a player state equals a cast to A or a player state.

04:50.640 --> 04:52.500
We're going to cast get player State.

04:54.760 --> 05:00.520
And we'll take our player state and we'll set those four variables first.

05:00.640 --> 05:02.620
We're going to call set player level.

05:02.620 --> 05:04.600
And I believe it's called set level.

05:04.600 --> 05:09.280
And that's going to be on save data player level.

05:10.450 --> 05:14.950
Next we'll take our player state and call set XP.

05:16.980 --> 05:20.040
We'll use save data XP.

05:21.870 --> 05:22.380
Well.

05:22.380 --> 05:25.620
Next take our player state and call set.

05:27.280 --> 05:28.480
Attribute points.

05:28.480 --> 05:29.590
Do we not have a setter?

05:29.590 --> 05:30.940
I don't think we do.

05:31.090 --> 05:33.400
So we'll have to go and add one.

05:33.610 --> 05:38.110
So let's go to public player or a player state.

05:38.440 --> 05:40.030
Let's see if we don't have one.

05:40.030 --> 05:40.690
We don't.

05:40.690 --> 05:42.580
We have Add to but not set.

05:42.580 --> 05:44.290
I'd like a setter for both.

05:45.040 --> 05:48.520
So we'll have void set attribute points.

05:49.370 --> 05:58.460
And 32 in points and a void set spell points and 32 end points.

06:00.490 --> 06:02.110
Let's generate these.

06:04.710 --> 06:10.470
And we'll set attribute points to end points.

06:12.350 --> 06:17.060
And for set spell points, we'll set spell points to end points.

06:17.780 --> 06:18.710
But what do we do?

06:18.710 --> 06:22.040
Every time we set these we broadcast delegates.

06:22.040 --> 06:22.700
Right.

06:22.700 --> 06:23.690
That's important.

06:23.690 --> 06:32.030
So we have to broadcast on attribute points change delegate and we'll broadcast attribute points.

06:33.670 --> 06:37.900
And for spell points, we'll get on spell points.

06:37.900 --> 06:42.100
Change delegate broadcast spell points.

06:42.830 --> 06:46.730
So now we have setters we can use and back in our character.

06:46.730 --> 06:52.820
Now we can set attribute points to save data attribute points.

06:52.820 --> 07:01.010
And we can get our player state and set spell points to save data spell points.

07:02.390 --> 07:04.940
So that takes care of the player state variables.

07:04.940 --> 07:06.950
But that's the easy part, right?

07:06.950 --> 07:08.240
What about our attributes.

07:08.240 --> 07:12.770
Because attributes should be set using gameplay effects if we can help it.

07:13.330 --> 07:19.240
I'm going to go back into the editor and I'm going to go into blueprints, ability, system data, and

07:19.240 --> 07:21.550
open character class info.

07:21.730 --> 07:23.140
Why am I doing this?

07:23.140 --> 07:30.850
Because each of our character classes has a gameplay effect for its primary attributes.

07:30.850 --> 07:37.360
And if we take a look at them, say, the primary attributes effect for the Elementalist, we'll see

07:37.360 --> 07:44.770
that this is a gameplay effect with our primary attributes, and they each have scalable floats, and

07:44.770 --> 07:50.980
we're using curve tables for that given class to set these values based on level.

07:50.980 --> 07:57.160
But if we're loading in from disk, we don't want to set these based on level, because we have the

07:57.160 --> 08:03.490
freedom to spend points on attributes, and we need to load in our load out whatever progress we've

08:03.490 --> 08:08.860
been pouring into our primary attributes, the points that we've been choosing for ourselves, that's

08:08.860 --> 08:10.270
what we want to apply.

08:10.270 --> 08:13.780
So we need a new gameplay effect for primary attributes.

08:13.780 --> 08:20.680
And I'd like to use set by color magnitudes that we can set when applying our primary attribute effect.

08:21.170 --> 08:25.670
And I'd like to add that effect here to character class info.

08:25.700 --> 08:31.070
We'll just have a primary attributes gameplay effect specific to loading in from disk.

08:31.070 --> 08:35.210
So I'm going to add one of these to our character class info data asset.

08:35.210 --> 08:44.780
So that's going to be in public ability system data character class info I'm going to add a new subclass

08:44.780 --> 08:46.580
of you gameplay effect.

08:46.580 --> 08:48.050
So here's one.

08:48.050 --> 08:54.920
So I'm going to just copy it and go down into the data asset and add one way down here it's going to

08:54.920 --> 08:58.010
be just above secondary attributes.

08:58.580 --> 09:04.010
And I'm going to call this primary attributes underscore set by color.

09:04.160 --> 09:08.780
That way it's specifically a set by color version of this.

09:08.780 --> 09:10.850
And it's going to be in common class defaults.

09:10.850 --> 09:16.310
It doesn't have to be specific to any character class because the character class doesn't matter.

09:16.310 --> 09:22.460
We're going to set those four primary attributes by set by color based on what we've loaded in from

09:22.460 --> 09:23.000
disk.

09:23.000 --> 09:30.140
So now that character class info has this primary attribute set by color, we need to create a primary

09:30.140 --> 09:33.380
attributes gameplay effect and change it to set by color.

09:33.380 --> 09:41.600
Well, I can go to Ability System Aura effects and get my GE aura primary attributes.

09:41.600 --> 09:46.250
Now this has strength, intelligence, resilience and vigor.

09:46.250 --> 09:50.180
And these are set to default values here.

09:50.180 --> 09:55.280
And really these could just be the starting values if we're loading in for the first time.

09:55.280 --> 10:01.340
But if we're not loading in for the first time we should have another one with set by color magnitudes.

10:01.520 --> 10:05.540
So I'm going to duplicate aura primary attributes.

10:06.230 --> 10:14.780
But I'm going to call this one GE primary attributes underscore set by color.

10:15.770 --> 10:21.170
And this will have the same four primary attributes, but they'll be set by color.

10:21.740 --> 10:27.620
So I'm going to take the magnitude calculation type and change it to set by color, and choose the data

10:27.620 --> 10:31.250
tag to be the attribute tag for this attribute.

10:31.250 --> 10:34.700
So that's going to be attributes primary for this one.

10:34.700 --> 10:35.690
It will be strength.

10:35.690 --> 10:40.580
Next is intelligence I'm going to set magnitude calculation type to set by color.

10:41.030 --> 10:44.060
Choosing intelligence.

10:44.960 --> 10:46.700
Next is resilience.

10:47.090 --> 10:52.010
We'll change this to set by color and the tag will be resilience.

10:52.310 --> 10:54.140
And finally vigor.

10:55.510 --> 10:59.320
We're going to change this to set by color and choose vigor.

10:59.590 --> 11:01.840
So now we have a set by color version.

11:01.840 --> 11:07.720
And we can set that on our character class info as soon as we compile and launch again.

11:07.720 --> 11:09.040
Now that we have this.

11:09.970 --> 11:16.750
So back in C plus plus we need a way to apply that and set it's set by color magnitudes, but only if

11:16.750 --> 11:18.610
we're not loading in for the first time.

11:18.610 --> 11:22.270
So how are we going to know if we've loaded in for the first time?

11:22.270 --> 11:24.310
Well, that's something we could save.

11:24.310 --> 11:30.580
It's something that we could have on our load screen save game, such as a boolean.

11:30.580 --> 11:33.700
I could put this all the way at the top, actually just above player.

11:33.700 --> 11:34.630
We'll put it right here.

11:34.630 --> 11:44.230
We can have a bool called be first time load in and set it to true by default.

11:44.230 --> 11:47.020
So the first time we load in we can set this to true.

11:47.020 --> 11:50.500
And we can check this when loading in our stats.

11:50.500 --> 11:57.430
And that way we'll know if we should use the default values or if we should load in from disk.

11:57.430 --> 12:01.840
Now, if we've saved our progress then we need to set this to false.

12:01.840 --> 12:04.870
So let's take care of that before we move on.

12:04.870 --> 12:08.500
So when are we going to save our progress?

12:08.500 --> 12:10.120
When we hit a checkpoint.

12:10.120 --> 12:11.020
Right.

12:11.020 --> 12:14.050
When we hit a checkpoint is when we save our progress.

12:14.050 --> 12:16.180
So let's go to checkpoint CP.

12:16.180 --> 12:19.030
And here we have execute save progress.

12:19.030 --> 12:27.520
So if we go into character or a character into save progress implementation, here is where we know

12:27.520 --> 12:30.070
that we're no longer fresh.

12:30.070 --> 12:32.230
We've just saved for the first time.

12:32.230 --> 12:38.170
We need to take our save data and take be first time load in and set it to false.

12:38.170 --> 12:42.940
Now we can check this if we need to know if this is our first time loading in.

12:42.940 --> 12:46.000
So back to load progress.

12:46.000 --> 12:50.440
We can check here if this is our first time loading in right here.

12:50.440 --> 13:01.960
We'll say if save data be first time load in, well then we can just do what we were doing before we

13:01.960 --> 13:04.120
can apply our default attributes.

13:04.120 --> 13:07.150
We can use that function that we just took out.

13:07.150 --> 13:09.490
Initialize default attributes.

13:09.490 --> 13:12.940
We can even add our character abilities as well.

13:14.290 --> 13:20.440
And whatever we have set for these, for our initial attributes and abilities, that's what we'll set.

13:20.440 --> 13:23.620
But that's only if it's a first time load in.

13:23.650 --> 13:26.020
If it's not, we have the else case.

13:26.020 --> 13:28.390
Then we need to load in from disk.

13:28.390 --> 13:35.920
And that means we need to apply some gameplay effects to initialize our attributes.

13:35.920 --> 13:38.860
And then of course we'll handle abilities shortly.

13:38.860 --> 13:45.640
But how are we going to apply our primary attributes and our secondary and our vital.

13:45.670 --> 13:51.130
Well, if we go to our ability system library we'll go to the cpp file.

13:51.160 --> 13:54.970
Here's a function called initialize default attributes.

13:54.970 --> 13:58.390
Here's a good example of how we can apply attributes.

13:58.390 --> 14:05.800
We're not setting any set by color magnitudes here, but we are applying gameplay effects and we're

14:05.800 --> 14:10.750
getting those gameplay effects from our data asset character class info.

14:10.750 --> 14:15.850
We're getting the class default info, getting the primary, secondary, and vital attributes.

14:15.850 --> 14:24.250
From that, we can create a Aura Ability system library function to apply set by color magnitudes that

14:24.250 --> 14:27.340
we retrieve from a save game object.

14:27.550 --> 14:30.820
So I'd like to create a function to do that.

14:30.820 --> 14:33.190
And we'll do that in the next video.

14:33.190 --> 14:35.020
So we're almost there.

14:35.020 --> 14:39.220
We're almost ready to initialize our default attributes from disk.

14:39.220 --> 14:41.020
We just need a function to do it.

14:41.020 --> 14:42.580
So we'll do that next.

14:42.580 --> 14:49.810
But before we wrap up though, let's compile so we can add that primary attribute gameplay effect with

14:49.810 --> 14:52.360
set by colors to our data asset.

14:52.360 --> 14:56.590
I'm just going to close down and relaunch the editor okay.

14:56.590 --> 15:00.190
So back in the editor we can go to character class info.

15:00.190 --> 15:06.190
And down in our common class defaults we have primary attributes set by color.

15:06.190 --> 15:12.160
And we can use our set by color primary attributes gameplay effect we created here.

15:12.160 --> 15:20.320
So this primary attribute set by color is just like our other primary attributes gameplay effects,

15:20.320 --> 15:24.040
except it requires set by color magnitudes.

15:24.040 --> 15:28.000
And that's what we're going to use to set these when loading in from disk.

15:28.000 --> 15:31.360
So we'll create a function to do that in the next video.

15:31.630 --> 15:34.750
So excellent job I'll see you soon.
