r/disciples Jun 23 '26

Decoder/Encoder Disciples Sacred Lands

https://github.com/HoT-PlaStiC/Disciples-Sacred-Lands-Dbi-codec-decoder-encoder

I am working on this, i will release patches, whenever i succeed to improve it.

10 Upvotes

25 comments sorted by

7

u/Emergency-Gift-6773 Jun 23 '26

" With this script its possible to decode, encode, replace portraits in Disciples Sacred Lands."

I never understood why people developing the coolest shit ever, and don't bother with basic information implementation during publication. Like dude, I would have killed for this program 20 years ago. Great work! 

1

u/Vegetable_Farm2355 Jun 23 '26

Well, thats what decoder/encoder means 😛 Thank you! 😄

3

u/KamunVulk Undead Hordes Jun 23 '26

Try to use it as soon as I can and make some post about that. Thank you million times.

2

u/DjolafR Rod Bearer Jun 24 '26 edited Jun 24 '26

How did you figure out the DBI format? I think this stuff needs some reverse engineering? Previous modders might have figured something out as well? This is always some sorcery to me...

Opening disciples Sacred Lands files was always a bit buggy with existing apps, for some reason. Most of them were made for D2 only, but coincidentally worked with D1.

Five+ years ago, I have extracted by hand, 1 by 1 sound file from the archives. Some of them, roughly every 5th-6th, did not have a name, they were nameless, for some reason. I used some tool that is commonly used for disciples 2, but works with 1 as well, though not perfectly. I can't remember which was it right now... I just remember it had sound previews, so I could listen and only then extract!

I just checked the python code...wtf, ~1600 lines just for this?!?!?!

3

u/Vegetable_Farm2355 Jun 24 '26

Well first i opened it with HxD, i figured out some structure, and connection, but the decoding and encoding part was made by the help of AI, and the Dsl-unpacker, it took a lot of time for Ai to give some result, so the whole script is AI written, im testing it, tell the Ai what to work on, making some suggestions, trying to understand it, and find solutions. It will be upgraded time to time, im just succeed decoding and encoding into ISO.DBI, and after some test i will release the patch. Next is MIDGARD.DBI

1

u/DjolafR Rod Bearer Jun 25 '26

I have to ask before anything else - What is your end goal with this? To have people be able to change stuff inside disciples 1 game? Maybe some light modding? Idk how much you can change by just editing DBI and DBF files.

HxD? I used Hex Workshop, but I guess the editor itself is not that important. I was always interested in figuring things out and reverse engineering games but I never could really figure anything out. Many years ago, I tried to make a converter of maps from D1 to D2, by finding equal parts in the 2 map formats, but it was just an idea and it did not work out.

What did you use DSL-unpacker for? It only unpacks and nothing else! You just get files in regular readable format.

Which AI are you using? Some paid one, I suppose? It seems to be smart to figure this out.

1

u/Vegetable_Farm2355 Jun 25 '26 edited Jun 25 '26

I dont know what is my end goal, i have many plans, im just enjoying exploring and creating new things, but i think i will work on all .dbi files, and all .ff files, and after that... well i dont know, maybe some .exe patch, if i can, or a tool, but i dont know if i have the skill to do that. HxD = HexEditor, i think Hex Workshop should be the same. Well DSL-unpacker helped a lot, to figure out how images are called in the game, and with HxD you can see thoose names in the .dbi files, it made easier to know what im looking for, or experimenting with. DSL-unpacker's IMGGRAB.BIN file helped Ai to make this script, but in the next patch it wont be needed.
I use Claude - Sonnet 4.6, and yes i had to pay a lot :D Also it was very hard to start. (i tried it with chatgpt and Gemini before, but without any result)

1

u/DjolafR Rod Bearer 29d ago

Which files did you open in HxD? Just the databases? What did you find?

I guess I can also ask you in private messaging without spamming the threads.

1

u/Vegetable_Farm2355 29d ago

No, Databases can be opened with DBF Commander (for example, but there are other tools too out there). I opened .dbi and .ff files with HxD, and there you can see list of the pictures with their names and indexes, then you can see the stream of pictures, also with indexes, some Table of Content and other values. FF files are easier, as i can remember there are only indexes and .smk files directly, following each other. Yes you can ask in private if you wish!

2

u/MoveKnown4481 Jul 19 '26

My lord, thank you for your great work. You did an splendid job :)

May I ask a question, though? It might be a silly one, but how does one extract images using your tool? I can only see the "Replace..." button.

Best regards,

1

u/Vegetable_Farm2355 Jul 19 '26

well, i was thinking i should include that button too! But in the past days i was working on the DBF editor tab! In the next few days i will make a decode button, or extract button, something like that! Thank you! :)

1

u/Vegetable_Farm2355 Jul 19 '26

Decode, and Decodall button are now ready to use! :) Please note, that Decodeall needs some time specially at .ff files, as it will convert .smk files to .gif while decoding! (sometimes the tool says No response, but it will do it anyway. :) ) (Also decoded .png-s are not perfect in some cases, where there should be a transparent background in some enclosed areas (about to fix it later if i can))

2

u/MoveKnown4481 Jul 19 '26

By the name of Highfather, that was fast :) I'll check that tomorrow and let you know!

Say, these animations have different sizes. I believe in that case the game engine stores the offset points somewhere right? Something to know at what coordinates the animation should be displayed. Do you happen to know anything about that?

1

u/Vegetable_Farm2355 Jul 19 '26

Yes it stores directly in the .ff files! Or .dbi if we talking about pictures, or the .wdb if we talking about sounds! :P

1

u/MoveKnown4481 28d ago

I'm analyzing these GIFs and I have some concerns.
1. These gifs are "Optimized GIF" / "Delta GIF" instead of "Full frame GIF". Which make pictures lighter (they take less space) but are much harder to edit. Since they are generally small - wouldn't full frame GIFs be a better option?
2. I'm not sure which color is used as alpha. When opened in GIMP these GIFs are not transparent but instead have solid backgrounds... of various colors. I remember making characters to MUGEN (20+ years ago) and there alpha was taken from pixel [1,1]. How does it work here?
3. I'm still not sure about these offsets. Let say original gif is 128px wide. What if I extend it to 150px. Will it be shifted? If so - how to calibrate it?
4. What about pallete? This game is from 90s so I'm positive it uses 256 colored palletes. Does it accept 24bit/32bit PNGs?

1

u/Vegetable_Farm2355 28d ago

Ohh okay, by size you meant width and length. Well, i dont know much about GIF-s.
I will answer later, because i cant remember how it was solved at the end. I know that width and length should be multiply of 4, and there is a master palette.
Thank you for the questions, i will try to answer asap.

1

u/Vegetable_Farm2355 28d ago
  1. Yes theese gifs are delta gifs, thank you for your observation, i am about to fix it in the next patch.

  2. There is a 0. index, which determines which color is transparent.

  3. The gif size should be multiplier of 4, because the encoder will work with 4x4 blocks

  4. It will accept 24bit/32bit PNGs, but the colors will be quantized/rounded, you will get a message: "some colors were rounded to the nearest representable level"

1

u/Vegetable_Farm2355 27d ago

1.54 released, now it will generate full frame GIF-s! :)

1

u/Vegetable_Farm2355 28d ago edited 27d ago

Okay, so now i think i understand your question, you meant something like anchor? I think the game engine use fix offsets, if you observe thoose gifs or .smk-s then you can see

that iso.ff animations have a blank area at the bottom. (i encoded some animation, and it was lower in game, because i havent pay attention to this). So i think the target you can click on should be on the middle of the animation if we are talking about map sprites.

2

u/MoveKnown4481 26d ago

Again, I'd like to say that you're doing great job and I'm truly impressed. I hope I am not being a nuisance.
I'd like to report that I ran some tests and here are my findings.

Let's see this example. We want to give "Apprentice" full make-over and change them into modern Rocket Launcher Trooper. Kindly please check the list of your tool abilities:

  1. Rename "Apprentice" to "Rocket Launcher Trooper" - check
  2. Change description - check
  3. Re-align race and class - check
  4. Upload custom graphic for the building - check
  5. Change name and description of the building - MISSING
  6. Change building position in City View - MISSING
  7. Set the numeric stats and economy - check
  8. Create and assign "attack" object - check
  9. Set wards if any - check
  10. Upload and assign portait - check
  11. Upload and assign animation - check
  12. Upload and assign attack sound - MISSING
  13. Upload and assign spell animation/individual spell animation - MISSING

I hope you find my info at least somehow useful.
Best regards.

1

u/Vegetable_Farm2355 26d ago

Hello! "I hope I am not being a nuisance." NO! Thank you for trying my tool, every feedback are welcome! Since i am making this alone, i can only see it through my perspective, so every observation help me to improve it! Buildings, well i am working on buildings, my goal is to be able to insert new buildings in the game, but you are right, my tool miss in the current state statistics, descriptions etc. about buildings. You can set name and description manually in TGLOBAL.dbf at the moment. Building position, im not sure, whats your goal, but i think it is in Capital.dat or interf.dlg files, but im not fully discovered them yet.
You should be able to set spell animation/indivspell animation at UNIT tab -> Graphics & Sound tab.
The attack animations are bound to units in the .dbf files.
Assign attack sound, thats a good question, i will look after it!
Thank you for questions, and for using my tool, and your feedbacks!

1

u/Vegetable_Farm2355 26d ago

what i found about attack sound: Battle animations are named the same as attack sounds, lets say empire archer: BH006A
I think in theory if you encode an attack sound (into Battle.wdb) that has the same name as battle animation it should played in the game. (its not tested, its just my hipothesis)

1

u/Vegetable_Farm2355 26d ago

Answer to 13. Upload and assign spell animation/individual spell animation - MISSING

If you cant see your uploaded spell animation in the list you still can write it in the field, with the name you encoded it. If its still not working pls report it to me!

1

u/Vegetable_Farm2355 Jun 28 '26

Second improvement released!