Quote:
Originally Posted by Unknown Rabbit
How much do you know about how save files work? I know fairly little, but I do now wonder what sort of scriptish information JJ2 could potentially be tricked into saving into them.
|
Save files are one of the lesser known JJ2 file formats, compared to ones like j2l or j2t. I don't think anyone has decoded it, though I think it uses zlib.
The trick would be finding some way to put extra information in the file without causing jj2 to see it as corrupt. I don't have the slightest clue on how to do this, but I've seen this sort of thing done with other (non-jj2) file formats, so who knows. I also don't know what a good way would be of telling the script to save/load stuff from there. Obviously an OnGameSave and OnGameLoad event would be a start.
There's also the problem of security, if the scripting language is allowed to write to the hard drive (which it would have to in order to save stuff). I never thought of this until Cpp mentioned it to me but it's actually a fairly big deal.
It's no big loss anyway. If I can't use expanded save files, I'll just use the variables that JJ2 does store in saves. Triggers would be an obvious choice, since I intend to set it up so they are persistent between levels (how to do this I'll figure out later). Each time you get an important "upgrade" (such as a special move or weapon), a trigger is set - and I'll probably only have 12 or 13 of those.
A somewhat more exotic option is just finding a way to save all that "scriptish information"
without expanding the save file format. The trick would be to find some variable that does nothing, but is saved anyway. If there is one (and I'm not sure - have to experiment), all we have to do is throw whatever is needed into it. For example, let's say we have 25 arbitrary "upgrades" of some sort. When you collect one of them, it sets some flag to 1, let's say upgrade[13] = 1. Then, we just need to take our Magic Useless Variable That Is Saved and change one of its bits (let's say the 13th, since that would make sense) to 1. It's a little messy, and you'd probably run out of bits pretty quickly... but on the other hand, it's fun doing things in really obscenely hackish ways like this.
Now I'm interested. I think I might start looking for "candidates" soon. One I might look at first is the "fastfeet" player variable, which gets set to 210 when you collect a shoe (and does nothing else). Quite useless, in other words, and invisible too, so we don't have to reset it every time the game reloads (to prevent the player from seeing weird things). Another option would be to take something really out of the way, like the variable for the amount of purple gems you had when you last hit a checkpoint (set it to whatever when saving the game, then set it to 0 when loading). And if all else fails, there's always your score, though using this would mean getting 0 points every time you reload.
There's also crazier stuff like an array for lap times (meant for race mode), though I doubt that goes in the save file, and might be a bad idea to use in single player....