• 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.

Add Researches in this Save/load system

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
Why don't you just take a real plain and simple to understand save/load trigger?
First 6 digits are gold, next 6 digits are lumber, next 3 digits are hero level, etc.
You'll get a code like '000246001242082', which would actually be 000246|001242|082, which is 246g, 1242 lumber and a hero level of 82. In your case, you could add research levels by single digits each. After the current save string, the next digit is for example for Ultra Vision, the 4 after that for the 4 common melee and ranged attack/defense enhance researchs. Then you'll get a code '00024600124208201322' which is actually 000246|001242|082|0|1|3|2|2 with the same explanation as before

Ofcourse people would easily crack this code, so you can convert the numbers to other numbers. For example:
1=3
2=8
3=5
4=0
5=1
6=7
7=9
8=6
9=4
0=2

So now you'll have a save/load code '22280722380826823588'. Nobody will know what each number means unless they do a lot of testing or you use an unprotected map.

To load it, simply check the substrings (0-6 for gold, 7-12 for lumber, etc.) Those values can be directly applied into a variable (Set substring 0-6 = GoldLoaded. Add GoldLoaded to current gold of Player 1 (Red)).



It might take a bit of time, but you'll have a very good save/load system that's easy to understand and edit.
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
Why don't you just take a real plain and simple to understand save/load trigger?
First 6 digits are gold, next 6 digits are lumber, next 3 digits are hero level, etc.
You'll get a code like '000246001242082', which would actually be 000246|001242|082, which is 246g, 1242 lumber and a hero level of 82. In your case, you could add research levels by single digits each. After the current save string, the next digit is for example for Ultra Vision, the 4 after that for the 4 common melee and ranged attack/defense enhance researchs. Then you'll get a code '00024600124208201322' which is actually 000246|001242|082|0|1|3|2|2 with the same explanation as before

Ofcourse people would easily crack this code, so you can convert the numbers to other numbers. For example:
1=3
2=8
3=5
4=0
5=1
6=7
7=9
8=6
9=4
0=2

So now you'll have a save/load code '22280722380826823588'. Nobody will know what each number means unless they do a lot of testing or you use an unprotected map.

To load it, simply check the substrings (0-6 for gold, 7-12 for lumber, etc.) Those values can be directly applied into a variable (Set substring 0-6 = GoldLoaded. Add GoldLoaded to current gold of Player 1 (Red)).



It might take a bit of time, but you'll have a very good save/load system that's easy to understand and edit.

My problem with this was.
- I could not get the darn thing to load.
- I could not set 0 = 2 etc.
- It was to darn easy to crack even with this stuff.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
-You just load with substrings, just like I said it.
-You don't set 0=2 as a variable, it's just something you type in the comments to keep it in mind. It's only noted in the comments of a trigger or you write it down somewhere, so only you know which number is replaced with which number. That's what you use to load it again with substrings.
-It's not easy to crack, unless you have your map unprotected. But if it's unprotected, everyone can 'crack' (it's actually just reading) your save/load system. Other then that, it can only be cracked with a whole lot of testing, which I don't think anyone will do just to get more gold or lumber...
 
Level 9
Joined
May 27, 2006
Messages
498
Couldnt you try storing the hardcode of the research as a string in the code and placing its level right after/before it?
Like;
-load b89weadnuiaurhar3sbao873gfos

And then load it by calling SetPlayerTechResearched(GetTriggerPlayer(), 'Rhar', 3)
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
@ Airandius: Check out some of the GUI save/load systems that are uploaded here. Most of them use something like this, except for the 'encrypting' (0=2 and stuff). It'll probably help you understand it faster then I can explain.

@ raft_pl: That would be very easy to crack. Nobody actually needs to know the name of the research and it would only enhance cracking it.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Sure. It could be useful to put 'comments' in the string (like you do comments in triggers) to keep things sorted. Do however keep in mind that this will only lengthen the string and doesn't give additional input to the system itself. If you're already going to store a long string for a lot of data, you might want to avoid this for both your sake and the sake of the player (who has to write down and copy everything).
 
Level 12
Joined
May 4, 2008
Messages
1,111
you can always add units coresponding to the upgrade? that when it loads it drops the unit in a certain area then checks to give the upgrades to the user (i used it in my map so i also used this method, it was easy and fast
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
That's what I meant by commenting how you encrypted it. You can just place those comments in the trigger comments (it'll save you the trouble, looking where you kept those notes :gg:).
With indirect saved data (stuff that aren't directly marked as a stat or property, like gold/lumber amount) can be saved like that. However, it's not very smart to encrypt direct stats/property too extreme, since it'll only be harder to decrypt for yourself.
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
I wrote my epicly failing code before hand, and then started the code.

-GGGGGGEEEEE111222333444HHH

G = Gold
E = Exp
Number = Spell
H = Hero

I just never got the loading part to work.

Protip: Add a maxvalue to things. If you use for example the first 6 spots for gold. But the gold only is like 300. You'll come short by 3 numbers.
I fixed this by adding 100000 to the gold amount.
 
Level 9
Joined
May 27, 2006
Messages
498
Didnt get what do you mean with modifing them to equal variables...
Uhm, Rhar is the hardcode, i guess you got that, and since in Jasscraft it is written:
Code:
constant native SetPlayerTechResearched takes player whichPlayer, [B][U]integer[/U] techid[/B], (...)
i guess it is possible to use some integer at the place of the hardcode.
But i dont know, i've never screwed around hardcodes that much.
 
Last edited:
Level 9
Joined
May 27, 2006
Messages
498
In every native that does something related to researches/upgrades, the upgrade is taken as integer "techid", meaning, hardcode.
So if you'll try to convert techid into an integer, you'll fail, cause its an integer already.
:/ Just encrypt it and put into your load code

I see no other solution
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I advise finding a save system that allows customizable storage of values.
You then just have to save an additional integer ontop of all the other standard ones.
TKoK is a good example of a map that used a customizable save system to do just what you want, too bad its protected.
 
Status
Not open for further replies.
Top