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

  1. #standard type magnetic tram cog.
  2. #don't forget to set blocking walls to "no move"
  3. symbols
  4. message             startup
  5. message             arrived
  6. message             crossed
  7. message             entered
  8. message             timer
  9.  
  10. thing               newtram             linkid=4
  11. thing               crateG
  12. thing               teleport1
  13. thing               teleport2
  14.  
  15. template            crateT
  16.  
  17. sector              thrustsector        linkid=5   
  18. sector              checksector         linkid=1
  19. sector              startsector         linkid=2
  20.  
  21. surface             triggeradjoin       mask=0xfff    
  22. surface             tram1block1         nolink
  23. surface             tram1block2         nolink
  24. surface             tram1block3         nolink
  25. surface             tram1block4         nolink
  26.  
  27. vector              cratepos            local
  28. vector              trampos             local
  29. vector              thrustvector
  30.  
  31. surface             conv0
  32. surface             conv1
  33. surface             conv2
  34. surface             conv3
  35. surface             conv4
  36. surface             conv5
  37.  
  38. vector              slidevector
  39.  
  40. end
  41.  
  42. ## Code Section
  43. code                  
  44. startup:
  45.      player=getlocalplayerthing();
  46.      setthinglight(newtram, 1.0, 0);
  47.      if (dwcheckdroidcaps(16)!=0) magneticthrust=8; //droid is magnetic
  48.      else magneticthrust=0;
  49.      call belton;
  50.      isattached=0;
  51.      return;
  52.      
  53. belton:
  54.      anim0=slidewall(conv0, slidevector, 5.0);     
  55.      anim1=slidewall(conv1, slidevector, 5.0);
  56.      anim2=slidewall(conv2, slidevector, 5.0);
  57.      anim3=slidewall(conv3, slidevector, 5.0);
  58.      anim4=slidewall(conv4, slidevector, 5.0);
  59.      anim5=slidewall(conv5, slidevector, 5.0);
  60.      return;
  61.      
  62. beltoff:
  63.      stopanim(anim0);     
  64.      stopanim(anim1);
  65.      stopanim(anim2);
  66.      stopanim(anim3);
  67.      stopanim(anim4);
  68.      stopanim(anim5);
  69.      return;
  70.      
  71. crossed:
  72.      print("crossed");
  73.      if ( (getcurframe(newtram)==2)&&(dwcheckdroidcaps(16)!=0) ) {
  74.           print("trying to attach droid");
  75.           hangoffset=('0,0,0');
  76.           achthing=getsourceref();
  77.           call movetram;
  78.      }
  79.      return;
  80.  
  81. movetram:
  82.      print("attaching crate");
  83.      isattached=1;
  84.      call clrajnflgs;
  85.      totalradius = GetThingRadius(achthing) + GetThingRadius(magnettram);
  86.     VectorSet(hangoffset, 0, 0, -totalradius);
  87.  //    hangoffset = VectorAdd(hangoffset, GetThingInsertOffset(magnettram));
  88.     hangoffset = VectorSub(hangoffset, GetThingInsertOffset(achthing));
  89.     SetThingPos(achthing, VectorAdd(GetThingPos(newtram), hangoffset));
  90.     AttachThingToThingEx(achthing, newtram, 8);     
  91.      movetoframe(newtram, 1, 4);
  92.      movetoframe(newcrate, 2, 5);
  93.      setsectorthrust(thrustsector, thrustvector, 0);
  94.      return;
  95.      
  96. arrived:
  97.      //when the tram has arrived, drop the achthing and reset to stop 0
  98.      if (getsenderid()==4) {
  99.           if (getcurframe(newtram)==1) {
  100.                print("reached dropoff frame");
  101.                if (isattached==1) {
  102.                     print("detachting thing");
  103.                     isattached=0;
  104.                     sleep(2);
  105.                     detachthing(achthing);
  106.                     setthingvel(achthing, '0,0,0.5');
  107.                     movetoframe(newtram, 0, 4); 
  108.                     dwenablejump();
  109.                }
  110.                else movetoframe(newtram, 0, 4);         
  111.           }
  112.           else if (getcurframe(newtram)==2) {
  113.                call setajnflags;
  114.                print("sector thrust on!");
  115.                setsectorthrust(thrustsector, thrustvector, magneticthrust);                   
  116.                settimer(5);
  117.           }
  118.           else if (getcurframe(newtrame)==0) print("let's stop now.");
  119.      }
  120.      else {
  121.           if (getcurframe(newcrate)==2) {  
  122.                destroything(newcrate);
  123.                if (getthingsector(player)==checksector) {
  124.                     teleportthing(player, teleport1);
  125.                     print("teleporting player out");
  126.                }
  127.                else call createcrate;
  128.           }
  129.           else if (getcurframe(newcrate)==1) { 
  130.                call setajnflgs;
  131.                sleep(2);
  132.                print("here comes the tram");
  133.                movetoframe(newtram, 2, 4);
  134. //               playsoundthing(t1tramstart, newtram, 1, -1, 80, 0);
  135. //               movechannel=playsoundthing(t1trammove, newtram, 1, -1, 80, 0x1);             
  136.                call beltoff;
  137.           }
  138.      }     
  139.      return;
  140.      
  141. entered:
  142.      if (getsenderid()==2) {
  143.           call createcrate; 
  144.           print("you're in the factory");          
  145.           if (magneticthrust!=0) dwdisablejump();
  146.      }
  147.      return;
  148.      
  149. timer:                         
  150.      if ( (getcurframe(newtram)==2)&&(isthingmoving(newtram)==0) ) {
  151.           print("you blew it.");
  152.           movetoframe(newtram, 0, 4);
  153.           movetoframe(newcrate, 2, 5);
  154.           setsectorthrust(thrustsector, thrustvector, 0);
  155.           call clrajnflgs;
  156.           call belton;
  157.      }
  158.      return;
  159.  
  160.  
  161. clrajnflgs:
  162.      print("clearing flags");
  163.      setadjoinflags(tram1block1, 2);
  164.      setadjoinflags(tram1block2, 2);
  165.      setadjoinflags(tram1block3, 2);
  166.      setadjoinflags(tram1block4, 2);
  167.      return;
  168.      
  169. setajnflgs:
  170.      print("setting flags");
  171.      clearadjoinflags(tram1block1, 2);
  172.      clearadjoinflags(tram1block2, 2);
  173.      clearadjoinflags(tram1block3, 2);
  174.      clearadjoinflags(tram1block4, 2);
  175.      return;
  176.      
  177. createcrate:
  178.      newcrate=CreateThing(crateT, crateG);
  179.      CaptureThing(newcrate);
  180.      movetoframe(newcrate, 1, 5);
  181.      return;
  182.  
  183.           
  184.  
  185.  
  186. end
  187.  
  188.  
  189.