home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / roam-and-protect.swf / scripts / DefineSprite_293 / frame_4 / DoAction.as
Encoding:
Text File  |  2005-09-29  |  3.1 KB  |  136 lines

  1. _X = _X + (speed * direct + _root.movevar);
  2. myx = _X;
  3. myy = _Y;
  4. if(_root.restart eq "true")
  5. {
  6.    gotoAndStop("off");
  7.    play();
  8. }
  9. if(targon eq "false")
  10. {
  11.    if(myx > - myw and myx < _root.stageW + myw)
  12.    {
  13.       listnum = _root.enlist.length;
  14.       _root.enlist[_root.enlist.length] = _name;
  15.       this._visible = 1;
  16.       targon = "true";
  17.    }
  18. }
  19. else
  20. {
  21.    this;
  22.    if(hitTest(_root.chopper))
  23.    {
  24.       _root.chopper.hits -= 5;
  25.       _root.chopper.chopper.field.gotoAndPlay(2);
  26.       if(myx > _root.playerX)
  27.       {
  28.          _root.chopper.xmove = -20;
  29.       }
  30.       else
  31.       {
  32.          _root.chopper.xmove = 20;
  33.       }
  34.       if(myy > _root.playerY)
  35.       {
  36.          _root.chopper.ymove = -20;
  37.       }
  38.       else
  39.       {
  40.          _root.chopper.ymove = 20;
  41.       }
  42.       hits = -1;
  43.    }
  44.    if(myx < myw * -1 or myx > _root.stageW + myw)
  45.    {
  46.       _root.enlist.splice(listnum,1);
  47.       e = listnum;
  48.       e;
  49.       while(e < _root.enlist.length)
  50.       {
  51.          eval("_root." add _root.enlist[e]).listnum -= 1;
  52.          e++;
  53.       }
  54.       this._visible = 0;
  55.       targon = "false";
  56.    }
  57. }
  58. if(targon eq "true")
  59. {
  60.    chopY = _root.chopper._y;
  61.    chopX = _root.chopper._x;
  62.    if(_Y > chopY + 50)
  63.    {
  64.       _Y = _Y - speed;
  65.       jet._rotation = -75;
  66.    }
  67.    else if(_Y < chopY - 50)
  68.    {
  69.       _Y = _Y + speed;
  70.       jet._rotation = -75;
  71.    }
  72.    if(_X > chopX - 150 and _X < chopX + 150)
  73.    {
  74.       speed *= 0.75;
  75.       if(_X < chopX)
  76.       {
  77.          if(direct == -1)
  78.          {
  79.             direct = 1;
  80.             _xscale = _xscale * -1;
  81.          }
  82.       }
  83.       else if(direct == 1)
  84.       {
  85.          direct = -1;
  86.          _xscale = _xscale * -1;
  87.       }
  88.    }
  89.    else if(speed < orgspeed)
  90.    {
  91.       speed += 1;
  92.       jet._rotation = 0;
  93.    }
  94.    if(random(400) < firecnt)
  95.    {
  96.       if(_root.encnt > 10)
  97.       {
  98.          _root.encnt = 0;
  99.       }
  100.       else
  101.       {
  102.          _root.encnt += 1;
  103.       }
  104.       if(direct == 1)
  105.       {
  106.          myradians = Math.atan2(_root.chopper._y - _Y,_root.chopper._x - _X);
  107.          myangle = myradians * 100 / 3.141592653589793;
  108.          xmove = Math.cos(0.017453292519943295 * myangle) * -10;
  109.          ymove = Math.sin(0.017453292519943295 * myangle) * -10;
  110.       }
  111.       else
  112.       {
  113.          myradians = Math.atan2(_Y - _root.chopper._y,_X - _root.chopper._x);
  114.          myangle = myradians * 100 / 3.141592653589793;
  115.          xmove = Math.cos(0.017453292519943295 * myangle) * 10;
  116.          ymove = Math.sin(0.017453292519943295 * myangle) * 10;
  117.       }
  118.       duplicateMovieClip(_root.bullet2,"enbullet" add _root.encnt,16384 + (500 + _root.encnt));
  119.       eval("_root.enbullet" add _root.encnt).xmove = xmove;
  120.       eval("_root.enbullet" add _root.encnt).ymove = ymove;
  121.       eval("_root.enbullet" add _root.encnt).xorg = _X;
  122.       eval("_root.enbullet" add _root.encnt).yorg = _Y;
  123.       eval("_root.enbullet" add _root.encnt).gotoAndPlay("fire");
  124.    }
  125. }
  126. if(hits < 0)
  127. {
  128.    _root.fightertocnt = _root.shiptocnt + 1;
  129.    gotoAndStop("explode");
  130.    play();
  131. }
  132. else
  133. {
  134.    gotoAndPlay(_currentframe - 1);
  135. }
  136.