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 linkid=13
- surface led_tens linkid=13
- surface led_hund linkid=13
- surface release_brake linkid=10
-
- thing elevator linkid=1
- thing cube linkid=2
- thing counterweight linkid=3
- thing wheel linkid=5
- 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 desc=pause_before_moving_up
- flex sleeptime=2.0
- flex c_weight=10.0
- flex c_dest=10.0
- flex sand_inc=5.0 local
- flex gravity=12.0 local
- flex speed=4.0
- int c_crate=0
- int step=10
- int l_color=111 local
- flex L_size=0.01 local
- flex droidweight=10.0
-
- sound wav0=Activate02.wav
-
- 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(line2start,counterweight);
- attachthingtothing(line3start,counterweight);
-
-
- droidweight = GetThingMass(GetLocalPlayerThing()) / 2.2; // Get the player's weight
- c_weight = (droidweight) + ((rand()*100)-50); // Set th e counterweight to something near the players weight
- //c_weight = (droidweight); // Set the counterweight to something near the players weight
- c_weight = c_weight - (c_weight % 10);
- c_crate = 0;
- call displayweight;
- return;
- crossed: // If player crosses adjoin(s)
-
- return;
-
- # ........................................................................................
-
- activate:
- 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);
- PlaySoundPos(wav0, SurfaceCenter(release_brake), 0.6, -1, -1, 0);
-
- if ((droidweight + c_crate) < (c_weight)) //Up
- {
- dwsetmissiontext(17105);
- speed = gravity - (gravity / (c_weight / (droidweight + c_crate)));
- SkipToFrame(elevator, 1, speed);
- SkipToFrame(counterweight, 1, speed);
- settimer(10);
- }
-
- if (droidweight + c_crate > c_weight) //Down
- {
- speed = gravity - (gravity / ((droidweight + c_crate) / c_weight));
- if (c_weight < 26)
- {
- speed=gravity;
- dwsetmissiontext(17107);
- }
- else
- {
- dwsetmissiontext(17106);
- }
- SkipToFrame(elevator, 2, speed);
- SkipToFrame(counterweight, 2, speed);
- settimer(10);
- }
-
- if (droidweight + c_crate == c_weight) //Same
- {
- dwsetmissiontext(17101);
- }
- 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:
- if (GetCurFrame(elevator) == 0)
- {
- SetWallCel(release_brake, 0);
- PlaySoundPos(wav0, SurfaceCenter(release_brake), 0.6, -1, -1, 0);
- }
- return;
- # ........................................................................................
-
- sand_add:
- if (GetWallCel(add_sand) != 1) //Nothing's already happening
- {
- SetWallCel(add_sand, 1);
- sand_inc = 1;
- c_dest = c_weight + step;
- SetPulse(0.02);
- }
- return;
-
- sand_rem:
- if (GetWallCel(rem_sand) != 1) //Nothing's already happening
- {
- SetWallCel(rem_sand, 1);
- sand_inc = -1;
- c_dest = c_weight - step;
- SetPulse(0.02);
- }
-
- return;
-
-
- pulse:
- c_weight = c_weight + sand_inc;
- if (c_weight < step)
- {
- SetPulse(0);
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- c_weight = step;
-
- }
-
- if (c_weight == c_dest)
- {
- 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;
- end
-
-