FanTranslatorsInternational / Kuriimu2

Kuriimu is a general purpose game translation project manager and toolkit for authors of fan translations and game mods.
GNU General Public License v3.0
310 stars 56 forks source link

Cardfight Vanguard (Decompression/Script Reader) #196

Closed ghost closed 2 years ago

ghost commented 2 years ago

Game Name: Cardfight!! Vanguard - Lock On Victory!! Console: Nintendo 3DS Format extension(s): .ctpk / .rtz Type: Text / Archive

First 8 or more bytes of the file(s): 80 00 02 00 1F 8B 08 00 00 00 00 00 00 03 ED 9D (.ctpk) 83 07 01 00 1F 8B 08 00 00 00 00 00 00 03 ED BD (.rtz)

More details: Apparent impossibility to access editable files due to complex compression. This is a challenge for romhackers that extends from the game's release in 2014 to the present day.

Other useful information can be seen in this topic about another game in the franchise, but with the same issue: http://q-bec.com/threads/help-editing-files-in-cardfight-vanguard-ride-to-victory.414178/

Sample files (if possible): 1) One of the main files (World Map): https://cdn.discordapp.com/attachments/706744631416586280/868279649766084648/worldmap.rtz 2) Unreadable text file obtained after an extraction attempt: https://cdn.discordapp.com/attachments/706744631416586280/868358286821445682/worldmap_saved.txt 3) Others files: https://cdn.discordapp.com/attachments/896224790782820413/896229805924708382/EV_CR_01.rtz https://cdn.discordapp.com/attachments/896224790782820413/896229870235942972/ch0010_msk.ctpk

onepiecefreak3 commented 2 years ago

As already explained in the linked gbatemp-Thread, the rtz is compressed with GZip from the 4th byte onwards. The first 4 bytes are the size of the decompressed file in Little Endian. Kuriimu2 will add an option to de-/compress GZip with the solution of this issue. After decompression, the rtz contains probably a script-like language. The text is not meant to be read as is in a text editor, nor is the text file provided correctly transformed at all.

While I don't have a deep understanding of the script, what I did figure out is the following: Starting from byte 7 the file contains a series of strings, prefixed with their size as a byte, followed by a 4 byte value. It's possible that this starts at byte 3 already and it's first 4 byte value and then a string. The 4 byte value might describe the action that takes place, and the string denotes the name of the action in the script executor of the game. That is unclear though.

For the given rtz, this structure holds true until byte 0x3aba. Afterwards stored are a series of strings without byte value interruptions. Followed by a list of 8 byte entries. Followed by more structured but unknown data. The sizes of each of those data sections is unclear, as well as how they are read or have to be interpreted.

The scope to fully reverse-engineer this script is too large, and Kuriimu2 does not support script formats with its current API. Therefore Kuriimu2 will not get support for this format. I may write down a more concise documentation of what I found out in the near future, but there will be no new plugin. You're free to close the issue, if you hoped for one.