home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / dragon.swf / scripts / DefineSprite_312_flame_ball / frame_1 / DoAction.as
Encoding:
Text File  |  2008-09-12  |  4.2 KB  |  149 lines

  1. function setVelocity(xdelta, ydelta)
  2. {
  3.    vx = xdelta;
  4.    vy = ydelta;
  5. }
  6. function step()
  7. {
  8.    m_flightTime++;
  9.    vy += _parent._parent.g_grav;
  10.    _Y = _Y + vy;
  11.    _X = _X + vx;
  12.    radians = Math.atan(vy / vx);
  13.    if(vx > 0)
  14.    {
  15.       _rotation = radians * 180 / 3.14159;
  16.    }
  17.    else
  18.    {
  19.       _rotation = radians * 180 / 3.14159 + 180;
  20.    }
  21.    if(vx < 0.00001 && vx > -0.00001)
  22.    {
  23.       _rotation = _rotation + 180;
  24.    }
  25.    if(boundaryTimer-- < 0)
  26.    {
  27.       boundaryTimer = 25;
  28.       if(_X < xmin || _X > xmax || _Y > ymax)
  29.       {
  30.          this.unloadMovie();
  31.       }
  32.    }
  33.    if(_X < -10 || _X > xmax || _Y > ymax)
  34.    {
  35.       this.unloadMovie();
  36.    }
  37.    if(flameDebrisTimer-- < 0)
  38.    {
  39.       flameDebrisTimer = 0;
  40.       var _loc3_ = _parent._parent.addObj("flame_spark",_parent._parent.debris_layer,_parent._parent.getNextDebrisLevel());
  41.       _loc3_._x = _X;
  42.       _loc3_._y = _Y;
  43.       _loc3_._rotation = _rotation;
  44.       _loc3_._xscale = _loc3_._yscale = 30 + rank * 20;
  45.       _loc3_.decayRate = 6;
  46.    }
  47.    testHitEnemies();
  48. }
  49. function testHitEnemies()
  50. {
  51.    var _loc4_ = undefined;
  52.    var _loc5_ = false;
  53.    var _loc3_ = 0;
  54.    while(_loc3_ < _parent._parent.enemies.length && !_loc5_)
  55.    {
  56.       _loc4_ = _parent._parent.enemies[_loc3_];
  57.       if(_loc4_.hitBox.hitTest(_X,_Y,0))
  58.       {
  59.          _loc5_ = true;
  60.          break;
  61.       }
  62.       _loc3_ = _loc3_ + 1;
  63.    }
  64.    if(_loc5_)
  65.    {
  66.       if(_loc4_.etype == "air_ship")
  67.       {
  68.          _parent._parent.woodExplosion(_X,_Y,Math.ceil(rank / 2.5));
  69.          _loc4_.testHitTroops(this);
  70.       }
  71.       var _loc9_ = undefined;
  72.       var _loc8_ = false;
  73.       if(_loc4_.etype != "fire")
  74.       {
  75.          if(_loc4_.etype == "air_ship" || _loc4_.etype == "dragon_archer" || _loc4_.etype == "dragon_scout" || _loc4_.etype == "greese")
  76.          {
  77.             _parent._parent.addSticky("sticky_fire",_loc4_,_X,_Y,20 + rank * 20);
  78.             _loc4_.takeDamage(rank * 2,_X,_Y);
  79.             _loc9_ = rank * 10;
  80.             _parent._parent.updateRankFire(getFlightBonus(10) + 5);
  81.             _loc8_ = true;
  82.             _parent._parent.playSound("shoot_rocket.wav");
  83.          }
  84.          else if(_loc4_.etype == "ice")
  85.          {
  86.             _loc4_.takeDamage(rank * 5,_X,_Y);
  87.             _loc9_ = rank * 20;
  88.             _parent._parent.updateRankFire(getFlightBonus(20) + 10);
  89.             _loc8_ = true;
  90.             _parent._parent.playSound("ice_shatter.wav");
  91.          }
  92.          else if(_loc4_.etype == "steel")
  93.          {
  94.             _loc9_ = 10;
  95.             _parent._parent.playSound("ching2.wav");
  96.          }
  97.          else
  98.          {
  99.             _loc4_.takeDamage(rank * 2,_X,_Y);
  100.             _loc9_ = rank * 10;
  101.             _parent._parent.updateRankFire(getFlightBonus(10) + 5);
  102.             _loc8_ = true;
  103.             _parent._parent.playSound("shoot_rocket.wav");
  104.          }
  105.          var _loc7_ = _parent._parent.addObj("explosion_pow",_parent._parent.debris_layer,_parent._parent.getNextDebrisLevel());
  106.          _loc7_._x = _X;
  107.          _loc7_._y = _Y;
  108.          _loc7_._rotation = random(360);
  109.          _loc7_._xscale = _loc7_._yscale = _loc9_;
  110.       }
  111.       else
  112.       {
  113.          _loc4_.takeDamage(0,_X,_Y);
  114.          _parent._parent.playSound("ching2.wav");
  115.       }
  116.       if(!_loc8_)
  117.       {
  118.          var _loc6_ = _parent._parent.addObj("deflect_flame",_parent._parent.debris_layer,_parent._parent.getNextDebrisLevel());
  119.          _loc6_._x = _X;
  120.          _loc6_._y = _Y;
  121.          var _loc10_ = Math.sqrt(vx * vx + vy * vy) * 0.75;
  122.          var _loc11_ = random(360);
  123.          _loc6_.vx = Math.cos(0.017453292519943295 * _loc11_) * _loc10_;
  124.          _loc6_.vy = Math.sin(0.017453292519943295 * _loc11_) * _loc10_;
  125.          _loc6_._xscale = _loc6_._yscale = _xscale;
  126.          _loc6_.rank = rank;
  127.       }
  128.       this.unloadMovie();
  129.    }
  130. }
  131. function getFlightBonus(amt)
  132. {
  133.    var _loc1_ = m_flightTime / 10;
  134.    if(_loc1_ > 4)
  135.    {
  136.       _loc1_ = 4;
  137.    }
  138.    return Math.ceil(_loc1_ * amt);
  139. }
  140. xmax = _parent._parent.g_width + 10;
  141. ymax = _parent._parent.g_ground + 10;
  142. flameDebrisTimer = 0;
  143. xmax = _parent._parent.g_width + 50;
  144. xmin = -50;
  145. ymin = -50;
  146. ymax = _parent._parent.g_ground + 50;
  147. boundaryTimer = 50;
  148. var m_flightTime = 0;
  149.