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

  1. #
  2. # CC_Laser.cog
  3. #
  4. # Crystal Information Center Laser script
  5. #
  6. # 03/24/98 DGS Created. 
  7. #
  8. #GOAL 0 3 reflect lasers onto crystals
  9. #GOAL 0 1 contact Jawa on duty
  10. #GOAL 0 2 view crystal information
  11. # (C) 1998 Lucas Learning Limited All Rights Reserved
  12. # ========================================================================================
  13.  
  14. symbols
  15. ## ================ Messages
  16. message        Startup
  17. message        activated
  18. message     pulse
  19. message        User0
  20. message        User1
  21. message     timer
  22. ## ================ Surfaces
  23. surface        Switch0_s               linkid=5
  24. surface        Switch1_s               linkid=5
  25. surface        Switch2_s               linkid=5
  26. surface        Switch3_s               linkid=5
  27. surface        Switch4_s               linkid=5
  28. surface        Switch5_s               linkid=5
  29. surface      crystal_0a_s           linkid=7
  30. surface      crystal_0b_s        linkid=7
  31. surface      crystal_1a_s        linkid=7
  32. surface      crystal_1b_s        linkid=7
  33. surface      crystal_3a_s        linkid=7
  34. surface      crystal_3b_s        linkid=7
  35. surface      crystal_4a_s        linkid=7
  36. surface      crystal_4b_s        linkid=7
  37. surface      crystal_7a_s        linkid=7
  38. surface      crystal_7b_s        linkid=7
  39.  
  40. ## ================ Sectorz
  41. sector      crystal_0a_z
  42. sector      crystal_0b_z
  43. sector      crystal_1a_z
  44. sector      crystal_1b_z
  45. sector      crystal_3a_z
  46. sector      crystal_3b_z
  47. sector      crystal_4a_z
  48. sector      crystal_4b_z
  49. sector      crystal_7a_z
  50. sector      crystal_7b_z
  51.  
  52.  
  53. ## ================ Things
  54. thing        laser_g
  55. thing        laser_i                local
  56. thing         camera0_g
  57.  
  58.  
  59. #=================== Sounds
  60.  
  61. sound        laser_snd=AMB04Pulse.WAV        local
  62. sound        cry_snd=AMB02LaserLp.WAV        local
  63. sound        act_snd=SWT00LtSwch1.WAV        local        
  64. sound        act2_snd=SWT00DrSwtch.WAV        local
  65. sound        deact_snd=SWT00LtSwch2.WAV        local        
  66. # ================= Misc. Variables
  67. int            counter=0            local
  68. int            l_color=1            local
  69. flex        l_radius=0.005        local
  70. flex        f_speed=0.25        local
  71. int            active_crystal=0    local
  72. int            active_sector=0        local
  73. int            s_light=0            local
  74. int            add_crystal=0        local
  75. int            see1=0                local
  76. int            see2=0                local
  77. int            see3=0                local
  78. int            got1=0                local
  79. int            got2=0                local
  80. int            got3=0                local
  81. int            got4=0                local
  82. int            got5=0                local
  83. int            got6=0                local
  84. int            got7=0                local
  85. int            got8=0                local
  86. int            got9=0                local
  87. int            got10=0                local
  88.  
  89. end
  90.  
  91. # ========================================================================================
  92.  
  93. code
  94. startup:
  95.     player=getlocalplayerthing();
  96.     //add_crystal = 3;
  97.     laser_i = 0;    
  98.     global9 = 0;
  99.     ///active_crystal = crystal_0a_s;
  100.     //setpulse(f_speed);
  101.     //REQUIREMENT 0 4 head with vocabulator
  102.     if (dwCheckDroidCaps(1048576)) SetInv(player, 4, 1);// if droid has a vocab
  103.     if ( (getinv(player, 34)>0)&&(getinv(player, 35)>0)&&(getinv(player, 36)>0) )  setinv(player, 5, 1);
  104.     return;
  105.  
  106. activated:
  107.     // This routine hangles getting the click from the user, and then turning the laser on or off. 
  108.     // It also handles figureing out which crys
  109.     if ( getsenderid() == 5)        // iF the player pressed the laser activate button
  110.         {
  111.         if (laser_i == 0) call laser_on;
  112.         else call laser_off;
  113.         }
  114.     else if (active_crystal > 0) //else if a crystal's active       
  115.         {
  116.         if ((getsenderref() == crystal_0a_s) && (active_crystal == crystal_0a_s))
  117.             {
  118.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  119.             sleep(1);
  120.             print("Activate Movie 0a");
  121.             dwPlayMovie("SEcrystal01.san"); 
  122.             SetInv(player, 2, 1);                
  123.             sleep(1);
  124.             }
  125.         if ((getsenderref() == crystal_0b_s) && (active_crystal == crystal_0b_s))
  126.             {
  127.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  128.             sleep(1);
  129.             print("Activate Movie 0b");
  130.             dwPlayMovie("crystal01.san"); 
  131.             SetInv(player, 2, 1);                
  132.             sleep(1);
  133.             if (see1 == 0) 
  134.                 {
  135.                 see1 = 1;
  136.                 call update_info;
  137.                 }
  138.             }
  139.         if ((getsenderref() == crystal_1a_s) && (active_crystal == crystal_1a_s))
  140.             {
  141.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  142.             sleep(1);
  143.             print("Activate Movie 1a");
  144.             dwPlayMovie("SJcrystal02.san"); 
  145.             SetInv(player, 2, 1);                
  146.             sleep(1);
  147.             // PLay movie
  148.             }
  149.         if ((getsenderref() == crystal_1b_s) && (active_crystal == crystal_1b_s))
  150.             {
  151.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  152.             sleep(1);
  153.             print("Activate Movie 1b");
  154.             dwPlayMovie("SEcrystal02.san"); 
  155.             SetInv(player, 2, 1);                
  156.             sleep(1);
  157.             // PLay movie
  158.             }
  159.         if ((getsenderref() == crystal_3a_s) && (active_crystal == crystal_3a_s))
  160.             {
  161.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  162.             sleep(1);
  163.             print("Activate Movie 3a");
  164.             dwPlayMovie("SWcrystal03.san"); 
  165.             SetInv(player, 2, 1);                
  166.             sleep(1);
  167.             // PLay movie
  168.             }
  169.         if ((getsenderref() == crystal_3b_s) && (active_crystal == crystal_3b_s))
  170.             {
  171.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  172.             sleep(1);
  173.             print("Activate Movie 3b");
  174.             dwPlayMovie("crystal03.san"); 
  175.             SetInv(player, 2, 1);                
  176.             sleep(1);
  177.             if (see2 == 0) 
  178.                 {
  179.                 see2 = 1;
  180.                 call update_info;
  181.                 }
  182.             // PLay movie
  183.             }
  184.         if ((getsenderref() == crystal_4a_s) && (active_crystal == crystal_4a_s))
  185.             {
  186.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  187.             sleep(1);
  188.             print("Activate Movie 4a");
  189.             // PLay movie
  190.             dwPlayMovie("crystal02.san"); 
  191.             SetInv(player, 2, 1);                
  192.             sleep(1);
  193.             if (see3 == 0) 
  194.                 {
  195.                 see3 = 1;
  196.                 call update_info;
  197.                 }
  198.             }
  199.         if ((getsenderref() == crystal_4b_s) && (active_crystal == crystal_4b_s))
  200.             {
  201.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  202.             sleep(1);
  203.             print("Activate Movie 4b");
  204.             dwPlayMovie("SEcrystal03.san");                        //////////////////////THIS IS THE DUPE CRYSTAL
  205.             SetInv(player, 2, 1);                
  206.             sleep(1);
  207.             }
  208.         if ((getsenderref() == crystal_7a_s) && (active_crystal == crystal_7a_s))
  209.             {
  210.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  211.             sleep(1);
  212.             print("Activate Movie 7a");
  213.             dwPlayMovie("SWcrystal01.san"); 
  214.             SetInv(player, 2, 1);                
  215.             sleep(1);
  216.             }
  217.         if ((getsenderref() == crystal_7b_s) && (active_crystal == crystal_7b_s))
  218.             {
  219.             garbage = playsoundlocal(act2_snd,1,0.0,0);
  220.             sleep(1);
  221.             print("Activate Movie 7b");
  222.             dwPlayMovie("SEcrystal03.san");                     //////////////////////THIS IS THE DUPE CRYSTAL
  223.             SetInv(player, 2, 1);                
  224.             sleep(1);
  225.             }
  226.         }
  227.     else
  228.         {
  229.         print("click");
  230.         dwPlayCammySpeech(16037, "M4ca023.wav", 10, 0);// I don't think it worked.    
  231.         }
  232.     return;
  233.  
  234. user0:
  235.     // Called by Mirror cogs to turn the laser off before rotation.
  236.     call laser_off;
  237.     return;
  238.  
  239. user1:
  240.     // This routine is called from the Jawatalking.cog and notifies this cog that another Crystal has been added.
  241.     add_crystal = add_crystal +1;        //This variable keeps track of how many crystals have been added by the Jawa. 
  242.     call laser_off;
  243.     return;    
  244.     
  245. laser_on:
  246.     // This routine controls turning the laser on.
  247.     print("LASER ON");
  248.     laser_i = addlaser(laser_g, l_color, l_radius);
  249.     garbage = playsoundpos(act_snd,getsurfacecenter(getsenderref()),1,-1,-1,0);
  250.     sounder = playsoundlocal(laser_snd,0.5,0.0,1);
  251.     global9 = 1;
  252.     call check_crystal;
  253.     call set_switch;
  254.     return;
  255.  
  256. Laser_off:
  257.     print("OFF");
  258.     // This controls turning the laser off. 
  259.     setpulse(0);
  260.     
  261.     if (active_crystal != 0)      //if a crystal was last hit by the laser
  262.         {
  263.         setwallcel(active_crystal,0);        // turn it's switch off. 
  264.         active_crystal = 0;    
  265.         }
  266.     if (active_sector != 0)        //if crystal sector is lit
  267.         {
  268.         SetSectorLight(active_sector, 0, 1.0);        // remove some light 
  269.         active_sector = 0; 
  270.         }
  271.     print("LASER OFF");
  272.     removelaser(laser_i);
  273.     if (sounder >0) {stopsound(sounder,0.5); sounder = -1;}
  274.     if (crysound >0) {stopsound(crysound,0.5); crysound = -1;}
  275.     garbage = playsoundlocal(deact_snd,1.0,0.0,0);
  276.     
  277.     laser_i = 0;
  278.     global9 = 0;
  279.     call set_switch;
  280.     return;
  281.  
  282. set_Switch:
  283.     //This routine sets any and all switches to the correct state
  284.     setwallcel(switch0_s,global9);
  285.     setwallcel(switch1_s,global9);
  286.     setwallcel(switch2_s,global9);
  287.     setwallcel(switch3_s,global9);
  288.     setwallcel(switch4_s,global9);
  289.     setwallcel(switch5_s,global9);
  290.     return;
  291.  
  292. check_crystal:
  293.     // This routine checks the angle of all the mirrors and turns on the activation switches for each crystal.
  294.     active_crystal = 0;        // Set this to 0 so that if no crystal is being activated this will stay at 0
  295.     if (global8 == -45)        // If the laser's pointed up at towards Chamber 0
  296.         {
  297.         if ((global0 == 40))// Chamber 0, crystal A
  298.             {
  299.             print("Hit 0a");
  300.             if (got1 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
  301.             got1 = 1;
  302.             timermode = 2;
  303.             settimer(10);
  304.             setwallcel(crystal_0a_s,1);
  305.             active_crystal = crystal_0a_s;
  306.             active_sector = crystal_0a_z;
  307.             crysound = playsoundpos(cry_snd,getsectorcenter(crystal_0a_z),1.0,-1,-1,1);
  308.              SetInv(player, 3, 1);                
  309.             setpulse(f_speed);
  310.             }
  311.         else if ((global0 == -20) && (add_crystal > 0)) //Chamber 0, crystal B
  312.             {
  313.             print("Hit 0b");
  314.             if (got2 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
  315.             got2 = 1;
  316.             timermode = 2;
  317.             settimer(10);
  318.             setwallcel(crystal_0b_s,1);
  319.             active_crystal = crystal_0b_s;
  320.             active_sector = crystal_0b_z;
  321.             crysound = playsoundpos(cry_snd,getsectorcenter(crystal_0b_z),1.0,-1,-1,1);
  322.             SetInv(player, 3, 1);                
  323.             setpulse(f_speed);
  324.             }
  325.         else if ((global0 == 0))// Back into itself  
  326.             {
  327.             call overheat;
  328.             }
  329.         }    
  330.     else if (global8 == 0)        // If the laser's pointed east towards Chambers 1,2,4
  331.         {
  332.         if ((global2 == 50))// towards Chamber 1
  333.               {
  334.             if ((global1 == 25))// Chamber 1, crystal A
  335.                 {
  336.                 print("Hit 1a");
  337.                 if (got3 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
  338.                 got3 = 1;
  339.                 timermode = 2;
  340.                 settimer(10);
  341.                 setwallcel(crystal_1a_s,1);
  342.                 active_crystal = crystal_1a_s;
  343.                 active_sector = crystal_1a_z;
  344.                 crysound = playsoundpos(cry_snd,getsectorcenter(crystal_1a_z),1.0,-1,-1,1);
  345.                 SetInv(player, 3, 1);                
  346.                 
  347.                 setpulse(f_speed);
  348.                 }
  349.             else if ((global1 == -25))// Chamber 1, crystal B
  350.                 {
  351.                 print("Hit 1b");
  352.                 
  353.                 //dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
  354.                 if (got4 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
  355.                 got4 = 1;
  356.                 
  357.                 timermode = 2;
  358.                 settimer(10);
  359.                 
  360.                 setwallcel(crystal_1b_s,1);
  361.                 active_crystal = crystal_1b_s;
  362.                 active_sector = crystal_1b_z;
  363.                 crysound = playsoundpos(cry_snd,getsectorcenter(crystal_1b_z),1.0,-1,-1,1);
  364.                 SetInv(player, 3, 1);                
  365.                 
  366.                 setpulse(f_speed);
  367.                 }
  368.             else if ((global1 == 0))// Back into itself  
  369.                 {
  370.                 call overheat;
  371.                 }
  372.             }
  373.         else if ((global2 == -35))// towards Chamber 4
  374.               {
  375.             if ((global4 == 25) && (add_crystal > 1))// Chamber 4, crystal A
  376.                 {
  377.                 print("Hit 4a");
  378.                 
  379.                 if (got5 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
  380.                 got5 = 1;
  381.                 
  382.                 timermode = 2;
  383.                 settimer(10);
  384.             
  385.                 setwallcel(crystal_4a_s,1);
  386.                 active_crystal = crystal_4a_s;
  387.                 active_sector = crystal_4a_z;
  388.                 crysound = playsoundpos(cry_snd,getsectorcenter(crystal_4a_z),1.0,-1,-1,1);
  389.                 SetInv(player, 3, 1);                
  390.                 
  391.                 setpulse(f_speed);
  392.                 }
  393.             else if ((global4 == -35))// Chamber 4, crystal B
  394.                 {
  395.                 print("Hit 4b");
  396.                 if (got6 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
  397.                 got6 = 1;
  398.                 timermode = 2;
  399.                 settimer(10);
  400.                 setwallcel(crystal_4b_s,1);
  401.                 active_crystal = crystal_4b_s;
  402.                 active_sector = crystal_4b_z;
  403.                 crysound = playsoundpos(cry_snd,getsectorcenter(crystal_4b_z),1.0,-1,-1,1);
  404.                 setpulse(f_speed);
  405.                 SetInv(player, 3, 1);                
  406.                 }
  407.             else if ((global4 == 0))// Back into itself  
  408.                 {
  409.                 call overheat;
  410.                 }
  411.             
  412.             }
  413.         else if ((global2 == 0))// Back into itself  
  414.             {
  415.             call overheat;
  416.             }
  417.         
  418.         }
  419.     else if (global8 == 45)        // If the laser's pointed south towards Chambers 3,5,6,7
  420.         {
  421.         if (global6 == 70)    // Towards chamber 7
  422.             {
  423.             if ((global7 == 40))// Chamber 7, crystal A
  424.                 {
  425.                 print("Hit 7a");
  426.                 if (got7 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
  427.                 got7 = 1;
  428.                 timermode = 2;
  429.                 settimer(10);
  430.                 
  431.                 setwallcel(crystal_7a_s,1);
  432.                 active_crystal = crystal_7a_s;
  433.                 active_sector = crystal_7a_z;
  434.                 crysound = playsoundpos(cry_snd,getsectorcenter(crystal_7a_z),1.0,-1,-1,1);
  435.                 SetInv(player, 3, 1);                
  436.                 setpulse(f_speed);
  437.                 }
  438.             else if ((global7 == -35))// Chamber 7, crystal B
  439.                 {
  440.                 print("Hit 7b");
  441.                     
  442.                 //dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
  443.                 if (got8 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
  444.                 got8 = 1;
  445.                 
  446.                 timermode = 2;
  447.                 settimer(10);
  448.             
  449.                 setwallcel(crystal_7b_s,1);
  450.                 active_crystal = crystal_7b_s;
  451.                 active_sector = crystal_7b_z;
  452.                 crysound = playsoundpos(cry_snd,getsectorcenter(crystal_7b_z),1.0,-1,-1,1);
  453.                 SetInv(player, 3, 1);                
  454.                 
  455.                 setpulse(f_speed);
  456.                 }
  457.             else if ((global7 == 0))// Back into itself  
  458.                 {
  459.                 call overheat;
  460.                 }
  461.             
  462.             }
  463.         else if (global6 == -45)    // 6 Towards chambers 3,5
  464.             {
  465.             if (global5 == -60)    // 5 Towards chambers 3
  466.                 {
  467.                 if ((global3 == 40))// Chamber 3, crystal A
  468.                     {
  469.                     print("Hit 3a");
  470.                     if (got10 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
  471.                     got10 = 1;
  472.                     timermode = 2;
  473.                     settimer(10);
  474.             
  475.                     setwallcel(crystal_3a_s,1);
  476.                     active_crystal = crystal_3a_s;
  477.                     active_sector = crystal_3a_z;
  478.                     crysound = playsoundpos(cry_snd,getsectorcenter(crystal_3a_z),1.0,-1,-1,1);
  479.                 SetInv(player, 3, 1);                
  480.                     
  481.                     setpulse(f_speed);
  482.                     }
  483.                 else if ((global3 == -20) && (add_crystal > 2))// Chamber 3, crystal B
  484.                     {
  485.                     print("Hit 3b");
  486.                     if (got9 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
  487.                     got9 = 1;
  488.                     timermode = 2;
  489.                     settimer(10);
  490.                     
  491.                     setwallcel(crystal_3b_s,1);
  492.                     active_crystal = crystal_3b_s;
  493.                     active_sector = crystal_3b_z;
  494.                     crysound = playsoundpos(cry_snd,getsectorcenter(crystal_3b_z),1.0,-1,-1,1);
  495.                 SetInv(player, 3, 1);                
  496.                     
  497.                     setpulse(f_speed);
  498.                     }
  499.                 else if ((global3 == 0))// Back into itself  
  500.                     {
  501.                     call overheat;
  502.                     }
  503.                 
  504.                 }
  505.             else if ((global5 == 0))// Back into itself  
  506.                 {
  507.                 call overheat;
  508.                 }
  509.             
  510.             }
  511.         else if ((global6 == 0))// Back into itself  
  512.             {
  513.             call overheat;
  514.             }
  515.         
  516.         }    
  517.     
  518.     if (active_sector > 0)
  519.         {
  520.         SetSectorLight(active_sector, 1.0, f_speed);        // add some light 
  521.         s_light = 1;
  522.         }
  523.     return;
  524.  
  525. overheat:
  526.     timermode = 1;
  527.     settimer(2);
  528.     return;
  529.  
  530. timer:
  531.     if (timermode == 1)
  532.         {
  533.         call laser_off;
  534.         dwPlayCammySpeech(16024, "M4ca021.wav", 10, 0); //Overheat        
  535.         timermode = 2;
  536.         settimer(10);
  537.         }
  538.     else if (timermode == 2)
  539.         {
  540.         // nothing anymore
  541.         }
  542.         
  543.  
  544.     return;
  545. update_info:
  546.     if (counter == 0)
  547.         {
  548.         counter = 1;
  549.         dwPlayCammySpeech(16034, "M4ca010.wav", 10, 0);// You got it!    
  550.         print("play 1");
  551.         }
  552.     else if (counter == 1)
  553.         {
  554.         counter = 2;
  555.         dwPlayCammySpeech(16035, "M4ca011.wav", 10, 0);// You got it!    
  556.         print("play 1");
  557.         }
  558.     else if (counter == 2)
  559.         {
  560.         counter = 3;
  561.         dwPlayCammySpeech(16036, "M4ca012.wav", 10, 0);// You got it!    
  562.         SetInv(player, 1, 1);                
  563.         print("play 1");
  564.         sleep(23);
  565.         dwendlevel();
  566.         }
  567.         
  568.     return;
  569.  
  570. pulse:
  571.     // Used to cycle the animation of the switches when they're turned on
  572.     if (active_crystal != 0)
  573.         {
  574.         //setwallcel(active_crystal,1);
  575.         setwallcel(active_crystal,1-getwallcel(active_crystal));
  576.         s_light = 1 - s_light;
  577.         setSectorLight(active_sector, s_light, f_speed);
  578.         }
  579. end
  580.  
  581.