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

  1. function setVelocity(xdelta, ydelta)
  2. {
  3.    vx = xdelta;
  4.    vy = ydelta;
  5. }
  6. function step()
  7. {
  8.    vy += _parent._parent.g_grav;
  9.    _Y = _Y + vy;
  10.    _X = _X + vx;
  11.    radians = Math.atan(vy / vx);
  12.    if(vx > 0)
  13.    {
  14.       _rotation = radians * 180 / 3.14159;
  15.    }
  16.    else
  17.    {
  18.       _rotation = radians * 180 / 3.14159 + 180;
  19.    }
  20.    if(vx < 0.00001 && vx > -0.00001)
  21.    {
  22.       _rotation = _rotation + 180;
  23.    }
  24.    if(boundaryTimer-- < 0)
  25.    {
  26.       boundaryTimer = 25;
  27.       if(_X < xmin || _X > xmax || _Y > ymax)
  28.       {
  29.          this.unloadMovie();
  30.       }
  31.    }
  32.    if(flameDebrisTimer-- < 0)
  33.    {
  34.       flameDebrisTimer = 0;
  35.       var _loc3_ = _parent._parent.addObj("snot_glob",_parent._parent.debris_layer,_parent._parent.getNextDebrisLevel());
  36.       _loc3_._x = _X;
  37.       _loc3_._y = _Y;
  38.       _loc3_._rotation = _rotation;
  39.       _loc3_._xscale = _loc3_._yscale = 30 + rank * 20;
  40.       _loc3_.decayRate = 6;
  41.    }
  42.    if(hitTimer-- < 0)
  43.    {
  44.       testHitEnemies();
  45.    }
  46. }
  47. function testHitEnemies()
  48. {
  49.    var _loc4_ = undefined;
  50.    var _loc5_ = false;
  51.    var _loc3_ = 0;
  52.    while(_loc3_ < _parent._parent.enemies.length && !_loc5_)
  53.    {
  54.       _loc4_ = _parent._parent.enemies[_loc3_];
  55.       if(_loc4_.hitBox.hitTest(_X,_Y,0))
  56.       {
  57.          _loc5_ = true;
  58.          break;
  59.       }
  60.       _loc3_ = _loc3_ + 1;
  61.    }
  62.    if(_loc5_)
  63.    {
  64.       _parent._parent.playSound("blood_splat.wav");
  65.       if(_loc4_.etype == "air_ship")
  66.       {
  67.          _loc4_.testHitTroops(this);
  68.       }
  69.       if(_loc4_.etype != "snot")
  70.       {
  71.          _parent._parent.addSticky("sticky_snot",_loc4_,_X,_Y,20 + rank * 20);
  72.          _loc4_.takeDamage(Math.ceil(rank / 2),_X,_Y);
  73.       }
  74.       else
  75.       {
  76.          _loc4_.takeDamage(0,_X,_Y);
  77.       }
  78.       this.unloadMovie();
  79.    }
  80. }
  81. xmax = _parent._parent.g_width + 10;
  82. ymax = _parent._parent.g_ground + 10;
  83. flameDebrisTimer = 0;
  84. _rotation = random(360);
  85. xmax = _parent._parent.g_width + 50;
  86. xmin = -50;
  87. ymin = -50;
  88. ymax = _parent._parent.g_ground + 50;
  89. hitTimer = 50;
  90. boundaryTimer = 50;
  91.