Advertisement
ZoriaRPG

Timed Undercombo for Pushblocks

Nov 19th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.74 KB | None | 0 0
  1. //Block Stairs Fix
  2. //Timed Undercombo for a Push block.
  3. //v0.2
  4.  
  5. //Args:
  6. //D0: Duration of delay timer.
  7. //D1: The Combo ID of the block to move.
  8. //D2: The layer on which the block moves. Must be '1' or '2'.
  9. //D3: The combo to place under the block, after it moves.
  10. //D4: The sound effect file to play when triggered. Set to '0' for 'None'.
  11. //D5: Set to '1' to enable verbose reporting.
  12.  
  13. //! Block to push should be on layer 1, or layer 2.
  14. ffc script FixBlockStairs{
  15.     void run(int dur, int sourceBlockComboD, int blockLayer, int underCombo, int secretSFX, int debugOn){
  16.         //If there is a movable block on the screen with a combo ID
  17.         //as specified, on the specified layer (must be 1 or higher)
  18.        
  19.         int blockLoc; //Location of block.
  20.         int cmb;
  21.         bool changed;
  22.  
  23.        
  24.         int debug[]="Debug Report for FixBlockStairs FFC Script. There was no combo matching the value of D2 on screen: ";
  25.         int debug2[]="...on map: ";
  26.         int debug3[]="...on DMap: ";
  27.        
  28.         for ( int q = 0; q < 176; q++ ) {
  29.             cmb = GetLayerComboD(layer,q);
  30.             if ( cmb == sourceBlockComboD ) blockLoc = q;   //If it's there, store its location
  31.         }
  32.        
  33.         //If there is no combo on the screen that matches this data...
  34.         if ( ! cmb ) {
  35.             //if verbose debugging is enabled
  36.             if ( debugOn ) {
  37.                 //Trace information to allegro.log, so that it's easier to fix the problem.
  38.                 TraceNL();  TraceS(debug);  Trace( Game->GetCurScreen() );
  39.                 TraceNL();  TraceS(debug2); Trace( Game->GetCurMap() );
  40.                 TraceNL();  TraceS(debug2); Trace( Game->GetCurDMap() );    TraceNL();
  41.             }
  42.            
  43.             this->Data = 0; //Kill the FFC.
  44.             this->Script = 0;
  45.             Quit();
  46.         }
  47.        
  48.        
  49.        
  50.        
  51.         //if we haven't finished replacing the block...
  52.         while(!changed){
  53.    
  54.             //Read / check for that block every frame
  55.             for ( int q = 0; q < 176; q++ ) {
  56.                 int cmb = GetLayerComboD(layer,q);
  57.                
  58.                 //if the block changes location from its original value...
  59.                 if ( cmb == sourceBlockComboD && cmb != blockLoc ) {
  60.            
  61.                     //if the secret sound is a positive number, play it now...
  62.                     if ( secretSFX > 0 ) Game->PlaySound(secretSFX);
  63.                    
  64.                     //run a timed loop for dur
  65.                     for ( int q = 0; q < dur; q++ ) Waitframe();
  66.                     //!Sure, we could probably use combo cycling for this, but it's more fun this way.
  67.                    
  68.                     //Then change the combo where it was, one layer under it, to undercombo
  69.                    
  70.                     changing = true;    //Mark that we've changed the combo in advance.
  71.                    
  72.                     //If the secret sound is a NEGATIVE value, wait for the
  73.                     //transformation, to play it.
  74.                     if ( secretSFX < 0 ) Game->PlaySound(secretSFX);
  75.  
  76.                     //Execute the combo change.
  77.                     SetLayerComboD( (layer-1), blockLoc, underCombo);
  78.                 }
  79.             }
  80.             Waitframe();
  81.            
  82.         }
  83.         this->Data = 0;
  84.         this->Script = 0;
  85.         Quit();
  86.  
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement