Savefile Character / Map Editor v1.0.1 (April 15, 2014)

Ask questions, share hints or chat in general about Eschalon: Book I.
demonpants
Pledge
Posts: 3
Joined: April 10th, 2009, 12:05 am

Re: Savefile Character / Map Editor

Post by demonpants »

Is there no way for you to create binaries of this? I don't quite understand why Python developers always require everyone to compile everything themselves...

Anyway I've got a Mac and despite getting PyGTK installed from darwinports.com I've got compilation problems.

Code: Select all

Traceback (most recent call last):
  File "./eschalon_b1_char.py", line 211, in <module>
    sys.exit(main())
  File "./eschalon_b1_char.py", line 202, in main
    from eschalonb1.maingui import MainGUI
  File "/Applications/Eschalon Book I/eschalon_b1_utils-0.4.2/eschalonb1/maingui.py", line 24, in <module>
    import cairo
ImportError: No module named cairo
I think it's pretty clear that this error is caused by a lack of cairo... however, cairo is supposed to be installed on my machine already (and it is), plus installing PyGTK automatically installed both Python and Cairo again, so I know I've got at least two versions of Cairo running. The question is whether or not Python is pointing to the right place on my HD - and clearly it isn't. I don't know if you can help me with this... probably you can't and I don't really feel it's worth it anyway.

What you could help me with is post here a simple list of how the bytes are structured in the character file, then I can port it to Java for all to easily enjoy via executable. I'm not really interested in doing this for the map editor at this time... I've looked at your source code which has the file reading in it, and you have readInt and all that, but still a simple little list of byte ordering would be awesome.

Thank you sir.

[EDIT]
Instead of just whining I thought I'd be helpful. I've managed to edit my save files on Mac OS X using the free program HexEdit (http://www.versiontracker.com/dyn/moreinfo/macosx/10658) and an online hex-to-decimal converter (http://www.permadi.com/tutorial/numConvJs/index.html) and xoltol's save file editor. How?

Basically you can go in and check out the hex in the save file, and using the byte ordering that xoltol already found you can easily adjust the code to be what you want.

Code: Select all

# Start processing
            self.unknown.initzero = self.df.readint()

            # Character info
            self.name = self.df.readstr()
            self.unknown.charstring = self.df.readstr()
            self.origin = self.df.readstr()
            self.axiom = self.df.readstr()
            self.classname = self.df.readstr()
            self.unknown.charone = self.df.readint()
            self.strength = self.df.readint()
            self.dexterity = self.df.readint()
            self.endurance = self.df.readint()
            self.speed = self.df.readint()
            self.intelligence = self.df.readint()
            self.wisdom = self.df.readint()
            self.perception = self.df.readint()
            self.concentration = self.df.readint()
The above is taken from xoltol's parser. In it you can see that the first 4 bytes (an int is 4 bytes) are a zero and can be ignored. Then the next string is the character's name, then there's a blank in between, then the origin name, etc. In hex, that looks like this:

Code: Select all

00 00 00 00 46 6F 72 64 61 6C 65 0D 0A 0D 0A 42
61 72 72 65 61 6E 0D 0A 56 69 72 74 75 6F 75 73
0D 0A 52 61 6E 67 65 72 0D 0A 
You can see that the first four pairs are garbage (zero), just as expected. Then we've got some random numbers which represent the ascii values of each character. Every character is represented by one pair (or byte). You should also note that the end of a string is always 0D 0A, which is for the zero value that signals the end up a string, plus a newline. So we get to the 0D 0A which means we've gotten to the end of our name. You notice above that the Python parser throws out a blank string next, hence our extra 0D 0A following the other one. Keep going through and you'll see that "Fordale" "Barrean" "Virtuous" "Ranger" will be spelled out. That's what the above represents.

Now that we got past that, we can get to meaty portion of our character file.

Code: Select all

01 00 00 00 1A 00 00 00 14 00 00 00 14 00 00 00
17 00 00 00 0D 00 00 00 0D 00 00 00 0D 00 00 00
0E 00 00 00 05 00 00 00 04 00 00 00 05 00 00 00
03 00 00 00 
After we read one trash integer (self.unknown.charone = self.df.readint()), we've reached the stats. Remember, an integer is 4 bytes, or 4 pairs. So, the "01 00 00 00" means nothing to us. From here on out, we'll be looking at interesting and important data.

According to xoltol's parser, strength is first. Looks like I have a 1A there. One thing to remember is that the files here are stored in little endian format - that is, instead of a million being like 1,000,000 it's like 000,000,1. So, the first byte, the 1A, represents all values up to 256. That means that unless you're cheating you're only going to need to change that first byte in all your stats. So, my strength is "1A 00 00 00" which using our online hex converter we can see is 26. I check my actual character and that matches up. Cool! If I wanted a few billion strength, I could change it to "00 00 00 01" (put 10000000 into the hex converter to see what that actually equals), or I could be more modest and just change 1A to 2A, giving myself 42 strength instead of 26.

Editing the rest of your stats should be pretty easy. Just remember that integers come in 4 bytes, so count by 4's to remember which stat is what. Also you can check values of stats to see what they match up with in your actual game file. And remember also that you can easily keep the game running to quickly see what changes you've made, just reload your save.

BUT, a word of CAUTION! Editing hex like this can make it VERY easy to destroy your save file! Back it up! Back it up! Back up your save!

And that's all she wrote...
Last edited by demonpants on April 10th, 2009, 12:46 am, edited 1 time in total.
waryk
Initiate
Posts: 13
Joined: April 6th, 2009, 6:18 pm

Re: Savefile Character / Map Editor

Post by waryk »

It's true - the Windows version is much easier to instal. Gotta love NEXT NEXT NEXT NEXT NEXT NEXT NEXT :D

Reminder: you DO have to download and install ALL of the applications/packages that xolotl mentioned. I was confused why there were two executables for gtk+ (2.12.9-1 and 2.12.9-2), so I downloaded and installed "-2" for everything.

The character editor works very well, although I've yet to load the save file to test the changes.

xolotl - Will the game or the editor automatically fix derived stats like HP, MP or resistances?

Having had trouble with the map editor because it requires lots of game files, so I'll install Book 1 on my virtual windows machine so I can edit the maps (spawn LOTS of chests in town for me to use. stupid 8 slot chests!!!)
User avatar
xolotl
Lieutenant
Lieutenant
Posts: 777
Joined: August 21st, 2008, 1:54 pm

Re: Savefile Character / Map Editor

Post by xolotl »

Anyway I've got a Mac and despite getting PyGTK installed from darwinports.com I've got compilation problems.

Code: Select all

...
ImportError: No module named cairo
There's Cairo, which is the C library which does the actual drawing work, and then there's PyCairo, which is the Python bindings for Cairo. That error, above, is indicating that you're missing PyCairo. As to how you'd get PyCairo installed, I'm not sure, but it's an important distinction to make. You mention that you've already got Cairo installed, so it's probably the Python bindings which are causing problems.
I don't know if you can help me with this... probably you can't and I don't really feel it's worth it anyway.
Probably not much, since I don't have any access to an OSX machine. I can certainly empathize; it's a shame that the dependencies don't seem to be available in precompiled form. When I started the project, it had looked like the necessary stuff was available for OSX, but getting it up and running seems to be nontrivial. Sorry about that!
What you could help me with is post here a simple list of how the bytes are structured in the character file, then I can port it to Java for all to easily enjoy via executable.
The code is honestly the best place, in the read() function, which as you've noticed just does readint(), readfloat(), etc. The way I've done it, an "int" is four bytes, "short" is two bytes, "char" is one, "float" takes eight bytes. Just read it from the top-down and it should be pretty clear. I'll PM you the textfile that I was jotting down notes on as I was deciphering the file, but I'm sure it's at least a little bit out-of-date. I'd doublecheck it versus the code before just accepting it verbatim. Good luck with a Java version, if you decide to take it as far as public release. I welcome the variety!

In re: packaging stuff, here's some boring answers in re: your distribution questions, as well:
demonpants wrote:Is there no way for you to create binaries of this?
It's possible that there is, on OSX, but the main thing getting in the way of that is that I have no access to that platform, so my hands are kind of tied. If anyone does get it going in an OSX environment and can help provide some details, then perhaps it could get streamlined. I just don't have a way of creating binaries myself since I don't have the platform. (In terms of creating actual binaries for Windows, I've got various leads on that which I swear I'll follow up on eventually. On the Linux side, there's really no need to create binaries since everything's in your distro's repo already.)
I don't quite understand why Python developers always require everyone to compile everything themselves...
Well, in general you don't have to compile anything, actually, but it's a matter of just having the environment available on your platform. Java, for instance, has the luxury of having a nicely-packaged full-featured native JVM on most platforms that you'd care about. It's the distribution of GTK/PyGTK/Cairo/etc which is getting in the way on OSX, and that's unfortunate. It had looked to me, when I started out, that they were available on OSX, but clearly that's not exactly the case in reality. Not having access to the platform, I couldn't really know that for myself. On both Linux and Windows, there's no compilation required. On Windows there's just a few .exe installers you've got to run through for the prereqs (and I am hoping to eventually do away with even that), and on Linux (as I mention above), afaik the prereqs should be already available via the repositories. The problem on OSX is just that (apparently) there's no precompiled stuff available, which is a shame, but it's a bit out of my hands.
User avatar
xolotl
Lieutenant
Lieutenant
Posts: 777
Joined: August 21st, 2008, 1:54 pm

Re: Savefile Character / Map Editor

Post by xolotl »

waryk wrote:Reminder: you DO have to download and install ALL of the applications/packages that xolotl mentioned. I was confused why there were two executables for gtk+ (2.12.9-1 and 2.12.9-2), so I downloaded and installed "-2" for everything.
Yeah, it's a bit confusing; I just used the "-2" versions as well. It looks like packaging it all up into a single EXE for Windows should be possilbe (so you wouldn't even have to NEXT NEXT NEXT), though it'll probably be a little while before I get that together, since doing packaging is boring and there's more fun things to work on. :)
Will the game or the editor automatically fix derived stats like HP, MP or resistances?
Re: HP and MP, not exactly - you'll notice that if you save a game while wearing a ring that gives you +5HP, your on-disk "current HP" will be 5 over your "max HP" (assuming that you're fully healed-up, of course). I didn't think it was worth figuring out the "virtual" max HP, etc, though I could consider it for a future version. As for resistances and stuff like ToHit, those are completely just computed by the game engine, from what I can tell, so they're not stats that you can just set. I haven't taken the time to try and figure out the internal equations that Eschalon uses to compute those, and I'm actually pretty unlikely to, since it'd be a pretty involved process.
Having had trouble with the map editor because it requires lots of game files, so I'll install Book 1 on my virtual windows machine so I can edit the maps
Heh, yeah, the map editor pretty much requires a game directory. You actually only need gfx.pak somewhere, so you could just copy that over if you want, and point the editor to the dir you put it in.
demonpants
Pledge
Posts: 3
Joined: April 10th, 2009, 12:05 am

Re: Savefile Character / Map Editor

Post by demonpants »

Wow, you guys replied before I could even edit my post! Cool!

Thanks for the quick response. I'll see if I can get a Java version for at least the character editor working, then at least Mac users will have something to use.

You can also check out my semi-complicated temporary solution that I posted above. :)

It'll work. All I want is more gold, because no matter how much I slaughter enemies and pillage their corpses, I always run out of damn arrows. Next time I'm making a wizard. :lol:

Thanks for deciphering the save files, you really did a fine job.
User avatar
xolotl
Lieutenant
Lieutenant
Posts: 777
Joined: August 21st, 2008, 1:54 pm

Re: Savefile Character / Map Editor

Post by xolotl »

demonpants wrote:Thanks for the quick response. I'll see if I can get a Java version for at least the character editor working, then at least Mac users will have something to use.
Cool cool. I had considered using Java at the beginning, actually, but I was really itching to do some Python instead.
It'll work. All I want is more gold
I probably should have mentioned this before, actually, but the character editor does have a couple of useful options via the CLI, which doesn't need any of the GUI stuff at all (ie: it should work just fine with only python installed). For instance, setting your gold level can be done just by:

Code: Select all

$ eschalon_b1_char.py --set-gold=20000 /path/to/char
(though you'd obviously have to have eschalon_b1_char.py in your $PATH, or just run it from the dir you unpacked it into, as "./eschalon_b1_char.py")

You can use "eschalon_b1_char.py --help" to get the full commandline help. I guess I don't really mention that on the site at all; I had just figured most folks would be more comfy in the GUI (assuming they can get it running).
User avatar
AK_Marty
Officer [Bronze Rank]
Officer [Bronze Rank]
Posts: 262
Joined: June 28th, 2008, 3:33 pm
Location: Alaska The Great Land

Re: Savefile Character / Map Editor

Post by AK_Marty »

xolotl wrote: Yeah, it's a bit confusing; I just used the "-2" versions as well. It looks like packaging it all up into a single EXE for Windows should be possilbe (so you wouldn't even have to NEXT NEXT NEXT), though it'll probably be a little while before I get that together, since doing packaging is boring and there's more fun things to work on. :)
A single EXE file for windows would be absolutly awesome! I can't wait to see it. Thank You
Alaska Marty
"It looks a lot more like it does now than it used to!"
User avatar
xolotl
Lieutenant
Lieutenant
Posts: 777
Joined: August 21st, 2008, 1:54 pm

Re: Savefile Character / Map Editor

Post by xolotl »

demonpants wrote:

Code: Select all

ImportError: No module named cairo
You know, after thinking about this a bit more, I realize that the character editor itself doesn't actually need cairo; all the actual Cairo calls happen in the map editor (where I needed it primarily for Cairo's far superior image compositing functions, versus the default GDK stuff that's available in GTK). The Character editor uses the game graphics backend stuff to do the loading that the Map editor uses, and I had been under the impression that Cairo was pretty well distributed along with everything else, but that may not be the case on OSX. Could you drop the following into a text file and see if your Python can run it? It should just pop up a little window which says "Test." If you can run that, then I should be able to get the character editor working without Cairo (I'd just release an 0.4.3 version with those changes). Let me know!

Code: Select all

#!/usr/bin/env python

import gtk

win = gtk.Window()
win.connect('delete_event', lambda w, e: gtk.main_quit())
win.set_size_request(300, 200)
label = gtk.Label('Test')
win.add(label)
win.show_all()
gtk.main()
Thanks...
User avatar
IJBall
Major
Major
Posts: 1684
Joined: August 31st, 2008, 11:07 am
Location: Southern California

Re: Savefile Character / Map Editor

Post by IJBall »

Hey, demonpants! - Have you gotten the *map* editor to work on Mac OS yet?

I must admit that I have never tried to get xolotl's program to work on my Mac because, frankly, it always seemed like getting it work requires abilities that may be over my head! :wink: and there are other character/stats editors out there for Book I (Goblin Hacker, for one, though I've never tried to use it myself - I have it downloaded, just in case!).

But if xolotl's app starts to function well as a map editor, well that's a whole different ballgame, because it might allow some of us to put together new scenarios (mods?) based on the Book I maps, something I'd be quite interested in doing. :mrgreen:

And to xolotl - you might want think about taking on one of these Mac guys as a collaborator on the MacOS version of your app. Couldn't hurt! :)

I'll be watching this thread with interest now... :D
User avatar
xolotl
Lieutenant
Lieutenant
Posts: 777
Joined: August 21st, 2008, 1:54 pm

Re: Savefile Character / Map Editor

Post by xolotl »

IJBall wrote:there are other character/stats editors out there for Book I (Goblin Hacker, for one, though I've never tried to use it myself )
Oh, whoa! I had actually searched around before even starting to see if there was anything already-existing, but hadn't found that. 'course I still would have written something since that app's only OSX, but it does look nice. I'll have to see if the code for that is available to see if he had found anything that I had missed. Looks like that app's got some more abstracted functionality ("Basic Weapon" / "Superb Weapon" / etc) which could probably be a worthy addition to my stuff, too. I'll try and get ahold of the author to see if we can share our knowledge For Great Justice!
it might allow some of us to put together new scenarios (mods?) based on the Book I maps, something I'd be quite interested in doing.
Yeah, that's what I'm most interested in right now as well. I've got some very basic "drawing" abilities in my development version of the map editor, which I'll be expanding on over the next few weeks. I'd say that I'd hope to release 0.5.0 within a month or so, which should make creating new maps much easier than with the current editing tools.
And to xolotl - you might want think about taking on one of these Mac guys as a collaborator on the MacOS version of your app. Couldn't hurt!
Yeah, absolutely - I'll be getting ahold of them. Thanks for the heads-up!
demonpants
Pledge
Posts: 3
Joined: April 10th, 2009, 12:05 am

Re: Savefile Character / Map Editor

Post by demonpants »

GoblinHacker looks pretty nifty. Guess I don't need to mess with the hex anymore. I'll probably still write that Java version just for fun.
User avatar
xolotl
Lieutenant
Lieutenant
Posts: 777
Joined: August 21st, 2008, 1:54 pm

Re: Savefile Character / Map Editor

Post by xolotl »

Hey all! This won't actually get released for a little while still (at least a few weeks, I'd imagine), but I'm rather excited that I've got wall drawing working more-or-less how I'd like to. IMO this is one of the most important features that the editor would need to have in order to do mass map editing.

I guess Youtube's still processing the video, so right now the quality really sucks, but: http://www.youtube.com/watch?v=aYKhAIqncWk

(The framerate choppiness in particular is due to my capture utility, not Youtube or the app itself, by the way.)

Anyway, not shown there is that I've also got a "basic" drawing tool as well which can be used to easily plop down other objects on the map.

Progress!
User avatar
IJBall
Major
Major
Posts: 1684
Joined: August 31st, 2008, 11:07 am
Location: Southern California

Re: Savefile Character / Map Editor

Post by IJBall »

xolotl wrote: guess Youtube's still processing the video, so right now the quality really sucks, but: http://www.youtube.com/watch?v=aYKhAIqncWk

Anyway, not shown there is that I've also got a "basic" drawing tool as well which can be used to easily plop down other objects on the map.
Very cool, xolotl!

Can this tool also be used to "overwrite" already existing walls or, say, "ruin" walls with "new" walls? (See where I'm going with this?... :wink: )

The other question about this - will this allow us to overwrite terrain? Or is terrain something more complicated, and we'll just have to start out with building new building-structures on the already present terrain on the pre-existing maps?

TIA!
User avatar
xolotl
Lieutenant
Lieutenant
Posts: 777
Joined: August 21st, 2008, 1:54 pm

Re: Savefile Character / Map Editor

Post by xolotl »

IJBall wrote:Can this tool also be used to "overwrite" already existing walls or, say, "ruin" walls with "new" walls? (See where I'm going with this?...
Yeah - in fact overwriting will probably be its only mode. I'm not sure what utility there'd be in having it check for existing walls and then NOT draw if it finds one. The tool just assumes that you want to overwrite at the moment.
will this allow us to overwrite terrain?
Yep, basic terrain drawing's already in there. My next step once I wrap up the "smart" wall-drawing is to smarten up the floor drawing, so that it automatically puts on the transition decals, etc (like moving from grass to sand, or sand to water) so that it looks a little nicer. The basic laying-down-new-terrain-tiles is already implemented on my development version, though. :)

Edit: Also I've been considering what it'd take to have a "fill" kind of tool, so you could lay down big chunks of terrain all at once. Right now you'd have to just wave your mouse around over the area until it was all filled up.
User avatar
IJBall
Major
Major
Posts: 1684
Joined: August 31st, 2008, 11:07 am
Location: Southern California

Re: Savefile Character / Map Editor

Post by IJBall »

xolotl, one last question:

Have you figured out how to do "self-closeable" doors vs. "regular" doors with your map tools?

For example, in Aridell, the doors to both the weaponsmith and the inn "self-close" when you exit those buildings. But the door to Abygale's Magicks Emporium is a "regular" door that doesn't self-close.

(I think if I did maps, I'd probably want most doors to be 'self-closing'... :wink: )
Post Reply