• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

save/load system

Status
Not open for further replies.
Level 6
Joined
May 20, 2010
Messages
274
hi i just wanna ask (request) if someone could please make me a save/load code system that can save the spells of the hero

and can also save:
gold
lumber
SPELLS
level and xp
items
units (not just the hero because ill try adding pets)

and if its possible the please the numbers in the code should have a different color than the letters and the letters should be capital letters so it will not be so confusing....i hope someone will help me on this :cry:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Making a code system from scratch is hardly programming a jpeg decompressor or sorftware that can learn...

Its a simple system of base conversions followed by a hash to check code integrity. Base conversion is ammong the first topics covered in any computer science / engineering course so you should have no problem writing a small script to do so.

Additionally if you think logically about codes and stuff, you should easilly devise your own base conversion algerthim.

A code is bi directional, meaning from numbers you get a string (the code). From that code then you can get the same numbers back. Everything you store are numbers and generally the smaller the number the better. Thus instead of storing what item types you have, you store the index of an item type from an array.

A simple code system I created did this.
Firstly there was the integer to string base conversion function which took a number, the number of characters to make from it (to specify the range as variable length codes require data specifying their length which is less efficent long term) and returned a string from the integer using a character map (which was a global) as the base for the numeric system in the string. If the character map was set to "01" binary would be out putted.

Next there was a hash system, this is to prevent people altering values or loading someone elses code. For each value saved, it got the decimal string representation of that number and then hashed it and added it to the previous hash (there is a native that does this so its all easy peasy).

Finally before displaying the code I added the hash of the lowercase player string name (important as you can change your names case freely on battlenet 1.0 WC3) to the previous hash and modulared it into a small positive number which could be stored in 2-3 characters via the conversion algerthim I made above.

To generate you just add value (like hero or whatever), hash value, add value (like level), hash value, .... , hash name, add value (hash).

Now since the order of the code is constant (or should be) you can reconstruct all the values via the inverse process in the same direction.

Basically to load you just get value (like hero or whatever), hash value, get value (like level), hash value, .... , hash name and then compare the generated hash you have to the saved hash after reducing it in the same way via a final get value (hash). The end result is if the hashes match, the code was loaded properly and correctly.
 
Level 6
Joined
May 20, 2010
Messages
274
Making a code system from scratch is hardly programming a jpeg decompressor or sorftware that can learn...

Its a simple system of base conversions followed by a hash to check code integrity. Base conversion is ammong the first topics covered in any computer science / engineering course so you should have no problem writing a small script to do so.

Additionally if you think logically about codes and stuff, you should easilly devise your own base conversion algerthim.

A code is bi directional, meaning from numbers you get a string (the code). From that code then you can get the same numbers back. Everything you store are numbers and generally the smaller the number the better. Thus instead of storing what item types you have, you store the index of an item type from an array.

A simple code system I created did this.
Firstly there was the integer to string base conversion function which took a number, the number of characters to make from it (to specify the range as variable length codes require data specifying their length which is less efficent long term) and returned a string from the integer using a character map (which was a global) as the base for the numeric system in the string. If the character map was set to "01" binary would be out putted.

Next there was a hash system, this is to prevent people altering values or loading someone elses code. For each value saved, it got the decimal string representation of that number and then hashed it and added it to the previous hash (there is a native that does this so its all easy peasy).

Finally before displaying the code I added the hash of the lowercase player string name (important as you can change your names case freely on battlenet 1.0 WC3) to the previous hash and modulared it into a small positive number which could be stored in 2-3 characters via the conversion algerthim I made above.

To generate you just add value (like hero or whatever), hash value, add value (like level), hash value, .... , hash name, add value (hash).

Now since the order of the code is constant (or should be) you can reconstruct all the values via the inverse process in the same direction.

Basically to load you just get value (like hero or whatever), hash value, get value (like level), hash value, .... , hash name and then compare the generated hash you have to the saved hash after reducing it in the same way via a final get value (hash). The end result is if the hashes match, the code was loaded properly and correctly.

if you dont know....im in 1st year high school (13 years old) and we havent had orientation yet (meaning we still dont have classess) so all i know is for grade 6 elementary level :p
 
Level 6
Joined
May 20, 2010
Messages
274
uhhmm..dr super good...if you dont mind or your really super good :D can you please give me a sample map of the script that you were saying? i think it might help me further :D
 
Last edited by a moderator:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
My save system (one version of)

To save something.
call SaveCode_InitCode(Player) //Start code generation for Player, this is not MPI as there is no reason to create codes parralel so just create them in series for players (one at a time).
call SaveCode_EncodeNatural(Integer,Characternum) //Adds a number to the code, the range is specified by Characternum (character map^Characternum is max range). This can be called as many times as you wish for each element you want the code system to store.
call SaveCode_FinishCode(Characternum) //Finishes the code and displays it to the player using Characternum number of characters for code and name integrity.

call SaveCode_InitLoad(Player,loadcode) //Starts the loadcode process for Player with the code string loadcode.
SaveCode_DecodeNatural(Characternum) //Returns a saved integer from loadcode in the same order the code was genenerated. Be warned that the Characternum must match up 1:1 with the code feneration and code load so no extra characters remain.
SaveCode_FinishLoad(Characternum) //Returns if the code is valid(true) or if it was damaged. Same deal with the above function, must match up 1:1 with the generator SaveCode_FinishCode function.

Far from the best save system but was one I made in under a day. Few other save systems allow the saving and generation of a code this easilly and most are not as efficent.
 
Level 9
Joined
Jan 3, 2010
Messages
359
It can save any natural number you want it to, be it exp, skills, items or what not.

Ofcourse you will have to make a system of converting your hero skills into compact natural numbers and back again but those generally are simple arrays / hashtable systems.

do u know how to save an item id that inside a struct ?
i really no idea how to do that ....
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
firstily get the item id.
struct.itemid where struct is a reference to the struct and itemid the reference to the variable inside it.

Then pass that through an item reducing system whereby it takes the item id and returns a small integer based on the number of savable items in your map (this is to reduce code size a lot). Likewise you have an inverse system to take in item saved integer and return an itemid to make the item from.
 
Last edited:
Level 2
Joined
Jun 27, 2010
Messages
20
doctor D: i cant understands you... gah ENGLISH please...

anywho, as he was saying, however, you need to set your abilites in variable arrays or hashtables, or whatever is your fetish. then, have that number saved in a system, then when you load have it check for what those values are... say.. you saved a 1 ... that means your hero had flame strike. and you saved a 2 right after that. that meant that the level of the last loaded ability was two...

i dont know if im explaining this well enough, but ill try to elaborate if you would like :/
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Yes if you get it to save skill data. You however will have to tell it how it should do that.

It basically saves numbers (like all save systems do). The numbers can be anything like quest position, gold, exp, hero, skill levels, abilites, items, you name it. You however are responsible as a map maker for comming up with what numbers everything is.

In the case of abilities, if they are based on hero type then you just save the ability levels in slots where from the slot offset and hero type you can get the right ability to level. For customizable abilities you need to save the ability in a certain ability slot as well as its level.

You do not need anything advanced and feel free to do loop searches to find data despite how unefficent they are. I would generally imagine there would be some sort of array system where the seved number is the index of an item in the array. For ability levels you just save the ability level.
 
Level 2
Joined
Jun 27, 2010
Messages
20
i think i know what your trying to get at here :/

no.

if you find a system that already saves exactly what you want it to, without much work to it needed... dont use it. 9/10 when i looked for things like this, before i learned how to mess with them, they were extremely easy to crack.. hence i could randomly type things that looked cool and it would generate things for me :/ if not that problem, they just didnt work...

to find something worth your time, read what the DR has been writing :/ and maybe a tutorial or two.

try reading over some of This you may have that epiphany like i did. "OHHHH... thats how they do that :D!" :] and everything will go much more smoothly than trying to find a system that is pre-set to these things :/

still, whatever you decide, best of luck.:thumbs_up:

p.s they aren't as hard as people make them out to be... or how they look the first time you pick some long vjass one, not knowing jass at all and are like "o_O wtf?" and go back to searching "save/load system" in the systems of this site x]
 
Status
Not open for further replies.
Top