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

  1. # Droids Cog Script
  2. #
  3. # 03_door.cog
  4. #
  5. # Generic Door Script
  6. #
  7. #         [IS]
  8. # 01/30/98    [DGS]    Added the switch
  9. # /2/15/98     [JP]      Modified for use in the Moisture Farm
  10. # ========================================================================================
  11.  
  12. symbols
  13.     message    startup        
  14.     message    activate    
  15.     message    arrived        
  16.     message    timer        
  17.     message    blocked        
  18.     message    pulse
  19.     
  20.     thing        door0        linkid=0 mask=0x405
  21.     thing        door1        linkid=1 mask=0x405
  22.     thing        door2        linkid=2 mask=0x405
  23.     thing        door3        linkid=3 mask=0x405
  24.  
  25.     float        moveSpeed=8.0
  26.     float        sleepTime=2.0
  27.     float        lightValue=0.5
  28.  
  29.     surface        button0    linkid=5
  30.     surface        button1    linkid=5
  31.     
  32.     sector    doorSector    local
  33.      
  34.      sound     switch=swt00drswtch.wav   local
  35.      sound     open=dor00strt02.wav      local
  36.      sound     close=dor00strt02.wav      local
  37.     
  38.     int        numDoors=0    local
  39.     int        doorStatus    local
  40.     int        moveStatus    local
  41.     int        i                local
  42. end
  43.  
  44. # ========================================================================================
  45.  
  46. code
  47.  
  48. startup:
  49.     for (i=0; i<=3; i=i+1)
  50.         if (door0[i] >= 0) numDoors = numDoors + 1;
  51.  
  52.     doorSector = GetThingSector(door0);
  53.     SetSectorAdjoins(doorSector, 0);
  54.     SetSectorLight(doorSector, lightValue, 0.0);        // add some light to door sector
  55.      Setwallcel(button0, 2);
  56.      Setwallcel(button1, 2);
  57.     return;
  58.  
  59. # ........................................................................................
  60.  
  61. activate:
  62.     if (getsenderid() == 5)
  63.         {
  64.         call CheckStatus;
  65.         if (moveStatus) return;
  66.         if (doorStatus == 0) 
  67.             {                    // all pieces are at frame 0
  68.             SetSectorAdjoins(doorSector, 1);
  69.             setwallcel(button0,1);
  70.             setwallcel(button1,1);
  71.                playsoundlocal(switch, 1, 0, 0);  //hit the switch sound
  72.             call OpenDoors;
  73.             }
  74.         }
  75.     return;
  76.  
  77. # ........................................................................................
  78. pulse:
  79.         setwallcel(button0,1-getwallcel(button0));
  80.     setwallcel(button1,1-getwallcel(button1));
  81.     return;
  82. arrived:
  83.     call CheckStatus;
  84.     if (moveStatus) return;
  85.         if (doorStatus == numDoors) 
  86.         {                // all pieces are at frame 1
  87.         SetTimer(sleepTime);
  88.         setpulse(0.1);
  89.         } 
  90.     else if (doorStatus == 0) 
  91.         {                // all pieces are at frame 0
  92.         SetSectorAdjoins(doorSector, 0);
  93.                 setwallcel(button0,2);
  94.         setwallcel(button1,2);
  95.         }
  96.     return;
  97.  
  98. # ........................................................................................
  99.  
  100. blocked:
  101.     call OpenDoors;
  102.     return;
  103.  
  104. # ........................................................................................
  105.  
  106. timer:
  107.     setpulse(0);
  108.         setwallcel(button0,1);
  109.     setwallcel(button1,1);
  110.     call CloseDoors;
  111.     return;
  112.  
  113. # ........................................................................................
  114.  
  115. OpenDoors:
  116.     for (i=0; i<=3; i=i+1)
  117.         if (door0[i] >= 0) 
  118.           {
  119.           MoveToFrame(door0[i], 1, moveSpeed);
  120.           PlaySoundThing(open, door0, 1.0, -1, -1, 0); //open door sound
  121.           }
  122.  
  123.     return;
  124.  
  125. # ........................................................................................
  126.  
  127. CloseDoors:
  128.     for (i=0; i<=3; i=i+1)
  129.         if (door0[i] >= 0)
  130.           {
  131.           MoveToFrame(door0[i], 0, moveSpeed);
  132.           PlaySoundThing(close, door0, 1.0, -1, -1, 0); //close door sound
  133.           }
  134.     return;
  135.  
  136. # ........................................................................................
  137.  
  138. CheckStatus:
  139.     moveStatus = 0;
  140.     doorStatus = 0;
  141.  
  142.     for (i=0; i<=3; i=i+1) {
  143.         if (door0[i] >= 0) {
  144.             moveStatus = moveStatus + IsThingMoving(door0[i]);
  145.             doorStatus = doorStatus + GetCurFrame(door0[i]);
  146.         }
  147.     }
  148.     return;
  149.  
  150. end
  151.  
  152.