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

  1. # DrowWorks Cog Script
  2. #    
  3. # SY_MagTram G
  4. #
  5. # Magnetic Tram that goes around the entire world
  6. #
  7. # Desc:
  8. #    
  9. #
  10. #
  11. # [01/18/97] DGS Created From Matt's TreadRX script.
  12. # [03/05/98] DGS Modified to work with sector thrusts. It got totally re-written. (Del-Fi Lost Treasures)
  13. #
  14. symbols
  15. ## ====================== Messages
  16. message        startup
  17. message     arrived
  18. message     entered
  19. message     exited 
  20. message        pulse
  21. message        timer
  22. message        touched
  23. message        pulse
  24.  
  25.  
  26. ## =  =============  Things
  27. thing    tram   
  28. thing    door1_o
  29. thing   door2_o
  30. thing   door3_o
  31. thing     door4_o
  32. thing     door5_o
  33. thing    acid_lift_o
  34. thing     door6_o
  35. thing     door7_o
  36. thing     door8_o
  37. thing     door9_o
  38. thing     door10_o
  39. thing     door11_o
  40. thing     door12_o
  41. thing     door13_o
  42. thing     door14_o
  43.  
  44.  
  45. ## ================ Door Sector Ints
  46. int            door1_s            local
  47. int            door2_s            local
  48. int            door3_s            local
  49. int            door4_s            local
  50. int            door5_s            local
  51. int            door6_s            local
  52. int            door7_s            local
  53. int            door8_s            local
  54. int            door9_s            local
  55. int            door10_s           local
  56. int            door11_s           local
  57. int            door12_s           local
  58. int            door13_s           local
  59. int            door14_s           local
  60.  
  61. ## ================= Sectors
  62. sector      pickup1_s         linkid=21
  63. sector      pickup2_s        linkid=22
  64. sector      pickup3_s        linkid=22
  65.  
  66. ## ================= Vector
  67. vector        up_v
  68.  
  69. ## ================= Misc. Variables
  70. flex        t_speed=20.0    local
  71. flex        t_max=25.0        local
  72. flex        t_cargo=10.0    local
  73. flex        door_speed=4.0    local
  74. int            cargo1_i=0        local
  75. int            cargo2_i=0        local 
  76. int            cargo3_i=0        local 
  77. int            cargot_i=0        local
  78. int            pickups_i=0        local
  79. int            in_tram=0        local
  80. int            rev_i=1            local
  81. int            timermode=0        local
  82. end
  83.  
  84. # ========================================================================================
  85.  
  86. code
  87.  
  88. startup:
  89.     setpulse(1);
  90.     //call pickup1;
  91.     t_speed = t_max;
  92.     movetoframe(tram,6,t_speed);
  93.     door1_s = GetThingSector(door1_o);
  94.     SetSectorAdjoins(door1_s, 0);
  95.     door2_s = GetThingSector(door2_o);
  96.     SetSectorAdjoins(door2_s, 0);
  97.     door3_s = GetThingSector(door3_o);
  98.     SetSectorAdjoins(door3_s, 0);
  99.     door4_s = GetThingSector(door4_o);
  100.     SetSectorAdjoins(door4_s, 0);
  101.     door5_s = GetThingSector(door5_o);
  102.     SetSectorAdjoins(door5_s, 0);
  103.     door6_s = GetThingSector(door6_o);
  104.     SetSectorAdjoins(door6_s, 0);
  105.     door7_s = GetThingSector(door7_o);
  106.     SetSectorAdjoins(door7_s, 0);
  107.     door8_s = GetThingSector(door8_o);
  108.     SetSectorAdjoins(door8_s, 0);
  109.     door9_s = GetThingSector(door9_o);
  110.     SetSectorAdjoins(door9_s, 0);
  111.     door10_s = GetThingSector(door10_o);
  112.     SetSectorAdjoins(door10_s, 0);
  113.     door11_s = GetThingSector(door11_o);
  114.     SetSectorAdjoins(door11_s, 0);
  115.     door12_s = GetThingSector(door12_o);
  116.     SetSectorAdjoins(door12_s, 0);
  117.     door13_s = GetThingSector(door13_o);
  118.     SetSectorAdjoins(door13_s, 0);
  119.     door14_s = GetThingSector(door14_o);
  120.     SetSectorAdjoins(door14_s, 0);
  121.     global1 = 0;
  122.     return;
  123.  
  124. entered:
  125.     print("entered");
  126.     // This routine handles setting up variables for when  the player (or potentially something else)
  127.     // enters a pickup zone. 
  128.     If (getsenderref()== pickup1_s) //if something entered pickup 1
  129.         {
  130.         cargo1_i = getsourceref();
  131.         }
  132.     If (getsenderref()== pickup2_s) //if something entered pickup 2
  133.         {
  134.         cargo2_i = getsourceref();
  135.         }
  136.     If (getsenderref()== pickup3_s) //if something entered pickup 3
  137.         {
  138.         cargo3_i = getsourceref();
  139.         }
  140.     
  141.     If (tram_pickup == 1)
  142.         {
  143.         print("JAMZ");
  144.         settimer(3);
  145.         call tramstop;
  146.         }
  147.     
  148.     return;
  149.  
  150. exited:
  151.        //This routine handles clearing varibles that keep track of what's potential cargo. 
  152.     If (getsenderref()== pickup1_s)//if something exited pickup 1
  153.         {
  154.         if (cargo1_i == getsourceref()) 
  155.             {
  156.             cargo1_i = 0; //if it was potential cargo, then remove it
  157.             SectorThrust(pickup1_s, up_v, 0);
  158.             }
  159.         }
  160.        If (getsenderref()== pickup2_s)//if something exited pickup 2
  161.         {
  162.         if (cargo2_i == getsourceref()) 
  163.             {
  164.             cargo2_i = 0; //if it was potential cargo, then remove it
  165.             SectorThrust(pickup2_s, up_v, 0);
  166.             }
  167.         }
  168.        If (getsenderref()== pickup3_s)//if something exited pickup 2
  169.         {
  170.         if (cargo3_i == getsourceref()) 
  171.             {
  172.             cargo3_i = 0; //if it was potential cargo, then remove it
  173.             SectorThrust(pickup3_s, up_v, 0);
  174.             }
  175.         }
  176.         
  177.         return;               
  178. tramstop:
  179.     //print("tramstop");
  180.     printint(cargot_i);
  181.     //This routine is in charge of checking a tram stop and dropping something off it it needs
  182.     // to, or picking someone up if it needs to.
  183.     if (cargot_i == 0)        //if the tram is empty
  184.         {
  185.         tram_pickup = 1;    // This variable tell's the touched message that it's okay to pick stuff up.
  186.         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
  187.             {
  188.             achthing = cargo1_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
  189.             cargo1_i = 0;         // Empty the cargostop  variable 
  190.             pickups_i = pickup1_s;    // tell the touched message what sectorthrust to stop.
  191.             SectorThrust(pickup1_s, up_v, 5);
  192.                settimer(3);
  193.             }
  194.         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
  195.             {
  196.             achthing = cargo2_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
  197.             cargo2_i = 0;         // Empty the cargostop  variable 
  198.             pickups_i = pickup2_s;    // tell the touched message what sectorthrust to stop.
  199.             SectorThrust(pickup2_s, up_v, 5);
  200.                settimer(3);
  201.             }
  202.         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
  203.             {
  204.             achthing = cargo3_i; // Let the achthing (the thing it picks up) = whatever the cargo is.
  205.             cargo3_i = 0;         // Empty the cargostop  variable 
  206.             pickups_i = pickup3_s;    // tell the touched message what sectorthrust to stop.
  207.             SectorThrust(pickup3_s, up_v, 5);
  208.                settimer(3);
  209.             }
  210.         }
  211.     else // Else the cargo is holding something and it's way out wackity wacked
  212.         {
  213.         call dropoff1;
  214.         }
  215.     return;
  216.     
  217. touched:
  218.     if (tram_pickup == 1)
  219.         {
  220.         tram_pickup = 0;
  221.         print("touched");
  222.         SectorThrust(pickups_i, up_v, 0);
  223.         //call pickup1;
  224.         sleep(0.01);
  225.         call pickup1;
  226.         settimer(0.01);
  227.         }
  228.     return;
  229.  
  230. pickup1:
  231.     // This routine picks up the player (well, in therory anything)
  232.     // It was taken from Matt the Tat's tram cog. I modified it a little. -Doug
  233.     t_speed = t_cargo;
  234.     in_tram = 1;
  235.     hangoffset=('0,0,0');
  236.     cargot_i = achthing;
  237.     //    setsectorthrust(thrustsector, thrustvector, 0);
  238.     totalradius = GetThingRadius(achthing) + GetThingRadius(tram);
  239.     VectorSet(hangoffset, 0, 0, -totalradius);
  240.     //    hangoffset = VectorAdd(hangoffset, GetThingInsertOffset(magnettram));
  241.     hangoffset = VectorSub(hangoffset, GetThingInsertOffset(achthing));
  242.     SetThingPos(achthing, VectorAdd(GetThingPos(tram), hangoffset));
  243.     AttachThingToThingEx(achthing, tram, 8);
  244.     dwdisablejump();
  245.     return;
  246.  
  247. dropoff1:
  248.     print("dropoff");
  249.     cargot_i = 0;        //empty out the cargo variable 
  250.     t_speed = t_max;
  251.     Sleep(2);   
  252.     in_tram = 0;
  253.     detachthing(achthing);
  254.     setthingvel(achthing, '0,0,0.5');
  255.     dwenablejump();
  256.     return;
  257.  
  258. arrived:
  259.     frame = getcurframe(tram);
  260.     global1 = frame;
  261.     
  262.     if (getsenderref() == tram)    // If it's the tram that arrived
  263.         {
  264.         if (frame == 0) 
  265.             {
  266.             print("Revolution #:");
  267.             printint(rev_i);
  268.             print("time (in seconds) #:");
  269.             printint(t_pulse);
  270.             rev_i = rev_i + 1;
  271.             call tramstop;
  272.             moveframe = 6;
  273.             timermode = 0;
  274.             settimer(3);
  275.             }
  276.         if (frame == 6)        // if the tram is getting close to door 1  (east storage Area)
  277.             {
  278.             SetSectorAdjoins(door1_s, 1);  //Turn on door adjoins
  279.             movetoframe(door1_o,1,door_speed);  //Open the door
  280.             movetoframe(tram,7,t_speed); // Move the tram to the next frame
  281.             }
  282.         else if (frame == 7) // Else if the tram's through door 1
  283.             {
  284.             movetoframe(door1_o,0,door_speed);  //close the door
  285.             movetoframe(tram,8,t_speed); // Move the tram to the next frame
  286.             }
  287.         else if (frame == 8)        // if the tram is getting close to door 2  (Control)
  288.             {
  289.             SetSectorAdjoins(door2_s, 1);  //Turn on door adjoins
  290.             movetoframe(door2_o,1,door_speed);  //Open the door
  291.             movetoframe(tram,9,t_speed); // Move the tram to the next frame
  292.             }
  293.         else if (frame == 9) 
  294.             {
  295.             movetoframe(door2_o,0,door_speed);  //close the door
  296.             movetoframe(tram,11,t_speed); // Move the tram to the next frame
  297.             }
  298.         else if (frame == 11)        
  299.             {
  300.             SetSectorAdjoins(door3_s, 1);  //Turn on door adjoins
  301.             movetoframe(door3_o,1,door_speed);  //Open the door
  302.             movetoframe(tram,12,t_speed); // Move the tram to the next frame
  303.             }
  304.         else if (frame == 12) 
  305.             {
  306.             movetoframe(door3_o,0,door_speed);  //close the door
  307.             movetoframe(tram,13,t_speed); // Move the tram to the next frame
  308.             }
  309.         else if (frame == 13)        
  310.             {
  311.             SetSectorAdjoins(door4_s, 1);  //Turn on door adjoins
  312.             movetoframe(door4_o,1,door_speed);  //Open the door
  313.             movetoframe(tram,14,t_speed); // Move the tram to the next frame
  314.             }
  315.         else if (frame == 14) 
  316.             {
  317.             movetoframe(door4_o,0,door_speed);  //close the door
  318.             movetoframe(tram,15,t_speed); // Move the tram to the next frame
  319.             }
  320.         else if (frame == 15) //-=============Drop player onto acid conveyor
  321.             {
  322.             call dropoff1;        //This is a forced dropoff. The tram cannot pickanyone up at this spot, just drop stuff off. 
  323.             t_speed = 5;    //special case for speed
  324.             movetoframe(tram,16,t_speed); // Move the tram to the next frame
  325.             timermode = 1;    // Tells the timer message what to do 
  326.             settimer(20);
  327.             } 
  328.         else if (frame == 16)        
  329.             {
  330.             SetSectorAdjoins(door5_s, 1);  //Turn on door adjoins
  331.             movetoframe(door5_o,1,door_speed);  //Open the door
  332.             movetoframe(tram,17,t_speed); // Move the tram to the next frame
  333.             }
  334.         else if (frame == 17) 
  335.             {
  336.             movetoframe(door5_o,0,door_speed);  //close the door
  337.             movetoframe(tram,18,t_speed); // Move the tram to the next frame 
  338.             // At this point the tram will wait until the timer (set at frame 15) expires and the elevator lift moves  
  339.             }
  340.         else if (frame == 19)        
  341.             {
  342.             movetoframe(acid_lift_o,0,2);    // reset the acid lift to 0 position. 
  343.             movetoframe(door6_o,0,door_speed);  //close the door
  344.             SetSectorAdjoins(door7_s, 1);  //Turn on door adjoins
  345.             movetoframe(door7_o,1,door_speed);  //Open the door
  346.             movetoframe(tram,20,t_speed); // Move the tram to the next frame
  347.             }
  348.         else if (frame == 20) 
  349.             {
  350.             movetoframe(door7_o,0,door_speed);  //close the door
  351.             movetoframe(tram,21,t_speed); // Move the tram to the next frame
  352.             }
  353.         else if (frame == 21)    ///===================== Dropping off player in the Referb Area 
  354.             {
  355.             //call dropoff1;  //Commented out for edbugging 
  356.             call tramstop;
  357.             moveframe = 22;
  358.             timermode = 0;
  359.             settimer(3);
  360.             //movetoframe(tram,22,t_speed); // Move the tram to the next frame
  361.             }
  362.         else if (frame == 22)        
  363.             {
  364.             SetSectorAdjoins(door8_s, 1);  //Turn on door adjoins
  365.             movetoframe(door8_o,1,door_speed);  //Open the door
  366.             movetoframe(tram,23,t_speed); // Move the tram to the next frame
  367.             }
  368.         else if (frame == 23) 
  369.             {
  370.             movetoframe(door8_o,0,door_speed);  //close the door
  371.             movetoframe(tram,24,t_speed); // Move the tram to the next frame
  372.             }
  373.         else if (frame == 24)        
  374.             {
  375.             SetSectorAdjoins(door9_s, 1);  //Turn on door adjoins
  376.             movetoframe(door9_o,1,door_speed);  //Open the door
  377.             movetoframe(tram,25,t_speed); // Move the tram to the next frame
  378.             }
  379.         else if (frame == 25) 
  380.             {
  381.             movetoframe(door9_o,0,door_speed);  //close the door
  382.             movetoframe(tram,30,t_speed); // Move the tram to the next frame
  383.             }
  384.         else if (frame == 30)        
  385.             {
  386.             SetSectorAdjoins(door10_s, 1);  //Turn on door adjoins
  387.             movetoframe(door10_o,1,door_speed);  //Open the door
  388.             movetoframe(tram,31,t_speed); // Move the tram to the next frame
  389.             }
  390.         else if (frame == 31) 
  391.             {
  392.             movetoframe(door10_o,0,door_speed);  //close the door
  393.             movetoframe(tram,40,t_speed); // Move the tram to the next frame
  394.             }
  395.         else if (frame == 40)        
  396.             {
  397.             SetSectorAdjoins(door11_s, 1);  //Turn on door adjoins
  398.             movetoframe(door11_o,1,door_speed);  //Open the door
  399.             movetoframe(tram,42,t_speed); // Move the tram to the next frame
  400.             }
  401.         else if (frame == 42) 
  402.             {
  403.             movetoframe(door11_o,0,door_speed);  //close the door
  404.             movetoframe(tram,43,t_speed); // Move the tram to the next frame
  405.             }
  406.         else if (frame == 43)        
  407.             {
  408.             SetSectorAdjoins(door12_s, 1);  //Turn on door adjoins
  409.             movetoframe(door12_o,1,door_speed);  //Open the door
  410.             movetoframe(tram,44,t_speed); // Move the tram to the next frame
  411.             }
  412.         else if (frame == 44) 
  413.             {
  414.             movetoframe(door12_o,0,door_speed);  //close the door
  415.             movetoframe(tram,49,t_speed); // Move the tram to the next frame
  416.             }
  417.                else if (frame == 49)        
  418.             {
  419.             SetSectorAdjoins(door13_s, 1);  //Turn on door adjoins
  420.             movetoframe(door13_o,1,door_speed);  //Open the door
  421.             movetoframe(tram,50,t_speed); // Move the tram to the next frame
  422.             }
  423.         else if (frame == 50) 
  424.             {
  425.             movetoframe(door13_o,0,door_speed);  //close the door
  426.             SetSectorAdjoins(door14_s, 1);  //Turn on door adjoins
  427.             movetoframe(door14_o,1,door_speed);  //open the door
  428.             movetoframe(tram,51,t_speed); // Move the tram to the next frame
  429.             }
  430.         else if (frame == 51)
  431.             {                 
  432.             movetoframe(door14_o,0,door_speed);  //close the door
  433.             skiptoframe(tram,0,getthingsector(tram)); // Move the tram to the next frame
  434.             } 
  435.         }
  436.     
  437.     else if (getsenderref() == door1_o) //if it's door 1 
  438.         {
  439.         if (getcurframe(door1_o) == 0) SetSectorAdjoins(door1_s, 0);  //Turn off door adjoins
  440.         }
  441.     else if (getsenderref() == door2_o) //if it's door 2 
  442.         {
  443.         if (getcurframe(door2_o) == 0) SetSectorAdjoins(door2_s, 0);  //Turn off door adjoins
  444.         }
  445.     else if (getsenderref() == door3_o) 
  446.         {
  447.         if (getcurframe(door3_o) == 0) SetSectorAdjoins(door3_s, 0);  //Turn off door adjoins
  448.         }
  449.     else if (getsenderref() == door4_o) 
  450.         {
  451.         if (getcurframe(door4_o) == 0) SetSectorAdjoins(door4_s, 0);  //Turn off door adjoins
  452.         }
  453.     else if (getsenderref() == door5_o) 
  454.         {
  455.         if (getcurframe(door5_o) == 0) SetSectorAdjoins(door5_s, 0);  //Turn off door adjoins
  456.         }
  457.     else if (getsenderref() == acid_lift_o) 
  458.         {
  459.         if (getcurframe(acid_lift_o) == 1)        // Pick up ther player from the Acid Bath.  
  460.             {
  461.             // This gets executed when the platform moves to the top of the acid bath.  The 
  462.             // tram tries to pick someone up. Let's see what happens.. . .   .  
  463.             t_speed = t_max;    // Sets the speed back to Max in case it doesn't pick anything up. 
  464.             call tramstop;
  465.             moveframe = 19;
  466.             timermode = 0;
  467.             //movetoframe(tram,19,t_speed); //     
  468.             settimer(3);
  469.             
  470.             SetSectorAdjoins(door6_s, 1);  //Turn on door adjoins
  471.             movetoframe(door6_o,1,door_speed);  //Open the door
  472.             //sleep(1);
  473.             }
  474.         }
  475.     else if (getsenderref() == door6_o) 
  476.         {
  477.         if (getcurframe(door6_o) == 0) SetSectorAdjoins(door6_s, 0);  //Turn off door adjoins
  478.         }
  479.     else if (getsenderref() == door7_o) 
  480.         {
  481.         if (getcurframe(door7_o) == 0) SetSectorAdjoins(door7_s, 0);  //Turn off door adjoins
  482.         }
  483.     else if (getsenderref() == door8_o) 
  484.         {
  485.         if (getcurframe(door8_o) == 0) SetSectorAdjoins(door8_s, 0);  //Turn off door adjoins
  486.         }
  487.     else if (getsenderref() == door9_o) 
  488.         {
  489.         if (getcurframe(door9_o) == 0) SetSectorAdjoins(door9_s, 0);  //Turn off door adjoins
  490.         }
  491.     else if (getsenderref() == door10_o) 
  492.         {
  493.         if (getcurframe(door10_o) == 0) SetSectorAdjoins(door10_s, 0);  //Turn off door adjoins
  494.         }
  495.     else if (getsenderref() == door11_o) 
  496.         {
  497.         if (getcurframe(door11_o) == 0) SetSectorAdjoins(door11_s, 0);  //Turn off door adjoins
  498.         }
  499.     else if (getsenderref() == door12_o) 
  500.         {
  501.         if (getcurframe(door12_o) == 0) SetSectorAdjoins(door12_s, 0);  //Turn off door adjoins
  502.         }
  503.     else if (getsenderref() == door13_o) 
  504.         {
  505.         if (getcurframe(door13_o) == 0) SetSectorAdjoins(door13_s, 0);  //Turn off door adjoins
  506.         }
  507.     else if (getsenderref() == door14_o) 
  508.         {
  509.         if (getcurframe(door14_o) == 0) SetSectorAdjoins(door14_s, 0);  //Turn off door adjoins
  510.         }
  511.     
  512.     
  513.     
  514.     return;
  515.  
  516.  
  517. timer:
  518.     if (timermode == 0)
  519.         {
  520.         // this routine is used to control the movement of the tram after it's waited at 
  521.         // the stop for a settimer() amount of ti
  522.         tram_pickup = 0;
  523.         movetoframe(tram,moveframe,t_speed);
  524.         }
  525.     else if (timermode == 1)
  526.         {
  527.         // Used to move the "acid elevator" to the top;
  528.         movetoframe(acid_lift_o,1,2);
  529.         }
  530.     return;
  531.  
  532. pulse:
  533.     // SImple pulse used to count how long things take. 
  534.     t_pulse = t_pulse + 1;
  535.     //print("second#:");
  536.     //printint(t_pulse);
  537.  
  538.     return;
  539.     
  540.  
  541. end
  542.