home *** CD-ROM | disk | FTP | other *** search
- #
- # Droids Cog Script
- #
- # 03_Tanks.cog
- #
- # bin 27 gear, this number can be changed. Right now, it's Doug's large gear bin number.
- # Desc:
- # This cog is responsible for keeping track of what gears are in the Gear assembly and where.
- # It's also in charge of moving the lock either to the right or to the left, depending on where
- # the gears are placed. There are also separate cogs for the gear pieces themselves when found.
- # After they've been placed in this assembly, they are part of this script. This cog will trigger
- # the water in the water tanks moving up and down also.
- #
- #
- # 1/27/98 [JP] Created, mostly with lines taken from Doug's mega Gear cog...
- #
- # <C> 1998 LucasLearningLimited. All Rights Reserved--------------------------------------------------------------------------------
-
-
- symbols
-
- message startup
- message used
- message arrived
- message user0
- message taken
- message timer
- message entered
-
- surface button0 linkid=2
- surface sign0
-
- ## Parts
- thing screw0 linkid=11 //horizontal worm gear
- thing lock linkid=3 //tank lock
- thing big_gear_vert linkid=11 //permanent big gear vertical, you don't place or take this
- thing big_gear_hori linkid=11 //permanent big gear horizontal, you don't place or take this
- thing med_gear_vert linkid=9 //permanent med gear vertical, you don't place or take this11
-
-
- ##Ghost Objects
- thing lower_left_spindle_g linkid=30
- thing lower_right_spindle_g linkid=31
- thing upper_left_spindle_g linkid=32
- thing upper_right_spindle_g linkid=33
-
- ##Ghost creation integers
- int lower_left_spindle_i=0 linkid=30 local
- int lower_right_spindle_i=0 local
- int upper_left_spindle_i=0 local
- int upper_right_spindle_i=0 local
-
- ##Spin Direction integers
- flex lower_left_spindle_d=0.0 local
- flex lower_right_spindle_d=0.0 local
- flex upper_left_spindle_d=0.0 local
- flex upper_right_spindle_d=0.0 local
- flex big_gear_vert_d=0.0 local
- flex big_gear_hori_d=0.0 local
- flex med_gear_vert_d=0.0 local
-
-
- ##templates
- template med_gear_t
-
- ##Sectors
- sector lower_left_sector //for placing gear in lower left slot
- sector lower_right_sector // " " in lower right slot
- sector upper_left_sector // " " in upper left
- sector upper_right_sector // " " in upper right
-
- ##cogs
- cog tempbuttoncog
- cog watermove1
-
- ##sounds
- sounds machine_on //moving .wav
- sounds place_gear
-
- ## Integral Variables
- float speed=2.0 local
- int on_button0=0 local
- int rotate local
- int lower_left_spindle=0 local
- int lower_right_spindle=0 local
- int upper_left_spindle=0 local
- int upper_right_spindle=0 local
- int timermode=0 local
- int part_id=0 local
- int bin=27 local
-
- sound motorfree=MCHt9MotFree.WAV
- sound motor=MCHt9MotFree.WAV
- sound switch=MCHt9MotStrt.WAV //button
- sound attach=SWTt9GearOn.WAV
- sound taken=SWTt9GearOff.WAV
- sound grind=MCHt9GearBog.WAV
- sound rotating=MCHt9MotStrss.WAV
- sound closing=ELVt7BigElevLp.WAV
-
- thing bottomspindles linkid=9 //was 11
- thing topspindles linkid=10 //was 11
- thing platA linkid=10
- thing platB linkid=10
- thing lockpodA linkid=9
- thing motorpodA linkid=9
-
- cog ecam1 //solution for tanks1
- cog maps
- cog buttoncog
-
- message pulse
-
- sound gearon=swtt9gearon.wav local
- sound gearoff=swtt9gearoff.wav local
- sound free=MCHt9MotFree.wav local
-
- surface s1
- surface s2
-
- cog arrows
-
- sound start=MCHt9MotStrt.wav local
- sound fin=MCHt9MotStp.wav local
-
- surface s3
-
- surface a1 linkid=5
-
- end
-
- ## Code Section
- code
-
- startup:
- //rotate = 1;
- //lower_left_spindle_d = -0.5;
- //lower_right_spindle_d = 0.5;
- //big_gear_vert_d = -0.5;
- //big_gear_hori_d = 0.5;
- //med_gear_vert_d = 0.5;
- //call rotate_gears;
- //print ("try4");
- SetWallCel(sign0, 1);
- AttachThingToThing (screw0, big_gear_vert);
- player=getlocalplayerthing();
- //these two lines below need to be monitored...
- motorpos=vectory(getthingpos(med_gear_vert));
- MiddleY=motorpos+.2039;
- setpulse(0.5);
- return;
-
-
- #==================================
- //pulse:
- //print("template");
- //printint(med_gear_t);
- //print("lowerleft");
- //printint(lower_left_spindle_i);
- //print("lowerright");
- //printint(lower_right_spindle_i);
- //print("upperleft");
- //printint(upper_left_spindle_i);
- //print("upperright");
- //printint(upper_right_spindle_i);
- //print("lowerleft G");
- //printint(lower_left_spindle_g);
- //print("lowerright G");
- //printint(lower_right_spindle_g);
- //print("upperleft G");
- //printint(upper_left_spindle_g);
- //print("upperright G");
- //printint(upper_right_spindle_g);
- //print("dummy");
- //printint(dummy);
- //print("dummy2");
- //printint(dummy2);
- //print("screw0");
- //printint(screw0);
- //print("lock");
- //printint(lock);
- //print("lowerleft D");
- //printflex(lower_left_spindle_d);
- //print("tempbuttoncog");
- //printint(tempbuttoncog);
- //print("watermove1");
- //printint(watermove1);
- //print("machine_on");
- //printint(machine_on);
- //print("place_gear");
- //printint(place_gear);
- //print("big_gear_vert");
- //printint(big_gear_vert);
- //print("big_gear_hori");
- //printint(big_gear_hori);
- //print("med_gear_vert");
- //printint(med_gear_hori);
- //print("lower_left_spindle");
- //printint(lower_left_spindle);
-
- //return;
-
-
- user0:
- //User0 gets called when the player hits the motor switch, see tank_activate.cog
- print("user0");
- if (rotate == 0) call start_motor;
- return;
-
- ##======================================
- used:
- // Section is executed when the user uses an inventory object.
- print("used:");
- printint (dwGetActivateBin());
- printint (getsenderid());
- if (rotate == 0)
- {
- if ( getinv(getlocalplayerthing(), dwGetActivatebin()) > 0)
- {
- if (GetSenderId() == 9) //bottom spindles...
- {
- playery=vectory(getthingpos(player));
- printflex(playery);
- printflex(MiddleY);
- {
- if (playery < MiddleY)
- {
- call handle_lower_right;
- }
- if (playery > MiddleY)
- {
- call handle_lower_left;
- }
- }
- }
-
- else if (GetSenderId() == 10)
- {
- playery=vectory(getthingpos(player));
- printflex(playery);
- printflex(MiddleY);
- {
- if (playery < MiddleY)
- {
- call handle_upper_right;
- }
- if (playery > MiddleY)
- {
- call handle_upper_left;
- }
- }
- }
- else if (GetSenderId() == 5)
- {
- playery=vectory(getthingpos(player));
- printflex(playery);
- printflex(MiddleY);
- {
- if (playery < MiddleY)
- {
- call handle_upper_right;
- }
-
- if (playery > MiddleY)
- {
- call handle_upper_left;
- }
- }
- }
-
- else
- {
- dwplaycammyspeech(0, "GHCA056.wav", 4, 2);
- }
- }
- }
-
- return;
-
- # =====================
- entered:
-
- if (getthingsector(getlocalplayerthing()) == upper_left_sector)
- print ("WE'RE IN");
- return;
-
- #======================
- taken:
- print ("taken");
- if (rotate == 0)
- {
- if (GetSenderId() == 9) // if it's the motor gear- p_med_gear_vert that got activated
- {
- playery=vectory(getthingpos(player));
- {
- if (playery < Middley) //right side
- {
- if (lower_right_spindle != 0)
- {
- // increase the bin to add it back to the inv, destroy one in the environment, and set
- // lower_left_spindle to 0
- ChangeInv(getlocalplayerthing(), lower_right_spindle, 1);
- destroything(lower_right_spindle_i);
- lower_right_spindle = 0;
- call update_bins;
- }
- else
- {
- // TELL THE PLAYER THERE'S NOTHING TO TAKE
- // there's nothing to take
- timermode = 2;
- settimer(10);
- }
- }
- if (playery > MiddleY) //left side
- {
- if (lower_left_spindle != 0)
- {
- // increase the bin to add it back to the inv, destroy one in the environment, and set
- // lower_right_spindle to 0
- ChangeInv(getlocalplayerthing(), lower_left_spindle, 1);
- destroything(lower_left_spindle_i);
- lower_left_spindle = 0;
- call update_bins;
- }
- else
- {
- // TELL THE PLAYER THERE'S NOTHING TO TAKE
- // there's nothing to take
- timermode = 2;
- settimer(10);
- }
- }
-
- }
- }
- if (GetSenderId() == 10)
- {
- playery=vectory(getthingpos(player));
- {
- if (playery < MiddleY) //right side
- {
- // player is taking stuff from the upper left of gear assembly
- if (upper_right_spindle != 0)
- {
- // increase the bin to add it back to the inv, destroy one in the environment, and set
- // upper_right_spindle to 0
- ChangeInv(getlocalplayerthing(), upper_right_spindle, 1);
- destroything(upper_right_spindle_i);
- upper_right_spindle = 0;
- call update_bins;
- }
- else
- {
- // TELL THE PLAYER THERE'S NOTHING TO TAKE
- // there's nothing to take
- timermode = 2;
- settimer(10);
- }
- }
-
- if (playery > MiddleY) //left side
- {
- if (upper_left_spindle != 0)
- {
- // increase the bin to add it back to the inv, destroy one in the environment, and set
- // upper_right_spindle to 0
- ChangeInv(getlocalplayerthing(), upper_left_spindle, 1);
- destroything(upper_left_spindle_i);
- upper_left_spindle = 0;
- call update_bins;
- }
- else
- {
- // TELL THE PLAYER THERE'S NOTHING TO TAKE
- // there's nothing to take
- timermode = 2;
- settimer(10);
- }
- }
- }
- }
-
- if (GetSenderId() == 5)
- {
- playery=vectory(getthingpos(player));
- {
- if (playery < MiddleY) //right side
- {
- // player is taking stuff from the upper left of gear assembly
- if (upper_right_spindle != 0)
- {
- // increase the bin to add it back to the inv, destroy one in the environment, and set
- // upper_right_spindle to 0
- ChangeInv(getlocalplayerthing(), upper_right_spindle, 1);
- destroything(upper_right_spindle_i);
- upper_right_spindle = 0;
- call update_bins;
- }
- }
-
- if (playery > MiddleY) //left side
- {
- if (upper_left_spindle != 0)
- {
- // increase the bin to add it back to the inv, destroy one in the environment, and set
- // upper_right_spindle to 0
- ChangeInv(getlocalplayerthing(), upper_left_spindle, 1);
- destroything(upper_left_spindle_i);
- upper_left_spindle = 0;
- call update_bins;
- }
- }
- }
- }
-
- }
-
- return;
-
- # ============== the long start motor section...
- start_motor:
- // if all the gears are in place
- playsoundlocal(start, 1, 0, 0); //LL
- print("start_motor");
- if ( (lower_left_spindle == bin) && (lower_right_spindle == bin) && (upper_left_spindle == bin) && (upper_right_spindle == bin) )
- { // case 4
- print ("case4");
- lower_left_spindle_d = 0; // none of the placeable gears move
- lower_right_spindle_d = 0;
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.0;
- // TODO: GRIND THE MOTOR FOR A LITTLE BIT
- PlaySoundThing(grind, med_gear_vert, 1, -1, -1, 0); //grind
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA056.wav", 4, 2);
- }
-
- else if ( (lower_right_spindle == bin) && (upper_right_spindle == bin) )
- { // there are gears in upper and lower right places at the same time
- // case 3, 4, 5, 6
- print ("case3456");
- lower_left_spindle_d = 0;
- lower_right_spindle_d = 0;
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.0;
-
- // TODO: GRIND THE MOTOR FOR A LITTLE BIT
- PlaySoundThing(grind, med_gear_vert, 1, -1, -1, 0); //grind
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA056.wav", 4, 2);
- }
-
-
-
- else if ( (lower_left_spindle == bin) && (lower_right_spindle != bin) && (upper_left_spindle == bin) && (upper_right_spindle == bin) )
- { // case 10: solution for Lock B (but not for Lock A)
- print("case10s");
- lower_left_spindle_d = 0;
- lower_right_spindle_d = 0;
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.0;
-
- // TODO: GRIND THE MOTOR FOR A LITTLE BIT
- PlaySoundThing(grind, med_gear_vert, 1, -1, -1, 0); //grind
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA056.wav", 4, 2);
- }
-
- else //set up so that something will spin (at least the motor gear: p_med_gear_vert)
- { // ++++++ set motion/direction
- //med_gear_vert = 0; // assume that if the motor gear is going to move, the below lines will set it that way
-
- if ( (lower_right_spindle != bin) && (upper_right_spindle != bin) )
- { // there are no gears in the upper and lower right spindles
- // case 7, 8, 9
- print("case789");
- lower_left_spindle_d = 0;
- lower_right_spindle_d = 0;
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = 0.0; //no movement
- big_gear_hori_d = 0.0; //no movement
- med_gear_vert_d = 0.5; //there's movement!! COUNTER-CLOCKWISE
- call rotate_gears;
- timermode = 1; // Timermode tells the timer what to do when it's called.
- settimer(4); //was 10
-
- // TODO: CAMBOT DIALOG
- motorfreei=PlaySoundThing(free, med_gear_vert, 1, -1, -1, 0x1); //motorfree
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA062.wav", 4, 2);
- }
-
- else if ( (lower_left_spindle != bin) && (lower_right_spindle != bin) && (upper_left_spindle != bin) && (upper_right_spindle == bin) )
- { // case 11
- print("case11");
- lower_left_spindle_d = 0;
- lower_right_spindle_d = 0;
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0.5; // gear is in this slot! CLOCKWISE
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.5; //there's movement!! COUNTER-CLOCKWISE
- call rotate_gears;
- timermode = 1; // Timermode tells the timer what to do when it's called.
- settimer(4); //was 10
- rotatingi=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA062.wav", 4, 2);
- }
-
- else if ( (lower_left_spindle != bin) && (lower_right_spindle == bin) && (upper_left_spindle != bin) && (upper_right_spindle != bin) )
- { // case 12
- print("case12");
- lower_left_spindle_d = 0;
- lower_right_spindle_d = -0.5; // gear is in this slot! CLOCKWISE
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.5; //theres' movement! COUNTER-CLOCKWISE
- call rotate_gears;
- timermode = 1; // Timermode tells the timer what to do when it's called.
- settimer(4); //was 10
- rotatingi=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA062.wav", 4, 2);
- }
-
- else if ( (lower_left_spindle == bin) && (lower_right_spindle != bin) && (upper_left_spindle != bin) && (upper_right_spindle == bin) )
- { // case 13
- print("case13");
- lower_left_spindle_d = 0; // gear is in this slot! NO MOVEMENT
- lower_right_spindle_d = 0;
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0.5; // gear is in this slot! CLOCKWISE
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.5; //there's movement! COUNTERCLOCKWISE
- call rotate_gears;
- timermode = 1; // Timermode tells the timer what to do when it's called.
- settimer(4); //was 10
- rotatingi=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA062.wav", 4, 2);
- }
-
- else if ( (lower_left_spindle != bin) && (lower_right_spindle == bin) && (upper_left_spindle == bin) && (upper_right_spindle != bin) )
- { // case 14
- print("case14");
- lower_left_spindle_d = 0;
- lower_right_spindle_d = 0.5; // gear is in this slot! CLOCKWISE
- upper_left_spindle_d = 0; // gear is in this slot! NO MOVEMENT
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.5; //there's movement! COUNTERCLOCKWISE
- call rotate_gears;
- timermode = 1; // Timermode tells the timer what to do when it's called.
- settimer(4); //was 10
- rotatingi=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA062.wav", 4, 2);
- }
-
- else if ( (lower_left_spindle != bin) && (lower_right_spindle != bin) && (upper_left_spindle == bin) && (upper_right_spindle == bin) )
- { // case 15
- print("case15");
- lower_left_spindle_d = 0;
- lower_right_spindle_d = 0;
- upper_left_spindle_d = -0.5; // gear is in this slot! COUNTER-CLOCKWISE
- upper_right_spindle_d = 0.5; // gear is in this slot! CLOCKWISE
- //permanent ones:
- big_gear_vert_d = 0.0; //none of the permenant gears move
- big_gear_hori_d = 0.0;
- med_gear_vert_d = 0.5; //there's movement! COUNTER-CLOCKWISE
- call rotate_gears;
- timermode = 1; // Timermode tells the timer what to do when it's called.
- settimer(4); //was 10
- rotatingi=PlaySoundThing(rotating, med_gear_vert, 1, -1, -1, 0x1);
- sleep(1.5);
- dwplaycammyspeech(0, "GHCA056.wav", 4, 2);
- }
-
- else if ( (lower_left_spindle == bin) && (lower_right_spindle == bin) && (upper_left_spindle != bin) && (upper_right_spindle != bin) )
- { // case 1 SOLUTION!!!!!
- print("case1");
- lower_left_spindle_d = 0.5; // gear is in this slot! COUNTER-CLOCKWISE
- lower_right_spindle_d = 0.5; // gear is in this slot! CLOCKWISE
- upper_left_spindle_d = 0;
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = -0.5; // there's movement! CLOCKWISE
- big_gear_hori_d = 0.5; // there's movement! CLOCKWISE
- med_gear_vert_d = 0.5; // there's movement! COUNTER-CLOCKWISE
- call rotate_gears;
- MoveToFrame(lock, 1, 0.3); //from 0.2 speed
- SetWallCel(sign0, 0);
- sendmessage(watermove1, user1);
- sendmessage(ecam1, user1);
- sendmessage(maps, user1); //sent to maps.cog
- sendmessage(buttoncog, user3); //switch access denied
- sendmessage(arrows, user1);
- //rotatingi=PlaySoundThing(rotating, med_gear_vert, 0.5, -1, -1, 0x1);
- //closingi=PlaySoundThing(closing, lock, 1, -1, -1, 0x1);
- rotatingi=PlaySoundlocal(rotating, 0.7, 0, 0x1);
- closingi=PlaySoundlocal(closing, 0.7, 0, 0x1);
- print("buttoncog, user3");
- dwplaycammyspeech(16028, "M3CA023.wav", 5, 2); //turning! you've closed it!
- }
-
- else if ( (lower_left_spindle == bin) && (lower_right_spindle == bin) && (upper_left_spindle == bin) && (upper_right_spindle != bin) )
- { // case 2 SOLUTION (not as nice as case 1, but still works)
- print("case2");
- lower_left_spindle_d = -0.5; // gear is in this slot! COUNTER-CLOCKWISE
- lower_right_spindle_d = 0.5; // gear is in this slot! CLOCKWISE
- upper_left_spindle_d = 0.5; // gear is in this slot! CLOCKWISE
- upper_right_spindle_d = 0;
- //permanent ones:
- big_gear_vert_d = -0.5; // there's movement! CLOCKWISE
- big_gear_hori_d = 0.5; // there's movement! CLOCKWISE
- med_gear_vert_d = 0.5; // there's movement! COUNTER-CLOCKWISE
- call rotate_gears;
- MoveToFrame(lock, 1, 0.3); //from 0.2 speed
- SetWallCel(sign0, 0);
- sendmessage(buttoncog, user3); //switch access denied
- sendmessage(watermove1, user1);
- sendmessage(ecam1, user1); //ecam1 for tanks1
- sendmessage(maps, user1); //sent to maps.cog
- sendmessage(arrows, user1);
- //rotatingi=PlaySoundThing(rotating, med_gear_vert, 0.5, -1, -1, 0x1);
- //closingi=PlaySoundThing(closing, lock, 1, -1, -1, 0x1);
- rotatingi=PlaySoundlocal(rotating, 0.7, 0, 0x1);
- closingi=PlaySoundlocal(closing, 0.7, 0, 0x1);
- dwplaycammyspeech(16028, "M3CA023.wav", 5, 2);
- }
-
- printint (lower_left_spindle);
- printflex(lower_left_spindle);
-
- //if (med_gear_vert_d > 0) // if the permenant motor gear is rotating COUNTER-CLOCKWISE
- // {
- // if (GetCurFrame(lock) != 0)
- // {
- // print("lock move");
- // MoveToFrame(lock, 1, speed);
- // call rotate_gears;
- // }
- // }
-
- }
- return;
-
-
- ##================
- handle_lower_left:
- // handle lower left is used to put gears on the lower left side of the assembly.
- print("handle_lower_left");
- if (lower_left_spindle == 0) // if the lower left spindle is empty
- {
- // adds whatever you gots to the spindle
- if (dwGetActivateBin() == 27) // if it's the "bin" gear
- {
- // 3 things happen: 1st variable lower_left_spindle is set to the gear that's going to go on the spindle
- // The bin number from the gear is used to represent what gear is on the spindle.
- // If lower_left_spindle is set to 0, then there should be no gear on the spindle. If a non-zero #,
- // it represents the present gear's bin number.
- lower_left_spindle = dwGetActivateBin();
- print ("l_l_gear_on");
- // creating the gear to be attached on the spindle
- lower_left_spindle_i = creatething (med_gear_t, lower_left_spindle_g);
- ChangeInv(getlocalplayerthing(), lower_left_spindle, -1);
- playsoundlocal(gearon, 1, 0, 0);
- call update_bins;
- }
- }
- else
- {
- //cambot: there's something on the spindle already!
- timermode = 2;
- settimer(10);
- }
- return;
-
- ##=================
- handle_lower_right:
- // handle lower right is used to put gears on the lower right side of the assembly.
- print("handle_lower_right");
- if (lower_right_spindle == 0) // if the lower right spindle is empty
- {
- // adds whatever you gots to the spindle
- if (dwGetActivateBin() == 27) // if it's the "bin" gear
- {
- //read desc for handle_lower_left to understand.
- lower_right_spindle = dwGetActivateBin();
- print ("l_r_gear_on");
- // creating the gear to be attached on the spindle
- lower_right_spindle_i = creatething (med_gear_t, lower_right_spindle_g);
- ChangeInv(getlocalplayerthing(), lower_right_spindle, -1);
- playsoundlocal(gearon, 1, 0, 0);
- call update_bins;
- }
- }
- else
- {
- //dwsetmissiontext(17304); // cambot: there's something on the spindle already!
-
- timermode = 2;
- settimer(10);
- }
- return;
-
- ##=================
- handle_upper_left:
- // handle upper left is used to put gears on the upper left side of the assembly.
- print("handle_upper_left");
- if (upper_left_spindle == 0) // if the upper left spindle is empty
- {
- // adds whatever you gots to the spindle
- if (dwGetActivateBin() == 27) // if it's the "bin" gear
- {
- //read desc for handle_lower_left to understand.
- upper_left_spindle = dwGetActivateBin();
- print ("u_l_gear_on");
- // creating the gear to be attached on the spindle
- upper_left_spindle_i = creatething (med_gear_t, upper_left_spindle_g);
- ChangeInv(getlocalplayerthing(), upper_left_spindle, -1);
- playsoundlocal(gearon, 1, 0, 0);
- call update_bins;
- }
- }
- else
- {
- //dwsetmissiontext(00000); // cambot: there's something on the spindle already!
-
- timermode = 2;
- settimer(10);
- }
- return;
-
- ##=================
- handle_upper_right:
- // handle upper right is used to put gears on the upper right side of the assembly.
- print("handle_upper_right");
- if (upper_right_spindle == 0) // if the upper right spindle is empty
- {
- // adds whatever you gots to the spindle
- if (dwGetActivateBin() == 27) // if it's the "bin" gear
- {
- //read desc for handle_lower_left to understand.
- upper_right_spindle = dwGetActivateBin();
- print ("u_r_gear_on");
- upper_right_spindle_i = creatething (med_gear_t, upper_right_spindle_g);
- ChangeInv(getlocalplayerthing(), upper_right_spindle, -1);
- playsoundlocal(gearon, 1, 0, 0);
- call update_bins;
- }
- }
- else
- {
- //dwsetmissiontext(17304); // cambot: there's something on the spindle already!
-
- timermode = 2;
- settimer(10);
- }
- return;
-
- ##==================
- rotate_gears:
- //This routine starts the gears a spinnin. After they continue, use "continue_gears:"
- call adjoinon;
- rotate = 1;
- RotatePivot(med_gear_vert, 1, 0.5); // permanent motor gear COUNTERCLOCKWISE.
- print ("rotate_gears");
- printint(lower_left_spindle_d);
- if (!(lower_left_spindle_d == 0.0)) RotatePivot(lower_left_spindle_i, 1, lower_left_spindle_d);
- if (!(lower_right_spindle_d == 0.0)) RotatePivot(lower_right_spindle_i, 1, lower_right_spindle_d);
- if (!(upper_left_spindle_d == 0.0)) RotatePivot(upper_left_spindle_i, 1, upper_left_spindle_d);
- if (!(upper_right_spindle_d == 0.0)) RotatePivot(upper_right_spindle_i, 1, upper_right_spindle_d);
- // and the permanent ones:
- //if (!(med_gear_vert_d == 0.0)) RotatePivot(med_gear_vert, 1, med_gear_vert_d);
- if (!(big_gear_vert_d == 0.0)) RotatePivot(big_gear_vert, 1, big_gear_vert_d);
- if (!(big_gear_hori_d == 0.0)) RotatePivot(big_gear_hori, 1, big_gear_hori_d);
- if (!(med_gear_vert_d == 0.0)) RotatePivot(med_gear_vert, 1, med_gear_vert_d);
- return;
-
-
- ##====================
- continue_gears:
- print("continue_gears");
- printint(getsenderid());
- if (!(lower_left_spindle_d == 0.0)) RotatePivot(lower_left_spindle_i, 1, lower_left_spindle_d);
- if (!(lower_right_spindle_d == 0.0)) RotatePivot(lower_right_spindle_i, 1, lower_right_spindle_d);
- if (!(upper_left_spindle_d == 0.0)) RotatePivot(upper_left_spindle_i, 1, upper_left_spindle_d);
- if (!(upper_right_spindle_d == 0.0)) RotatePivot(upper_right_spindle_i, 1, upper_right_spindle_d);
- // and the permanent ones:
- if (!(med_gear_vert_d == 0.0)) RotatePivot(med_gear_vert, 1, med_gear_vert_d);
- if (!(big_gear_vert_d == 0.0)) RotatePivot(big_gear_vert, 1, big_gear_vert_d);
- if (!(big_gear_hori_d == 0.0)) RotatePivot(big_gear_hori, 1, big_gear_hori_d);
- return;
-
- ##===================
- stop_gears:
- //this routine will hopefully stop all the gears... hopefully...
- call adjoinoff;
- playsoundlocal(fin, 1, 0, 0);
- stopthing(lower_left_spindle_i);
- stopthing(lower_right_spindle_i);
- stopthing(upper_left_spindle_i);
- stopthing(upper_right_spindle_i);
- stopthing(big_gear_vert);
- stopthing(big_gear_hori);
- stopthing(med_gear_vert); // motor gear
- rotate = 0;
- stopsound(motorfreei, 0.5);
- stopsound(rotatingi, 0.5);
- stopsound(closingi, 0.5);
- //sendmessage(tank_button_cog, user0);
- return;
-
- ##====================
- arrived:
- if ((GetSenderId() != 3) && (rotate == 1))
- {
- print("I arrived");
- call continue_gears;
- }
-
- if (GetSenderId() == 3)
- {
- call stop_gears;
- //dwsetmissiontext(00000); //clears cambot's text
- rotate = 0;
- }
- return;
-
- ##=====================
- timer:
- if (timermode == 1) // will turn off the gears
- {
- call stop_gears;
- rotate = 0;
- }
- else if (timermode == 2) // will clear cambot's text
- {
- //dwsetmissiontext(00000); //clears cambot's text
- }
- return;
-
- ##======================
- update_bins:
- //this is a utility routine used to turn on and off availability of items.
- // Until Jon B. adds it into DW.
- playsoundlocal(gearoff, 1, 0, 0);
- if ( getinv(getlocalplayerthing(),bin) > 0) SetInvAvailable(getlocalplayerthing(), bin, 1); //if the bin has more than 0 turn on the inv icon;
- else SetInvAvailable(getlocalplayerthing(), bin, 0); // else turn it off;
- return;
-
- adjoinon:
- clearadjoinflags(s1, 2);
- clearadjoinflags(s2, 2);
- clearadjoinflags(s3, 2);
- return;
-
- adjoinoff:
- setadjoinflags(s1, 2);
- setadjoinflags(s2, 2);
- setadjoinflags(s3, 2);
- return;
-
- end
-
-
-
-
-