home *** CD-ROM | disk | FTP | other *** search
Wrap
# Droids COG Script # # b0_PulleySetup2.cog # # A "subdeck" cog designed to handle the setting up and taking down of a pulley setup. # # Desc: # This cog controls everything about Pulley setup 2. It also talks with the rop cog to # tell it to sag and whatnot. It's pretty hairy. Check the comments in Pulley #1 if there's # Not enough comments in this one. All the cogs are the same minus a few animtion things, and # the comments in pulley 1 are the most updated. # # 01/15/98 [DGS] Created # 03/24/98 DGS Added arm stength to the cog # ======================================================================================== symbols message User0 message User1 message user3 message activate message pulse message arrived message startup message used ## ----------------Cogs cog pulley_rop cog Setup1_cog cog setup3_cog ## ----------------Things thing block linkid=1 thing flap linkid=1 surface act_sur ## ----------------Templates template pulley1_t template pulley2_t template hook_t ## ----------------Ghost Objects thing Pulley_top_g thing hook_g thing pulley_bot_g ## ----------------Thing Integers int pulley_top_i local int pulley_bot_i local int hook_i local ## ----------------Rope Ghosts thing rope1a thing rope1b thing rope2a thing rope2b ## ----------------Rope Integers int rope1_i local int rope2_i local ## ----------------sounds sound wheel_snd=FLYt3PulleyLp.WAV local sound hook_snd=SWTt9GearOn.WAV local sound unhook_snd=SWTt9GearOff.WAV local sound setup_snd=SWTt9GearOff.WAV local ## ----------------Misc int arm_str=0 local int lift=0 local int l_color=114 local int moving=0 local int setup=0 local flex l_size=0.005 local int pulley_1_b=28 local int pulley_2_b=29 local int pulley_3_b=30 local end code startup: player = getlocalplayerthing(); arm_str = dwGetArmStrength(); //arm_str = 100; //call user0; // set it'self up return; user0: print("setup 2: Sent"); // AKA Setup // build the pulley setup setup = 1; // Says that the setup is up pulley_top_i = creatething(pulley2_t, pulley_top_g); pulley_bot_i = creatething(pulley1_t, pulley_bot_g); capturething(pulley_top_i); //Capture the hook, it's the one they'll activate hook_i = creatething(hook_t, hook_g); rope1_i = addbeam(rope1a,rope1b,l_color,l_size); rope2_i = addbeam(rope2a,rope2b,l_color,l_size); attachthingtothing(rope2a, hook_i); attachthingtothing(pulley_bot_i, hook_i); attachthingtothing(rope1b, hook_i); print("Done"); garbage = playsoundthing(setup_snd,hook_i,1.0,-1,-1,0); return; user1: // AKA Takedown // takedown the pulley setup setup = 0; // says the setup is down detachthing(rope2a); detachthing(pulley_bot_i); detachthing(rope1b); removelaser(rope1_i); removelaser(rope2_i); destroything(pulley_top_i); destroything(pulley_bot_i); destroything(hook_i); return; user3: // AKA Pull on the rope // Someone's a tuggin' on the otha end of the rope print("Setup1: User3"); if (setup == 1) { if (lift > 0) // if it hasnrn't { dwPlayCammySpeech(10003, "t3ca009.wav", 10, 0); // Cammy: You don't need to work the pulley now } else { print("Freeze2"); dwfreezeplayer(); if (getcurframe(hook_i) == 1) //if the pulley is down { if (arm_str > 5) //if arm stength is greater than 10 { global1 = 2; // change PulleyJawa dialog lift = 1; // Tells arrived message that the block is lifting sendmessage(pulley_rop,user2); // tell the end of the rope to go down sendmessage(pulley_rop,user1); // tell rope to get tite sendmessage(pulley_rop,user4); // tell rope to get tite sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1); sleep(1); attachthingtothing(block,hook_i); movetoframe(hook_i,2,1); } else // else You're not strong enough { if (global1 == 0) global1 = 1; // change PulleyJawa dialog sendmessage(pulley_rop,user1); // tell rope to get tite sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1); sleep(3); if (sounder >0) stopsound(sounder,0.5); // Stop the sound sendmessage(pulley_rop,user0); // tell rope to get loose dwPlayCammySpeech(10001, "t3ca007.wav", 10, 0); // Cammy: You're not strong enough dwsetreftopic("pulley.tpc"); print("UnFreeze2"); dwunfreezeplayer(); } } else //else the hook is up { print("UnFreeze2"); dwunfreezeplayer(); dwPlayCammySpeech(10007, "t3ca013.wav", 10, 0); // Cammy: The hook's not attached to anyting } } } return; used: print("2 Used:"); printint(dwGetActivateBin()); // This rountine controls putting on another pulley if (setup == 1) { if ((getcurframe(hook_i) == 0) && (moving == 0)) // if the hook it up at the top { if (global0 == 0) global0 =1; // change PulleyJawa dialog if (dwGetActivateBin() == pulley_1_b) //Putting on pulley config # 2 { if ( getinv(getlocalplayerthing(),pulley_1_b) > 0) // If it's in his inventory { call user1; print("setup 2: Sent to 1"); ChangeInv(getlocalplayerthing(), pulley_1_b, -1); // remove a #2 pulley from inv ChangeInv(getlocalplayerthing(), pulley_2_b, 1); // add a #1 pulley to inv call update_bins; // Send To Pulley config #2: Setup dwPlayCammySpeech(10005, "t3ca011.wav", 10, 0); // Cammy: // Pulleys switched! sendmessage(setup1_cog,user0); // Set up pulley 1 } } if (dwGetActivateBin() == pulley_3_b) //Putting on pulley config # 3 { if ( getinv(getlocalplayerthing(),pulley_3_b) > 0) // If it's in his inventory { call user1; print("setup 2: Sent to 3"); ChangeInv(getlocalplayerthing(), pulley_3_b, -1); // remove a #3 pulley from inv ChangeInv(getlocalplayerthing(), pulley_2_b, 1); // add a #1 pulley to inv call update_bins; // Send To Pulley config #3: Setup dwPlayCammySpeech(10005, "t3ca011.wav", 10, 0); // Cammy: // Pulleys switched! sendmessage(setup3_cog,user0); // Set up pulley 3 } } } else //else the hook is down { dwPlayCammySpeech(10004, "t3ca010.wav", 10, 0); // Cammy: /You need to raise the hook up! } } return; activate: //move it down or up print("activated"); if (setup == 1) { if (getsenderid() == 0) // make sure it's the rigt piece { if (lift == 0) // If the block hasn't been lifted into the air yet { if (global0 == 0) global0 =1; // change PulleyJawa dialog if (moving == 0) { if (getcurframe(hook_i) == 0) // if the hook it up at the top { setCollideType(hook_i, 0); // turn off collides for the hook SetCollideType(pulley_bot_i, 0); // Turn off collides for the bottom pulley moving = 1; //Don't get messages until it arrived bounce = 1; sendmessage(pulley_rop,user3); sendmessage(pulley_rop,user1); // tell rope to get tite capturething(hook_i); movetoframe(hook_i,1,1); //send it down sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1); print("Freeze2"); dwfreezeplayer(); //stop the player from moving while it's all going on setpulse(0.2); } else //else the hook is down { setCollideType(hook_i, 0); // turn off collides for the hook SetCollideType(pulley_bot_i, 0); // Turn off collides for the bottom pulley moving = 1; //Don't get messages until it arrived bounce = 1; sendmessage(pulley_rop,user2); sendmessage(pulley_rop,user1); // tell rope to get tite capturething(hook_i); movetoframe(hook_i,0,1); //send it up garbage = playsoundthing(unhook_snd,hook_i,1.0,-1,-1,0); sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,11); print("Freeze2"); dwfreezeplayer(); //stop the player from moving while it's all going on setpulse(0.2); } } } else // else the block's been lifted { dwPlayCammySpeech(10003, "t3ca009.wav", 10, 0); // Cammy: You don't need to work the pulley now } } } return; arrived: // arrived controls how all the parts move. The variable "lift" specifies what frame to go to next. print("arrived"); if (setup == 1) { printint(getsenderid()); printint(hook_i); print("sender matched"); if (lift == 0) // if the pulley is not lifting the block up { print("UnFreeze2"); dwunfreezeplayer(); print("Stop Bob"); SetCollideType(hook_i, 3); // turn on collides for the hook SetCollideType(pulley_bot_i, 3); // Turn on collides for the bottom pulley moving = 0; setpulse(0); //stop the bouncing if (sounder >0) stopsound(sounder,0.5); // Stop the sound sendmessage(pulley_rop,user0); // reset the rope to it's loose state capturething(pulley_top_i); // recapture the top pulley if (getcurframe(hook_i) == 1) //if the hook's at the bottom { garbage = playsoundthing(hook_snd,hook_i,1.0,-1,-1,0); dwPlayCammySpeech(10006, "t3ca012.wav", 10, 0); // Cammy: You don't need to work the pulley now } } else if (lift == 1) // else the pulley is lifting the block up { if (sounder >0) stopsound(sounder,0.1); // Stop the sound sendmessage(pulley_rop,user5); // tell rope to get tite movetoframe(flap,1,1); // flip the flap down lift = 2; } else if (lift == 2) { sounder = playsoundthing(wheel_snd,hook_i,1.0,-1,-1,1); movetoframe(hook_i,3,1); // Move hook and block back down lift = 3; } else if (lift == 3) { SetCollideType(hook_i, 3); // turn on collides for the hook if (sounder >0) stopsound(sounder,0.1); // Stop the sound SetCollideType(pulley_bot_i, 3); // Turn on collides for the bottom pulley sendmessage(pulley_rop,user0); // reset the rope to it's loose state lift = 4; SetInv(player, 1, 1); // Set the mission objective to True dwPlayCammySpeech(10012, "M2CA025.wav", 10, 0); // Cammy:All rite! print("UnFreeze2"); dwunfreezeplayer(); } } return; pulse: // used to cause bounce in the rope as it moves. if (bounce == 1) sendmessage(pulley_rop,user0); // tell rope to get loose else sendmessage(pulley_rop,user1); // tell rope to get loose bounce = 1- bounce; return; update_bins: // this is a utility routine used to turn on and off availability of items. Just until Jon adds it into DW for reals. 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; else SetInvAvailable(getlocalplayerthing(), pulley_1_b, 0); // else turn it off; 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; else SetInvAvailable(getlocalplayerthing(), pulley_2_b, 0); // else turn it off; 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; else SetInvAvailable(getlocalplayerthing(), pulley_3_b, 0); // else turn it off; return; end