home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Aventura / the_lost_vikings.swf / scripts / DefineSprite_576_LaserClass / frame_1 / DoAction.as
Encoding:
Text File  |  2007-03-20  |  2.8 KB  |  124 lines

  1. function Laser_Collide0(target)
  2. {
  3.    if(target.Obj_Flags & 0x40)
  4.    {
  5.       return 0;
  6.    }
  7.    if(target.CX2 < this.CX1 || target.CX1 > this.CX2 || target.CY2 < this.CY1 || target.CY1 > this.CY2)
  8.    {
  9.       return 0;
  10.    }
  11.    return 1;
  12. }
  13. function Laser_Collide1()
  14. {
  15.    var i;
  16.    var y;
  17.    var x1;
  18.    var x2;
  19.    x1 = (this.Obj_X >> 16) + this.Obj_X1 & 4294967288;
  20.    x2 = (this.Obj_X >> 16) + this.Obj_X2 & 4294967288;
  21.    y = this.Obj_Y >> 16 & 4294967288;
  22.    if(this.Obj_Flip < 0)
  23.    {
  24.       i = y / 8 * 102 + x1 / 8;
  25.    }
  26.    else
  27.    {
  28.       i = y / 8 * 102 + x2 / 8;
  29.    }
  30.    if(_root.CMapArray[i] == 1)
  31.    {
  32.       return 1;
  33.    }
  34.    return 0;
  35. }
  36. function Laser_Shoot_Collide()
  37. {
  38.    if(!(_root.Shield.Obj_Flags & 4))
  39.    {
  40.       if(Laser_Collide0(_root.Shield))
  41.       {
  42.          if(_root.Shield.Obj_Shield_Up || this.Obj_Flip == _root.Shield.Obj_Flip)
  43.          {
  44.             _root.snd.attachSound("LV_226");
  45.             _root.snd.start();
  46.             _root.Shield.Obj_DX = 131072 * this.Obj_Flip;
  47.             _root.Shield.setHndlr(1,0);
  48.             _root.Shield.gotoAndPlay("Shield_Hit");
  49.          }
  50.          return 1;
  51.       }
  52.    }
  53.    if(!(_root.Fighter.Obj_Flags & 4))
  54.    {
  55.       if(Laser_Collide0(_root.Fighter))
  56.       {
  57.          _root.snd.attachSound("LV_226");
  58.          _root.snd.start();
  59.          _root.Fighter.Obj_DX = 131072 * this.Obj_Flip;
  60.          _root.Fighter.setHndlr(1,0);
  61.          _root.Fighter.gotoAndPlay("Fighter_Hit");
  62.          return 1;
  63.       }
  64.    }
  65.    if(!(_root.Runner.Obj_Flags & 4))
  66.    {
  67.       if(Laser_Collide0(_root.Runner))
  68.       {
  69.          _root.snd.attachSound("LV_226");
  70.          _root.snd.start();
  71.          _root.Runner.Obj_DX = 131072 * this.Obj_Flip;
  72.          _root.Runner.setHndlr(1,0);
  73.          _root.Runner.gotoAndPlay("Runner_Hit");
  74.          return 1;
  75.       }
  76.    }
  77.    if(Laser_Collide1())
  78.    {
  79.       return 1;
  80.    }
  81.    return 0;
  82. }
  83. function Laser_Loop()
  84. {
  85.    this.Obj_X += 524288 * this.Obj_Flip;
  86.    this.Obj_Timer--;
  87.    this.cacheCX();
  88.    this.updateCache();
  89.    if(this.Obj_Timer == 0)
  90.    {
  91.       this.kill();
  92.    }
  93.    if(Laser_Shoot_Collide())
  94.    {
  95.       this.kill();
  96.    }
  97. }
  98. this.setHndlr(1,this.Laser_Loop);
  99. this.gotoAndPlay("Laser_Loop");
  100. _root.KEY_LT = 37;
  101. _root.KEY_RT = 39;
  102. _root.KEY_UP = 38;
  103. _root.KEY_DN = 40;
  104. _root.KEY_A = 65;
  105. _root.KEY_B = 83;
  106. _root.KEY_LB = 81;
  107. _root.KEY_RB = 87;
  108. _root.KEY_CHEAT = 17;
  109. _root.Obj_Flags_ALWAYSRUN = 384;
  110. _root.Obj_Flags_BACKGROUND = 256;
  111. _root.Obj_Flags_MICKEY = 128;
  112. _root.Obj_Flags_DEAD = 64;
  113. _root.Obj_Flags_SPECIAL = 32;
  114. _root.Obj_Flags_KILL = 16;
  115. _root.Obj_Flags_KEYBD = 8;
  116. _root.Obj_Flags_GONE = 4;
  117. _root.Obj_Flags_ATTACK = 2;
  118. _root.Obj_Flags_CLIMBING = 1;
  119. this.Obj_X1 = -10;
  120. this.Obj_X2 = 10;
  121. this.Obj_Y1 = -2;
  122. this.Obj_Y2 = 2;
  123. this.Obj_Timer = 32;
  124.