ZoriaRPG

ZC Conveyors Move Bombs, Blocks, Objects

Nov 7th, 2016
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Move Bombs or BLocks on Conveyors
  2.  
  3. //Global conditions to move all of any object type.
  4. const int CONVEYORS_MOVE_FFCS = 0;
  5. const int CONVEYORS_MOVE_ITEMS = 0; //ZC already does, but you could use this to chane their speed.
  6. const int CONVEYORS_MOVE_LWEAPONS = 0;
  7. const int CONVEYORS_MOVE_EWEAPONS = 0;
  8. const int CONVEYORS_MOVE_NPCS = 0;
  9.  
  10. const int CONVEYORS_MOVE_BOMBS = 1;
  11. const int CONVEYORS_MOVE_WALKING_NPCS = 0;
  12.  
  13. const int CONVEYORS_USE_COLLISION = 1; //Se tto 0 to use coordinates, instead of collision.
  14.  
  15.  bool IsOnConveyor(int cmb){
  16.      return ( ComboT[cmb] == CT_CVLEFT || ComboT[cmb] == CT_CVRIGHT || ComboT[cmb] == CT_CVUP ||ComboT[cmb] == CT_CVDOWN );
  17.  }
  18.  
  19.  const int WEAP_CONVEY_TIMER = 1; //Misc Index
  20.  
  21.  const int CONVEY_TIME = 20; //How many frames to wait before moving one pixel on a conveyor, +1.
  22.                 //! The movement occurs at '1', not '0'.
  23.  
  24.  void MarkObjectConveyor(lweapon l) { if ( !l->Misc[WEAP_CONVEY_TIMER] ) l->Misc[WEAP_CONVEY_TIMER] = CONVEY_TIME; }
  25.  
  26.  void MoveObjectConveyor(lweapon l) {
  27.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  28.         //Move it
  29.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVLEFT ) l->X--;
  30.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVRIGHT ) l->X++;
  31.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVUP ) l->Y--;
  32.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVDOWN ) l->Y++;
  33.     }
  34.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  35.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  36. }
  37.  
  38.  
  39.  void MarkObjectConveyor(eweapon l) { if ( !l->Misc[WEAP_CONVEY_TIMER] ) l->Misc[WEAP_CONVEY_TIMER] = CONVEY_TIME; }
  40.  
  41.  void MoveObjectConveyor(eweapon l) {
  42.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  43.         //Move it
  44.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVLEFT ) l->X--;
  45.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVRIGHT ) l->X++;
  46.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVUP ) l->Y--;
  47.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVDOWN ) l->Y++;
  48.     }
  49.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  50.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  51. }
  52.  
  53.  void MarkObjectConveyor(item l) { if ( !l->Misc[WEAP_CONVEY_TIMER] ) l->Misc[WEAP_CONVEY_TIMER] = CONVEY_TIME; }
  54.  
  55.  void MoveObjectConveyor(item l) {
  56.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  57.         //Move it
  58.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVLEFT ) l->X--;
  59.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVRIGHT ) l->X++;
  60.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVUP ) l->Y--;
  61.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVDOWN ) l->Y++;
  62.     }
  63.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  64.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  65. }
  66.  
  67.  void MarkObjectConveyor(ffc l) { if ( !l->Misc[WEAP_CONVEY_TIMER] ) l->Misc[WEAP_CONVEY_TIMER] = CONVEY_TIME; }
  68.  
  69.  void MoveObjectConveyor(ffc l) {
  70.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  71.         //Move it
  72.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVLEFT ) l->X--;
  73.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVRIGHT ) l->X++;
  74.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVUP ) l->Y--;
  75.         if ( ComboT[ComboAt(l->X, l->Y)] == CT_CVDOWN ) l->Y++;
  76.     }
  77.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  78.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  79. }
  80.  
  81.  
  82.  void MoveObjectConveyorCollision(ffc l, int cmb) {
  83.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  84.         //Move it
  85.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVLEFT ) l->X--;
  86.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVRIGHT ) l->X++;
  87.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVUP ) l->Y--;
  88.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVDOWN ) l->Y++;
  89.     }
  90.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  91.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  92. }
  93.  
  94.  void MoveObjectConveyorCollision(item l, int cmb) {
  95.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  96.         //Move it
  97.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVLEFT ) l->X--;
  98.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVRIGHT ) l->X++;
  99.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVUP ) l->Y--;
  100.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVDOWN ) l->Y++;
  101.     }
  102.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  103.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  104. }
  105.  
  106.  void MoveObjectConveyorCollision(lweapon l, int cmb) {
  107.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  108.         //Move it
  109.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVLEFT ) l->X--;
  110.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVRIGHT ) l->X++;
  111.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVUP ) l->Y--;
  112.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVDOWN ) l->Y++;
  113.     }
  114.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  115.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  116. }
  117.  
  118.  void MoveObjectConveyorCollision(eweapon l, int cmb) {
  119.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  120.         //Move it
  121.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVLEFT ) l->X--;
  122.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVRIGHT ) l->X++;
  123.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVUP ) l->Y--;
  124.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVDOWN ) l->Y++;
  125.     }
  126.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  127.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  128. }
  129.  
  130.  void MoveObjectConveyorCollision(npc l, int cmb) {
  131.     if ( l->Misc[WEAP_CONVEY_TIMER] == 1 ) {
  132.         //Move it
  133.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVLEFT ) l->X--;
  134.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVRIGHT ) l->X++;
  135.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVUP ) l->Y--;
  136.         if ( Collision(l,cmb) && ComboT[cmb] == CT_CVDOWN ) l->Y++;
  137.     }
  138.     if ( l->Misc[WEAP_CONVEY_TIMER] > 1 ) l->Misc[WEAP_CONVEY_TIMER]--;
  139.     if ( !l->Misc[WEAP_CONVEY_TIMER] && IsOnConveyor(l) ) MarkObjectConveyor(l);
  140. }
  141.  
  142. void ConveyorObjects(){
  143.     lweapon l; item i; eweapon e; npc n; ffc f; int q;
  144.     if ( CONVEYORS_MOVE_BOMBS ) {
  145.         for ( q = Screen->NumLWeapons(); q > 0; q-- ) {
  146.             l = Screen->LoadLWeapon(q);
  147.             if ( l->ID == LW_BOMB || l->ID == LW_SBOMB ) MoveObjectConveyor(l);
  148.         }
  149.     }
  150.     //Add more definitions.
  151.     //Somaria Blocks
  152.    
  153.     //Walking NPCs? -- How should we handle ghosted NPCs?
  154. }
  155.  
  156. void ConveyorObjectsCollision(){
  157.     lweapon l; item i; eweapon e; npc n; ffc f; int q; int cmb;
  158.     if ( CONVEYORS_MOVE_BOMBS ) {
  159.         for ( cmb = 0; cmb < 176; cmb++ ) {
  160.             for ( q = Screen->NumLWeapons(); q > 0; q-- ) {
  161.                 l = Screen->LoadLWeapon(q);
  162.                 if ( l->ID == LW_BOMB || l->ID == LW_SBOMB ) MoveObjectConveyorCollision(l,cmb);
  163.             }
  164.         }
  165.     }
  166.     //Add more definitions.
  167.     //Somaria Blocks
  168.    
  169.     //Walking NPCs? -- How should we handle ghosted NPCs?
  170. }
  171.  
  172. global script conveyor_test{
  173.     void run(){
  174.         while(true){
  175.             if ( !CONVEYORS_USE_COLLISION ) ConveyorObjects();
  176.             if ( CONVEYORS_USE_COLLISION ) ConveyorObjectsCollision();
  177.             Waitdraw();
  178.             Waitframe();
  179.         }
  180.     }
  181. }
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.

×