home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / sinta.swf / scripts / Lustra.as < prev    next >
Encoding:
Text File  |  2008-08-08  |  4.8 KB  |  202 lines

  1. package
  2. {
  3.    import flash.display.*;
  4.    import flash.events.*;
  5.    import flash.text.*;
  6.    
  7.    [Embed(source="/_assets/assets.swf", symbol="Lustra")]
  8.    public class Lustra extends MovieClip
  9.    {
  10.        
  11.       
  12.       public var startX:Number;
  13.       
  14.       public var startY:Number;
  15.       
  16.       public var damageType:int;
  17.       
  18.       public var gravity:Number;
  19.       
  20.       public var blocktype:int;
  21.       
  22.       public var health:int;
  23.       
  24.       public var damage:int;
  25.       
  26.       public var falling:Boolean;
  27.       
  28.       public var dy:Number;
  29.       
  30.       public var hit:Boolean;
  31.       
  32.       public var hitbithurt:*;
  33.       
  34.       public var dx:Number;
  35.       
  36.       public var alive:Boolean;
  37.       
  38.       public var hitbitbite:*;
  39.       
  40.       public var game:PlatformGame;
  41.       
  42.       public function Lustra(param1:PlatformGame)
  43.       {
  44.          super();
  45.          addFrameScript(73,frame74,87,frame88,312,frame313);
  46.          game = param1;
  47.          gravity = 0.03;
  48.          damage = 101;
  49.          damageType = 2;
  50.          dy = 0;
  51.          init();
  52.       }
  53.       
  54.       internal function frame313() : *
  55.       {
  56.          regen();
  57.          stop();
  58.       }
  59.       
  60.       public function smash() : *
  61.       {
  62.          if(alive)
  63.          {
  64.             alive = false;
  65.             gotoAndPlay("smash");
  66.          }
  67.       }
  68.       
  69.       public function init() : *
  70.       {
  71.          falling = false;
  72.          hit = false;
  73.          alive = true;
  74.          dy = 0;
  75.          health = 60;
  76.       }
  77.       
  78.       internal function frame74() : *
  79.       {
  80.          stop();
  81.       }
  82.       
  83.       internal function frame88() : *
  84.       {
  85.          checkDead();
  86.          gotoAndStop("start");
  87.       }
  88.       
  89.       public function regen() : *
  90.       {
  91.          gotoAndPlay(1);
  92.          x = startX;
  93.          y = startY;
  94.          init();
  95.       }
  96.       
  97.       public function fall() : *
  98.       {
  99.          falling = true;
  100.       }
  101.       
  102.       public function checkDead() : *
  103.       {
  104.          if(health == 0)
  105.          {
  106.             fall();
  107.          }
  108.       }
  109.       
  110.       public function update(param1:Number) : *
  111.       {
  112.          var _loc2_:int = 0;
  113.          var _loc3_:* = undefined;
  114.          if(falling)
  115.          {
  116.             if(!hit)
  117.             {
  118.                dy += gravity * param1;
  119.             }
  120.             y += dy;
  121.          }
  122.          if(falling)
  123.          {
  124.             _loc2_ = 0;
  125.             while(_loc2_ < game.enemies.length)
  126.             {
  127.                if(game.enemies[_loc2_].monsterType != 28)
  128.                {
  129.                   if(Boolean(game.enemies[_loc2_].inner.hitbithurt.hitTestObject(hitbitbite)) && Boolean(game.enemies[_loc2_].alive))
  130.                   {
  131.                      if(!hit)
  132.                      {
  133.                         game.enemies[_loc2_].takeDamage(damage);
  134.                      }
  135.                      smash();
  136.                      hit = true;
  137.                      break;
  138.                   }
  139.                }
  140.                else if(Boolean(game.enemies[_loc2_].inner.movewiz.hitbithurt.hitTestObject(hitbitbite)) && Boolean(game.enemies[_loc2_].alive))
  141.                {
  142.                   if(!hit)
  143.                   {
  144.                      game.sounds.wizardhit.play();
  145.                      game.enemies[_loc2_].takeDamage(damage);
  146.                   }
  147.                   hit = true;
  148.                   smash();
  149.                   break;
  150.                }
  151.                _loc2_++;
  152.             }
  153.             if(!hit && game.hero.alive && game.hero.mc.hitTestObject(hitbitbite))
  154.             {
  155.                game.hero.takeDamage(damage,damageType,0,x);
  156.                hit = true;
  157.                smash();
  158.             }
  159.             _loc2_ = 0;
  160.             while(_loc2_ < game.fixedObjects.length)
  161.             {
  162.                _loc3_ = game.fixedObjects[_loc2_];
  163.                if(_loc3_.blocktype < 11)
  164.                {
  165.                   if(x + 80 > _loc3_.leftside && x < _loc3_.rightside)
  166.                   {
  167.                      if(y + 85 > _loc3_.topside)
  168.                      {
  169.                         hit = true;
  170.                         y = _loc3_.topside - 85;
  171.                         dy = 0;
  172.                         smash();
  173.                         break;
  174.                      }
  175.                   }
  176.                }
  177.                _loc2_++;
  178.             }
  179.             if(x > 700 || x < -20 || y > 440 - height)
  180.             {
  181.                hit = true;
  182.                dy = 0;
  183.                smash();
  184.             }
  185.          }
  186.       }
  187.       
  188.       public function takeDamage(param1:*) : *
  189.       {
  190.          if(!hit)
  191.          {
  192.             health -= param1;
  193.             if(health < 0)
  194.             {
  195.                health = 0;
  196.             }
  197.             gotoAndPlay("hit");
  198.          }
  199.       }
  200.    }
  201. }
  202.