home *** CD-ROM | disk | FTP | other *** search
/ Classic Fond 52 / ClassicFond52.iso / GAMES / DROIDW.RAR / DWCD.GOB / mission_cog_moisture_counterweight.cog < prev    next >
Encoding:
Text File  |  1998-11-04  |  5.3 KB  |  230 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       linkid=13
  27. surface  led_tens       linkid=13
  28. surface  led_hund       linkid=13
  29. surface  release_brake  linkid=10
  30.  
  31. thing    elevator       linkid=1
  32. thing    cube           linkid=2
  33. thing    counterweight  linkid=3
  34. thing    wheel          linkid=5
  35. thing    brake          linkid=6
  36. thing    line0start 
  37. thing    line0end                        
  38. thing    line1start 
  39. thing    line1end
  40. thing    line2start 
  41. thing    line2end
  42. thing    line3start 
  43. thing    line3end
  44.  
  45. sector   reset_puzzle    linkid=11
  46. flex     start_wait=0.25   desc=pause_before_moving_up
  47. flex     sleeptime=2.0
  48. flex     c_weight=10.0
  49. flex     c_dest=10.0
  50. flex     sand_inc=5.0    local
  51. flex       gravity=12.0 local
  52. flex     speed=4.0
  53. int       c_crate=0
  54. int       step=10
  55. int    l_color=111    local    
  56. flex     L_size=0.01    local    
  57. flex     droidweight=10.0
  58.  
  59. sound    wav0=Activate02.wav
  60.  
  61. end
  62.  
  63. # ========================================================================================
  64.  
  65. code
  66.  
  67. startup:
  68.        addbeam(line0start,line0end,l_color,l_size);
  69.        addbeam(line1start,line1end,l_color,l_size);
  70.        addbeam(line2start,line2end,l_color,l_size);
  71.        addbeam(line3start,line3end,l_color,l_size);
  72.  
  73.        attachthingtothing(line0start,elevator);
  74.        attachthingtothing(line1start,elevator);
  75.        
  76.        attachthingtothing(line2start,counterweight);
  77.        attachthingtothing(line3start,counterweight);
  78.  
  79.  
  80.     droidweight = GetThingMass(GetLocalPlayerThing()) / 2.2;  // Get the player's weight
  81.         c_weight = (droidweight) + ((rand()*100)-50); // Set th e counterweight to something near the players weight
  82.     //c_weight = (droidweight);  // Set the counterweight to something near the players weight
  83.         c_weight = c_weight - (c_weight % 10); 
  84.     c_crate = 0;
  85.     call displayweight;
  86.     return;
  87. crossed:                // If player crosses adjoin(s)
  88.   
  89.   return;
  90.  
  91. # ........................................................................................
  92.  
  93. activate:
  94. if (GetSenderId() == 10)          // message came from release_brake
  95.     
  96.     {
  97.     //--------------------------------------------- RELEASE THE BRAKE
  98.        
  99.     if (GetWallCel(release_brake) == 1) return; //exit if the button is down already
  100.        SetWallCel(release_brake, 1);
  101.        PlaySoundPos(wav0, SurfaceCenter(release_brake), 0.6, -1, -1, 0);
  102.         
  103.     if ((droidweight + c_crate) < (c_weight)) //Up
  104.         {
  105.         dwsetmissiontext(17105);
  106.                 speed = gravity - (gravity / (c_weight / (droidweight + c_crate))); 
  107.          SkipToFrame(elevator, 1, speed);
  108.          SkipToFrame(counterweight, 1, speed);
  109.         settimer(10);
  110.         }
  111.     
  112.     if (droidweight + c_crate > c_weight) //Down
  113.         {
  114.         speed = gravity  - (gravity / ((droidweight + c_crate) / c_weight)); 
  115.            if (c_weight < 26) 
  116.             {
  117.             speed=gravity;
  118.             dwsetmissiontext(17107);
  119.             }
  120.             else
  121.             {
  122.             dwsetmissiontext(17106);
  123.             }
  124.         SkipToFrame(elevator, 2, speed);
  125.          SkipToFrame(counterweight, 2, speed);
  126.         settimer(10);
  127.         }
  128.  
  129.     if (droidweight + c_crate == c_weight) //Same
  130.         {
  131.         dwsetmissiontext(17101);
  132.         }
  133.     printflex(speed);
  134.     }   
  135.  
  136.     //-----------------------------------------------END RELEASE 
  137.  
  138.        if (GetSenderId() == 8)      // message came from add_sand
  139.         {
  140.         call sand_add;
  141.         }
  142.    if (GetSenderId() == 9)      // message came from rem_sand
  143.     {
  144.     call sand_rem;
  145.     }
  146.  
  147.    return;
  148.     
  149.  
  150. # ........................................................................................
  151.  
  152. arrived:
  153.     if (GetCurFrame(elevator) == 0) 
  154.         {
  155.           SetWallCel(release_brake, 0);
  156.           PlaySoundPos(wav0, SurfaceCenter(release_brake), 0.6, -1, -1, 0);
  157.            } 
  158.     return;
  159. # ........................................................................................
  160.  
  161. sand_add:
  162.       if (GetWallCel(add_sand) != 1)    //Nothing's already happening
  163.         {
  164.         SetWallCel(add_sand, 1);
  165.         sand_inc = 1;
  166.         c_dest = c_weight + step;
  167.         SetPulse(0.02);
  168.         }
  169.     return;
  170.  
  171. sand_rem:
  172.  if (GetWallCel(rem_sand) != 1)    //Nothing's already happening
  173.         {
  174.         SetWallCel(rem_sand, 1);
  175.         sand_inc = -1;
  176.         c_dest = c_weight - step;
  177.         SetPulse(0.02);
  178.         }
  179.  
  180.     return;
  181.  
  182.  
  183. pulse:
  184.     c_weight = c_weight + sand_inc;
  185.     if (c_weight < step) 
  186.         {
  187.         SetPulse(0);
  188.         SetWallCel(add_sand, 0);
  189.         SetWallCel(rem_sand, 0);
  190.         c_weight = step;
  191.         
  192.         }
  193.     
  194.     if (c_weight == c_dest) 
  195.         {
  196.         SetPulse(0);
  197.         SetWallCel(add_sand, 0);
  198.         SetWallCel(rem_sand, 0);
  199.         }
  200.  
  201.         call displayweight;
  202.  
  203.     return;
  204.  
  205.  timer:
  206.     // Clear Cammy's message area         
  207.     dwsetmissiontext(00000);
  208.         return;
  209.  
  210. entered:
  211.     if (GetSenderId() == 11)          // message came from Puzzle_reset
  212.         {
  213.         SkipToFrame(elevator, 0, 60);
  214.          SkipToFrame(counterweight, 0, 60);
  215.           SetWallCel(release_brake, 0);
  216.         }
  217.     return;    
  218.  
  219. displayweight:
  220.  
  221.    SetWallCel(led_ones, c_weight %  10);
  222.    SetWallCel(led_tens, (c_weight / 10) % 10);
  223.    SetWallCel(led_hund, (c_weight / 100) % 10);
  224.    printint(c_crate);
  225.    print("And");
  226.    printint(droidweight);
  227.    return;
  228. end
  229.  
  230.