ZoriaRPG

Let's Script #0 : Timed Pressure Plate Triggers

Jan 28th, 2017
214
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ///////////////////////////////////
  3. /// Timed Pressure Plates       ///
  4. /// v1.0 - 26th January, 2017   ///
  5. /// By: ZoriaRPG                ///
  6. /// Requested By: Shadowblitz16 ///
  7. ///////////////////////////////////
  8.  
  9. //Settings
  10.  
  11. //Flags to Use
  12. const int CF_PRESSPLATE     = 101; //Flag used to denote a pressure plate.
  13. const int CF_PRESSPLATE_DOOR    = 102; //Flag for combo to change when all pressure plates are triggered.
  14.  
  15. const int PRESSUREPLATES_ADVANCE_WHEN_TRIGGERED = 1; //Overrides 'advance' option in the ffc, globally.
  16.  
  17. ffc script multipressplates{
  18.     //D0: THe Screen->D register to use.
  19.     //D1: The sound for stepping on a pressure plate.
  20.     //D2: the sound to play for doors opening.
  21.     //D3: The number of pressure plates on the screen, required to trigger the doors.
  22.     //D4: Duration of pressure plate sequence timer.
  23.     //D5: Set to '1' if you want the trigger to be permanent.
  24.     //D6: Split between integer and decimal:
  25.     //  Integer Side, Set to '1' to advance pressure plates when triggered.
  26.     //  Decimal Side, Set to '1' to clear *inherent* flags on pressure plate combos.
  27.     //Rats. Here's how those value splitting things work.
  28.     //D7: Set to a combo ID if you wish this ffc to turn into that combo when all triggers are triggered.
  29.    
  30.     //Too bad FFCs aren;t solid, but it can be used for something such as an additional trigger.
  31.     void run(int reg, int sfx, int shuttersfx, int numplates, int PRESSUREPLATE_DUR, int perm, int advance_clear_inherent, int change_this_into){
  32.         int advance = (advance_clear_inherent << 0); //Integer side
  33.         int clear_inherent = ( advance_clear_inherent - ( advance_clear_inherent << 0 ) * 10000); //decimal side.
  34.         int platetimers[32];
  35.         int platelocations[32];
  36.         int w; //a general sp.
  37.         for ( ; w < 32; w++ ) {
  38.             platelocations[w] = -1;
  39.             platetimers[w] = -1;
  40.         }
  41.         int ffram[32];
  42.         w = 0; int q;
  43.         int loc;
  44.         //int doortimers[32];
  45.         //int doorlocations[32];
  46.        
  47.         //Allow the change to persist if D4 is set.
  48.         if ( perm && Screen->D[reg] >= numplates ) {
  49.            
  50.             for ( q = 0; q < 176; q++ ) {
  51.                 //find the door flag
  52.                 if ( ComboFI(ComboX(q), ComboY(q), CF_PRESSPLATE_DOOR) ) Screen->ComboD[q]++;
  53.                 //if ( shuttersfx ) Game->PlaySound(shuttersfx);
  54.                
  55.             }
  56.             this->Data = 0; this->Script = 0; Quit();
  57.            
  58.         }
  59.         //If D4 is not set, revert on screen reload.
  60.         else {
  61.             Screen->D[reg] = 0;
  62.         }
  63.        
  64.         //Main loop
  65.         while(true){
  66.             //Check the pressure plate timers, reduce them if needed.
  67.             for ( q = 0; q < 32; q++ ) {
  68.                 if ( platetimers[q] > 0 ) platetimers[q]--;
  69.                 //If a timer is '0', change its combo back to a trigger.
  70.                 if ( platetimers[q] == 0 ) {
  71.                     //if we changed a plate at a location...
  72.                     if ( platelocations[q] != -1 ) { //-1 is 'unchanged'
  73.                         Screen->ComboD[ platelocations[q] ]--; //change it back
  74.                         if ( sfx ) Game->PlaySound(sfx);
  75.                         Screen->ComboF[ platelocations[q] ] = CF_PRESSPLATE;
  76.                         if ( Screen->D[reg] > 0 ) Screen->D[reg]--;
  77.                         //Screen->ComboI[ platelocations[q] ] = CF_PRESSPLATE;
  78.                     }
  79.                     platetimers[q] = -1; //mark it as an unchanged status, for the next cycle.
  80.                 }
  81.             }
  82.             //Update the location of Link's trigger point.
  83.             loc = ComboAt(Link->X+8, Link->Y+8);
  84.             //If he steps on a combo with either a placed, or inherent flag of the triggering type...
  85.             if ( ComboFI(Link->X+8, Link->Y+8, CF_PRESSPLATE) ) {
  86.                 Screen->D[reg]++; //increment Screen->D[reg]
  87.                 if ( sfx ) Game->PlaySound(sfx); //play a sound, if set
  88.                 Screen->ComboF[loc] = CF_NONE; //clear the flags off the combo.
  89.                 if ( clear_inherent ) Screen->ComboI[loc] = CF_NONE;  
  90.                                 //You may want to remove the clearing of inherent
  91.                                 //flags if you use combos that have other types applies
  92.                                 //and rely solely on placed flags for this.
  93.                 if ( PRESSUREPLATES_ADVANCE_WHEN_TRIGGERED || advance ) Screen->ComboD[loc]++; //Move to the next combo if we allow that.
  94.                 platelocations[w] = loc; platetimers[w] = PRESSUREPLATE_DUR; w++;  //Update the locations, and timers.
  95.                 //store the location and set a timer for it.
  96.                
  97.                 //This reads the setting, and if the assigned value is not '0'
  98.                 //it advances the pressure plate combo by '1'.
  99.                 continue; //return tot he head of the loop.
  100.             }
  101.             //If Link has triggered all of the plates...
  102.             if ( Screen->D[reg] >= numplates ) {
  103.                 for ( q = 0; q < 176; q++ ) { //cycle through the combos looking for the combo to change.
  104.                     //find the door flag; note that you can change any combo to another.
  105.                     //It need not be a door; only a combo with the flag that we specify.
  106.                     //It could equally be a chest, or something.
  107.                     if ( ComboFI(ComboX(q), ComboY(q), CF_PRESSPLATE_DOOR) ) Screen->ComboD[q]++;
  108.                     //If a sound is set, for the doors/secret trigger, play it.
  109.                     if ( shuttersfx ) Game->PlaySound(shuttersfx);
  110.                     if ( change_this_into ) this->Data = change_this_into;
  111.                 }
  112.  
  113.                 break; //then exit the scope of the while loop.
  114.             }
  115.             Waitframe();
  116.         }
  117.         //If we have exited the scope of the while loop, clear and exit the script.
  118.         this->Script = 0;
  119.         if ( this->Data != change_this_into ) this->Data = 0;
  120.         Quit();
  121.     }
  122. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×