home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / colobotdemo / colobotdemo10e.exe / script / tprot1a.txt < prev    next >
Text File  |  2001-06-10  |  1KB  |  54 lines

  1. extern void object::Attack( )
  2. {
  3.     object    p;
  4.     float    dist, prox;
  5.     point    nav1, nav2, dest;
  6.     boolean    advance = true;
  7.  
  8.     wait(5);
  9.  
  10.     while ( true )
  11.     {
  12.         p = radar(WheeledShooter);
  13.         if ( p == null )
  14.         {
  15.             nav1.x = position.x-5;
  16.             nav1.y = position.y;
  17.             nav2.x = position.x+5;
  18.             nav2.y = position.y;
  19.  
  20.             while ( true )
  21.             {
  22.                 goto(nav1);
  23.                 p = radar(WheeledShooter);
  24.                 if ( p != null )  break;
  25.  
  26.                 goto(nav2);
  27.                 p = radar(WheeledShooter);
  28.                 if ( p != null )  break;
  29.             }
  30.         }
  31.         else
  32.         {
  33.             dist = distance(p.position, position);
  34.             if ( dist <= 25 && !advance )
  35.             {
  36.                 fire(p.position);
  37.                 advance = true;
  38.                 wait(2);
  39.             }
  40.             else
  41.             {
  42.                 prox = dist-5;
  43.                 if ( prox > 25 )  prox = 25;
  44.                 if ( prox < 15 )  prox = 15;
  45.                 dest.x = (position.x-p.position.x)*prox/dist + p.position.x;
  46.                 dest.y = (position.y-p.position.y)*prox/dist + p.position.y;
  47.                 dest.z = (position.z-p.position.z)*prox/dist + p.position.z;
  48.                 goto(dest);
  49.                 advance = false;
  50.             }
  51.         }
  52.     }
  53. }
  54.