home *** CD-ROM | disk | FTP | other *** search
- # Droids COG Script
- #
- # 03_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.
- # 2/11/98 [JP] Modified for the Moisture Farm C/W
- # ========================================================================================
-
- symbols
-
- message crossed
- message activate
- message arrived
- message timer
- message pulse
- message startup
- message entered
- message user5 #message from rdroid that he's on the startsector
-
- 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
-
- cog sander
- cog Rdroid
-
- thing wdud2
- thing elevator linkid=1
- thing wdud
- thing Repairdroid linkid=2
- thing counterweight linkid=3
- thing brake linkid=6
-
- thing line0start
- thing line0end
- thing line1start
- thing line1end
- thing line2start
- thing line2end
- thing line3start
- thing line3end
-
- sector reset_puzzle linkid=11
- 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
- flex L_size=0.01 local
- flex droidweight=10.0 local
-
- sound wav0=Activate02.wav local
- sound switch
- sound switchmax
- sound release
- sound elevmove
- sound elevstart
- sound elevstop
-
- surface a1
- surface a2
- surface a3
- surface a4
- surface a5
- surface a6
- surface a7
- surface a8
- surface a9
- surface a10
- surface a11
- surface a12
- surface a13
-
- cog rdroid2
-
- sound est=elvt7bigelevst.wav local
- sound esp=elvt7bigelevstp.wav 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);
-
- Rdroid_on=0;
-
- 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 (Rdroid_on == 0) //++++++++++++++++++ Rdroid is not on...
- {
- c_weight = (290);
- c_crate = 0;
- //destroything(cube);
- }
- //else if (getdifficulty() == 1) //++++++++++++++++++ EASY
- //{
- // c_weight = (230);
- // c_crate = 175;
- //destroything(cube);
- //}
- else if (Rdroid_on == 1) //++++++++++++++++++ EASY
- {
- c_weight = (290);
- c_crate = 175;
- //attachthingtothing(cube,elevator);
- }
-
- c_weight = c_weight - (c_weight % 10); // Rounds the weight to a 10
- call displayweight;
- return;
- crossed: // If player crosses adjoin(s)
-
- return;
-
- user5:
- print("user5");
- //if (getthingsector(Repairdroid)==startsector);
- Rdroid_on=1;
- c_crate = 175;
- 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);
- call adjoinon; //makes it impossible to get off elevator
- //dwdisablejump();
- PlaySoundPos(release, SurfaceCenter(release_brake), 1.0, -1, -1, 0); //changed wav0 to release A
- //move=(elevmove, elevator, 1, -1, -1, 0x1);
- if ((droidweight + c_crate) < (c_weight)) //Up take c_crate out?
- {
- dwplaycammyspeech(16009, "M3CA010.wav", 5, 2); //c uh oh, we're moving up...
- speed = gravity - (gravity / (c_weight / (droidweight + c_crate)));
- SkipToFrame(elevator, 1, speed);
- SkipToFrame(counterweight, 1, speed); //down
- sendmessage(Rdroid, user5); //added
- xmove=playsoundthing(elevmove, elevator, 1, -1, -1, 129); //LLL
- playsoundlocal(est, 1, 0, 0);
- dwdisablejump(); //LLL
- }
-
- if (droidweight + c_crate > c_weight) //Down
- {
- speed = gravity - (gravity / ((droidweight + c_crate) / c_weight));
- if (c_weight < 26)
- {
- speed=gravity;
- //dwsetmissiontext(16010);
- }
- else
- {
- //dwsetmissiontext(17106);
- }
- SkipToFrame(elevator, 2, speed);
- SkipToFrame(counterweight, 2, speed); //up
- sendmessage(Rdroid, user5); //added
- xmove=playsoundthing(elevmove, elevator, 1, -1, -1, 129); //LLL
- playsoundlocal(est, 1, 0, 0);
- dwdisablejump();
- dwplaycammyspeech(16099, "M3CA011.wav", 5, 2);
- }
-
- if (droidweight + c_crate == c_weight) //Same
- {
- SetWallcel(release_brake, 0);
- Playsoundlocal(switchmax, 1, 0, 0);
- //dwsetmissiontext(17101);
- }
- printflex(speed);
- }
-
- //-----------------------------------------------END RELEASE
-
- if (GetSenderId() == 8) // message came from add_sand
- {
- if ( (getwallcel(rem_sand)==1)||(getwallcel(add_sand)==1) ) return;
- call sand_add;
- }
- if (GetSenderId() == 9) // message came from rem_sand
- {
- if ( (getwallcel(rem_sand)==1)||(getwallcel(add_sand)==1) ) return;
- call sand_rem;
- }
-
- return;
-
-
- # ........................................................................................
-
- arrived:
- //print("current elev frame:")
- //printint(getc
- if (GetSenderId() == 1) //the elev
- {
- if (GetCurFrame(elevator) == 0)
- {
- SetWallCel(release_brake, 0);
- PlaySoundPos(wav0, SurfaceCenter(release_brake), 0.6, -1, -1, 0);
- print("STOP! THE! SOUND!");
- stopsound(xmove, 0.5);
- print("elevatorframeis:");
- printint(getcurframe(elevator));
- print("move droid");
- sendmessage(rdroid, user3); //if bottom
- sendmessage(rdroid, user2); //if top
- call adjoinoff;
- dwenablejump();
- playsoundlocal(esp, 1, 0, 0);
- }
- }
- return;
- # ........................................................................................
-
- sand_add:
- if ( (GetWallCel(add_sand) != 1) && (GetWallCel(rem_sand) != 1) )//Nothing's already happening
- {
- sendmessage(sander, user1);
- SetWallCel(add_sand, 1);
- PlaySoundPos(switch, SurfaceCenter(add_sand), 0.6, -1, -1, 0);
- sand_inc = 1;
- c_dest = c_weight + step;
- SetPulse(0.3);
- }
- return;
-
- sand_rem:
- if ( (GetWallCel(rem_sand) != 1) && (GetWallCel(add_sand) != 1) ) //Nothing's already happening
- {
- sendmessage(sander, user2);
- SetWallCel(rem_sand, 1);
- PlaySoundPos(switch, SurfaceCenter(rem_sand), 0.6, -1, -1, 0);
- sand_inc = -1;
- c_dest = c_weight - step;
- SetPulse(0.3);
- }
-
- return;
-
-
- pulse:
- c_weight = c_weight + sand_inc;
- if (c_weight < 200)
- {
- sendmessage(sander, user0);
- SetPulse(0);
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- c_weight = 200;
- PlaySoundPos(switchmax, SurfaceCenter(rem_sand), 1.0, -1, -1, 0);
- dwplaycammyspeech(16007, "M3CA008.wav", 5, 2);
- }
-
- if (c_weight > 300)
- {
- sendmessage(sander, user0);
- SetPulse(0);
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- c_weight = 300;
- PlaySoundPos(switchmax, SurfaceCenter(add_sand), 1.0, -1, -1, 0);
- dwplaycammyspeech(16008, "M3CA009.wav", 5, 2);
- }
-
- if (c_weight == c_dest)
- {
- sendmessage(sander, user0);
- SetPulse(0);
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- }
-
- call displayweight;
-
- return;
-
- timer:
- // Clear Cammy's message area
- //dwsetmissiontext(00000);
- return;
-
- entered:
- if (GetSenderId() == 11) // message came from Puzzle_reset
- {
- SkipToFrame(elevator, 0, 60);
- SkipToFrame(counterweight, 0, 60);
- 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;
-
-
- adjoinon:
- clearadjoinflags(a1, 2);
- clearadjoinflags(a2, 2);
- clearadjoinflags(a3, 2);
- clearadjoinflags(a4, 2);
- clearadjoinflags(a5, 2);
- clearadjoinflags(a6, 2);
- clearadjoinflags(a7, 2);
- clearadjoinflags(a8, 2);
- clearadjoinflags(a9, 2);
- clearadjoinflags(a10, 2);
- clearadjoinflags(a11, 2);
- clearadjoinflags(a12, 2);
- return;
-
- adjoinoff:
- setadjoinflags(a1, 2);
- setadjoinflags(a2, 2);
- setadjoinflags(a3, 2);
- setadjoinflags(a4, 2);
- setadjoinflags(a5, 2);
- setadjoinflags(a6, 2);
- setadjoinflags(a7, 2);
- setadjoinflags(a8, 2);
- setadjoinflags(a9, 2);
- setadjoinflags(a10, 2);
- setadjoinflags(a11, 2);
- setadjoinflags(a12, 2);
- return;
-
-
-
-
- end
-
-