Advertisement
ZoriaRPG

ZScript: Zelda 3 Style Whistle Warp Selection

Nov 27th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.56 KB | None | 0 0
  1. ///////////////////////////////////
  2. /// Zelda 3 Whistle Warp Screen ///
  3. /// v0.1 - 27-Nov-2016          ///
  4. /// By: ZoriaRPG                ///
  5. ///////////////////////////////////
  6.  
  7. /// place ffcs on a screen, each with D0 set as its ID, D1 its dmap, D2 its screen, D3 its x dest, D4 its y dest
  8.  
  9.  
  10. const int WARP_CURSOR_MOVE_SFX = = 75;
  11. const int WARP_CURSOR_SELECT_SFX = = 76;
  12. const int WARP_CURSOR_SELECT_SFX_DUR = 60;
  13. const int WARP_WHISTLE_WAVY_DUR = 100;
  14.  
  15. ffc script WhistleWarpSelect{
  16.     void run(){
  17.         ffc f[32]; int q[4]; int ff[]="WhistleWarpSelect"; int ffd[]="WhistleWarpDest";
  18.         int fff; int dests[32]; int cursor[256]; int ffcOfFirstDest; int ffcOfLastDest;
  19.         int selection = 1; int last; int coordinates[8];
  20.        
  21.         for ( q[0] = 1; q[0] <= 32; q[0]++ ) {
  22.             //load each ffc into a pointer
  23.             f[ q[0] ] = Screen->LoadFFC(q[0]);
  24.             fff = Game->GetFFCScript(ffd);
  25.             if ( f[ q[0] ]->Script == fff ) { //it is a selection
  26.                 cursor[ q[0] ] = f[ q[0] ]->InitD[0];
  27.                 if ( !ffcOfFirstDest ) ffcOfFirstDest = q[0];
  28.                 ffcOfLastDest = q[0];
  29.                 if ( f[ q[0] ]->InitD[0] > last ) last = f[ q[0] ]->InitD[0]; //Store the highest destination ID for wrapping.
  30.             }
  31.             //if ( f[ q[0] ]->Script != fff ) ffcOfLastDest = last
  32.         }
  33.         //Set the initial position.
  34.         this->X = f[ffcOfFirstDest]->X; this->Y = f[ffcOfFirstDest]->Y;
  35.         Link->Invisible = true; //We need to tie this into IsInvisible()
  36.         Waitframes(2); //Wait for other ffcs to set their values.
  37.         while(true){
  38.             //This->Datais the selection cursor
  39.            
  40.             if ( Link->PressRight ) {
  41.                 Link->PressRight = false;
  42.                 if ( WARP_CURSOR_MOVE_SFX ) Game->PlaySound(WARP_CURSOR_MOVE_SFX);
  43.                 if ( selection < last ) {
  44.                     //Find the next dest.
  45.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  46.                         if ( cursor[ q[1] ] == selection += 1 ) {
  47.                             selection++;
  48.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  49.                             //clear all non-selected ffcs of any special iconography
  50.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  51.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  52.                             }
  53.                             f[selection]->Data++; //Give it a flashing indicator.
  54.                         }
  55.                     }
  56.                 }
  57.                 else { //wrap to 1
  58.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  59.                         if ( f[ q[1] ]->InitD[0] == 1 ) {
  60.                             selection = 1;
  61.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  62.                             //clear all non-selected ffcs of any special iconography
  63.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  64.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  65.                             }
  66.                             f[selection]->Data++; //Give it a flashing indicator.
  67.                         }
  68.                     }
  69.                 }
  70.             }
  71.            
  72.            
  73.             if ( Link->PressUp ) {
  74.                 Link->PressUp = false;
  75.                 if ( WARP_CURSOR_MOVE_SFX ) Game->PlaySound(WARP_CURSOR_MOVE_SFX);
  76.                 if ( selection < last ) {
  77.                     //Find the next dest.
  78.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  79.                         if ( cursor[ q[1] ] == selection += 1 ) {
  80.                             selection++;
  81.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  82.                             //clear all non-selected ffcs of any special iconography
  83.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  84.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  85.                             }
  86.                             f[selection]->Data++; //Give it a flashing indicator.
  87.                         }
  88.                     }
  89.                 }
  90.                 else { //wrap to 1
  91.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  92.                         if ( f[ q[1] ]->InitD[0] == 1 ) {
  93.                             selection = 1;
  94.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  95.                             //clear all non-selected ffcs of any special iconography
  96.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  97.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  98.                             }
  99.                             f[selection]->Data++; //Give it a flashing indicator.
  100.                         }
  101.                     }
  102.                 }
  103.             }
  104.            
  105.             if ( Link->PressLeft ) {
  106.                 Link->PressLeft = false;
  107.                 if ( WARP_CURSOR_MOVE_SFX ) Game->PlaySound(WARP_CURSOR_MOVE_SFX);
  108.                 if ( selection > 1 ) {
  109.                     //Find the prior dest.
  110.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  111.                         if ( cursor[ q[1] ] == selection -= 1 ) {
  112.                             selection--;
  113.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  114.                             //clear all non-selected ffcs of any special iconography
  115.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  116.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  117.                             }
  118.                             f[selection]->Data++; //Give it a flashing indicator.
  119.                         }
  120.                     }
  121.                 }
  122.                 else { //wrap to last
  123.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  124.                         if ( f[ q[1] ]->InitD[0] == last ) {
  125.                             selection = last;
  126.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  127.                             //clear all non-selected ffcs of any special iconography
  128.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  129.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  130.                             }
  131.                             f[selection]->Data++; //Give it a flashing indicator.
  132.                         }
  133.                     }
  134.                 }
  135.             }
  136.            
  137.             if ( Link->PressDown ) {
  138.                 Link->PressDown = false;
  139.                 if ( WARP_CURSOR_MOVE_SFX ) Game->PlaySound(WARP_CURSOR_MOVE_SFX);s
  140.                 if ( selection > 1 ) {
  141.                     //Find the prior dest.
  142.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  143.                         if ( cursor[ q[1] ] == selection -= 1 ) {
  144.                             selection--;
  145.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  146.                             //clear all non-selected ffcs of any special iconography
  147.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  148.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  149.                             }
  150.                             f[selection]->Data++; //Give it a flashing indicator.
  151.                         }
  152.                     }
  153.                 }
  154.                 else { //wrap to last
  155.                     for ( q[1] = 1; q[1] <= 32; q[1]++ ){
  156.                         if ( f[ q[1] ]->InitD[0] == last ) {
  157.                             selection = last;
  158.                             this->X = f[ q[1] ]->X; this->Y = f[ q[1] ]->Y;
  159.                             //clear all non-selected ffcs of any special iconography
  160.                             for ( q[2] = 1; q[2] <= 32; q[2]++ ) {
  161.                                 f[ q[2] ]->Data = f[ q[2] ]->misc[0];
  162.                             }
  163.                             f[selection]->Data++; //Give it a flashing indicator.
  164.                         }
  165.                     }
  166.                 }
  167.             }
  168.            
  169.             if ( Link->PressA || Link->PressB ) { //Warp
  170.                 if ( WARP_CURSOR_SELECT_SFX ) Game->PlaySound(WARP_CURSOR_SELECT_SFX);
  171.                 if ( WARP_CURSOR_SELECT_SFX_DUR ) {
  172.                     for ( q[2] = 0; q[2] < WARP_CURSOR_SELECT_SFX_DUR; q[2]++ ) WaitNoAction();
  173.                     for ( q[3] = 0; q[3] < 8; q[3]++ ) coordinates[q] = f[selection]->InitD[q];
  174.                     break;
  175.  
  176.             }
  177.            
  178.             if ( Link->PressEx1 ) {} //Cancel
  179.             //Move this->X/Y to each position in sequence.
  180.             Waitframe();
  181.         }
  182.         Link->X = coordinates[3]; Link->Y = coordinates[4];
  183.         Screen->Wavy = WARP_WHISTLE_WAVY_DUR;
  184.         Link->Invisible = false; //Again, tie int IsInvisible()
  185.         Link->PitWarp(coordinates[1], coordinates[2]);
  186.     }
  187. }
  188.  
  189. ffc script WhistleWarpDest{
  190.     void run(int dest_number, int dmap, int screen, int destX, int destY){
  191.         this->Misc[0] = this->Data;
  192.         while(true) Waitframe();
  193.     }
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement