WEBVTT

00:06.800 --> 00:07.790
Welcome back.

00:08.180 --> 00:14.870
Now that we have the ability to load in at the correct checkpoint, the last one we saved at and we're

00:14.870 --> 00:16.280
saving world state.

00:16.280 --> 00:21.560
So all checkpoints that have previously been reached are already reached.

00:21.560 --> 00:22.700
We can't reach them again.

00:22.700 --> 00:25.940
They're all glowy and that looks great.

00:25.970 --> 00:28.790
Now it's time to start saving player state.

00:28.820 --> 00:35.450
Now, I don't mean the player state class, I mean the state of all the variables pertaining to our

00:35.450 --> 00:44.120
player such as level attributes, attribute points, all of that great information that we can load

00:44.120 --> 00:44.810
in with.

00:44.840 --> 00:48.320
We're going to want to figure out how we can save all that.

00:48.320 --> 00:53.660
Well, if we're going to save anything, it needs to be in our save game object so we can start there.

00:54.580 --> 01:01.060
I'm going to go ahead and close all my tabs and just go into my save game object header file.

01:01.060 --> 01:04.930
That's going to be in game load screen save game.

01:05.380 --> 01:07.600
Now we called it load screen save game.

01:07.600 --> 01:10.150
But really we could have just called it Aura Save game.

01:10.150 --> 01:10.600
Right?

01:10.600 --> 01:16.300
Because it's going to contain all of the information that we're going to save.

01:16.480 --> 01:22.300
And all of this stuff at the top is kind of just necessary for a save game object.

01:22.300 --> 01:24.820
We have the slot name, the slot index.

01:24.820 --> 01:26.410
We have the player name.

01:26.980 --> 01:34.630
That pertains to the load screen and we have our map name, the player start tag, save slot status,

01:34.630 --> 01:37.300
and then the save actors for the world.

01:37.300 --> 01:41.740
Underneath this though, we can start having more player specific stuff.

01:41.740 --> 01:43.330
We're going to say player.

01:45.260 --> 01:48.830
We don't want to say player state because that sounds like the player state class.

01:48.830 --> 01:50.450
I'm just going to say player here.

01:50.930 --> 01:54.140
So what all do we need for our player?

01:54.140 --> 01:55.580
What do we need to save?

01:55.580 --> 02:00.890
Well, there are four variables that come to mind that exist on the player state.

02:01.280 --> 02:03.080
Those are the player level.

02:03.320 --> 02:06.350
Let's just go ahead and add these as we can think of them.

02:06.350 --> 02:09.380
That's an INT 32 called the player level.

02:10.040 --> 02:13.910
And we'll give these all default values I'll start them off at zero.

02:13.910 --> 02:16.010
But of course we're going to save them right.

02:16.010 --> 02:17.960
We're going to save and load them.

02:17.960 --> 02:20.570
So it doesn't really matter what we initialize them with.

02:20.570 --> 02:22.460
But there's player level.

02:22.670 --> 02:25.430
We're also going to want our XP.

02:26.210 --> 02:27.800
We'll just call that XP.

02:27.800 --> 02:32.240
And our player state also has spell points and attribute points.

02:32.240 --> 02:33.380
Let's do that too.

02:33.380 --> 02:38.150
We'll have spell points and we'll have attribute points.

02:39.680 --> 02:40.970
And in your game.

02:40.970 --> 02:46.190
If you have more things you need to save from your player state, you'd add them here too.

02:46.280 --> 02:47.210
Now.

02:48.120 --> 02:55.380
In addition to that, we have attributes and thanks to all of our attributes, except for primaries

02:55.380 --> 03:01.380
being derived from other attributes, all we need to save are the primaries, because if we set the

03:01.380 --> 03:07.800
primary attributes, the secondary attributes are all based on the primaries or each other, and the

03:07.800 --> 03:11.070
vital attributes are based on other attributes as well.

03:11.070 --> 03:13.650
So everything is derived from the primaries.

03:13.650 --> 03:20.220
So if we save the primary attributes we're set when it comes to attributes, at least in this project,

03:20.430 --> 03:24.000
if you had other attributes you needed to save, you'd save them too.

03:24.120 --> 03:25.980
So we're going to save these as floats.

03:25.980 --> 03:27.570
I'm going to start with strength.

03:28.170 --> 03:32.370
And these will all get defaults of zero and new properties.

03:32.370 --> 03:36.210
So there's a strength and we need four more.

03:36.210 --> 03:42.930
I'm just going to copy this and paste it four times one two actually three for a total of four.

03:42.930 --> 03:50.100
And we're going to have strength intelligence resilience and vigor.

03:51.900 --> 03:55.440
And with that we have our primary values.

03:55.440 --> 03:58.350
Now this is everything except for abilities.

03:58.350 --> 04:00.870
We'll do the abilities in a future video.

04:00.870 --> 04:04.650
For now, let's just get these basic numerical values.

04:04.650 --> 04:06.870
We want to be able to save these.

04:07.290 --> 04:09.210
So how are we going to save them?

04:09.690 --> 04:16.110
Well, first of all, before we answer that question, we should ask ourselves where in the code should

04:16.110 --> 04:17.070
we save them?

04:17.760 --> 04:21.240
Well, we should save them in our interface function.

04:21.240 --> 04:22.530
Save progress.

04:22.530 --> 04:23.100
Right.

04:23.100 --> 04:30.990
Let's go into character and we'll just go straight to the private folder character or a character we

04:30.990 --> 04:32.130
have save progress.

04:32.130 --> 04:38.340
This is where we're saving the checkpoint tag that's passed in here, because this is called from a

04:38.340 --> 04:39.330
checkpoint.

04:39.510 --> 04:46.410
And while we're saving that player start tag the checkpoint tag, we can save all the other pertinent

04:46.410 --> 04:50.130
data that we need to save right here in save progress.

04:50.580 --> 04:52.590
That's what we need to do.

04:52.590 --> 04:56.190
So four of those variables are on the player state.

04:56.190 --> 04:58.380
So we need to access the player state.

04:58.380 --> 05:00.450
So let's get the player state here.

05:00.450 --> 05:04.800
We're going to say a or a player state.

05:07.280 --> 05:15.320
Or a player state equals a cast to A or a player state.

05:17.710 --> 05:19.750
And we're going to call get Player state.

05:22.870 --> 05:25.270
We can wrap this in an if statement.

05:27.270 --> 05:33.360
And we can start saving those four variables on the player state to our save data.

05:34.800 --> 05:36.660
So we're going to take save data.

05:36.660 --> 05:40.170
And let's just start with player level.

05:41.070 --> 05:48.030
We're going to get our player state and call get player level.

05:50.530 --> 05:53.410
And we'll do this three more times.

05:53.410 --> 05:53.890
One.

05:53.890 --> 05:55.300
Two, three.

05:55.330 --> 06:00.160
Only we're going to change what we're setting here instead of player level.

06:00.160 --> 06:06.190
We're going to have what's the next one XP and we'll call get XP.

06:08.870 --> 06:11.210
We also have attribute points.

06:12.420 --> 06:13.620
Let's call.

06:14.290 --> 06:18.130
Get attribute points and we have spell points.

06:18.880 --> 06:21.970
We'll call get spell points.

06:23.930 --> 06:28.730
And now our save data is going to contain those four variables.

06:29.150 --> 06:30.170
Okay.

06:30.200 --> 06:34.520
Now we also have to save our primary attributes.

06:34.850 --> 06:37.880
Well how are we going to get our primary attributes.

06:37.910 --> 06:41.480
Well we have you ora attribute set.

06:42.380 --> 06:48.110
And we have get strength attribute which is static.

06:48.110 --> 06:51.650
And from this we can get numeric value.

06:52.220 --> 06:55.490
Now get numeric value requires an attribute set.

06:55.490 --> 06:59.810
But or a character has a get attribute set function.

06:59.810 --> 07:01.010
We made that.

07:01.010 --> 07:02.690
That makes it easy right?

07:02.870 --> 07:05.420
So this gives us the strength attribute.

07:05.840 --> 07:08.210
We can save that and our save data.

07:08.210 --> 07:13.490
We can take save data strength and set it equal to this.

07:14.570 --> 07:16.910
And we'll do the same thing for the other attributes.

07:16.910 --> 07:18.380
Let's take save data.

07:18.650 --> 07:20.510
We'll do intelligence next.

07:22.360 --> 07:29.020
And I'm going to copy this line and change this to get intelligence attribute.

07:30.220 --> 07:32.140
Let's do our next one.

07:32.470 --> 07:39.520
We'll do Resilience control V and change this to get resilience attribute.

07:39.520 --> 07:43.660
And one more save data Vigor.

07:45.400 --> 07:48.550
And we'll paste and use get vigor attribute.

07:48.550 --> 07:54.760
So now our save data has these four values from the player state and these four values from our attribute

07:54.760 --> 07:55.480
set.

07:56.320 --> 08:00.280
And our load screen save game just has those eight values.

08:00.280 --> 08:04.090
And I'll go ahead and give this a comment that says attributes.

08:06.370 --> 08:09.430
So with that, we're saving our progress.

08:09.430 --> 08:09.730
Now.

08:09.730 --> 08:11.950
How do we load our progress?

08:11.950 --> 08:14.920
How do we set these when loading in?

08:14.920 --> 08:17.740
Well that's a little bit more involved.

08:17.740 --> 08:20.440
And we're going to do that in the next video.

08:20.440 --> 08:22.000
So excellent job.

08:22.000 --> 08:24.130
Let's go ahead and just quickly compile.

08:24.130 --> 08:27.520
Make sure we didn't do any terrible things.

08:27.700 --> 08:28.990
Looks like we're good.

08:28.990 --> 08:33.280
And in the next video we'll load our progress I'll see you soon.
