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

  1. # Droids COG Script
  2. #
  3. # b0_PulleySetup2.cog
  4. #
  5. # A "subdeck" cog designed to handle the setting up and taking down of a pulley setup. 
  6. #
  7. # Desc:
  8. #    This cog controls everything about Pulley setup 2. It also talks with the rop cog to
  9. #    tell it to sag and whatnot. It's pretty hairy.     Check the comments in Pulley #1 if there's
  10. #     Not enough comments in this one. All the cogs are the same minus a few animtion things, and
  11. #    the comments in pulley 1 are the most updated.
  12. #
  13. #     01/15/98 [DGS]    Created
  14. #     03/24/98 DGS Added arm stength to the cog
  15. # ========================================================================================
  16.    
  17. symbols
  18. message        User0
  19. message        User1
  20. message        user3
  21. message     activate
  22. message        pulse
  23. message        arrived
  24. message        startup
  25. message        used
  26.  
  27. ## ----------------Cogs
  28. cog        pulley_rop
  29. cog        Setup1_cog
  30. cog        setup3_cog
  31.  
  32. ## ----------------Things
  33. thing        block    linkid=1
  34. thing        flap    linkid=1
  35. surface        act_sur
  36.  
  37. ## ----------------Templates
  38. template     pulley1_t 
  39. template    pulley2_t
  40. template    hook_t      
  41.  
  42. ## ----------------Ghost Objects
  43. thing         Pulley_top_g     
  44. thing        hook_g
  45. thing        pulley_bot_g        
  46.  
  47. ## ----------------Thing Integers
  48. int        pulley_top_i    local
  49. int        pulley_bot_i    local
  50. int        hook_i        local
  51.  
  52. ## ----------------Rope Ghosts
  53. thing        rope1a         
  54. thing        rope1b        
  55. thing        rope2a
  56. thing        rope2b
  57.  
  58. ## ----------------Rope Integers
  59. int        rope1_i        local
  60. int        rope2_i        local
  61.  
  62.  
  63. ## ----------------sounds
  64. sound    wheel_snd=FLYt3PulleyLp.WAV        local
  65. sound    hook_snd=SWTt9GearOn.WAV        local
  66. sound    unhook_snd=SWTt9GearOff.WAV     local
  67. sound    setup_snd=SWTt9GearOff.WAV         local
  68.  
  69.  
  70. ## ----------------Misc
  71. int        arm_str=0            local      
  72. int        lift=0                local
  73. int        l_color=114            local
  74. int        moving=0            local
  75. int        setup=0                local
  76. flex    l_size=0.005        local            
  77. int        pulley_1_b=28        local
  78. int        pulley_2_b=29        local
  79. int        pulley_3_b=30        local
  80. end
  81. code
  82.  
  83. startup:
  84.     player = getlocalplayerthing();
  85.     arm_str = dwGetArmStrength();
  86.     //arm_str = 100;
  87.     //call user0;    // set it'self up
  88.     return;
  89.     
  90. user0:
  91.     print("setup 2: Sent");
  92.     //         AKA Setup
  93.     //        build the pulley setup 
  94.     setup         = 1; // Says that the setup is up
  95.     pulley_top_i     = creatething(pulley2_t, pulley_top_g);
  96.     pulley_bot_i     = creatething(pulley1_t, pulley_bot_g);
  97.     capturething(pulley_top_i); //Capture the hook, it's the one they'll activate
  98.     hook_i         = creatething(hook_t, hook_g);
  99.     rope1_i     = addbeam(rope1a,rope1b,l_color,l_size);
  100.     rope2_i     = addbeam(rope2a,rope2b,l_color,l_size);
  101.     attachthingtothing(rope2a, hook_i);
  102.     attachthingtothing(pulley_bot_i, hook_i);
  103.     attachthingtothing(rope1b, hook_i);
  104.     print("Done");
  105.     garbage = playsoundthing(setup_snd,hook_i,1.0,-1,-1,0);
  106.     return;
  107.  
  108. user1:
  109.     //        AKA Takedown
  110.     //        takedown the pulley setup
  111.     setup = 0;    // says the setup is down
  112.     detachthing(rope2a);
  113.     detachthing(pulley_bot_i);
  114.     detachthing(rope1b);
  115.     removelaser(rope1_i);
  116.     removelaser(rope2_i);
  117.     destroything(pulley_top_i);
  118.     destroything(pulley_bot_i);
  119.     destroything(hook_i);
  120.     return;
  121.  
  122. user3:
  123.     //        AKA Pull on the rope
  124.     //        Someone's a tuggin' on the otha end of the rope
  125.     print("Setup1:     User3");
  126.         if (setup == 1)
  127.         {
  128.         if (lift > 0) // if it hasnrn't 
  129.             {
  130.             dwPlayCammySpeech(10003, "t3ca009.wav", 10, 0); // Cammy: You don't need to work the pulley now
  131.             }
  132.         else    
  133.             {
  134.             print("Freeze2");
  135.             dwfreezeplayer();
  136.             if (getcurframe(hook_i) == 1)    //if the pulley is down
  137.                 {
  138.                 if (arm_str > 5) //if arm stength is greater than 10
  139.                     {
  140.                     global1 = 2; // change PulleyJawa dialog
  141.                     lift     = 1; // Tells arrived message that the block is lifting
  142.                     sendmessage(pulley_rop,user2);  // tell the end of the rope to go down
  143.                     sendmessage(pulley_rop,user1);    // tell rope to get tite
  144.                     sendmessage(pulley_rop,user4);    // tell rope to get tite
  145.                     sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1);
  146.                     sleep(1);
  147.                     attachthingtothing(block,hook_i);      
  148.                     movetoframe(hook_i,2,1);
  149.                     }
  150.                 else // else You're not strong enough
  151.                     {
  152.                     if (global1 == 0) global1 = 1; // change PulleyJawa dialog
  153.                     sendmessage(pulley_rop,user1);    // tell rope to get tite
  154.                     sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1);
  155.                     sleep(3);
  156.                     if (sounder >0) stopsound(sounder,0.5);        // Stop the sound
  157.                     sendmessage(pulley_rop,user0);    // tell rope to get loose
  158.                     dwPlayCammySpeech(10001, "t3ca007.wav", 10, 0); // Cammy: You're not strong enough
  159.                     dwsetreftopic("pulley.tpc");
  160.                     print("UnFreeze2");
  161.                     dwunfreezeplayer();
  162.                     }
  163.                 }
  164.             else  //else the hook is up
  165.                 {
  166.                 print("UnFreeze2");
  167.                 dwunfreezeplayer();
  168.                 dwPlayCammySpeech(10007, "t3ca013.wav", 10, 0); // Cammy: The hook's not attached to anyting
  169.                 }
  170.             }
  171.         }
  172.     return;
  173. used:
  174.     print("2 Used:");
  175.     printint(dwGetActivateBin());
  176.     // This rountine controls putting on another pulley
  177.     if (setup == 1)
  178.         {
  179.         if ((getcurframe(hook_i)  == 0) && (moving == 0)) // if the hook it up at the top
  180.         {
  181.                 if (global0 == 0) global0 =1; // change PulleyJawa dialog
  182.         if (dwGetActivateBin() == pulley_1_b) //Putting on pulley config # 2
  183.             {
  184.             if ( getinv(getlocalplayerthing(),pulley_1_b) > 0) // If it's in his inventory
  185.                 {
  186.                 call user1;
  187.                 print("setup 2: Sent to 1");
  188.                 ChangeInv(getlocalplayerthing(), pulley_1_b, -1); // remove a #2 pulley from inv
  189.                 ChangeInv(getlocalplayerthing(), pulley_2_b,  1); // add a #1 pulley to inv
  190.                 call update_bins;
  191.                 // Send To Pulley config #2: Setup
  192.                 dwPlayCammySpeech(10005, "t3ca011.wav", 10, 0); // Cammy: // Pulleys switched!
  193.                 sendmessage(setup1_cog,user0); // Set up pulley 1
  194.                 }
  195.             }
  196.                 
  197.         if (dwGetActivateBin() == pulley_3_b) //Putting on pulley config # 3
  198.             {
  199.             if ( getinv(getlocalplayerthing(),pulley_3_b) > 0) // If it's in his inventory
  200.                 {
  201.                 call user1;
  202.                 print("setup 2: Sent to 3");
  203.                 ChangeInv(getlocalplayerthing(), pulley_3_b, -1); // remove a #3 pulley from inv
  204.                 ChangeInv(getlocalplayerthing(), pulley_2_b,  1); // add a #1 pulley to inv
  205.                 call update_bins;
  206.                 // Send To Pulley config #3: Setup
  207.                 dwPlayCammySpeech(10005, "t3ca011.wav", 10, 0); // Cammy: // Pulleys switched!
  208.                 sendmessage(setup3_cog,user0); // Set up pulley 3
  209.                 }
  210.              }
  211.         }
  212.     else         //else the hook is down
  213.         {
  214.         dwPlayCammySpeech(10004, "t3ca010.wav", 10, 0); // Cammy: /You need to raise the hook up!
  215.         }
  216.     }
  217.     return;
  218.     
  219.  
  220. activate:
  221.     //move it down or up
  222.         print("activated");
  223.           if (setup == 1)
  224.         {
  225.         if (getsenderid() == 0)    // make sure it's the rigt piece
  226.         {
  227.         if (lift == 0) // If the block hasn't been lifted into the air yet
  228.             {
  229.                         if (global0 == 0) global0 =1; // change PulleyJawa dialog
  230.             if (moving == 0)
  231.                 {
  232.                 if (getcurframe(hook_i)  == 0) // if the hook it up at the top
  233.                     {
  234.                                         setCollideType(hook_i,         0);    // turn off collides for the hook 
  235.                     SetCollideType(pulley_bot_i,     0);     // Turn off collides for the bottom pulley 
  236.                     moving     = 1; //Don't get messages until it arrived
  237.                     bounce     = 1;
  238.                     sendmessage(pulley_rop,user3);
  239.                     sendmessage(pulley_rop,user1);    // tell rope to get tite
  240.                     capturething(hook_i);
  241.                     movetoframe(hook_i,1,1);    //send it down
  242.                     sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1);
  243.                     print("Freeze2");
  244.                     dwfreezeplayer();          //stop the player from moving while it's all going on
  245.                     setpulse(0.2);
  246.                     }
  247.                 else    //else the hook is down
  248.                     {
  249.                                         setCollideType(hook_i,         0);    // turn off collides for the hook 
  250.                     SetCollideType(pulley_bot_i,     0);     // Turn off collides for the bottom pulley 
  251.                     moving = 1; //Don't get messages until it arrived
  252.                     bounce = 1;
  253.                     sendmessage(pulley_rop,user2);
  254.                     sendmessage(pulley_rop,user1);    // tell rope to get tite
  255.                     capturething(hook_i);
  256.                     movetoframe(hook_i,0,1);    //send it up
  257.                     garbage = playsoundthing(unhook_snd,hook_i,1.0,-1,-1,0);
  258.                     sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,11);
  259.                     print("Freeze2");
  260.                     dwfreezeplayer();          //stop the player from moving while it's all going on
  261.                     
  262.                     setpulse(0.2);
  263.                     }
  264.                 }
  265.             }
  266.         else // else the block's been lifted 
  267.             {
  268.             dwPlayCammySpeech(10003, "t3ca009.wav", 10, 0); // Cammy: You don't need to work the pulley now
  269.             }
  270.         }
  271.         }
  272.     return;
  273.  
  274. arrived:
  275.     // arrived controls how all the parts move. The variable "lift" specifies what frame to go to next. 
  276.     print("arrived");
  277.     if (setup == 1)
  278.     {
  279.     printint(getsenderid());
  280.     printint(hook_i);
  281.         print("sender matched");
  282.     if (lift == 0) // if the pulley is not lifting the block up
  283.         {
  284.         print("UnFreeze2");
  285.         dwunfreezeplayer();
  286.         print("Stop Bob");
  287.         SetCollideType(hook_i,         3);    // turn on collides for the hook 
  288.         SetCollideType(pulley_bot_i,     3);     // Turn on collides for the bottom pulley 
  289.         moving = 0;
  290.         setpulse(0);        //stop the bouncing
  291.         if (sounder >0) stopsound(sounder,0.5);        // Stop the sound
  292.         
  293.         sendmessage(pulley_rop,user0); // reset the rope to it's loose state
  294.         capturething(pulley_top_i); // recapture the top pulley 
  295.         if (getcurframe(hook_i) == 1) //if the hook's at the bottom
  296.             {
  297.             garbage = playsoundthing(hook_snd,hook_i,1.0,-1,-1,0);
  298.             dwPlayCammySpeech(10006, "t3ca012.wav", 10, 0); // Cammy: You don't need to work the pulley now
  299.             }
  300.         }
  301.     else if (lift == 1)    // else the pulley is lifting the block up
  302.         {
  303.         if (sounder >0) stopsound(sounder,0.1);        // Stop the sound
  304.         sendmessage(pulley_rop,user5);    // tell rope to get tite
  305.         movetoframe(flap,1,1);    // flip the flap down
  306.         lift = 2;
  307.         }
  308.     else if (lift == 2) 
  309.         {
  310.         sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1);
  311.         movetoframe(hook_i,3,1); // Move hook and block back down
  312.         lift = 3;
  313.         }
  314.     else if (lift == 3) 
  315.         {
  316.         SetCollideType(hook_i,         3);    // turn on collides for the hook 
  317.         if (sounder >0) stopsound(sounder,0.1);        // Stop the sound
  318.         
  319.         SetCollideType(pulley_bot_i,     3);     // Turn on collides for the bottom pulley 
  320.         sendmessage(pulley_rop,user0); // reset the rope to it's loose state
  321.         lift = 4;
  322.         SetInv(player, 1, 1);    // Set the mission objective to True
  323.         dwPlayCammySpeech(10012, "M2CA025.wav", 10, 0); // Cammy:All rite!
  324.         print("UnFreeze2");
  325.         dwunfreezeplayer();
  326.         }
  327.     }           
  328.     return;
  329.  
  330. pulse:
  331.     // used to cause bounce in the rope as it moves. 
  332.     if (bounce == 1) sendmessage(pulley_rop,user0);    // tell rope to get loose
  333.         else sendmessage(pulley_rop,user1);    // tell rope to get loose
  334.     bounce = 1- bounce;
  335.     return;
  336.  
  337. update_bins:
  338.     // this is a utility routine used to turn on and off availability of items. Just until Jon adds it into DW for reals.
  339.         if ( getinv(getlocalplayerthing(),pulley_1_b) > 0) SetInvAvailable(getlocalplayerthing(), pulley_1_b, 1); //if the sm. bin has more than 0 turn on the inv icon; 
  340.     else SetInvAvailable(getlocalplayerthing(), pulley_1_b, 0);    // else turn it off;
  341.     
  342.         if ( getinv(getlocalplayerthing(),pulley_2_b) > 0) SetInvAvailable(getlocalplayerthing(), pulley_2_b, 1); //if the md. bin has more than 0 turn on the inv icon; 
  343.     else SetInvAvailable(getlocalplayerthing(), pulley_2_b, 0);    // else turn it off;
  344.        
  345.         if ( getinv(getlocalplayerthing(),pulley_3_b) > 0) SetInvAvailable(getlocalplayerthing(), pulley_3_b, 1); //if the lg. bin has more than 0 turn on the inv icon; 
  346.     else SetInvAvailable(getlocalplayerthing(), pulley_3_b, 0);    // else turn it off;
  347.     return;
  348.  
  349. end
  350.  
  351.  
  352.  
  353.  
  354.