Jump to content
deguix

top-decompiler (uses luajit)

Recommended Posts

It decompiles the .bin files from many top/pko versions. Easy to use: just extract, edit user.lua file (documentation of functions are in there) and run the bat file. I didn't test this with all versions (technically, only versions 4 and 5 were tested, but other versions should work).

 

Here's the link: https://drive.google.com/file/d/0B0QOetVFt_yXX0N5d0t4OFJwcGs/view?usp=sharing&resourcekey=0-AAK4j3hDVILCb5hi-Y8o7Q

The latest version can be found with the top-recode project: https://gitlab.com/deguix/top-recode/-/tree/master/helpers. To get it to work in standalone (like with the old version), download the old version first, and just replace the old "decompiler.lua" file with the new one. (so far no changes afaik)

Discord: https://discord.gg/uwcR74E (same as top-recode project, go to "#top-decompiler" channel).

 

I don't develop much for it anymore because TOP/KOP/PKO are all gone, but I'm still updating version "9" which is for decompiling top-recode .bins themselves.

 

---

 

(section refering to its first lua version)

 

The 7z has the LuaJit 2.1.0-beta3 binary files with forward lua 5.2 compatibility (compatibility is not needed for these files though, its just that I use it for everything).

 

This is a new version with the same version number as last release in s*****d**, except I added texture decrypting functions (along with the updated luajit).

 

Now for some personal comments:

- It originally was made in Python. It is better and faster in luajit than in Python. I've had many issues with Python, mostly syntax-wise. Lua is not perfect, but from what i've seen, it's the best for me. Believe me, I'm very picky with the syntax.

- The Python version had many extra version numbers for top/pko versions that don't exist anymore. I didn't add them because no files use old TOP/PKO versions. If there's a version you need, tell me, I'll re-add it.

- I didn't publish it here earlier because I wanted to make the syntax even better - but lately I've been busy with other projects.

- item.lit is a bin file (in scripts/txt folder) - this can't decompile it because the sub-items are also binary files (the size of an item varies, all other bins have invariant items).

- I've even made a version that could run on lua 5.0 (what server runs), but won't release it anymore because server/client source code is available and i'm fixing the client. So far both the server and client are both running luajit.

- Re-release of other projects will have to wait until I finish the above.

 

Please comment if it's not working. I know that I've tested it with an older luajit build, but I didn't do it yet with the newer one.

Edited by deguix
updated link
  • Like 3

Share this post


Link to post
Share on other sites

I'm getting  " luajit: decompiler.lua:589: ´end´ expected to <to close ´function´ at line 580> near ´return´ ".

 

Double checked the bins file path and all, but won't decompile.

Share this post


Link to post
Share on other sites

oh, remove "return n", it should work (function sub_f is not used yet).

 

EDIT: I just tested it with top2 files and it seems that I got some weird strings on skillinfo, and 1 at terraininfo for 1 item. Everything else seems fine though. I'm going to try to fix them today.

 

EDIT#2: Fixed.

 

Version 1.0.5:

- Fixed: lua syntax error above ^^.

- Fixed: static function flag parameter wasn't being used.

- Fixed: TerrainInfo uses byte instead of ulong for the 1? and 2? params (sry no good names yet).

Edited by deguix

Share this post


Link to post
Share on other sites

Tried decompiling certain iteminfo, but kept getting the error below. Tested with a different iteminfo and works fine. Any idea if it is because the iteminfo is a different version or in some way encrypted?.

error.png

Edited by Crescendo

Share this post


Link to post
Share on other sites

Did you try using other version numbers? From the error I see, it's highly probable that the version needed is 1 (TOPI 1.3.5), because that one has shorter description messages (thus it runs out of chars - lack of chars results in a nil - a nil will have that error pop up).

Share this post


Link to post
Share on other sites

Does that even work with the client? If it does then you can store the .bin online and put the link here or send through pm. I can attempt to decompile it. From the result from gemini, it seems there are some extra invalid bytes in the beginning. Taking them out should make it able to work.

Share this post


Link to post
Share on other sites

Ok... the version is 2, but the file is corrupted. There are many missing bytes in it. Must have been a faulty internet.

 

EDIT: Version 1.0.6:

- Added: version 9 for the compiled client. This compiled client with fixed binaries is not released yet. So it basically means nothing for you guys right now.

- Fixed: crash on having missing binary files when decompiling whole folder. If having extra binary files not supported by the version number, the .txt outputs will only have a comment line.

- Fixed: whole folder texture decryption only decrypted half of the files on Windows. [fix thanks to: @Wrexor ]

 

EDIT #2 (10/2/17):

Woops, forgot to remove myfile:close() at if myfile == nil then block.

Edited by deguix

Share this post


Link to post
Share on other sites

(Added new post because of importance)

Version 1.0.7:

- Fixed a bug on sceneobjinfo which caused the addition of 6, anytime the type of scenery was 6. Bug applies to all versions of top-decompiler. It affects items 480 to 489. This is what it should look like (remove 6, from env_* and 2500) - from top2:

480    yyyy080.lmo    Wave Sound Effe    6    env_surf    2500    0    1    0    200    0    1    0
481    yyyy080.lmo    Worm Sound Effe    6    env_insect    2500    0    1    0    200    0    1    0
482    yyyy080.lmo    Cicada Sound Ef    6    env_cicada    2500    0    1    0    200    0    1    0
483    yyyy080.lmo    Chirping Sound     6    env_bird1    2500    0    1    0    200    0    1    0
484    yyyy080.lmo    Chirping Sound     6    env_bird2    2500    0    1    0    200    0    1    0
485    yyyy080.lmo    Chilling Sound     6    env_bise    2500    0    1    0    200    0    1    0
486    yyyy080.lmo    Shipyard Sound     6    env_ship    2500    0    1    0    200    0    1    0
487    yyyy080.lmo    Factory Sound E    6    env_BlackS    2500    0    1    0    200    0    1    0
488    yyyy080.lmo    Fountain Sound     6    env_founta    2500    0    1    0    200    0    1    0
489    yyyy080.lmo    River Sound Eff    6    env_ghyll    2500    0    1    0    200    0    1    0

 

- Fixed something on version 9 but forgot.

- Added a message if binary file doesn't exist (when decompiling and decrypting).

- Fixed crash on decrypting if file doesn't exist.

Edited by deguix

Share this post


Link to post
Share on other sites

hi, im new to the whole TOP scripts and all that fancy sql stuff, i been learning alot in this forum, but ¿can anyone tell what's the porpuse of doing this? thanks.

Share this post


Link to post
Share on other sites
On 4/25/2019 at 8:52 PM, willewallo said:

hi, im new to the whole TOP scripts and all that fancy sql stuff, i been learning alot in this forum, but ¿can anyone tell what's the porpuse of doing this? thanks.

Hello!

 

This tool allows you to get the source .txt files from .bin tables (which are located in Client\scripts\table folder). These tables contain information about items, monsters, skills, and so on. This way you can edit these things for your client.


Share this post


Link to post
Share on other sites
41 minutes ago, V3ct0r said:

Hello!

 

This tool allows you to get the source .txt files from .bin tables (which are located in Client\scripts\table folder). These tables contain information about items, monsters, skills, and so on. This way you can edit these things for your client.

thanks v3t0r, once one saving the day, btw answer my direct message i want some of your top services.

Share this post


Link to post
Share on other sites
On 9/13/2017 at 3:28 AM, deguix said:

It decompiles the .bin files from many top/pko versions. Easy to use: just extract, edit user.lua file (documentation of functions are in there) and run the bat file. I didn't test this with all versions (technically, only versions 4 and 5 were tested, but other versions should work).

 

Here's the link: https://drive.google.com/open?id=0B0QOetVFt_yXX0N5d0t4OFJwcGs

 

The 7z has the LuaJit 2.1.0-beta3 binary files with forward lua 5.2 compatibility (compatibility is not needed for these files though, its just that I use it for everything).

 

This is a new version with the same version number as last release in s*****d**, except I added texture decrypting functions (along with the updated luajit).

 

Now for some personal comments:

- It originally was made in Python. It is better and faster in luajit than in Python. I've had many issues with Python, mostly syntax-wise. Lua is not perfect, but from what i've seen, it's the best for me. Believe me, I'm very picky with the syntax.

- The Python version had many extra version numbers for top/pko versions that don't exist anymore. I didn't add them because no files use old TOP/PKO versions. If there's a version you need, tell me, I'll re-add it.

- I didn't publish it here earlier because I wanted to make the syntax even better - but lately I've been busy with other projects.

- item.lit is a bin file (in scripts/txt folder) - this can't decompile it because the sub-items are also binary files (the size of an item varies, all other bins have invariant items).

- I've even made a version that could run on lua 5.0 (what server runs), but won't release it anymore because server/client source code is available and i'm fixing the client. So far both the server and client are both running luajit.

- Re-release of other projects will have to wait until I finish the above.

 

Please comment if it's not working. I know that I've tested it with an older luajit build, but I didn't do it yet with the newer one.

hi,bro u got discord? need ur help

Share this post


Link to post
Share on other sites

Hi Guys im in need of some help,,

 

when decompiling I get the following

 

Folder decompiled successfully in 0.492s: C:/Program Files (x86)/Tales of Pirates II/scripts/table/

C:\Program Files (x86)\Tales of Pirates II\scripts\table>pause
Press any key to continue . . .

 

 

then when i go look for the  decompiled  text files, i cannot seem to find them,,

 

 

can someone please assist?

 

Share this post


Link to post
Share on other sites

Hello @MolSlangX!

 

Show your script for decompiling


Share this post


Link to post
Share on other sites
10 hours ago, MolSlangX said:

Hi Guys im in need of some help,,

 

when decompiling I get the following

 

Folder decompiled successfully in 0.492s: C:/Program Files (x86)/Tales of Pirates II/scripts/table/

C:\Program Files (x86)\Tales of Pirates II\scripts\table>pause
Press any key to continue . . .

 

 

then when i go look for the  decompiled  text files, i cannot seem to find them,,

 

 

can someone please assist?

 

 


Nissan-GT-R.gif

Share this post


Link to post
Share on other sites
1 hour ago, oldwise2 said:

some1 know how to decrypt texture with deguix ?

 

 

All guidance on how to use this is contained in user.lua; notably, the guidance you are looking for:

 

Quote

--[[
    decrypt_texture(source_image_file[,target_image_file])
    Decrypts the specified source image file to target file. Does nothing but copy if file is already decrypted.
    Replaces itself if target_image_file is not specified.
    
    Parameters:
        source_binary_file: the full path to the source image file using foward slashes. Example: 'C:/Games/TOP/texture/terrain/abrick01.bmp'.
        (optional) target_decrypted_binary_file: the full path to the target decrypted image file using foward slashes. Example: 'C:/Games/TOP/texture/terrain/abrick01_decrypted.bmp'.
--]]

--[[
    decrypt_folder_texture(folder[,linux])
    Decrypts all image files in a folder if they're not decrypted already. Sub-folders are not followed (yet).
    
    Parameters:
        folder: path to the folder using foward slashes and no ending slash. Example: 'C:/Games/TOP/texture/terrain'.
        (optional) linux: set to true if using this in a linux system (cmdline program in linux is named differently). Example: true.
--]]

 

Does that answer your question? Else, what further guidance do you need and what have you tried so far?

Share this post


Link to post
Share on other sites
37 minutes ago, oldwise2 said:

image.png.bcba462bd17d1b0656c08c3a195b32aa.png

 

 

when i open the decompiler . bat this appears  ,,, luajit is not recognized as an internal or external command

Could you post a screenshot of your folder structure for the decompiler please? And just to double check - you are running the bat file by double clicking it?

Share this post


Link to post
Share on other sites

I would advise you first try downloading the decompiler from the Google Drive link and extract all of the contents to a separate, new directory. It looks like you have downloaded the decompiler from the source code repository and are trying to use it as a standalone version; if you wish to do this you should download the Google Drive link, extract the contents, then replace the decompiler.lua in the Google Drive release with the same file from the source code repository, per the original post:

Quote

To get it to work in standalone (like with the old version), download the old version first, and just replace the old "decompiler.lua" file with the new one. (so far no changes afaik)

 

As it stands, you are missing some crucial files. Once you extract the contents from the Google Drive link, the folder should have the following contents:

 

KcT0MPv.png

(This directory structure is straight from the current Google Drive download link in the original post of this thread)

 

 

Once you have:

1. Re-downloaded and extracted the entirety of the contents to a fresh folder;

2. Modified the user.lua file to:

    i) adjust the functions called (make sure you are decrypting textures and not decompiling bins)

    ii) adjust the target directory path

3. Run decompile.bat again (in the same manner, by double clicking it) (note: if the target directory is protected / requires admin rights to make files, then you will need to run decompile.bat as admin)

 

Let me know if it worked, what hurdle we need to cross next (include any error messages, etc.), or if you need clarification on anything I said. If it worked, then you can (but don't necessarily need to) replace the decompiler.lua with the same file from the source code repository, as previously instructed.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...