Advertisement
ZoriaRPG

Ornamental Shelf Sliding Door FFC for Triforce Knight

Mar 3rd, 2019
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.68 KB | None | 0 0
  1. //Ornamental Shelf for Triforce Knight Cane Leve
  2. //By: ZoriaRPG, for BigJoe
  3.  
  4. const int FFC_CANE_LEVEL_DOOR_FLAG_OPEN_DOOR =  0000000001b;
  5. const int FFC_CANE_LEVEL_DOOR_FLAG_STAY_OPEN =  0000000010b;
  6.  
  7. ffc script CaneLevelDoor
  8. {
  9.     void run(int reg, float px_dist_per_frame, int frame_timer, int open_grind_sfx,  
  10.             int stay_open, int fully_open_x)
  11.     {
  12.         int q[256];
  13.         ffc lnk = Screen->LoadFFC(this->Link); //Get the second half.
  14.         open_grind_sfx = ( open_grind_sfx << 0 );
  15.         //
  16.         //  q[0] - q[4] : Loop reservations. (unused)
  17.         // 
  18.         //  Hell, we'll just go bitwise.
  19.         //
  20.         //  q[5] timer
  21.         //  q[6] state that the door is open fully.
  22.         //
  23.        
  24.        
  25.                
  26.                 //Trace(Game->GetCurScreen());
  27.        
  28.         q[5] = frame_timer; //I might want to evaluate this in seconds.
  29.             //TraceB(GetScreenDBit(119, reg, FFC_CANE_LEVEL_DOOR_FLAG_OPEN_DOOR)); 
  30.         //If the door has been opened in the past and set not to animate on revisiting, open it fully.
  31.         //This requires running on screen init.
  32.         if ( GetScreenDBit(119, reg, FFC_CANE_LEVEL_DOOR_FLAG_OPEN_DOOR) && stay_open )
  33.         {
  34.             this->X = fully_open_x;
  35.             lnk->X = fully_open_x+64;
  36.             Screen->Door[DOOR_UP] = D_OPEN; //Change the solid wall, to a door.
  37.             Quit();
  38.         }
  39.         //else { this->X = this->X; this->Y = this->Y;  }
  40.        
  41.         while(true)
  42.         {
  43.             if ( Screen->NumNPCs() ) { Waitframe(); } //Do not freeze Link and allow him to be murdered.
  44.            
  45.             if ( !GetScreenDBit(Game->GetCurScreen(), reg, FFC_CANE_LEVEL_DOOR_FLAG_OPEN_DOOR))
  46.             {
  47.                 //If the external device has not set a bit on this screen, wait and do nothing.
  48.                 this->X = this->X; this->Y = this->Y;
  49.                 Waitframe();
  50.             }
  51.            
  52.            
  53.             else
  54.             {
  55.                 while(Link->Action == LA_SCROLLING) { Waitframe(); continue; }
  56.                 // Set draw over for both ffcs here.
  57.                 this->Flags[FFCF_OVERLAY] = true;
  58.                 lnk->Flags[FFCF_OVERLAY] = true;
  59.                
  60.                 Screen->Door[DOOR_UP] = D_OPEN; //Change the solid wall, to a door.
  61.                 //Otherwise, the trigger event has occurred.
  62.                 if ( !q[6] )
  63.                 {
  64.                     if ( open_grind_sfx > 0 && open_grind_sfx < 256 ) Game->PlaySound(open_grind_sfx);
  65.                     //If the sound is set, play it.
  66.                     while( q[5]-- || this->X < fully_open_x )
  67.                     {
  68.                         //Open the door
  69.                         this->X -= px_dist_per_frame;
  70.                         lnk->X -= px_dist_per_frame;
  71.                         WaitNoAction(); //Link does not move. He is stunned by the animation effects.
  72.                     }
  73.                     q[6] = 1; //The door is open.
  74.                     this->Flags[FFCF_OVERLAY] = false;
  75.                     lnk->Flags[FFCF_OVERLAY] = false;
  76.                     if ( stay_open )
  77.                     {
  78.                         //If the animation does not repeat on revisiting the screen
  79.                         //which is a terrible shame...
  80.                        
  81.                         SetScreenDFlag( reg, FFC_CANE_LEVEL_DOOR_FLAG_STAY_OPEN, true );
  82.                         break;
  83.                     }  
  84.                        
  85.                 }
  86.             }
  87.             Waitframe();
  88.         } //End of main loop.
  89.        
  90.         //Any clean-up?
  91.        
  92.        
  93.         Quit();
  94.     }
  95. }
  96.  
  97. ffc script SetCaneDoorBit
  98. {
  99.     void run(int reg, int screen, int enemies, int sfx)
  100.     {
  101.         if ( screen == -1 ) screen = 119;
  102.         //what is the trigger?
  103.         Waitframes( 5 ); //Wait for npcs to spawn.
  104.         while(true)
  105.         {
  106.             if ( !enemies && !Screen->State[ST_SECRET] )  { Waitframe(); continue; }
  107.             if ( enemies && Screen->NumNPCs() )  { Waitframe(); continue; }
  108.             //We shall presume that the trigger is a secret state for the present.
  109.             break;
  110.         }
  111.        
  112.         if ( sfx  && !GetScreenDBit(screen, reg, FFC_CANE_LEVEL_DOOR_FLAG_OPEN_DOOR) ) Game->PlaySound( sfx ); //Play the sound only one time.
  113.         //Set the remote bit and exit.
  114.         SetScreenDBit(screen, reg, FFC_CANE_LEVEL_DOOR_FLAG_OPEN_DOOR, true);
  115.        
  116.         //Drawscreen the screen witht he secret?
  117.         //TraceB(GetScreenDBit(119, reg, FFC_CANE_LEVEL_DOOR_FLAG_OPEN_DOOR));
  118.         this->Data = 0; this->Script = 0; Quit();
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement