Jump to content

Sacred 2 Downloads - weaponpool.txt dbid sorting tool


Recommended Posts

weaponpool.txt dbid sorting tool

View File

Sorts weaponpool.txt by dbid parameter.

 

Since it's a pretty simple task, I had two pathway opportunities: Either program from scratch or re-use all the code from previous tools. Given my current lack of time, I've decided for the latter, resulting in the tool being completely over-engineered. On the other hand, with some little tweaks this tool has the potential to become a universal file sorting tool for all Sacred 2 .txt files supported by my other tools because of that.

One final thing: it only sorts and writes the defines, any commentary at the start or end of weaponpool.txt or inbetween the defines will be lost. Commentary inbetween the start and end of a define however works fine and will not be lost.


 

  • Thanks! 1
Link to comment
10 hours ago, Lindor said:

weaponpool.txt dbid sorting tool

View File

Sorts weaponpool.txt by dbid parameter.

 

Since it's a pretty simple task, I had two pathway opportunities: Either program from scratch or re-use all the code from previous tools. Given my current lack of time, I've decided for the latter, resulting in the tool being completely over-engineered. On the other hand, with some little tweaks this tool has the potential to become a universal file sorting tool for all Sacred 2 .txt files supported by my other tools because of that.

One final thing: it only sorts and writes the defines, any commentary at the start or end of weaponpool.txt or inbetween the defines will be lost. Commentary inbetween the start and end of a define however works fine and will not be lost.


 

More than anything I think I just loved reading here  how you thought through,

how you were going to set this up,

the calculations of your thought processes

and the speed at which you did it 

Nice work Lindor

:superman:

gogo

Link to comment

THANK YOU.  :yay:    It works very well, quick and painless.  Well, I had to download and register lua54.dll first.

Many of my D2F scripts are manually sorted by my own preferences, but for ease of browsing, weaponpool was very much in need of this sorting tool.  Material.txt and typification.txt are other good candidates for sorting.  Strangely some of the bigger scripts are in nearly perfect numerical order already (creatureinfo, iteminfo, even itemtype).

I do have one quandary: I seem to have somehow acquired one extra entry in my new sorted weaponpool.txt.  886 entries vs. the original 885.  Seems a single entry got duplicated somewhere but I can't find it yet.

Link to comment

I just realized something. This tool is completely unnecessary. This right here:

16 hours ago, Lindor said:

this tool has the potential to become a universal file sorting tool for all Sacred 2 .txt files supported by my other tools

already exists.

  1. Download my Comparison Extractor and read README
  2. "modded" is the mod you want the scripts to become sorted
  3. "basic" needs to be an empty folder

With this setup, the S2CE becomes the sorting tool. You can try to do that with Material.txt and typification.txt if you like. If it doesn't work, I might consider continuing the work on this tool.

15 hours ago, Flix said:

I do have one quandary: I seem to have somehow acquired one extra entry in my new sorted weaponpool.txt.  886 entries vs. the original 885.  Seems a single entry got duplicated somewhere but I can't find it yet.

I know why. Weaponpools.txt was one of those special files with additional spaces, wasn't it? Seems like you didn't fix that yet for D2F.

  1. Open unsorted file
  2. Strg+F this: "} " (withouit quotation mark)
  3. The entry one below is the one which became duplicated
16 hours ago, Flix said:

Well, I had to download and register lua54.dll first.

Oh, yes, I knew I forgot smth:blush:

 

 

 

I'm gonna take this opportunity to explain a little bit more about this issue so you have something to read gogo:lol::

16 hours ago, gogoblender said:

More than anything I think I just loved reading here  how you thought through,

You're probably thinking: "If one space can cause such an error, your program doesn't seem to be the most stable, does it?" Let me explain:

For the program to work, we need three things:

  1. Recognition of the first line of a define
  2. Recognition of a unique identifyer of a define
  3. Recognition of the last line of a define

The problem is that the last line of a weaponpool.txt define only has a single letter, "}". So the recognition function would recognize all lines containing this letter as the end of a define if I hadn't enabled the check_length_end config. So now the issue becomes that an additional letter, in this case a space, screws things up, making the algorithm to recognize the last line of the next define as the define end and skipping the actual define end.

The whole thing is that my program is not an A.I. which gets trained to those specific Sacred 2 files, making it good at those but bad with general files. Instead my program has hardcoded recognition parameters, making it good in general but bad with specific files. It's just the question of what I choose. I could e.g. make the program ignore spaces at the end/start of a line, but that would again bring its own issues. I could also make it recognize a define by an empty line inbetween, but again, that would bring its own issues. In the end, I chose the algorithm which in my head seems to be the most stable as a general rule.

It's simply a question of

  • Do I want to make it ignore spaces at start and end, and then fix the issues I notice this change brings, and then fix the issues I notice the fix brings and then the fix of the fix and so on until I've got something that works perfectly on all Sacred 2 files, but has hundreds of issues if I change the shape of some files?

or

  • Do I want something that works as best as possible in general, but as a consequence has issues with some specific files, making it possibly require to change them a little bit?

None of those is really better than the other, I simply chose the latter.

Don't think that those kinds of issues don't exist with other tools too, I bet they're there. In fact you can proof that under certain conditions (which apply to the Sacred 2 files) the perfect recognition algorithm does not exist. It's just that I don't try to "hide" the issues, by making them not appear on usage with the Sacred 2 files, instead I openly talk about it because I'd rather improve the files over changing the algorithm. Again, because changing the algorithm would not be an improvement, but changing the files would be.

Hope I could explain it good enough, it's a little bit abstract and kinda hard to get across what I mean.

 

  • Appreciation 1
Link to comment
On 3/22/2022 at 12:12 PM, Lindor said:

Weaponpools.txt was one of those special files with additional spaces, wasn't it? Seems like you didn't fix that yet for D2F.

In this case "dm_dm_chest" had one space after the final bracket. It also had a series of 4 spaces camouflaged as the usual TAB intentions but that may not have mattered.

Link to comment
7 minutes ago, Flix said:

In this case "dm_dm_chest" had one space after the final bracket.

And dm_dm_shoulder should be the one duplicated (I hope).

6 minutes ago, Flix said:

It also had a series of 4 spaces camouflaged as the usual TAB intentions but that may not have mattered.

Yep that doesn't matter.

On 3/22/2022 at 6:12 PM, Lindor said:

With this setup, the S2CE becomes the sorting tool.

May I ask: Did you test that yet? I'm curious whether it works, if not I might consider testing it myself this weekend:)

Link to comment

Haven't tried it on other scripts yet. I'm doing so many things at once across multiple projects, it's easy to get sidetracked. So right now it's just been added to the list.

Link to comment

Uh I like lists:lol: Don't worry, take your time! It's super impressive what you're managing to do even just for Sacred 2 alone!

Edited by Lindor
Link to comment
21 hours ago, Flix said:

Haven't tried it on other scripts yet. I'm doing so many things at once across multiple projects, it's easy to get sidetracked. So right now it's just been added to the list.

 

22 hours ago, Lindor said:

if not I might consider testing it myself this weekend:)

I tested it and it works mostly as I thought, proving the work on the sorting tool has been unnecessary.

  • All files where defines are uniquely identifyable by a number, weaponpool.txt and blueprint.txt etc. are sorted by that number correctly.
  • Also most defines identified by strings like the surface.txt name are sorted alphabetically.
  • However I could not figure out how it sorted behaviour.txt, it seems like utter chaos to me. The defines should become sorted alphabetically by the name parameter, but it doesn't seem to be the case, e.g. the tool considers this:
  name         = "JOB_DRYADSTATIST",

to be lower than this:

  name         = "JOB_COMMUNICATOR",

despite the letter "D" being higher than "C". At first I thought it were the spaces, but both entries have the same spaceage including TABs, so I don't see any order here at the moment.

  • Thanks! 1
Link to comment

I don't know what happens with behaviour.txt in detail, but I found out that only the first 5 entries are affected:

  • "JOB_DRYADSTATIST", "JOB_COMMUNICATOR", "JOB_WALKPATH", "JOB_SENATOR" and "JOB_DOCKWORKER".

The program assigns those the numbers 0-4 in the order I listed them. Everything else is sorted alphabetically by name, as it should. If someone recognizes a pattern for those numbers appearing in the entries of those defines in behaviour.txt, pls tell me.

 

 

Another file not sorted correctly is soundprofile.txt:

  • "Weather Set 1", "Weapon 2H Sword", "Item Stone3", "Item Stone4", "Item Crystal Standard5 S", ...

Notice the pattern? The problem is that the program by default searches for numbers first if not otherly stated, and that the strings contain numbers.

  • Enabling the config.prefer_name_over_Id configuration for soundprofile.txt should fix the bug.
  • Another, more general but also more calculation heavy solution would be to alter the searchfor_number() function to return nil or false if the number is inside two quotation marks. And that has again the potential to bring its own bugs, like I explained above I don't want to be caught in an infinite fix of the fix of the fix of the... loop.

The decision on how I want to fix it has not been made yet, but I'm leaning towards the config atm. After the mysterious issue of behaviour.txt has been narrowed down, this will be fixed in the next iteration of the S2CE.

 

 

Last but not least, I want to pull this conversation over to the S2CE discussion where it belongs more imho, so I will be quoting myself there.

Edited by Lindor
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...
Please Sign In or Sign Up