home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / RadioactiveSnakesFromMa.swf / scripts / DefineSprite_211 / frame_36 / DoAction.as
Encoding:
Text File  |  2006-06-20  |  11.2 KB  |  323 lines

  1. if(loop == 2)
  2. {
  3.    loop = 0;
  4. }
  5. _parent.pause.gotoAndStop(1);
  6. loop++;
  7. _root.clock = 1;
  8. dead = 0;
  9. if(_root.readygo.tune == "music1" or _root.readygo.tune == "music2")
  10. {
  11.    ltune = "music";
  12. }
  13. else
  14. {
  15.    ltune = _root.readygo.tune;
  16. }
  17. ltune2 = ltune;
  18. ltune = "music";
  19. player = 1;
  20. while(player <= _root.players)
  21. {
  22.    if(_root.player[player].speed > 0)
  23.    {
  24.       if(_root.player[player].life < 240)
  25.       {
  26.          ltune = "musicfast";
  27.       }
  28.       else if(_root.player[player].speed > 4 and ltune != "musicfast")
  29.       {
  30.          ltune = "musicfaster";
  31.       }
  32.       if(loop == 2)
  33.       {
  34.          if(player == _root.thisUser)
  35.          {
  36.             if(Key.isDown(37) and _root.player[player].inverted != 1 or Key.isDown(39) and _root.player[player].inverted == 1)
  37.             {
  38.                _root.player[_root.thisUser].ball[1].dir--;
  39.                if(_root.player[_root.thisUser].ball[1].dir < 0)
  40.                {
  41.                   _root.player[_root.thisUser].ball[1].dir = 11;
  42.                }
  43.             }
  44.             else if(Key.isDown(39) and _root.player[player].inverted != 1 or Key.isDown(37) and _root.player[player].inverted == 1)
  45.             {
  46.                _root.player[_root.thisUser].ball[1].dir = _root.player[_root.thisUser].ball[1].dir + 1;
  47.                if(_root.player[_root.thisUser].ball[1].dir > 11)
  48.                {
  49.                   _root.player[_root.thisUser].ball[1].dir = 0;
  50.                }
  51.             }
  52.          }
  53.          else if(player == _root.nextUser)
  54.          {
  55.             if(Key.isDown(65) and _root.player[player].inverted != 1 or Key.isDown(83) and _root.player[player].inverted == 1)
  56.             {
  57.                _root.player[_root.nextUser].ball[1].dir--;
  58.                if(_root.player[_root.nextUser].ball[1].dir < 0)
  59.                {
  60.                   _root.player[_root.nextUser].ball[1].dir = 11;
  61.                }
  62.             }
  63.             else if(Key.isDown(83) and _root.player[player].inverted != 1 or Key.isDown(65) and _root.player[player].inverted == 1)
  64.             {
  65.                _root.player[_root.nextUser].ball[1].dir = _root.player[_root.nextUser].ball[1].dir + 1;
  66.                if(_root.player[_root.nextUser].ball[1].dir > 11)
  67.                {
  68.                   _root.player[_root.nextUser].ball[1].dir = 0;
  69.                }
  70.             }
  71.          }
  72.          else if(wait < 45)
  73.          {
  74.             wait++;
  75.          }
  76.          else
  77.          {
  78.             _root.player[player].ball[1].dir--;
  79.             if(_root.player[player].ball[1].dir < 0)
  80.             {
  81.                _root.player[player].ball[1].dir = 11;
  82.             }
  83.             wait -= 3;
  84.          }
  85.       }
  86.       i = 1;
  87.       while(i < _root.player[player].ball.length)
  88.       {
  89.          hp = 1;
  90.          while(hp <= _root.players)
  91.          {
  92.             if(hp != player or i > 2)
  93.             {
  94.                if(_root.player[hp].speed > 0)
  95.                {
  96.                   xxd = _root.player[player].ball[i].x - _root.player[hp].ball[1].x;
  97.                   xxd *= xxd;
  98.                   if(xxd <= 196)
  99.                   {
  100.                      yyd = _root.player[player].ball[i].y - _root.player[hp].ball[1].y;
  101.                      yyd *= yyd;
  102.                      if(yyd <= 196)
  103.                      {
  104.                         xyd = Math.sqrt(yyd + xxd);
  105.                         if(xyd <= 15)
  106.                         {
  107.                            _root.player[hp].speed = 0;
  108.                            if(i == 1)
  109.                            {
  110.                               _root.player[player].speed = 0;
  111.                            }
  112.                         }
  113.                      }
  114.                   }
  115.                }
  116.             }
  117.             hp++;
  118.          }
  119.          if(i == 1 and _root.player[player].speed > 0)
  120.          {
  121.             w = 0;
  122.             while(w < _root.wall.length)
  123.             {
  124.                if(_root.player[player].ball[i].x + 12 > _root.wall[w].x and _root.player[player].ball[i].x - 12 < _root.wall[w].x + _root.wall[w].w)
  125.                {
  126.                   if(_root.wall[w].ym == 2 and _root.player[player].ball[i].y + 12 > _root.wall[w].y and _root.player[player].ball[i].y - 12 < _root.wall[w].y + _root.wall[w].h)
  127.                   {
  128.                      _root.player[player].speed = 0;
  129.                   }
  130.                   else if(_root.wall[w].ym < 0 and _root.player[player].ball[i].y - 12 < _root.wall[w].y and _root.player[player].ball[i].y + 12 > _root.wall[w].y - _root.wall[w].h)
  131.                   {
  132.                      xds = _root.player[player].ball[i].x - _root.wall[w].x;
  133.                      xpr = xds / _root.wall[w].w;
  134.                      yds = _root.wall[w].y - _root.wall[w].h * xpr;
  135.                      if(_root.player[player].ball[i].y + 12 > yds and _root.player[player].ball[i].y - 12 < yds)
  136.                      {
  137.                         _root.player[player].speed = 0;
  138.                      }
  139.                   }
  140.                   else if(_root.wall[w].ym > 0 and _root.player[player].ball[i].y + 12 > _root.wall[w].y and _root.player[player].ball[i].y - 12 < _root.wall[w].y + _root.wall[w].h)
  141.                   {
  142.                      xds = _root.player[player].ball[i].x - _root.wall[w].x;
  143.                      xpr = xds / _root.wall[w].w;
  144.                      yds = _root.wall[w].y + _root.wall[w].h * xpr;
  145.                      if(_root.player[player].ball[i].y + 12 > yds and _root.player[player].ball[i].y - 12 < yds)
  146.                      {
  147.                         _root.player[player].speed = 0;
  148.                      }
  149.                   }
  150.                   else if(_root.player[player].ball[i].y + 12 > _root.wall[w].y and _root.player[player].ball[i].y - 12 < _root.wall[w].y)
  151.                   {
  152.                      _root.player[player].speed = 0;
  153.                   }
  154.                }
  155.                w++;
  156.             }
  157.             if(_root.player[player].ball[i].x < 22)
  158.             {
  159.                _root.player[player].speed = 0;
  160.             }
  161.             else if(_root.player[player].ball[i].x > 618)
  162.             {
  163.                _root.player[player].speed = 0;
  164.             }
  165.             else if(_root.player[player].ball[i].y < 54)
  166.             {
  167.                _root.player[player].speed = 0;
  168.             }
  169.             else if(_root.player[player].ball[i].y > 458)
  170.             {
  171.                _root.player[player].speed = 0;
  172.             }
  173.          }
  174.          if(i == 1)
  175.          {
  176.             ball = 1;
  177.          }
  178.          else if(i == _root.player[player].ball.length - 1)
  179.          {
  180.             ball = 3;
  181.          }
  182.          else
  183.          {
  184.             ball = 2;
  185.          }
  186.          this[_root.player[player].ball[i].clip].gotoAndStop(ball);
  187.          s = 0;
  188.          while(s < _root.player[player].speed)
  189.          {
  190.             if(i == 1)
  191.             {
  192.                if(_root.player[player].oldspeed != _root.player[player].speed or _root.player[player].olddir != _root.player[player].ball[i].dir)
  193.                {
  194.                   _root.player[player].ball[i].speed = _root.player[player].speed;
  195.                   _root.player[player].ball[i + 1].step.push({x:_root.player[player].ball[i].x,y:_root.player[player].ball[i].y,dir:_root.player[player].ball[i].dir,speed:_root.player[player].ball[i].speed});
  196.                }
  197.                _root.player[player].oldspeed = _root.player[player].speed;
  198.                _root.player[player].olddir = _root.player[player].ball[i].dir;
  199.             }
  200.             else if(_root.player[player].ball[i].x == _root.player[player].ball[i].step[0].x and _root.player[player].ball[i].y == _root.player[player].ball[i].step[0].y)
  201.             {
  202.                _root.player[player].ball[i].dir = _root.player[player].ball[i].step[0].dir;
  203.                _root.player[player].ball[i].speed = _root.player[player].ball[i].step[0].speed;
  204.                _root.player[player].ball[i].step.shift();
  205.                _root.player[player].ball[i + 1].step.push({x:_root.player[player].ball[i].x,y:_root.player[player].ball[i].y,dir:_root.player[player].ball[i].dir,speed:_root.player[player].ball[i].speed});
  206.             }
  207.             if(_root.player[player].ball[i].dir == 0)
  208.             {
  209.                xm = 0;
  210.                ym = 4;
  211.             }
  212.             else if(_root.player[player].ball[i].dir == 1)
  213.             {
  214.                xm = -2;
  215.                ym = 3.5;
  216.             }
  217.             else if(_root.player[player].ball[i].dir == 2)
  218.             {
  219.                xm = -3.5;
  220.                ym = 2;
  221.             }
  222.             else if(_root.player[player].ball[i].dir == 3)
  223.             {
  224.                xm = -4;
  225.                ym = 0;
  226.             }
  227.             else if(_root.player[player].ball[i].dir == 4)
  228.             {
  229.                xm = -3.5;
  230.                ym = -2;
  231.             }
  232.             else if(_root.player[player].ball[i].dir == 5)
  233.             {
  234.                xm = -2;
  235.                ym = -3.5;
  236.             }
  237.             else if(_root.player[player].ball[i].dir == 6)
  238.             {
  239.                xm = 0;
  240.                ym = -4;
  241.             }
  242.             else if(_root.player[player].ball[i].dir == 7)
  243.             {
  244.                xm = 2;
  245.                ym = -3.5;
  246.             }
  247.             else if(_root.player[player].ball[i].dir == 8)
  248.             {
  249.                xm = 3.5;
  250.                ym = -2;
  251.             }
  252.             else if(_root.player[player].ball[i].dir == 9)
  253.             {
  254.                xm = 4;
  255.                ym = 0;
  256.             }
  257.             else if(_root.player[player].ball[i].dir == 10)
  258.             {
  259.                xm = 3.5;
  260.                ym = 2;
  261.             }
  262.             else if(_root.player[player].ball[i].dir == 11)
  263.             {
  264.                xm = 2;
  265.                ym = 3.5;
  266.             }
  267.             if(_root.player[player].ball[i].delay > 0)
  268.             {
  269.                _root.player[player].ball[i].delay -= 2;
  270.             }
  271.             else
  272.             {
  273.                _root.player[player].ball[i].y += ym / 4 * 2;
  274.                _root.player[player].ball[i].x += xm / 4 * 2;
  275.             }
  276.             s += 2;
  277.          }
  278.          this[_root.player[player].ball[i].clip]._x = _root.player[player].ball[i].x;
  279.          this[_root.player[player].ball[i].clip]._y = _root.player[player].ball[i].y;
  280.          this[_root.player[player].ball[i].clip]._rotation = _root.player[player].ball[i].dir * 30;
  281.          i++;
  282.       }
  283.    }
  284.    else if(_root.player[player].ball.length > 0)
  285.    {
  286.       this[_root.player[player].ball[1].clip].gotoAndStop(4);
  287.       removeMovieClip(_root.player[player].ball[0].clip);
  288.       _root.player[player].ball.shift();
  289.       if(_root.players > 1)
  290.       {
  291.          _root.player[player].vspoints = -1;
  292.       }
  293.       if(playdead != 1)
  294.       {
  295.          _root.readygo.gotoAndPlay("dead");
  296.          playdead = 1;
  297.       }
  298.    }
  299.    else
  300.    {
  301.       _root.player[player].lives--;
  302.       if(_root.players > 1)
  303.       {
  304.          _root.level = _root.level + 1;
  305.       }
  306.       _root.clock = 0;
  307.       stop();
  308.    }
  309.    player++;
  310. }
  311. if(ltune != ltune2)
  312. {
  313.    if(ltune == "music")
  314.    {
  315.       ltune = "music1";
  316.    }
  317.    _root.readygo.tune = ltune;
  318.    _root.readygo.Music.stop();
  319.    _root.readygo.Music.attachSound(ltune);
  320.    _root.readygo.Music.start();
  321. }
  322. _root.txt = orbs - onorb + " pills remaining";
  323.