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

  1. function updateStickies(sticky)
  2. {
  3.    if(++m_stickyNdx >= m_maxStickies)
  4.    {
  5.       m_stickyNdx = 0;
  6.    }
  7.    var _loc1_ = m_stickies[m_stickyNdx];
  8.    _loc1_.unloadMovie();
  9.    m_stickies[m_stickyNdx] = sticky;
  10. }
  11. function step()
  12. {
  13.    if(hp_bar._alpha > 0)
  14.    {
  15.       hp_bar._alpha -= 5;
  16.    }
  17.    if(isDead())
  18.    {
  19.       vy += 0.08;
  20.       _rotation = _rotation - 0.2;
  21.    }
  22.    else
  23.    {
  24.       updateCannon();
  25.    }
  26.    updatePosition();
  27.    if(_X < goal_xspot && !isDead())
  28.    {
  29.       vx = 0;
  30.    }
  31.    if(_Y > _parent._parent.g_ground + 100)
  32.    {
  33.       destroy();
  34.    }
  35.    if(_X < -50)
  36.    {
  37.       destroy();
  38.    }
  39. }
  40. function updateCannon()
  41. {
  42.    if(shootTimer-- < 0)
  43.    {
  44.       shootTimer = 300;
  45.       _parent._parent.shootAtDragonProjectile(_X,_Y,2,"proj_enemy_ice");
  46.    }
  47. }
  48. function updatePosition()
  49. {
  50.    _X = _X + vx;
  51.    _Y = _Y + vy;
  52. }
  53. function takeDamage(amt, xp, yp)
  54. {
  55.    if(hp > 0)
  56.    {
  57.       hp -= amt;
  58.       if(hp <= 0)
  59.       {
  60.          hp = 0;
  61.          _parent._parent.addScore(200,_X,_Y);
  62.          if(random(6) == 0)
  63.          {
  64.             var _loc3_ = _parent._parent.addObj("ammo_box_heal",_parent._parent.ammo_layer,_parent._parent.getNextAmmoLevel());
  65.             _loc3_._x = _X;
  66.             _loc3_._y = _Y;
  67.          }
  68.       }
  69.       else
  70.       {
  71.          hp_bar.bar._width = hp / max_hp * 100;
  72.          hp_bar._alpha = 100;
  73.       }
  74.       if(_parent._parent.g_dmg_text_on)
  75.       {
  76.          var _loc2_ = _parent._parent.addObj("dmg_text",_parent._parent.score_layer,_parent._parent.getNextScoreLevel());
  77.          _loc2_._x = xp;
  78.          _loc2_._y = yp;
  79.          _loc2_.val = amt;
  80.       }
  81.    }
  82. }
  83. function isDead()
  84. {
  85.    return hp == 0;
  86. }
  87. function setHP(num)
  88. {
  89.    hp = num;
  90. }
  91. function destroy()
  92. {
  93.    _parent._parent.removeEnemy(this);
  94. }
  95. function slowShooting(amt)
  96. {
  97.    shootTimer += amt;
  98.    if(shootTimer > 500)
  99.    {
  100.       shootTimer = 500;
  101.    }
  102. }
  103. vx = -0.8;
  104. vy = 0;
  105. max_hp = Math.floor(10 * (1 + _parent._parent.g_level / 100));
  106. hp = max_hp;
  107. shootTimer = 300;
  108. etype = "dragon_scout";
  109. var m_maxStickies = 3;
  110. var m_stickies = new Array(m_maxStickies);
  111. var m_stickyNdx = 0;
  112.