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