home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / Titans / beastboy.swf / scripts / DefineSprite_338 / frame_1 / DoAction.as
Encoding:
Text File  |  2006-01-05  |  1.2 KB  |  72 lines

  1. range = 300;
  2. xs = 3;
  3. xmin = _X;
  4. xmax = _X + range;
  5. _xscale = -100;
  6. hd = 1;
  7. attacking = 0;
  8. onenterframe = function()
  9. {
  10.    if(!attacking)
  11.    {
  12.       _X = _X + xs;
  13.       if(_X > xmax)
  14.       {
  15.          _X = xmax;
  16.          xs = - xs;
  17.          _xscale = 100;
  18.          hd = 2;
  19.       }
  20.       else if(_X < xmin)
  21.       {
  22.          _X = xmin;
  23.          xs = - xs;
  24.          _xscale = -100;
  25.          hd = 1;
  26.       }
  27.       if(p._y <= _Y + 10 and p._y > _Y - 150)
  28.       {
  29.          dx = _X - p._x;
  30.          if(math.abs(dx) < 100)
  31.          {
  32.             if(hd == 1 and dx < 0 or hd == 2 and dx > 0)
  33.             {
  34.                attacking = 1;
  35.                d = 20;
  36.                t.gotoAndStop("attack");
  37.             }
  38.          }
  39.       }
  40.    }
  41.    else
  42.    {
  43.       d--;
  44.       if(d < 15)
  45.       {
  46.          cekhitp(this);
  47.       }
  48.       if(!d)
  49.       {
  50.          attacking = 0;
  51.          t.gotoAndStop("walk");
  52.       }
  53.    }
  54.    cekhitattack(z);
  55.    if(die)
  56.    {
  57.       if(hd == 1 and dx < 0 or hd == 2 and dx > 0)
  58.       {
  59.          die = 0;
  60.          cekhitp(this);
  61.          attacking = 1;
  62.          d = 20;
  63.          t.gotoAndStop("attack");
  64.       }
  65.       else
  66.       {
  67.          gotoAndPlay(2);
  68.       }
  69.    }
  70. };
  71. stop();
  72.