• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

code for save/load a hero

Status
Not open for further replies.
Level 11
Joined
Apr 28, 2008
Messages
696
Sers,

some of you have maybe seen my previews of my inventory and interfacesystems. I'm thinking about adding a multiplayer mod of my RPG. And for that mod I'm thinking of a save/load system that uses a code. So far no problem. But because of the complexity of my RPG much data has to be stored. That means the code will become veeeeeeery long. The code is a string and will displayed to the player who wants to save. For now I don't think about encryption, cause my problem is the length of the code.

Things that have to be stored:

A hero can carry up to 90 items in his backpack, 5 in his belt and 13 in his equipment slots => up to 108 different items to store. Every item needs 2 digits for coding it's type and an additional one for coding the stacksize. In the worst case I'll have to store 108 different items and 95 of them are itemsstacks:

=> 95 * 3 + 13 * 2 = 311 digits for the items(worst case)

The hero lvl and his attributs will take 8 digits. Talentpoints won't be saved. They'll be given in depency of the herolvl. So you'll have to reskill your talents after loading your hero.

For the weapon/armourskills of the hero I have to store the progress of every skill, a number between 1 and 250 => 2 digits in hexadecimal (there are all about 28 skills)

=> 28 skills * 2 = 56 digits

That comes to an overall result of MAXIMAL(if your hero carries 108 different items and 95 of them are itemstacks) 375 digits*sigh*. A 375 digitscode will look like:





And my question is, is there a way to compress that code and reduce its size without losing data?


You can save the code by capturing it with a screenshot, but you'll have to enter it manually, as long you didn't save it in a *.txt-file and simply copy&paste in game(that's the way I would do it).

If anyone has an idea, plz answer :)

Thy
 
Level 9
Joined
Apr 25, 2009
Messages
468
I am planing on making the most simple save & load EVER, wont even need codes to load.
If I do this, ill give you a link for download :p

Answer to your Question: Try downloading an Save & Load system and see there :p
 
Level 11
Joined
Apr 28, 2008
Messages
696
Thanks for advice :), but I know HOW to make a save system. The problem is the length of the required code to store all data.

And my question still is:

Is there a way to reduce the length of a code that contains a-z A-Z 1-9 so that there will be no lose of data?
 
Level 12
Joined
Dec 10, 2008
Messages
850
For the weapon and armour skills, are they added via triggers or taught by the player? If its player taught, then dont bother saving those, because a max of 5 abilitys to be re-learnt isnt that hard. If its added by triggers, you could try checking the level of the hero when the -load substring is enterd.

You could also try cutting down on the backpack size, I mean, 90 items? Holy crow, are the heros trying to carry half the map?

This sounds like its gunna be "Fun" for you to code. Hope these help you in some way.
 
Level 11
Joined
Apr 28, 2008
Messages
696
For the weapon and armour skills, are they added via triggers or taught by the player? If its player taught, then dont bother saving those, because a max of 5 abilitys to be re-learnt isnt that hard. If its added by triggers, you could try checking the level of the hero when the -load substring is enterd.

You could also try cutting down on the backpack size, I mean, 90 items? Holy crow, are the heros trying to carry half the map?

This sounds like its gunna be "Fun" for you to code. Hope these help you in some way.

The skills are no WC3 skills. Your hero "trains" in the skills by using weapons or wearing armour. The higher the skill is, the better he fights with the weapon. That means every skillprogress is an integervalue between 1 and 250. That means using hexadecimal that can code 0-255 would be enough, so 2 digits per skill.

The high number of items is a mainpart of the game. You'll be able to raid dungeons and collect itemsets etc. Further there are 5 producing professions where you can craft items like armour or potions etc. So not saving that items would really suck, you know^^
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
There's no lossless compression method that possibly makes it smaller. There's a reason why no orpg ever uses fullscreen inventories...

I can think of 2 optimizations:
1) Don't use hexadecimal encoding. Using all characters (upper- and lowercase) and numbers can get you to base 62. For easy conversions with binary numbers, you can add an additional 2 characters so you can store numbers in base 64 instead of base 16. That'll reduce your # of characters from 375 to +/- 300

2) Store meta information about your items. Simply start your savecode with 1 integer between 0 and 108 that stores how many items your inventory contains. Then, the rest of your savecode only contains the itemid's of the items in your inventory. This will make your savecode of variable length. In a worst case scenario you'll still need 300 digits, but in best case scenario you don't need to use any digits at all for items.

Conclusion: you probably have to remove your fullscreen inventory. At the very least.

I am planing on making the most simple save & load EVER, wont even need codes to load.
Allow me to be very sceptic, since I don't believe in magic.
 
Level 11
Joined
Apr 28, 2008
Messages
696
Ok, thank you all. So I'm not an idiot at all because of not finding a solution.*g*

I thought about the features that the code scales with the amount of data that have to be stored. So storing more items will make the code longer.

Maybe there is a solution. I will be able to test if the whole string converted to integer can be devided by a large integervalue. If so, the value wil be dived and shorten in length. Than the divisor is added to the code to give info with what number the code has been edited and multipy the code before loading again. If the integer is a prim or can't be divied without rest, than you'll have to enter the whole code. Just a thought :)

And I think, if you really like a game, you'll also accept to enter a 375 digit code. Than that what you'll get in exchange for the code will be worth it.
 
Level 9
Joined
Apr 25, 2009
Messages
468
Save codes kinda sucks, they are not eaven needed...
Base the whole save & load system on Player Names, 10x more simple
for the players. Requires more skills than "code" systems, but as I said,
much much better...

I made a system like this a few months ago, if I find it ill post it here.
It saves exp, gold, lumber, items & ofc, units. ohh, and levels :D
 
Status
Not open for further replies.
Top