home *** CD-ROM | disk | FTP | other *** search
Wrap
# Droids COG Script # # b0_PulleySetup3.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 Setup1_cog cog setup2_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 thing rope3a thing rope3b thing rope4a thing rope4b ## ----------------Rope Integers int rope1_i local int rope2_i local int rope3_i local int rope4_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(); //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(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/1.5); rope2_i = addbeam(rope2a, rope2b, l_color, l_size/1.5); rope3_i = addbeam(rope3a, rope3b, l_color, l_size/1.5); rope4_i = addbeam(rope4a, rope4b, l_color, l_size/1.5); attachthingtothing(rope1b, hook_i); attachthingtothing(rope2a, hook_i); attachthingtothing(rope3b, hook_i); attachthingtothing(rope4a, hook_i); attachthingtothing(pulley_bot_i, 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(rope1b); detachthing(rope2a); detachthing(rope3b); detachthing(rope4a); detachthing(pulley_bot_i); removelaser(rope1_i); removelaser(rope2_i); removelaser(rope3_i); removelaser(rope4_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 if (setup == 1) // if the pulley is setup { 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("Freeze3"); dwfreezeplayer(); if (getcurframe(hook_i) == 1) //if the pulley is down { if (arm_str > 0) //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: not strong enough dwsetreftopic("pulley.tpc"); print("UnFreeze3"); dwunfreezeplayer(); } } else //else the hook is up { print("UnFreeze3"); dwunfreezeplayer(); dwPlayCammySpeech(10007, "t3ca013.wav", 10, 0); // Cammy: The hook's not attached to anyting } } } return; used: print("Used:"); printint(dwGetActivateBin()); printint(pulley_2_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_1_b) //Putting on pulley config # 1 { if ( getinv(getlocalplayerthing(),pulley_1_b) > 0) // If it's in his inventory { call user1; print("setup 3: Sent to 1"); ChangeInv(getlocalplayerthing(), pulley_1_b, -1); // remove a #1 pulley from inv changeInv(getlocalplayerthing(), pulley_3_b, 1); // add a #3 pulley to inv call update_bins; // Send To Pulley config #1: Setup dwPlayCammySpeech(10005, "t3ca011.wav", 10, 0); // Cammy: pullies switched sendmessage(setup1_cog,user0); // Set up pulley 1 } } 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; print("setup 3: Sent to 2"); ChangeInv(getlocalplayerthing(), pulley_2_b, -1); // remove a #2 pulley from inv ChangeInv(getlocalplayerthing(), pulley_3_b, 1); // add a #3 pulley to inv call update_bins; // Send To Pulley config #2: Setup dwPlayCammySpeech(10005, "t3ca011.wav", 10, 0); // Cammy: pullies switched sendmessage(setup2_cog,user0); // Set up pulley 2 } } } 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 (moving == 0) { if (global0 == 0) global0 =1; // change PulleyJawa dialog 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("Freeze3"); dwfreezeplayer(); //stop the player from moving while it's all going on setpulse(0.2); } else //else the hook is down { moving = 1; //Don't get messages until it arrived bounce = 1; SetCollideType(hook_i, 0); // turn off collides for the hook SetCollideType(pulley_bot_i, 0); // Turn off collides for the bottom pulley 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("Freeze3"); 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: ou don't need to work the pulle } } } 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("UnFreeze3"); 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: 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 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 SetCollideType(pulley_bot_i, 3); // Turn on collides for the bottom pulley if (sounder >0) stopsound(sounder,0.1); // Stop the sound sendmessage(pulley_rop,user0); // reset the rope to it's loose state SetInv(player, 1, 1); // Set the mission objective to True dwPlayCammySpeech(10012, "M2CA025.wav", 10, 0); // Cammy:All rite! lift = 4; print("UnFreeze3"); 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