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

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