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

  1.  
  2.  
  3. # DrowWorks Cog Script
  4. #    
  5. # SY_MagTram C
  6. #
  7. # Replacement for Magtram B
  8. #
  9. #
  10. # Desc:
  11. #    
  12. #    When I reworked the Salvage yard I had rewrite all these tram cogs. Bummer.
  13. #
  14. # [01/18/97] DGS Created From Matt's TreadRX script.
  15. # [03/03/98] DGS Modified to work with sector thrusts. It got totally re-written. (Del-Fi Lost Treasures)
  16. # [04/02/98] DGS  Getting totally re-written again as so it's waiting for you at said "wait point".  (Captiol Ultra-Lounge: Bachelor Pad Royale)
  17. #                   and it's a piece of junk that I just hate. 
  18.  
  19.  
  20. symbols
  21.  
  22. ## ====================== Messages
  23. message        startup
  24. message     arrived
  25. message     entered
  26. message     exited 
  27. message        pulse
  28. message        touched
  29. message        activated
  30. message        timer
  31.  
  32. ## ====================== Things
  33. thing        tram                mask=0xffff
  34. thing        door1_o                
  35. thing        door2_o        
  36. thing        door3_o    
  37. thing        door4_o
  38. thing        door5_o    
  39. thing        door6_o    
  40. thing        ghost1_o
  41. thing        ghost2_o
  42. template    killer_t
  43. int            killer_i=0        local
  44. ##  ====================== Surfaces
  45. surface     tram1block1        nolink
  46. surface     tram1block2        nolink
  47. surface     tram1block3        nolink
  48. surface     tram1block4        nolink
  49. surface     tram1block5        nolink
  50. surface     tram1block6        nolink
  51. surface     tram1block7        nolink
  52. surface     tram1block8        nolink
  53. surface        switch_s        
  54.  
  55. ## ---------------------- Door sectors
  56. int            door1_s            local
  57. int            door2_s            local
  58. int            door3_s            local
  59. int            door4_s            local
  60. int            door5_s            local
  61. int            door6_s            local
  62.  
  63. ##    ===================== Vectors
  64. vector        up_v
  65.  
  66. ## ====================== Sectors
  67. sector      pickup1_s     linkid=21
  68. sector      pickup2_s        linkid=22 mask=0xffff
  69. int            tram_sect_i        local    
  70.  
  71. sound         act_snd=SWT00LtSwch2.WAV        local
  72.  
  73. ## ====================== Misc. Variables
  74.  
  75. flex        t_speed=15.0    local
  76. flex        door_speed=12.0    local
  77. int            cargo1_i=0        local
  78. int            cargo2_i=0        local 
  79. int            cargot_i=0        local
  80. int            pickups_i=0        local
  81. int            moveframe=0        local
  82. int            in_tram=0        local
  83. int            tram_pickup=0    local
  84. int            touchy=0        local
  85. int            killer_loc=1    local
  86. int            sayline=0        local
  87. int            player=0        local
  88. int            okaytoattach=1
  89.  
  90. end
  91.  
  92. # ========================================================================================
  93.  
  94. code
  95.  
  96. startup:
  97.     //movetoframe(tram,1,t_speed);
  98.     player = getlocalplayerthing();
  99.     moveframe = 1;
  100.     call open_adjoins;
  101.     door1_s = GetThingSector(door1_o);
  102.     SetSectorAdjoins(door1_s, 0);
  103.     door2_s = GetThingSector(door2_o);
  104.     SetSectorAdjoins(door2_s, 0);
  105.     door3_s = GetThingSector(door3_o);
  106.     SetSectorAdjoins(door3_s, 0);
  107.     door4_s = GetThingSector(door4_o);
  108.     SetSectorAdjoins(door4_s, 0);
  109.     door5_s = GetThingSector(door5_o);
  110.     SetSectorAdjoins(door5_s, 0);
  111.     door6_s = GetThingSector(door6_o);
  112.     SetSectorAdjoins(door6_s, 0);
  113.     
  114.     setwallcel(switch_s,1);        //turn switch to green
  115. #    global8 = 0;    
  116.      global8=1;
  117.     pickups_i = pickup1_s;
  118.     //SectorThrust(pickups_i, up_v, 5);
  119.      okaytoattach=1;
  120.     return;
  121.  
  122. touched:
  123.     print("touched");
  124.     if (touchy == 0)
  125.     {
  126.     if (getsenderref() == tram)
  127.         {
  128.         call open_adjoins;
  129.         print("touched32");
  130.         touchy = 1;
  131.         //print("touched");
  132.         tram_pickup = 0;
  133.         SectorThrust(pickups_i, up_v, 0);        //turn it off whereever it is
  134.         sleep(0.01);
  135.         call pickup1;
  136.         settimer(1);
  137.           okaytoattach=0;
  138.         }
  139.     }
  140.     return;
  141. activated:
  142.     // Hi. This is Doug. I just wanted to leave a personal message to anyone out there reading the cogs.  I love america!
  143.     if (getsenderref() == switch_s)
  144.         {
  145.             print("Cammy Line");
  146.             dwPlayCammySpeech(12120, "M1ca040.wav", 10, 3);
  147.         
  148.         setwallcel(switch_s,1 - getwallcel(switch_s));
  149.         garbage = playsoundpos(act_snd,getsurfacecenter(switch_s),0.5,-1,-1,0);
  150.                 
  151.         if (getwallcel(switch_s) == 0)        // if the switch is set to red (stopped)
  152.             {
  153.             if (killer_loc == 1)
  154.                 {
  155.                 print("Sanctuary!");
  156.                 global8 = 1;
  157.                 }
  158.             else if (killer_loc == 2)
  159.                 {
  160.                 print("Not Yet!");
  161. #                global8 = 0;
  162.                 }
  163.             stopthing(tram); //Stop the tram from moving
  164.             }
  165.         else                //else it's set to greeeeeeeeeen!
  166.             {
  167.             print("Cammy Line");
  168.             dwPlayCammySpeech(12130, "M1ca041.wav", 10, 0);
  169.             
  170. #            global8 = 0;
  171.             if (touchy != 0) settimer(0.01); //if the tram is not waiting to pickup the player
  172.             }
  173.         }    
  174.     return;
  175.  
  176. entered:
  177.     print("entered");
  178.     if (dwCheckDroidCaps(16))
  179.         {
  180.         if (getwallcel(switch_s) == 1)     //if the tram is turned on
  181.             {
  182.             if ((getcurframe(tram) == 0) && (getsenderref()== pickup1_s) && (moving == 0))
  183.                 {
  184.                 pickups_i = pickup1_s;
  185.                 call close_adjoins;
  186.                 SectorThrust(pickups_i, up_v, 5);
  187.                 setpulse(0);
  188.                     achthing=getsourceref();
  189.                 }
  190.             if ((getcurframe(tram) == 18) && (getsenderref()== pickup2_s) && (moving == 0))
  191.                 {
  192.                 if (okaytoattach!=1) return;
  193.                     pickups_i = pickup2_s;
  194.                 call close_adjoins;
  195.                 SectorThrust(pickups_i, up_v, 5);
  196.                 setpulse(0);
  197.                     if (getthingtemplate(getsourceref())==killer_t) {
  198.                          print("that AD is STUCK");
  199.                          }
  200.                     achthing=getsourceref();
  201.                     }            
  202.                }
  203.         }
  204.     return;
  205.  
  206. exited:
  207.        //This routine handles clearing varibles that keep track of what's potential cargo. 
  208.     If (getsenderref()== pickup1_s)//if something exited pickup 1
  209.         {
  210.         if (cargo1_i == getsourceref()) 
  211.             {
  212.             cargo1_i = 0; //if it was potential cargo, then remove it
  213.             SectorThrust(pickup1_s, up_v, 0);
  214.             }
  215.         }
  216.         return;               
  217.  
  218. pickup1:
  219.     // This routine picks up the player (well, in therory anything)
  220.     // It was taken from Matt the Tat's tram cog. I modified it a little. -Doug
  221.     if (dwCheckDroidCaps(16))
  222.         {
  223.         print("pick me up!");
  224.         printint(achthing);
  225.         t_speed = 7.5;
  226.         hangoffset=('0,0,0');
  227.         moving = 1;
  228.         cargot_i = achthing;
  229.         //    setsectorthrust(thrustsector, thrustvector, 0);
  230.         totalradius = GetThingRadius(achthing) + GetThingRadius(tram);
  231.         VectorSet(hangoffset, 0, 0, (-totalradius)- 0.5);
  232.         //    hangoffset = VectorAdd(hangoffset, GetThingInsertOffset(magnettram));
  233.         hangoffset = VectorSub(hangoffset, GetThingInsertOffset(achthing));
  234.         //SetThingPos(achthing, VectorAdd(GetThingPos(tram), hangoffset));
  235.         AttachThingToThingEx(achthing, tram, 8);
  236.         if (achthing==player) dwdisablejump();
  237.         }
  238.     else
  239.         {
  240.         // Tell player not magnetic
  241.         }
  242.     return;
  243.  
  244. dropoff1:
  245.     print("dropOFF:");
  246.     moving = 1;
  247.     if (cargot_i == killer_i)
  248.         {
  249.         if (getcurframe(tram) == 0)
  250.             {
  251.             killer_loc = 1;
  252.             // dwPlayCammySpeech(16122, "M1ca015.wav", 10, 0);
  253.             moving = 0;
  254.             }
  255.         if (getcurframe(tram) == 18)
  256.             {
  257.             killer_loc = 2;
  258.             dwPlayCammySpeech(16143, "M1ca028.wav", 10, 0);
  259.             moving = 0;
  260.             }
  261.         }
  262.     printint(cargot_i);
  263.     cargot_i = 0;        //empty out the cargo variable 
  264.     t_speed = 15;
  265.     //Sleep(2);   
  266.     in_tram = 0;
  267.     detachthing(achthing);
  268.     setthingvel(achthing, '0,0,0.5');
  269.     SectorThrust(pickup1_s, up_v, 3);
  270.     SectorThrust(pickup2_s, up_v, 3);
  271.     setpulse(2);
  272.     dwenablejump();
  273.     touchy = 0;
  274.     okaytoattach=1;
  275.     return;
  276.  
  277.  
  278. create_killer:
  279.     // In charge of creating the assassin droid and moving the tram;
  280.     print("Kreate Killer!");
  281.     if (killer_i != 0)
  282.         {
  283.         destroything(killer_i);
  284.         killer_i = 0;
  285.         }
  286.     if (getcurframe(tram) == 0)
  287.         {
  288.         killer_i = creatething(killer_t,ghost1_o);
  289.         moveframe = 1;
  290.         }
  291.     if (getcurframe(tram) == 18)
  292.         {
  293.         killer_i = creatething(killer_t,ghost2_o);
  294.         moveframe = 26;
  295.         }
  296.      setactorflags(killer_i, 8);        
  297.     Call Cammyline;
  298.     cargot_i = killer_i;
  299.     achthing = killer_i;
  300.     touchy = 1;
  301.     AttachThingToThingEx(killer_i, tram, 8);
  302.     movetoframe(tram,moveframe,t_speed);
  303.     return;
  304. cammyline:
  305.     if (sayline == 0)
  306.         {
  307.         dwPlayCammySpeech(12140, "M1ca042.wav", 10, 0);
  308.         sayline = 1;
  309.         }
  310.     else if (sayline == 1)
  311.         {
  312.         dwPlayCammySpeech(12141, "M1ca043.wav", 10, 0);
  313.         sayline = 2;
  314.         }
  315.     else if (sayline == 2)
  316.         {
  317.         sayline = 3;
  318.         dwPlayCammySpeech(16945, "M1ca031.wav", 10, 0);
  319.         }
  320.     else if (sayline == 3)
  321.         {
  322.         dwPlayCammySpeech(16944, "M1ca030.wav", 10, 0);
  323.         sayline = 4;
  324.         }
  325.     else
  326.         {
  327.         sayline = 3;
  328.         dwPlayCammySpeech(16945, "M1ca031.wav", 10, 0);
  329.         }
  330.         return;
  331. arrived:
  332.    if ((getsenderref() == tram) && (getwallcel(switch_s) == 1))        //if it's the tram and the switch is turned on
  333.         {
  334.         if ((getcurframe(tram))==0)
  335.             {
  336.             if (cargot_i == 0)        // If the tram is empty
  337.                 {
  338. #                call create_killer;        //Create the assassin
  339.                 }
  340.             else                //Else something's in the tram
  341.                 {
  342.                 if (cargot_i == player) //if the player is in the tram
  343.                     {
  344.                     call dropoff1;         //drop it.
  345.                     moveframe = 1;
  346.                     settimer(2);
  347.                     }
  348.                 if (cargot_i == killer_i) //if the player is in the tram
  349.                     {
  350.                     call dropoff1;         //drop it.
  351.                     moveframe = 1;
  352.                     global8=1;
  353.                          //settimer(2);
  354.                     }
  355.                 
  356.                 }
  357.             moveframe = 1;
  358.             } 
  359.         else if ((getcurframe(tram))==1)
  360.             {
  361.             SetSectorAdjoins(door1_s, 1);  //Turn on door adjoins
  362.             movetoframe(door1_o,1,door_speed);
  363.                moveframe = 2;
  364.             movetoframe(tram,2,t_speed);
  365.             } 
  366.          else if ((getcurframe(tram))==2)
  367.             {
  368.             movetoframe(door1_o,0,door_speed);
  369.                moveframe = 3;
  370.             movetoframe(tram,3,t_speed);
  371.             }
  372.          else if ((getcurframe(tram))==3)
  373.             {
  374.             SetSectorAdjoins(door2_s, 1);  //Turn on door adjoins
  375.             movetoframe(door2_o,1,door_speed);
  376.                moveframe = 4;
  377.             movetoframe(tram,4,t_speed);
  378.             }
  379.          else if ((getcurframe(tram))==4)
  380.             {
  381.             movetoframe(door2_o,0,door_speed);  // Close door
  382.                moveframe = 7;
  383.             movetoframe(tram,7,t_speed);
  384.             }   
  385.          else if ((getcurframe(tram))==7)
  386.             {
  387.             SetSectorAdjoins(door3_s, 1);  //Turn on door adjoins
  388.             movetoframe(door3_o,1,door_speed);
  389.                moveframe = 8;
  390.             movetoframe(tram,8,t_speed);
  391.             } 
  392.          else if ((getcurframe(tram))==8)
  393.             {
  394.             movetoframe(door3_o,0,door_speed);  // Close door
  395.                moveframe = 9;
  396.             movetoframe(tram,9,t_speed);
  397.             }
  398.          else if ((getcurframe(tram))==9)
  399.             {
  400.             SetSectorAdjoins(door4_s, 1);  //Turn on door adjoins
  401.             movetoframe(door4_o,1,door_speed);
  402.                moveframe = 10;
  403.             movetoframe(tram,10,t_speed);
  404.             } 
  405.          else if ((getcurframe(tram))==10)
  406.             {
  407.             movetoframe(door4_o,0,door_speed);  // Close door
  408.                moveframe = 12;
  409.             movetoframe(tram,12,t_speed);
  410.             }
  411.          else if ((getcurframe(tram))==12)
  412.             {
  413.             SetSectorAdjoins(door5_s, 1);  //Turn on door adjoins
  414.             movetoframe(door5_o,1,door_speed);
  415.                moveframe = 13;
  416.             movetoframe(tram,13,t_speed);
  417.             } 
  418.          else if ((getcurframe(tram))==13)
  419.             {
  420.             movetoframe(door5_o,0,door_speed);  // Close door
  421.                moveframe = 14;
  422.             movetoframe(tram,14,t_speed);
  423.             }
  424.          else if ((getcurframe(tram))==14)
  425.             {
  426.             SetSectorAdjoins(door6_s, 1);  //Turn on door adjoins
  427.             movetoframe(door6_o,1,door_speed);
  428.                moveframe = 15;
  429.             movetoframe(tram,15,t_speed);
  430.             } 
  431.          else if ((getcurframe(tram))==15)
  432.             {
  433.             movetoframe(door6_o,0,door_speed);  // Close door
  434.                moveframe = 18;
  435.             movetoframe(tram,18,t_speed);
  436.             }
  437.          else if ((getcurframe(tram))==18)
  438.             {
  439.             if (cargot_i == player) // If it's dropping off the player
  440.                 {
  441.                 call dropoff1;
  442.                 moveframe = 26;
  443.                 settimer(2);
  444.                 }
  445.             else if (cargot_i == killer_i) // else if it's dropping off the assassin droid
  446.                 {
  447.                 call dropoff1;
  448.                 //destroything(killer_i);
  449.                 pickups_i = pickup2_s;
  450.                 moveframe = 26;
  451.                 }
  452.             else if (cargot_i == 0) // else if it's empty
  453.                 {
  454. #                call create_killer;
  455.                 }
  456.             }
  457.          else if ((getcurframe(tram))==26)
  458.             {
  459.                moveframe = 0;
  460.             skiptoframe(tram,0,t_speed);
  461.             }
  462.         }
  463.     else if (getsenderref() == door1_o) //if it's door 1 
  464.         {
  465.         if (getcurframe(door1_o) == 0) SetSectorAdjoins(door1_s, 0);  //Turn off door adjoins
  466.         }
  467.     else if (getsenderref() == door2_o) 
  468.         {                                            
  469.         if (getcurframe(door2_o) == 0) SetSectorAdjoins(door2_s, 0);  //Turn off door adjoins
  470.         }
  471.     else if (getsenderref() == door3_o)                            
  472.         {                                            
  473.         if (getcurframe(door3_o) == 0) SetSectorAdjoins(door3_s, 0);  //Turn off door adjoins
  474.         }
  475.     else if (getsenderref() == door4_o)                            
  476.         {                                            
  477.         if (getcurframe(door4_o) == 0) SetSectorAdjoins(door4_s, 0);  //Turn off door adjoins
  478.         }
  479.     else if (getsenderref() == door5_o)                            
  480.         {                                            
  481.         if (getcurframe(door5_o) == 0) SetSectorAdjoins(door5_s, 0);  //Turn off door adjoins
  482.         }
  483.     else if (getsenderref() == door6_o)                            
  484.         {                                            
  485.         if (getcurframe(door6_o) == 0) SetSectorAdjoins(door6_s, 0);  //Turn off door adjoins
  486.         }
  487.     
  488.     return;
  489. timer:
  490.     // this routine is used to control the movement of the tram after it's waited at 
  491.     // the stop for a settimer() amount of ti
  492.     print("I pity the fool");
  493.     if (moveframe == 0) skiptoframe(tram,moveframe,t_speed);
  494.     else movetoframe(tram,moveframe,t_speed);
  495.     
  496.     return;
  497.  
  498. pulse:
  499.     SectorThrust(pickup1_s, up_v, 0);
  500.     SectorThrust(pickup2_s, up_v, 0);
  501.     setpulse(0);
  502.     return;
  503.  
  504. open_adjoins:
  505.      if (getcurframe(tram) == 0)
  506.          {
  507.          print("clearing flags");
  508.          setadjoinflags(tram1block1, 2);
  509.          setadjoinflags(tram1block2, 2);
  510.          setadjoinflags(tram1block3, 2);
  511.          setadjoinflags(tram1block4, 2);
  512.          }
  513.      if (getcurframe(tram) == 18)
  514.          {
  515.          print("clearing flags 2");
  516.          setadjoinflags(tram1block5, 2);
  517.          setadjoinflags(tram1block6, 2);
  518.          setadjoinflags(tram1block7, 2);
  519.          setadjoinflags(tram1block8, 2);
  520.          }
  521.         
  522.      return;
  523.      
  524. close_adjoins:
  525.      if (getcurframe(tram) == 0)
  526.         {
  527.         print("setting flags");
  528.         clearadjoinflags(tram1block1, 2);
  529.         clearadjoinflags(tram1block2, 2);
  530.         clearadjoinflags(tram1block3, 2);
  531.         clearadjoinflags(tram1block4, 2);
  532.         }
  533.      if (getcurframe(tram) == 18)
  534.         {
  535.         print("setting flags 2");
  536.         clearadjoinflags(tram1block5, 2);
  537.         clearadjoinflags(tram1block6, 2);
  538.         clearadjoinflags(tram1block7, 2);
  539.         clearadjoinflags(tram1block8, 2);
  540.         }
  541.      
  542.      return;
  543.  
  544.  
  545. end
  546.