home *** CD-ROM | disk | FTP | other *** search
- # DrowWorks Cog Script
- #
- # SY_MagTram B
- #
- # First attempt at MagTram cog
- #
- # Desc:
- #
- #
- #
- # [01/18/97] DGS Created From Matt's TreadRX script.
- # [03/03/98] DGS Modified to work with sector thrusts. It got totally re-written. (Del-Fi Lost Treasures)
- symbols
- ## ====================== Messages
- message startup
- message activated
- message arrived
- message entered
- message exited
- message touched
- message timer
- message pulse
-
- ## ====================== Things
- thing tram
- thing door1_o
- thing door2_o
- thing door3_o
- thing door4_o
- thing door5_o
- thing door6_o
- thing door7_o
- thing door8_o
- ## ---------------------- Door sectors
- 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
-
- ## ===================== Vectors
- vector up_v
-
- ## ====================== Sectors
- sector pickup1_s linkid=21
- sector pickup2_s linkid=22
- int tram_sect_i local
-
- ## ====================== Assassin Droid Templates/Ghosts
- template killer_t
- thing ghost1_g
- thing ghost2_g
- int killer_i=0 local
- int killer_loc=0 local
- ## ====================== Misc. Stuff
- surface tramswitch
- flex t_speed=25.0 local
- flex t_max=25.0 local
- flex t_cargo=15.0 local
- flex door_speed=12.0 local
- int cargo1_i=0 local
- int cargo2_i=0 local
- int cargot_i=0 local
- int pickups_i=0 local
- int moveframe=0 local
- int in_tram=0 local
- int waitfor=0 local
- int playerdrop=0 local
- int killer_pickup=0 local
- end
-
- # ========================================================================================
-
- code
-
- startup:
- setwallcel(tramswitch, 1);
- killer_loc = pickup1_s;
- player = getlocalplayerthing();
- movetoframe(tram,1,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);
-
- //printint(global1);
- return;
-
- tramstop:
- //print("tramstop");
- //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);
- timermode = 1;
- 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);
- timermode = 1;
- settimer(3);
- }
- }
- else // Else the cargo is holding something and it's way out wackity wacked
- {
- call dropoff1;
- }
- // The lines below control the killer droid
- if ((playerdrop == pickup2_s) && (getthingsector(tram) == pickup1_s)) //if you're inside jawa area and the tram's not
- {
- print("assassin Droid comming your way into the JAWA area");
- call pickup_killer;
- playerdrop = 0;
- }
- if ((playerdrop == pickup1_s) && (getthingsector(tram) == pickup2_s)) //
- {
- print("assassin Droid comming your way back to Refurb area");
- call pickup_killer;
- playerdrop = 0;
- }
-
- return;
- touched:
- if (getsenderref() == tram)
- {
- if (tram_pickup == 1)
- {
- tram_pickup = 0;
- print("touched");
- SectorThrust(pickups_i, up_v, 0);
- //call pickup1;
- sleep(0.01);
- call pickup1;
- timermode = 1;
- settimer(0.01);
- }
- }
- 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
- {
- //print("Sector 1:");
- //printint(getsourceref());
- cargo1_i = getsourceref();
- }
- If (getsenderref()== pickup2_s) //if something entered pickup 2
- {
- //print("Sector 2:");
- //printint(getsourceref());
- cargo2_i = getsourceref();
- }
- if (tram_pickup == 1)
- {
- print("JAMZ");
- timermode = 1;
- 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);
- }
- }
- 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);
- if (achthing == player) dwdisablejump(); // if it's the player we're picking up, freeze his controls.
- return;
-
- dropoff1:
- //print("dropOFF:");
- if (achthing != 0)
- {
- printint(cargot_i);
- 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');
- if (achthing == player) dwenablejump(); // if it's the player we're dropping, let him move.
- if (achthing == player) //This stuff is for making the assassin droid follow you in/out.
- {
- if (getthingsector(tram) == pickup1_s) playerdrop = pickup1_s;
- if (getthingsector(tram) == pickup2_s) playerdrop = pickup2_s;
- print("playerdrop:");
- printint(playerdrop);
- }
- acthing = 0;
- if (achthing == killer_i) //This stuff is for making the assassin droid follow you in/out.
- {
- if (getthingsector(tram) == pickup1_s) killer_loc = pickup1_s;
- if (getthingsector(tram) == pickup2_s) killer_loc = pickup2_s;
- print("killer_loc:");
- printint(killer_loc);
-
- }
- }
- return;
-
- pickup_killer:
- // This routine creates an assassin droid and attaches him into the tram for dropoff later on.
- t_speed = t_cargo;
- in_tram = 1;
- killer_pickup = killer_pickup +1;
- if (killer_pickup == 1) dwPlayCammySpeech(12140, "M1ca042.wav", 10, 0);
- else dwPlayCammySpeech(12141, "M1ca043.wav", 10, 0);
- timermode = 2;
- settimerex(10,2,0,0);
- hangoffset=('0,0,0');
- if (killer_i != 0) destroything(killer_i);
- if (getthingsector(tram) == pickup1_s)
- {
- killer_i = creatething(killer_t,ghost1_g);
- }
- if (getthingsector(tram) == pickup2_s)
- {
- killer_i = creatething(killer_t,ghost2_g);
- }
- achthing = killer_i;
- 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);
- return;
-
-
-
- arrived:
- // This routine differs from the other tram scripts becuase it has controls for stopping and starting the tram at any time.
- // because of this, the variable Moveframe is set to the frame it's headed towards every time, so that if the tram is stopped
- // and restarted we know what frame to send it to. Pretty sneaky, eh?
- if (getsenderref() == tram)
- {
- if ((getcurframe(tram))==0)
- {
- call tramstop;
- moveframe = 1;
- timermode = 1;
- settimer(3);
- }
- else if ((getcurframe(tram))==1)
- {
- SetSectorAdjoins(door1_s, 1); //Turn on door adjoins
- movetoframe(door1_o,1,door_speed);
- movetoframe(tram,2,t_speed);
- moveframe = 2;
-
- }
- else if ((getcurframe(tram))==2)
- {
- movetoframe(door1_o,0,door_speed);
- movetoframe(tram,3,t_speed);
- moveframe = 3;
-
- }
- else if ((getcurframe(tram))==3)
- {
- SetSectorAdjoins(door2_s, 1); //Turn on door adjoins
- movetoframe(door2_o,1,door_speed);
- movetoframe(tram,4,t_speed);
- moveframe = 4;
-
- }
- else if ((getcurframe(tram))==4)
- {
- movetoframe(door2_o,0,door_speed); // Close door
- if ((global1 < 22) || (global1 > 25)) // If another tram's not passing in front of it
- {
- movetoframe(door2_o,0,door_speed); // Close door
- movetoframe(tram,7,t_speed);
- moveframe = 7;
- }
- else //Else a tram is passing!
- {
- moveframe = 7;
- waitfor = 1;
- setpulse(1);
- }
- }
- else if ((getcurframe(tram))==7)
- {
- SetSectorAdjoins(door3_s, 1); //Turn on door adjoins
- movetoframe(door3_o,1,door_speed);
- movetoframe(tram,8,t_speed);
- moveframe = 8;
- }
- else if ((getcurframe(tram))==8)
- {
- movetoframe(door3_o,0,door_speed); // Close door
- movetoframe(tram,9,t_speed);
- moveframe = 9;
- }
- else if ((getcurframe(tram))==9)
- {
- SetSectorAdjoins(door4_s, 1); //Turn on door adjoins
- movetoframe(door4_o,1,door_speed);
- movetoframe(tram,10,t_speed);
- moveframe = 10;
- }
- else if ((getcurframe(tram))==10)
- {
- movetoframe(door4_o,0,door_speed); // Close door
- movetoframe(tram,12,t_speed);
- moveframe = 12;
- }
- else if ((getcurframe(tram))==12)
- {
- SetSectorAdjoins(door5_s, 1); //Turn on door adjoins
- movetoframe(door5_o,1,door_speed);
- movetoframe(tram,13,t_speed);
- moveframe = 13;
- }
- else if ((getcurframe(tram))==13)
- {
- movetoframe(door5_o,0,door_speed); // Close door
- movetoframe(tram,14,t_speed);
- moveframe = 14;
- }
- else if ((getcurframe(tram))==14)
- {
- SetSectorAdjoins(door6_s, 1); //Turn on door adjoins
- movetoframe(door6_o,1,door_speed);
- movetoframe(tram,15,t_speed);
- moveframe = 15;
- }
-
- else if ((getcurframe(tram))==15)
- {
- movetoframe(door6_o,0,door_speed); // Close door
- movetoframe(tram,18,t_speed);
- moveframe = 18;
- }
- else if ((getcurframe(tram))==18)
- {
- call tramstop;
- moveframe = 20;
- timermode = 1;
- settimer(3);
- }
- else if ((getcurframe(tram))==20)
- {
- SetSectorAdjoins(door7_s, 1); //Turn on door adjoins
- movetoframe(door7_o,1,door_speed);
- movetoframe(tram,21,t_speed);
- moveframe = 21;
- }
-
- else if ((getcurframe(tram))==21)
- {
- movetoframe(door7_o,0,door_speed); // Close door
- movetoframe(tram,23,t_speed);
- moveframe = 23;
- }
- else if ((getcurframe(tram))==23)
- {
- SetSectorAdjoins(door8_s, 1); //Turn on door adjoins
- movetoframe(door8_o,1,door_speed);
- movetoframe(tram,24,t_speed);
- moveframe = 24;
- }
-
- else if ((getcurframe(tram))==24)
- {
- movetoframe(door8_o,0,door_speed); // Close door
- movetoframe(tram,26,t_speed);
- moveframe = 26;
- }
-
- else if ((getcurframe(tram))==26)
- {
- skiptoframe(tram,0,t_speed);
- moveframe = 0;
- }
-
-
-
- }
- 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 (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() == 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
- }
- return;
-
- activated:
- // Used to turn the tram on and off. I hope this works.
- print("Activated:");
- if (getsenderref() == tramswitch)
- {
- setwallcel(tramswitch, 1 - getwallcel(tramswitch) );
- if (getwallcel(tramswitch) == 0) // If the player turned the tram off
- {
- dwPlayCammySpeech(12120, "M1ca040.wav", 10, 3);
-
- settimerex(10,2,0,0);
- timermode = 2;
- print("stopping!");
- //stopthing(tram);
- movetoframe(tram,moveframe,0.0000001);
- if (killer_loc == pickup1_s)
- {
- global8 = 1;
- }
- }
- else //else the player turned it back on
- {
- dwPlayCammySpeech(12130, "M1ca041.wav", 10, 0);
-
- settimerex(10,2,0,0);
- timermode = 2;
- print("starting!");
- if (moveframe != 0) movetoframe(tram,moveframe,t_speed);
- else skiptoframe(tram,0,t_speed);
- global8 = 0;
- }
- }
- //print("global8:");
- //printint(global8);
- return;
-
-
- timer:
- // this routine is used to control the movement of the tram after it's waited at
- // the stop for a settimer() amount of ti
-
- if ( getsenderid() == 2)
- {
- // nothing anymore
- }
- else
- {
- tram_pickup = 0;
- SectorThrust(pickups_i, up_v, 0);
- movetoframe(tram,moveframe,t_speed);
- }
- return;
-
- pulse:
- // This is used to check to see when a tram has passed in front of another
- if (waitfor == 1)
- {
- if ((global1 < 22) || (global1 > 25)) // If another tram's not passing in front of it
- {
- setpulse(0);
- movetoframe(tram,moveframe,t_speed);
- }
- }
-
- end
-