home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / dragon.swf / scripts / DefineSprite_79_greese_ball / frame_1 / DoAction.as
Encoding:
Text File  |  2008-09-12  |  3.4 KB  |  128 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(flameDebrisTimer-- < 0)
  34.    {
  35.       flameDebrisTimer = 0;
  36.       var _loc3_ = _parent._parent.addObj("oil_glob",_parent._parent.debris_layer,_parent._parent.getNextDebrisLevel());
  37.       _loc3_._x = _X;
  38.       _loc3_._y = _Y;
  39.       _loc3_._rotation = _rotation;
  40.       _loc3_._xscale = _loc3_._yscale = 30 + rank * 20;
  41.       _loc3_.decayRate = 6;
  42.    }
  43.    testHitEnemies();
  44. }
  45. function testHitEnemies()
  46. {
  47.    var _loc4_ = undefined;
  48.    var _loc5_ = false;
  49.    var _loc3_ = 0;
  50.    while(_loc3_ < _parent._parent.enemies.length && !_loc5_)
  51.    {
  52.       _loc4_ = _parent._parent.enemies[_loc3_];
  53.       if(_loc4_.hitBox.hitTest(_X,_Y,0))
  54.       {
  55.          _loc5_ = true;
  56.          break;
  57.       }
  58.       _loc3_ = _loc3_ + 1;
  59.    }
  60.    if(_loc5_)
  61.    {
  62.       _parent._parent.playSound("blood_splat.wav");
  63.       if(_loc4_.etype == "air_ship")
  64.       {
  65.          _loc4_.testHitTroops(this);
  66.       }
  67.       if(_loc4_.etype == "greese" || _loc4_.etype == "steel")
  68.       {
  69.          _loc4_.takeDamage(0,_X,_Y);
  70.       }
  71.       else
  72.       {
  73.          _parent._parent.addSticky("sticky_greese",_loc4_,_X,_Y,20 + rank * 20);
  74.          _loc4_.takeDamage(Math.ceil(rank / 2),_X,_Y);
  75.          _parent._parent.updateRankGreese(getFlightBonus(10) + 5);
  76.       }
  77.       this.unloadMovie();
  78.    }
  79. }
  80. function testHitTroops(obj)
  81. {
  82.    if(obj.archer != null && obj.archer.hitTest(_X,_Y,0))
  83.    {
  84.       obj.archer.unloadMovie();
  85.       _parent._parent.addFlyingTroop("deb_ene_archer",_X,_Y,obj.archer._xscale,obj.archer._yscale);
  86.    }
  87.    else if(obj.boss != null && obj.boss.hitTest(_X,_Y,0))
  88.    {
  89.       _parent._parent.updateRankGreese(getFlightBonus(10) + 5,_X,_Y);
  90.       _parent._parent.addFlyingTroop("deb_ene_boss",_X,_Y,obj.archer._xscale,obj.archer._yscale);
  91.       obj.boss.unloadMovie();
  92.    }
  93.    else if(obj.foot1 != null && obj.foot1.hitTest(_X,_Y,0))
  94.    {
  95.       _parent._parent.addFlyingTroop("deb_ene_foot",_X,_Y,obj.archer._xscale,obj.archer._yscale);
  96.       obj.foot1.unloadMovie();
  97.    }
  98.    else if(obj.foot2 != null && obj.foot2.hitTest(_X,_Y,0))
  99.    {
  100.       _parent._parent.addFlyingTroop("deb_ene_foot",_X,_Y,obj.archer._xscale,obj.archer._yscale);
  101.       obj.foot2.unloadMovie();
  102.    }
  103.    else if(obj.flagger != null && obj.flagger.hitTest(_X,_Y,0))
  104.    {
  105.       _parent._parent.addFlyingTroop("deb_ene_cat",_X,_Y,obj.archer._xscale,obj.archer._yscale);
  106.       obj.flagger.unloadMovie();
  107.    }
  108. }
  109. function getFlightBonus(amt)
  110. {
  111.    var _loc1_ = m_flightTime / 10;
  112.    if(_loc1_ > 4)
  113.    {
  114.       _loc1_ = 4;
  115.    }
  116.    return Math.ceil(_loc1_ * amt);
  117. }
  118. xmax = _parent._parent.g_width + 10;
  119. ymax = _parent._parent.g_ground + 10;
  120. flameDebrisTimer = 0;
  121. _rotation = random(360);
  122. xmax = _parent._parent.g_width + 50;
  123. xmin = -50;
  124. ymin = -50;
  125. ymax = _parent._parent.g_ground + 50;
  126. boundaryTimer = 50;
  127. var m_flightTime = 0;
  128.