home *** CD-ROM | disk | FTP | other *** search
/ Classic Fond 52 / ClassicFond52.iso / GAMES / DROIDW.RAR / DWCD.GOB / mission_cog_03_tanks2.cog < prev    next >
Encoding:
Text File  |  1998-11-04  |  34.8 KB  |  829 lines

  1. #
  2. # Droids Cog Script
  3. #
  4. # 03_Tanks.cog
  5. #
  6. #    bin 27    gear, this number can be changed.  Right now, it's Doug's large gear bin number.
  7. # Desc: 
  8. #     This cog is responsible for keeping track of what gears are in the Gear assembly and where.
  9. #    It's also in charge of moving the lock either to the right or to the left, depending on where
  10. #    the gears are placed.  There are also separate cogs for the gear pieces themselves when found.
  11. #    After they've been placed in this assembly, they are part of this script.  This cog will trigger 
  12. #    the water in the water tanks moving up and down also.  
  13. #     
  14. #
  15. # 1/27/98    [JP]         Created, mostly with lines taken from Doug's mega Gear cog...  
  16. #
  17. # <C> 1998 LucasLearningLimited.  All Rights Reserved--------------------------------------------------------------------------------
  18.  
  19.  
  20. symbols
  21.     
  22.     message    startup
  23.      message   used
  24.      message   arrived
  25.      message   user0
  26.      message   taken
  27.      message   timer
  28.      message   entered
  29.      message   pulse
  30.      
  31.     //surface    button0             linkid=2
  32.      surface   sign0
  33.      
  34.     ## Parts
  35.      thing     screw0              linkid=11          //horizontal worm gear
  36.      thing     lock                linkid=3           //tank lock
  37.      thing     big_gear_vert     linkid=11          //permanent big gear vertical, you don't place or take this
  38.      thing     big_gear_hori     linkid=11          //permanent big gear horizontal, you don't place or take this
  39.      thing     med_gear_vert     linkid=9          //permanent med gear vertical, you don't place or take this11
  40.      
  41.  
  42.      ##Ghost Objects
  43.      thing     lower_left_spindle_g     linkid=30
  44.      thing     lower_right_spindle_g    linkid=31
  45.      thing     upper_left_spindle_g     linkid=32
  46.      thing     upper_right_spindle_g    linkid=33
  47.      
  48.      ##Ghost creation integers
  49.      int       lower_left_spindle_i=0   linkid=30      local
  50.      int       lower_right_spindle_i=0                 local
  51.      int       upper_left_spindle_i=0                  local
  52.      int       upper_right_spindle_i=0                 local   
  53.      
  54.      ##Spin Direction integers
  55.      flex      lower_left_spindle_d=0.0      local
  56.      flex      lower_right_spindle_d=0.0     local
  57.      flex      upper_left_spindle_d=0.0      local
  58.      flex      upper_right_spindle_d=0.0     local
  59.      flex      big_gear_vert_d=0.0         local
  60.      flex      big_gear_hori_d=0.0         local
  61.      flex      med_gear_vert_d=0.0         local
  62.      
  63.      
  64.      ##templates
  65.      template  med_gear_t
  66.      
  67.      ##Sectors
  68.      //sector    lower_left_sector2         //for placing gear in lower left slot
  69.      //sector    lower_right_sector2         //  "          "   in lower right slot
  70.      //sector    upper_left_sector2          //  "          "   in upper left
  71.      //sector    upper_right_sector2         //  "          "   in upper right
  72.      
  73.      ##cogs
  74.      cog       tank_button2_cog //switch
  75.      cog       watermove1       //small tank adjoin and state changes
  76.      cog       watermove2       //medium tank adjoin and state changes
  77.      cog       watermove3       //large tank adjoin and state changes
  78.      cog       ecam             //to external camera
  79.      cog       pipemove
  80.      cog       rdroid
  81.      
  82.      ##sounds
  83.      sounds    machine_on          //moving .wav
  84.      sounds    place_gear          
  85.  
  86.      ## Integral Variables
  87.     float     speed=2.0                local
  88.     int        on_button0=0              local        
  89.      int       xrotate                   local
  90.      int       lower_left_spindle=0     local
  91.      int       lower_right_spindle=0    local
  92.      int       upper_left_spindle=0     local
  93.      int       upper_right_spindle=0    local
  94.      int       timermode=0              local
  95.      int       part_id=0                local
  96.      int       bin=27                   local
  97.      
  98.      
  99.      sound     motorfree=MCHt9MotFree.WAV       
  100.      sound     motor=MCHt9MotFree.WAV           
  101.      sound     switch=MCHt9MotStrt.WAV  //button
  102.      sound     attach=SWTt9GearOn.WAV           
  103.      sound     taken=SWTt9GearOff.WAV           
  104.      sound     grind=MCHt9GearBog.WAV           
  105.      sound     rotating=MCHt9MotStrss.WAV       
  106.      sound     closing=DORt7BoltSlide.WAV 
  107.      
  108.      thing     bottomspindles      linkid=9  //was11
  109.      thing     topspindles         linkid=10 //was11
  110.      thing     plat1               linkid=10
  111.      thing     plat2               linkid=10
  112.      thing     lockpod             linkid=9 //that cracked white thing
  113.      thing     motorpod            linkid=9 
  114.      cog       maps        
  115.      cog       waterfall
  116.      
  117.      sound     gearon=swtt9gearon.wav local
  118.      sound     gearoff=swtt9gearoff.wav local
  119.      
  120.      cog       arrows
  121.      
  122.      surface   s1
  123.      surface   s2
  124.      
  125.      sound     start2=MCHt9MotStrt.wav local
  126.      sound     fin2=MCHt9MotStp.wav local
  127.      
  128.      surface   s3
  129.      surface   s4
  130.      
  131.      surface   a1   linkid=5
  132.  
  133. end
  134.  
  135. ## Code Section
  136. code
  137.  
  138. startup:
  139.      //xrotate = 1;
  140.      //lower_left_spindle_d = -0.5;
  141.      //lower_right_spindle_d = 0.5;
  142.      //big_gear_vert_d = -0.5;
  143.      //big_gear_hori_d = 0.5;
  144.      //med_gear_vert_d = 0.5;
  145.      //call rotate_gears;
  146.      //print ("try4");
  147.      SetWallCel(sign0, 1);
  148.      AttachThingToThing (screw0, big_gear_vert);
  149.      player=getlocalplayerthing();
  150.      motorpos=vectory(getthingpos(med_gear_vert));
  151.      MiddleY=motorpos+.1969;  // was .1619, was .1969  
  152.      setpulse(0.5);
  153.      return;
  154.  
  155.  
  156. #==================================
  157. user0:
  158.           //User0 gets called when the player hits the motor switch, see tank_activate2.cog
  159.      print("user0");
  160.      if (xrotate == 0)  call start_motor;
  161.      return;
  162.  
  163. ##======================================
  164. used: 
  165.           // Section is executed when the user uses an inventory object.  
  166.           print("used2");
  167.           printint (dwGetActivateBin());
  168.           printint (getsenderid());
  169.           if (xrotate == 0)
  170.                {
  171.                if ( getinv(getlocalplayerthing(), dwGetActivatebin()) > 0)
  172.                     {
  173.                     if (GetSenderId() == 9)
  174.                          {
  175.                          playery=vectory(getthingpos(player));
  176.                          printflex(playery);
  177.                          printflex(MiddleY);
  178.                               {
  179.                               if (playery < MiddleY)
  180.                                    {
  181.                                    call handle_lower_right;
  182.                                    }
  183.                                    
  184.                               if (playery > MiddleY)
  185.                                    {
  186.                                    call handle_lower_left;
  187.                                    }
  188.                               }
  189.                               
  190.                          }
  191.                          
  192.                     else if (GetSenderId() == 10)
  193.                          {
  194.                          playery=vectory(getthingpos(player));
  195.                          printflex(playery);
  196.                          printflex(MiddleY);
  197.                               {
  198.                               if (playery < MiddleY)
  199.                                    {
  200.                                    call handle_upper_right;
  201.                                    }
  202.                                    
  203.                               if (playery > MiddleY)
  204.                                    {
  205.                                    call handle_upper_left;
  206.                                    }
  207.                                    
  208.                               }
  209.                          }
  210.                          
  211.                     else if (GetSenderId() == 5)
  212.                          {
  213.                          playery=vectory(getthingpos(player));
  214.                          printflex(playery);
  215.                          printflex(MiddleY);
  216.                               {
  217.                               if (playery < MiddleY)
  218.                                    {
  219.                                    call handle_upper_right;
  220.                                    }
  221.                                    
  222.                               if (playery > MiddleY)
  223.                                    {
  224.                                    call handle_upper_left;
  225.                                    }
  226.                               }
  227.                          }
  228.                     else 
  229.                          {
  230.                          dwplaycammyspeech(0, "GHCA056.wav", 4, 2);
  231.                          }
  232.                     }
  233.                     
  234.                }
  235.                
  236.      return;           
  237.  
  238. # =====================
  239. entered:
  240.        
  241.      if (getthingsector(getlocalplayerthing()) == upper_left_sector2)
  242.      print ("WE'RE IN2");
  243.      setpulse(0.5);
  244.      return;
  245.      
  246. #======================
  247. pulse:
  248.      //printvector(getthingpos(player));
  249.      return;
  250.  
  251. taken:
  252.      print ("taken");
  253.      if (xrotate == 0)
  254.           {
  255.           if (GetSenderId() == 9)  // if it's the motor gear- p_med_gear_vert that got activated
  256.                {
  257.                playery=vectory(getthingpos(player));
  258.                     {
  259.                     if (playery < MiddleY) //right side
  260.                          {     
  261.                          if (lower_right_spindle != 0)
  262.                               {
  263.                               ChangeInv(getlocalplayerthing(), lower_right_spindle, 1);
  264.                               destroything(lower_right_spindle_i);
  265.                               lower_right_spindle = 0;
  266.                               call update_bins;
  267.                               }
  268.                          
  269.                          else
  270.                               {
  271.                               print("hey");
  272.                               }
  273.                               
  274.                          }
  275.                          
  276.                     if (playery > MiddleY) //left side
  277.                          {
  278.                          if (lower_left_spindle != 0)
  279.                               {
  280.                               ChangeInv(getlocalplayerthing(), lower_left_spindle, 1);
  281.                               destroything(lower_left_spindle_i);
  282.                               lower_left_spindle = 0;
  283.                               call update_bins;
  284.                               }
  285.                          else
  286.                               {
  287.                               // TELL THE PLAYER THERE'S NOTHING TO TAKE
  288.                               }
  289.                         } 
  290.                     }
  291.                }
  292.                
  293.           if (GetSenderId() == 10)
  294.                {
  295.                playery=vectory(getthingpos(player));
  296.                     {
  297.                     if (playery < MiddleY)  //right side
  298.                          {
  299.                          if (upper_right_spindle != 0)
  300.                               {
  301.                               ChangeInv(getlocalplayerthing(), upper_right_spindle, 1);
  302.                               destroything(upper_right_spindle_i);
  303.                               upper_right_spindle = 0;
  304.                               call update_bins;
  305.                               }
  306.                          else
  307.                               {
  308.                               // TELL THE PLAYER THERE'S NOTHING TO TAKE
  309.                               }
  310.                          }
  311.  
  312.                     if (playery > MiddleY) //left side
  313.                          {
  314.                          if (upper_left_spindle != 0)
  315.                               {
  316.                               ChangeInv(getlocalplayerthing(), upper_left_spindle, 1);
  317.                               destroything(upper_left_spindle_i);
  318.                               upper_left_spindle = 0;
  319.                               call update_bins;
  320.                               }
  321.                          else
  322.                               {
  323.                               // TELL THE PLAYER THERE'S NOTHING TO TAKE
  324.                               }
  325.                          }
  326.                     }
  327.                }
  328.           
  329.           if (GetSenderId() == 5)
  330.                {                                                                         
  331.                playery=vectory(getthingpos(player));                                   
  332.                     {                                                                  
  333.                     if (playery < MiddleY)  //right side                               
  334.                          {                                                             
  335.                          if (upper_right_spindle != 0)                                 
  336.                               {                                                        
  337.                               ChangeInv(getlocalplayerthing(), upper_right_spindle, 1);
  338.                               destroything(upper_right_spindle_i);                     
  339.                               upper_right_spindle = 0;                                 
  340.                               call update_bins;                                        
  341.                               }                                                        
  342.                          else                                                          
  343.                               {                                                        
  344.                               // TELL THE PLAYER THERE'S NOTHING TO TAKE               
  345.                               }                                                        
  346.                          }                                                             
  347.                                                                                        
  348.                     if (playery > MiddleY) //left side                                 
  349.                          {                                                             
  350.                          if (upper_left_spindle != 0)                                  
  351.                               {                                                        
  352.                               ChangeInv(getlocalplayerthing(), upper_left_spindle, 1); 
  353.                               destroything(upper_left_spindle_i);                      
  354.                               upper_left_spindle = 0;                                  
  355.                               call update_bins;                                        
  356.                               }                                                        
  357.                          else                                                          
  358.                               {                                                        
  359.                               // TELL THE PLAYER THERE'S NOTHING TO TAKE               
  360.                               }                                                        
  361.                          }                                                             
  362.                     }                                                                  
  363.                }                                                                       
  364.                     
  365.           }     
  366.      return;
  367.      
  368. # ============== the long start motor section...
  369. start_motor:
  370.      // if all the gears are in place
  371.      playsoundlocal(start, 1, 0, 0);
  372.      print("start_motor");
  373.      if ( (lower_left_spindle == bin) && (lower_right_spindle == bin) && (upper_left_spindle == bin) && (upper_right_spindle == bin) )  
  374.           {  // case 4
  375.           print ("case4");
  376.           lower_left_spindle_d  = 0;    // none of the placeable gears move
  377.           lower_right_spindle_d = 0;
  378.           upper_left_spindle_d  = 0;
  379.           upper_right_spindle_d = 0;
  380.           //permanent ones:
  381.           big_gear_vert_d = 0.0;      //none of the permenant gears move      
  382.           big_gear_hori_d = 0.0;         
  383.           med_gear_vert_d = 0.0;
  384.           // TODO:  GRIND THE MOTOR FOR A LITTLE BIT
  385.           PlaySoundThing(grind, med_gear_vert, 1, -1, -1, 0);
  386.           }
  387.      
  388.      else if ( (lower_right_spindle == bin) && (upper_right_spindle == bin) )
  389.           { // there are gears in upper and lower right places at the same time  
  390.           // case 3, 4, 5, 6
  391.           print ("case3456");
  392.           lower_left_spindle_d  = 0;
  393.           lower_right_spindle_d = 0;
  394.           upper_left_spindle_d  = 0;
  395.           upper_right_spindle_d = 0;
  396.           //permanent ones:
  397.           big_gear_vert_d = 0.0;      //none of the permenant gears move      
  398.           big_gear_hori_d = 0.0;         
  399.           med_gear_vert_d = 0.0;
  400.  
  401.           // TODO:  GRIND THE MOTOR FOR A LITTLE BIT
  402.           PlaySoundThing(grind, med_gear_vert, 1, -1, -1, 0);
  403.           dwplaycammyspeech(16025, "M3CA020.wav", 5, 2);
  404.           }
  405.      
  406.           
  407.  
  408.      else if ( (lower_left_spindle == bin) && (lower_right_spindle == bin) && (upper_left_spindle != bin) && (upper_right_spindle != bin) )  
  409.           {  // case 1 solution for lock 1, but not this one
  410.           print("case1");
  411.           lower_left_spindle_d  = 0;
  412.           lower_right_spindle_d = 0;
  413.           upper_left_spindle_d  = 0;
  414.           upper_right_spindle_d = 0;
  415.           //permanent ones:
  416.           big_gear_vert_d = 0;     //none of the permenant gears move      
  417.           big_gear_hori_d = 0;         
  418.           med_gear_vert_d = 0;
  419.  
  420.           // TODO:  GRIND THE MOTOR FOR A LITTLE BIT
  421.           PlaySoundThing(grind, med_gear_vert, 1, -1, -1, 0);
  422.           dwplaycammyspeech(16025, "M3CA020.wav", 5, 2);
  423.           }
  424.      else if ( (lower_left_spindle == bin) && (lower_right_spindle == bin) && (upper_left_spindle != bin) && (upper_right_spindle != bin) )  
  425.           {  // case 2 solution for lock 1, but not this one
  426.           print("case2");
  427.           lower_left_spindle_d  = 0;
  428.           lower_right_spindle_d = 0;
  429.           upper_left_spindle_d  = 0;
  430.           upper_right_spindle_d = 0;
  431.           //permanent ones:
  432.           big_gear_vert_d = 0;     //none of the permenant gears move      
  433.           big_gear_hori_d = 0;         
  434.           med_gear_vert_d = 0;
  435.           
  436.           // TODO:  GRIND THE MOTOR A LITTLE BIT
  437.           PlaySoundThing(grind, med_gear_vert, 1, -1, -1, 0);
  438.           dwplaycammyspeech(16025, "M3CA020.wav", 5, 2);
  439.           }
  440.           
  441.      else //set up so that something will spin (at least the motor gear: p_med_gear_vert)
  442.           { // ++++++ set motion/direction
  443.           //med_gear_vert = 0; // assume that if the motor gear is going to move, the below lines will set it that way
  444.           
  445.           if ( (lower_right_spindle != bin) && (upper_right_spindle != bin) )
  446.           { // there are no gears in the upper and lower right spindles
  447.           // case 7, 8, 9
  448.           print("case789"); 
  449.           lower_left_spindle_d  = 0;
  450.           lower_right_spindle_d = 0;
  451.           upper_left_spindle_d  = 0;
  452.           upper_right_spindle_d = 0;
  453.           //permanent ones:
  454.           big_gear_vert_d = 0.0;     //no movement
  455.           big_gear_hori_d = 0.0;      //no movement
  456.           med_gear_vert_d = 0.5;      //there's movement!!  COUNTER-CLOCKWISE
  457.           call rotate_gears;
  458.           timermode = 1; // Timermode tells the timer what to do when it's called. 
  459.          settimer(4);
  460.  
  461.           // TODO:  CAMBOT DIALOG
  462.           motorfreei2=PlaySoundthing(motorfree, med_gear_vert, 1, -1, -1, 0x1);
  463.           dwplaycammyspeech(16025, "M3CA020.wav", 5, 2);  
  464.           }
  465.           
  466.           else if ( (lower_left_spindle != bin) && (lower_right_spindle != bin) && (upper_left_spindle != bin) && (upper_right_spindle == bin) )  
  467.           {  // case 11
  468.           print("case11");
  469.           lower_left_spindle_d  = 0;
  470.           lower_right_spindle_d = 0;
  471.           upper_left_spindle_d  = 0;
  472.           upper_right_spindle_d = 0.5;  // gear is in this slot!  CLOCKWISE
  473.           //permanent ones:
  474.           big_gear_vert_d = 0.0;      //none of the permenant gears move      
  475.           big_gear_hori_d = 0.0;         
  476.           med_gear_vert_d = 0.5;     //there's movement!!  COUNTER-CLOCKWISE
  477.           call rotate_gears;
  478.           timermode = 1; // Timermode tells the timer what to do when it's called. 
  479.         settimer(10);
  480.           rotatingi2=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
  481.           dwplaycammyspeech(16026, "M3CA021.wav", 5, 2);
  482.           }
  483.           
  484.           else if ( (lower_left_spindle != bin) && (lower_right_spindle == bin) && (upper_left_spindle != bin) && (upper_right_spindle != bin) )  
  485.           {  // case 12
  486.           print("case12");
  487.           lower_left_spindle_d  = 0;
  488.           lower_right_spindle_d = -0.5;  // gear is in this slot!  CLOCKWISE
  489.           upper_left_spindle_d  = 0;
  490.           upper_right_spindle_d = 0;
  491.           //permanent ones:
  492.           big_gear_vert_d = 0.0;      //none of the permenant gears move      
  493.           big_gear_hori_d = 0.0;         
  494.           med_gear_vert_d = 0.5;     //theres' movement!  COUNTER-CLOCKWISE
  495.           call rotate_gears;
  496.           timermode = 1; // Timermode tells the timer what to do when it's called. 
  497.         settimer(4);
  498.           rotatingi2=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
  499.           sleep(1);
  500.           dwplaycammyspeech(16026, "M3CA021.wav", 5, 2);
  501.           }
  502.  
  503.           else if ( (lower_left_spindle == bin) && (lower_right_spindle != bin) && (upper_left_spindle != bin) && (upper_right_spindle == bin) )  
  504.           {  // case 13
  505.           print("case13");
  506.           lower_left_spindle_d  = 0;    // gear is in this slot!  NO MOVEMENT
  507.           lower_right_spindle_d = 0;    
  508.           upper_left_spindle_d  = 0;    
  509.           upper_right_spindle_d = 0.5;  // gear is in this slot!  CLOCKWISE
  510.           //permanent ones:
  511.           big_gear_vert_d = 0.0;      //none of the permenant gears move      
  512.           big_gear_hori_d = 0.0;         
  513.           med_gear_vert_d = 0.5;     //there's movement! COUNTERCLOCKWISE
  514.           call rotate_gears;
  515.           timermode = 1; // Timermode tells the timer what to do when it's called. 
  516.         settimer(4);
  517.           rotatingi2=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
  518.           sleep(1);
  519.           dwplaycammyspeech(16026, "M3CA021.wav", 5, 2);
  520.           }
  521.  
  522.           else if ( (lower_left_spindle != bin) && (lower_right_spindle == bin) && (upper_left_spindle == bin) && (upper_right_spindle != bin) )  
  523.           {  // case 14
  524.           print("case14");
  525.           lower_left_spindle_d  = 0;
  526.           lower_right_spindle_d = 0.5;  // gear is in this slot!  CLOCKWISE
  527.           upper_left_spindle_d  = 0;    // gear is in this slot!  NO MOVEMENT
  528.           upper_right_spindle_d = 0;
  529.           //permanent ones:
  530.           big_gear_vert_d = 0.0;      //none of the permenant gears move      
  531.           big_gear_hori_d = 0.0;         
  532.           med_gear_vert_d = 0.5;     //there's movement!  COUNTERCLOCKWISE
  533.           call rotate_gears;
  534.           timermode = 1; // Timermode tells the timer what to do when it's called. 
  535.         settimer(4);
  536.           rotatingi2=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
  537.           sleep(1);
  538.           dwplaycammyspeech(16026, "M3CA021.wav", 5, 2);
  539.           }
  540.  
  541.           else if ( (lower_left_spindle != bin) && (lower_right_spindle != bin) && (upper_left_spindle == bin) && (upper_right_spindle == bin) )  
  542.           {  // case 15
  543.           print("case15");
  544.           lower_left_spindle_d  = 0;
  545.           lower_right_spindle_d = 0;  
  546.           upper_left_spindle_d  = -0.5; // gear is in this slot!  COUNTER-CLOCKWISE
  547.           upper_right_spindle_d = 0.5;  // gear is in this slot!  CLOCKWISE
  548.           //permanent ones:
  549.           big_gear_vert_d = 0.0;      //none of the permenant gears move      
  550.           big_gear_hori_d = 0.0;         
  551.           med_gear_vert_d = 0.5;     //there's movement!  COUNTER-CLOCKWISE
  552.           call rotate_gears;
  553.           timermode = 1; // Timermode tells the timer what to do when it's called. 
  554.         settimer(4);
  555.  
  556.           rotatingi2=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
  557.           sleep(1);
  558.           dwplaycammyspeech(16026, "M3CA021.wav", 5, 2);
  559.           }
  560.  
  561.           else if ( (lower_left_spindle == bin) && (lower_right_spindle != bin) && (upper_left_spindle == bin) && (upper_right_spindle == bin) )  
  562.           {  // case 10 SOLUTION FOR LOCK #2
  563.           print("case10!");
  564.           lower_left_spindle_d  = -0.5; // gear is in this slot!  CLOCKWISE
  565.           lower_right_spindle_d = 0; 
  566.           upper_left_spindle_d  = -0.5; // gear is in this slot!  COUNTER-CLOCKWISE
  567.           upper_right_spindle_d = 0.5;  // gear is in this slot!  CLOCKWISE
  568.           //permanent ones:             
  569.           big_gear_vert_d = 0.5;      // there's movement!  COUNTER-CLOCKWISE        
  570.           big_gear_hori_d = -0.5;      // there's movement!  COUNTER-CLOCKWISE
  571.           med_gear_vert_d = 0.5;     // there's movement!  COUNTER-CLOCKWISE 
  572.           call rotate_gears;
  573.           MoveToFrame(lock, 1, 0.32);
  574.           SetWallCel(sign0, 0); //LL
  575.           sendmessage(watermove2, user1);
  576.           //sendmessage(watermove3, user1);   //tells wm3 to show water at right time
  577.           sendmessage(pipemove, user1);
  578.           sendmessage(ecam, user1);
  579.           sendmessage(rdroid, user4);
  580.           sendmessage(maps, user2); //sent to maps.cog
  581.           sendmessage(waterfall, user3);
  582.           sendmessage(tank_button2_cog, user6); //tells tank_button2_cog to turn off itself
  583.           sendmessage(arrows, user1);
  584.           //rotatingi2=PlaySoundThing(rotating, med_gear_vert, 0.5, -1, -1, 0x1);
  585.           rotatingi2=PlaySoundlocal(rotating, 0.7, 0, 0x1);
  586.           dwplaycammyspeech(16029, "M3CA024.wav", 5, 2);
  587.           }
  588.  
  589.           Printint (lower_left_spindle);
  590.           printflex(lower_left_spindle);
  591.      
  592.      //if (med_gear_vert_d > 0)  // if the permenant motor gear is rotating COUNTER-CLOCKWISE
  593.      //     {
  594.      //     if (GetCurFrame(lock) != 0)  
  595.      //          {
  596.      //          print("lock move");
  597.      //          MoveToFrame(lock, 1, speed);
  598.      //          call rotate_gears;                  
  599.      //          }   
  600.      //     }          
  601.  
  602.      }
  603.      return;
  604.      
  605.  
  606. ##================
  607. handle_lower_left:
  608.      // handle lower left is used to put gears on the lower left side of the assembly.
  609.      print("handle_lower_left");
  610.      if (lower_left_spindle == 0)  // if the lower left spindle is empty
  611.           {
  612.           // adds whatever you gots to the spindle
  613.           if (dwGetActivateBin() == 27)  // if it's the "bin" gear
  614.                {
  615.                // 3 things happen:  1st variable lower_left_spindle is set to the gear that's going to go on the spindle
  616.                // The bin number from the gear is used to represent what gear is on the spindle.    
  617.                // If lower_left_spindle is set to 0, then there should be no gear on the spindle.  If a non-zero #, 
  618.                // it represents the present gear's bin number.
  619.                lower_left_spindle = dwGetActivateBin();
  620.                print ("l_l_gear_on");
  621.                // creating the gear to be attached on the spindle
  622.                lower_left_spindle_i = creatething (med_gear_t, lower_left_spindle_g);
  623.                ChangeInv(getlocalplayerthing(), lower_left_spindle, -1);
  624.                playsoundlocal(gearon, 1, 0, 0);
  625.                call update_bins;
  626.                }
  627.           }
  628.      else
  629.           {
  630.                //dwsetmissiontext(17304);  // cambot:  there's something on the spindle already!
  631.           timermode = 2;
  632.           settimer(10);
  633.           }
  634.      return;
  635.      
  636. ##=================     
  637. handle_lower_right:
  638.      // handle lower right is used to put gears on the lower right side of the assembly.
  639.      print("handle_lower_right");
  640.      if (lower_right_spindle == 0)  // if the lower right spindle is empty
  641.           {
  642.           // adds whatever you gots to the spindle
  643.           if (dwGetActivateBin() == 27)  // if it's the "bin" gear
  644.                {
  645.                //read desc for handle_lower_left to understand.
  646.                lower_right_spindle = dwGetActivateBin();
  647.                print ("l_r_gear_on");
  648.                // creating the gear to be attached on the spindle
  649.                lower_right_spindle_i = creatething (med_gear_t, lower_right_spindle_g);
  650.                ChangeInv(getlocalplayerthing(), lower_right_spindle, -1);
  651.                playsoundlocal(gearon, 1, 0, 0);
  652.                call update_bins;
  653.                }    
  654.           }
  655.      else
  656.           {
  657.                //dwsetmissiontext(17304);  // cambot:  there's something on the spindle already!
  658.                
  659.           timermode = 2;
  660.           settimer(10); 
  661.           }
  662.      return;
  663.      
  664. ##=================     
  665. handle_upper_left:
  666.      // handle upper left is used to put gears on the upper left side of the assembly.
  667.      print("handle_upper_left");
  668.      if (upper_left_spindle == 0)  // if the upper left spindle is empty
  669.           {
  670.           // adds whatever you gots to the spindle
  671.           if (dwGetActivateBin() == 27)  // if it's the "bin" gear
  672.                {
  673.                //read desc for handle_lower_left to understand.
  674.                upper_left_spindle = dwGetActivateBin();
  675.                print ("u_l_gear_on");
  676.                // creating the gear to be attached on the spindle
  677.                upper_left_spindle_i = creatething (med_gear_t, upper_left_spindle_g);
  678.                ChangeInv(getlocalplayerthing(), upper_left_spindle, -1);
  679.                playsoundlocal(gearon, 1, 0, 0);
  680.                call update_bins;
  681.                }    
  682.           }
  683.      else
  684.           {
  685.                //dwsetmissiontext(00000);  // cambot:  there's something on the spindle already!
  686.                
  687.           timermode = 2;
  688.           settimer(10); 
  689.           }
  690.      return;      
  691.  
  692. ##=================     
  693. handle_upper_right:
  694.      // handle upper right is used to put gears on the upper right side of the assembly.
  695.      print("handle_upper_right");
  696.      if (upper_right_spindle == 0)  // if the upper right spindle is empty
  697.           {
  698.           // adds whatever you gots to the spindle
  699.           if (dwGetActivateBin() == 27)  // if it's the "bin" gear
  700.                {
  701.                //read desc for handle_lower_left to understand.
  702.                upper_right_spindle = dwGetActivateBin();
  703.                print ("u_r_gear_on");
  704.                upper_right_spindle_i = creatething (med_gear_t, upper_right_spindle_g);
  705.                ChangeInv(getlocalplayerthing(), upper_right_spindle, -1);
  706.                playsoundlocal(gearon, 1, 0, 0);
  707.                call update_bins;
  708.                }    
  709.           }
  710.      else
  711.           {
  712.                //dwsetmissiontext(17304);  // cambot:  there's something on the spindle already!
  713.                
  714.           timermode = 2;
  715.           settimer(10); 
  716.           }
  717.      return;
  718.  
  719. ##==================
  720. rotate_gears:
  721.      //This routine starts the gears a spinnin.  After they continue, use "continue_gears:"
  722.      call adjoinon;
  723.      xrotate = 1;
  724.      RotatePivot(med_gear_vert, 1, 0.5);  //  permanent motor gear COUNTERCLOCKWISE.
  725.      print ("rotate_gears");
  726.      printint(lower_left_spindle_d);
  727.      if (!(lower_left_spindle_d == 0.0))     RotatePivot(lower_left_spindle_i,  1, lower_left_spindle_d);
  728.      if (!(lower_right_spindle_d == 0.0))    RotatePivot(lower_right_spindle_i, 1, lower_right_spindle_d);
  729.      if (!(upper_left_spindle_d == 0.0))     RotatePivot(upper_left_spindle_i,  1, upper_left_spindle_d);
  730.      if (!(upper_right_spindle_d == 0.0))    RotatePivot(upper_right_spindle_i, 1, upper_right_spindle_d);
  731.      // and the permanent ones:
  732.      //if (!(med_gear_vert_d == 0.0))          RotatePivot(med_gear_vert, 1, med_gear_vert_d);
  733.      if (!(big_gear_vert_d == 0.0))          RotatePivot(big_gear_vert, 1, big_gear_vert_d);
  734.      if (!(big_gear_hori_d == 0.0))          RotatePivot(big_gear_hori, 1, big_gear_hori_d);
  735.      if (!(med_gear_vert_d == 0.0))          RotatePivot(med_gear_vert, 1, med_gear_vert_d);
  736.      return;
  737.     
  738.     
  739. ##====================
  740. continue_gears:
  741.      //print("continue_gears");
  742.      //printint(getsenderid());
  743.      if (!(lower_left_spindle_d == 0.0))     RotatePivot(lower_left_spindle_i,  1, lower_left_spindle_d);   
  744.      if (!(lower_right_spindle_d == 0.0))    RotatePivot(lower_right_spindle_i,  1, lower_right_spindle_d);   
  745.      if (!(upper_left_spindle_d == 0.0))     RotatePivot(upper_left_spindle_i,  1, upper_left_spindle_d);   
  746.      if (!(upper_right_spindle_d == 0.0))    RotatePivot(upper_right_spindle_i,  1, upper_right_spindle_d);   
  747.      // and the permanent ones:
  748.      if (!(med_gear_vert_d == 0.0))          RotatePivot(med_gear_vert, 1, med_gear_vert_d);
  749.      if (!(big_gear_vert_d == 0.0))          RotatePivot(big_gear_vert, 1, big_gear_vert_d);               
  750.      if (!(big_gear_hori_d == 0.0))          RotatePivot(big_gear_hori, 1, big_gear_hori_d);
  751.      return;
  752.  
  753. ##===================
  754. stop_gears:
  755.      //this routine will hopefully stop all the gears...  hopefully...
  756.      call adjoinoff;
  757.      playsoundlocal(fin, 1, 0, 0);
  758.      stopthing(lower_left_spindle_i);
  759.      stopthing(lower_right_spindle_i);
  760.      stopthing(upper_left_spindle_i);
  761.      stopthing(upper_right_spindle_i);
  762.      stopthing(big_gear_vert);
  763.      stopthing(big_gear_hori);
  764.      stopthing(med_gear_vert);     // motor gear
  765.      xrotate = 0;
  766.      stopsound(motorfreei2, 0.5);
  767.      stopsound(rotatingi2, 0.5);
  768.      stopsound(closingi2, 0.5);
  769.      sendmessage(tank_button_cog, user0);
  770.      return;
  771.      
  772. ##====================
  773. arrived:
  774.      if ((GetSenderId() != 3) && (xrotate == 1))
  775.           {
  776.           print("I arrived");
  777.           call continue_gears;
  778.           }
  779.           
  780.      if (GetSenderId() == 3)
  781.           {
  782.           call stop_gears;
  783.           //dwsetmissiontext(00000);  //clears cambot's text
  784.           xrotate = 0;
  785.           }
  786.      return;
  787.      
  788. ##=====================
  789. timer:
  790.      if (timermode == 1) // will turn off the gears
  791.           {
  792.           call stop_gears;
  793.           xrotate = 0;
  794.           }
  795.      else if (timermode == 2)  // will clear cambot's text
  796.           {
  797.                //dwsetmissiontext(00000);  //clears cambot's text
  798.           }
  799.      return;
  800.      
  801. ##======================
  802. update_bins:
  803.   //this is a utility routine used to turn on and off availability of items.  
  804.   // Until Jon B. adds it into DW.
  805.   playsoundlocal(gearoff, 1, 0, 0);
  806.         if ( getinv(getlocalplayerthing(),bin) > 0) SetInvAvailable(getlocalplayerthing(), bin, 1); //if the bin has more than 0 turn on the inv icon; 
  807.     else SetInvAvailable(getlocalplayerthing(), bin, 0);    // else turn it off;
  808.     return;
  809.                
  810. adjoinon:
  811.      clearadjoinflags(s1, 2);
  812.      clearadjoinflags(s2, 2);
  813.      clearadjoinflags(s3, 2);
  814.      clearadjoinflags(s4, 2);
  815.      return;
  816.      
  817. adjoinoff:
  818.      setadjoinflags(s1, 2);
  819.      setadjoinflags(s2, 2);
  820.      setadjoinflags(s3, 2);
  821.      setadjoinflags(s4, 2);
  822.      return;
  823.     
  824. end
  825.             
  826.             
  827.             
  828.  
  829.