home *** CD-ROM | disk | FTP | other *** search
/ Classic Fond 52 / ClassicFond52.iso / GAMES / DROIDW.RAR / DWCD.GOB / mission_cog_sy_magtramb.cog < prev    next >
Text File  |  1998-11-04  |  16KB  |  541 lines

  1. # DrowWorks Cog Script
  2. #    
  3. # SY_MagTram B
  4. #
  5. # First attempt at MagTram cog
  6. #
  7. # Desc:
  8. #    
  9. #
  10. #
  11. # [01/18/97] DGS Created From Matt's TreadRX script.
  12. # [03/03/98] DGS Modified to work with sector thrusts. It got totally re-written. (Del-Fi Lost Treasures)
  13. symbols
  14. ## ====================== Messages
  15. message        startup
  16. message        activated
  17. message     arrived
  18. message     entered
  19. message     exited 
  20. message        touched
  21. message        timer
  22. message        pulse
  23.  
  24. ## ====================== Things
  25. thing        tram   
  26. thing        door1_o        
  27. thing        door2_o        
  28. thing        door3_o    
  29. thing        door4_o
  30. thing        door5_o    
  31. thing        door6_o    
  32. thing        door7_o    
  33. thing        door8_o    
  34. ## ---------------------- Door sectors
  35. int            door1_s            local
  36. int            door2_s            local
  37. int            door3_s            local
  38. int            door4_s            local
  39. int            door5_s            local
  40. int            door6_s            local                    
  41. int            door7_s            local
  42. int            door8_s            local
  43.  
  44. ##    ===================== Vectors
  45. vector        up_v
  46.  
  47. ## ====================== Sectors
  48. sector      pickup1_s         linkid=21
  49. sector      pickup2_s        linkid=22
  50. int            tram_sect_i        local    
  51.  
  52. ## ====================== Assassin Droid Templates/Ghosts
  53. template    killer_t        
  54. thing        ghost1_g
  55. thing        ghost2_g
  56. int            killer_i=0        local
  57. int            killer_loc=0    local
  58. ## ====================== Misc. Stuff
  59. surface        tramswitch        
  60. flex        t_speed=25.0    local
  61. flex        t_max=25.0        local
  62. flex        t_cargo=15.0    local
  63. flex        door_speed=12.0    local
  64. int            cargo1_i=0        local
  65. int            cargo2_i=0        local 
  66. int            cargot_i=0        local
  67. int            pickups_i=0        local
  68. int            moveframe=0        local
  69. int            in_tram=0        local
  70. int            waitfor=0        local
  71. int            playerdrop=0    local
  72. int            killer_pickup=0    local
  73. end
  74.  
  75. # ========================================================================================
  76.  
  77. code
  78.  
  79. startup:
  80.     setwallcel(tramswitch, 1);
  81.     killer_loc = pickup1_s;
  82.     player = getlocalplayerthing();
  83.     movetoframe(tram,1,t_speed);
  84.     
  85.     door1_s = GetThingSector(door1_o);
  86.     SetSectorAdjoins(door1_s, 0);
  87.     door2_s = GetThingSector(door2_o);
  88.     SetSectorAdjoins(door2_s, 0);
  89.     door3_s = GetThingSector(door3_o);
  90.     SetSectorAdjoins(door3_s, 0);
  91.     door4_s = GetThingSector(door4_o);
  92.     SetSectorAdjoins(door4_s, 0);
  93.     door5_s = GetThingSector(door5_o);
  94.     SetSectorAdjoins(door5_s, 0);
  95.     door6_s = GetThingSector(door6_o);
  96.     SetSectorAdjoins(door6_s, 0);
  97.     door7_s = GetThingSector(door7_o);
  98.     SetSectorAdjoins(door7_s, 0);
  99.     door8_s = GetThingSector(door8_o);
  100.     SetSectorAdjoins(door8_s, 0);
  101.  
  102.     //printint(global1);
  103.     return;
  104.  
  105. tramstop:
  106.     //print("tramstop");
  107.     //This routine is in charge of checking a tram stop and dropping something off it it needs
  108.     // to, or picking someone up if it needs to.
  109.     if (cargot_i == 0)        //if the tram is empty
  110.         {
  111.         tram_pickup = 1;    // This variable tell's the touched message that it's okay to pick stuff up.
  112.         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
  113.             {
  114.             achthing = cargo1_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
  115.             cargo1_i = 0;         // Empty the cargostop  variable 
  116.             pickups_i = pickup1_s;    // tell the touched message what sectorthrust to stop.
  117.             SectorThrust(pickup1_s, up_v, 5);
  118.                timermode = 1;
  119.             settimer(3);
  120.             }
  121.         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
  122.             {
  123.             achthing = cargo2_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
  124.             cargo2_i = 0;         // Empty the cargostop  variable 
  125.             pickups_i = pickup2_s;    // tell the touched message what sectorthrust to stop.
  126.             SectorThrust(pickup2_s, up_v, 5);
  127.                timermode = 1;
  128.             settimer(3);
  129.             }
  130.         }
  131.     else // Else the cargo is holding something and it's way out wackity wacked
  132.         {
  133.         call dropoff1;
  134.         }
  135.     // The lines below control the killer droid 
  136.     if    ((playerdrop == pickup2_s) && (getthingsector(tram) == pickup1_s)) //if you're inside jawa area and the tram's not
  137.         {
  138.         print("assassin Droid comming your way into the JAWA area");        
  139.         call pickup_killer;
  140.         playerdrop = 0;
  141.         }
  142.     if    ((playerdrop == pickup1_s) && (getthingsector(tram) == pickup2_s)) //
  143.         {
  144.         print("assassin Droid comming your way back to Refurb area");        
  145.         call pickup_killer;
  146.         playerdrop = 0;
  147.         }
  148.     
  149.     return;
  150. touched:
  151.     if (getsenderref() == tram)
  152.         {
  153.         if (tram_pickup == 1)
  154.             {
  155.             tram_pickup = 0;
  156.             print("touched");
  157.             SectorThrust(pickups_i, up_v, 0);
  158.             //call pickup1;
  159.             sleep(0.01);
  160.             call pickup1;
  161.                timermode = 1;
  162.             settimer(0.01);
  163.             }
  164.         }
  165.     return;
  166.  
  167. entered:
  168.     print("entered");
  169.     // This routine handles setting up variables for when  the player (or potentially something else)
  170.     // enters a pickup zone. 
  171.     If (getsenderref()== pickup1_s) //if something entered pickup 1
  172.         {
  173.         //print("Sector 1:");
  174.         //printint(getsourceref());
  175.         cargo1_i = getsourceref();
  176.         }
  177.     If (getsenderref()== pickup2_s) //if something entered pickup 2
  178.         {
  179.         //print("Sector 2:");
  180.         //printint(getsourceref());
  181.         cargo2_i = getsourceref();
  182.         }
  183.     if (tram_pickup == 1)
  184.         {
  185.         print("JAMZ");
  186.         timermode = 1;
  187.         settimer(3);
  188.         call tramstop;
  189.         }
  190.     return;
  191.  
  192. exited:
  193.        //This routine handles clearing varibles that keep track of what's potential cargo. 
  194.     If (getsenderref()== pickup1_s)//if something exited pickup 1
  195.         {
  196.         if (cargo1_i == getsourceref()) 
  197.             {
  198.             cargo1_i = 0; //if it was potential cargo, then remove it
  199.             SectorThrust(pickup1_s, up_v, 0);
  200.             }
  201.         }
  202.        If (getsenderref()== pickup2_s)//if something exited pickup 2
  203.         {
  204.         if (cargo2_i == getsourceref()) 
  205.             {
  206.             cargo2_i = 0; //if it was potential cargo, then remove it
  207.             SectorThrust(pickup2_s, up_v, 0);
  208.             }
  209.         }
  210.         return;               
  211.  
  212. pickup1:
  213.     // This routine picks up the player (well, in therory anything)
  214.     // It was taken from Matt the Tat's tram cog. I modified it a little. -Doug
  215.     t_speed = t_cargo;
  216.     in_tram = 1;
  217.     hangoffset=('0,0,0');
  218.     cargot_i = achthing;
  219.     //    setsectorthrust(thrustsector, thrustvector, 0);
  220.     totalradius = GetThingRadius(achthing) + GetThingRadius(tram);
  221.     VectorSet(hangoffset, 0, 0, -totalradius);
  222.     //    hangoffset = VectorAdd(hangoffset, GetThingInsertOffset(magnettram));
  223.     hangoffset = VectorSub(hangoffset, GetThingInsertOffset(achthing));
  224.     SetThingPos(achthing, VectorAdd(GetThingPos(tram), hangoffset));
  225.     AttachThingToThingEx(achthing, tram, 8);
  226.     if (achthing == player) dwdisablejump(); // if it's the player we're picking up, freeze his controls.
  227.     return;
  228.  
  229. dropoff1:
  230.     //print("dropOFF:");
  231.     if (achthing != 0)
  232.         {
  233.         printint(cargot_i);
  234.         cargot_i = 0;        //empty out the cargo variable 
  235.         t_speed = t_max;
  236.         Sleep(2);   
  237.         in_tram = 0;
  238.         detachthing(achthing);
  239.         setthingvel(achthing, '0,0,0.5');
  240.         if (achthing == player) dwenablejump(); // if it's the player we're dropping, let him move.
  241.         if (achthing == player) //This stuff is for making the assassin droid follow you in/out. 
  242.             {
  243.             if (getthingsector(tram) == pickup1_s) playerdrop = pickup1_s; 
  244.             if (getthingsector(tram) == pickup2_s) playerdrop = pickup2_s;
  245.             print("playerdrop:");
  246.             printint(playerdrop);
  247.             }
  248.         acthing = 0;
  249.         if (achthing == killer_i) //This stuff is for making the assassin droid follow you in/out. 
  250.             {
  251.             if (getthingsector(tram) == pickup1_s) killer_loc = pickup1_s; 
  252.             if (getthingsector(tram) == pickup2_s) killer_loc = pickup2_s;
  253.             print("killer_loc:");
  254.             printint(killer_loc);
  255.             
  256.             }
  257.         }
  258.     return;
  259.  
  260. pickup_killer:
  261.     // This routine    creates an assassin droid and attaches him into the tram for dropoff later on.
  262.     t_speed = t_cargo;
  263.     in_tram = 1;
  264.     killer_pickup = killer_pickup +1;
  265.     if (killer_pickup == 1)    dwPlayCammySpeech(12140, "M1ca042.wav", 10, 0);        
  266.     else dwPlayCammySpeech(12141, "M1ca043.wav", 10, 0);
  267.     timermode = 2;
  268.     settimerex(10,2,0,0);
  269.     hangoffset=('0,0,0');
  270.     if (killer_i != 0) destroything(killer_i); 
  271.     if (getthingsector(tram) == pickup1_s) 
  272.         {
  273.         killer_i = creatething(killer_t,ghost1_g);
  274.         }
  275.     if (g