Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Rune Factory 4 / Present files
- #
- # Written by HenryEx
- #
- # script for QuickBMS http://quickbms.aluigi.org
- idstring "NLCL"
- get FLAGS long
- get HDUMMY1 long
- get HDUMMY2 long
- # check flags so we don't operate on silly files
- if FLAGS != 0x 20130228
- print "[!] Unexpected flags!"
- CleanExit
- endif
- open FDSE "rf3TxtItem_split2_1.eng" 1
- idstring 1 "TEXT"
- get NUM_NAMES long 1
- #setup a virtual memory file
- math TMP = 1
- math TMP *= 0x8000
- log MEMORY_FILE 0 0
- putvarchr MEMORY_FILE TMP 0 # improves the speed with pre-allocation
- log MEMORY_FILE 0 0 # reset the position and size of the file
- set MBEGIN string "\""
- putct MBEGIN string -1 MEMORY_FILE
- get FILENAME basename
- string FILENAME += ".csv"
- get FILESIZE asize
- set CSV string "\";\"" # set the csv string to ";"
- set LINEBREAK binary "\"\x0D\x0A\"" # end with ", linebreak, start with "
- get BLOCKNUM long
- get TOC_P long
- # Set up CSV header
- putct "Set" string -1 MEMORY_FILE # data block, relates to like/dislike categories
- putct CSV string -1 MEMORY_FILE
- putct "ID" string -1 MEMORY_FILE # Item / Category ID
- putct CSV string -1 MEMORY_FILE
- putct "Name" string -1 MEMORY_FILE # Name for items, or "Category" for categories
- putct CSV string -1 MEMORY_FILE
- putct "Effect" string -1 MEMORY_FILE # effect in FP
- putct LINEBREAK string -1 MEMORY_FILE
- if BLOCKNUM > 1
- for i = 1 < BLOCKNUM
- xmath TOSPOS "TOC_P + (0x10 * i) + 4"
- xmath NEXT "i + 1"
- goto TOSPOS
- get OFF_BLOCK long
- if NEXT >= BLOCKNUM
- xmath LEN_BLOCK "TOC_P - OFF_BLOCK"
- else
- xmath TOSPOS "TOC_P + (0x10 * i) + 20"
- goto TOSPOS
- get NEXT_BLOCK long
- xmath LEN_BLOCK "NEXT_BLOCK - OFF_BLOCK"
- endif
- goto OFF_BLOCK
- get NUM_ENTRY long
- xmath LEN_ENTRY "(LEN_BLOCK - 4) / NUM_ENTRY"
- if LEN_ENTRY != 4
- print "[!] Unexpected entry length %LEN_ENTRY%! \n Data Block: %i%, Offset %OFF_BLOCK%, Block Length %LEN_BLOCK%, Entries %NUM_ENTRY%"
- CleanExit
- endif
- for j = 0 < NUM_ENTRY
- get ITEMID short
- get IEFFECT signed_short
- xmath ISCATI "ITEMID & 0x8000"
- if ISCATI > 0
- xmath ISCATG "ITEMID & 0x0100"
- math ITEMID & 0xFF
- else
- math ISCATG = 0
- math ITEMID & 0x0FFF
- endif
- if ITEMID > NUM_NAMES
- print "[!] Item ID %ITEMID% out of bounds. Exiting..."
- CleanExit
- endif
- xmath PTR_NAME "(ITEMID * 8) + 8"
- goto PTR_NAME 1
- get LEN_NAME long 1
- get POS_NAME long 1
- goto POS_NAME 1
- getdstring INAME LEN_NAME 1
- if ISCATI > 0
- string INAME = "[Item Type]"
- endif
- if ISCATG > 0
- math ITEMID + 1
- string INAME = "[Category]"
- endif
- putct i string -1 MEMORY_FILE
- putct CSV string -1 MEMORY_FILE
- putct ITEMID string -1 MEMORY_FILE
- putct CSV string -1 MEMORY_FILE
- putct INAME string -1 MEMORY_FILE
- putct CSV string -1 MEMORY_FILE
- putct IEFFECT string -1 MEMORY_FILE
- putct LINEBREAK string -1 MEMORY_FILE
- next j
- putct LINEBREAK string -1 MEMORY_FILE
- next i
- else
- print "[!] Script is not meant for one block files!"
- CleanExit
- endif
- // write the finished table to the disk
- get MLENGTH asize MEMORY_FILE
- math MLENGTH - 1 # get rid of last trailing double quote
- log FILENAME 0 MLENGTH MEMORY_FILE
- print "[---] SUCCESS! [---]"
Add Comment
Please, Sign In to add comment