home *** CD-ROM | disk | FTP | other *** search
- # Droids COG Script
- #
- # ZZ_Counterweight.cog
- #
- # Desc:
- # This behemoth is the counterweight puzzle. Do not taunt it.
- #
- # 10/14/97 [DGS] Created
- # 12/01/97 [DGS] Updated to take droid's actual weight.
- #
- # ========================================================================================
-
- symbols
-
- message crossed
- message activate
- message arrived
- message timer
- message pulse
- message startup
- message entered
-
- surface add_sand linkid=8
- surface rem_sand linkid=9
-
- surface led_ones nolink
- surface led_tens nolink
- surface led_hund nolink
- surface release_brake linkid=10
- surface walkwindow nolink
- cog sander
-
- thing elevator linkid=1 nolink
- thing cube linkid=2
- thing counterweight linkid=3
- thing brake linkid=6 nolink
-
- thing line0start
- thing line0end
- thing line1start
- thing line1end
- thing line2start
- thing line2end
- thing line3start
- thing line3end
-
- sector reset_puzzle linkid=11
- sector reset_puzzle2 linkid=11
-
- sound eloop_snd=ELVt7BigElevLp.WAV local
- sound ebrake_snd=ELVt7BigElevLp.WAV local
- sound estart_snd=ELVt7BigElevSt.WAV local
- sound eend_snd=ELVt7BigElevStp.WAV local
- sound release_snd=SWT00tBigLvr.WAV local
- sound act_snd=SWT00LtSwch1.WAV local
- sound act2_snd=SWT00LtSwch2.WAV local
- flex start_wait=0.25 local
- flex sleeptime=2.0 local
- flex c_weight=10.0 local
- flex c_dest=10.0 local
- flex sand_inc=5.0 local
- flex gravity=12.0 local
- flex speed=4.0 local
- int c_crate=0 local
- int step=10 local
- int l_color=111 local
- int falling=0 local
- int maxgamage=25 local
- int mindamage=30 local
- int e_switch=0 local
- flex L_size=0.01 local
- flex droidweight=10.0 local
-
-
- end
-
- # ========================================================================================
-
- code
-
- startup:
- addbeam(line0start,line0end,l_color,l_size);
- addbeam(line1start,line1end,l_color,l_size);
- addbeam(line2start,line2end,l_color,l_size);
- addbeam(line3start,line3end,l_color,l_size);
-
- attachthingtothing(line0start,elevator);
- attachthingtothing(line1start,elevator);
- attachthingtothing(brake,elevator);
-
- attachthingtothing(line2start,counterweight);
- attachthingtothing(line3start,counterweight);
-
- droidweight = GetThingMass(GetLocalPlayerThing()) / 2.2; // Get the player's weight
- //c_weight = (droidweight) + ((rand()*20)-10); // Set th e counterweight to something near the players weight
- //c_weight = (droidweight); // Set the counterweight to something near the players weight
-
- // ++++++++++++++++++++++++++++++ These lines set the counterweight to a specific number
- if (getdifficulty() == 0) //++++++++++++++++++ EASY
- {
- print("easy");
- c_weight = (150);
- c_crate = 0;
- //destroything(cube);
- }
- else if (getdifficulty() == 1) //++++++++++++++++++ med
- {
- print("Med");
- c_weight = (10);
- c_crate = 100;
- attachthingtothing(cube,elevator);
- }
- else if (getdifficulty() == 2) //++++++++++++++++++ hard
- {
- print("Hard");
- c_weight = (50);
- //c_weight = (droidweight) + ((rand()*droidweight)-(droidweight/2)); // Set th e counterweight to something near the players weight
- c_crate = 140;
- }
-
- c_weight = c_weight - (c_weight % 10); // Rounds the weight to a 10
- call displayweight;
- return;
- crossed: // If player crosses adjoin(s)
-
- return;
-
- # ........................................................................................
-
- activate:
- print("Cweight: Activated");
- printint(getsenderid());
- printint(getsenderref());
- printint(add_sand);
- if (GetSenderId() == 10) // message came from release_brake
- {
- //--------------------------------------------- RELEASE THE BRAKE
-
- if (GetWallCel(release_brake) == 1) return; //exit if the button is down already
- SetWallCel(release_brake, 1); // Set the switch
-
-
- PlaySoundPos(release_snd, SurfaceCenter(release_brake), 0.6, -1, -1, 0);
-
- if ((droidweight + c_crate) < (c_weight)) // =========================Elev going Up
- {
- clearadjoinflags(walkwindow, 2); //close the window
- dwdisablejump();
-
-
- dwPlayCammySpeech(17105, "T7ca007.wav", 10, 0);
-
- garbage = playsoundpos(estart_snd,getsurfacecenter(release_brake),0.5,-1,-1,0);
- sounder = playsoundlocal(eloop_snd,1.0,0.0,11);
-
- speed = gravity - (gravity / (c_weight / (droidweight + c_crate)));
-
- if (speed > 7.00)
- {
- //speed=gravity; // FALLLLLLLLLLLLL ING!
- falling = 1;
- }
-
-
- SkipToFrame(elevator, 1, speed);
- SkipToFrame(counterweight, 1, speed);
- settimer(10);
- }
-
- if (droidweight + c_crate > c_weight) //Down
- {
-
- clearadjoinflags(walkwindow, 2); //close the window
- dwdisablejump();
-
-
- garbage = playsoundpos(estart_snd,getsurfacecenter(release_brake),0.5,-1,-1,0);
- sounder = playsoundlocal(eloop_snd,1.0,0.0,11);
-
-
- speed = gravity - (gravity / ((droidweight + c_crate) / c_weight));
- print("speed:");
- printflex(speed);
- if (speed > 7.00)
- {
- //speed=gravity; // FALLLLLLLLLLLLL ING!
- dwPlayCammySpeech(17107, "T7ca009.wav", 10, 0);
- falling = 1;
- }
- else
- {
- dwPlayCammySpeech(17106, "T7ca008.wav", 10, 0);
- }
- SkipToFrame(elevator, 2, speed);
- SkipToFrame(counterweight, 2, speed);
- settimer(10);
- }
-
- if (droidweight + c_crate == c_weight) //=======================================//Same
- {
- dwPlayCammySpeech(17101, "T7ca003.wav", 10, 0);
- sleep(1);
- SetWallCel(release_brake, 0); // reset the switch
- }
- printflex(speed);
- }
-
- //-----------------------------------------------END RELEASE
-
- if (GetSenderId() == 8) // message came from add_sand
- {
- call sand_add;
- }
- if (GetSenderId() == 9) // message came from rem_sand
- {
- call sand_rem;
- }
-
- return;
-
-
- # ........................................................................................
-
- arrived:
- printint(getcurframe(elevator));
- if (GetCurFrame(elevator) == 0)
- {
-
- setadjoinflags(walkwindow, 2); //open the window
- dwenablejump();
-
- SetWallCel(release_brake, 0);
- if (sounder >0) stopsound(sounder,0.5);
- sounder = playsoundthing(eend_snd,elevator,1.0,-1,-1,0);
- if (falling == 1)
- {
- victim = getlocalplayerthing();
- print("DAMAGE!!!!!!");
- damage = (rand() * (maxDamage - minDamage)) + minDamage;
- garbage = DamageThing(victim, damage, 0x2, victim); // self-inflicted damage
- falling = 0;
- }
-
- }
- return;
- # ........................................................................................
-
- sand_add:
- if (GetWallCel(add_sand) != 1) //Nothing's already happening
- {
- sendmessage(sander, user1);
- e_switch = add_sand;
- SetWallCel(e_switch, 1);
- garbage = playsoundpos(act_snd,getsurfacecenter(add_sand),0.5,-1,-1,0);
- sand_inc = 1;
- c_dest = c_weight + step;
- SetPulse(0.05);
- }
- return;
-
- sand_rem:
- if (GetWallCel(rem_sand) != 1) //Nothing's already happening
- {
- sendmessage(sander, user2);
- e_switch = rem_sand;
- SetWallCel(e_switch, 1);
- garbage = playsoundpos(act_snd,getsurfacecenter(rem_sand),0.5,-1,-1,0);
- sand_inc = -1;
- c_dest = c_weight - step;
- SetPulse(0.05);
- }
-
- return;
-
-
- pulse:
- c_weight = c_weight + sand_inc;
- if (c_weight < step)
- {
- sendmessage(sander, user0);
- SetPulse(0);
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- c_weight = step;
- }
- if (c_weight > 990)
- {
- sendmessage(sander, user0);
- SetPulse(0);
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- c_weight = 990;
- }
-
-
- if (c_weight == c_dest)
- {
- sendmessage(sander, user0);
- SetPulse(0);
- garbage = playsoundpos(act2_snd,getsurfacecenter(e_switch),0.5,-1,-1,0);
- SetWallCel(e_switch, 0);
- }
-
- call displayweight;
-
- return;
-
- timer:
- // Clear Cammy's message area
- // not needed anymore
- return;
-
- entered:
- if (GetSenderId() == 11) // message came from Puzzle_reset
- {
- SkipToFrame(elevator, 0, 12);
- SkipToFrame(counterweight, 0, 12);
- SetWallCel(release_brake, 0);
- }
- return;
-
- displayweight:
-
- SetWallCel(led_ones, c_weight % 10);
- SetWallCel(led_tens, (c_weight / 10) % 10);
- SetWallCel(led_hund, (c_weight / 100) % 10);
- //printint(c_crate);
- //print("And");
- //printint(droidweight);
- return;
- end
-
-