Advertisement
HenryEx

The Letter horror visual novel - xml chapter parser QuickBMS

Sep 5th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.83 KB | None | 0 0
  1. # Script to parse XML chapter data from The Letter
  2. # as CSV tables for cleaner data overview
  3. # or as text files for better readability
  4. #
  5. # Written by HenryEx
  6. #
  7. # script for QuickBMS http://quickbms.aluigi.org
  8.  
  9. # script options
  10. set TO_CSV byte 1 # export as CSV
  11. set TO_TEXT byte 1 # export as continuous text file
  12. set SLIMTEXT byte 0 # slim down text export
  13.  
  14.  
  15. # set misc. standard strings / variables
  16. get FILENAME basename 0
  17. get FILESIZE asize 0
  18. set TITLE string ""
  19. set CHAPTER string ""
  20. set CHNAME string ""
  21. set BGROUND string ""
  22. set BGM string ""
  23. set NCHAPTER string ""
  24. set CSV string "\";\"" # set the csv string to ";"
  25. set LINEBREAK binary "\"\x0D\x0A\"" # end with ", linebreak, start with "
  26. set CR binary "\x0D" # Carriage Return
  27. set LF binary "\x0A" # Line Feed
  28. set CRLF short 2573 # CR+LF
  29. set INDENT string " "
  30. set CSTACK long 0 # condition stack
  31. get XMLHEADER line 0
  32. if XMLHEADER != "<?xml version="1.0"?>"
  33. print "[!] Error: incorrect XML header found! Exiting..."
  34. CleanExit
  35. endif
  36. findloc STARTITEMS string "<items>" 0 # offset of start bracket for items
  37. # findloc ENDITEMS string "</items>" 0 # offset of end bracket for items
  38.  
  39. #setup virtual memory files
  40. math TMP = 1000
  41. math TMP *= 0x8000 # 32 MB
  42. if TO_CSV != 0
  43. log MEMORY_FILE 0 0
  44. putvarchr MEMORY_FILE TMP 0 # improves the speed with pre-allocation
  45. log MEMORY_FILE 0 0 # reset the position and size of the file
  46. set MBEGIN string "\"" # leading "
  47. putct MBEGIN string -1 MEMORY_FILE
  48. endif
  49. if TO_TEXT != 0
  50. log MEMORY_FILE2 0 0
  51. putvarchr MEMORY_FILE2 TMP 0 # improves the speed with pre-allocation
  52. log MEMORY_FILE2 0 0 # reset the position and size of the file
  53. putarray 2 20 0 # pre-allocate condition index array
  54. putarray 2 0 0
  55. endif
  56.  
  57. # set up actions array
  58. putarray 0 48 0 # pre-allocate
  59. putarray 0 0 "none"
  60. putarray 0 1 "say"
  61. putarray 0 2 "charadd"
  62. putarray 0 3 "question"
  63. putarray 0 4 "choice"
  64. putarray 0 5 "condition"
  65. putarray 0 6 "else"
  66. putarray 0 7 "conditionend"
  67. putarray 0 8 "gotochapter"
  68. putarray 0 9 "charmove"
  69. putarray 0 10 "chardel"
  70. putarray 0 11 "bgchange"
  71. putarray 0 12 "fadeout"
  72. putarray 0 13 "fadein"
  73. putarray 0 14 "wait"
  74. putarray 0 15 "playsound"
  75. putarray 0 16 "changebgm"
  76. putarray 0 17 "playsoundloop"
  77. putarray 0 18 "stopsoundloop"
  78. putarray 0 19 "charscale"
  79. putarray 0 20 "charemote"
  80. putarray 0 21 "portraitchange"
  81. putarray 0 22 "bgmove"
  82. putarray 0 23 "bgscale"
  83. putarray 0 24 "quicktime"
  84. putarray 0 25 "bgaction"
  85. putarray 0 26 "gameover"
  86. putarray 0 27 "checkpoint"
  87. putarray 0 28 "camerashake"
  88. putarray 0 29 "galleryunlock"
  89. putarray 0 30 "achievement"
  90. putarray 0 31 "addphonecall"
  91. putarray 0 32 "removephonecall"
  92. putarray 0 33 "playeffects"
  93. putarray 0 34 "unlockjournal"
  94. putarray 0 35 "playvoice"
  95. putarray 0 36 "unlockbranchtreenode"
  96. putarray 0 37 "setvariable"
  97. putarray 0 38 "charanim"
  98. putarray 0 39 "showgamenotification"
  99. putarray 0 40 "chardirection"
  100. putarray 0 41 "charchangearm"
  101. putarray 0 42 "charchangepose"
  102. putarray 0 43 "addfocusobject"
  103. putarray 0 44 "removefocusobject"
  104. putarray 0 45 "unlockending"
  105. putarray 0 46 "unlockrelationship"
  106. putarray 0 47 "eyeanim"
  107. putarray 0 48 "showingametitle"
  108.  
  109. # set up eyeanim array
  110. putarray 1 4 0 # pre-allocate
  111. putarray 1 0 "DisableOverride"
  112. putarray 1 1 "Eye00Default"
  113. putarray 1 2 "Eye01Left"
  114. putarray 1 3 "Eye02Right"
  115. putarray 1 4 "Eye03Dilated"
  116.  
  117.  
  118. # ========================================
  119.  
  120. # process first lines
  121. for i = 0 < 1
  122. get DATA line 0
  123. savepos OFFSET 0 # offset of next line
  124.  
  125. if OFFSET >= STARTITEMS
  126. math OFFSET = STARTITEMS
  127. math i = 1 # stop reading header lines
  128. endif
  129.  
  130. if DATA != "" # parse other header items
  131. if DATA & "</Title>"
  132. string DATA > "</Title>" # clip off end tag
  133. string DATA | "<Title>" # clip off start tag
  134. set TITLE string DATA
  135. elif DATA & "</Chapter>"
  136. string DATA > "</Chapter>" # clip off end tag
  137. string DATA | "<Chapter>" # clip off start tag
  138. set CHAPTER string DATA
  139. elif DATA & "</ChapterName>"
  140. string DATA > "</ChapterName>" # clip off end tag
  141. string DATA | "<ChapterName>" # clip off start tag
  142. set CHNAME string DATA
  143. elif DATA & "</Background>"
  144. string DATA > "</Background>" # clip off end tag
  145. string DATA | "<Background>" # clip off start tag
  146. set BGROUND string DATA
  147. elif DATA & "</BGM>"
  148. string DATA > "</BGM>" # clip off end tag
  149. string DATA | "<BGM>" # clip off start tag
  150. set BGM string DATA
  151. elif DATA & "</NextChapter>"
  152. string DATA > "</NextChapter>" # clip off end tag
  153. string DATA | "<NextChapter>" # clip off start tag
  154. set NCHAPTER string DATA
  155. endif
  156. endif
  157. next
  158.  
  159. if TO_CSV != 0
  160. # write header columns, row 1
  161. /*
  162. string HEADER = "Chapter "
  163. string HEADER + CHAPTER
  164. string HEADER + ", "
  165. string HEADER + CHNAME
  166. string HEADER + ", Title: "
  167. string HEADER + TITLE
  168. string HEADER + ", BG: "
  169. string HEADER + BGROUND
  170. string HEADER + ", BGM: "
  171. string HEADER + BGM
  172. string HEADER + ", next: "
  173. string HEADER + NCHAPTER
  174. putct HEADER string -1 MEMORY_FILE
  175. putct LINEBREAK string -1 MEMORY_FILE
  176. */
  177.  
  178. # write header columns, row 2
  179. putct "Idx" string -1 MEMORY_FILE
  180. putct CSV string -1 MEMORY_FILE
  181. putct "Action" string -1 MEMORY_FILE
  182. putct CSV string -1 MEMORY_FILE
  183. putct "Name" string -1 MEMORY_FILE
  184. putct CSV string -1 MEMORY_FILE
  185. putct "VN Text" string -1 MEMORY_FILE
  186. putct CSV string -1 MEMORY_FILE
  187. putct "Variable1" string -1 MEMORY_FILE
  188. putct CSV string -1 MEMORY_FILE
  189. putct "Value" string -1 MEMORY_FILE
  190. putct LINEBREAK string -1 MEMORY_FILE
  191. endif
  192.  
  193. if TO_TEXT != 0
  194. putct "Chapter " string -1 MEMORY_FILE2
  195. putct CHAPTER string -1 MEMORY_FILE2
  196. putct ": " string -1 MEMORY_FILE2
  197. putct CHNAME string -1 MEMORY_FILE2
  198. put CRLF short MEMORY_FILE2
  199. if TITLE != ""
  200. putct "Title: " string -1 MEMORY_FILE2
  201. putct TITLE string -1 MEMORY_FILE2
  202. put CRLF short MEMORY_FILE2
  203. endif
  204. if BGROUND != ""
  205. putct "Background: " string -1 MEMORY_FILE2
  206. putct BGROUND string -1 MEMORY_FILE2
  207. put CRLF short MEMORY_FILE2
  208. endif
  209. if BGM != ""
  210. putct "BGM: " string -1 MEMORY_FILE2
  211. putct BGM string -1 MEMORY_FILE2
  212. put CRLF short MEMORY_FILE2
  213. endif
  214. if NCHAPTER != ""
  215. putct "Next default chapter: " string -1 MEMORY_FILE2
  216. putct NCHAPTER string -1 MEMORY_FILE2
  217. put CRLF short MEMORY_FILE2
  218. endif
  219. put CRLF short MEMORY_FILE2
  220. endif
  221.  
  222.  
  223. # ========================================
  224.  
  225. # go to offset after <items>
  226. math OFFSET + 7
  227. goto OFFSET 0
  228.  
  229. # process VNItems
  230. for i = 0 < 1
  231. # set up default field values
  232. math ACTIONID = 0
  233. string VNACTION = "?"
  234. string INDEX = "?"
  235. string DIRECTION = ""
  236. string SIZE = ""
  237. string SPEED = ""
  238. string TRANSITION = ""
  239. string VAR1 = ""
  240. string CNAME = ""
  241. string AUTONEXT = ""
  242. string POSX = ""
  243. string POSY = ""
  244. string FADE = ""
  245. string VNTEXT = ""
  246. string ANIMATION = ""
  247. string EMOTION = ""
  248. string ARMPOSE = ""
  249. string EYEANIMID = ""
  250. string EYEANIMATION = ""
  251. string XMLVAL = ""
  252.  
  253. /*
  254. # get VNItem line
  255. get DATA line 0
  256.  
  257. if DATA & "</items>"
  258. string DATA > "</items>"
  259. math i + 1 # stop
  260. endif
  261. */
  262.  
  263. # alternate data fetch across lines
  264. findloc TAG_OFF string "<VNItem" 0 ""
  265. if TAG_OFF != ""
  266. findloc TAG_END string "</VNItem>"
  267. xmath TAG_SZ "TAG_END + 9 - TAG_OFF"
  268. goto TAG_OFF 0
  269. getdstring DATA TAG_SZ 0
  270. else
  271. math i = 1 # no more lines found, stop
  272. continue # end for loop
  273. endif
  274.  
  275. # get action id
  276. string TEMP = DATA
  277. string TEMP 0| "id=\""
  278. string TEMP 0% "\""
  279. if TEMP != ""
  280. math ACTIONID = TEMP
  281. getarray VNACTION 0 ACTIONID
  282. endif
  283.  
  284. # get index
  285. string TEMP = DATA
  286. string TEMP 0| "idx=\""
  287. string TEMP 0% "\""
  288. if TEMP != ""
  289. math INDEX = TEMP
  290. endif
  291.  
  292. # abort if we got bogus data
  293. if ACTIONID > 48
  294. print "[!] Error: action ID %ACTIONID% on line %INDEX% out of bounds! Exiting..."
  295. CleanExit
  296. endif
  297.  
  298. # get direction
  299. string TEMP = DATA
  300. string TEMP 0| "direction=\""
  301. string TEMP 0% "\""
  302. if TEMP != ""
  303. math DIRECTION = TEMP
  304. endif
  305.  
  306. # get size (float)
  307. string TEMP = DATA
  308. string TEMP 0| "size=\""
  309. string TEMP 0% "\""
  310. if TEMP != ""
  311. set SIZE string TEMP
  312. endif
  313.  
  314. # get speed (float)
  315. string TEMP = DATA
  316. string TEMP 0| "speed=\""
  317. string TEMP 0% "\""
  318. if TEMP != ""
  319. set SPEED string TEMP
  320. endif
  321.  
  322. # get transition
  323. string TEMP = DATA
  324. string TEMP 0| "transition=\""
  325. string TEMP 0% "\""
  326. if TEMP != ""
  327. callfunction CLEAN_XML_STR 1
  328. set TRANSITION string TEMP
  329. endif
  330.  
  331. # get variable1
  332. string TEMP = DATA
  333. string TEMP 0| "variable1=\""
  334. string TEMP 0% "\""
  335. if TEMP != ""
  336. callfunction CLEAN_XML_STR 1
  337. set VAR1 string TEMP
  338. endif
  339.  
  340. # get name
  341. string TEMP = DATA
  342. string TEMP 0| "name=\""
  343. string TEMP 0% "\""
  344. if TEMP != ""
  345. callfunction CLEAN_XML_STR 1
  346. set CNAME string TEMP
  347. endif
  348.  
  349. # get autonext (float)
  350. string TEMP = DATA
  351. string TEMP 0| "autonext=\""
  352. string TEMP 0% "\""
  353. if TEMP != ""
  354. set AUTONEXT string TEMP
  355. endif
  356.  
  357. # get posX (float)
  358. string TEMP = DATA
  359. string TEMP 0| "posX=\""
  360. string TEMP 0% "\""
  361. if TEMP != ""
  362. set POSX string TEMP
  363. endif
  364.  
  365. # get posY (float)
  366. string TEMP = DATA
  367. string TEMP 0| "posY=\""
  368. string TEMP 0% "\""
  369. if TEMP != ""
  370. set POSY string TEMP
  371. endif
  372.  
  373. # get fade (bool)
  374. string TEMP = DATA
  375. string TEMP 0| "fade=\""
  376. string TEMP 0% "\""
  377. if TEMP != ""
  378. set FADE string TEMP
  379. endif
  380.  
  381. # get VN text
  382. string TEMP = DATA
  383. string TEMP 0| "vntext=\""
  384. string TEMP 0% "\""
  385. if TEMP != ""
  386. callfunction CLEAN_XML_STR 1
  387. set VNTEXT string TEMP
  388. endif
  389.  
  390. # get animation
  391. string TEMP = DATA
  392. string TEMP 0| "animation=\""
  393. string TEMP 0% "\""
  394. if TEMP != ""
  395. callfunction CLEAN_XML_STR 1
  396. set ANIMATION string TEMP
  397. endif
  398.  
  399. # get emotion
  400. string TEMP = DATA
  401. string TEMP 0| "emotion=\""
  402. string TEMP 0% "\""
  403. if TEMP != ""
  404. callfunction CLEAN_XML_STR 1
  405. set EMOTION string TEMP
  406. endif
  407.  
  408. # get arm pose
  409. string TEMP = DATA
  410. string TEMP 0| "armpose=\""
  411. string TEMP 0% "\""
  412. if TEMP != ""
  413. callfunction CLEAN_XML_STR 1
  414. set ARMPOSE string TEMP
  415. endif
  416.  
  417. # get eye animation
  418. string TEMP = DATA
  419. string TEMP 0| "eyeanim=\""
  420. string TEMP 0% "\""
  421. if TEMP != ""
  422. math EYEANIMID = TEMP
  423. endif
  424.  
  425. # get value
  426. string TEMP = DATA
  427. string TEMP > "</VNItem>"
  428. string TEMP 0| ">"
  429. if TEMP != ""
  430. callfunction CLEAN_XML_STR 1
  431. set XMLVAL string TEMP
  432. endif
  433.  
  434. # put values into table
  435. if TO_CSV != 0
  436. putct INDEX string -1 MEMORY_FILE
  437. putct CSV string -1 MEMORY_FILE
  438. putct VNACTION string -1 MEMORY_FILE
  439. putct CSV string -1 MEMORY_FILE
  440. putct CNAME string -1 MEMORY_FILE
  441. putct CSV string -1 MEMORY_FILE
  442. putct VNTEXT string -1 MEMORY_FILE
  443. putct CSV string -1 MEMORY_FILE
  444. putct VAR1 string -1 MEMORY_FILE
  445. putct CSV string -1 MEMORY_FILE
  446. putct XMLVAL string -1 MEMORY_FILE
  447. putct LINEBREAK string -1 MEMORY_FILE
  448. endif
  449.  
  450.  
  451. # parse values into text file
  452. if TO_TEXT != 0
  453. if INDEX > 9999 # whoa what
  454. string LINETEXT = "[!]Error: Index of 10k and above unsupported!"
  455. putct LINETEXT string -1 MEMORY_FILE2
  456. math i = 1 # stop everything
  457. continue # abort, abort
  458. endif
  459.  
  460. string LINETEXT p "%.4i: " INDEX # get 4 digit idx
  461. for j = CSTACK > 0
  462. string LINETEXT + INDENT # indent text depending on conditions stack
  463. prev j
  464.  
  465. # mod string for every action ID case
  466. if ACTIONID == 0 # none
  467. # print "Parse action 0: none @ idx %INDEX%"
  468. string LINETEXT + "[NONE]"
  469. if CNAME != ""
  470. string LINETEXT + " Name: "
  471. string LINETEXT + CNAME
  472. endif
  473. if XMLVAL != ""
  474. string LINETEXT + " Value: "
  475. string LINETEXT + XMLVAL
  476. endif
  477. if VNTEXT != ""
  478. string LINETEXT + " VNText: "
  479. string LINETEXT + VNTEXT
  480. endif
  481. elif ACTIONID == 1 # say
  482. # print "Parse action 1: say @ idx %INDEX%"
  483. set SPEAKER string CNAME
  484. if SPEAKER == "None"
  485. string SPEAKER = ""
  486. endif
  487. if VAR1 != ""
  488. set PORTRAIT1 string VAR1
  489. set PORTRAIT2 string VAR1
  490. string PORTRAIT1 % "/" # 1st half of portrait
  491. string PORTRAIT2 0| "/" # 2nd half of portrait or ""
  492. if PORTRAIT2 == "None"
  493. string PORTRAIT2 = ""
  494. endif
  495. else
  496. string PORTRAIT1 = "None"
  497. string PORTRAIT2 = ""
  498. endif
  499. set PORTRAIT string PORTRAIT1
  500. string PORTRAIT + PORTRAIT2
  501. if SLIMTEXT == 0
  502. string LINETEXT + "{"
  503. string LINETEXT + "PORTRAIT"
  504. string LINETEXT + "} \""
  505. string LINETEXT + VNTEXT
  506. string LINETEXT + "\" ("
  507. if SPEAKER != ""
  508. string LINETEXT + "as "
  509. string LINETEXT + SPEAKER
  510. string LINETEXT + ", "
  511. endif
  512. string LINETEXT + "voice: "
  513. string LINETEXT + XMLVAL
  514. string LINETEXT + ")"
  515. else
  516. string VNTEXT replace "''" "\"" # double apostrophe => quotation marks
  517. if PORTRAIT == "Others" && SPEAKER != ""
  518. string LINETEXT + "[b]"
  519. string LINETEXT + SPEAKER
  520. string LINETEXT + "[/b]"
  521. elif SPEAKER == "???"
  522. string LINETEXT + "[b]"
  523. string LINETEXT + SPEAKER
  524. string LINETEXT + "[/b]"
  525. else
  526. string LINETEXT + "{"
  527. string LINETEXT + "PORTRAIT"
  528. string LINETEXT + "}"
  529. endif
  530. string LINETEXT + ": "
  531. string LINETEXT + VNTEXT
  532. endif
  533. elif ACTIONID == 2 # charadd
  534. # print "Parse action 2: charadd @ idx %INDEX%"
  535. string LINETEXT + "[C]+ >'"
  536. string LINETEXT + XMLVAL
  537. string LINETEXT + "' added"
  538. if SLIMTEXT == 0
  539. string LINETEXT + " @ pos ("
  540. string LINETEXT + POSX
  541. string LINETEXT + ", "
  542. string LINETEXT + POSY
  543. string LINETEXT + "), "
  544. if DIRECTION == 1
  545. string LINETEXT + "facing left"
  546. elif DIRECTION == -1
  547. string LINETEXT + "facing right"
  548. else
  549. string LINETEXT + "direction "
  550. if DIRECTION != ""
  551. string LINETEXT + DIRECTION
  552. else
  553. string LINETEXT + "???"
  554. endif
  555. endif
  556. endif
  557. string LINETEXT + ", emoting "
  558. string LINETEXT + EMOTION
  559. if EYEANIMID != ""
  560. string LINETEXT + " with eyes #"
  561. string LINETEXT + EYEANIMID
  562. if EYEANIMID < 5
  563. getarray EYEANIMATION 1 EYEANIMID
  564. string LINETEXT + ": "
  565. string LINETEXT + EYEANIMATION
  566. else
  567. print "[!] Error: Unknown eye animation %EYEANIMID% at idx %INDEX%"
  568. endif
  569. endif
  570. if SLIMTEXT == 0
  571. string LINETEXT + ", pose "
  572. string LINETEXT + ANIMATION
  573. string LINETEXT + ", arms "
  574. string LINETEXT + ARMPOSE
  575. endif
  576. if DIRECTION != ""
  577. if DIRECTION != 1 && DIRECTION != -1
  578. string LINETEXT + " [!]Error: Unknown direction!"
  579. endif
  580. endif
  581. if EYEANIMID != ""
  582. if EYEANIMID > 4
  583. string LINETEXT + " [!]Error: Unknown eye animation!"
  584. endif
  585. endif
  586. elif ACTIONID == 3 # question
  587. # print "Parse action 3: question @ idx %INDEX%"
  588. string LINETEXT + "[Q] \""
  589. string LINETEXT + VNTEXT
  590. string LINETEXT + "\""
  591. elif ACTIONID == 4 # choice
  592. # print "Parse action 4: choice @ idx %INDEX%"
  593. string LINETEXT + " [A] \""
  594. string LINETEXT + VNTEXT
  595. string LINETEXT + "\" --> "
  596. set TEMP string VAR1
  597. string TEMP R "_" ", "
  598. string LINETEXT + TEMP
  599. elif ACTIONID == 5 # condition
  600. # print "Parse action 5: condition @ idx %INDEX%"
  601. if XMLVAR == ""
  602. print "[!]Error: Condition missing on idx %INDEX%!"
  603. string LINETEXT P "[!]Error: Condition missing on idx %INDEX%!"
  604. else
  605. math CSTACK + 1
  606. putarray 2 CSTACK INDEX # put idx of condition in stack array
  607. string LINETEXT + "$If ( "
  608. set TEMP string XMLVAL
  609. if TEMP & "|"
  610. for j = 0 < 1
  611. set TEMP2 string TEMP
  612. string TEMP2 0% "|" # str before 1st OR
  613. string TEMP | "|" # str after 1st OR, rest
  614. if TEMP2 != ""
  615. string LINETEXT + TEMP2
  616. string LINETEXT + " OR "
  617. else
  618. string LINETEXT + TEMP
  619. math j = 1
  620. endif
  621. next
  622. elif TEMP & "&"
  623. for j = 0 < 1
  624. set TEMP2 string TEMP
  625. string TEMP2 0% "&" # str before 1st AND
  626. string TEMP | "&" # str after 1st AND, rest
  627. if TEMP2 != ""
  628. string LINETEXT + TEMP2
  629. string LINETEXT + " AND "
  630. else
  631. string LINETEXT + TEMP
  632. math j = 1
  633. endif
  634. next
  635. else
  636. string LINETEXT + XMLVAL
  637. endif
  638. string LINETEXT + " )"
  639. endif
  640. elif ACTIONID == 6 # else
  641. # print "Parse action 6: else @ idx %INDEX%"
  642. getarray TEMP 2 CSTACK # get idx of current condition
  643. string TEMP p "%.4i" TEMP
  644. string LINETEXT > INDENT # remove indentation
  645. string LINETEXT + "$Else @"
  646. string LINETEXT + TEMP
  647. if CSTACK < 1
  648. print "[!] Error: Hit ELSE before condition on idx %INDEX%!"
  649. string LINETEXT P "[!]Error: Hit ELSE before condition on idx %INDEX%!"
  650. endif
  651. elif ACTIONID == 7 # conditionend
  652. # print "Parse action 7: conditionend @ idx %INDEX%"
  653. getarray TEMP 2 CSTACK # get idx of current condition
  654. string TEMP p "%.4i" TEMP
  655. string LINETEXT > INDENT # remove indentation
  656. string LINETEXT + "$Endif @"
  657. string LINETEXT + TEMP
  658. if CSTACK > 0
  659. math CSTACK - 1
  660. else
  661. print "[!] Error: Hit END before condition on idx %INDEX%!"
  662. string LINETEXT P "[!]Error: Hit END before condition on idx %INDEX%!"
  663. endif
  664. elif ACTIONID == 8 # gotochapter
  665. # print "Parse action 8: gotochapter @ idx %INDEX%"
  666. string LINETEXT + "[-->] Chapter "
  667. string LINETEXT + XMLVAL
  668. elif ACTIONID == 9 # charmove
  669. # print "Parse action 9: charmove @ idx %INDEX%"
  670. string LINETEXT + ">'"
  671. string LINETEXT + XMLVAL
  672. string LINETEXT + "' moved by ("
  673. string LINETEXT + POSX
  674. string LINETEXT + ", "
  675. string LINETEXT + POSY
  676. string LINETEXT + "), speed "
  677. string LINETEXT + SPEED
  678. elif ACTIONID == 10 # chardel
  679. # print "Parse action 10: chardel @ idx %INDEX%"
  680. string LINETEXT + "[C]- >'"
  681. string LINETEXT + XMLVAL
  682. string LINETEXT + "' leaves the screen"
  683. elif ACTIONID == 11 # bgchange
  684. # print "Parse action 11: bgchange @ idx %INDEX%"
  685. if VAR1 == "" || VAR1 == 1
  686. string LINETEXT + "[BG] Fade to "
  687. else
  688. string LINETEXT + "[BG] Change to "
  689. endif
  690. string LINETEXT + XMLVAL
  691. # elif ACTIONID == 12 # fadeout, unused
  692. # print "Parse action 12: fadeout @ idx %INDEX%"
  693. # elif ACTIONID == 13 # fadein, unused
  694. # print "Parse action 13: fadein @ idx %INDEX%"
  695. # elif ACTIONID == 14 # wait, unused
  696. # print "Parse action 14: wait @ idx %INDEX%"
  697. elif ACTIONID == 15 # playsound
  698. # print "Parse action 15: playsound @ idx %INDEX%"
  699. string LINETEXT + "[SFX] "
  700. string LINETEXT + XMLVAL
  701. if SLIMTEXT != 0
  702. if XMLVAL == "GameNotificationSFX"
  703. string LINETEXT = ""
  704. endif
  705. endif
  706. elif ACTIONID == 16 # changebgm
  707. # print "Parse action 16: changebgm @ idx %INDEX%"
  708. string LINETEXT + "[MUSIC] "
  709. string LINETEXT + XMLVAL
  710. if VAR1 != ""
  711. string LINETEXT + " (on next BG change)"
  712. endif
  713. elif ACTIONID == 17 # playsoundloop
  714. # print "Parse action 17: playsoundloop @ idx %INDEX%"
  715. string LINETEXT + "[SFX] Play loop: "
  716. string LINETEXT + XMLVAL
  717. elif ACTIONID == 18 # stopsoundloop
  718. # print "Parse action 18: stopsoundloop @ idx %INDEX%"
  719. string LINETEXT + "[SFX] Stop loop"
  720. # elif ACTIONID == 19 # charscale, unused
  721. # print "Parse action 19: charscale @ idx %INDEX%"
  722. elif ACTIONID == 20 # charemote
  723. # print "Parse action 20: charemote @ idx %INDEX%"
  724. string LINETEXT + ">'"
  725. string LINETEXT + CNAME
  726. string LINETEXT + "' emotes: "
  727. string LINETEXT + XMLVAL
  728. # elif ACTIONID == 21 # portraitchange, unused
  729. # print "Parse action 21: portraitchange @ idx %INDEX%"
  730. elif ACTIONID == 22 # bgmove
  731. # print "Parse action 22: bgmove @ idx %INDEX%"
  732. string LINETEXT + "[BG] Move to pos ("
  733. string LINETEXT + POSX
  734. string LINETEXT + ", "
  735. string LINETEXT + POSY
  736. string LINETEXT + "), speed: "
  737. string LINETEXT + SPEED
  738. # elif ACTIONID == 23 # bgscale, unused
  739. # print "Parse action 23: bgscale @ idx %INDEX%"
  740. elif ACTIONID == 24 # quicktime
  741. # print "Parse action 24: quicktime @ idx %INDEX%"
  742. string LINETEXT + "[QTE] "
  743. string LINETEXT + XMLVAL
  744. string LINETEXT + " (var "
  745. string LINETEXT + VAR1
  746. string LINETEXT + ")"
  747. elif ACTIONID == 25 # bgaction
  748. # print "Parse action 25: bgaction @ idx %INDEX%"
  749. string LINETEXT + "[BG] Action #"
  750. string LINETEXT + XMLVAL
  751. elif ACTIONID == 26 # gameover
  752. # print "Parse action 26: gameover @ idx %INDEX%"
  753. string LINETEXT + "[GAME OVER]"
  754. elif ACTIONID == 27 # checkpoint
  755. # print "Parse action 27: checkpoint @ idx %INDEX%"
  756. string LINETEXT + "[CHECKPOINT]"
  757. elif ACTIONID == 28 # camerashake
  758. # print "Parse action 28: camerashake @ idx %INDEX%"
  759. if SLIMTEXT == 0
  760. string LINETEXT + "[SHAKE] Duration "
  761. string LINETEXT + SPEED
  762. string LINETEXT + ", Intensity "
  763. string LINETEXT + SIZE
  764. else
  765. string LINETEXT = ""
  766. endif
  767. # elif ACTIONID == 29 # galleryunlock, unused
  768. # print "Parse action 29: galleryunlock @ idx %INDEX%"
  769. elif ACTIONID == 30 # achievement
  770. # print "Parse action 30: achievement @ idx %INDEX%"
  771. string LINETEXT + "[ACHIEVEMENT] "
  772. string TEMP = VNTEXT
  773. string TEMP | ": "
  774. if SLIMTEXT == 0
  775. string LINETEXT + TEMP
  776. string LINETEXT + " (id: #"
  777. string LINETEXT + VAR1
  778. string LINETEXT + ")"
  779. else
  780. string LINETEXT + "[b]"
  781. string LINETEXT + TEMP
  782. string LINETEXT + "[/b]"
  783. endif
  784. elif ACTIONID == 31 # addphonecall
  785. # print "Parse action 31: addphonecall @ idx %INDEX%"
  786. if CNAME != ""
  787. set CALLNAME string CNAME
  788. set CALLIMG string CNAME
  789. string CALLNAME % "/" # 1st half of string
  790. string CALLIMG 0| "/" # 2nd half of string or ""
  791. string LINETEXT + "[PHONE] Add "
  792. string LINETEXT + XMLVAL
  793. string LINETEXT + ", caller "
  794. string LINETEXT + CALLNAME
  795. string LINETEXT + ", image "
  796. string LINETEXT + CALLIMG
  797. string LINETEXT + ", type: "
  798. if VAR1 == 0
  799. string LINETEXT + "Talking"
  800. elif VAR1 == 1
  801. string LINETEXT + "Incoming"
  802. elif VAR1 == 2
  803. string LINETEXT + "Calling"
  804. else
  805. string LINETEXT + "[!]Error: Unknown phonecall type!"
  806. endif
  807. else
  808. string LINETEXT + "[!]Error: Phone call with undefined recipient!"
  809. endif
  810. elif ACTIONID == 32 # removephonecall
  811. # print "Parse action 32: removephonecall @ idx %INDEX%"
  812. string LINETEXT + "[PHONE] Remove phonecall"
  813. # elif ACTIONID == 33 # playeffects, unused
  814. # print "Parse action 33: playeffects @ idx %INDEX%"
  815. elif ACTIONID == 34 # unlockjournal
  816. # print "Parse action 34: unlockjournal @ idx %INDEX%"
  817. string LINETEXT + "[JOURNAL] Unlock section "
  818. string LINETEXT + XMLVAL
  819. string LINETEXT + " in "
  820. if VAR1 == 1
  821. string LINETEXT + "Timeline"
  822. elif VAR1 == 3
  823. string LINETEXT + "Profiles"
  824. elif VAR1 == 2
  825. string LINETEXT + "E. Mansion"
  826. else
  827. print "[!] Error: Unknown journal ID %VAR1% on idx %INDEX%!"
  828. string LINETEXT P "[!]Error: Unknown journal ID %VAR1% on idx %INDEX%!"
  829. endif
  830. # elif ACTIONID == 35 # playvoice, unused
  831. # print "Parse action 35: playvoice @ idx %INDEX%"
  832. elif ACTIONID == 36 # unlockbranchtreenode
  833. # print "Parse action 36: unlockbranchtreenode @ idx %INDEX%"
  834. if SLIMTEXT == 0
  835. string LINETEXT + "Unlock branch tree node #"
  836. string LINETEXT + XMLVAL
  837. string LINETEXT + " in route "
  838. string LINETEXT + VAR1
  839. else
  840. string LINETEXT = ""
  841. endif
  842. elif ACTIONID == 37 # setvariable
  843. # print "Parse action 37: setvariable @ idx %INDEX%"
  844. set TEMP string XMLVAL
  845. if TEMP & "gameData"
  846. string TEMP | "gameData"
  847. string LINETEXT + "[SETVAR] persistent var "
  848. else
  849. string LINETEXT + "[SETVAR] current var "
  850. endif
  851. string LINETEXT + TEMP
  852. elif ACTIONID == 38 # charanim
  853. # print "Parse action 38: charanim @ idx %INDEX%"
  854. string LINETEXT + ">'"
  855. string LINETEXT + CNAME
  856. string LINETEXT + "' animates with: "
  857. string LINETEXT + XMLVAL
  858. elif ACTIONID == 39 # showgamenotification
  859. # print "Parse action 39: showgamenotification @ idx %INDEX%"
  860. if VNTEXT == "Story Updated"
  861. string LINETEXT + "[BUTTERFLY]"
  862. elif VNTEXT & "Journal" && SLIMTEXT != 0
  863. string LINETEXT = ""
  864. else
  865. string LINETEXT + "[NOTE] "
  866. if SLIMTEXT != 0
  867. string LINETEXT + "[b]"
  868. endif
  869. string LINETEXT + "'"
  870. string LINETEXT + VNTEXT
  871. string LINETEXT + "'"
  872. if SLIMTEXT != 0
  873. string LINETEXT + "[/b]"
  874. else
  875. string LINETEXT + " (icon "
  876. string LINETEXT + XMLVAL
  877. string LINETEXT + ")"
  878. endif
  879. endif
  880. # elif ACTIONID == 40 # chardirection, unused
  881. # print "Parse action 40: chardirection @ idx %INDEX%"
  882. elif ACTIONID == 41 # charchangearm
  883. # print "Parse action 41: charchangearm @ idx %INDEX%"
  884. string LINETEXT + ">'"
  885. string LINETEXT + CNAME
  886. string LINETEXT + "' animates into arm position "
  887. string LINETEXT + XMLVAL
  888. elif ACTIONID == 42 # charchangepose
  889. # print "Parse action 42: charchangepose @ idx %INDEX%"
  890. string LINETEXT + ">'"
  891. string LINETEXT + CNAME
  892. string LINETEXT + "' animates into position "
  893. string LINETEXT + XMLVAL
  894. elif ACTIONID == 43 # addfocusobject
  895. # print "Parse action 43: addfocusobject @ idx %INDEX%"
  896. string LINETEXT + "[ITEM] Show: "
  897. string LINETEXT + XMLVAL
  898. elif ACTIONID == 44 # removefocusobject
  899. # print "Parse action 44: removefocusobject @ idx %INDEX%"
  900. string LINETEXT + "[ITEM] Hide"
  901. elif ACTIONID == 45 # unlockending
  902. # print "Parse action 45: unlockending @ idx %INDEX%"
  903. string LINETEXT + "[UNLOCK] Ending #"
  904. string LINETEXT + XMLVAL
  905. elif ACTIONID == 46 # unlockrelationship
  906. # print "Parse action 46: unlockrelationship @ idx %INDEX%"
  907. if SLIMTEXT == 0
  908. string LINETEXT + "[UNLOCK] Relationship #"
  909. string LINETEXT + XMLVAL
  910. else
  911. string LINETEXT = ""
  912. endif
  913. elif ACTIONID == 47 # eyeanim
  914. # print "Parse action 47: eyeanim @ idx %INDEX%"
  915. string LINETEXT + ">'"
  916. string LINETEXT + CNAME
  917. string LINETEXT + "' eye animation #"
  918. string LINETEXT + XMLVAL
  919. if XMLVAL < 5
  920. string LINETEXT + ": "
  921. getarray EYEANIMATION 1 XMLVAL
  922. string LINETEXT + EYEANIMATION
  923. endif
  924. # elif ACTIONID == 48 # showingametitle, unused
  925. # print "Parse action 48: showingametitle @ idx %INDEX%"
  926. else # ActionID > 48????
  927. print "[!] Error: action ID %ACTIONID% on line %INDEX% unassigned or out of bounds! Skipping line."
  928. string TEMP P "[!] Unassigned action ID %ACTIONID%."
  929. string LINETEXT + TEMP
  930. endif
  931.  
  932. if LINETEXT != ""
  933. if SLIMTEXT == 0 && AUTONEXT != ""
  934. if AUTONEXT > 9999 && TRANSITION == "FORCE_TRANSITION"
  935. string LINETEXT + " [WAIT for transition finish]"
  936. else
  937. string LINETEXT + " [WAIT "
  938. string LINETEXT + AUTONEXT
  939. string LINETEXT + " seconds]"
  940. endif
  941. endif
  942. putct LINETEXT string -1 MEMORY_FILE2
  943. put CRLF short MEMORY_FILE2
  944. endif
  945. endif
  946.  
  947. next
  948.  
  949.  
  950.  
  951. # ========================================
  952.  
  953. if TO_CSV != 0
  954. set FILENAME string CHAPTER
  955. string FILENAME + ". "
  956. string FILENAME + CHNAME
  957. string FILENAME + ", "
  958. string FILENAME + TITLE
  959. string FILENAME + ".csv"
  960.  
  961. get MLENGTH asize MEMORY_FILE
  962. log FILENAME 0 MLENGTH MEMORY_FILE
  963. endif
  964.  
  965. if TO_TEXT != 0
  966. set FILENAME string CHAPTER
  967. string FILENAME + ". "
  968. string FILENAME + CHNAME
  969. if SLIMTEXT != 0
  970. string FILENAME + "_s"
  971. endif
  972. string FILENAME + ".txt"
  973.  
  974. get MLENGTH asize MEMORY_FILE2
  975. log FILENAME 0 MLENGTH MEMORY_FILE2
  976. endif
  977.  
  978. CleanExit
  979.  
  980. # function to replace XML escape characters in TEMP string
  981. startfunction CLEAN_XML_STR
  982. string TEMP - CR # remove carriage returns
  983. string TEMP - LF # remove line feeds
  984. string TEMP replace "&lt;" "<"
  985. string TEMP replace "&gt;" ">"
  986. string TEMP replace "&amp;" "&"
  987. string TEMP replace "&quot;" "''" # use double apostrophe to not mess up csv text
  988. string TEMP replace "&apos;" "'"
  989. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement