Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu
- #Title[TTHTest2]
- #Text[Testing for editing CtC TTH files]
- #Player[FREE]
- #ScriptVersion[2]
- script_enemy_main {
- #include_function ".\DATA\TT.dnh" //For InitializePreLoadTTH, plus constants
- #include_function ".\Font.dnh" //For __CreateTexTextCache, AddTexTextHandle, AddTexTextHandleList, plus some constants
- let ImgBoss = "script\img\ExRumia.png"; //default Rumia graphic
- let CSD = GetCurrentScriptDirectory;
- let prefix = CSD ~ "TEST\TTH_";
- let suffix = [ "MENU", "ED", "SPELL", "KOUMA", "EIYA", "KAEI", "LOTUS", "EXPH"];
- let filelist = [];
- ascent(i in 0..length(suffix)){
- filelist = filelist ~ [(prefix ~ suffix[i] ~ ".DAT")];
- }
- let lengthlist = [ 1577, 626, 1057, 795, 792, 792, 789, 621, 0];
- let category = "TEX_TEXT_CACHE";
- let filenum = 0;
- let item = 0;
- let item_str = "0";
- let length_str = "0";
- let frame = 0;
- let DIR_CL_IMAGE_FONT = ".\IMAGE\FONT\";
- let IMAGE_CL_FONT_ASCII = DIR_CL_IMAGE_FONT ~ "Font.png";
- let IMAGE_CL_FONT_SJIS16 = [
- DIR_CL_IMAGE_FONT ~ "sjis16_1.png",
- DIR_CL_IMAGE_FONT ~ "sjis16_2.png",
- DIR_CL_IMAGE_FONT ~ "sjis16_3.png"];
- @Initialize {
- CreateCommonDataArea(CL_CDNS_MESSAGE);
- FontInitialize( IMAGE_CL_FONT_ASCII, IMAGE_CL_FONT_SJIS16);
- //LoadTTC(filenum);
- RefreshStrings();
- SetLife(50000);
- //SetTimer(50);
- SetScore(1000000);
- AddGraze(100);
- SetMovePosition02(GetCenterX, GetCenterY - 100, 120);
- LoadGraphic(ImgBoss); // this loads the boss's graphic
- SetTexture(ImgBoss);
- SetGraphicRect(0, 0, 64, 64); // this sets the dimensions of the boss's graphic
- //NewTask;
- SetRateScoreSystemEnable(false);
- }
- @MainLoop {
- SetCollisionA(GetX, GetY, 32); // this sets the boss's hitbox
- SetCollisionB(GetX, GetY, 16);
- loop(10){
- if(filenum < 8){
- CreateTexText24Cache(suffix[filenum] ~ ToIntString(item));
- RefreshStrings();
- item++;
- if(item >= lengthlist[filenum]){
- item = 0;
- SaveTTC(filenum);
- filenum++;
- if(filenum == 8){
- AddLife(-99999);
- }
- break;
- }
- }
- }
- frame++;
- }
- @DrawLoop {
- /*
- DrawText(a_str,48,48,16,255);
- DrawText(b_str,48,80,16,255);
- DrawText(c_str,48,112,16,255);
- DrawText(count_str,48,144,16,255);*/
- DrawText(filelist[filenum],48,48,16,255);
- DrawText(item_str,48,80,16,255);
- DrawText(length_str,148,80,16,255);
- DrawText(ToIntString(lengthlist[filenum]), 248, 80, 16, 255);
- DrawGraphic(GetX, GetY); // this draws the boss's graphic
- //if(frame>90){DrawTexTextOnCache( item, 0, 0, GetCenterX() - 112, GetClipMaxY() - 16);} // all it does right now is make the boss graphic disappear
- }
- @Finalize {
- DeleteGraphic(ImgBoss); // unloads the boss's graphic
- }
- function RefreshStrings(){
- item_str = ToIntString(item);
- length_str = ToIntString(length(m_aCLTTCValue));
- }
- function ToIntString(let n1){
- let n1_str = ToString(n1);
- loop(7){n1_str = erase(n1_str, length(n1_str)-1);}
- return n1_str;
- }
- // Copied from IO.dnh - CL_CDNS_MESSAGE and CL_CD_TTC are defined in a file that I forgot
- function LoadTTC( let nCDID ){
- InitializePreLoadTTH( nCDID );
- LoadCommonDataEx( CL_CDNS_MESSAGE, filelist[nCDID] );
- ClearTexTextHandle();
- AddTexTextHandleList( GetCommonDataDefaultEx( CL_CDNS_MESSAGE, CL_CD_TTC, [] ) );
- DeleteCommonDataEx( CL_CDNS_MESSAGE, CL_CD_TTC );
- }
- // For writing files. Clears the cache afterward
- function SaveTTC( let nCDID ){
- SetCommonDataEx( CL_CDNS_MESSAGE, CL_CD_TTC, m_aCLTTCValue );
- SaveCommonDataEx( CL_CDNS_MESSAGE, filelist[nCDID] );
- ClearTexTextHandle();
- }
- // given TTC, return string - this is key to reading, but doability is questionable
- function DecodeTexTextCache( let aszImageID, let anSrcX, let anSrcY ){
- let szText = "";
- let i = 0;
- while(i < length( aszImageID)){
- let nGap = 0;
- alternative( anSrcX[ i ] )
- case( CL_FONT_CODE_SPACE ){
- szText = szText ~ " ";
- }
- case( CL_FONT_CODE_CRLF ){
- szText = szText ~ "\n";
- }
- others {
- if( aszImageID[ i ] == -1 ){ // ASCII
- // compute ASCII value
- }
- else { // SJIS
- // compute SJIS value
- }
- }
- }
- // return szText;
- }
- function Max(let n1, let n2){return [n1, n2][n2 > n1];}
- function Min(let n1, let n2){return [n1, n2][n2 < n1];}
- function MinMax(let n, let min, let max){ return Min(Max(n, min), max) }
- function Animation(let n1, let n2, let n3, let n4, let a5) { return (n1+n2)/2; } // dummy function, only used in DrawTexTextOnCacheEx
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement