ZoriaRPG

ZC Faster Conveyor Belts v0.1.5

Nov 15th, 2016
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /////////////////////////////
  2. /// Faster Conveyor Belts ///
  3. /// v0.1.5                ///
  4. /// 15-Nov-2016           ///
  5. /// By: ZoriaRPG          ///
  6. /////////////////////////////////////////////////////////////////////////////////
  7. /// Purpose: This allows creating conveyor belts that move *Link* faster than ///
  8. /// the stock ZC conveyors.                                                   ///
  9. ///                                                                           ///
  10. /// Future versions may support bombs, items, somaria blocks, and npcs.       ///
  11. /// I have *no plans* to add, or support creating *slower* conveyors with     ///
  12. /// this header.                                                              ///
  13. /////////////////////////////////////////////////////////////////////////////////
  14.  
  15. //FFC Version
  16.  
  17. //Flags for ffcs. Using these alternative ffcs permits you to have both normal, and fast conveyors on the same screen
  18. //without usin the global script.
  19. const int FFC_FLAG_I_FAST_CONVEY = 100; //The Inherent Flag to use on conveyor combos for use with ffc script FasterConveyorsInhFlagged.
  20.                     //Default: SCRIPT_3
  21. const int FFC_FLAG_FAST_CONVEY = 99; //The Placed Flag to use on conveyor combos on the screen with ffc script FasterConveyorsManFlagged.
  22.                     // Default: SCRIPT_2.
  23.  
  24. ffc script FasterConveyors{
  25.     void run(int speed, int step){
  26.         int timer = speed;
  27.         while(true){
  28.             if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVLEFT ) {
  29.                 if ( !timer ) timer = speed;
  30.                 if ( timer > 1 ) timer--;
  31.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_LEFT, step, false) ) {
  32.                     Link->X--;
  33.                     timer = speed;
  34.                 }
  35.             }
  36.             else if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVRIGHT ) {
  37.                 if ( !timer ) timer = speed;
  38.                 if ( timer > 1 ) timer--;
  39.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_RIGHT, step, false) ) {
  40.                     Link->X++;
  41.                     timer = speed;
  42.                 }
  43.             }
  44.             if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVUP ) {
  45.                 if ( !timer ) timer = speed;
  46.                 if ( timer > 1 ) timer--;
  47.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_UP, step, false)  ) {
  48.                     Link->Y--;
  49.                     timer = speed;
  50.                 }
  51.             }
  52.             else if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVDOWN ) {
  53.                 if ( !timer ) timer = speed;
  54.                 if ( timer > 1 ) timer--;
  55.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_DOWN, step, false) ) {
  56.                     Link->Y++;
  57.                     timer = speed;
  58.                 }
  59.             }
  60.             else timer = speed;
  61.             Waitframe();
  62.         }
  63.     }
  64. }
  65.  
  66.  
  67.  
  68.  
  69. //As ffc above, except this only works with conveyor combos that ALSO have an INHERENT flag of FFC_FLAG_I_FAST_CONVEY.
  70. ffc script FasterConveyorsInhFlagged{
  71.     void run(int speed, int step){
  72.         int timer = speed;
  73.         while(true){
  74.             if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVLEFT && Screen->ComboI[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_I_FAST_CONVEY ) {
  75.                 if ( !timer ) timer = speed;
  76.                 if ( timer > 1 ) timer--;
  77.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_LEFT, step, false) ) {
  78.                     Link->X--;
  79.                     timer = speed;
  80.                 }
  81.             }
  82.             else if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVRIGHT && Screen->ComboI[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_I_FAST_CONVEY ) {
  83.                 if ( !timer ) timer = speed;
  84.                 if ( timer > 1 ) timer--;
  85.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_RIGHT, step, false) ) {
  86.                     Link->X++;
  87.                     timer = speed;
  88.                 }
  89.             }
  90.             if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVUP && Screen->ComboI[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_I_FAST_CONVEY ) {
  91.                 if ( !timer ) timer = speed;
  92.                 if ( timer > 1 ) timer--;
  93.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_UP, step, false)  ) {
  94.                     Link->Y--;
  95.                     timer = speed;
  96.                 }
  97.             }
  98.             else if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVDOWN && Screen->ComboI[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_I_FAST_CONVEY ) {
  99.                 if ( !timer ) timer = speed;
  100.                 if ( timer > 1 ) timer--;
  101.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_DOWN, step, false) ) {
  102.                     Link->Y++;
  103.                     timer = speed;
  104.                 }
  105.             }
  106.             else timer = speed;
  107.             Waitframe();
  108.         }
  109.     }
  110. }
  111.  
  112.  
  113. //As ffc above, except this only works with conveyor combos that ALSO have a PLACED flag of FFC_FLAG_FAST_CONVEY.
  114. ffc script FasterConveyorsManFlagged{
  115.     void run(int speed, int step){
  116.         int timer = speed;
  117.         while(true){
  118.             if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVLEFT && Screen->ComboF[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_FAST_CONVEY ) {
  119.                 if ( !timer ) timer = speed;
  120.                 if ( timer > 1 ) timer--;
  121.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_LEFT, step, false) ) {
  122.                     Link->X--;
  123.                     timer = speed;
  124.                 }
  125.             }
  126.             else if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVRIGHT && Screen->ComboF[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_FAST_CONVEY ) {
  127.                 if ( !timer ) timer = speed;
  128.                 if ( timer > 1 ) timer--;
  129.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_RIGHT, step, false) ) {
  130.                     Link->X++;
  131.                     timer = speed;
  132.                 }
  133.             }
  134.             if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVUP && Screen->ComboF[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_FAST_CONVEY ) {
  135.                 if ( !timer ) timer = speed;
  136.                 if ( timer > 1 ) timer--;
  137.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_UP, step, false)  ) {
  138.                     Link->Y--;
  139.                     timer = speed;
  140.                 }
  141.             }
  142.             else if ( Screen->ComboT[ ComboAt(Link->X+8, Link->Y+8) ] == CT_CVDOWN && Screen->ComboF[ ComboAt(Link->X+8, Link->Y+8) ] == FFC_FLAG_FAST_CONVEY ) {
  143.                 if ( !timer ) timer = speed;
  144.                 if ( timer > 1 ) timer--;
  145.                 if ( timer <= 1 && CanWalk(Link->X+8, Link->Y+8, DIR_DOWN, step, false) ) {
  146.                     Link->Y++;
  147.                     timer = speed;
  148.                 }
  149.             }
  150.             else timer = speed;
  151.             Waitframe();
  152.         }
  153.     }
  154. }
  155.  
  156. //Global Version
  157.  
  158. int ____GRAM[214747];
  159.  
  160. const int CONVEYOR_TIMER = 10020; //Index of ____GRAM.
  161. const int FAST_CONVEY_SPEED = 15;
  162. const int FAST_CONVEY_STEP = 1;
  163. const int CMB_FAST_CONVEY_RT = 1000; //Set to combo ID of Fast Conveyor (Right)
  164. const int CMB_FAST_CONVEY_LF = 1001; //Set to combo ID of Fast Conveyor (Left)
  165. const int CMB_FAST_CONVEY_UP = 1002; //Set to combo ID of Fast Conveyor (Up)
  166. const int CMB_FAST_CONVEY_DN = 1003; //Set to combo ID of Fast Conveyor (Down)
  167.  
  168. //Call as FasterConveyors(FAST_CONVEY_SPEED, FAST_CONVEY_STEP, ____GRAM, CONVEYOR_TIMER);
  169. void FasterConveyors(int speed, int step, int arr, int index){
  170.     if ( Screen->ComboD[ ComboAt(Link->X+8, Link->Y+8) ] == CMB_FAST_CONVEY_LF ) {
  171.         if ( !arr[index] ) arr[index] = speed;
  172.         if ( arr[index] > 1 ) arr[index]--;
  173.         if ( arr[index] == 1 && CanWalk(Link->X+8, Link->Y+8, DIR_LEFT, step, false) ) {
  174.             Link->X--;
  175.             arr[index] = speed;
  176.         }
  177.     }
  178.     else if ( Screen->ComboD[ ComboAt(Link->X+8, Link->Y+8) ] == CMB_FAST_CONVEY_RT ) {
  179.         if ( !arr[index] ) arr[index] = speed;
  180.         if ( arr[index] > 1 ) arr[index]--;
  181.         if ( arr[index] == 1 && CanWalk(Link->X+8, Link->Y+8, DIR_RIGHT, step, false) ) {
  182.             Link->X++;
  183.             arr[index] = speed;
  184.         }
  185.     }
  186.     else if ( Screen->ComboD[ ComboAt(Link->X+8, Link->Y+8) ] == CMB_FAST_CONVEY_UP ) {
  187.         if ( !arr[index] ) arr[index] = speed;
  188.         if ( arr[index] > 1 ) arr[index]--;
  189.         if ( arr[index] == 1 && CanWalk(Link->X+8, Link->Y+8, DIR_UP, step, false)  ) {
  190.             Link->Y--;
  191.             arr[index] = speed;
  192.         }
  193.     }
  194.     else if ( Screen->ComboD[ ComboAt(Link->X+8, Link->Y+8) ] == CMB_FAST_CONVEY_DN ) {
  195.         if ( !arr[index] ) arr[index] = speed;
  196.         if ( arr[index] > 1 ) arr[index]--;
  197.         if ( arr[index] == 1 && CanWalk(Link->X+8, Link->Y+8, DIR_DOWN, step, false) ) {
  198.             Link->Y+++;
  199.             arr[index] = speed;
  200.         }
  201.     }
  202.     else arr[index] = speed;
  203. }
  204.  
  205. global script convey{
  206.     void run(){
  207.         while(true){
  208.             FasterConveyors(FAST_CONVEY_SPEED, FAST_CONVEY_STEP, ____GRAM, CONVEYOR_TIMER);
  209.             Waitdraw();
  210.             Waitframe();
  211.         }
  212.     }
  213. }
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.

×