Advertisement
ZoriaRPG

2.55 New Script Types: Test Scripts

Dec 23rd, 2018
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.51 KB | None | 0 0
  1. import "std.zh"
  2.  
  3. dmapdata script dmapscript
  4. {
  5.     void run()
  6.     {
  7.         int f;
  8.         while(1)
  9.         {
  10.             ++f;
  11.             if (!(f%180))
  12.             {
  13.                 TraceS("Dmap Script Before Waitdraw()"); TraceNL();
  14.                
  15.             }
  16.             Waitdraw();
  17.             if (!(f%180))
  18.             {
  19.                 TraceS("Dmap Script After Waitdraw()"); TraceNL();
  20.                
  21.             }
  22.             Waitframe();
  23.         }
  24.  
  25.     }
  26. }
  27.  
  28. screendata script sd1
  29. {
  30. void run(){}
  31. }
  32.  
  33. link script link_init1
  34. {
  35.     void run()
  36.     {
  37.         TraceS("Running Link Init Script"); TraceNL();
  38.         Link->X = 100;
  39.         Link->Y = 60;
  40.     }
  41. }
  42.  
  43. link script link_active
  44. {
  45.     void run()
  46.     {
  47.         while(1)
  48.         {
  49.             //TraceS("Link Active Script Running"); TraceNL();
  50.             if ( Input->ReadKey[KEY_T] ) { ++Link->X; }
  51.             Waitframe();
  52.         }
  53.     }
  54. }
  55.  
  56. npc script noanim
  57. {
  58.     void run()
  59.     {
  60.         Trace(this->Animation);
  61.         this->Animation = false;
  62.         TraceB(this->Animation);
  63.         this->Tile = 11728;
  64.     }
  65. }
  66.  
  67. eweapon script E2
  68. {
  69.     void run(){}
  70. }
  71.  
  72. eweapon script E
  73. {
  74.     void run(int pow)
  75.     {
  76.         //TraceS("eweapon script E: this: "); Trace(this); TraceNL();
  77.         TraceS("InitD[0] is: "); Trace(pow); TraceNL();
  78.         int f;
  79.         Trace(this->ID);
  80.         while(this->isValid())
  81.         {
  82. TraceS("EWeapon Script Running"); TraceNL();
  83.             ++f;
  84.             if ( !(f%10) )
  85.             {
  86.                 this->Dir = Rand(0,3);
  87.                 TraceS("EWeapon Script Running"); TraceNL();
  88.             }
  89.             if ( !(this->isValid()) ) Quit();
  90.             Waitframe();
  91.        
  92.         }
  93.     }
  94. }
  95.  
  96. lweapon script L
  97. {
  98.     void run()
  99.     {
  100.         TraceS("Script L: this: "); Trace(this); TraceNL();
  101.         int f = 0;
  102.         while(this->isValid())
  103.         {
  104.              
  105.             ++f;
  106.             if ( !(f%10) )
  107.             {
  108.                 this->Dir = Rand(0,3);
  109.                 TraceS("LWeapon Script Running"); TraceNL();
  110.             }
  111.             if ( !(this->isValid()) ) Quit();
  112.             Waitframe();
  113.        
  114.         }
  115.     }
  116. }
  117.  
  118. lweapon script sword
  119. {
  120.     void run()
  121.     {
  122.         TraceS("Script sword: this: "); Trace(this); TraceNL();
  123.         Trace(this->ID);
  124.         while(this->isValid())
  125.         {
  126.             //this->X += 10;
  127.             TraceS("LWeapon Script Running"); TraceNL();
  128.             Waitframe();
  129.         }
  130.     }
  131. }
  132.  
  133. lweapon script beam
  134. {
  135.     void run()
  136.     {
  137.         //TraceS("Script beam: this: "); Trace(this); TraceNL();
  138.         int f;
  139.         Trace(this->ID);
  140.         while(this->isValid())
  141.         {
  142.             ++f;
  143.             if ( !(f%10) )
  144.             {
  145.                 this->Dir = Rand(0,3);
  146.                 //TraceS("LWeapon Script Running"); TraceNL();
  147.             }
  148.             if ( !(this->isValid()) ) Quit();
  149.             Waitframe();
  150.        
  151.         }
  152.     }
  153. }
  154.  
  155. lweapon script bait
  156. {
  157.     void run(int pow)
  158.     {
  159.         TraceS("Script bait: this: "); Trace(this); TraceNL();
  160.         TraceS("Bait InitD[0] is: "); Trace(pow); TraceNL();
  161.         int f = 0; int dir = Rand(0,3); int step = 2;
  162.         while(this->isValid())
  163.         {
  164.             ++f; if (!(f%6)) { dir = Rand(0,3); step = Rand(2,6); }
  165.             switch(dir)
  166.             {
  167.                 case DIR_UP: this->Y -= step; break;
  168.                 case DIR_DOWN: this->Y += step; break;
  169.                 case DIR_LEFT: this->X -= step; break;
  170.                 case DIR_RIGHT: this->X += step; break;
  171.                 default: break;
  172.             }
  173.             if ( !(this->isValid()) ) Quit();
  174.             Waitframe();
  175.         }
  176.     }
  177. }      
  178.  
  179. global script ab
  180. {
  181.     void run()
  182.     {
  183.        
  184.         dmapdata dd = Game->LoadDMapData(0);
  185.         int mp = dd->Map;
  186.         mapdata md = Game->LoadMapData(mp, 0);
  187.         while(1)
  188.         {
  189.             for ( int q = Screen->NumLWeapons(); q > 0; --q )
  190.             {
  191.                 lweapon l = Screen->LoadLWeapon(q);
  192.                 if ( l->ID == LW_SCRIPT1 )
  193.                 {
  194.                     //TraceS("Found LW_SCRIPT1"); TraceNL();
  195.                 }
  196.             }
  197.             if ( Input->ReadKey[KEY_Y] )
  198.             {
  199.                
  200.                 for ( int q = 0; q < 176; ++q )
  201.                 {
  202.                     LogPrint("Mapdata->ComboD[%d] is: %d \n", q, md->ComboD[q]);
  203.                     LogPrint("Mapdata->ComboT[%d] is: %d \n", q, md->ComboT[q]);
  204.                     LogPrint("Mapdata->ComboC[%d] is: %d \n", q, md->ComboC[q]);
  205.                     LogPrint("Mapdata->ComboS[%d] is: %d \n", q, md->ComboS[q]);
  206.                     LogPrint("Mapdata->ComboF[%d] is: %d \n", q, md->ComboF[q]);
  207.                     LogPrint("Mapdata->ComboI[%d] is: %d \n", q, md->ComboI[q]);
  208.                 }
  209.             }
  210.             if ( Input->ReadKey[KEY_I] )
  211.             {
  212.                 LogPrint("Getting mapdata combo information with GetCurScreen()%s \n", " ");
  213.                 mapdata mdm = Game->LoadMapData(mp, Game->GetCurScreen());
  214.                 for ( int q = 0; q < 176; ++q )
  215.                 {
  216.                     LogPrint("Mapdata->ComboD[ %d ] is: %d \n", q, mdm->ComboD[q]);
  217.                     LogPrint("Mapdata->ComboT[ %d ] is: %d \n", q, mdm->ComboT[q]);
  218.                     LogPrint("Mapdata->ComboC[ %d ] is: %d \n", q, mdm->ComboC[q]);
  219.                     LogPrint("Mapdata->ComboS[ %d ] is: %d \n", q, mdm->ComboS[q]);
  220.                     LogPrint("Mapdata->ComboF[ %d ] is: %d \n", q, mdm->ComboF[q]);
  221.                     LogPrint("Mapdata->ComboI[ %d ] is: %d \n", q, mdm->ComboI[q]);
  222.                 }
  223.             }
  224.             if ( Input->ReadKey[KEY_U] )
  225.             {
  226.                 md->ComboD[0] = 100;
  227.                 md->ComboF[0] = 15;
  228.                 md->ComboT[0] = 2;
  229.             }
  230.             Waitframe();
  231.         }
  232.     }
  233. }
  234.  
  235. lweapon script readcombos
  236. {
  237.     void run()
  238.     {
  239.        
  240.         dmapdata dd = Game->LoadDMapData(0);
  241.         int mp = dd->Map;
  242.         mapdata md = Game->LoadMapData(mp, 0);
  243.         while(this->isValid())
  244.         {
  245.            
  246.             if ( Input->ReadKey[KEY_Y] )
  247.             {
  248.                
  249.                 for ( int q = 0; q < 176; ++q )
  250.                 {
  251.                     LogPrint("Mapdata->ComboD[%d] is: %d \n", q, md->ComboD[q]);
  252.                     LogPrint("Mapdata->ComboT[%d] is: %d \n", q, md->ComboT[q]);
  253.                     LogPrint("Mapdata->ComboC[%d] is: %d \n", q, md->ComboC[q]);
  254.                     LogPrint("Mapdata->ComboS[%d] is: %d \n", q, md->ComboS[q]);
  255.                     LogPrint("Mapdata->ComboF[%d] is: %d \n", q, md->ComboF[q]);
  256.                     LogPrint("Mapdata->ComboI[%d] is: %d \n", q, md->ComboI[q]);
  257.                 }
  258.             }
  259.             if ( Input->ReadKey[KEY_I] )
  260.             {
  261.                 LogPrint("Getting mapdata combo information with GetCurScreen()%s \n", " ");
  262.                 mapdata mdm = Game->LoadMapData(mp, Game->GetCurScreen());
  263.                 for ( int q = 0; q < 176; ++q )
  264.                 {
  265.                     LogPrint("Mapdata->ComboD[ %d ] is: %d \n", q, mdm->ComboD[q]);
  266.                     LogPrint("Mapdata->ComboT[ %d ] is: %d \n", q, mdm->ComboT[q]);
  267.                     LogPrint("Mapdata->ComboC[ %d ] is: %d \n", q, mdm->ComboC[q]);
  268.                     LogPrint("Mapdata->ComboS[ %d ] is: %d \n", q, mdm->ComboS[q]);
  269.                     LogPrint("Mapdata->ComboF[ %d ] is: %d \n", q, mdm->ComboF[q]);
  270.                     LogPrint("Mapdata->ComboI[ %d ] is: %d \n", q, mdm->ComboI[q]);
  271.                 }
  272.             }
  273.             if ( Input->ReadKey[KEY_U] )
  274.             {
  275.                 md->ComboD[0] = 100;
  276.                 md->ComboF[0] = 15;
  277.                 md->ComboT[0] = 2;
  278.             }
  279.             Waitframe();
  280.         }
  281.     }
  282. }
  283.  
  284.  
  285. lweapon script comboat
  286. {
  287.     void run()
  288.     {
  289.         while(this->isValid())
  290.         {
  291.             mapdata mps = Game->LoadMapData(Game->GetCurMap(), Game->GetCurScreen());
  292.             LogPrint("Mapdata->ComboD[] at this lweapon location is: %d \n", mps->ComboD[ComboAt(this->X, this->Y)]);
  293.             Waitframe();
  294.         }
  295.     }
  296. }
  297.  
  298.  
  299. link script onWin
  300. {
  301.     void run()
  302.     {
  303.         int q;
  304.         while(1)
  305.         {
  306.             ++q;
  307.             Trace(q);
  308.             if ( q > 100 ) Quit();
  309.             Waitframe();
  310.         }
  311.     }
  312. }
  313.  
  314. ///////////////////////////////////////
  315. /// Custom Game Over and F6 Screens ///
  316. /// v1.4 for ZC 2.55                ///
  317. /// 24th October, 2018              ///
  318. /// By: ZoriaRPG                    ///
  319. ///////////////////////////////////////
  320.  
  321. //v1.4 : Added CONTINUE option to both screens. The user can enable or disable this.
  322.  
  323. typedef const int define;
  324. typedef const int config;
  325.  
  326. define ON = 1;
  327. define OFF = 0;
  328. define YES = 1;
  329. define NO = 0;
  330.  
  331. script typedef ffc namespace;
  332.  
  333. namespace script F6
  334. {
  335. define SELECTION_SAVE = 1;
  336. define SELECTION_RETRY = 2;
  337. define SELECTION_CANCEL = 3;
  338. define SELECTION_CONTINUE = 4;
  339. define CONTINUE_HP = 16*3;
  340. define CONTINUE_MP = 32*3;
  341.  
  342. config ALLOW_F6_CONTINUE = YES;
  343.    
  344. config F6MIDI = -3;
  345.    
  346.     void run(){}
  347.     const int FREEZE = 504; //Freeze Combo
  348.     void freeze(int state)
  349.     {
  350.         ffc f = Screen->LoadFFC(32);
  351.         if ( state ) f->Data = FREEZE;
  352.         else f->Data = 0;
  353.     }
  354.        
  355.     //if ( F6.press() ) { F6.optiona(); }
  356.     bool press()
  357.     {
  358.         TraceS("User pressed F6"); TraceNL();
  359.         if ( Input->ReadKey[46+6] ) return true;
  360.         return false;
  361.     }
  362.     void draw(bool ALLOW_F6_CONTINUE)
  363.     {
  364.         gameover.draw(true, ALLOW_F6_CONTINUE);
  365.     }
  366.     int choice(bool ALLOW_F6_CONTINUE)
  367.     {
  368.         return gameover.get_choice(ALLOW_F6_CONTINUE);
  369.     }
  370.    
  371.     void options()
  372.     {
  373.         Game->DisableActiveSubscreen = true;
  374.         freeze(ON);
  375.         int oldmidi = Game->GetMIDI();
  376.         Game->PlayMIDI(F6MIDI);
  377.         while(menu(CONTINUE_HP, YES, CONTINUE_MP, YES))
  378.         {
  379.             draw(true);
  380.             Waitdraw();
  381.             Waitframe();
  382.         }
  383.         Game->PlayMIDI(oldmidi);
  384.         freeze(OFF);
  385.        
  386.         Link->PressStart = false; Link->InputStart = false;
  387.        
  388.     }
  389.     //for HP, 0 will preserve Link's HP before continuing. For MAGIC, use -1 to do this.
  390.     bool menu(int cont_hp, bool hp_is_percent, int cont_mp, bool mp_is_percent)
  391.     {
  392.         int sel = choice(true);
  393.         switch(sel)
  394.         {
  395.             case SELECTION_SAVE:
  396.             {
  397.                 Game->Save(); return false;
  398.             }
  399.             case SELECTION_RETRY:
  400.             {
  401.                 freeze(OFF);
  402.                 Game->End(); return false;
  403.             }
  404.             case SELECTION_CONTINUE:
  405.             {
  406.                 freeze(OFF);
  407.                 return do_continue(cont_hp, hp_is_percent, cont_mp, mp_is_percent);
  408.             }
  409.             case SELECTION_CANCEL:
  410.             {
  411.                 return false;
  412.             }
  413.         }
  414.         return true;
  415.     }
  416.     bool do_continue(int hp, bool hp_percent, int mp, bool mp_percent)
  417.     {
  418.         //int entrancedmap = Game->LastEntranceDMap;
  419.         //Replace with WarpEx()
  420.         //Link->Warp(Game->GetCurDMap(), Game->DMapContinue[Game->GetCurDMap()]);
  421.         Link->Warp(Game->LastEntranceDMap, Game->LastEntranceScreen);
  422.         if ( hp > 0 ) Link->HP = ( Cond(hp_percent, Link->MaxHP*(hp/100), hp) );
  423.         if ( mp > -1 ) Link->MP = ( Cond(mp_percent, Link->MaxMP*(mp/100), hp) );
  424.         Link->Dir = DIR_DOWN;
  425.         Link->Action = LA_NONE;
  426.         return false;
  427.     }
  428.    
  429. }
  430.  
  431. namespace script gameover
  432. {
  433.  
  434. config ALLOW_DEATH_CONTINUE = YES;
  435.  
  436.     // Sounds and MIDIs
  437. config SFX_WINKOUT          = 38; //Sound to play during wink-out animation.
  438. config SFX_LINKDEATH            = 28; //Sound to play when Link dies.
  439. config SFX_GAMEOVERSCREEN_CURSOR    = 6;  //Sound to play when the player moves the game over cursor.
  440. config SFX_GAMEOVERSCREEN_SELECTION     = 44; //Sound to play when the user selects a game over menu option.
  441. config MIDI_GAMEOVER            = -4; //MIDI to play on Game Over screen.
  442.     //Defaults: -3 is the internal Game Over, -2 is Level 9, -1 is Overworld
  443.  
  444. // Sprites (Weapons/Misc)
  445. config SPR_DEATH        = 88; //Sprite of Link Spinning
  446. config SPR_DEATH_WINKOUT    = 89; //Sprite of wink-out
  447. // Sprite Timing
  448. config END_DEATH_SPIN       = 40; //Frames to display death spin animation.
  449. config END_WINKOUT      = 10; //Frames to display wink-out animation.
  450.  
  451. // Other Graphics and Colours
  452. config TILE_SAVECURSOR      = 20;
  453. config TILE_SAVECURSOR_CSET     = 1;    //CSet for minitile cursor.
  454. config BLACK            = 0x0F; //Black in the current palette
  455. config RED          = 0x93; //Red in the current palette
  456. config WHITE            = 0x01; //White in the current palette
  457.  
  458. // Menu Object Positions and Settings
  459. config DONT_SAVE_X      = 102; //X position of the RETRY string.
  460. config SAVE_X           = 102; //X position of the SAVE string.
  461. config DONT_SAVE_Y      = 68;  //Y position of the RETRY string.
  462. config CANCEL_Y         = 68+14;  //Y position of the CANCEL string.
  463. config CONTINUE_Y       = 68+28;  //Y position of the CONTINUE string.
  464. config SAVE_Y           = 54;  //X position of the SAVE string.
  465. config CURSOR_OFFSET        = 26;  //X offset of the cursor from the text.
  466.  
  467. //Global Variables and Arrays
  468.  
  469. //Indices for values[]
  470. define MENU_SEL_STATE       = 0; //The current selected menu option.
  471. define MENU_SEL_POS_X       = 1; //Stores where to draw menu selector.
  472. define MENU_SEL_POS_Y       = 2; //Stores where to draw menu selector.
  473. define DEATH_LX         = 3; //Cache of Link's last X position before death.
  474. define DEATH_LY         = 4; //Cache of Link's last Y position before death.
  475. define DEATHFRAME       = 5; //Timer for death animations.
  476. define QUIT             = 6; //The game 'QUIT' type, SAVE or RETRY
  477.  
  478. //gameover.QUIT Types
  479. define quitSAVE         = 1;
  480. define quitRETRY        = 2;
  481. define quitCONTINUE         = 4;
  482.  
  483. //Menu Selection types
  484. define SELECTION_SAVE       = 1;
  485. define SELECTION_RETRY      = 2;
  486. define SELECTION_CANCEL     = 3;
  487. define SELECTION_CONTINUE   = 4;
  488.  
  489.     int values[8] = {1,SAVE_Y,DONT_SAVE_Y, 0,0};
  490.     void run(){}
  491.     bool check()
  492.     {
  493.         if ( Link->HP < 1 )
  494.         {
  495.             Link->HP = 1;
  496.             Link->Invisible = true;
  497.             Link->CollDetection = false;
  498.             values[DEATH_LX] = Link->X;
  499.             values[DEATH_LY] = Link->Y;
  500.             return true;
  501.         }
  502.         return false;
  503.     }
  504.     void clean_up()
  505.     {
  506.         int q;
  507.         if ( Screen->NumNPCs() )
  508.         {
  509.             for ( q = Screen->NumNPCs(); q > 0; --q )
  510.             {
  511.                 npc n = Screen->LoadNPC(q); Remove(n);
  512.             }
  513.         }
  514.         if ( Screen->NumLWeapons() )
  515.         {
  516.             for ( q = Screen->NumLWeapons(); q > 0; --q )
  517.             { lweapon n = Screen->LoadLWeapon(q); Remove(n); }
  518.         }
  519.         if ( Screen->NumEWeapons() )
  520.         {
  521.             for ( q = Screen->NumEWeapons(); q > 0; --q )
  522.             { eweapon n = Screen->LoadEWeapon(q); Remove(n); }
  523.         }
  524.         if ( Screen->NumItems() )
  525.         {
  526.             for ( q = Screen->NumItems(); q > 0; --q )
  527.             { item n = Screen->LoadItem(q); Remove(n); }
  528.         }
  529.         //clear all ffcs
  530.         for ( q = 1; q < 33; ++q )
  531.         {
  532.             ffc f = Screen->LoadFFC(q);
  533.             f->Data = 0; f->Script = 0;
  534.         }
  535.     }
  536.     void draw(bool cancel, bool can_continue)
  537.     {
  538.         //Draw black background with Rectangle()
  539.         Screen->Rectangle(5,0,0,256,256,BLACK,100, 0,0,0,true,128);
  540.         if ( !cancel )
  541.         {
  542.             if ( !can_continue )
  543.             {
  544.                 switch ( values[MENU_SEL_STATE] )
  545.                 {
  546.                     case SELECTION_SAVE:
  547.                     {
  548.                         //int ss1[]="Drawing cursor and text.";
  549.                         //TraceS(ss1);
  550.                         Screen->FastTile(6,SAVE_X-CURSOR_OFFSET, SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  551.                         //draw strings, red for selected
  552.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,RED, -1,0,"SAVE",128);
  553.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"RETRY",128);
  554.                         break;
  555.                     }
  556.                     case SELECTION_RETRY:
  557.                     {
  558.                         //Draw cursor
  559.                         Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, DONT_SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  560.                         //draw strings, red for selected
  561.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,WHITE, -1,0,"SAVE",128);
  562.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,RED, -1,0,"RETRY",128);
  563.                         break;
  564.                     }
  565.                     default: break;
  566.                 }
  567.             }
  568.             else
  569.             {
  570.                 switch ( values[MENU_SEL_STATE] )
  571.                 {
  572.                     case SELECTION_SAVE:
  573.                     {
  574.                         //int ss1[]="Drawing cursor and text.";
  575.                         //TraceS(ss1);
  576.                         Screen->FastTile(6,SAVE_X-CURSOR_OFFSET, SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  577.                         //draw strings, red for selected
  578.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,RED, -1,0,"SAVE",128);
  579.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"CONTINUE",128);
  580.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,WHITE, -1,0,"RETRY",128);
  581.                         break;
  582.                     }
  583.                     case SELECTION_CONTINUE:
  584.                     {
  585.                         //int ss1[]="Drawing cursor and text.";
  586.                         //TraceS(ss1);
  587.                         Screen->FastTile(6,SAVE_X-CURSOR_OFFSET, DONT_SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  588.                         //draw strings, red for selected
  589.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,RED, -1,0,"SAVE",128);
  590.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"CONTINUE",128);
  591.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,WHITE, -1,0,"RETRY",128);
  592.                         break;
  593.                     }
  594.                     case SELECTION_RETRY:
  595.                     {
  596.                         //Draw cursor
  597.                         Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, CANCEL_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  598.                         //draw strings, red for selected
  599.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,WHITE, -1,0,"SAVE",128);
  600.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"CONTINUE",128);
  601.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,RED, -1,0,"RETRY",128);
  602.                         break;
  603.                     }
  604.                     default: break;
  605.                 }
  606.            
  607.            
  608.            
  609.             }
  610.         }
  611.         else
  612.         {
  613.             if ( !can_continue )
  614.             {
  615.                 switch(values[MENU_SEL_STATE])
  616.                 {
  617.                    
  618.                    
  619.                     case SELECTION_SAVE:
  620.                     {
  621.                         //int ss1[]="Drawing cursor and text.";
  622.                         //TraceS(ss1);
  623.                         Screen->FastTile(6,SAVE_X-CURSOR_OFFSET, SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  624.                         //draw strings, red for selected
  625.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,RED, -1,0,"SAVE",128);
  626.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"RETRY",128);
  627.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,WHITE, -1,0,"CANCEL",128);
  628.                         break;
  629.                     }
  630.                     case SELECTION_RETRY:
  631.                     {
  632.                         //Draw cursor
  633.                         Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, DONT_SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  634.                         //draw strings, red for selected
  635.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,WHITE, -1,0,"SAVE",128);
  636.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,RED, -1,0,"RETRY",128);
  637.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,WHITE, -1,0,"CANCEL",128);
  638.                         break;
  639.                     }
  640.                     case SELECTION_CANCEL:
  641.                     {
  642.                         //Draw cursor
  643.                         Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, CANCEL_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  644.                         //draw strings, red for selected
  645.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,WHITE, -1,0,"SAVE",128);
  646.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"RETRY",128);
  647.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,RED, -1,0,"CANCEL",128);
  648.                         break;
  649.                     }
  650.                     default: break;
  651.                    
  652.                 }
  653.             }
  654.             else //allow F6 continue
  655.             {
  656.                 switch(values[MENU_SEL_STATE])
  657.                 {
  658.                    
  659.                     //I'm reusing the positional defines for cancel and continue, and transposing them
  660.                     //to reorder the list. -Z
  661.                    
  662.                     //I should rename these to LIST_1_Y, LIST_2_Y, and so forth.
  663.                     case SELECTION_SAVE:
  664.                     {
  665.                         //int ss1[]="Drawing cursor and text.";
  666.                         //TraceS(ss1);
  667.                         Screen->FastTile(6,SAVE_X-CURSOR_OFFSET, SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  668.                         //draw strings, red for selected
  669.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,RED, -1,0,"SAVE",128);
  670.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"RETRY",128);
  671.                         Screen->DrawString(6,DONT_SAVE_X,CONTINUE_Y,0,WHITE, -1,0,"CANCEL",128);
  672.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,WHITE, -1,0,"CONTINUE",128);
  673.                         break;
  674.                     }
  675.                     case SELECTION_RETRY:
  676.                     {
  677.                         //Draw cursor
  678.                         Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, DONT_SAVE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  679.                         //draw strings, red for selected
  680.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,WHITE, -1,0,"SAVE",128);
  681.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,RED, -1,0,"RETRY",128);
  682.                         Screen->DrawString(6,DONT_SAVE_X,CONTINUE_Y,0,WHITE, -1,0,"CANCEL",128);
  683.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,WHITE, -1,0,"CONTINUE",128);
  684.                         break;
  685.                     }
  686.                     case SELECTION_CANCEL:
  687.                     {
  688.                         //Draw cursor
  689.                         Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, CANCEL_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  690.                         //draw strings, red for selected
  691.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,WHITE, -1,0,"SAVE",128);
  692.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"RETRY",128);
  693.                         Screen->DrawString(6,DONT_SAVE_X,CONTINUE_Y,0,RED, -1,0,"CANCEL",128);
  694.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,WHITE, -1,0,"CONTINUE",128);
  695.                         break;
  696.                     }
  697.                     case SELECTION_CONTINUE:
  698.                     {
  699.                         //Draw cursor
  700.                         Screen->FastTile(6,DONT_SAVE_X-CURSOR_OFFSET, CONTINUE_Y, TILE_SAVECURSOR, TILE_SAVECURSOR_CSET,128);
  701.                         //draw strings, red for selected
  702.                         Screen->DrawString(6,SAVE_X,SAVE_Y,0,WHITE, -1,0,"SAVE",128);
  703.                         Screen->DrawString(6,DONT_SAVE_X,DONT_SAVE_Y,0,WHITE, -1,0,"RETRY",128);
  704.                         Screen->DrawString(6,DONT_SAVE_X,CONTINUE_Y,0,WHITE, -1,0,"CANCEL",128);
  705.                         Screen->DrawString(6,DONT_SAVE_X,CANCEL_Y,0,RED, -1,0,"CONTINUE",128);
  706.                         break;
  707.                     }
  708.                     default: break;
  709.                    
  710.                 }
  711.             }
  712.            
  713.         }
  714.     }
  715.     bool choice(bool can_continue)
  716.     {
  717.         if ( !can_continue )
  718.         {
  719.             if ( Link->PressDown ) // || Link->PressUp )
  720.             {
  721.                 switch(values[MENU_SEL_STATE])
  722.                 {
  723.                     case SELECTION_SAVE: //save
  724.                         ++values[MENU_SEL_STATE]; break;
  725.                     case SELECTION_RETRY: //retry
  726.                         --values[MENU_SEL_STATE]; break;
  727.                 }
  728.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  729.                 return true;
  730.             }
  731.             if ( Link->PressUp )
  732.             {
  733.                 switch(values[MENU_SEL_STATE])
  734.                 {
  735.                     case SELECTION_SAVE: //save
  736.                         --values[MENU_SEL_STATE]; return true;;
  737.                     case SELECTION_RETRY: //retry
  738.                         ++values[MENU_SEL_STATE]; return true;;
  739.                 }
  740.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  741.                 return true;
  742.             }
  743.         }
  744.         else //save, continue, retry
  745.         {
  746.             if ( Link->PressDown ) // || Link->PressUp )
  747.             {
  748.                 switch(values[MENU_SEL_STATE])
  749.                 {
  750.                     case SELECTION_SAVE: //save
  751.                         values[MENU_SEL_STATE] = SELECTION_CONTINUE; break;
  752.                     case SELECTION_CONTINUE: //save
  753.                         values[MENU_SEL_STATE] = SELECTION_RETRY; break;
  754.                     case SELECTION_RETRY: //retry
  755.                         values[MENU_SEL_STATE] = SELECTION_SAVE; break;
  756.                 }
  757.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  758.                 return true;
  759.             }
  760.             if ( Link->PressUp )
  761.             {
  762.                 switch(values[MENU_SEL_STATE])
  763.                 {
  764.                     case SELECTION_SAVE: //save
  765.                         values[MENU_SEL_STATE] = SELECTION_RETRY; break;
  766.                     case SELECTION_CONTINUE: //save
  767.                         values[MENU_SEL_STATE] = SELECTION_SAVE; break;
  768.                     case SELECTION_RETRY: //retry
  769.                         values[MENU_SEL_STATE] = SELECTION_CONTINUE; break;
  770.                 }
  771.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  772.                 return true;
  773.             }
  774.         }
  775.         if ( Link->PressStart )
  776.         {
  777.             Game->PlaySound(SFX_GAMEOVERSCREEN_SELECTION);
  778.             if ( values[MENU_SEL_STATE] ) values[QUIT] = quitSAVE;
  779.             else values[QUIT] = quitRETRY; //no save
  780.             return false;
  781.         }
  782.         return true;
  783.     }
  784.    
  785.    
  786.     int get_choice(bool can_continue)
  787.     {
  788.         if ( !can_continue )
  789.         {
  790.             if ( Link->PressDown )
  791.             {
  792.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  793.                 switch(values[MENU_SEL_STATE])
  794.                 {
  795.                     case SELECTION_SAVE: //save
  796.                         ++values[MENU_SEL_STATE]; break;
  797.                     case SELECTION_RETRY: //retry
  798.                         ++values[MENU_SEL_STATE]; break;
  799.                     case SELECTION_CANCEL: //3
  800.                         values[MENU_SEL_STATE] = 1; break;
  801.                     default: //cance;
  802.                         values[MENU_SEL_STATE] = 0; break;
  803.                 }
  804.             }
  805.             if ( Link->PressUp )
  806.             {
  807.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  808.                 switch(values[MENU_SEL_STATE])
  809.                 {
  810.                     case 1: //save
  811.                         values[MENU_SEL_STATE] = 3; break;
  812.                     case 2: //retry
  813.                         --values[MENU_SEL_STATE] ; break;
  814.                     case SELECTION_CANCEL: //3
  815.                         --values[MENU_SEL_STATE] ; break;
  816.                     default: //cance;
  817.                         values[MENU_SEL_STATE] = 0; break;
  818.                 }
  819.             }      
  820.         }
  821.         else //allow continue
  822.         {
  823.             if ( Link->PressDown )
  824.             {
  825.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  826.                 switch(values[MENU_SEL_STATE])
  827.                 {
  828.                     case SELECTION_SAVE: //save
  829.                         ++values[MENU_SEL_STATE]; break;
  830.                     case SELECTION_RETRY: //retry
  831.                         ++values[MENU_SEL_STATE]; break;
  832.                     case SELECTION_CANCEL: //3
  833.                         ++values[MENU_SEL_STATE] = 1; break;
  834.                     case SELECTION_CONTINUE: //3
  835.                         values[MENU_SEL_STATE] = 1; break;
  836.                     default: //cance;
  837.                         values[MENU_SEL_STATE] = 0; break;
  838.                 }
  839.             }
  840.             if ( Link->PressUp )
  841.             {
  842.                 Game->PlaySound(SFX_GAMEOVERSCREEN_CURSOR);
  843.                 switch(values[MENU_SEL_STATE])
  844.                 {
  845.                     case 1: //save
  846.                         values[MENU_SEL_STATE] = 4; break;
  847.                     case 2: //retry
  848.                         --values[MENU_SEL_STATE]; break;
  849.                     case SELECTION_CANCEL: //3
  850.                         --values[MENU_SEL_STATE]; break;
  851.                     case SELECTION_CONTINUE: //3
  852.                         --values[MENU_SEL_STATE]; break;
  853.                     default: //cance;
  854.                         values[MENU_SEL_STATE] = 0; break;
  855.                 }
  856.             }  
  857.         }
  858.         if ( Link->PressStart )
  859.         {
  860.             Game->PlaySound(SFX_GAMEOVERSCREEN_SELECTION);
  861.             int ret = values[MENU_SEL_STATE];
  862.             values[MENU_SEL_STATE] = 1;
  863.             return ret;
  864.         }
  865.     }
  866.     void animation()
  867.     {
  868.     if ( values[DEATHFRAME] == 0 ) Game->PlaySound(SFX_LINKDEATH);
  869.         lweapon death = Screen->CreateLWeapon(LW_SPARKLE);
  870.        
  871.         death->UseSprite(SPR_DEATH);
  872.         death->X = values[DEATH_LX];
  873.         death->Y = values[DEATH_LY];
  874.  
  875.         while ( values[DEATHFRAME] < END_DEATH_SPIN )
  876.         {
  877.             ++values[DEATHFRAME];
  878.             //spin Link around by drawing his tiles, then make the wink out.
  879.             NoAction(); Waitdraw(); Waitframe();
  880.         }
  881.         Remove(death);
  882.         Game->PlaySound(SFX_WINKOUT);
  883.         lweapon death2 = Screen->CreateLWeapon(LW_SPARKLE);
  884.         death2->UseSprite(SPR_DEATH_WINKOUT);
  885.         death2->X = values[DEATH_LX];
  886.         death2->Y = values[DEATH_LY];
  887.         while ( values[DEATHFRAME] < END_DEATH_SPIN+END_WINKOUT )
  888.         {
  889.             ++values[DEATHFRAME];
  890.             //wink-out
  891.             NoAction();  Waitdraw(); Waitframe();
  892.         }
  893.         Remove(death2);
  894.     }
  895. }
  896.  
  897.  
  898. //Global Active Script
  899. link script noF6
  900. {
  901.     void run()
  902.     {
  903.         while(true)
  904.         {
  905.             //Normal pre-waitdraw functions go here.
  906.        
  907.             //UpdateGhostZH1();
  908.            
  909.             //Put any health refull code above this!
  910.             //Run the check to see if Link is dying...
  911.             if ( F6.press() ) { Game->DisableActiveSubscreen = false; F6.options(); }
  912.             if ( gameover.check() ) break; //LAST before Waitdraw()
  913.             Waitdraw();
  914.            
  915.             //Normal post-waitdraw functions go here.
  916.            
  917.             //UpdateGhostZH2();
  918.            
  919.             Waitframe();
  920.         }
  921.         while(!gameover.values[gameover.QUIT])
  922.         {
  923.             //gameover.values[gameover.DEATH_LX] = Link->X;
  924.             //gameover.values[gameover.DEATH_LY] = Link->Y;
  925.             //Set game music to a silent MIDI.
  926.  
  927.             Link->HP = Link->MaxHP;
  928.             Link->Invisible = true;
  929.             Link->CollDetection = false;
  930.             //Clean up screen objects
  931.             gameover.clean_up();
  932.             //Do Link Death animation
  933.             gameover.animation();
  934.            
  935.             bool menu = true;
  936.             Game->PlayMIDI(gameover.MIDI_GAMEOVER);//Play game over midi.
  937.             Game->DisableActiveSubscreen = true;   
  938.            
  939.             while(menu) //menu loop
  940.             {
  941.                 //    GAME OVER SCREEN
  942.                 gameover.draw(false,false); //gameover.draw(true, ALLOW_F6_CONTINUE);
  943.                 menu = gameover.choice(gameover.ALLOW_DEATH_CONTINUE);
  944.                 Waitdraw();
  945.                 Waitframe();
  946.             }
  947.             Waitdraw(); Waitframe();
  948.         }
  949.         switch(gameover.values[gameover.QUIT])
  950.         {
  951.             case gameover.quitSAVE:
  952.             {
  953.                 ++Game->NumDeaths;
  954.                 Game->Save();
  955.                 Game->End();
  956.                 break;
  957.             }
  958.             case gameover.quitRETRY:
  959.             {
  960.                 Game->End(); //Retry
  961.                 break;
  962.             }
  963.             case gameover.quitCONTINUE:
  964.             {
  965.                 F6.do_continue(F6.CONTINUE_HP, YES, F6.CONTINUE_MP, YES);
  966.                 break;
  967.             }
  968.             default: break;
  969.         }
  970.     }
  971. }
  972.  
  973. global script OnExit
  974. {
  975.     void run()
  976.     {
  977.         Link->Invisible = false;
  978.     }
  979. }
  980. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement