Welcome back.
Now that we have the ability to load in at the correct checkpoint, the last one we saved at and we're
saving world state.
So all checkpoints that have previously been reached are already reached.
We can't reach them again.
They're all glowy and that looks great.
Now it's time to start saving player state.
Now, I don't mean the player state class, I mean the state of all the variables pertaining to our
player such as level attributes, attribute points, all of that great information that we can load
in with.
We're going to want to figure out how we can save all that.
Well, if we're going to save anything, it needs to be in our save game object so we can start there.
I'm going to go ahead and close all my tabs and just go into my save game object header file.
That's going to be in game load screen save game.
Now we called it load screen save game.
But really we could have just called it Aura Save game.
Right?
Because it's going to contain all of the information that we're going to save.
And all of this stuff at the top is kind of just necessary for a save game object.
We have the slot name, the slot index.
We have the player name.
That pertains to the load screen and we have our map name, the player start tag, save slot status,
and then the save actors for the world.
Underneath this though, we can start having more player specific stuff.
We're going to say player.
We don't want to say player state because that sounds like the player state class.
I'm just going to say player here.
So what all do we need for our player?
What do we need to save?
Well, there are four variables that come to mind that exist on the player state.
Those are the player level.
Let's just go ahead and add these as we can think of them.
That's an INT 32 called the player level.
And we'll give these all default values I'll start them off at zero.
But of course we're going to save them right.
We're going to save and load them.
So it doesn't really matter what we initialize them with.
But there's player level.
We're also going to want our XP.
We'll just call that XP.
And our player state also has spell points and attribute points.
Let's do that too.
We'll have spell points and we'll have attribute points.
And in your game.
If you have more things you need to save from your player state, you'd add them here too.
Now.
In addition to that, we have attributes and thanks to all of our attributes, except for primaries
being derived from other attributes, all we need to save are the primaries, because if we set the
primary attributes, the secondary attributes are all based on the primaries or each other, and the
vital attributes are based on other attributes as well.
So everything is derived from the primaries.
So if we save the primary attributes we're set when it comes to attributes, at least in this project,
if you had other attributes you needed to save, you'd save them too.
So we're going to save these as floats.
I'm going to start with strength.
And these will all get defaults of zero and new properties.
So there's a strength and we need four more.
I'm just going to copy this and paste it four times one two actually three for a total of four.
And we're going to have strength intelligence resilience and vigor.
And with that we have our primary values.
Now this is everything except for abilities.
We'll do the abilities in a future video.
For now, let's just get these basic numerical values.
We want to be able to save these.
So how are we going to save them?
Well, first of all, before we answer that question, we should ask ourselves where in the code should
we save them?
Well, we should save them in our interface function.
Save progress.
Right.
Let's go into character and we'll just go straight to the private folder character or a character we
have save progress.
This is where we're saving the checkpoint tag that's passed in here, because this is called from a
checkpoint.
And while we're saving that player start tag the checkpoint tag, we can save all the other pertinent
data that we need to save right here in save progress.
That's what we need to do.
So four of those variables are on the player state.
So we need to access the player state.
So let's get the player state here.
We're going to say a or a player state.
Or a player state equals a cast to A or a player state.
And we're going to call get Player state.
We can wrap this in an if statement.
And we can start saving those four variables on the player state to our save data.
So we're going to take save data.
And let's just start with player level.
We're going to get our player state and call get player level.
And we'll do this three more times.
One.
Two, three.
Only we're going to change what we're setting here instead of player level.
We're going to have what's the next one XP and we'll call get XP.
We also have attribute points.
Let's call.
Get attribute points and we have spell points.
We'll call get spell points.
And now our save data is going to contain those four variables.
Okay.
Now we also have to save our primary attributes.
Well how are we going to get our primary attributes.
Well we have you ora attribute set.
And we have get strength attribute which is static.
And from this we can get numeric value.
Now get numeric value requires an attribute set.
But or a character has a get attribute set function.
We made that.
That makes it easy right?
So this gives us the strength attribute.
We can save that and our save data.
We can take save data strength and set it equal to this.
And we'll do the same thing for the other attributes.
Let's take save data.
We'll do intelligence next.
And I'm going to copy this line and change this to get intelligence attribute.
Let's do our next one.
We'll do Resilience control V and change this to get resilience attribute.
And one more save data Vigor.
And we'll paste and use get vigor attribute.
So now our save data has these four values from the player state and these four values from our attribute
set.
And our load screen save game just has those eight values.
And I'll go ahead and give this a comment that says attributes.
So with that, we're saving our progress.
Now.
How do we load our progress?
How do we set these when loading in?
Well that's a little bit more involved.
And we're going to do that in the next video.
So excellent job.
Let's go ahead and just quickly compile.
Make sure we didn't do any terrible things.
Looks like we're good.
And in the next video we'll load our progress I'll see you soon.