Advertisement
Guest User

Concealed the Conclusion TTH_*.dat creator proof of concept

a guest
Feb 15th, 2012
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. #TouhouDanmakufu
  2. #Title[TTHTest2]
  3. #Text[Testing for editing CtC TTH files]
  4. #Player[FREE]
  5. #ScriptVersion[2]
  6.  
  7. script_enemy_main {
  8.  
  9. #include_function ".\DATA\TT.dnh" //For InitializePreLoadTTH, plus constants
  10. #include_function ".\Font.dnh" //For __CreateTexTextCache, AddTexTextHandle, AddTexTextHandleList, plus some constants
  11.  
  12. let ImgBoss = "script\img\ExRumia.png"; //default Rumia graphic
  13. let CSD = GetCurrentScriptDirectory;
  14. let prefix = CSD ~ "TEST\TTH_";
  15. let suffix = [ "MENU", "ED", "SPELL", "KOUMA", "EIYA", "KAEI", "LOTUS", "EXPH"];
  16. let filelist = [];
  17. ascent(i in 0..length(suffix)){
  18. filelist = filelist ~ [(prefix ~ suffix[i] ~ ".DAT")];
  19. }
  20. let lengthlist = [ 1577, 626, 1057, 795, 792, 792, 789, 621, 0];
  21. let category = "TEX_TEXT_CACHE";
  22. let filenum = 0;
  23. let item = 0;
  24. let item_str = "0";
  25. let length_str = "0";
  26.  
  27. let frame = 0;
  28.  
  29. let DIR_CL_IMAGE_FONT = ".\IMAGE\FONT\";
  30.  
  31. let IMAGE_CL_FONT_ASCII = DIR_CL_IMAGE_FONT ~ "Font.png";
  32. let IMAGE_CL_FONT_SJIS16 = [
  33. DIR_CL_IMAGE_FONT ~ "sjis16_1.png",
  34. DIR_CL_IMAGE_FONT ~ "sjis16_2.png",
  35. DIR_CL_IMAGE_FONT ~ "sjis16_3.png"];
  36.  
  37. @Initialize {
  38. CreateCommonDataArea(CL_CDNS_MESSAGE);
  39. FontInitialize( IMAGE_CL_FONT_ASCII, IMAGE_CL_FONT_SJIS16);
  40. //LoadTTC(filenum);
  41. RefreshStrings();
  42. SetLife(50000);
  43. //SetTimer(50);
  44. SetScore(1000000);
  45. AddGraze(100);
  46. SetMovePosition02(GetCenterX, GetCenterY - 100, 120);
  47.  
  48. LoadGraphic(ImgBoss); // this loads the boss's graphic
  49. SetTexture(ImgBoss);
  50. SetGraphicRect(0, 0, 64, 64); // this sets the dimensions of the boss's graphic
  51. //NewTask;
  52. SetRateScoreSystemEnable(false);
  53. }
  54.  
  55. @MainLoop {
  56. SetCollisionA(GetX, GetY, 32); // this sets the boss's hitbox
  57. SetCollisionB(GetX, GetY, 16);
  58. loop(10){
  59. if(filenum < 8){
  60. CreateTexText24Cache(suffix[filenum] ~ ToIntString(item));
  61. RefreshStrings();
  62. item++;
  63. if(item >= lengthlist[filenum]){
  64. item = 0;
  65. SaveTTC(filenum);
  66. filenum++;
  67. if(filenum == 8){
  68. AddLife(-99999);
  69. }
  70. break;
  71. }
  72. }
  73. }
  74. frame++;
  75. }
  76.  
  77. @DrawLoop {
  78. /*
  79. DrawText(a_str,48,48,16,255);
  80. DrawText(b_str,48,80,16,255);
  81. DrawText(c_str,48,112,16,255);
  82. DrawText(count_str,48,144,16,255);*/
  83. DrawText(filelist[filenum],48,48,16,255);
  84. DrawText(item_str,48,80,16,255);
  85. DrawText(length_str,148,80,16,255);
  86. DrawText(ToIntString(lengthlist[filenum]), 248, 80, 16, 255);
  87. DrawGraphic(GetX, GetY); // this draws the boss's graphic
  88. //if(frame>90){DrawTexTextOnCache( item, 0, 0, GetCenterX() - 112, GetClipMaxY() - 16);} // all it does right now is make the boss graphic disappear
  89. }
  90.  
  91. @Finalize {
  92. DeleteGraphic(ImgBoss); // unloads the boss's graphic
  93. }
  94.  
  95. function RefreshStrings(){
  96. item_str = ToIntString(item);
  97. length_str = ToIntString(length(m_aCLTTCValue));
  98. }
  99.  
  100. function ToIntString(let n1){
  101. let n1_str = ToString(n1);
  102. loop(7){n1_str = erase(n1_str, length(n1_str)-1);}
  103. return n1_str;
  104. }
  105.  
  106. // Copied from IO.dnh - CL_CDNS_MESSAGE and CL_CD_TTC are defined in a file that I forgot
  107. function LoadTTC( let nCDID ){
  108. InitializePreLoadTTH( nCDID );
  109. LoadCommonDataEx( CL_CDNS_MESSAGE, filelist[nCDID] );
  110. ClearTexTextHandle();
  111. AddTexTextHandleList( GetCommonDataDefaultEx( CL_CDNS_MESSAGE, CL_CD_TTC, [] ) );
  112. DeleteCommonDataEx( CL_CDNS_MESSAGE, CL_CD_TTC );
  113. }
  114.  
  115. // For writing files. Clears the cache afterward
  116. function SaveTTC( let nCDID ){
  117. SetCommonDataEx( CL_CDNS_MESSAGE, CL_CD_TTC, m_aCLTTCValue );
  118. SaveCommonDataEx( CL_CDNS_MESSAGE, filelist[nCDID] );
  119. ClearTexTextHandle();
  120. }
  121.  
  122. // given TTC, return string - this is key to reading, but doability is questionable
  123. function DecodeTexTextCache( let aszImageID, let anSrcX, let anSrcY ){
  124. let szText = "";
  125. let i = 0;
  126. while(i < length( aszImageID)){
  127. let nGap = 0;
  128. alternative( anSrcX[ i ] )
  129. case( CL_FONT_CODE_SPACE ){
  130. szText = szText ~ " ";
  131. }
  132. case( CL_FONT_CODE_CRLF ){
  133. szText = szText ~ "\n";
  134. }
  135. others {
  136. if( aszImageID[ i ] == -1 ){ // ASCII
  137. // compute ASCII value
  138. }
  139. else { // SJIS
  140. // compute SJIS value
  141. }
  142. }
  143. }
  144. // return szText;
  145. }
  146.  
  147. function Max(let n1, let n2){return [n1, n2][n2 > n1];}
  148. function Min(let n1, let n2){return [n1, n2][n2 < n1];}
  149. function MinMax(let n, let min, let max){ return Min(Max(n, min), max) }
  150. function Animation(let n1, let n2, let n3, let n4, let a5) { return (n1+n2)/2; } // dummy function, only used in DrawTexTextOnCacheEx
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement