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

  1. function Do_Bowling_Shoot()
  2. {
  3.    var i = _root.Objs.create("LaserClass",56,0,this.Obj_X,this.Obj_Y - 1048576,null);
  4.    i.Obj_Flip = this.Obj_Flip;
  5.    _root.snd.attachSound("LV_169");
  6.    _root.snd.start();
  7. }
  8. function Do_Bowling_Stuff()
  9. {
  10.    this.Obj_Climb = this.Obj_Climb + 1;
  11.    if(_root.Arrow)
  12.    {
  13.       if(!(_root.Arrow.Obj_Flags & 0x40))
  14.       {
  15.          if(Bowling_Collide0(_root.Arrow))
  16.          {
  17.             _root.Arrow.Obj_Flags |= 64;
  18.             this.Obj_Flags |= 64;
  19.             this._visible = 0;
  20.             _root.Objs.create("BowlingDeathClass",32,0,this.Obj_X,this.Obj_Y,null);
  21.          }
  22.       }
  23.    }
  24.    switch(this.Obj_Climb & 3)
  25.    {
  26.       case 0:
  27.          if(_root.Runner.Obj_Flags & 0x20)
  28.          {
  29.             if(Bowling_Collide1(_root.Runner))
  30.             {
  31.                _runner.Obj_Flags &= 65535 - 32;
  32.                if(this.Obj_Flip > 0)
  33.                {
  34.                   _root.Runner.CX_Obj_Collide |= 1;
  35.                }
  36.                else
  37.                {
  38.                   _root.Runner.CX_Obj_Collide |= 2;
  39.                }
  40.                _root.snd.attachSound("LV_185");
  41.                _root.snd.start();
  42.                this.Obj_Flags |= 64;
  43.                this._visible = 0;
  44.                _root.Objs.create("BowlingDeathClass",32,0,this.Obj_X,this.Obj_Y,null);
  45.             }
  46.          }
  47.          break;
  48.       case 1:
  49.          if(Bowling_Collide1(_root.Fighter))
  50.          {
  51.             if(_root.Fighter.Obj_Flags & 2)
  52.             {
  53.                _root.Fighter.Obj_Flags &= 255 - 2;
  54.                this.Obj_Flags |= 64;
  55.                this._visible = 0;
  56.                _root.Objs.create("BowlingDeathClass",32,0,this.Obj_X,this.Obj_Y,null);
  57.             }
  58.          }
  59.          break;
  60.       case 2:
  61.          break;
  62.       case 3:
  63.          if(this.Obj_Timer)
  64.          {
  65.             this.Obj_Timer--;
  66.          }
  67.          if(this.Obj_Timer == 0)
  68.          {
  69.             if(!(_root.Shield.Obj_Flags & 4))
  70.             {
  71.                Bowling_Collide2(_root.Shield);
  72.             }
  73.             if(!(_root.Runner.Obj_Flags & 4))
  74.             {
  75.                Bowling_Collide2(_root.Runner);
  76.             }
  77.             if(!(_root.Fighter.Obj_Flags & 4))
  78.             {
  79.                Bowling_Collide2(_root.Fighter);
  80.             }
  81.          }
  82.    }
  83. }
  84. function Bowling_Collide0(target)
  85. {
  86.    if(target.CX2 < this.CX1 || target.CX1 > this.CX2 || target.CY2 < this.CY1 || target.CY1 > this.CY2)
  87.    {
  88.       return 0;
  89.    }
  90.    return 1;
  91. }
  92. function Bowling_Collide1(target)
  93. {
  94.    if(target.Obj_Flip < 0)
  95.    {
  96.       if(target.CX2 + 8 < this.CX1 || target.CX1 - 16 > this.CX2 || target.CY2 < this.CY1 || target.CY1 > this.CY2)
  97.       {
  98.          return 0;
  99.       }
  100.    }
  101.    else if(target.CX2 + 16 < this.CX1 || target.CX1 - 8 > this.CX2 || target.CY2 < this.CY1 || target.CY1 > this.CY2)
  102.    {
  103.       return 0;
  104.    }
  105.    return 1;
  106. }
  107. function Bowling_Collide2(target)
  108. {
  109.    if(target.CX2 + 128 < this.CX1 || target.CX1 - 128 > this.CX2 || target.CY2 < this.CY1 || target.CY1 > this.CY2)
  110.    {
  111.       return 0;
  112.    }
  113.    if(target.Obj_X < this.Obj_X)
  114.    {
  115.       this.Obj_Flip = -1;
  116.       this.gotoAndPlay("Bowling_Shoot");
  117.    }
  118.    else
  119.    {
  120.       this.Obj_Flip = 1;
  121.       this.gotoAndPlay("Bowling_Shoot");
  122.    }
  123.    return 1;
  124. }
  125. function Bowling_Collide3(target)
  126. {
  127.    if(target.Obj_Flip < 0)
  128.    {
  129.       if(target.CX2 + 16 < this.CX1 || target.CX1 - 24 > this.CX2 || target.CY2 < this.CY1 || target.CY1 > this.CY2)
  130.       {
  131.          return 0;
  132.       }
  133.    }
  134.    else if(target.CX2 + 24 < this.CX1 || target.CX1 - 16 > this.CX2 || target.CY2 < this.CY1 || target.CY1 > this.CY2)
  135.    {
  136.       return 0;
  137.    }
  138.    return 1;
  139. }
  140. function Bowling_Walk()
  141. {
  142.    var x;
  143.    var y0;
  144.    var y1;
  145.    var x1;
  146.    var y2;
  147.    if(this.Obj_Flags & 0x40)
  148.    {
  149.       return undefined;
  150.    }
  151.    if(this.CX_Obj_Collide & 3)
  152.    {
  153.       this.Obj_DX *= -1;
  154.       this.CX_Obj_Collide = 0;
  155.    }
  156.    if(!(_root.Shield.Obj_Flags & 4))
  157.    {
  158.       if(!Bowling_Collide3(_root.Shield))
  159.       {
  160.          this.Obj_X += this.Obj_DX;
  161.       }
  162.    }
  163.    x1 = this.Obj_X >> 16;
  164.    y2 = this.Obj_Y >> 16;
  165.    y0 = y2 + 1 & 4294967288;
  166.    y1 = y2 + 0 & 4294967288;
  167.    if(this.Obj_DX < 0)
  168.    {
  169.       this.Obj_Flip = -1;
  170.       x = x1 - 1 & 4294967288;
  171.       if(!_root.Collide_DN_Tabl[_root.CMapArray[y0 / 8 * 102 + (x & 4294967288) / 8]])
  172.       {
  173.          this.Obj_DX *= -1;
  174.       }
  175.       if(_root.Collide_DN_Tabl[_root.CMapArray[y1 / 8 * 102 + (x & 4294967288) / 8]])
  176.       {
  177.          this.Obj_DX *= -1;
  178.       }
  179.    }
  180.    else
  181.    {
  182.       this.Obj_Flip = 1;
  183.       x = x1 + 1 & 4294967288;
  184.       if(!_root.Collide_DN_Tabl[_root.CMapArray[y0 / 8 * 102 + (x & 4294967288) / 8]])
  185.       {
  186.          this.Obj_DX *= -1;
  187.       }
  188.       if(_root.Collide_DN_Tabl[_root.CMapArray[y1 / 8 * 102 + (x & 4294967288) / 8]])
  189.       {
  190.          this.Obj_DX *= -1;
  191.       }
  192.    }
  193.    this.CX1 = (this.Obj_X >> 16) + this.Obj_X1;
  194.    this.CX2 = (this.Obj_X >> 16) + this.Obj_X2;
  195.    this.CY1 = (this.Obj_Y >> 16) + this.Obj_Y1;
  196.    this.CY2 = (this.Obj_Y >> 16) + this.Obj_Y2;
  197.    this.updateCacheX();
  198.    Do_Bowling_Stuff();
  199. }
  200. function Bowling_Shoot()
  201. {
  202.    Do_Bowling_Stuff();
  203. }
  204. this.gotoAndPlay("Bowling_Walk");
  205. _root.KEY_LT = 37;
  206. _root.KEY_RT = 39;
  207. _root.KEY_UP = 38;
  208. _root.KEY_DN = 40;
  209. _root.KEY_A = 65;
  210. _root.KEY_B = 83;
  211. _root.KEY_LB = 81;
  212. _root.KEY_RB = 87;
  213. _root.KEY_CHEAT = 17;
  214. _root.Obj_Flags_ALWAYSRUN = 384;
  215. _root.Obj_Flags_BACKGROUND = 256;
  216. _root.Obj_Flags_MICKEY = 128;
  217. _root.Obj_Flags_DEAD = 64;
  218. _root.Obj_Flags_SPECIAL = 32;
  219. _root.Obj_Flags_KILL = 16;
  220. _root.Obj_Flags_KEYBD = 8;
  221. _root.Obj_Flags_GONE = 4;
  222. _root.Obj_Flags_ATTACK = 2;
  223. _root.Obj_Flags_CLIMBING = 1;
  224. this.Obj_X1 = -5;
  225. this.Obj_X2 = 5;
  226. this.Obj_Y1 = -31;
  227. this.Obj_Y2 = 0;
  228. this.Obj_DX = -131072;
  229. this.Obj_Timer = 15;
  230.