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

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