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

  1. # Droids COG Script
  2. #
  3. # ZZ_Counterweight.cog
  4. #
  5. # Desc:
  6. #    This behemoth is the counterweight puzzle. Do not taunt it.  
  7. #
  8. # 10/14/97 [DGS]    Created
  9. # 12/01/97 [DGS]    Updated to take droid's actual weight.
  10. #
  11. # ========================================================================================
  12.  
  13. symbols
  14.  
  15. message  crossed
  16. message  activate
  17. message  arrived
  18. message  timer
  19. message  pulse
  20. message  startup
  21. message  entered
  22.  
  23. surface  add_sand       linkid=8
  24. surface  rem_sand       linkid=9
  25.  
  26. surface  led_ones       nolink
  27. surface  led_tens       nolink
  28. surface  led_hund       nolink
  29. surface  release_brake  linkid=10
  30. surface     walkwindow        nolink
  31. cog     sander
  32.  
  33. thing    elevator       linkid=1          nolink
  34. thing    cube               linkid=2
  35. thing    counterweight  linkid=3
  36. thing    brake          linkid=6          nolink
  37.  
  38. thing    line0start 
  39. thing    line0end                        
  40. thing    line1start 
  41. thing    line1end
  42. thing    line2start 
  43. thing    line2end
  44. thing    line3start 
  45. thing    line3end
  46.  
  47. sector       reset_puzzle        linkid=11
  48. sector       reset_puzzle2        linkid=11
  49.  
  50. sound     eloop_snd=ELVt7BigElevLp.WAV        local
  51. sound     ebrake_snd=ELVt7BigElevLp.WAV        local
  52. sound     estart_snd=ELVt7BigElevSt.WAV        local
  53. sound     eend_snd=ELVt7BigElevStp.WAV        local
  54. sound    release_snd=SWT00tBigLvr.WAV        local    
  55. sound    act_snd=SWT00LtSwch1.WAV            local
  56. sound    act2_snd=SWT00LtSwch2.WAV            local
  57. flex         start_wait=0.25                 local
  58. flex         sleeptime=2.0                    local
  59. flex         c_weight=10.0                    local
  60. flex         c_dest=10.0                        local
  61. flex         sand_inc=5.0                    local
  62. flex           gravity=12.0                    local
  63. flex        speed=4.0                        local
  64. int               c_crate=0                        local
  65. int               step=10                            local
  66. int            l_color=111                        local    
  67. int            falling=0                        local
  68. int            maxgamage=25                    local
  69. int            mindamage=30                    local
  70. int            e_switch=0                        local
  71. flex         L_size=0.01                        local    
  72. flex     droidweight=10.0                     local
  73.  
  74.  
  75. end
  76.  
  77. # ========================================================================================
  78.  
  79. code
  80.  
  81. startup:
  82.        addbeam(line0start,line0end,l_color,l_size);
  83.        addbeam(line1start,line1end,l_color,l_size);
  84.        addbeam(line2start,line2end,l_color,l_size);
  85.        addbeam(line3start,line3end,l_color,l_size);
  86.  
  87.     attachthingtothing(line0start,elevator);
  88.     attachthingtothing(line1start,elevator);
  89.     attachthingtothing(brake,elevator);
  90.  
  91.        attachthingtothing(line2start,counterweight);
  92.        attachthingtothing(line3start,counterweight);
  93.  
  94.     droidweight = GetThingMass(GetLocalPlayerThing()) / 2.2;  // Get the player's weight
  95.     //c_weight = (droidweight) + ((rand()*20)-10); // Set th e counterweight to something near the players weight
  96.     //c_weight = (droidweight);  // Set the counterweight to something near the players weight
  97.         
  98.         // ++++++++++++++++++++++++++++++ These lines set the counterweight to a specific number
  99.     if (getdifficulty() == 0) //++++++++++++++++++ EASY
  100.             {
  101.             print("easy");
  102.             c_weight = (150);
  103.             c_crate = 0;
  104.             //destroything(cube);
  105.             }
  106.         else if (getdifficulty() == 1) //++++++++++++++++++ med
  107.             {
  108.             print("Med");
  109.             c_weight = (10);
  110.             c_crate = 100;
  111.             attachthingtothing(cube,elevator);
  112.             }
  113.         else if (getdifficulty() == 2) //++++++++++++++++++ hard
  114.             {
  115.             print("Hard");
  116.             c_weight = (50);
  117.             //c_weight = (droidweight) + ((rand()*droidweight)-(droidweight/2)); // Set th e counterweight to something near the players weight
  118.             c_crate = 140;
  119.             }
  120.         
  121.     c_weight = c_weight - (c_weight % 10);     // Rounds the weight to a 10
  122.     call displayweight;
  123.     return;
  124. crossed:                // If player crosses adjoin(s)
  125.   
  126.   return;
  127.  
  128. # ........................................................................................
  129.  
  130. activate:
  131. print("Cweight: Activated");
  132. printint(getsenderid());
  133. printint(getsenderref());
  134. printint(add_sand);
  135. if (GetSenderId() == 10)          // message came from release_brake
  136.     {
  137.     //--------------------------------------------- RELEASE THE BRAKE
  138.        
  139.     if (GetWallCel(release_brake) == 1) return; //exit if the button is down already
  140.        SetWallCel(release_brake, 1);    // Set the switch
  141.     
  142.     
  143.     PlaySoundPos(release_snd, SurfaceCenter(release_brake), 0.6, -1, -1, 0);
  144.     
  145.     if ((droidweight + c_crate) < (c_weight)) //  =========================Elev going Up
  146.         {
  147.         clearadjoinflags(walkwindow, 2);        //close the window
  148.         dwdisablejump();
  149.         
  150.         
  151.         dwPlayCammySpeech(17105, "T7ca007.wav", 10, 0);
  152.         
  153.         garbage = playsoundpos(estart_snd,getsurfacecenter(release_brake),0.5,-1,-1,0);
  154.         sounder = playsoundlocal(eloop_snd,1.0,0.0,11);
  155.         
  156.         speed = gravity - (gravity / (c_weight / (droidweight + c_crate))); 
  157.          
  158.         if (speed > 7.00) 
  159.             {
  160.             //speed=gravity;            // FALLLLLLLLLLLLL ING!
  161.             falling = 1;
  162.             }
  163.         
  164.         
  165.         SkipToFrame(elevator, 1, speed);
  166.          SkipToFrame(counterweight, 1, speed);
  167.         settimer(10);
  168.         }
  169.     
  170.     if (droidweight + c_crate > c_weight) //Down
  171.         {
  172.         
  173.         clearadjoinflags(walkwindow, 2);        //close the window
  174.         dwdisablejump();
  175.                 
  176.  
  177.         garbage = playsoundpos(estart_snd,getsurfacecenter(release_brake),0.5,-1,-1,0);
  178.         sounder = playsoundlocal(eloop_snd,1.0,0.0,11);
  179.         
  180.         
  181.         speed = gravity  - (gravity / ((droidweight + c_crate) / c_weight)); 
  182.            print("speed:");
  183.         printflex(speed);
  184.         if (speed > 7.00) 
  185.             {
  186.             //speed=gravity;            // FALLLLLLLLLLLLL ING!
  187.             dwPlayCammySpeech(17107, "T7ca009.wav", 10, 0);
  188.             falling = 1;
  189.             }
  190.             else
  191.             {
  192.             dwPlayCammySpeech(17106, "T7ca008.wav", 10, 0);
  193.             }
  194.         SkipToFrame(elevator, 2, speed);
  195.          SkipToFrame(counterweight, 2, speed);
  196.         settimer(10);
  197.         }
  198.  
  199.     if (droidweight + c_crate == c_weight) //=======================================//Same
  200.         {
  201.         dwPlayCammySpeech(17101, "T7ca003.wav", 10, 0);
  202.         sleep(1);
  203.         SetWallCel(release_brake, 0);    // reset the switch
  204.         }
  205.     printflex(speed);
  206.     }   
  207.  
  208.     //-----------------------------------------------END RELEASE 
  209.  
  210.     if (GetSenderId() == 8)      // message came from add_sand
  211.         {
  212.         call sand_add;
  213.         }
  214.    if (GetSenderId() == 9)      // message came from rem_sand
  215.         {
  216.         call sand_rem;
  217.         }
  218.  
  219.    return;
  220.     
  221.  
  222. # ........................................................................................
  223.  
  224. arrived:
  225.     printint(getcurframe(elevator));
  226.     if (GetCurFrame(elevator) == 0) 
  227.         {
  228.           
  229.         setadjoinflags(walkwindow, 2);        //open the window
  230.         dwenablejump();
  231.         
  232.         SetWallCel(release_brake, 0);
  233.         if (sounder >0) stopsound(sounder,0.5);
  234.         sounder = playsoundthing(eend_snd,elevator,1.0,-1,-1,0);
  235.         if (falling == 1)
  236.             {
  237.             victim = getlocalplayerthing();
  238.             print("DAMAGE!!!!!!");
  239.             damage = (rand() * (maxDamage - minDamage)) + minDamage;
  240.             garbage = DamageThing(victim, damage, 0x2, victim);        // self-inflicted damage
  241.             falling = 0;
  242.             } 
  243.         
  244.         } 
  245.     return;
  246. # ........................................................................................
  247.  
  248. sand_add:
  249.       if (GetWallCel(add_sand) != 1)    //Nothing's already happening
  250.         {
  251.         sendmessage(sander, user1);
  252.         e_switch = add_sand;
  253.         SetWallCel(e_switch, 1);
  254.         garbage = playsoundpos(act_snd,getsurfacecenter(add_sand),0.5,-1,-1,0);
  255.         sand_inc = 1;
  256.         c_dest = c_weight + step;
  257.         SetPulse(0.05);
  258.         }
  259.     return;
  260.  
  261. sand_rem:
  262.  if (GetWallCel(rem_sand) != 1)    //Nothing's already happening
  263.         {
  264.         sendmessage(sander, user2);
  265.         e_switch = rem_sand;
  266.         SetWallCel(e_switch, 1);
  267.         garbage = playsoundpos(act_snd,getsurfacecenter(rem_sand),0.5,-1,-1,0);
  268.         sand_inc = -1;
  269.         c_dest = c_weight - step;
  270.         SetPulse(0.05);
  271.         }
  272.  
  273.     return;
  274.  
  275.  
  276. pulse:
  277.     c_weight = c_weight + sand_inc;
  278.     if (c_weight < step) 
  279.         {
  280.         sendmessage(sander, user0);
  281.         SetPulse(0);
  282.         SetWallCel(add_sand, 0);
  283.         SetWallCel(rem_sand, 0);
  284.         c_weight = step;
  285.         }
  286.     if (c_weight > 990) 
  287.         {
  288.         sendmessage(sander, user0);
  289.         SetPulse(0);
  290.         SetWallCel(add_sand, 0);
  291.         SetWallCel(rem_sand, 0);
  292.         c_weight = 990;
  293.         }
  294.     
  295.     
  296.     if (c_weight == c_dest) 
  297.         {
  298.         sendmessage(sander, user0);
  299.         SetPulse(0);
  300.         garbage = playsoundpos(act2_snd,getsurfacecenter(e_switch),0.5,-1,-1,0);
  301.         SetWallCel(e_switch, 0);
  302.         }
  303.  
  304.         call displayweight;
  305.  
  306.     return;
  307.  
  308.  timer:
  309.     // Clear Cammy's message area         
  310. // not needed anymore
  311.         return;
  312.  
  313. entered:
  314.     if (GetSenderId() == 11)          // message came from Puzzle_reset
  315.         {
  316.         SkipToFrame(elevator, 0, 12);
  317.          SkipToFrame(counterweight, 0, 12);
  318.         SetWallCel(release_brake, 0);
  319.         }
  320.     return;    
  321.  
  322. displayweight:
  323.  
  324.    SetWallCel(led_ones, c_weight %  10);
  325.    SetWallCel(led_tens, (c_weight / 10) % 10);
  326.    SetWallCel(led_hund, (c_weight / 100) % 10);
  327.    //printint(c_crate);
  328.    //print("And");
  329.    //printint(droidweight);
  330.    return;
  331. end
  332.  
  333.