home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / sky-chopper.swf / scripts / frame_336 / DoAction.as < prev   
Encoding:
Text File  |  2005-09-29  |  34.8 KB  |  1,158 lines

  1. function startFTimer()
  2. {
  3.    startTime = new Date();
  4.    _root.startFTime = startTime.getTime();
  5.    _root.loopsFTimer = _root.loopsFTimer + 1;
  6. }
  7. function stopFTimer()
  8. {
  9.    endTime = new Date();
  10.    now = endTime.getTime();
  11.    _root.totalFTime += now - _root.startFTime;
  12. }
  13. function startFTimer2()
  14. {
  15.    startTime2 = new Date();
  16.    _root.startFTime2 = startTime2.getTime();
  17.    _root.loopsFTimer2 = _root.loopsFTimer2 + 1;
  18. }
  19. function stopFTimer2()
  20. {
  21.    endTime2 = new Date();
  22.    now2 = endTime2.getTime();
  23.    _root.totalFTime2 += now2 - _root.startFTime2;
  24. }
  25. function pauseGame()
  26. {
  27.    var _loc1_ = _root;
  28.    gamePaused = true;
  29.    _loc1_.ground.stop();
  30.    _loc1_.heli.stop();
  31.    _loc1_.heli.moveX = 0;
  32.    _loc1_.heli.moveY = 0;
  33. }
  34. function unpauseGame()
  35. {
  36.    gamePaused = false;
  37.    _root.ground.play();
  38.    _root.heli.play();
  39. }
  40. function updateHealthDisplay()
  41. {
  42.    var _loc1_ = _root;
  43.    var _loc3_ = 200;
  44.    var currentHitpoints = _loc1_.heli.hitPoints;
  45.    var _loc2_ = int(currentHitpoints / _loc3_ * 100);
  46.    if(_loc2_ <= 10)
  47.    {
  48.       if(!_loc1_.alarmplaying)
  49.       {
  50.          _loc1_.alarm_sound.start(0,999);
  51.          _loc1_.alarmplaying = true;
  52.       }
  53.       _loc1_.health._alpha = _loc1_.theFlicker2.flick._alpha;
  54.    }
  55.    else
  56.    {
  57.       _loc1_.health._alpha = 100;
  58.    }
  59.    _loc1_.health.gotoAndStop(_loc2_);
  60. }
  61. function goodieSpawn(posX, posY)
  62. {
  63.    var goodieArray = Array("goodie_shield","goodie_mines","goodie_guided_missiles","goodie_wingman","goodie_primary_upgrade","goodie_primary_upgrade","goodie_cash","goodie_nuke","goodie_health","goodie_unguided_missiles");
  64.    var pick = random(goodieArray.length);
  65.    chosenParent = eval(goodieArray[pick]);
  66.    var motime2 = new Date();
  67.    var checkBack = motime2.getTime();
  68.    lastSpawn = checkBack - spawnTime;
  69.    if(lastSpawn >= 3000)
  70.    {
  71.       currentGoodie = chosenParent.duplicateMovieClip("goodie_" + ++goodieCount,heli.o++);
  72.       currentGoodie._x = posX;
  73.       currentGoodie._y = posY;
  74.       _root.goodies.push(currentGoodie);
  75.       var motime = new Date();
  76.       spawnTime = motime.getTime();
  77.    }
  78. }
  79. function killAll()
  80. {
  81.    for(var checker in enemies)
  82.    {
  83.       var checkenemy = eval(enemies[checker]);
  84.       removeMovieClip(checkenemy);
  85.    }
  86.    var checker = 0;
  87.    while(checker <= mineCount)
  88.    {
  89.       var currentmine = eval("_root.mine_" + checker);
  90.       removeMovieClip(currentmine);
  91.       checker++;
  92.    }
  93.    for(var checker in wingmen)
  94.    {
  95.       var currentman = _root.wingmen[checker];
  96.       removeMovieClip(currentman);
  97.    }
  98.    for(var checker in goodies)
  99.    {
  100.       var currentgoodie = _root.goodies[checker];
  101.       removeMovieClip(currentgoodie);
  102.    }
  103.    for(var checker in projectileArray)
  104.    {
  105.       var currentprojectile = _root.projectileArray[checker];
  106.       removeMovieClip(currentprojectile);
  107.    }
  108.    stopAllSounds();
  109. }
  110. function checkAlive(target)
  111. {
  112.    var _loc1_ = target;
  113.    var _loc2_ = _root;
  114.    if(_loc1_.hitPoints <= 0)
  115.    {
  116.       _loc1_._rotation += 10;
  117.       _loc1_._y += 10;
  118.       if(_loc1_._y >= 350)
  119.       {
  120.          if(!framesSinceExplosion)
  121.          {
  122.             explode(_loc1_);
  123.             if(!_loc1_.amWingman)
  124.             {
  125.                life_indicator.play();
  126.             }
  127.          }
  128.          framesSinceExplosion++;
  129.          if(framesSinceExplosion >= 20)
  130.          {
  131.             if(!_loc1_.amWingman)
  132.             {
  133.                _loc2_.upgrades.setSelectedIndex(_loc2_.upgrades.getSelectedIndex() - 1,false);
  134.                _loc2_.sec_weapon_indc.mines_pool = 0;
  135.                _loc2_.sec_weapon_indc.nuke_pool = 0;
  136.                _loc2_.sec_weapon_indc.unguided_pool = 0;
  137.                _loc2_.sec_weapon_indc.guided_pool = 0;
  138.                _loc2_.flash_display.gotoAndPlay("life lost");
  139.                _loc1_._rotation = 0;
  140.                _loc1_._y = 50;
  141.                _loc1_._x = 50;
  142.                _loc1_._visible = 1;
  143.                _loc1_._alpha = 100;
  144.                framesSinceExplosion = 0;
  145.                _loc1_.hitPoints = 200;
  146.                alarm_sound.stop();
  147.                alarmplaying = false;
  148.                flicker(_loc1_);
  149.                shield.hitPoints = 0;
  150.                _loc1_.shielded = false;
  151.                shield._x = -1000;
  152.                shield._y = -1000;
  153.                updateHealthDisplay();
  154.             }
  155.             else
  156.             {
  157.                wingmen = cleanArray(wingmen);
  158.             }
  159.          }
  160.       }
  161.    }
  162.    if(heli.hitPoints <= 0)
  163.    {
  164.       return false;
  165.    }
  166.    return true;
  167. }
  168. function getClosestEnemy(what)
  169. {
  170.    var _loc1_ = what;
  171.    _loc1_.smallestDistance = 3000;
  172.    for(var _loc2_ in enemies)
  173.    {
  174.       _loc1_.checkenemy = enemies[_loc2_];
  175.       if(_loc1_.checkenemy._x)
  176.       {
  177.          _loc1_.distance = int(Math.sqrt(Math.pow(_loc1_.checkenemy._x - _loc1_._x,2) + Math.pow(_loc1_.checkenemy._y - _loc1_._y,2)));
  178.          if(_loc1_.distance < _loc1_.smallestDistance)
  179.          {
  180.             _loc1_.smallestDistance = _loc1_.distance;
  181.             _loc1_.smallestObject = _loc1_.checkenemy;
  182.          }
  183.       }
  184.    }
  185.    if(_loc1_.smallestObject)
  186.    {
  187.       _root.bee_beep_sound.start();
  188.    }
  189.    return _loc1_.smallestObject;
  190. }
  191. function shoot()
  192. {
  193.    laserEnabler.gotoAndStop(1);
  194.    shots++;
  195.    heli.flash.play();
  196.    mode = upgrades.getValue();
  197.    if(mode == "Basic MG")
  198.    {
  199.       gun_sound2.start();
  200.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  201.       currentProjectile = eval("projectile_" + projectileCount);
  202.       currentProjectile.moveX = 20;
  203.       currentProjectile.moveY = 0;
  204.       currentProjectile._x = heli._x + 30;
  205.       currentProjectile._y = heli._y + 10;
  206.    }
  207.    if(mode == "Double MG")
  208.    {
  209.       gun_sound2.start();
  210.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  211.       currentProjectile = eval("projectile_" + projectileCount);
  212.       currentProjectile.moveX = 20;
  213.       currentProjectile.moveY = -2;
  214.       currentProjectile._x = heli._x + 30;
  215.       currentProjectile._y = heli._y + 10;
  216.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  217.       currentProjectile = eval("projectile_" + projectileCount);
  218.       currentProjectile.moveX = 20;
  219.       currentProjectile.moveY = 2;
  220.       currentProjectile._x = heli._x + 30;
  221.       currentProjectile._y = heli._y + 10;
  222.    }
  223.    if(mode == "Super MG")
  224.    {
  225.       gun_sound3.start();
  226.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  227.       currentProjectile = eval("projectile_" + projectileCount);
  228.       currentProjectile.moveX = 25;
  229.       currentProjectile.moveY = 0;
  230.       currentProjectile._x = heli._x + 30;
  231.       currentProjectile._y = heli._y + 10;
  232.    }
  233.    if(mode == "Double Super MG")
  234.    {
  235.       gun_sound3.start();
  236.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  237.       currentProjectile = eval("projectile_" + projectileCount);
  238.       currentProjectile.moveX = 25;
  239.       currentProjectile.moveY = 0;
  240.       currentProjectile._x = heli._x + 30;
  241.       currentProjectile._y = heli._y + 10;
  242.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  243.       currentProjectile = eval("projectile_" + projectileCount);
  244.       currentProjectile.moveX = 25;
  245.       currentProjectile.moveY = 0;
  246.       currentProjectile._x = heli._x + 30;
  247.       currentProjectile._y = heli._y;
  248.    }
  249.    if(mode == "Double MG + Rearfire")
  250.    {
  251.       gun_sound3.start();
  252.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  253.       currentProjectile = eval("projectile_" + projectileCount);
  254.       currentProjectile.moveX = 25;
  255.       currentProjectile.moveY = 0;
  256.       currentProjectile._x = heli._x + 30;
  257.       currentProjectile._y = heli._y + 10;
  258.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  259.       currentProjectile = eval("projectile_" + projectileCount);
  260.       currentProjectile.moveX = 25;
  261.       currentProjectile.moveY = 0;
  262.       currentProjectile._x = heli._x + 30;
  263.       currentProjectile._y = heli._y;
  264.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  265.       currentProjectile = eval("projectile_" + projectileCount);
  266.       currentProjectile.moveX = -20;
  267.       currentProjectile.moveY = 0;
  268.       currentProjectile._x = heli._x + 30;
  269.       currentProjectile._y = heli._y + 10;
  270.    }
  271.    if(mode == "Double MG + Rearfire + Fireball")
  272.    {
  273.       gun_sound3.start();
  274.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  275.       currentProjectile = eval("projectile_" + projectileCount);
  276.       currentProjectile.moveX = 25;
  277.       currentProjectile.moveY = 0;
  278.       currentProjectile._x = heli._x + 30;
  279.       currentProjectile._y = heli._y + 10;
  280.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  281.       currentProjectile = eval("projectile_" + projectileCount);
  282.       currentProjectile.moveX = 25;
  283.       currentProjectile.moveY = 0;
  284.       currentProjectile._x = heli._x + 30;
  285.       currentProjectile._y = heli._y;
  286.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  287.       currentProjectile = eval("projectile_" + projectileCount);
  288.       currentProjectile.moveX = 20;
  289.       currentProjectile.moveY = -2;
  290.       currentProjectile._x = heli._x + 30;
  291.       currentProjectile._y = heli._y + 10;
  292.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  293.       currentProjectile = eval("projectile_" + projectileCount);
  294.       currentProjectile.moveX = 20;
  295.       currentProjectile.moveY = 2;
  296.       currentProjectile._x = heli._x + 30;
  297.       currentProjectile._y = heli._y + 10;
  298.    }
  299.    if(mode == "Multi MG + Rearfire + Fireball")
  300.    {
  301.       gun_sound3.start();
  302.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  303.       currentProjectile = eval("projectile_" + projectileCount);
  304.       currentProjectile.moveX = 20;
  305.       currentProjectile.moveY = -2;
  306.       currentProjectile._x = heli._x + 30;
  307.       currentProjectile._y = heli._y + 10;
  308.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  309.       currentProjectile = eval("projectile_" + projectileCount);
  310.       currentProjectile.moveX = 20;
  311.       currentProjectile.moveY = 2;
  312.       currentProjectile._x = heli._x + 30;
  313.       currentProjectile._y = heli._y + 10;
  314.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  315.       currentProjectile = eval("projectile_" + projectileCount);
  316.       currentProjectile.moveX = -20;
  317.       currentProjectile.moveY = 0;
  318.       currentProjectile._x = heli._x + 30;
  319.       currentProjectile._y = heli._y + 10;
  320.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  321.       currentProjectile = eval("projectile_" + projectileCount);
  322.       currentProjectile.moveX = 20;
  323.       currentProjectile.moveY = 4;
  324.       currentProjectile._x = heli._x + 30;
  325.       currentProjectile._y = heli._y + 10;
  326.       MGshots.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  327.       currentProjectile = eval("projectile_" + projectileCount);
  328.       currentProjectile.moveX = 20;
  329.       currentProjectile.moveY = -4;
  330.       currentProjectile._x = heli._x + 30;
  331.       currentProjectile._y = heli._y + 10;
  332.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  333.       currentProjectile = eval("projectile_" + projectileCount);
  334.       currentProjectile.moveX = 25;
  335.       currentProjectile.moveY = 0;
  336.       currentProjectile._x = heli._x + 30;
  337.       currentProjectile._y = heli._y + 10;
  338.       firebolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  339.       currentProjectile = eval("projectile_" + projectileCount);
  340.       currentProjectile.moveX = 25;
  341.       currentProjectile.moveY = 0;
  342.       currentProjectile._x = heli._x + 30;
  343.       currentProjectile._y = heli._y;
  344.    }
  345.    _root.projectileArray.push(currentProjectile);
  346. }
  347. function enemyShoot(how, whichEnemy)
  348. {
  349.    if(random(whichEnemy.reload) == 1 && !_root.gamePaused)
  350.    {
  351.       whichEnemy.gotoAndPlay("shoot");
  352.       if(how == "bolt")
  353.       {
  354.          gun_sound2.start();
  355.          weapon_bolt.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  356.          currentProjectile = eval("projectile_" + projectileCount);
  357.          currentProjectile._x = whichEnemy._x - 40;
  358.          currentProjectile._y = whichEnemy._y;
  359.       }
  360.       if(how == "multishot")
  361.       {
  362.          gun_sound2.start();
  363.          currentProjectile = weapon_rocket2.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  364.          currentProjectile._x = whichEnemy._x - 40;
  365.          currentProjectile._y = whichEnemy._y;
  366.          currentProjectile.moveX = -5;
  367.          currentProjectile.moveY = -1;
  368.          currentProjectile = weapon_rocket2.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  369.          currentProjectile._x = whichEnemy._x - 40;
  370.          currentProjectile._y = whichEnemy._y;
  371.          currentProjectile.moveX = -5;
  372.          currentProjectile.moveY = -0.8;
  373.          currentProjectile = weapon_rocket2.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  374.          currentProjectile._x = whichEnemy._x - 40;
  375.          currentProjectile._y = whichEnemy._y;
  376.          currentProjectile.moveX = -5;
  377.          currentProjectile.moveY = 0.8;
  378.          currentProjectile = weapon_rocket2.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  379.          currentProjectile._x = whichEnemy._x - 40;
  380.          currentProjectile._y = whichEnemy._y;
  381.          currentProjectile.moveX = -5;
  382.          currentProjectile.moveY = 1;
  383.       }
  384.       if(how == "laser")
  385.       {
  386.          bounce_sound.start();
  387.          weapon_laser.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  388.          currentProjectile = eval("projectile_" + projectileCount);
  389.          currentProjectile._x = whichEnemy._x - 40;
  390.          currentProjectile._y = whichEnemy._y;
  391.       }
  392.       if(how == "MG")
  393.       {
  394.          gun_sound2.start();
  395.          weapon_MG.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  396.          currentProjectile = eval("projectile_" + projectileCount);
  397.          currentProjectile._x = whichEnemy._x - 40;
  398.          currentProjectile._y = whichEnemy._y;
  399.          if(whichEnemy._x <= heli._x)
  400.          {
  401.             currentProjectile.moveX = -10;
  402.          }
  403.          if(whichEnemy._x >= heli._x)
  404.          {
  405.             currentProjectile.moveX = 10;
  406.          }
  407.       }
  408.       if(how == "MG_aimed")
  409.       {
  410.          gun_sound2.start();
  411.          weapon_MG_aimed.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  412.          currentProjectile = eval("projectile_" + projectileCount);
  413.          currentProjectile._x = whichEnemy._x - 40;
  414.          currentProjectile._y = whichEnemy._y;
  415.       }
  416.       if(how == "fireball")
  417.       {
  418.          weapon_fireball.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  419.          currentProjectile = eval("projectile_" + projectileCount);
  420.          currentProjectile._x = whichEnemy._x - 40;
  421.          currentProjectile._y = whichEnemy._y;
  422.          disappear_sound.start();
  423.       }
  424.       if(how == "ball")
  425.       {
  426.          weapon_ball.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  427.          currentProjectile = eval("projectile_" + projectileCount);
  428.          currentProjectile._x = whichEnemy._x - 40;
  429.          currentProjectile._y = whichEnemy._y;
  430.          fireburst_sound.start();
  431.       }
  432.       if(how == "doubleball")
  433.       {
  434.          weapon_ball.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  435.          currentProjectile = eval("projectile_" + projectileCount);
  436.          currentProjectile._x = whichEnemy._x - 40;
  437.          currentProjectile._y = whichEnemy._y;
  438.          weapon_ball.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  439.          currentProjectile = eval("projectile_" + projectileCount);
  440.          currentProjectile._x = whichEnemy._x - 40;
  441.          currentProjectile._y = whichEnemy._y + 10;
  442.          fireburst_sound.start();
  443.       }
  444.       if(how == "fireball_slow")
  445.       {
  446.          weapon_fireball_slow.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  447.          currentProjectile = eval("projectile_" + projectileCount);
  448.          currentProjectile._x = whichEnemy._x - 40;
  449.          currentProjectile._y = whichEnemy._y;
  450.          fireburst_sound.start();
  451.       }
  452.       if(how == "rocket")
  453.       {
  454.          weapon_rocket.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  455.          currentProjectile = eval("projectile_" + projectileCount);
  456.          currentProjectile._x = whichEnemy._x - 40;
  457.          currentProjectile._y = whichEnemy._y;
  458.          missile_sound.start();
  459.       }
  460.       if(how == "doublerocket")
  461.       {
  462.          weapon_rocket.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  463.          currentProjectile = eval("projectile_" + projectileCount);
  464.          currentProjectile._x = whichEnemy._x - 40;
  465.          currentProjectile._y = whichEnemy._y;
  466.          weapon_rocket.duplicateMovieClip("projectile_" + ++projectileCount,heli.o++);
  467.          currentProjectile = eval("projectile_" + projectileCount);
  468.          currentProjectile._x = whichEnemy._x;
  469.          currentProjectile._y = whichEnemy._y + 5;
  470.          missile_sound.start();
  471.       }
  472.    }
  473.    _root.projectileArray.push(currentProjectile);
  474. }
  475. function changeBrightness(target)
  476. {
  477.    var _loc1_ = target;
  478.    if(_loc1_.flash == "on")
  479.    {
  480.       _loc1_.flash = "off";
  481.       var _loc3_ = new Color(_loc1_);
  482.       var _loc2_ = {rb:"255",gb:"255",bb:"255"};
  483.       _loc3_.setTransform(_loc2_);
  484.       _loc1_.flashFrame += 1;
  485.    }
  486.    else
  487.    {
  488.       _loc1_.flash = "on";
  489.       _loc3_ = new Color(_loc1_);
  490.       _loc2_ = {rb:"0",gb:"0",bb:"0"};
  491.       _loc3_.setTransform(_loc2_);
  492.       _loc1_.flashFrame += 1;
  493.    }
  494.    if(_loc1_.flashFrame >= 9)
  495.    {
  496.       clearInterval(_loc1_.flashInterval);
  497.       _loc1_.flashing = false;
  498.       _loc3_ = new Color(_loc1_);
  499.       _loc2_ = {rb:"0",gb:"0",bb:"0"};
  500.       _loc3_.setTransform(_loc2_);
  501.    }
  502. }
  503. function flicker(what)
  504. {
  505.    var _loc1_ = what;
  506.    if(!_loc1_.flashing)
  507.    {
  508.       _loc1_.flashInterval = setInterval(changeBrightness,25,_loc1_);
  509.       _loc1_.flashFrame = 0;
  510.       _loc1_.flashing = true;
  511.    }
  512. }
  513. function checkEnemyCollision(which)
  514. {
  515.    var _loc1_ = which;
  516.    if(!_loc1_.initHitPoints)
  517.    {
  518.       _loc1_.initHitPoints = _loc1_.hitPoints;
  519.    }
  520.    if(_loc1_.hitTest(heli.hitarea))
  521.    {
  522.       if(!heli.shielded)
  523.       {
  524.          explode(_loc1_);
  525.          flicker(heli);
  526.          heli.hitPoints -= 50;
  527.          updateHealthDisplay();
  528.       }
  529.       else
  530.       {
  531.          _root.sHit_sound.start();
  532.          flicker(shield);
  533.          shield.hitPoints -= 50;
  534.          what.removeMovieClip();
  535.          if(shield.hitPoints <= 0)
  536.          {
  537.             heli.shielded = false;
  538.             shield.gotoAndStop("cleanframe");
  539.             shield._x = -1000;
  540.             shield._y = -1000;
  541.          }
  542.       }
  543.    }
  544. }
  545. function enemyCheckHit(what)
  546. {
  547.    var _loc1_ = what;
  548.    if(_loc1_.hitTest(heli.hitareaLarge))
  549.    {
  550.       if(!heli.shielded)
  551.       {
  552.          spark(heli);
  553.          flicker(heli);
  554.          heli.hitPoints -= _loc1_.damage;
  555.          _loc1_.removeMovieClip();
  556.          updateHealthDisplay();
  557.       }
  558.       else
  559.       {
  560.          _root.sHit_sound.start();
  561.          flicker(shield);
  562.          shield.hitPoints -= _loc1_.damage;
  563.          _loc1_.removeMovieClip();
  564.          if(shield.hitPoints <= 0)
  565.          {
  566.             heli.shielded = false;
  567.             shield.gotoAndStop("cleanframe");
  568.             shield._x = -1000;
  569.             shield._y = -1000;
  570.          }
  571.       }
  572.    }
  573. }
  574. function checkHit(what, donotremoveorigin)
  575. {
  576.    var _loc1_ = what;
  577.    var _loc3_ = donotremoveorigin;
  578.    for(var _loc2_ in enemies)
  579.    {
  580.       checkenemy = enemies[_loc2_];
  581.       if(_loc1_.hitTest(checkenemy))
  582.       {
  583.          hits++;
  584.          checkenemy.hitPoints -= _loc1_.damage;
  585.          if(checkenemy.hitPoints <= 0)
  586.          {
  587.             takedowns++;
  588.             explode(checkenemy,null,true);
  589.          }
  590.          else
  591.          {
  592.             spark(checkenemy);
  593.             flicker(checkenemy);
  594.          }
  595.          if(!_loc3_)
  596.          {
  597.             _loc1_.removeMovieClip();
  598.          }
  599.       }
  600.    }
  601. }
  602. function explode(what, nosound, byplayer)
  603. {
  604.    if(!nosound && _root.framesSinceLastExplosion >= 10)
  605.    {
  606.       _root.framesSinceLastExplosion = 0;
  607.       explosion_sound.start();
  608.    }
  609.    if(what.myLooper)
  610.    {
  611.       what.myLooper.removeMovieClip();
  612.    }
  613.    explosionsprite.duplicateMovieClip("exSprite_" + ++exSpriteCount,heli.o++);
  614.    var currentexSprite = eval("exSprite_" + exSpriteCount);
  615.    currentexSprite._x = what._x;
  616.    currentexSprite._y = what._y;
  617.    var getScore = int(what.initHitPoints * 2);
  618.    if(byplayer == true)
  619.    {
  620.       scoreboard.score(getScore);
  621.       _root.popScore(new String(getScore),what);
  622.    }
  623.    goodieSpawn(what._x,what._y);
  624.    if(what.listener)
  625.    {
  626.       what.listener.overrideX = 0;
  627.       what.listener.overrideY = 0;
  628.    }
  629.    what._visible = 0;
  630.    what.removeMovieClip();
  631.    enemies = cleanArray(enemies);
  632. }
  633. function spark(what)
  634. {
  635.    var randomcloud = eval("cloud" + random(3));
  636.    randomcloud.duplicateMovieClip("exSprite_" + ++exSpriteCount,heli.o++);
  637.    var currentexSprite = eval("exSprite_" + exSpriteCount);
  638.    currentexSprite._x = what._x;
  639.    currentexSprite._y = what._y;
  640. }
  641. function moveEnemy(what, how, direction)
  642. {
  643.    var _loc1_ = what;
  644.    var _loc2_ = how;
  645.    if(!_root.gamePaused)
  646.    {
  647.       if(_loc1_._x <= -100 || _loc1_._x >= 700 || _loc1_._y >= 440 || _loc1_._y <= -30)
  648.       {
  649.          if(!_loc1_.amWingman)
  650.          {
  651.             explode(_loc1_,true);
  652.          }
  653.       }
  654.       if(!_loc1_.startPosX)
  655.       {
  656.          _loc1_.startPosX = _loc1_._x;
  657.       }
  658.       if(!_loc1_.startPosY)
  659.       {
  660.          _loc1_.startPosY = _loc1_._y;
  661.       }
  662.       if(_loc1_._y >= -30 && !_root.gamePaused)
  663.       {
  664.          if(_loc2_ == "random")
  665.          {
  666.             if(!_loc1_.destY)
  667.             {
  668.                _loc1_.destY = random(400);
  669.             }
  670.             if(!_loc1_.destX)
  671.             {
  672.                _loc1_.destX = random(550);
  673.             }
  674.             if(_loc1_.dochange++ >= 100)
  675.             {
  676.                _loc1_.dochange = 0;
  677.                _loc1_.destY = random(400);
  678.                _loc1_.destX = random(550);
  679.             }
  680.             if(_loc1_._y > _loc1_.destY)
  681.             {
  682.                _loc1_.moveY -= random(3) / 10;
  683.             }
  684.             if(_loc1_._y < _loc1_.destY)
  685.             {
  686.                _loc1_.moveY += random(3) / 10;
  687.             }
  688.             if(_loc1_._x > _loc1_.destX)
  689.             {
  690.                _loc1_.moveX -= random(3) / 10;
  691.             }
  692.             if(_loc1_._x < _loc1_.destX)
  693.             {
  694.                _loc1_.moveX += random(3) / 10;
  695.             }
  696.             if(_loc1_.moveX >= 4)
  697.             {
  698.                _loc1_.moveX = 4;
  699.             }
  700.             if(_loc1_.moveX <= -4)
  701.             {
  702.                _loc1_.moveX = -4;
  703.             }
  704.             if(_loc1_.moveY >= 4)
  705.             {
  706.                _loc1_.moveY = 4;
  707.             }
  708.             if(_loc1_.moveY <= -4)
  709.             {
  710.                _loc1_.moveY = -4;
  711.             }
  712.             _loc1_._x += _loc1_.moveX;
  713.             _loc1_._y += _loc1_.moveY;
  714.          }
  715.          if(_loc2_ == "kamikaze")
  716.          {
  717.             if(_loc1_.overrideX > 1)
  718.             {
  719.                _loc1_.destX = _loc1_.overrideX;
  720.             }
  721.             else
  722.             {
  723.                _loc1_.destX = heli._x - 50;
  724.             }
  725.             if(_loc1_.overrideY > 1)
  726.             {
  727.                _loc1_.destY = _loc1_.overrideY;
  728.             }
  729.             else
  730.             {
  731.                _loc1_.destY = heli._y;
  732.             }
  733.             l = 0;
  734.             if(_loc1_._y > _loc1_.destY)
  735.             {
  736.                _loc1_.moveY -= random(3) / 10;
  737.             }
  738.             if(_loc1_._y < _loc1_.destY)
  739.             {
  740.                _loc1_.moveY += random(3) / 10;
  741.             }
  742.             if(_loc1_._x > _loc1_.destX)
  743.             {
  744.                _loc1_.moveX -= random(3) / 10;
  745.             }
  746.             if(_loc1_._x < _loc1_.destX)
  747.             {
  748.                _loc1_.moveX += random(3) / 10;
  749.             }
  750.             if(_loc1_.moveX >= 4)
  751.             {
  752.                _loc1_.moveX = 4;
  753.             }
  754.             if(_loc1_.moveX <= -4)
  755.             {
  756.                _loc1_.moveX = -4;
  757.             }
  758.             if(_loc1_.moveY >= 4)
  759.             {
  760.                _loc1_.moveY = 4;
  761.             }
  762.             if(_loc1_.moveY <= -4)
  763.             {
  764.                _loc1_.moveY = -4;
  765.             }
  766.             _loc1_._x += _loc1_.moveX;
  767.             _loc1_._y += _loc1_.moveY;
  768.          }
  769.          if(_loc2_ == "sine")
  770.          {
  771.             if(_loc1_.direction == "right")
  772.             {
  773.                _loc1_._x += 2;
  774.             }
  775.             else
  776.             {
  777.                _loc1_._x -= 2;
  778.             }
  779.             _loc1_._y = _loc1_.startPosY + 100 * Math.sin(_loc1_.r += 0.05);
  780.             if(_loc1_._y < 10)
  781.             {
  782.                if(_loc1_.direction == "left")
  783.                {
  784.                   _loc1_.direction = "right";
  785.                }
  786.             }
  787.             if(_loc1_._y > 540)
  788.             {
  789.                if(_loc1_.direction == "right")
  790.                {
  791.                   _loc1_.direction = "left";
  792.                }
  793.             }
  794.             _loc1_.startPosY += _loc1_.driftY;
  795.             _loc1_.startPosX += _loc1_.driftX;
  796.          }
  797.          if(_loc2_ == "zipoff")
  798.          {
  799.             if(!_loc1_.accel)
  800.             {
  801.                _loc1_.accel = 5;
  802.             }
  803.             _loc1_.accel += 0.5;
  804.             _loc1_._x -= _loc1_.accel;
  805.          }
  806.          if(_loc2_ == "getY_stayright")
  807.          {
  808.             _loc1_.destY = heli._y;
  809.             if(_loc1_.dochange++ >= 100)
  810.             {
  811.                _loc1_.dochange = 0;
  812.                _loc1_.destX = random(200) + 440;
  813.             }
  814.             if(_loc1_._y > _loc1_.destY)
  815.             {
  816.                _loc1_.moveY -= random(3) / 10;
  817.             }
  818.             if(_loc1_._y < _loc1_.destY)
  819.             {
  820.                _loc1_.moveY += random(3) / 10;
  821.             }
  822.             if(_loc1_._x > _loc1_.destX)
  823.             {
  824.                _loc1_.moveX -= random(3) / 10;
  825.             }
  826.             if(_loc1_._x < _loc1_.destX)
  827.             {
  828.                _loc1_.moveX += random(3) / 10;
  829.             }
  830.             if(_loc1_.moveX >= 4)
  831.             {
  832.                _loc1_.moveX = 4;
  833.             }
  834.             if(_loc1_.moveX <= -4)
  835.             {
  836.                _loc1_.moveX = -4;
  837.             }
  838.             if(_loc1_.moveY >= 4)
  839.             {
  840.                _loc1_.moveY = 4;
  841.             }
  842.             if(_loc1_.moveY <= -4)
  843.             {
  844.                _loc1_.moveY = -4;
  845.             }
  846.             _loc1_._x += _loc1_.moveX;
  847.             _loc1_._y += _loc1_.moveY;
  848.          }
  849.          if(_loc2_ == "getY")
  850.          {
  851.             _loc1_.destY = heli._y;
  852.             if(_loc1_.dochange++ >= 100)
  853.             {
  854.                _loc1_.dochange = 0;
  855.                _loc1_.destX = random(550);
  856.             }
  857.             if(_loc1_._y > _loc1_.destY)
  858.             {
  859.                _loc1_.moveY -= random(3) / 10;
  860.             }
  861.             if(_loc1_._y < _loc1_.destY)
  862.             {
  863.                _loc1_.moveY += random(3) / 10;
  864.             }
  865.             if(_loc1_._x > _loc1_.destX)
  866.             {
  867.                _loc1_.moveX -= random(3) / 10;
  868.             }
  869.             if(_loc1_._x < _loc1_.destX)
  870.             {
  871.                _loc1_.moveX += random(3) / 10;
  872.             }
  873.             if(_loc1_.moveX >= 4)
  874.             {
  875.                _loc1_.moveX = 4;
  876.             }
  877.             if(_loc1_.moveX <= -4)
  878.             {
  879.                _loc1_.moveX = -4;
  880.             }
  881.             if(_loc1_.moveY >= 4)
  882.             {
  883.                _loc1_.moveY = 4;
  884.             }
  885.             if(_loc1_.moveY <= -4)
  886.             {
  887.                _loc1_.moveY = -4;
  888.             }
  889.             _loc1_._x += _loc1_.moveX;
  890.             _loc1_._y += _loc1_.moveY;
  891.          }
  892.          if(_loc2_ == "vehicle_random")
  893.          {
  894.             if(!_loc1_.destX)
  895.             {
  896.                _loc1_.destX = random(550);
  897.             }
  898.             if(_loc1_.dochange++ >= 100)
  899.             {
  900.                _loc1_.dochange = 0;
  901.                _loc1_.destX = random(550);
  902.             }
  903.             if(_loc1_._x > _loc1_.destX)
  904.             {
  905.                _loc1_.moveX -= random(3) / 10;
  906.             }
  907.             if(_loc1_._x < _loc1_.destX)
  908.             {
  909.                _loc1_.moveX += random(3) / 10;
  910.             }
  911.             if(_loc1_.moveX >= 3)
  912.             {
  913.                _loc1_.moveX = 3;
  914.             }
  915.             if(_loc1_.moveX <= -3)
  916.             {
  917.                _loc1_.moveX = -3;
  918.             }
  919.             if(_loc1_.moveX < 0)
  920.             {
  921.                _loc1_.direction = "left";
  922.             }
  923.             if(_loc1_.moveX >= 0)
  924.             {
  925.                _loc1_.direction = "right";
  926.             }
  927.             _loc1_._x += _loc1_.moveX;
  928.          }
  929.          if(_loc2_ == "speedin")
  930.          {
  931.             if(_loc1_._x >= 550)
  932.             {
  933.                _loc1_.MoveX = -10;
  934.             }
  935.             else if(_loc1_.MoveX <= -4 && _loc1_._x > 200)
  936.             {
  937.                _loc1_.MoveX /= 1.06;
  938.             }
  939.             if(_loc1_.MoveX >= -10 && _loc1_._x <= 200)
  940.             {
  941.                _loc1_.MoveX *= 1.06;
  942.             }
  943.             _loc1_._x += _loc1_.MoveX;
  944.             _loc1_._y = _loc1_.startPosY + 2 * Math.sin(_loc1_.r += 0.2);
  945.          }
  946.          if(_loc2_ == "speedin_slow")
  947.          {
  948.             if(_loc1_._x >= 550)
  949.             {
  950.                _loc1_.MoveX = -10;
  951.             }
  952.             else if(_loc1_.MoveX <= -2 && _loc1_._x > 200)
  953.             {
  954.                _loc1_.MoveX /= 1.06;
  955.             }
  956.             if(_loc1_.MoveX >= -5 && _loc1_._x <= 200)
  957.             {
  958.                _loc1_.MoveX *= 1.06;
  959.             }
  960.             _loc1_._x += _loc1_.MoveX;
  961.             _loc1_._y = _loc1_.startPosY + 2 * Math.sin(_loc1_.r += 0.2);
  962.          }
  963.          if(_loc2_ == "divein")
  964.          {
  965.             if(direction == "right")
  966.             {
  967.                _loc1_._x += 5;
  968.             }
  969.             else
  970.             {
  971.                _loc1_._x -= 5;
  972.             }
  973.             if(_loc1_.path == "down")
  974.             {
  975.                _loc1_._y = _loc1_.startPosY - 10 * Math.sin(_loc1_.r += 0.1);
  976.             }
  977.             else
  978.             {
  979.                _loc1_._y = _loc1_.startPosY + 10 * Math.sin(_loc1_.r += 0.1);
  980.             }
  981.          }
  982.          if(_loc2_ == "loop")
  983.          {
  984.             if(!_loc1_.phase)
  985.             {
  986.                _loc1_.thex += 0.2;
  987.                _loc1_._y = 200 - Math.pow(_loc1_.thex,2) * 2;
  988.                _loc1_._x = _loc1_.startPosX + _loc1_.thex * 5;
  989.                if(_loc1_.thex >= 6)
  990.                {
  991.                   _loc1_.phase = _loc1_.phase + 1;
  992.                }
  993.             }
  994.             if(_loc1_.phase == 1)
  995.             {
  996.                _loc1_.movehow = "random";
  997.             }
  998.          }
  999.       }
  1000.    }
  1001. }
  1002. function moveMissile(which)
  1003. {
  1004.    var _loc1_ = which;
  1005.    if(_loc1_._x <= 0 || _loc1_._x >= 550 || _loc1_._y >= 440 || _loc1_._y <= -30)
  1006.    {
  1007.       _loc1_.removeMovieClip();
  1008.    }
  1009.    if(_loc1_.getNewTarget++ >= 10 && !_loc1_.seek._x)
  1010.    {
  1011.       _loc1_.getNewTarget = 0;
  1012.       _loc1_.seek = getClosestEnemy(_loc1_);
  1013.    }
  1014.    var _loc3_ = _loc1_.seek._x;
  1015.    var _loc2_ = _loc1_.seek._y;
  1016.    if(!_loc3_)
  1017.    {
  1018.       _loc3_ = 500;
  1019.    }
  1020.    if(!_loc2_)
  1021.    {
  1022.       _loc2_ = -50;
  1023.    }
  1024.    var z = _loc3_ - _loc1_._x;
  1025.    var r = _loc2_ - _loc1_._y;
  1026.    var a = z;
  1027.    var b = r;
  1028.    var e = z / r;
  1029.    var k = Math.atan(e);
  1030.    var g = k * 180 / 3.141592653589793;
  1031.    _loc1_._rotation = g;
  1032.    if(_loc2_ > _loc1_._y)
  1033.    {
  1034.       _loc1_._rotation = 90 - _loc1_._rotation;
  1035.    }
  1036.    else if(_loc2_ < _loc1_._y)
  1037.    {
  1038.       _loc1_._rotation = 180 - (_loc1_._rotation - 90);
  1039.    }
  1040.    _loc1_.step = _loc1_.step + 1;
  1041.    if(_loc1_._rotation != initAngle)
  1042.    {
  1043.       if(_loc1_.step <= 10)
  1044.       {
  1045.          _loc1_._rotation = 0;
  1046.       }
  1047.       var g = _loc1_._rotation * 0.01745;
  1048.       var z = Math.cos(g);
  1049.       var n = Math.sin(g);
  1050.       _loc1_._x += z * 10 + _loc1_.initSpeed;
  1051.       _loc1_._y += n * 10;
  1052.       _loc1_.initSpeed /= 1.04;
  1053.       if(_loc1_._x >= _loc3_ - 40 && _loc1_._x <= _loc3_ + 40 && _loc1_._y >= _loc2_ - 30 && _loc1_._y <= _loc2_ + 30)
  1054.       {
  1055.          _loc1_.seek.hitPoints -= _loc1_.damage;
  1056.          if(_loc1_.seek.hitPoints <= 0)
  1057.          {
  1058.             explode(_loc1_.seek,null,true);
  1059.          }
  1060.          else
  1061.          {
  1062.             flicker(_loc1_.seek);
  1063.             spark(_loc1_.seek);
  1064.          }
  1065.          _loc1_.removeMovieClip();
  1066.       }
  1067.    }
  1068.    makeSmoke(_loc1_);
  1069. }
  1070. function makeSmoke(what)
  1071. {
  1072.    if(drawsmoke)
  1073.    {
  1074.       var chooseSmoke = random(3) + 1;
  1075.       var chosenOne = eval("_root.cloud" + chooseSmoke);
  1076.       chosenOne.duplicateMovieClip("dupedSmoke_" + ++_root.cloudCount,_root.heli.o++);
  1077.       var dupedOne = eval("dupedSmoke_" + _root.cloudCount);
  1078.       var chosenSize = random(50) + 50;
  1079.       dupedOne._x = what.lastXpos;
  1080.       dupedOne._y = what.lastYpos;
  1081.       dupedOne._xscale = chosenSize;
  1082.       dupedOne._yscale = chosenSize;
  1083.       what.lastXpos = what._x;
  1084.       what.lastYpos = what._y;
  1085.    }
  1086. }
  1087. function rotate(what)
  1088. {
  1089.    var _loc1_ = what;
  1090.    if(Key.isDown(39) || Key.isDown(40))
  1091.    {
  1092.       if(_loc1_.flymode == "normal")
  1093.       {
  1094.          _loc1_.gotoAndPlay("rotate down");
  1095.       }
  1096.       if(_loc1_.flymode == "undodown")
  1097.       {
  1098.          _loc1_.gotoAndPlay(_loc1_._currentframe - 25);
  1099.       }
  1100.       if(_loc1_.flymode == "undoup")
  1101.       {
  1102.          _loc1_.rotatethru = true;
  1103.       }
  1104.    }
  1105.    if(Key.isDown(37) || Key.isDown(38))
  1106.    {
  1107.       if(_loc1_.flymode == "normal")
  1108.       {
  1109.          _loc1_.gotoAndPlay("rotate up");
  1110.       }
  1111.       if(_loc1_.flymode == "undoup")
  1112.       {
  1113.          _loc1_.gotoAndPlay(_loc1_._currentframe - 33);
  1114.       }
  1115.       if(_loc1_.flymode == "undodown")
  1116.       {
  1117.          _loc1_.rotatethru = true;
  1118.       }
  1119.    }
  1120. }
  1121. function unrotate(what)
  1122. {
  1123.    var _loc1_ = what;
  1124.    if(_loc1_.flymode == "bedown")
  1125.    {
  1126.       _loc1_.gotoAndPlay("goback down");
  1127.    }
  1128.    if(_loc1_.flymode == "godown")
  1129.    {
  1130.       gotoFrame = 45 - (_loc1_._currentframe - 8);
  1131.       _loc1_.gotoAndPlay(gotoFrame);
  1132.    }
  1133.    if(_loc1_.flymode == "beup")
  1134.    {
  1135.       _loc1_.gotoAndPlay("goback up");
  1136.    }
  1137.    if(_loc1_.flymode == "goup")
  1138.    {
  1139.       gotoFrame = 87 - (_loc1_._currentframe - 46);
  1140.       _loc1_.gotoAndPlay(gotoFrame);
  1141.    }
  1142. }
  1143. function cleanArray(input)
  1144. {
  1145.    var _loc1_ = input;
  1146.    newarray = new Array();
  1147.    _loc1_.sort();
  1148.    l = 0;
  1149.    for(var _loc2_ in _loc1_)
  1150.    {
  1151.       if(_loc1_[_loc2_]._x)
  1152.       {
  1153.          newarray[++l] = _loc1_[_loc2_];
  1154.       }
  1155.    }
  1156.    return newarray;
  1157. }
  1158.