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

  1. # Droids Cog Script
  2. #
  3. # D0_skyway.cog
  4. #
  5. # Skyways cog
  6. #
  7. #                                                      
  8. #
  9. #
  10. # [MT]
  11. #
  12. #
  13. # (C) 1997 LucasLearningLimited. All Rights Reserved
  14.  
  15.  
  16.  
  17. symbols                     
  18. message             startup     
  19. message             activate
  20. message             arrived
  21. message             pulse
  22. message             timer
  23. message             user0                              //Countdown is done
  24. message             user1                              //Create fake crate
  25. message             user4                              //destroy the crate (attached to funky tram)
  26. message             user5                              //okay to call another crate
  27.  
  28. surface             adjustswitch        linkid=2       //rotates the catapult                    
  29. surface             destructionfloor0   mask=0x004
  30. surface             destructionfloor1   mask=0x004
  31. surface             destructionfloor2   mask=0x004
  32. surface             fakelever           linkid=1       //launches the crate 
  33. surface             add_sand            linkid=10
  34. surface             rem_sand            linkid=4
  35. surface             led_ones            nolink
  36. surface             led_tens            nolink
  37. surface             led_hund            nolink
  38. surface             callregcrate        linkid=6
  39.  
  40. sector              destructionsector          
  41. sector              curplayersector
  42. sector              ds2
  43. sector              ds3
  44.  
  45. thing               catapult
  46. thing               minecart            linkid=3
  47. thing               catapult0
  48. thing               catapult1
  49. thing               catapult2
  50. thing               catapult3
  51. thing               catapult4
  52. thing               catapult5
  53. thing               smallcrate          local
  54. thing               player              local 
  55. thing               createcrateghost 
  56.  
  57. template            ADcratetemplate
  58.  
  59. cog                 callcratecog
  60.  
  61. //template              explosion_tpl=+grenade_exp    
  62.  
  63. flex                md_power=10.0       local
  64. flex                c_dest=10.0         local
  65. flex                sand_inc=5.0         local
  66. flex                payloadweight       local
  67. flex                playerweight        local
  68. flex                timecount           local
  69. int                 callcrate=0         local
  70. int                 crateisinworld=0    local
  71. int                 launch=0            local
  72. int                 cratev              local
  73. int                   step=10             local
  74. vector              catvel              local        
  75.  
  76. thing               anglecamera
  77. thing               launchcamera
  78.  
  79. sound               t1catlaunch
  80. sound               t1caton
  81. sound               t1catreset
  82. sound               t1catwarmup
  83. sound               texplo01            
  84. sound               clicksound  
  85.                 
  86. template              explosion_tpl=+grenade_exp 
  87. surface             CRMface             linkid=2
  88. surface             fakeadd_sand1       linkid=10
  89. surface             fakeadd_sand2       linkid=10
  90. surface             fakerem_sand1       linkid=4
  91. surface             fakerem_sand2       linkid=4
  92. sound               switchsound=swt00ltswch1.wav   
  93. sound               dave=mcht1ctrsetstp.wav 
  94. end
  95.  
  96. ## Code Section
  97. code    
  98. startup:
  99.      setwallcel(callregcrate, 0);
  100.      player=getlocalplayerthing();
  101.      attachthingtothing(minecart, catapult);
  102.      callcrate=0;
  103.      crateisinworld=0;
  104.      launch=0;
  105.      donotlaunch=0;
  106.      md_power=10.0; 
  107.      magcrate=0;     
  108.      setwallcel(CRMface, 1);
  109.      sleep(3);
  110.      call displayweight;
  111.      setwallcel(fakelever, 1);
  112. #     call user1;
  113.      return;
  114.      
  115. pulse:
  116.      if ((getthingsector(crate))==destructionsector) {
  117.           print("sorry, no");
  118.           call destroycrate;
  119.      }       
  120.      if ((getthingsector(crate))==ds2) {
  121.           print("closer, but no");
  122.           call destroycrate;
  123.      }          
  124.      if ((getthingsector(crate))==ds3) {
  125.           print("oh drat.  almost there.");
  126.           call destroycrate;
  127.      }               
  128.      return;
  129.      
  130. user4:
  131.      print("it's going well...");
  132.      destroything(crate);
  133.      setpulse(0);
  134.      return;
  135.      
  136. destroycrate:
  137.      print("destroying crate");
  138.      setpulse(0);
  139.      exsector=getthingsector(crate);
  140.      expos=getthingpos(crate);
  141.      createthingatpos(explosion_tpl, exsector, expos, '0,0,0');  
  142.      destroything(crate);
  143.      playsoundpos(tExplo01, expos, 1, -1, 80, 0);     
  144.      callcrate=0;
  145.      crateisinworld=0;
  146.      setwallcel(callregcrate, 0);           
  147.      return;
  148.  
  149. user5:     
  150.      print("special destroying crate");
  151.      callcrate=0;
  152.      crateisinworld=0;
  153.      setwallcel(callregcrate, 0);           
  154.      return;
  155.  
  156. getpayloadweight:
  157.      if (crateisinworld==1) payloadweight=730;
  158.      return;               
  159.  
  160. arrived:
  161. //if the mine cart has arrived at the end of the catapult, launch the crate
  162.      if (getsenderid()==3) {   
  163.           if (donotlaunch==1) {               
  164.                playsoundthing(dave, minecar, 1, -1, -1, 0);
  165.                return;
  166.           }            
  167.           playsoundthing(t1catreset, minecar, 1, 10, 20, 0);
  168.           if ((launch==1)&&(crateisinworld==0)&&(getsectorplayercount(curplayersector)!=1)) {
  169.                call launchnothing;
  170.                return;
  171.           }
  172.           launch=1;
  173.           call getpayloadweight;                         
  174.           if ((getcurframe(catapult))==0) {
  175.                catvel=computecatapultvelocity(payloadweight, catapult0, catapult1, catpower);           
  176.                skiptoframe(minecart, 0, 3);
  177.                if (crateisinworld==1) call launchcrate;          
  178.             }
  179.           else if ((getcurframe(catapult))==1) {
  180.                skiptoframe(minecart, 2, 3);
  181.                catvel=computecatapultvelocity(payloadweight, catapult2, catapult3, catpower);                  
  182.                if (crateisinworld==1) call launchcrate;                
  183.           }
  184.           else if ((getcurframe(catapult))==2) { 
  185.                skiptoframe(minecart, 4, 3);           
  186.                catvel=computecatapultvelocity(payloadweight, catapult4, catapult5, catpower);                  
  187.                if (crateisinworld==1) call launchcrate;           
  188.           }        
  189.      }            
  190.      else if (getsenderref()==catapult) {
  191.           if (getcurframe(catapult)==0) setwallcel(adjustswitch, 0);
  192.           if (getcurframe(catapult)==1) setwallcel(adjustswitch, 1);
  193.           if (getcurframe(catapult)==2) setwallcel(adjustswitch, 2);
  194. //          playsoundthing(t1catadjstop, catapult, 1, -1, -1, 0);
  195. //          stopsound(channel22, 0.5);             
  196.           setwallcel(CRMface, 1);
  197.      }
  198.      return;
  199.      
  200. launchnothing:
  201.           print("launchnothing");
  202.           donotlaunch=1;
  203.           if ((getcurframe(catapult))==0) {         
  204.                skiptoframe(minecart, 0, 3);
  205.           }
  206.           else if ((getcurframe(catapult))==1) {
  207.                skiptoframe(minecart, 2, 3);
  208.           }
  209.           else if ((getcurframe(catapult))==2) { 
  210.                skiptoframe(minecart, 4, 3);           
  211.           }        
  212.           return;
  213.      
  214.  
  215. //launches the minecar   
  216. launchit:
  217.      print("launchitcalled");          
  218.      launchchannel=playsoundthing(t1catlaunch, minecar, 1, 10, 20, 0);
  219.      call cameracheck;
  220.      if ((getcurframe(catapult))==0) skiptoframe(minecart, 1, 29.17);
  221.      else if ((getcurframe(catapult))==1) skiptoframe(minecart, 3, 29.17);
  222.      else if ((getcurframe(catapult))==2) skiptoframe(minecart, 5, 29.17);                 
  223.      stopsound(warmupchannel, 0.5);      
  224.      setthingmass(crate, 730);      
  225.      return;
  226.      
  227. cameracheck:
  228.      dwfreezeplayer();
  229.      if (crateisinworld==1) setcamerafocii(2, crate, launchcamera);
  230.      else if (crateisinworld==0) setcamerafocii(2, minecart, launchcamera);
  231.      setcurrentcamera(2);
  232.      setTimerEX(4, 3, 0, 0);
  233.      return;
  234.      
  235.  
  236. //create the true crate out of thin air     
  237. user1:
  238.      print("creating cType crate");
  239.      crate=creatething(ADcratetemplate, createcrateghost);     
  240.      setwallcel(fakelever, 0);
  241.      settimerEX(2, 5, 0, 0);
  242.      return;     
  243.  
  244. activate:  
  245.      //start the launch sequence to move the minecar.
  246.      if (getsenderid()==1) {
  247.           if (getwallcel(fakelever)==1) return;          
  248.  
  249.           else {
  250.                donotlaunch=0;
  251.                setwallcel(fakelever, 1);
  252. //               sendmessage(countdowncog, user0);
  253. //               settimerEX(6,1,0,0);
  254.                warmupchannel=playsoundthing(t1catwarmup, minecar, 1, 10, 20, 0x1);
  255.                playsoundthing(t1caton, minecar, 1, 10, 20, 0);               
  256.                call launchit; 
  257.           }
  258.       }
  259.      //move (rotate) the catapult
  260.      else if (getsenderid()==2) {
  261.           if ( (isthingmoving(catapult)!=0)||(isthingmoving(minecar)!=0) ) return;
  262.           else {                    
  263.                playsoundpos(switchsound, getsurfacecenter(adjustswitch), 1.0, -1, -1, 0);
  264.                setwallcel(CRMface, 0);
  265.                setwallcel(adjustswitch, 1);               
  266. //               channel22=playsoundthing(t1catadjloop, catapult, 1.0, -1, -1, 0x1);
  267.                if ((getcurframe(catapult))==0) movetoframe(catapult, 1, 0.3);
  268.                else if ((getcurframe(catapult))==1) movetoframe(catapult, 2, 0.3);
  269.                else if ((getcurframe(catapult))==2) movetoframe(catapult, 0, 0.3);
  270.                call rotatecamera;
  271.           }
  272.      }
  273.      else if (GetSenderId() == 10)  call sand_add;     
  274.      else if (GetSenderId() == 4)  {
  275.           call sand_rem;     
  276.      }
  277.      else if ( (getsenderid() ==5)||(getsenderid() ==6) ) {
  278.           if (getwallcel(callregcrate)==1) return;
  279.           playsoundpos(switchsound, getsurfacecenter(callregcrate), 1.0, -1, -1, 0);
  280.           call callcrates;
  281.      }
  282.      return;
  283.      
  284. rotatecamera:
  285.      dwfreezeplayer();
  286.      setcamerafocii(2, catapult, anglecamera);
  287.      setcurrentcamera(2);
  288.      setTimerEX(4, 3, 0, 0);
  289.      return;
  290.        
  291. callcrates:
  292.      //bring in a small crate
  293.      setwallcel(callregcrate, 1);    
  294.      sendmessage(callcratecog, user1);
  295.      truecratetype=0;
  296.      call nocrates;
  297.      return;
  298.  
  299. timer:
  300.      if (getsenderid()==2) {
  301.          md_power = md_power + sand_inc;
  302.          if (md_power < step) {
  303.              SetWallCel(add_sand, 0);
  304.              SetWallCel(rem_sand, 0);
  305.              md_power = step;
  306.              
  307.              }
  308.           else if (md_power>100) {
  309.                SetWallCel(add_sand,0);
  310.                SetWallCel(rem_sand,0);
  311.                md_power=100;
  312.           }
  313.          
  314.          else if (md_power == c_dest)        {
  315.              SetWallCel(add_sand, 0);
  316.              SetWallCel(rem_sand, 0);
  317.              }
  318.      
  319.           else {
  320.                SetTimerEX(0.02,2,0,0);
  321.           }
  322.            call displayweight;
  323.      }
  324. //     else if (getsenderid()==1) {
  325. //          setwallcel(fakelever, 0);
  326. //     }
  327.      else if (getsenderid()==3) {
  328.           setcurrentcamera(7);
  329.           dwunfreezeplayer();
  330.      }
  331.      else if (getsenderid()==5) setthingmass(crate, 730);
  332.      return;
  333.        
  334. nocrates:
  335.      launch=0;
  336.      callcrate=1; 
  337.      crateisinworld=1;
  338.      setwallcel(callsmallcrate,1);
  339.      setwallcel(callbigcrate,1);
  340.      return;
  341.  
  342. launchcrate:
  343.      print("launching crate");
  344.      print("payload weight is");
  345.      printflex(payloadweight);
  346.      print("catvel is");
  347.      printvector(catvel);
  348.      donotlaunch=1;
  349.      callcrate=0;
  350.      detachthing(crate);
  351.      setthingvel(crate, catvel);
  352.      setwallcel(callsmallcrate,0);
  353.      setwallcel(callbigcrate,0);
  354.      call getpulsetime;
  355.      printflex(pulsetime);
  356.      setpulse(pulsetime);
  357.      print("catpower is ");
  358.      printint(catpower);
  359.      return;
  360.      
  361. getpulsetime:
  362.      pulsetime=0.25;
  363.      return; 
  364.   
  365.      
  366. sand_add:
  367.       if (GetWallCel(add_sand) != 1)    //Nothing's already happening
  368.      {
  369.      SetWallCel(add_sand, 1);
  370.      sand_inc = 1;
  371.      c_dest = md_power + step;
  372.      SetTimerEX(0.02,2,0,0);
  373.      }
  374.      return;
  375.      
  376. sand_rem:
  377.      if (GetWallCel(rem_sand) != 1)    //Nothing's already happening
  378.           {
  379.           SetWallCel(rem_sand, 1);
  380.           sand_inc = -1;
  381.           c_dest = md_power - step;
  382.           SetTimerEX(0.02,2,0,0);
  383.           }
  384.      return;
  385.      
  386. displayweight:
  387.      playsoundpos(clicksound, getsurfacecenter(led_tens), 0.3, -1, -1, 0);
  388.      SetWallCel(led_ones, md_power %  10);
  389.      SetWallCel(led_tens, (md_power / 10) % 10);
  390.      SetWallCel(led_hund, (md_power / 100) % 10);
  391.      catpower=(md_power/100)*12500;
  392.      return;
  393.  
  394.  
  395.  
  396.  
  397.                      
  398. end
  399.  
  400.  
  401.  
  402.  
  403.