home *** CD-ROM | disk | FTP | other *** search
Wrap
# Droids COG Script # # b0_PulleySetup1.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 1. It also talks with the rop cog to # tell it to sag and whatnot. It's pretty hairy. # # 01/15/98 [DGS] Created # # ======================================================================================== symbols message User0 message User1 message user3 message activate message pulse message arrived message startup message used ## ----------------Cogs cog pulley_rop cog Setup2_cog cog setup3_cog ## ----------------Things thing block linkid=1 thing clamp nolink thing flap linkid=1 surface act_sur ## ----------------Templates template pulley1_t template hook_t ## ----------------Ghost Objects thing Pulley_top_g thing hook_g ## ----------------Thing Integers int pulley_top_i local int hook_i local ## ----------------Rope Ghosts thing rope1a thing rope1b ## ----------------Rope Integers int rope1_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: global0 = 0; global1 = 0; global2 = 0; player = getlocalplayerthing(); arm_str = dwGetArmStrength(); //arm_str = 100; dwPlayCammySpeech(16001, "t3ca002.wav", 10, 0); attachthingtothing(clamp,block); call user0; // set it'self up return; user0: // AKA Setup // build the pulley setup setup = 1; // Says that the setup is up pulley_top_i = creatething(pulley1_t, pulley_top_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); attachthingtothing(rope1b, hook_i); 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 removelaser(rope1_i); detachthing(rope1b); destroything(pulley_top_i); destroything(hook_i); return; user3: // AKA Pull on the rope // Someone's a tuggin' on the otha end of the rope // This routine is called by pulley_rop cog when the rope is pulled on. It's in charge of figuring // out whether or not the droid can lift the block and animating it. 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("Freeze1"); dwfreezeplayer(); if (getcurframe(hook_i) == 1) //if the pulley is down { if (arm_str > 8) //if the droid's arm strength is strong enough { // They are pulling up the block 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 the spool to start spinning 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("UnFreeze1"); dwunfreezeplayer(); } } else //else the hook is up { print("Lifto:"); printint(lift); dwPlayCammySpeech(10007, "t3ca013.wav", 10, 0); // Cammy: The hook's not attached to anyting print("UnFreeze1"); dwunfreezeplayer(); } } } return; used: print("1 Used:"); printint(dwGetActivateBin()); print("Ice:"); printint(pulley_2_b); printint(pulley_3_b); // 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_2_b) //Putting on pulley config # 2 { if ( getinv(getlocalplayerthing(),pulley_2_b) > 0) // If it's in his inventory { call user1; ChangeInv(getlocalplayerthing(), pulley_2_b, -1); // remove a #2 pulley from inv ChangeInv(getlocalplayerthing(), pulley_1_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 print("setup 1: Sent to 2"); sendmessage(setup2_cog,user0); // Set up pulley 2 } } if (dwGetActivateBin() == pulley_3_b) //Putting on pulley config # 2 { if ( getinv(getlocalplayerthing(),pulley_3_b) > 0) // If it's in his inventory { call user1; ChangeInv(getlocalplayerthing(), pulley_3_b, -1); // remove a #3 pulley from inv ChangeInv(getlocalplayerthing(), pulley_1_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 print("setup 1: Sent to 3"); 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 before you can switch out the pulleys } } 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) { setCollideType(hook_i, 0); // turn off collides for the hook 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("Freeze1"); dwfreezeplayer(); //stop the player from moving while it's all going on setpulse(0.2); } else { setCollideType(hook_i, 0); // turn off collides for the hook 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("Freeze1"); 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("UnFreeze1"); dwunfreezeplayer(); print("Stop Bob"); setCollideType(hook_i, 3); // turn off collides for the hook 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:it hooked onto the block } } 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 the spool to stop spinning 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, 1); // turn off collides for the hook if (sounder >0) stopsound(sounder,0.1); // Stop the sound 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:it hooked onto the block print("UnFreeze1"); 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