home *** CD-ROM | disk | FTP | other *** search
- # DrowWorks Cog Script
- #
- # SY_MagTram G
- #
- # Magnetic Tram that goes around the entire world
- #
- # Desc:
- #
- #
- #
- # [01/18/97] DGS Created From Matt's TreadRX script.
- # [03/05/98] DGS Modified to work with sector thrusts. It got totally re-written. (Del-Fi Lost Treasures)
- #
- symbols
- ## ====================== Messages
- message startup
- message arrived
- message entered
- message exited
- message pulse
- message timer
- message touched
- message pulse
-
-
- ## = ============= Things
- thing tram
- thing door1_o
- thing door2_o
- thing door3_o
- thing door4_o
- thing door5_o
- thing acid_lift_o
- thing door6_o
- thing door7_o
- thing door8_o
- thing door9_o
- thing door10_o
- thing door11_o
- thing door12_o
- thing door13_o
- thing door14_o
-
-
- ## ================ Door Sector Ints
- int door1_s local
- int door2_s local
- int door3_s local
- int door4_s local
- int door5_s local
- int door6_s local
- int door7_s local
- int door8_s local
- int door9_s local
- int door10_s local
- int door11_s local
- int door12_s local
- int door13_s local
- int door14_s local
-
- ## ================= Sectors
- sector pickup1_s linkid=21
- sector pickup2_s linkid=22
- sector pickup3_s linkid=22
-
- ## ================= Vector
- vector up_v
-
- ## ================= Misc. Variables
- flex t_speed=20.0 local
- flex t_max=25.0 local
- flex t_cargo=10.0 local
- flex door_speed=4.0 local
- int cargo1_i=0 local
- int cargo2_i=0 local
- int cargo3_i=0 local
- int cargot_i=0 local
- int pickups_i=0 local
- int in_tram=0 local
- int rev_i=1 local
- int timermode=0 local
- end
-
- # ========================================================================================
-
- code
-
- startup:
- setpulse(1);
- //call pickup1;
- t_speed = t_max;
- movetoframe(tram,6,t_speed);
- door1_s = GetThingSector(door1_o);
- SetSectorAdjoins(door1_s, 0);
- door2_s = GetThingSector(door2_o);
- SetSectorAdjoins(door2_s, 0);
- door3_s = GetThingSector(door3_o);
- SetSectorAdjoins(door3_s, 0);
- door4_s = GetThingSector(door4_o);
- SetSectorAdjoins(door4_s, 0);
- door5_s = GetThingSector(door5_o);
- SetSectorAdjoins(door5_s, 0);
- door6_s = GetThingSector(door6_o);
- SetSectorAdjoins(door6_s, 0);
- door7_s = GetThingSector(door7_o);
- SetSectorAdjoins(door7_s, 0);
- door8_s = GetThingSector(door8_o);
- SetSectorAdjoins(door8_s, 0);
- door9_s = GetThingSector(door9_o);
- SetSectorAdjoins(door9_s, 0);
- door10_s = GetThingSector(door10_o);
- SetSectorAdjoins(door10_s, 0);
- door11_s = GetThingSector(door11_o);
- SetSectorAdjoins(door11_s, 0);
- door12_s = GetThingSector(door12_o);
- SetSectorAdjoins(door12_s, 0);
- door13_s = GetThingSector(door13_o);
- SetSectorAdjoins(door13_s, 0);
- door14_s = GetThingSector(door14_o);
- SetSectorAdjoins(door14_s, 0);
- global1 = 0;
- return;
-
- entered:
- print("entered");
- // This routine handles setting up variables for when the player (or potentially something else)
- // enters a pickup zone.
- If (getsenderref()== pickup1_s) //if something entered pickup 1
- {
- cargo1_i = getsourceref();
- }
- If (getsenderref()== pickup2_s) //if something entered pickup 2
- {
- cargo2_i = getsourceref();
- }
- If (getsenderref()== pickup3_s) //if something entered pickup 3
- {
- cargo3_i = getsourceref();
- }
-
- If (tram_pickup == 1)
- {
- print("JAMZ");
- settimer(3);
- call tramstop;
- }
-
- return;
-
- exited:
- //This routine handles clearing varibles that keep track of what's potential cargo.
- If (getsenderref()== pickup1_s)//if something exited pickup 1
- {
- if (cargo1_i == getsourceref())
- {
- cargo1_i = 0; //if it was potential cargo, then remove it
- SectorThrust(pickup1_s, up_v, 0);
- }
- }
- If (getsenderref()== pickup2_s)//if something exited pickup 2
- {
- if (cargo2_i == getsourceref())
- {
- cargo2_i = 0; //if it was potential cargo, then remove it
- SectorThrust(pickup2_s, up_v, 0);
- }
- }
- If (getsenderref()== pickup3_s)//if something exited pickup 2
- {
- if (cargo3_i == getsourceref())
- {
- cargo3_i = 0; //if it was potential cargo, then remove it
- SectorThrust(pickup3_s, up_v, 0);
- }
- }
-
- return;
- tramstop:
- //print("tramstop");
- printint(cargot_i);
- //This routine is in charge of checking a tram stop and dropping something off it it needs
- // to, or picking someone up if it needs to.
- if (cargot_i == 0) //if the tram is empty
- {
- tram_pickup = 1; // This variable tell's the touched message that it's okay to pick stuff up.
- if ((getthingsector(tram) == pickup1_s) && (cargo1_i !=0 )) //if the sector the tram is in is pickup 1 and there's cargo to pick up
- {
- achthing = cargo1_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
- cargo1_i = 0; // Empty the cargostop variable
- pickups_i = pickup1_s; // tell the touched message what sectorthrust to stop.
- SectorThrust(pickup1_s, up_v, 5);
- settimer(3);
- }
- if ((getthingsector(tram) == pickup2_s) && (cargo2_i !=0 )) //if the sector the tram is in is pickup 1 and there's cargo to pick up
- {
- achthing = cargo2_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
- cargo2_i = 0; // Empty the cargostop variable
- pickups_i = pickup2_s; // tell the touched message what sectorthrust to stop.
- SectorThrust(pickup2_s, up_v, 5);
- settimer(3);
- }
- if ((getthingsector(tram) == pickup3_s) && (cargo3_i !=0 )) //if the sector the tram is in is pickup 1 and there's cargo to pick up
- {
- achthing = cargo3_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
- cargo3_i = 0; // Empty the cargostop variable
- pickups_i = pickup3_s; // tell the touched message what sectorthrust to stop.
- SectorThrust(pickup3_s, up_v, 5);
- settimer(3);
- }
- }
- else // Else the cargo is holding something and it's way out wackity wacked
- {
- call dropoff1;
- }
- return;
-
- touched:
- if (tram_pickup == 1)
- {
- tram_pickup = 0;
- print("touched");
- SectorThrust(pickups_i, up_v, 0);
- //call pickup1;
- sleep(0.01);
- call pickup1;
- settimer(0.01);
- }
- return;
-
- pickup1:
- // This routine picks up the player (well, in therory anything)
- // It was taken from Matt the Tat's tram cog. I modified it a little. -Doug
- t_speed = t_cargo;
- in_tram = 1;
- hangoffset=('0,0,0');
- cargot_i = achthing;
- // setsectorthrust(thrustsector, thrustvector, 0);
- totalradius = GetThingRadius(achthing) + GetThingRadius(tram);
- VectorSet(hangoffset, 0, 0, -totalradius);
- // hangoffset = VectorAdd(hangoffset, GetThingInsertOffset(magnettram));
- hangoffset = VectorSub(hangoffset, GetThingInsertOffset(achthing));
- SetThingPos(achthing, VectorAdd(GetThingPos(tram), hangoffset));
- AttachThingToThingEx(achthing, tram, 8);
- dwdisablejump();
- return;
-
- dropoff1:
- print("dropoff");
- cargot_i = 0; //empty out the cargo variable
- t_speed = t_max;
- Sleep(2);
- in_tram = 0;
- detachthing(achthing);
- setthingvel(achthing, '0,0,0.5');
- dwenablejump();
- return;
-
- arrived:
- frame = getcurframe(tram);
- global1 = frame;
-
- if (getsenderref() == tram) // If it's the tram that arrived
- {
- if (frame == 0)
- {
- print("Revolution #:");
- printint(rev_i);
- print("time (in seconds) #:");
- printint(t_pulse);
- rev_i = rev_i + 1;
- call tramstop;
- moveframe = 6;
- timermode = 0;
- settimer(3);
- }
- if (frame == 6) // if the tram is getting close to door 1 (east storage Area)
- {
- SetSectorAdjoins(door1_s, 1); //Turn on door adjoins
- movetoframe(door1_o,1,door_speed); //Open the door
- movetoframe(tram,7,t_speed); // Move the tram to the next frame
- }
- else if (frame == 7) // Else if the tram's through door 1
- {
- movetoframe(door1_o,0,door_speed); //close the door
- movetoframe(tram,8,t_speed); // Move the tram to the next frame
- }
- else if (frame == 8) // if the tram is getting close to door 2 (Control)
- {
- SetSectorAdjoins(door2_s, 1); //Turn on door adjoins
- movetoframe(door2_o,1,door_speed); //Open the door
- movetoframe(tram,9,t_speed); // Move the tram to the next frame
- }
- else if (frame == 9)
- {
- movetoframe(door2_o,0,door_speed); //close the door
- movetoframe(tram,11,t_speed); // Move the tram to the next frame
- }
- else if (frame == 11)
- {
- SetSectorAdjoins(door3_s, 1); //Turn on door adjoins
- movetoframe(door3_o,1,door_speed); //Open the door
- movetoframe(tram,12,t_speed); // Move the tram to the next frame
- }
- else if (frame == 12)
- {
- movetoframe(door3_o,0,door_speed); //close the door
- movetoframe(tram,13,t_speed); // Move the tram to the next frame
- }
- else if (frame == 13)
- {
- SetSectorAdjoins(door4_s, 1); //Turn on door adjoins
- movetoframe(door4_o,1,door_speed); //Open the door
- movetoframe(tram,14,t_speed); // Move the tram to the next frame
- }
- else if (frame == 14)
- {
- movetoframe(door4_o,0,door_speed); //close the door
- movetoframe(tram,15,t_speed); // Move the tram to the next frame
- }
- else if (frame == 15) //-=============Drop player onto acid conveyor
- {
- call dropoff1; //This is a forced dropoff. The tram cannot pickanyone up at this spot, just drop stuff off.
- t_speed = 5; //special case for speed
- movetoframe(tram,16,t_speed); // Move the tram to the next frame
- timermode = 1; // Tells the timer message what to do
- settimer(20);
- }
- else if (frame == 16)
- {
- SetSectorAdjoins(door5_s, 1); //Turn on door adjoins
- movetoframe(door5_o,1,door_speed); //Open the door
- movetoframe(tram,17,t_speed); // Move the tram to the next frame
- }
- else if (frame == 17)
- {
- movetoframe(door5_o,0,door_speed); //close the door
- movetoframe(tram,18,t_speed); // Move the tram to the next frame
- // At this point the tram will wait until the timer (set at frame 15) expires and the elevator lift moves
- }
- else if (frame == 19)
- {
- movetoframe(acid_lift_o,0,2); // reset the acid lift to 0 position.
- movetoframe(door6_o,0,door_speed); //close the door
- SetSectorAdjoins(door7_s, 1); //Turn on door adjoins
- movetoframe(door7_o,1,door_speed); //Open the door
- movetoframe(tram,20,t_speed); // Move the tram to the next frame
- }
- else if (frame == 20)
- {
- movetoframe(door7_o,0,door_speed); //close the door
- movetoframe(tram,21,t_speed); // Move the tram to the next frame
- }
- else if (frame == 21) ///===================== Dropping off player in the Referb Area
- {
- //call dropoff1; //Commented out for edbugging
- call tramstop;
- moveframe = 22;
- timermode = 0;
- settimer(3);
- //movetoframe(tram,22,t_speed); // Move the tram to the next frame
- }
- else if (frame == 22)
- {
- SetSectorAdjoins(door8_s, 1); //Turn on door adjoins
- movetoframe(door8_o,1,door_speed); //Open the door
- movetoframe(tram,23,t_speed); // Move the tram to the next frame
- }
- else if (frame == 23)
- {
- movetoframe(door8_o,0,door_speed); //close the door
- movetoframe(tram,24,t_speed); // Move the tram to the next frame
- }
- else if (frame == 24)
- {
- SetSectorAdjoins(door9_s, 1); //Turn on door adjoins
- movetoframe(door9_o,1,door_speed); //Open the door
- movetoframe(tram,25,t_speed); // Move the tram to the next frame
- }
- else if (frame == 25)
- {
- movetoframe(door9_o,0,door_speed); //close the door
- movetoframe(tram,30,t_speed); // Move the tram to the next frame
- }
- else if (frame == 30)
- {
- SetSectorAdjoins(door10_s, 1); //Turn on door adjoins
- movetoframe(door10_o,1,door_speed); //Open the door
- movetoframe(tram,31,t_speed); // Move the tram to the next frame
- }
- else if (frame == 31)
- {
- movetoframe(door10_o,0,door_speed); //close the door
- movetoframe(tram,40,t_speed); // Move the tram to the next frame
- }
- else if (frame == 40)
- {
- SetSectorAdjoins(door11_s, 1); //Turn on door adjoins
- movetoframe(door11_o,1,door_speed); //Open the door
- movetoframe(tram,42,t_speed); // Move the tram to the next frame
- }
- else if (frame == 42)
- {
- movetoframe(door11_o,0,door_speed); //close the door
- movetoframe(tram,43,t_speed); // Move the tram to the next frame
- }
- else if (frame == 43)
- {
- SetSectorAdjoins(door12_s, 1); //Turn on door adjoins
- movetoframe(door12_o,1,door_speed); //Open the door
- movetoframe(tram,44,t_speed); // Move the tram to the next frame
- }
- else if (frame == 44)
- {
- movetoframe(door12_o,0,door_speed); //close the door
- movetoframe(tram,49,t_speed); // Move the tram to the next frame
- }
- else if (frame == 49)
- {
- SetSectorAdjoins(door13_s, 1); //Turn on door adjoins
- movetoframe(door13_o,1,door_speed); //Open the door
- movetoframe(tram,50,t_speed); // Move the tram to the next frame
- }
- else if (frame == 50)
- {
- movetoframe(door13_o,0,door_speed); //close the door
- SetSectorAdjoins(door14_s, 1); //Turn on door adjoins
- movetoframe(door14_o,1,door_speed); //open the door
- movetoframe(tram,51,t_speed); // Move the tram to the next frame
- }
- else if (frame == 51)
- {
- movetoframe(door14_o,0,door_speed); //close the door
- skiptoframe(tram,0,getthingsector(tram)); // Move the tram to the next frame
- }
- }
-
- else if (getsenderref() == door1_o) //if it's door 1
- {
- if (getcurframe(door1_o) == 0) SetSectorAdjoins(door1_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door2_o) //if it's door 2
- {
- if (getcurframe(door2_o) == 0) SetSectorAdjoins(door2_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door3_o)
- {
- if (getcurframe(door3_o) == 0) SetSectorAdjoins(door3_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door4_o)
- {
- if (getcurframe(door4_o) == 0) SetSectorAdjoins(door4_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door5_o)
- {
- if (getcurframe(door5_o) == 0) SetSectorAdjoins(door5_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == acid_lift_o)
- {
- if (getcurframe(acid_lift_o) == 1) // Pick up ther player from the Acid Bath.
- {
- // This gets executed when the platform moves to the top of the acid bath. The
- // tram tries to pick someone up. Let's see what happens.. . . .
- t_speed = t_max; // Sets the speed back to Max in case it doesn't pick anything up.
- call tramstop;
- moveframe = 19;
- timermode = 0;
- //movetoframe(tram,19,t_speed); //
- settimer(3);
-
- SetSectorAdjoins(door6_s, 1); //Turn on door adjoins
- movetoframe(door6_o,1,door_speed); //Open the door
- //sleep(1);
- }
- }
- else if (getsenderref() == door6_o)
- {
- if (getcurframe(door6_o) == 0) SetSectorAdjoins(door6_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door7_o)
- {
- if (getcurframe(door7_o) == 0) SetSectorAdjoins(door7_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door8_o)
- {
- if (getcurframe(door8_o) == 0) SetSectorAdjoins(door8_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door9_o)
- {
- if (getcurframe(door9_o) == 0) SetSectorAdjoins(door9_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door10_o)
- {
- if (getcurframe(door10_o) == 0) SetSectorAdjoins(door10_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door11_o)
- {
- if (getcurframe(door11_o) == 0) SetSectorAdjoins(door11_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door12_o)
- {
- if (getcurframe(door12_o) == 0) SetSectorAdjoins(door12_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door13_o)
- {
- if (getcurframe(door13_o) == 0) SetSectorAdjoins(door13_s, 0); //Turn off door adjoins
- }
- else if (getsenderref() == door14_o)
- {
- if (getcurframe(door14_o) == 0) SetSectorAdjoins(door14_s, 0); //Turn off door adjoins
- }
-
-
-
- return;
-
-
- timer:
- if (timermode == 0)
- {
- // this routine is used to control the movement of the tram after it's waited at
- // the stop for a settimer() amount of ti
- tram_pickup = 0;
- movetoframe(tram,moveframe,t_speed);
- }
- else if (timermode == 1)
- {
- // Used to move the "acid elevator" to the top;
- movetoframe(acid_lift_o,1,2);
- }
- return;
-
- pulse:
- // SImple pulse used to count how long things take.
- t_pulse = t_pulse + 1;
- //print("second#:");
- //printint(t_pulse);
-
- return;
-
-
- end
-