Page 1 of 2

Saving and loading game data

Posted: Thu Nov 25, 2010 10:22 am
by N64vSNES
So saving and loading game data is somthing that rarely gets talked about, however its a vital part of game logic that for many big projects needs to be planned out carefully and I'm curiouse and thought it would be nice to get some peoples ideas on the approach people should take.

Looking at Ocarina Of Time for the Nintendo 64, the save data is fairly simple.

You can't exit the kokiri forest because the is a npc guarding the exit, however if you complete the deku tree's level then that npc will let you pass.

if you have completed the deku tree then npcs in the forest normally say somthing like
"I see you have a fairly at least, good for you"

And when you completed the deku tree they say stuff like
"What has happened to the deku tree?"

If you cheat your way past that npc guarding the exit to the forest you get the spritual stone of the forest and then when you go back in the npcs will say somthing diffrent

My theory is that the game only saves vital aspects such as

-What spirtual stones you have
-What sage coins you have
-What rupees you have
-What equipment you have

Every major level such as temples, dungeons, etc you recive somthing vital such as a stone, a sage coin, a piece of equipment.

Somtimes you need a special peice of equipment to enter the level after the level you recive this peice of equipment.

Like I said this area of game development dosen't often get viewed and I find these methods extremely clever since by saving such tiny amounts of game data you can predict exactly what distance into the game you are.

The reason I'm using The Legand Of Zelda as a example is because its so basic but effective.

Not all games function like zelda though so I'm very intrested in peoples ideas and opinions on how you would go about implementing this and handling this?

Re: Saving and loading game data

Posted: Fri Nov 26, 2010 2:32 am
by Milch
But as far as I know, they also save how far you progressed in a dungeon, are they?
I mean, if you exit the dungeon and enter it again, you don't have to redo it all over again.

Re: Saving and loading game data

Posted: Fri Nov 26, 2010 6:27 am
by pritam
Final Fantasy VII is one of my favorite games and perhaps the one I've played the most, while playing it I often wondered how the save/load game data was structured. I can't speak for the way FF does this, but I /imagine/ the data includes a variable like worldState (storyProgress or what have you) that upon key plot events increases one by one. Now each area has a default state that works for the general worldState, beyond that the areas can act specifically on one or more ranges of values or simply single values, basicly, worldState controls the area's NPCs, their conversations, minor/major changes to the tilemap and things like that.

Re: Saving and loading game data

Posted: Fri Nov 26, 2010 9:07 am
by N64vSNES
Milch wrote:But as far as I know, they also save how far you progressed in a dungeon, are they?
I mean, if you exit the dungeon and enter it again, you don't have to redo it all over again.
Well yes if you enter a dungeon and save the game then reload the game certin entities such as treasure chests and the web in the first level ( the deku tree ) but these are nessacary to save however basic enemies like the spiders that climb on walls respawn every time ( even if you just leave the room )

So is defnitly more than the stat/equipment that gets saved but I didn't want to go too in depth about it as what I've said about it so far is threoretical.
pritam wrote:Final Fantasy VII is one of my favorite games and perhaps the one I've played the most, while playing it I often wondered how the save/load game data was structured. I can't speak for the way FF does this, but I /imagine/ the data includes a variable like worldState (storyProgress or what have you) that upon key plot events increases one by one. Now each area has a default state that works for the general worldState, beyond that the areas can act specifically on one or more ranges of values or simply single values, basicly, worldState controls the area's NPCs, their conversations, minor/major changes to the tilemap and things like that.
I'm yet to play Final fantasy but I hear its a great game, I hope to play it sometime :)

Re: Saving and loading game data

Posted: Wed Dec 01, 2010 8:40 am
by RyanPridgeon
I agree with Pritam. Everything that you talked about in your post about what the characters say, what equipment you have, are really all just saved as states somewhere. I would imagine the simplest way you could do it is just make a note of all the states that need to be saved, and just incorporate them into your saving/loading procedures.

I assume large, modern games have more elegant solutions, like SaveState, GetState or some other kinds of methods being included in all their game objects, as part of their program's structure. But that's just a guess. Still, it all just comes down to keeping track of the world and objects through their states.

Re: Saving and loading game data

Posted: Wed Dec 01, 2010 9:10 am
by N64vSNES
RyanPridgeon wrote:I agree with Pritam. Everything that you talked about in your post about what the characters say, what equipment you have, are really all just saved as states somewhere. I would imagine the simplest way you could do it is just make a note of all the states that need to be saved, and just incorporate them into your saving/loading procedures.

I assume large, modern games have more elegant solutions, like SaveState, GetState or some other kinds of methods being included in all their game objects, as part of their program's structure. But that's just a guess. Still, it all just comes down to keeping track of the world and objects through their states.
Yeah but you have to admit its pretty clever how the game can calculate the exact distance into the game you are from such little information :)

Re: Saving and loading game data

Posted: Mon Dec 27, 2010 1:48 pm
by pritam
N64vSNES wrote:
RyanPridgeon wrote:I agree with Pritam. Everything that you talked about in your post about what the characters say, what equipment you have, are really all just saved as states somewhere. I would imagine the simplest way you could do it is just make a note of all the states that need to be saved, and just incorporate them into your saving/loading procedures.

I assume large, modern games have more elegant solutions, like SaveState, GetState or some other kinds of methods being included in all their game objects, as part of their program's structure. But that's just a guess. Still, it all just comes down to keeping track of the world and objects through their states.
Yeah but you have to admit its pretty clever how the game can calculate the exact distance into the game you are from such little information :)
It's really simple actually if you know your engine/system, you could calculate the story progression from the amount of dialog text between key plot events for instance, dialog that is vital to key plot events. Or simply divide the worldState's number with the total amount of key events for an estimate.

Re: Saving and loading game data

Posted: Mon Dec 27, 2010 2:44 pm
by dnxviral
I'm glad you bring this up because I'm currently trying to design my own 'how far/where are/what are you in a game' solution. I was thinking about using something like a list. A progression list of the story line, key objects that you'd get or set during game play. Once you get one or complete something it's crossed off that list.

But what I need to think about is how that effects game play now and how to program characters to 'know' how far the player is. Im glad somebody is shedding a bit more light on the subject.

Re: Saving and loading game data

Posted: Wed Dec 29, 2010 3:50 am
by pritam
dnxviral wrote:I'm glad you bring this up because I'm currently trying to design my own 'how far/where are/what are you in a game' solution. I was thinking about using something like a list. A progression list of the story line, key objects that you'd get or set during game play. Once you get one or complete something it's crossed off that list.

But what I need to think about is how that effects game play now and how to program characters to 'know' how far the player is. Im glad somebody is shedding a bit more light on the subject.
I don't see how a list like that would be efficient technically and not sure what you mean with
crossed off that list
But a list of storyline progression could easily be tied to a story progression variable.

I can't help you any further with this right now but I hope it works out.

Re: Saving and loading game data

Posted: Wed Dec 29, 2010 9:04 am
by dnxviral
Pritam wrote:I don't see how a list like that would be efficient technically and not sure what you mean with
crossed off that list
But a list of storyline progression could easily be tied to a story progression variable.

I can't help you any further with this right now but I hope it works out.
Exactly. Figuratively it'd be a list, otherwise a variable that'd tell how far someone was in the game.
Hope to hear some other ideas.

Re: Saving and loading game data

Posted: Wed Dec 29, 2010 9:27 am
by N64vSNES
I forgot about this thread XD

For EQ the way I vision we will have it is the major stuff will be saved with the engine ( without giving too much storyline away ) the are severall items you will need to collect along your quest in the temples/dungeons etc

So in the game ( well in lua )

Code: Select all

--New map loaded, this script will get executed

if Party:HasKeyItem(1) then -- If we have our first item
Map:SetTile(20,20,1) -- Lay a rock iin front of the temple
end
So then like in Zelda 2 the dungeon has a rock infront of the temple, or maybe the temple can collapse. For certin entities such as chests and whatnot I'm not sure how we will do that.

Think this is a solid design?

Re: Saving and loading game data

Posted: Wed Dec 29, 2010 2:50 pm
by dnxviral
N64vSNES wrote:I forgot about this thread XD

For EQ the way I vision we will have it is the major stuff will be saved with the engine ( without giving too much storyline away ) the are severall items you will need to collect along your quest in the temples/dungeons etc

So in the game ( well in lua )

Code: Select all

--New map loaded, this script will get executed

if Party:HasKeyItem(1) then -- If we have our first item
Map:SetTile(20,20,1) -- Lay a rock iin front of the temple
end
So then like in Zelda 2 the dungeon has a rock infront of the temple, or maybe the temple can collapse. For certin entities such as chests and whatnot I'm not sure how we will do that.

Think this is a solid design?
Hmm not sure how well that would work. Instead of checking if your player got a certain item every time you loaded a map... , should it be presets when you load your player game file it changes all the maps up to a certain point dependent on your progression variable? Which would change when you got a certain item the only problem I currently see with this approach are loop holes in which a player could advance farther if theirs an item on the 'progression list' thats farther than their next 'task'.

I'm fairly new to saving/loading so correct me if I'm wrong :oops: And I like to think out loud ea post

Re: Saving and loading game data

Posted: Wed Dec 29, 2010 3:35 pm
by N64vSNES
dnxviral wrote:
N64vSNES wrote:I forgot about this thread XD

For EQ the way I vision we will have it is the major stuff will be saved with the engine ( without giving too much storyline away ) the are severall items you will need to collect along your quest in the temples/dungeons etc

So in the game ( well in lua )

Code: Select all

--New map loaded, this script will get executed

if Party:HasKeyItem(1) then -- If we have our first item
Map:SetTile(20,20,1) -- Lay a rock iin front of the temple
end
So then like in Zelda 2 the dungeon has a rock infront of the temple, or maybe the temple can collapse. For certin entities such as chests and whatnot I'm not sure how we will do that.

Think this is a solid design?
Hmm not sure how well that would work. Instead of checking if your player got a certain item every time you loaded a map... , should it be presets when you load your player game file it changes all the maps up to a certain point dependent on your progression variable?

I'm fairly new to saving/loading so correct me if I'm wrong :oops: And I like to think out loud ea post
Well most of EQ will be lua, and the will be at least one new script loaded per map so its not going to be the entire purpose of the script. I don't know if this is how we are going to handle it but this is what I've been thinking could work.

Re: Saving and loading game data

Posted: Tue Jan 04, 2011 10:47 am
by dnxviral
Well we just talked about what were saving.. But I'm quite interested in how the actual saving would work? Not what we save but how we save it.

Re: Saving and loading game data

Posted: Tue Jan 04, 2011 11:52 am
by N64vSNES
dnxviral wrote:Not what we save but how we save it.
Obviously the only way to get data static from a program executing and terminating would be to save it to a file.