home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / bubble_tanks_2.swf / scripts / __Packages / BubbleTanksGame.as < prev    next >
Encoding:
Text File  |  2008-09-02  |  143.0 KB  |  4,264 lines

  1. class BubbleTanksGame
  2. {
  3.    var kongEnemiesKilledThisGame;
  4.    var kongBigEnemiesKilledThisGame;
  5.    var kongDestroyerKilledThisGame;
  6.    var kongTriGuardianKilledThisGame;
  7.    var kongSpawnCarrierKilledThisGame;
  8.    var kongBFTKilledThisGame;
  9.    var kongBlnRefresh;
  10.    var mySharedObject;
  11.    var upgradePath;
  12.    var blnWorldCreated;
  13.    var worldCreateRow;
  14.    var worldCreateColumn;
  15.    var prevOutside;
  16.    var secondBulletCounter;
  17.    var numJumps;
  18.    var intTutorialState;
  19.    var avatarLife;
  20.    var maxAvatarLife;
  21.    var intStoreDepth_openMask;
  22.    var intStoreDepth_overlay;
  23.    var intStoreDepth_avatar;
  24.    var intStoreDepth_bg;
  25.    var intStoreDepth_bubbleSplit;
  26.    var intStoreDepth_effects_mc;
  27.    var intStoreDepth_miniBubblesLayer_mc;
  28.    var intStoreDepth_bubbleMask;
  29.    var intStoreDepth_effectMask_mc;
  30.    var intStoreDepth_pause_mc;
  31.    var intStoreDepth_life;
  32.    var intStoreDepth_fireRate_mc;
  33.    var intStoreDepth_flash_mc;
  34.    var runOnce;
  35.    var transitionState;
  36.    var mouseListener;
  37.    var intPrimaryCounter;
  38.    var intSecondaryCounter;
  39.    var intAutoCounter;
  40.    var blnPrimaryActive;
  41.    var vecMomentum;
  42.    var numAvatarMaxVelocity;
  43.    var numSensitivity;
  44.    var numResistence;
  45.    var stickyCounter;
  46.    var arrBullets;
  47.    var arrBulletBusters;
  48.    var arrFloatingBubbles;
  49.    var arrDebris;
  50.    var arrCleanup;
  51.    var arrEffects;
  52.    var arrUnderEffects;
  53.    var arrMap;
  54.    var arrAllySeekers;
  55.    var arrAllies;
  56.    var deltaList;
  57.    var numBulletDepth;
  58.    var numMineDepth;
  59.    var numAllyDepth;
  60.    var spawnedEnemyDepth;
  61.    var arrFloatingBubblesDepth;
  62.    var effectDepth;
  63.    var underEffectDepth;
  64.    var blnEnemiesCleared;
  65.    var blnFlushList;
  66.    var intWinFlag;
  67.    var intLifeState;
  68.    var intMaxHigh;
  69.    var intMaxLow;
  70.    var blnLifeFlag;
  71.    var intLifeCounter;
  72.    var intFireRateState;
  73.    var intFireRateMaxHigh;
  74.    var intFireRateMaxLow;
  75.    var blnFireRateFlag;
  76.    var intFireRateCounter;
  77.    var intKeyLock;
  78.    var intAssembledState;
  79.    var intAssembledFrame;
  80.    var blnSpaceDown;
  81.    var world;
  82.    var blnUpgradeFlag;
  83.    var backgroundDepth;
  84.    var arrBackgrounds;
  85.    var numEnemiesCreated;
  86.    var strCurrentScreen;
  87.    var blnWaitingToUpgrade;
  88.    var arrUpgradePath;
  89.    var mapLocX;
  90.    var mapLocY;
  91.    var intJumpsAsMax;
  92.    var blnBoss;
  93.    var intBossState;
  94.    var intBossX;
  95.    var intBossY;
  96.    var intShieldCounter;
  97.    var intShieldWidth;
  98.    var intBubblesCollected;
  99.    var intEnemiesKilled;
  100.    var intShakeDuration;
  101.    var intShakeCounter;
  102.    var intShakeStart;
  103.    var vecScreenCoords;
  104.    var _enemySet;
  105.    var arenaTimer;
  106.    var _enemySet2;
  107.    var intUpgradeDelay;
  108.    var gotoAndStop;
  109.    var intTotalFrames;
  110.    var easeFrames;
  111.    var dblDestX;
  112.    var dblDestY;
  113.    var deltaX;
  114.    var deltaY;
  115.    function BubbleTanksGame()
  116.    {
  117.       this.kongEnemiesKilledThisGame = new DataObject();
  118.       this.kongEnemiesKilledThisGame.Set(0);
  119.       this.kongBigEnemiesKilledThisGame = new DataObject();
  120.       this.kongBigEnemiesKilledThisGame.Set(0);
  121.       this.kongDestroyerKilledThisGame = new DataObject();
  122.       this.kongDestroyerKilledThisGame.Set(0);
  123.       this.kongTriGuardianKilledThisGame = new DataObject();
  124.       this.kongTriGuardianKilledThisGame.Set(0);
  125.       this.kongSpawnCarrierKilledThisGame = new DataObject();
  126.       this.kongSpawnCarrierKilledThisGame.Set(0);
  127.       this.kongBFTKilledThisGame = new DataObject();
  128.       this.kongBlnRefresh = false;
  129.       this.mySharedObject = SharedObject.getLocal("settings");
  130.       this.upgradePath = new UpgradeTree();
  131.       this.blnWorldCreated = false;
  132.       this.worldCreateRow = 0;
  133.       this.worldCreateColumn = 0;
  134.       this.prevOutside = false;
  135.       this.secondBulletCounter = 0;
  136.       this.numJumps = 0;
  137.       this.intTutorialState = 1;
  138.       this.avatarLife = new DataObject();
  139.       this.avatarLife.Set(1);
  140.       this.maxAvatarLife = 1;
  141.       this.intStoreDepth_openMask = _root.openMask.getDepth();
  142.       this.intStoreDepth_overlay = _root.overlay.getDepth();
  143.       this.intStoreDepth_avatar = _root.avatar.getDepth();
  144.       this.intStoreDepth_bg = _root.bg.getDepth();
  145.       this.intStoreDepth_bubbleSplit = _root.bubbleSplit.getDepth();
  146.       this.intStoreDepth_effects_mc = _root.effects_mc.getDepth();
  147.       this.intStoreDepth_miniBubblesLayer_mc = _root.miniBubblesLayer_mc.getDepth();
  148.       this.intStoreDepth_bubbleMask = _root.bubbleMask.getDepth();
  149.       this.intStoreDepth_effectMask_mc = _root.effectMask_mc.getDepth();
  150.       this.intStoreDepth_pause_mc = _root.pause_mc.getDepth();
  151.       this.intStoreDepth_life = _root.life.getDepth();
  152.       this.intStoreDepth_fireRate_mc = _root.fireRate_mc.getDepth();
  153.       this.intStoreDepth_flash_mc = _root.flash_mc.getDepth();
  154.       _root.openMask.stop();
  155.       _root.openMask.swapDepths(1000001);
  156.       _root.overlay.swapDepths(1000000);
  157.       _root.avatar.swapDepths(510);
  158.       _root.bg.swapDepths(500);
  159.       _root.bubbleSplit.swapDepths(505);
  160.       _root.effects_mc.swapDepths(507);
  161.       _root.miniBubblesLayer_mc.swapDepths(508);
  162.       _root.bubbleMask.swapDepths(509);
  163.       _root.effectMask_mc.swapDepths(511);
  164.       _root.effects_mc.setMask("effectMask_mc");
  165.       _root.miniBubblesLayer_mc.setMask("bubbleMask");
  166.       this.runOnce = false;
  167.       this.transitionState = 0;
  168.       var thisRef = this;
  169.       this.mouseListener = new Object();
  170.       this.mouseListener.onMouseDown = function()
  171.       {
  172.          thisRef.MouseDown();
  173.       };
  174.       this.mouseListener.onMouseUp = function()
  175.       {
  176.          thisRef.MouseUp();
  177.       };
  178.       Mouse.addListener(this.mouseListener);
  179.       this.intPrimaryCounter = 0;
  180.       this.intSecondaryCounter = 0;
  181.       this.intAutoCounter = 0;
  182.       this.blnPrimaryActive = false;
  183.       this.vecMomentum = new Vector();
  184.       this.numAvatarMaxVelocity = 7;
  185.       this.numSensitivity = 0.4;
  186.       this.numResistence = 0.08;
  187.       this.stickyCounter = 0;
  188.       this.arrBullets = new Array();
  189.       this.arrBulletBusters = new Array();
  190.       this.arrFloatingBubbles = new Array();
  191.       this.arrDebris = new Array();
  192.       this.arrCleanup = new Array();
  193.       this.arrEffects = new Array();
  194.       this.arrUnderEffects = new Array();
  195.       this.arrMap = new Array();
  196.       this.arrAllySeekers = new Array();
  197.       this.arrAllies = new Array();
  198.       this.deltaList = new Array();
  199.       this.numBulletDepth = 100000;
  200.       this.numMineDepth = 100;
  201.       this.numAllyDepth = 560;
  202.       this.spawnedEnemyDepth = 20001;
  203.       this.arrFloatingBubblesDepth = 700;
  204.       this.effectDepth = 50000;
  205.       this.underEffectDepth = 10;
  206.       this.blnEnemiesCleared = false;
  207.       this.blnFlushList = false;
  208.       this.intWinFlag = -1;
  209.       this.intLifeState = 3;
  210.       this.intMaxHigh = 352;
  211.       this.intMaxLow = 412;
  212.       this.blnLifeFlag = false;
  213.       this.intLifeCounter = 0;
  214.       this.intFireRateState = 3;
  215.       this.intFireRateMaxHigh = -50;
  216.       this.intFireRateMaxLow = 5;
  217.       this.blnFireRateFlag = false;
  218.       this.intFireRateCounter = 0;
  219.       this.intKeyLock = 0;
  220.       this.intAssembledState = 0;
  221.       this.intAssembledFrame = 1;
  222.       this.blnSpaceDown = false;
  223.       this.world = new BubbleTanksWorld();
  224.       if(_global.gameMode == 1)
  225.       {
  226.       }
  227.       this.arrMap.push({xloc:this.world.x,yloc:this.world.y,blnCreate:true,blnBoss:false});
  228.       _root.pause_mc._visible = false;
  229.       this.blnUpgradeFlag = false;
  230.       this.backgroundDepth = 100;
  231.       this.arrBackgrounds = new Array();
  232.       this.arrBackgrounds.push("bg_bubbles_301");
  233.       this.numEnemiesCreated = 0;
  234.       this.strCurrentScreen = "stats_mc";
  235.       this.blnWaitingToUpgrade = false;
  236.       this.arrUpgradePath = Array();
  237.       this.arrUpgradePath.push({min:1,max:76,name:"Starting Tank"});
  238.       this.arrUpgradePath.push({min:76,max:201,name:"Machine Gun Tank"});
  239.       this.arrUpgradePath.push({min:201,max:371,name:"3-Shot Tank"});
  240.       this.arrUpgradePath.push({min:371,max:999999,name:"Super Tank"});
  241.       this.mapLocX = undefined;
  242.       this.mapLocY = undefined;
  243.       this.intJumpsAsMax = 0;
  244.       this.blnBoss = false;
  245.       this.intBossState = 0;
  246.       this.intBossX = 0;
  247.       this.intBossY = 0;
  248.       this.intShieldCounter = 0;
  249.       this.intShieldWidth = 65;
  250.       this.intBubblesCollected = 0;
  251.       this.intEnemiesKilled = 0;
  252.       this.intShakeDuration = 0;
  253.       this.intShakeCounter = 0;
  254.       this.intShakeStart = 0;
  255.       this.vecScreenCoords = new Vector();
  256.       this.vecScreenCoords._x = _root.avatar._x;
  257.       this.vecScreenCoords._y = _root.avatar._y;
  258.    }
  259.    function QuitGame()
  260.    {
  261.       Mouse.removeListener(this.mouseListener);
  262.       this.world.current.HideAllUnits();
  263.       this.CleanPickupBubbles();
  264.       this.CleanupBullets();
  265.       this.RemoveAllAllySeekers();
  266.       this.CleanEffects();
  267.       this.CleanAllies();
  268.       _root.openMask.swapDepths(this.intStoreDepth_openMask);
  269.       _root.overlay.swapDepths(this.intStoreDepth_overlay);
  270.       _root.avatar.swapDepths(this.intStoreDepth_avatar);
  271.       _root.bg.swapDepths(this.intStoreDepth_bg);
  272.       _root.bubbleSplit.swapDepths(this.intStoreDepth_bubbleSplit);
  273.       _root.effects_mc.swapDepths(this.intStoreDepth_effects_mc);
  274.       _root.miniBubblesLayer_mc.swapDepths(this.intStoreDepth_miniBubblesLayer_mc);
  275.       _root.bubbleMask.swapDepths(this.intStoreDepth_bubbleMask);
  276.       _root.effectMask_mc.swapDepths(this.intStoreDepth_effectMask_mc);
  277.       _root.pause_mc.swapDepths(this.intStoreDepth_pause_mc);
  278.       _root.life.swapDepths(this.intStoreDepth_life);
  279.       _root.fireRate_mc.swapDepths(this.intStoreDepth_fireRate_mc);
  280.       _root.flash_mc.swapDepths(this.intStoreDepth_flash_mc);
  281.       _root.effects_mc.setMask("");
  282.       _root.miniBubblesLayer_mc.setMask("");
  283.       _global.gamePaused = false;
  284.       _global.arena = new Bubblefield();
  285.       _global.arenaAvatar = 1;
  286.       _root.ExitGame();
  287.    }
  288.    function CreateNewUnit(enemyType, startPos, CreatedFrom)
  289.    {
  290.       if(enemyType == "Enemy_2")
  291.       {
  292.          if(this._enemySet == 1)
  293.          {
  294.             enemyType = "Enemy_2";
  295.          }
  296.          else if(this._enemySet == 2)
  297.          {
  298.             enemyType = "Enemy_93";
  299.          }
  300.          else if(this._enemySet == 3)
  301.          {
  302.             enemyType = "Enemy_94";
  303.          }
  304.       }
  305.       var _loc4_ = "enemy_" + this.spawnedEnemyDepth;
  306.       var _loc6_ = Math.round(Math.random() * 360) - 180;
  307.       this.world.current.AddSpawnedUnit(_loc4_,enemyType,startPos,this.spawnedEnemyDepth);
  308.       _root.attachMovie(enemyType,_loc4_,this.spawnedEnemyDepth);
  309.       this.spawnedEnemyDepth = this.spawnedEnemyDepth + 1;
  310.       if(this.spawnedEnemyDepth > 40000)
  311.       {
  312.          this.spawnedEnemyDepth = 20001;
  313.       }
  314.       _root[_loc4_]._x = startPos._x;
  315.       _root[_loc4_]._y = startPos._y;
  316.       _root[_loc4_]._rotation = _loc6_;
  317.       if(enemyType == "Enemy_Orbital_Seeker" || enemyType == "Enemy_Sapper" || enemyType == "Enemy_Leecher")
  318.       {
  319.          _root[_loc4_].SetCreatedFrom(CreatedFrom);
  320.       }
  321.       return _loc4_;
  322.    }
  323.    function SafeToFire()
  324.    {
  325.       if(this.transitionState == 0)
  326.       {
  327.          return true;
  328.       }
  329.       return false;
  330.    }
  331.    function StartGame()
  332.    {
  333.       _root.pause_mc.swapDepths(1000010);
  334.       _root.life.swapDepths(1000005);
  335.       _root.fireRate_mc.swapDepths(1000006);
  336.       _root.flash_mc.swapDepths(1000008);
  337.       _root.flash_mc._visible = false;
  338.       _root.bg.boss_mc._visible = false;
  339.       _root.bg.bossUp_mc._visible = false;
  340.       _root.bg.bossRight_mc._visible = false;
  341.       _root.bg.bossDown_mc._visible = false;
  342.       _root.bg.bossLeft_mc._visible = false;
  343.       if(_global.gameMode == 2)
  344.       {
  345.          var _loc7_ = new Vector();
  346.          this.world.current.ShowAllUnits(_loc7_);
  347.          _root.bg.tutShell_mc.tutorial.gotoAndStop(7);
  348.          this.avatarLife.Set(this.upgradePath.GetNodeWithID(_global.arenaAvatar).nodeData._minPoints + 50);
  349.          this.upgradePath.SetNodeWithID(_global.arenaAvatar);
  350.          _root.avatar.gotoAndStop(_global.arenaAvatar);
  351.          if(this.upgradePath.currentNode.nodeData._id < 21)
  352.          {
  353.             _root.avatar.gun.gotoAndStop(50);
  354.          }
  355.          this.arenaTimer = new Timer();
  356.          this.arenaTimer.Start();
  357.       }
  358.       else
  359.       {
  360.          this._enemySet = 0;
  361.          this._enemySet2 = 0;
  362.          var _loc6_ = 1;
  363.          var _loc4_ = new Array(1,2,3);
  364.          var _loc5_ = 0;
  365.          while(_loc5_ < _loc4_.length)
  366.          {
  367.             if(_loc4_[_loc5_] == _global.set1)
  368.             {
  369.                _loc4_.splice(_loc5_,1);
  370.                _loc5_ = _loc5_ - 1;
  371.             }
  372.             else if(_loc4_[_loc5_] == _global.set2)
  373.             {
  374.                _loc4_.splice(_loc5_,1);
  375.                _loc5_ = _loc5_ - 1;
  376.             }
  377.             _loc5_ = _loc5_ + 1;
  378.          }
  379.          _loc6_ = _loc4_[this.RandNum(0,_loc4_.length - 1)];
  380.          _global.set2 = _global.set1;
  381.          _global.set1 = this._enemySet = _loc6_;
  382.          _loc6_ = 1;
  383.          _loc4_ = new Array(1,2);
  384.          _loc5_ = 0;
  385.          while(_loc5_ < _loc4_.length)
  386.          {
  387.             if(_loc4_[_loc5_] == _global.set3)
  388.             {
  389.                _loc4_.splice(_loc5_,1);
  390.                _loc5_ = _loc5_ - 1;
  391.             }
  392.             _loc5_ = _loc5_ + 1;
  393.          }
  394.          _loc6_ = _loc4_[this.RandNum(0,_loc4_.length - 1)];
  395.          _global.set3 = this._enemySet2 = _loc6_;
  396.          if(this.mySharedObject.data.firstTime != undefined)
  397.          {
  398.             this.mySharedObject.data.set1 = _global.set1;
  399.             this.mySharedObject.data.set2 = _global.set2;
  400.             this.mySharedObject.data.set3 = _global.set3;
  401.             this.mySharedObject.flush();
  402.          }
  403.       }
  404.    }
  405.    function RunGame()
  406.    {
  407.       _root.stop();
  408.       var _loc4_ = undefined;
  409.       var _loc5_ = undefined;
  410.       if(_global.gamePaused == false)
  411.       {
  412.          if(this.transitionState == 0)
  413.          {
  414.             _loc5_ = this.MoveAvatar();
  415.          }
  416.          else if(this.deltaList.length != 0)
  417.          {
  418.             _loc5_ = new Vector();
  419.             var _loc7_ = this.deltaList[0];
  420.             this.deltaList.shift();
  421.             _loc5_._x = _loc7_._x * -1;
  422.             _loc5_._y = _loc7_._y * -1;
  423.             if(this.transitionState == 1)
  424.             {
  425.                _loc4_ = this.world.GetLeft(false);
  426.                _loc4_.MoveAllBubblefieldUnits(_loc5_);
  427.             }
  428.             else if(this.transitionState == 2)
  429.             {
  430.                _loc4_ = this.world.GetUp(false);
  431.                _loc4_.MoveAllBubblefieldUnits(_loc5_);
  432.             }
  433.             else if(this.transitionState == 3)
  434.             {
  435.                _loc4_ = this.world.GetRight(false);
  436.                _loc4_.MoveAllBubblefieldUnits(_loc5_);
  437.             }
  438.             else if(this.transitionState == 4)
  439.             {
  440.                _loc4_ = this.world.GetDown(false);
  441.                _loc4_.MoveAllBubblefieldUnits(_loc5_);
  442.             }
  443.          }
  444.          else
  445.          {
  446.             var _loc6_ = new Vector();
  447.             if(this.transitionState == 1)
  448.             {
  449.                _loc4_ = this.world.GetLeft(false);
  450.                if(_loc4_ == undefined)
  451.                {
  452.                   this.world.PrintBubblefieldCoordsList();
  453.                }
  454.                _loc4_.HideAllUnits();
  455.                if(_loc4_.blnBoss == true)
  456.                {
  457.                   this.HideBoss();
  458.                }
  459.                _loc6_._x = 1147.6;
  460.             }
  461.             else if(this.transitionState == 2)
  462.             {
  463.                _loc4_ = this.world.GetUp(false);
  464.                if(_loc4_ == undefined)
  465.                {
  466.                   this.world.PrintBubblefieldCoordsList();
  467.                }
  468.                _loc4_.HideAllUnits();
  469.                if(_loc4_.blnBoss == true)
  470.                {
  471.                   this.HideBoss();
  472.                }
  473.                _loc6_._y = 1147.6;
  474.             }
  475.             else if(this.transitionState == 3)
  476.             {
  477.                _loc4_ = this.world.GetRight(false);
  478.                if(_loc4_ == undefined)
  479.                {
  480.                   this.world.PrintBubblefieldCoordsList();
  481.                }
  482.                _loc4_.HideAllUnits();
  483.                if(_loc4_.blnBoss == true)
  484.                {
  485.                   this.HideBoss();
  486.                }
  487.                _loc6_._x = -1147.6;
  488.             }
  489.             else if(this.transitionState == 4)
  490.             {
  491.                _loc4_ = this.world.GetDown(false);
  492.                if(_loc4_ == undefined)
  493.                {
  494.                   this.world.PrintBubblefieldCoordsList();
  495.                }
  496.                _loc4_.HideAllUnits();
  497.                if(_loc4_.blnBoss == true)
  498.                {
  499.                   this.HideBoss();
  500.                }
  501.                _loc6_._y = -1147.6;
  502.             }
  503.             this.blnEnemiesCleared = false;
  504.             this.FlushEncounteredList();
  505.             this.BackgroundShift(_loc6_);
  506.             if(this.world.current.blnBoss == true)
  507.             {
  508.                this.ShiftBoss();
  509.             }
  510.             this.CleanPickupBubbles();
  511.             this.CleanupBullets();
  512.             this.RemoveAllySeekers();
  513.             this.CleanEffects();
  514.             this.ManageTutorial();
  515.             if(this.kongBlnRefresh == true)
  516.             {
  517.                _root.kongregateStats.submit("MaxKillsInAGame",this.kongEnemiesKilledThisGame.Get());
  518.                this.kongBlnRefresh = false;
  519.             }
  520.             this.transitionState = 0;
  521.             if(this.GetDistance() <= _root.bg.inside._width / 2)
  522.             {
  523.                this.runOnce = false;
  524.             }
  525.             _loc5_ = this.MoveAvatar();
  526.             if(this.intBossState == 1)
  527.             {
  528.                this.intBossState = 2;
  529.                this.blnWaitingToUpgrade = true;
  530.                this.PauseGame();
  531.                _root.pause_mc.gotoAndStop(1);
  532.                _root.pause_mc._visible = false;
  533.                this.blnUpgradeFlag = true;
  534.                _root.bg.boss_mc._visible = true;
  535.                _root.bg.boss_mc.gotoAndPlay(2);
  536.             }
  537.          }
  538.          this.MoveWorld(_loc5_);
  539.          this.RotateGun();
  540.          this.ManageDisassembly();
  541.          this.OperateAvatarWeapons();
  542.          this.CheckPickupBubbleCollection();
  543.          if(this.transitionState == 0)
  544.          {
  545.             this.CheckBulletCollision();
  546.             this.CheckTankExit();
  547.          }
  548.          this.ControlInterface();
  549.          this.ControlFireRateInterface();
  550.          this.ManageShaking();
  551.          this.ManageWinGame();
  552.       }
  553.       if(_global.gamePaused == true && this.intBossState == 2)
  554.       {
  555.          this.ManageShaking();
  556.       }
  557.       if(_global.gameMode == 2)
  558.       {
  559.          this.arenaTimer.Run();
  560.       }
  561.       this.CheckKeyPress();
  562.       this.DoCleanup();
  563.    }
  564.    function ManageWinGame()
  565.    {
  566.       if(this.intWinFlag == 0)
  567.       {
  568.          _root.kongregateStats.submit("GameCompleted",1);
  569.          this.blnUpgradeFlag = true;
  570.          this.PauseGame();
  571.          if(_global.doUnlockEC.Get() != -1)
  572.          {
  573.             _root.pause_mc.gotoAndPlay("winScreen");
  574.          }
  575.          else
  576.          {
  577.             _root.pause_mc.gotoAndPlay("winScreenLocked");
  578.          }
  579.          _root.bg.boss_mc.gotoAndStop(1);
  580.          _root.bg.boss_mc._visible = false;
  581.          this.intWinFlag = -1;
  582.       }
  583.       else if(this.intWinFlag > 0)
  584.       {
  585.          this.intWinFlag = this.intWinFlag - 1;
  586.       }
  587.    }
  588.    function ResumeBossFight()
  589.    {
  590.       this.BossSpawnBody();
  591.       this.intBossState = 3;
  592.       this.blnWaitingToUpgrade = false;
  593.       this.blnUpgradeFlag = false;
  594.       this.UnPauseGame();
  595.    }
  596.    function HideBoss()
  597.    {
  598.       _root.bg.boss_mc.gotoAndStop(1);
  599.       _root.bg.boss_mc._visible = false;
  600.    }
  601.    function ShowBoss(vecShift)
  602.    {
  603.       if(this.intBossState == 3)
  604.       {
  605.          if(vecShift._x == 0 && vecShift._y < 0)
  606.          {
  607.             _root.bg.bossUp_mc._visible = true;
  608.             _root.bg.bossUp_mc.gotoAndStop("resumeBoss");
  609.          }
  610.          else if(vecShift._x > 0 && vecShift._y == 0)
  611.          {
  612.             _root.bg.bossRight_mc._visible = true;
  613.             _root.bg.bossRight_mc.gotoAndStop("resumeBoss");
  614.          }
  615.          else if(vecShift._x == 0 && vecShift._y > 0)
  616.          {
  617.             _root.bg.bossDown_mc._visible = true;
  618.             _root.bg.bossDown_mc.gotoAndStop("resumeBoss");
  619.          }
  620.          else if(vecShift._x < 0 && vecShift._y == 0)
  621.          {
  622.             _root.bg.bossLeft_mc._visible = true;
  623.             _root.bg.bossLeft_mc.gotoAndStop("resumeBoss");
  624.          }
  625.       }
  626.    }
  627.    function ShiftBoss()
  628.    {
  629.       if(this.intBossState == 3)
  630.       {
  631.          _root.bg.boss_mc._visible = true;
  632.          _root.bg.boss_mc.gotoAndStop("resumeBoss");
  633.          _root.bg.bossUp_mc.gotoAndStop(1);
  634.          _root.bg.bossUp_mc._visible = false;
  635.          _root.bg.bossRight_mc.gotoAndStop(1);
  636.          _root.bg.bossRight_mc._visible = false;
  637.          _root.bg.bossDown_mc.gotoAndStop(1);
  638.          _root.bg.bossDown_mc._visible = false;
  639.          _root.bg.bossLeft_mc.gotoAndStop(1);
  640.          _root.bg.bossLeft_mc._visible = false;
  641.       }
  642.    }
  643.    function BossSpawnBody()
  644.    {
  645.       var _loc4_ = new Vector();
  646.       var _loc3_ = {x:_root.bg.boss_mc.handLeft_mc._x,y:_root.bg.boss_mc.handLeft_mc._y};
  647.       _root.bg.boss_mc.localToGlobal(_loc3_);
  648.       _loc4_._x = _loc3_.x;
  649.       _loc4_._y = _loc3_.y;
  650.       var _loc7_ = this.CreateNewUnit("Enemy_B2",_loc4_,"");
  651.       _root[_loc7_]._rotation = _root.bg.boss_mc.handLeft_mc._rotation;
  652.       _root.bg.boss_mc.handLeft_mc._visible = false;
  653.       _loc4_ = new Vector();
  654.       _loc3_ = {x:_root.bg.boss_mc.handRight_mc._x,y:_root.bg.boss_mc.handRight_mc._y};
  655.       _root.bg.boss_mc.localToGlobal(_loc3_);
  656.       _loc4_._x = _loc3_.x;
  657.       _loc4_._y = _loc3_.y;
  658.       var _loc10_ = this.CreateNewUnit("Enemy_B2",_loc4_,"");
  659.       _root[_loc10_]._rotation = _root.bg.boss_mc.handRight_mc._rotation;
  660.       _root.bg.boss_mc.handRight_mc._visible = false;
  661.       var _loc6_ = new Vector();
  662.       _loc3_ = {x:_root.bg.boss_mc.head_mc._x,y:_root.bg.boss_mc.head_mc._y};
  663.       _root.bg.boss_mc.localToGlobal(_loc3_);
  664.       _loc6_._x = _loc3_.x;
  665.       _loc6_._y = _loc3_.y;
  666.       var _loc8_ = this.CreateNewUnit("Enemy_B1",_loc6_,"");
  667.       _root[_loc8_]._rotation = _root.bg.boss_mc.head_mc._rotation;
  668.       _root.bg.boss_mc.head_mc._visible = false;
  669.       var _loc5_ = new Vector();
  670.       _loc3_ = {x:_root.bg.boss_mc.tail_mc._x,y:_root.bg.boss_mc.tail_mc._y};
  671.       _root.bg.boss_mc.localToGlobal(_loc3_);
  672.       _loc5_._x = _loc3_.x;
  673.       _loc5_._y = _loc3_.y;
  674.       var _loc9_ = this.CreateNewUnit("Enemy_B3",_loc5_,"");
  675.       _root[_loc9_]._rotation = _root.bg.boss_mc.tail_mc._rotation;
  676.       _root.bg.boss_mc.tail_mc._visible = false;
  677.    }
  678.    function ManageTutorial()
  679.    {
  680.       if(this.upgradePath.currentNode.nodeData._id >= 21)
  681.       {
  682.          this.intJumpsAsMax = this.intJumpsAsMax + 1;
  683.       }
  684.       this.numJumps = this.numJumps + 1;
  685.       if(_global.gameMode != 2)
  686.       {
  687.          if(this.intTutorialState == 2)
  688.          {
  689.             this.intTutorialState = 3;
  690.             _root.bg.tutShell_mc.gotoAndStop(1);
  691.             _root.bg.tutShell_mc.tutorial.gotoAndStop(6);
  692.          }
  693.          else if(this.world.current.blnBoss == true)
  694.          {
  695.             _root.bg.tutShell_mc.gotoAndStop(1);
  696.             _root.bg.tutShell_mc.tutorial.gotoAndStop(7);
  697.          }
  698.          else if(this.numJumps == 1)
  699.          {
  700.             _root.bg.tutShell_mc.gotoAndStop(1);
  701.             _root.bg.tutShell_mc.tutorial.gotoAndStop(2);
  702.          }
  703.          else if(this.numJumps == 2)
  704.          {
  705.             _root.bg.tutShell_mc.gotoAndStop(1);
  706.             _root.bg.tutShell_mc.tutorial.gotoAndStop(3);
  707.          }
  708.          else if(this.numJumps == 3)
  709.          {
  710.             _root.bg.tutShell_mc.gotoAndStop(1);
  711.             _root.bg.tutShell_mc.tutorial.gotoAndStop(4);
  712.          }
  713.          else if(this.numJumps == 4)
  714.          {
  715.             _root.bg.tutShell_mc.gotoAndStop(1);
  716.             _root.bg.tutShell_mc.tutorial.gotoAndStop(5);
  717.          }
  718.          else if(this.numJumps > 4)
  719.          {
  720.             _root.bg.tutShell_mc.gotoAndStop(2);
  721.          }
  722.       }
  723.       else
  724.       {
  725.          _root.bg.tutShell_mc.gotoAndStop(2);
  726.       }
  727.    }
  728.    function CheckKeyPress()
  729.    {
  730.       if(this.intKeyLock == 0)
  731.       {
  732.          var _loc3_ = -1;
  733.          if(Key.isDown(_global.pauseHotkey))
  734.          {
  735.             if(this.blnUpgradeFlag == false)
  736.             {
  737.                if(_global.gamePaused == true)
  738.                {
  739.                   this.ClosePauseScreen();
  740.                   this.intKeyLock = 20;
  741.                }
  742.                else
  743.                {
  744.                   this.PauseGame();
  745.                   this.intKeyLock = 20;
  746.                }
  747.             }
  748.          }
  749.          if(Key.isDown(17) && Key.isDown(107))
  750.          {
  751.             if(_global.doUnlockEC.Get() != -1)
  752.             {
  753.                if(_global.doUnLockCheats.Get() != -1)
  754.                {
  755.                   this.avatarLife.Set(this.avatarLife.Get() + 100);
  756.                   this.intKeyLock = 20;
  757.                   this.CheckUpgradeState();
  758.                }
  759.             }
  760.          }
  761.       }
  762.       else
  763.       {
  764.          this.intKeyLock = this.intKeyLock - 1;
  765.       }
  766.       if(_global.gamePaused == false)
  767.       {
  768.          if(Key.isDown(_global.fireHotkey))
  769.          {
  770.             if(this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[0].type == 24)
  771.             {
  772.                if(this.blnSpaceDown == false)
  773.                {
  774.                   this.intAssembledState = 1;
  775.                   this.blnSpaceDown = true;
  776.                }
  777.             }
  778.             else
  779.             {
  780.                this.OperateAvatarSecondaryWeapons();
  781.             }
  782.          }
  783.          else if(this.blnSpaceDown == true)
  784.          {
  785.             this.intAssembledState = 3;
  786.             this.blnSpaceDown = false;
  787.          }
  788.       }
  789.    }
  790.    function SetupPauseScreen()
  791.    {
  792.       _root.pause_mc.inside_mc.buttonText_txt.text = "";
  793.       this.SelectPauseScreen(this.strCurrentScreen);
  794.    }
  795.    function SelectPauseScreen(openScreen)
  796.    {
  797.       var _loc3_ = _root.pause_mc.inside_mc;
  798.       _loc3_.content_mc.gotoAndStop(openScreen);
  799.       if(openScreen == "stats_mc")
  800.       {
  801.          _loc3_.stats_mc.gotoAndStop(2);
  802.       }
  803.       else
  804.       {
  805.          _loc3_.stats_mc.gotoAndStop(1);
  806.       }
  807.       if(openScreen == "map_mc")
  808.       {
  809.          _loc3_.map_mc.gotoAndStop(2);
  810.          this.DrawMap();
  811.       }
  812.       else
  813.       {
  814.          _loc3_.map_mc.gotoAndStop(1);
  815.       }
  816.       if(openScreen == "options_mc")
  817.       {
  818.          _loc3_.options_mc.gotoAndStop(2);
  819.       }
  820.       else
  821.       {
  822.          _loc3_.options_mc.gotoAndStop(1);
  823.       }
  824.       if(openScreen == "stats_mc")
  825.       {
  826.          this.SetupStats();
  827.       }
  828.       if(openScreen != "quit_mc" && openScreen != "controls_mc")
  829.       {
  830.          this.strCurrentScreen = openScreen;
  831.       }
  832.    }
  833.    function SetupArenaScreen()
  834.    {
  835.       _root.pause_mc.inside_mc.enemiesKilled_txt.text = this.intEnemiesKilled;
  836.       _root.pause_mc.inside_mc.bubblesCollected_txt.text = this.intBubblesCollected;
  837.       _root.pause_mc.inside_mc.timeCompleted_txt.text = this.arenaTimer.GetTimeString();
  838.    }
  839.    function CompleteArena()
  840.    {
  841.       this.arenaTimer.Pause();
  842.       this.blnUpgradeFlag = true;
  843.       this.PauseGame();
  844.       _root.pause_mc.gotoAndPlay("arenaComplete");
  845.    }
  846.    function PauseGame()
  847.    {
  848.       _global.gamePaused = true;
  849.       if(_global.gameMode == 2)
  850.       {
  851.          this.arenaTimer.Pause();
  852.       }
  853.       if(this.transitionState != 0)
  854.       {
  855.          this.world.previous.HaltUnits();
  856.       }
  857.       this.world.current.HaltUnits();
  858.       this.PauseAllies();
  859.       var _loc4_ = 0;
  860.       while(_loc4_ < this.arrBullets.length)
  861.       {
  862.          _root[this.arrBullets[_loc4_]]._holdMovement = true;
  863.          if(_root[this.arrBullets[_loc4_]]._type == 8)
  864.          {
  865.             _root[this.arrBullets[_loc4_]].PauseUnPauseBusted(true);
  866.          }
  867.          _loc4_ = _loc4_ + 1;
  868.       }
  869.       _loc4_ = 0;
  870.       while(_loc4_ < this.arrAllySeekers.length)
  871.       {
  872.          _root[this.arrAllySeekers[_loc4_].name].TurnOff();
  873.          _loc4_ = _loc4_ + 1;
  874.       }
  875.       _root.pause_mc._visible = true;
  876.       _root.pause_mc.gotoAndPlay(2);
  877.    }
  878.    function UpgradePause()
  879.    {
  880.       this.PauseGame();
  881.       this.blnUpgradeFlag = true;
  882.       if(this.upgradePath.currentNode.GetNumChildren() == 3)
  883.       {
  884.          _root.pause_mc.gotoAndPlay("upgradeThree");
  885.       }
  886.       else if(this.upgradePath.currentNode.GetNumChildren() == 2)
  887.       {
  888.          _root.pause_mc.gotoAndPlay("upgradeTwo");
  889.       }
  890.    }
  891.    function UpgradePauseComplete()
  892.    {
  893.       this.UnPauseGame();
  894.       this.blnUpgradeFlag = false;
  895.    }
  896.    function ClosePauseScreen()
  897.    {
  898.       _root.pause_mc.gotoAndPlay(16);
  899.       this.blnUpgradeFlag = false;
  900.    }
  901.    function CloseWinScreen()
  902.    {
  903.       _global.invincible = true;
  904.       if(_global.doUnlockEC.Get() != -1)
  905.       {
  906.          _root.pause_mc.gotoAndPlay(77);
  907.       }
  908.       else
  909.       {
  910.          _root.pause_mc.gotoAndPlay(107);
  911.       }
  912.       this.blnUpgradeFlag = false;
  913.    }
  914.    function UnPauseGame()
  915.    {
  916.       _root.pause_mc._visible = false;
  917.       if(_global.gameMode == 2)
  918.       {
  919.          this.arenaTimer.UnPause();
  920.       }
  921.       _global.gamePaused = false;
  922.       if(this.transitionState != 0)
  923.       {
  924.          this.world.previous.ResumeUnits();
  925.       }
  926.       this.world.current.ResumeUnits();
  927.       this.UnPauseAllies();
  928.       var _loc4_ = 0;
  929.       while(_loc4_ < this.arrBullets.length)
  930.       {
  931.          _root[this.arrBullets[_loc4_]]._holdMovement = false;
  932.          if(_root[this.arrBullets[_loc4_]]._type == 8)
  933.          {
  934.             _root[this.arrBullets[_loc4_]].PauseUnPauseBusted(false);
  935.          }
  936.          _loc4_ = _loc4_ + 1;
  937.       }
  938.       _loc4_ = 0;
  939.       while(_loc4_ < this.arrAllySeekers.length)
  940.       {
  941.          _root[this.arrAllySeekers[_loc4_].name].TurnOn();
  942.          _loc4_ = _loc4_ + 1;
  943.       }
  944.    }
  945.    function DrawMap()
  946.    {
  947.       this.ClearMap();
  948.       var _loc23_ = _root.pause_mc.inside_mc;
  949.       var _loc4_ = _root.pause_mc.inside_mc.content_mc.contentInside_mc.mapInside_mc;
  950.       if(this.mapLocX == undefined)
  951.       {
  952.          this.mapLocX = _loc4_._x;
  953.          this.mapLocY = _loc4_._y;
  954.       }
  955.       _loc4_.map_mc._visible = false;
  956.       var _loc15_ = 999999;
  957.       var _loc13_ = -999999;
  958.       var _loc14_ = 999999;
  959.       var _loc12_ = -999999;
  960.       var _loc3_ = 0;
  961.       while(_loc3_ < this.arrMap.length)
  962.       {
  963.          if(this.arrMap[_loc3_].xloc < _loc15_)
  964.          {
  965.             _loc15_ = this.arrMap[_loc3_].xloc;
  966.          }
  967.          if(this.arrMap[_loc3_].xloc > _loc13_)
  968.          {
  969.             _loc13_ = this.arrMap[_loc3_].xloc;
  970.          }
  971.          if(this.arrMap[_loc3_].yloc < _loc14_)
  972.          {
  973.             _loc14_ = this.arrMap[_loc3_].yloc;
  974.          }
  975.          if(this.arrMap[_loc3_].yloc > _loc12_)
  976.          {
  977.             _loc12_ = this.arrMap[_loc3_].yloc;
  978.          }
  979.          _loc3_ = _loc3_ + 1;
  980.       }
  981.       var _loc10_ = 1;
  982.       var _loc11_ = 15;
  983.       var _loc9_ = _loc4_.map_mc._x + _loc4_.map_mc._width / 2;
  984.       var _loc8_ = _loc4_.map_mc._y + _loc4_.map_mc._height / 2;
  985.       var _loc7_ = 0;
  986.       var _loc6_ = 0;
  987.       var _loc21_ = this.world.startX;
  988.       var _loc20_ = this.world.startY;
  989.       var _loc18_ = this.world.current.x;
  990.       var _loc19_ = this.world.current.y;
  991.       var _loc25_ = 5;
  992.       var _loc5_ = this.arrMap[0].xloc + "_" + this.arrMap[0].yloc;
  993.       var _loc27_ = undefined;
  994.       var _loc26_ = undefined;
  995.       var _loc17_ = undefined;
  996.       _loc17_ = _loc18_ - _loc21_;
  997.       _loc9_ -= _loc17_ * _loc11_;
  998.       _loc17_ = _loc19_ - _loc20_;
  999.       _loc8_ += _loc17_ * _loc11_;
  1000.       _loc4_.attachMovie("token",_loc5_,_loc10_);
  1001.       _loc10_ = _loc10_ + 1;
  1002.       _loc4_[_loc5_]._x = _loc9_;
  1003.       _loc4_[_loc5_]._y = _loc8_;
  1004.       _loc4_.lineStyle(0,16777215,100);
  1005.       var _loc22_ = new Object();
  1006.       var _loc24_ = new Object();
  1007.       _loc4_.moveTo(_loc9_,_loc8_);
  1008.       _loc3_ = 1;
  1009.       while(_loc3_ < this.arrMap.length)
  1010.       {
  1011.          _loc7_ = _loc9_ + (this.arrMap[_loc3_].xloc - this.arrMap[_loc3_ - 1].xloc) * _loc11_;
  1012.          _loc6_ = _loc8_ + (this.arrMap[_loc3_].yloc - this.arrMap[_loc3_ - 1].yloc) * (- _loc11_);
  1013.          _loc5_ = this.arrMap[_loc3_].xloc + "_" + this.arrMap[_loc3_].yloc;
  1014.          if(this.arrMap[_loc3_].blnCreate == true)
  1015.          {
  1016.             _loc4_.attachMovie("token",_loc5_,_loc10_);
  1017.             _loc10_ = _loc10_ + 1;
  1018.             _loc4_[_loc5_]._x = _loc7_;
  1019.             _loc4_[_loc5_]._y = _loc6_;
  1020.          }
  1021.          _loc4_.lineTo(_loc7_,_loc6_);
  1022.          _loc9_ = _loc7_;
  1023.          _loc8_ = _loc6_;
  1024.          _loc3_ = _loc3_ + 1;
  1025.       }
  1026.       var _loc16_ = undefined;
  1027.       _loc16_ = this.arrMap[0].xloc + "_" + this.arrMap[0].yloc;
  1028.       _loc4_[_loc16_].gotoAndStop(2);
  1029.       if(this.blnBoss == true)
  1030.       {
  1031.          _loc16_ = this.intBossX + "_" + this.intBossY;
  1032.          _loc4_[_loc16_].gotoAndStop(4);
  1033.       }
  1034.       _loc16_ = _loc18_ + "_" + _loc19_;
  1035.       _loc4_[_loc16_].gotoAndStop(3);
  1036.    }
  1037.    function ClearMap()
  1038.    {
  1039.       var _loc2_ = _root.pause_mc.inside_mc.content_mc.contentInside_mc.mapInside_mc;
  1040.       _loc2_.clear();
  1041.       for(var _loc3_ in _loc2_)
  1042.       {
  1043.          if(_loc2_[_loc3_]._name != "map_mc")
  1044.          {
  1045.             _loc2_[_loc3_].removeMovieClip();
  1046.          }
  1047.       }
  1048.    }
  1049.    function SetupStats()
  1050.    {
  1051.       var _loc4_ = _root.pause_mc.inside_mc.content_mc.contentInside_mc;
  1052.       _loc4_.stateName_txt.text = this.upgradePath.currentNode.nodeData._name;
  1053.       _loc4_.stateDescription_txt.text = this.upgradePath.currentNode.nodeData._description;
  1054.       _loc4_.primary_txt.text = this.upgradePath.currentNode.nodeData._primary;
  1055.       _loc4_.primaryDescription_txt.text = this.upgradePath.currentNode.nodeData._primaryDescription;
  1056.       _loc4_.secondary_txt.text = this.upgradePath.currentNode.nodeData._secondary;
  1057.       _loc4_.secondaryDescription_txt.text = this.upgradePath.currentNode.nodeData._secondaryDescription;
  1058.       _loc4_.enemiesKilled_txt.text = this.intEnemiesKilled;
  1059.       _loc4_.bubblesCollected_txt.text = this.intBubblesCollected;
  1060.       _loc4_.icon_mc.enemyImage.attachMovie("avatar","currentShownEnemy",200);
  1061.       var _loc3_ = _loc4_.icon_mc.enemyImage.currentShownEnemy;
  1062.       _loc3_.gotoAndStop(this.upgradePath.currentNode.nodeData._id);
  1063.       if(this.upgradePath.currentNode.nodeData._id != 1 && this.upgradePath.currentNode.nodeData._id != 21)
  1064.       {
  1065.          _loc3_.gun.gotoAndStop(50);
  1066.       }
  1067.       var _loc5_ = undefined;
  1068.       if(_loc3_._width > 105 || _loc3_._height > 105)
  1069.       {
  1070.          if(_loc3_._width > _loc3_._height)
  1071.          {
  1072.             _loc5_ = 105 / _loc3_._width;
  1073.          }
  1074.          else if(_loc3_._width == _loc3_._height)
  1075.          {
  1076.             _loc5_ = 105 / _loc3_._width;
  1077.          }
  1078.          else
  1079.          {
  1080.             _loc5_ = 105 / _loc3_._height;
  1081.          }
  1082.          _loc3_._width *= _loc5_;
  1083.          _loc3_._height *= _loc5_;
  1084.       }
  1085.       _loc3_.TurnOff();
  1086.       _loc3_._x = 38;
  1087.       _loc3_._y = 34;
  1088.    }
  1089.    function ControlInterface()
  1090.    {
  1091.       if(this.upgradePath.currentNode.nodeData._maxPoints == 999999)
  1092.       {
  1093.          _root.life.inside._xscale = 100;
  1094.          _root.life.left_txt.text = "Max Tank Size";
  1095.          _root.life.state_txt.text = this.upgradePath.currentNode.nodeData._name;
  1096.       }
  1097.       else
  1098.       {
  1099.          var _loc4_ = undefined;
  1100.          var _loc3_ = undefined;
  1101.          if(this.upgradePath.currentNode.nodeData._maxPoints - this.upgradePath.currentNode.nodeData._minPoints != 0)
  1102.          {
  1103.             _loc4_ = (this.avatarLife.Get() - this.upgradePath.currentNode.nodeData._minPoints) / (this.upgradePath.currentNode.nodeData._maxPoints - this.upgradePath.currentNode.nodeData._minPoints);
  1104.             _loc3_ = this.upgradePath.currentNode.nodeData._maxPoints - this.avatarLife.Get();
  1105.          }
  1106.          else
  1107.          {
  1108.             _loc4_ = 1;
  1109.             _loc3_ = 0;
  1110.          }
  1111.          _loc3_ = _loc3_ + 1;
  1112.          _root.life.inside._xscale = Math.round(_loc4_ * 100);
  1113.          _root.life.left_txt.text = _loc3_ + " Bubbles Left";
  1114.          _root.life.state_txt.text = this.upgradePath.currentNode.nodeData._name;
  1115.       }
  1116.       if((this.intLifeState == 3 || this.intLifeState == 1) && this.blnLifeFlag == true)
  1117.       {
  1118.          this.intLifeState = 2;
  1119.       }
  1120.       else if(this.intLifeState == 4)
  1121.       {
  1122.          if(this.intLifeCounter == 1)
  1123.          {
  1124.             this.intLifeState = 1;
  1125.          }
  1126.          if(this.intLifeCounter > 0)
  1127.          {
  1128.             this.intLifeCounter = this.intLifeCounter - 1;
  1129.          }
  1130.          if(this.blnLifeFlag == true)
  1131.          {
  1132.             this.intLifeCounter = 75;
  1133.             if(this.intFireRateCounter > 1)
  1134.             {
  1135.                this.intFireRateCounter = 75;
  1136.             }
  1137.          }
  1138.       }
  1139.       switch(this.intLifeState)
  1140.       {
  1141.          case 1:
  1142.             var _loc5_ = this.intMaxLow - _root.life._y;
  1143.             if(_loc5_ < 2)
  1144.             {
  1145.                _root.life._y = this.intMaxLow;
  1146.                this.intLifeState = 3;
  1147.             }
  1148.             else
  1149.             {
  1150.                _root.life._y += 0.2 * _loc5_;
  1151.             }
  1152.             break;
  1153.          case 2:
  1154.             _loc5_ = _root.life._y - this.intMaxHigh;
  1155.             if(_loc5_ < 2)
  1156.             {
  1157.                _root.life._y = this.intMaxHigh;
  1158.                this.intLifeState = 4;
  1159.                this.intLifeCounter = 75;
  1160.                if(this.intFireRateCounter > 1)
  1161.                {
  1162.                   this.intFireRateCounter = 75;
  1163.                }
  1164.             }
  1165.             else
  1166.             {
  1167.                _root.life._y -= 0.2 * _loc5_;
  1168.             }
  1169.       }
  1170.       this.blnLifeFlag = false;
  1171.    }
  1172.    function ControlFireRateInterface()
  1173.    {
  1174.       var _loc3_ = 1;
  1175.       _loc3_ = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[0].delay;
  1176.       var _loc5_ = Math.round((1 - this.intPrimaryCounter / _loc3_) * 100);
  1177.       _root.fireRate_mc.insidePrimary_mc._xscale = _loc5_;
  1178.       if(this.upgradePath.currentNode.nodeData._arrSecondaryWeapons.length == 0)
  1179.       {
  1180.          _root.fireRate_mc.insideSecondary_mc._xscale = 0.1;
  1181.       }
  1182.       else
  1183.       {
  1184.          _loc3_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[0].delay;
  1185.          var _loc6_ = Math.round((1 - this.intSecondaryCounter / _loc3_) * 100);
  1186.          _root.fireRate_mc.insideSecondary_mc._xscale = _loc6_;
  1187.       }
  1188.       if((this.intFireRateState == 3 || this.intFireRateState == 1) && this.blnFireRateFlag == true)
  1189.       {
  1190.          this.intFireRateState = 2;
  1191.       }
  1192.       else if(this.intFireRateState == 4)
  1193.       {
  1194.          if(this.intFireRateCounter == 1)
  1195.          {
  1196.             this.intFireRateState = 1;
  1197.          }
  1198.          if(this.intFireRateCounter > 0)
  1199.          {
  1200.             this.intFireRateCounter = this.intFireRateCounter - 1;
  1201.          }
  1202.          if(this.blnFireRateFlag == true)
  1203.          {
  1204.             this.intFireRateCounter = 75;
  1205.             if(this.intLifeCounter > 1)
  1206.             {
  1207.                this.intLifeCounter = 75;
  1208.             }
  1209.          }
  1210.       }
  1211.       switch(this.intFireRateState)
  1212.       {
  1213.          case 1:
  1214.             var _loc4_ = _root.fireRate_mc._y - this.intFireRateMaxHigh;
  1215.             if(_loc4_ < 2)
  1216.             {
  1217.                _root.fireRate_mc._y = this.intFireRateMaxHigh;
  1218.                this.intFireRateState = 3;
  1219.             }
  1220.             else
  1221.             {
  1222.                _root.fireRate_mc._y -= 0.2 * _loc4_;
  1223.             }
  1224.             break;
  1225.          case 2:
  1226.             _loc4_ = this.intFireRateMaxLow - _root.fireRate_mc._y;
  1227.             if(_loc4_ < 2)
  1228.             {
  1229.                _root.fireRate_mc._y = this.intFireRateMaxLow;
  1230.                this.intFireRateState = 4;
  1231.                this.intFireRateCounter = 75;
  1232.                if(this.intLifeCounter > 1)
  1233.                {
  1234.                   this.intLifeCounter = 75;
  1235.                }
  1236.             }
  1237.             else
  1238.             {
  1239.                _root.fireRate_mc._y += 0.2 * _loc4_;
  1240.             }
  1241.       }
  1242.       this.blnFireRateFlag = false;
  1243.    }
  1244.    function CheckUpgradeState()
  1245.    {
  1246.       if(this.avatarLife.Get() > this.upgradePath.currentNode.nodeData._maxPoints)
  1247.       {
  1248.          if(this.upgradePath.UpgradeAlreadySelected() == false)
  1249.          {
  1250.             this.blnWaitingToUpgrade = true;
  1251.             this.UpgradePause();
  1252.          }
  1253.          else
  1254.          {
  1255.             this.intPrimaryCounter = 0;
  1256.             this.intSecondaryCounter = 0;
  1257.             this.intAutoCounter = 0;
  1258.             _root.avatar.gotoAndStop(this.upgradePath.currentNode.nodeData._id);
  1259.          }
  1260.       }
  1261.       else if(this.avatarLife.Get() < this.upgradePath.currentNode.nodeData._minPoints)
  1262.       {
  1263.          if(this.upgradePath.currentNode.nodeData._id != 1)
  1264.          {
  1265.             if(this.upgradePath.currentNode.nodeData._id == 26)
  1266.             {
  1267.                this.DowngradeRemoveFighters();
  1268.             }
  1269.             this.intPrimaryCounter = 0;
  1270.             this.intSecondaryCounter = 0;
  1271.             this.upgradePath.DownGrade();
  1272.             _root.avatar.gotoAndStop(this.upgradePath.currentNode.nodeData._id);
  1273.             this.intJumpsAsMax = 0;
  1274.          }
  1275.       }
  1276.       var _loc3_ = this.avatarLife.Get() - this.upgradePath.currentNode.nodeData._minPoints;
  1277.       if(this.upgradePath.currentNode.nodeData._id < 21)
  1278.       {
  1279.          _root.avatar.gun.gotoAndStop(_loc3_);
  1280.       }
  1281.       this.ScaleMiniBubble();
  1282.    }
  1283.    function DowngradeRemoveFighters()
  1284.    {
  1285.       var _loc4_ = this.arrAllies.slice();
  1286.       var _loc3_ = 0;
  1287.       while(_loc3_ < _loc4_.length)
  1288.       {
  1289.          this.Effect_PierceExplosion(_root[_loc4_[_loc3_]]._x,_root[_loc4_[_loc3_]]._y);
  1290.          _root[_loc4_[_loc3_]].Dock();
  1291.          _loc3_ = _loc3_ + 1;
  1292.       }
  1293.    }
  1294.    function UpgradeChosen(buttonName)
  1295.    {
  1296.       if(this.blnWaitingToUpgrade == true)
  1297.       {
  1298.          if(getTimer() - this.intUpgradeDelay > 1200)
  1299.          {
  1300.             var _loc4_ = this.upgradePath.currentNode.GetNumChildren();
  1301.             this.upgradePath.Upgrade(buttonName);
  1302.             this.blnWaitingToUpgrade = false;
  1303.             this.intPrimaryCounter = 0;
  1304.             this.intSecondaryCounter = 0;
  1305.             if(this.intTutorialState == 1)
  1306.             {
  1307.                if(this.upgradePath.currentNode.nodeData._id >= 5)
  1308.                {
  1309.                   this.intTutorialState = 2;
  1310.                }
  1311.             }
  1312.             if(_global.gameMode == 1)
  1313.             {
  1314.                if(this.IsAvatarLocked(this.upgradePath.currentNode.nodeData._id) == true)
  1315.                {
  1316.                   _global.encounteredStates.push(this.upgradePath.currentNode.nodeData._id);
  1317.                   this.mySharedObject.data.statesList = _global.encounteredStates;
  1318.                   this.mySharedObject.flush();
  1319.                }
  1320.             }
  1321.             if(_loc4_ == 3)
  1322.             {
  1323.                _root.pause_mc.gotoAndPlay("upgradeThreeComplete");
  1324.             }
  1325.             else if(_loc4_ == 2)
  1326.             {
  1327.                _root.pause_mc.gotoAndPlay("upgradeTwoComplete");
  1328.             }
  1329.             this.upgradePath.currentNode.nodeData._selected = true;
  1330.             _root.avatar.gotoAndStop(this.upgradePath.currentNode.nodeData._id);
  1331.             this.CheckUpgradeState();
  1332.          }
  1333.       }
  1334.    }
  1335.    function SetupUpgradeButtons(screenRef, numButtons)
  1336.    {
  1337.       var _loc4_ = undefined;
  1338.       var _loc5_ = undefined;
  1339.       var _loc7_ = undefined;
  1340.       var _loc9_ = undefined;
  1341.       var _loc8_ = undefined;
  1342.       this.upgradePath.currentNode.Reset();
  1343.       _loc5_ = this.upgradePath.currentNode.GetChild();
  1344.       _loc4_ = screenRef.first_mc;
  1345.       _loc4_.title_txt.text = _loc5_.nodeData._name;
  1346.       _loc4_.primary_txt.text = _loc5_.nodeData._primary;
  1347.       _loc4_.secondary_txt.text = _loc5_.nodeData._secondary;
  1348.       _loc7_ = _loc5_.nodeData._locked;
  1349.       if(_global.doUnlockEC.Get() != -1 || _loc5_.nodeData._locked == false)
  1350.       {
  1351.          _loc4_.description_txt.text = _loc5_.nodeData._description;
  1352.          _loc4_.locked_mc.gotoAndStop(1);
  1353.          _loc4_.lockedText_mc.gotoAndStop(1);
  1354.       }
  1355.       else
  1356.       {
  1357.          _loc4_.description_txt.text = "Only available on ArmorGames.com.  Click to play the Extra Content version!";
  1358.          _loc4_.locked_mc.gotoAndStop(2);
  1359.          _loc4_.lockedText_mc.gotoAndStop(2);
  1360.       }
  1361.       this.upgradePath.currentNode.NextChild();
  1362.       _loc5_ = this.upgradePath.currentNode.GetChild();
  1363.       _loc4_ = screenRef.second_mc;
  1364.       _loc4_.title_txt.text = _loc5_.nodeData._name;
  1365.       _loc4_.primary_txt.text = _loc5_.nodeData._primary;
  1366.       _loc4_.secondary_txt.text = _loc5_.nodeData._secondary;
  1367.       _loc9_ = _loc5_.nodeData._locked;
  1368.       if(_global.doUnlockEC.Get() != -1 || _loc5_.nodeData._locked == false)
  1369.       {
  1370.          _loc4_.description_txt.text = _loc5_.nodeData._description;
  1371.          _loc4_.locked_mc.gotoAndStop(1);
  1372.          _loc4_.lockedText_mc.gotoAndStop(1);
  1373.       }
  1374.       else
  1375.       {
  1376.          _loc4_.description_txt.text = "Only available on ArmorGames.com.  Click to play the Extra Content version!";
  1377.          _loc4_.locked_mc.gotoAndStop(2);
  1378.          _loc4_.lockedText_mc.gotoAndStop(2);
  1379.       }
  1380.       if(numButtons == 3)
  1381.       {
  1382.          this.upgradePath.currentNode.NextChild();
  1383.          _loc5_ = this.upgradePath.currentNode.GetChild();
  1384.          _loc4_ = screenRef.third_mc;
  1385.          _loc4_.title_txt.text = _loc5_.nodeData._name;
  1386.          _loc4_.primary_txt.text = _loc5_.nodeData._primary;
  1387.          _loc4_.secondary_txt.text = _loc5_.nodeData._secondary;
  1388.          _loc8_ = _loc5_.nodeData._locked;
  1389.          if(_global.doUnlockEC.Get() != -1 || _loc5_.nodeData._locked == false)
  1390.          {
  1391.             _loc4_.description_txt.text = _loc5_.nodeData._description;
  1392.             _loc4_.locked_mc.gotoAndStop(1);
  1393.             _loc4_.lockedText_mc.gotoAndStop(1);
  1394.          }
  1395.          else
  1396.          {
  1397.             _loc4_.description_txt.text = "Only available on ArmorGames.com.  Click to play the Extra Content version!";
  1398.             _loc4_.locked_mc.gotoAndStop(2);
  1399.             _loc4_.lockedText_mc.gotoAndStop(2);
  1400.          }
  1401.       }
  1402.       _loc4_ = screenRef.first_mc;
  1403.       _loc4_.onRollOver = function()
  1404.       {
  1405.          this.gotoAndStop(2);
  1406.       };
  1407.       _loc4_.onRollOut = function()
  1408.       {
  1409.          this.gotoAndStop(1);
  1410.       };
  1411.       if(_global.doUnlockEC.Get() != -1 || _loc7_ == false)
  1412.       {
  1413.          _loc4_.onRelease = function()
  1414.          {
  1415.             _root.game.UpgradeChosen("first_mc");
  1416.          };
  1417.       }
  1418.       else
  1419.       {
  1420.          _loc4_.onRelease = function()
  1421.          {
  1422.             getUrl("http://www.herointeractive.com/BT2_Transfer.php?intID=3", "_blank");
  1423.          };
  1424.       }
  1425.       _loc4_ = screenRef.second_mc;
  1426.       _loc4_.onRollOver = function()
  1427.       {
  1428.          this.gotoAndStop(2);
  1429.       };
  1430.       _loc4_.onRollOut = function()
  1431.       {
  1432.          this.gotoAndStop(1);
  1433.       };
  1434.       if(_global.doUnlockEC.Get() != -1 || _loc9_ == false)
  1435.       {
  1436.          _loc4_.onRelease = function()
  1437.          {
  1438.             _root.game.UpgradeChosen("second_mc");
  1439.          };
  1440.       }
  1441.       else
  1442.       {
  1443.          _loc4_.onRelease = function()
  1444.          {
  1445.             getUrl("http://www.herointeractive.com/BT2_Transfer.php?intID=3", "_blank");
  1446.          };
  1447.       }
  1448.       if(numButtons == 3)
  1449.       {
  1450.          _loc4_ = screenRef.third_mc;
  1451.          _loc4_.onRollOver = function()
  1452.          {
  1453.             this.gotoAndStop(2);
  1454.          };
  1455.          _loc4_.onRollOut = function()
  1456.          {
  1457.             this.gotoAndStop(1);
  1458.          };
  1459.          if(_global.doUnlockEC.Get() != -1 || _loc8_ == false)
  1460.          {
  1461.             _loc4_.onRelease = function()
  1462.             {
  1463.                _root.game.UpgradeChosen("third_mc");
  1464.             };
  1465.          }
  1466.          else
  1467.          {
  1468.             _loc4_.onRelease = function()
  1469.             {
  1470.                getUrl("http://www.herointeractive.com/BT2_Transfer.php?intID=3", "_blank");
  1471.             };
  1472.          }
  1473.       }
  1474.       this.intUpgradeDelay = getTimer();
  1475.    }
  1476.    function RemoveBullet(strName)
  1477.    {
  1478.       var _loc4_ = 0;
  1479.       while(_loc4_ < this.arrBullets.length)
  1480.       {
  1481.          if(strName == this.arrBullets[_loc4_])
  1482.          {
  1483.             if(_root[this.arrBullets[_loc4_]]._type == 8)
  1484.             {
  1485.                var _loc3_ = 0;
  1486.                while(_loc3_ < this.arrBulletBusters.length)
  1487.                {
  1488.                   if(this.arrBulletBusters[_loc3_] == strName)
  1489.                   {
  1490.                      this.arrBulletBusters.splice(_loc3_,1);
  1491.                      break;
  1492.                   }
  1493.                   _loc3_ = _loc3_ + 1;
  1494.                }
  1495.             }
  1496.             this.arrBullets.splice(_loc4_,1);
  1497.             break;
  1498.          }
  1499.          _loc4_ = _loc4_ + 1;
  1500.       }
  1501.    }
  1502.    function CleanupBullets()
  1503.    {
  1504.       var _loc3_ = 0;
  1505.       while(_loc3_ < this.arrBullets.length)
  1506.       {
  1507.          if(_root[this.arrBullets[_loc3_]]._type == 8)
  1508.          {
  1509.             _root[this.arrBullets[_loc3_]].CleanupBusted();
  1510.          }
  1511.          _root[this.arrBullets[_loc3_]].removeMovieClip();
  1512.          _loc3_ = _loc3_ + 1;
  1513.       }
  1514.       delete this.arrBullets;
  1515.       this.arrBullets = new Array();
  1516.    }
  1517.    function DropPickupBubbles(num2Drop, origin, myPower, myType)
  1518.    {
  1519.       var _loc4_ = 0;
  1520.       while(_loc4_ < num2Drop)
  1521.       {
  1522.          var _loc3_ = "pickup_bubbles_" + this.arrFloatingBubblesDepth;
  1523.          this.arrFloatingBubbles.push(_loc3_);
  1524.          if(myType == 3)
  1525.          {
  1526.             _root.attachMovie("pickup_bubble_ultra",_loc3_,this.arrFloatingBubblesDepth);
  1527.          }
  1528.          else if(myType == 2)
  1529.          {
  1530.             _root.attachMovie("pickup_bubble_large",_loc3_,this.arrFloatingBubblesDepth);
  1531.          }
  1532.          else
  1533.          {
  1534.             _root.attachMovie("pickup_bubble",_loc3_,this.arrFloatingBubblesDepth);
  1535.          }
  1536.          _root[_loc3_]._x = origin._x;
  1537.          _root[_loc3_]._y = origin._y;
  1538.          _root[_loc3_].DetermineRandomMovement(myPower);
  1539.          this.arrFloatingBubblesDepth = this.arrFloatingBubblesDepth + 1;
  1540.          if(this.arrFloatingBubblesDepth == 899)
  1541.          {
  1542.             this.arrFloatingBubblesDepth = 700;
  1543.          }
  1544.          _loc4_ = _loc4_ + 1;
  1545.       }
  1546.    }
  1547.    function LeachPickupBubbles(origin)
  1548.    {
  1549.       var _loc3_ = "pickup_bubbles_" + this.arrFloatingBubblesDepth;
  1550.       this.arrFloatingBubbles.push(_loc3_);
  1551.       _root.attachMovie("pickup_bubble",_loc3_,this.arrFloatingBubblesDepth);
  1552.       _root[_loc3_]._x = origin._x;
  1553.       _root[_loc3_]._y = origin._y;
  1554.       _root[_loc3_]._type = 2;
  1555.       this.arrFloatingBubblesDepth = this.arrFloatingBubblesDepth + 1;
  1556.       if(this.arrFloatingBubblesDepth == 899)
  1557.       {
  1558.          this.arrFloatingBubblesDepth = 700;
  1559.       }
  1560.    }
  1561.    function MovePickupBubbles(dirVector)
  1562.    {
  1563.       var _loc3_ = 0;
  1564.       while(_loc3_ < this.arrFloatingBubbles.length)
  1565.       {
  1566.          _root[this.arrFloatingBubbles[_loc3_]]._x += dirVector._x;
  1567.          _root[this.arrFloatingBubbles[_loc3_]]._y += dirVector._y;
  1568.          _loc3_ = _loc3_ + 1;
  1569.       }
  1570.    }
  1571.    function CleanPickupBubbles()
  1572.    {
  1573.       var _loc3_ = 0;
  1574.       while(_loc3_ < this.arrFloatingBubbles.length)
  1575.       {
  1576.          _root[this.arrFloatingBubbles[_loc3_]].removeMovieClip();
  1577.          _loc3_ = _loc3_ + 1;
  1578.       }
  1579.       delete this.arrFloatingBubbles;
  1580.       this.arrFloatingBubbles = new Array();
  1581.    }
  1582.    function GetBubbleDistance(myName)
  1583.    {
  1584.       var _loc3_ = _root[myName]._x - _root.avatar._x;
  1585.       var _loc2_ = _root[myName]._y - _root.avatar._y;
  1586.       return Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
  1587.    }
  1588.    function CheckPickupBubbleCollection()
  1589.    {
  1590.       var _loc10_ = 6;
  1591.       var _loc6_ = 0;
  1592.       while(_loc6_ < this.arrFloatingBubbles.length)
  1593.       {
  1594.          var _loc5_ = this.GetBubbleDistance(this.arrFloatingBubbles[_loc6_]);
  1595.          var _loc4_ = _root.avatar._width + 30;
  1596.          if(this.blnEnemiesCleared == true)
  1597.          {
  1598.             _loc4_ = _root.bg.inside._width + 25;
  1599.             _loc10_ = 10;
  1600.          }
  1601.          if(_root[this.arrFloatingBubbles[_loc6_]]._type == 2)
  1602.          {
  1603.             _loc4_ = _root.bg.inside._width;
  1604.          }
  1605.          if(_loc5_ <= _loc4_)
  1606.          {
  1607.             var _loc9_ = (_loc4_ - _loc5_) / _loc4_ * _loc10_;
  1608.             var _loc7_ = new Vector();
  1609.             _loc7_._x = (_root[this.arrFloatingBubbles[_loc6_]]._x - _root.avatar._x) / _loc5_ * _loc9_;
  1610.             _loc7_._y = (_root[this.arrFloatingBubbles[_loc6_]]._y - _root.avatar._y) / _loc5_ * _loc9_;
  1611.             _root[this.arrFloatingBubbles[_loc6_]]._x -= _loc7_._x;
  1612.             _root[this.arrFloatingBubbles[_loc6_]]._y -= _loc7_._y;
  1613.          }
  1614.          _loc6_ = _loc6_ + 1;
  1615.       }
  1616.       var _loc8_ = new Array();
  1617.       var _loc11_ = false;
  1618.       _loc6_ = 0;
  1619.       while(_loc6_ < this.arrFloatingBubbles.length)
  1620.       {
  1621.          if(_root.avatar.hitTest(_root[this.arrFloatingBubbles[_loc6_]]._x,_root[this.arrFloatingBubbles[_loc6_]]._y,true))
  1622.          {
  1623.             this.avatarLife.Set(this.avatarLife.Get() + _root[this.arrFloatingBubbles[_loc6_]]._amount);
  1624.             if(this.avatarLife.Get() > this.maxAvatarLife)
  1625.             {
  1626.                this.maxAvatarLife = this.avatarLife.Get();
  1627.             }
  1628.             _loc8_.push(this.arrFloatingBubbles[_loc6_]);
  1629.             _loc11_ = true;
  1630.             this.blnLifeFlag = true;
  1631.             this.intBubblesCollected = this.intBubblesCollected + 1;
  1632.             _global.SoundManager.PlayBubbleSound("collect_2");
  1633.          }
  1634.          _loc6_ = _loc6_ + 1;
  1635.       }
  1636.       if(_loc11_ == true)
  1637.       {
  1638.          this.CheckUpgradeState();
  1639.       }
  1640.       _loc6_ = 0;
  1641.       while(_loc6_ < _loc8_.length)
  1642.       {
  1643.          this.RemovePickupBubble(_loc8_[_loc6_]);
  1644.          _root[_loc8_[_loc6_]].removeMovieClip();
  1645.          _loc6_ = _loc6_ + 1;
  1646.       }
  1647.    }
  1648.    function RemovePickupBubble(strName)
  1649.    {
  1650.       var _loc2_ = 0;
  1651.       while(_loc2_ < this.arrFloatingBubbles.length)
  1652.       {
  1653.          if(strName == this.arrFloatingBubbles[_loc2_])
  1654.          {
  1655.             this.arrFloatingBubbles.splice(_loc2_,1);
  1656.             break;
  1657.          }
  1658.          _loc2_ = _loc2_ + 1;
  1659.       }
  1660.    }
  1661.    function AvatarHit(numDamage)
  1662.    {
  1663.       if(this.transitionState == 0)
  1664.       {
  1665.          if(_global.invincible == false)
  1666.          {
  1667.             this.avatarLife.Set(this.avatarLife.Get() - Math.round(numDamage * 3));
  1668.             if(this.avatarLife.Get() > 0)
  1669.             {
  1670.                this.CheckUpgradeState();
  1671.             }
  1672.             if(this.avatarLife.Get() <= 0)
  1673.             {
  1674.                this.avatarLife.Set(1);
  1675.                this.CheckUpgradeState();
  1676.                _global.SoundManager.PlaySound("dead");
  1677.                this.EjectFromBubblefield();
  1678.             }
  1679.          }
  1680.       }
  1681.    }
  1682.    function CheckBulletCollision()
  1683.    {
  1684.       var _loc4_ = new Array();
  1685.       var _loc7_ = new Array();
  1686.       var _loc6_ = 0;
  1687.       while(_loc6_ < this.arrBullets.length)
  1688.       {
  1689.          if(_root[this.arrBullets[_loc6_]]._enemy == false)
  1690.          {
  1691.             if(_root[this.arrBullets[_loc6_]]._type != 8)
  1692.             {
  1693.                if(this.world.current.CheckForHits(this.arrBullets[_loc6_]))
  1694.                {
  1695.                   _global.SoundManager.PlaySound("hit");
  1696.                   _loc4_.push(this.arrBullets[_loc6_]);
  1697.                }
  1698.             }
  1699.          }
  1700.          else
  1701.          {
  1702.             if(this.transitionState == 0)
  1703.             {
  1704.                if(this.intAssembledState == 0)
  1705.                {
  1706.                   var _loc9_ = true;
  1707.                   if(this.intShieldCounter > 0)
  1708.                   {
  1709.                      var _loc8_ = new Vector();
  1710.                      _loc8_._x = _root[this.arrBullets[_loc6_]]._x - _root.avatar._x;
  1711.                      _loc8_._y = _root[this.arrBullets[_loc6_]]._y - _root.avatar._y;
  1712.                      var _loc12_ = _loc8_.GetLength();
  1713.                      if(_loc12_ <= this.intShieldWidth)
  1714.                      {
  1715.                         var _loc13_ = _loc8_.GetAngle();
  1716.                         var _loc10_ = new Vector();
  1717.                         _loc10_._x = 250;
  1718.                         _loc10_._y = 200;
  1719.                         _root[this.CreateEffect("shieldHit",_loc10_,true,"avatar")]._rotation = _loc13_;
  1720.                         _loc4_.push(this.arrBullets[_loc6_]);
  1721.                         _loc9_ = false;
  1722.                      }
  1723.                   }
  1724.                   if(_loc9_ == true)
  1725.                   {
  1726.                      if(_root.avatar.hitTest(_root[this.arrBullets[_loc6_]]._x,_root[this.arrBullets[_loc6_]]._y,true))
  1727.                      {
  1728.                         if(this.arrBullets[_loc6_].substr(1,11) == "enemySticky")
  1729.                         {
  1730.                            this.stickyCounter = 160;
  1731.                            _root.avatar.gun.effects.gotoAndStop("sticky");
  1732.                         }
  1733.                         if(_global.invincible == false)
  1734.                         {
  1735.                            var _loc11_ = _root[this.arrBullets[_loc6_]]._damage;
  1736.                            if(this.upgradePath.currentNode.nodeData._turnMode == 2)
  1737.                            {
  1738.                               _loc11_ = Math.round(_loc11_ * 0.3);
  1739.                            }
  1740.                            this.avatarLife.Set(this.avatarLife.Get() - _loc11_);
  1741.                         }
  1742.                         if(this.avatarLife.Get() > 0)
  1743.                         {
  1744.                            this.CheckUpgradeState();
  1745.                         }
  1746.                         if(this.avatarLife.Get() <= 0)
  1747.                         {
  1748.                            this.avatarLife.Set(1);
  1749.                            this.CheckUpgradeState();
  1750.                            _global.SoundManager.PlaySound("dead");
  1751.                            this.EjectFromBubblefield();
  1752.                            _loc4_.push(this.arrBullets[_loc6_]);
  1753.                            break;
  1754.                         }
  1755.                         _global.SoundManager.PlaySound("avatar_hit");
  1756.                         _loc4_.push(this.arrBullets[_loc6_]);
  1757.                      }
  1758.                   }
  1759.                }
  1760.             }
  1761.             if(_loc9_ == true)
  1762.             {
  1763.                var _loc5_ = 0;
  1764.                while(_loc5_ < this.arrAllySeekers.length)
  1765.                {
  1766.                   if(_root[this.arrAllySeekers[_loc5_].name].hitTest(_root[this.arrBullets[_loc6_]]._x,_root[this.arrBullets[_loc6_]]._y,true))
  1767.                   {
  1768.                      _root[this.arrAllySeekers[_loc5_].name].removeMovieClip();
  1769.                      this.arrAllySeekers.splice(_loc5_,1);
  1770.                      _loc5_ = _loc5_ - 1;
  1771.                      _loc4_.push(this.arrBullets[_loc6_]);
  1772.                   }
  1773.                   _loc5_ = _loc5_ + 1;
  1774.                }
  1775.                if(_root[this.arrBullets[_loc6_]]._type != 8)
  1776.                {
  1777.                   _loc5_ = 0;
  1778.                   while(_loc5_ < this.arrBulletBusters.length)
  1779.                   {
  1780.                      if(_root[this.arrBulletBusters[_loc5_]].hitTest(_root[this.arrBullets[_loc6_]]._x,_root[this.arrBullets[_loc6_]]._y,true))
  1781.                      {
  1782.                         _root[this.arrBulletBusters[_loc5_]].AddBusted(this.arrBullets[_loc6_]);
  1783.                         _loc7_.push(this.arrBullets[_loc6_]);
  1784.                      }
  1785.                      else if(_root[this.arrBulletBusters[_loc5_]].hitTest(_root[this.arrBullets[_loc6_]].halfX,_root[this.arrBullets[_loc6_]].halfY,true))
  1786.                      {
  1787.                         _root[this.arrBulletBusters[_loc5_]].AddBusted(this.arrBullets[_loc6_]);
  1788.                         _loc7_.push(this.arrBullets[_loc6_]);
  1789.                      }
  1790.                      _loc5_ = _loc5_ + 1;
  1791.                   }
  1792.                }
  1793.             }
  1794.          }
  1795.          _loc6_ = _loc6_ + 1;
  1796.       }
  1797.       _loc6_ = 0;
  1798.       while(_loc6_ < _loc7_.length)
  1799.       {
  1800.          this.RemoveBullet(_loc7_[_loc6_]);
  1801.          _loc6_ = _loc6_ + 1;
  1802.       }
  1803.       _loc6_ = 0;
  1804.       while(_loc6_ < _loc4_.length)
  1805.       {
  1806.          if(_root[_loc4_[_loc6_]]._type != 2 && _root[_loc4_[_loc6_]]._type != 6 && _root[_loc4_[_loc6_]]._type != 7)
  1807.          {
  1808.             _root[_loc4_[_loc6_]]._holdMovement = true;
  1809.             _root[_loc4_[_loc6_]].gotoAndPlay("hit");
  1810.             this.AddToCleanup(_loc4_[_loc6_]);
  1811.             this.RemoveBullet(_loc4_[_loc6_]);
  1812.          }
  1813.          else
  1814.          {
  1815.             this.Effect_PierceExplosion(_root[_loc4_[_loc6_]]._x,_root[_loc4_[_loc6_]]._y);
  1816.             _root[_loc4_[_loc6_]]._damage -= 1;
  1817.             if(_root[_loc4_[_loc6_]]._damage < 1)
  1818.             {
  1819.                _root[_loc4_[_loc6_]]._damage = 1;
  1820.             }
  1821.          }
  1822.          _loc6_ = _loc6_ + 1;
  1823.       }
  1824.    }
  1825.    function EjectFromBubblefield()
  1826.    {
  1827.       var _loc5_ = 4;
  1828.       var _loc6_ = undefined;
  1829.       var _loc3_ = undefined;
  1830.       var _loc10_ = this.world.GetUp(false);
  1831.       var _loc9_ = this.world.GetLeft(false);
  1832.       var _loc7_ = this.world.GetDown(false);
  1833.       var _loc8_ = this.world.GetRight(false);
  1834.       _loc3_ = this.world.GetUp(true);
  1835.       _loc6_ = _loc3_.EstimateDifficulty();
  1836.       _loc3_ = this.world.GetLeft(true);
  1837.       if(_loc3_.EstimateDifficulty() < _loc6_)
  1838.       {
  1839.          _loc6_ = _loc3_.EstimateDifficulty();
  1840.          _loc5_ = 3;
  1841.       }
  1842.       _loc3_ = this.world.GetDown(true);
  1843.       if(_loc3_.EstimateDifficulty() < _loc6_)
  1844.       {
  1845.          _loc6_ = _loc3_.EstimateDifficulty();
  1846.          _loc5_ = 2;
  1847.       }
  1848.       _loc3_ = this.world.GetRight(true);
  1849.       if(_loc3_.EstimateDifficulty() < _loc6_)
  1850.       {
  1851.          _loc6_ = _loc3_.EstimateDifficulty();
  1852.          _loc5_ = 1;
  1853.       }
  1854.       var _loc2_ = new Vector();
  1855.       var _loc4_ = undefined;
  1856.       if(_loc5_ == 4)
  1857.       {
  1858.          if(_loc10_ == undefined)
  1859.          {
  1860.             _loc4_ = true;
  1861.          }
  1862.          else
  1863.          {
  1864.             _loc4_ = false;
  1865.          }
  1866.          this.world.MoveUp();
  1867.          _loc2_._y = -1147.6;
  1868.          this.world.current.ShowAllUnits(_loc2_);
  1869.          if(this.world.current.blnBoss == true)
  1870.          {
  1871.             this.ShowBoss(_loc2_);
  1872.          }
  1873.          this.MoveAvatarToBubble("destTop");
  1874.          this.transitionState = 4;
  1875.       }
  1876.       else if(_loc5_ == 3)
  1877.       {
  1878.          if(_loc9_ == undefined)
  1879.          {
  1880.             _loc4_ = true;
  1881.          }
  1882.          else
  1883.          {
  1884.             _loc4_ = false;
  1885.          }
  1886.          this.world.MoveLeft();
  1887.          _loc2_._x = -1147.6;
  1888.          this.world.current.ShowAllUnits(_loc2_);
  1889.          if(this.world.current.blnBoss == true)
  1890.          {
  1891.             this.ShowBoss(_loc2_);
  1892.          }
  1893.          this.MoveAvatarToBubble("destLeft");
  1894.          this.transitionState = 3;
  1895.       }
  1896.       else if(_loc5_ == 2)
  1897.       {
  1898.          if(_loc7_ == undefined)
  1899.          {
  1900.             _loc4_ = true;
  1901.          }
  1902.          else
  1903.          {
  1904.             _loc4_ = false;
  1905.          }
  1906.          this.world.MoveDown();
  1907.          _loc2_._y = 1147.6;
  1908.          this.world.current.ShowAllUnits(_loc2_);
  1909.          if(this.world.current.blnBoss == true)
  1910.          {
  1911.             this.ShowBoss(_loc2_);
  1912.          }
  1913.          this.MoveAvatarToBubble("destBottom");
  1914.          this.transitionState = 2;
  1915.       }
  1916.       else if(_loc5_ == 1)
  1917.       {
  1918.          if(_loc8_ == undefined)
  1919.          {
  1920.             _loc4_ = true;
  1921.          }
  1922.          else
  1923.          {
  1924.             _loc4_ = false;
  1925.          }
  1926.          this.world.MoveRight();
  1927.          _loc2_._x = 1147.6;
  1928.          this.world.current.ShowAllUnits(_loc2_);
  1929.          if(this.world.current.blnBoss == true)
  1930.          {
  1931.             this.ShowBoss(_loc2_);
  1932.          }
  1933.          this.MoveAvatarToBubble("destRight");
  1934.          this.transitionState = 1;
  1935.       }
  1936.       this.arrMap.push({xloc:this.world.x,yloc:this.world.y,blnCreate:_loc4_,blnBoss:false});
  1937.    }
  1938.    function AddToCleanup(myName)
  1939.    {
  1940.       this.arrCleanup.push({name:myName,counter:6});
  1941.    }
  1942.    function DoCleanup()
  1943.    {
  1944.       var _loc4_ = new Array();
  1945.       var _loc3_ = 0;
  1946.       while(_loc3_ < this.arrCleanup.length)
  1947.       {
  1948.          this.arrCleanup[_loc3_].counter--;
  1949.          if(this.arrCleanup[_loc3_].counter == 0)
  1950.          {
  1951.             _loc4_.push(this.arrCleanup[_loc3_].name);
  1952.          }
  1953.          _loc3_ = _loc3_ + 1;
  1954.       }
  1955.       _loc3_ = 0;
  1956.       while(_loc3_ < _loc4_.length)
  1957.       {
  1958.          _root[_loc4_[_loc3_]].removeMovieClip();
  1959.          this.RemoveCleanupItem(_loc4_[_loc3_]);
  1960.          _loc3_ = _loc3_ + 1;
  1961.       }
  1962.    }
  1963.    function RemoveCleanupItem(strName)
  1964.    {
  1965.       var _loc2_ = 0;
  1966.       while(_loc2_ < this.arrCleanup.length)
  1967.       {
  1968.          if(strName == this.arrCleanup[_loc2_].name)
  1969.          {
  1970.             this.arrCleanup.splice(_loc2_,1);
  1971.             break;
  1972.          }
  1973.          _loc2_ = _loc2_ + 1;
  1974.       }
  1975.    }
  1976.    function MoveWorld(vecMove)
  1977.    {
  1978.       vecMove._x = Math.round(vecMove._x);
  1979.       vecMove._y = Math.round(vecMove._y);
  1980.       _root.bg._x += vecMove._x;
  1981.       _root.bg._y += vecMove._y;
  1982.       _root.bubbleSplit._x += vecMove._x;
  1983.       _root.bubbleSplit._y += vecMove._y;
  1984.       _root.bubbleMask._x += vecMove._x;
  1985.       _root.bubbleMask._y += vecMove._y;
  1986.       _root.effectMask_mc._x += vecMove._x;
  1987.       _root.effectMask_mc._y += vecMove._y;
  1988.       _root.overlay._x += vecMove._x;
  1989.       _root.overlay._y += vecMove._y;
  1990.       this.world.current.MoveAllBubblefieldUnits(vecMove);
  1991.       var _loc4_ = 0;
  1992.       while(_loc4_ < this.arrBullets.length)
  1993.       {
  1994.          _root[this.arrBullets[_loc4_]]._x += vecMove._x;
  1995.          _root[this.arrBullets[_loc4_]]._y += vecMove._y;
  1996.          if(_root[this.arrBullets[_loc4_]]._type == 8)
  1997.          {
  1998.             _root[this.arrBullets[_loc4_]].MoveBusted(vecMove);
  1999.          }
  2000.          _loc4_ = _loc4_ + 1;
  2001.       }
  2002.       _loc4_ = 0;
  2003.       while(_loc4_ < this.arrAllySeekers.length)
  2004.       {
  2005.          if(_root[this.arrAllySeekers[_loc4_].name]._type != 2)
  2006.          {
  2007.             _root[this.arrAllySeekers[_loc4_].name]._x += vecMove._x;
  2008.             _root[this.arrAllySeekers[_loc4_].name]._y += vecMove._y;
  2009.          }
  2010.          else if(_root[this.arrAllySeekers[_loc4_].name].intState != 2)
  2011.          {
  2012.             _root[this.arrAllySeekers[_loc4_].name]._x += vecMove._x;
  2013.             _root[this.arrAllySeekers[_loc4_].name]._y += vecMove._y;
  2014.          }
  2015.          _loc4_ = _loc4_ + 1;
  2016.       }
  2017.       if(this.intAssembledState == 2)
  2018.       {
  2019.          _loc4_ = 1;
  2020.          while(_loc4_ < 20)
  2021.          {
  2022.             if(_loc4_ != 6)
  2023.             {
  2024.                var _loc5_ = _loc4_ + "_mc";
  2025.                _root[_loc5_]._x += vecMove._x;
  2026.                _root[_loc5_]._y += vecMove._y;
  2027.             }
  2028.             _loc4_ = _loc4_ + 1;
  2029.          }
  2030.       }
  2031.       this.MovePickupBubbles(vecMove);
  2032.       this.MoveEffects(vecMove);
  2033.    }
  2034.    function BackgroundShift(vecMove)
  2035.    {
  2036.       vecMove._x = Math.round(vecMove._x);
  2037.       vecMove._y = Math.round(vecMove._y);
  2038.       _root.bg._x += vecMove._x;
  2039.       _root.bg._y += vecMove._y;
  2040.       _root.bubbleSplit._x += vecMove._x;
  2041.       _root.bubbleSplit._y += vecMove._y;
  2042.       _root.bubbleMask._x += vecMove._x;
  2043.       _root.bubbleMask._y += vecMove._y;
  2044.       _root.effectMask_mc._x += vecMove._x;
  2045.       _root.effectMask_mc._y += vecMove._y;
  2046.       _root.overlay._x += vecMove._x;
  2047.       _root.overlay._y += vecMove._y;
  2048.    }
  2049.    function PrintVector(myName, vecMe)
  2050.    {
  2051.    }
  2052.    function EnemyDead(myName)
  2053.    {
  2054.       var _loc4_ = this.world.current.GetUnitType(myName);
  2055.       if(_root[myName]._type == 1)
  2056.       {
  2057.          this.intEnemiesKilled = this.intEnemiesKilled + 1;
  2058.       }
  2059.       if(_root[myName]._type == 1)
  2060.       {
  2061.          this.kongEnemiesKilledThisGame.Set(this.kongEnemiesKilledThisGame.Get() + 1);
  2062.          if(_global.gameMode == 1)
  2063.          {
  2064.             if(_loc4_ == "Enemy_97")
  2065.             {
  2066.                this.kongDestroyerKilledThisGame.Set(this.kongDestroyerKilledThisGame.Get() + 1);
  2067.                _root.kongregateStats.submit("MaxDestroyerKillsInAGame",this.kongDestroyerKilledThisGame.Get());
  2068.             }
  2069.             else if(_loc4_ == "Enemy_90")
  2070.             {
  2071.                this.kongTriGuardianKilledThisGame.Set(this.kongTriGuardianKilledThisGame.Get() + 1);
  2072.                _root.kongregateStats.submit("MaxTriGuardianKillsInAGame",this.kongTriGuardianKilledThisGame.Get());
  2073.             }
  2074.             else if(_loc4_ == "Enemy_86")
  2075.             {
  2076.                this.kongSpawnCarrierKilledThisGame.Set(this.kongSpawnCarrierKilledThisGame.Get() + 1);
  2077.                _root.kongregateStats.submit("MaxSpawnCarrierKillsInAGame",this.kongSpawnCarrierKilledThisGame.Get());
  2078.             }
  2079.             else if(_loc4_ == "Enemy_14")
  2080.             {
  2081.                this.kongBFTKilledThisGame.Set(this.kongBFTKilledThisGame.Get() + 1);
  2082.                _root.kongregateStats.submit("MaxBFTKillsInAGame",this.kongBFTKilledThisGame.Get());
  2083.             }
  2084.             if(_loc4_ == "Enemy_97" || _loc4_ == "Enemy_90" || _loc4_ == "Enemy_86" || _loc4_ == "Enemy_14")
  2085.             {
  2086.                this.kongBigEnemiesKilledThisGame.Set(this.kongBigEnemiesKilledThisGame.Get() + 1);
  2087.                _root.kongregateStats.submit("MaxBigKillsInAGame",this.kongBigEnemiesKilledThisGame.Get());
  2088.             }
  2089.             this.kongBlnRefresh = true;
  2090.          }
  2091.       }
  2092.       _global.SoundManager.PlaySound("small_death");
  2093.       this.CheckListAndAdd(_loc4_);
  2094.       this.world.current.RemoveUnit(myName);
  2095.       if(_global.gameMode == 2)
  2096.       {
  2097.          if(this.world.current.GetNumUnits() == 0)
  2098.          {
  2099.             this.CompleteArena();
  2100.          }
  2101.       }
  2102.       else if(this.world.current.GetNumUnits() == 0)
  2103.       {
  2104.          this.blnEnemiesCleared = true;
  2105.          if(this.world.current.blnBoss == true)
  2106.          {
  2107.             this.intWinFlag = 74;
  2108.             this.intBossState = 4;
  2109.             _root.bg.boss_mc.gotoAndPlay("deathAnim");
  2110.          }
  2111.       }
  2112.    }
  2113.    function CheckTankExit()
  2114.    {
  2115.       var _loc4_ = 0;
  2116.       if(this.GetDistance() > _root.bg.inside._width / 2)
  2117.       {
  2118.          _loc4_ = this.GetAngle();
  2119.          _root.bubbleSplit.gotoAndPlay("show");
  2120.          _root.bubbleSplit._rotation = _loc4_;
  2121.          var _loc3_ = new Vector();
  2122.          var _loc6_ = undefined;
  2123.          var _loc5_ = undefined;
  2124.          if(_loc4_ < -45 && _loc4_ > -135)
  2125.          {
  2126.             _loc6_ = this.world.GetUp(false);
  2127.             if(_loc6_ == undefined)
  2128.             {
  2129.                _loc5_ = true;
  2130.             }
  2131.             else
  2132.             {
  2133.                _loc5_ = false;
  2134.             }
  2135.             this.world.MoveUp();
  2136.             _loc3_._y = -1147.6;
  2137.             this.world.current.ShowAllUnits(_loc3_);
  2138.             if(this.world.current.blnBoss == true)
  2139.             {
  2140.                this.ShowBoss(_loc3_);
  2141.             }
  2142.             this.MoveAvatarToBubble("destTop");
  2143.             this.transitionState = 4;
  2144.          }
  2145.          else if(_loc4_ <= -135 && _loc4_ >= -180 || _loc4_ >= 135 && _loc4_ <= 180)
  2146.          {
  2147.             _loc6_ = this.world.GetLeft(false);
  2148.             if(_loc6_ == undefined)
  2149.             {
  2150.                _loc5_ = true;
  2151.             }
  2152.             else
  2153.             {
  2154.                _loc5_ = false;
  2155.             }
  2156.             this.world.MoveLeft();
  2157.             _loc3_._x = -1147.6;
  2158.             this.world.current.ShowAllUnits(_loc3_);
  2159.             if(this.world.current.blnBoss == true)
  2160.             {
  2161.                this.ShowBoss(_loc3_);
  2162.             }
  2163.             this.MoveAvatarToBubble("destLeft");
  2164.             this.transitionState = 3;
  2165.          }
  2166.          else if(_loc4_ < 135 && _loc4_ > 45)
  2167.          {
  2168.             _loc6_ = this.world.GetDown(false);
  2169.             if(_loc6_ == undefined)
  2170.             {
  2171.                _loc5_ = true;
  2172.             }
  2173.             else
  2174.             {
  2175.                _loc5_ = false;
  2176.             }
  2177.             this.world.MoveDown();
  2178.             _loc3_._y = 1147.6;
  2179.             this.world.current.ShowAllUnits(_loc3_);
  2180.             if(this.world.current.blnBoss == true)
  2181.             {
  2182.                this.ShowBoss(_loc3_);
  2183.             }
  2184.             this.MoveAvatarToBubble("destBottom");
  2185.             this.transitionState = 2;
  2186.          }
  2187.          else
  2188.          {
  2189.             _loc6_ = this.world.GetRight(false);
  2190.             if(_loc6_ == undefined)
  2191.             {
  2192.                _loc5_ = true;
  2193.             }
  2194.             else
  2195.             {
  2196.                _loc5_ = false;
  2197.             }
  2198.             this.world.MoveRight();
  2199.             _loc3_._x = 1147.6;
  2200.             this.world.current.ShowAllUnits(_loc3_);
  2201.             if(this.world.current.blnBoss == true)
  2202.             {
  2203.                this.ShowBoss(_loc3_);
  2204.             }
  2205.             this.MoveAvatarToBubble("destRight");
  2206.             this.transitionState = 1;
  2207.          }
  2208.          this.arrMap.push({xloc:this.world.x,yloc:this.world.y,blnCreate:_loc5_,blnBoss:false});
  2209.       }
  2210.    }
  2211.    function GetDistance()
  2212.    {
  2213.       var _loc3_ = _root.avatar._x - _root.bg._x;
  2214.       var _loc2_ = _root.avatar._y - _root.bg._y;
  2215.       return Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
  2216.    }
  2217.    function GetAngle()
  2218.    {
  2219.       var _loc2_ = new Vector();
  2220.       _loc2_._x = _root.avatar._x - _root.bg._x;
  2221.       _loc2_._y = _root.avatar._y - _root.bg._y;
  2222.       var _loc3_ = Math.atan2(_loc2_._y,_loc2_._x);
  2223.       var _loc4_ = 360 * _loc3_ / 6.283185307179586;
  2224.       return _loc4_;
  2225.    }
  2226.    function MoveAvatarToBubble(bubbleDest)
  2227.    {
  2228.       if(this.runOnce == false)
  2229.       {
  2230.          this.intTotalFrames = 35;
  2231.          this.easeFrames = 35;
  2232.          var ref = eval("_root.bg." + bubbleDest);
  2233.          var myPoint = {x:ref._x,y:ref._y};
  2234.          _root.bg.localToGlobal(myPoint);
  2235.          this.dblDestX = myPoint.x;
  2236.          this.dblDestY = myPoint.y;
  2237.          this.BuildPointList();
  2238.          this.vecMomentum._x = 0;
  2239.          this.vecMomentum._y = 0;
  2240.          this.runOnce = true;
  2241.       }
  2242.    }
  2243.    function MoveAvatar()
  2244.    {
  2245.       var _loc6_ = new Vector();
  2246.       var _loc4_ = this.upgradePath.currentNode.nodeData._speed;
  2247.       if(this.stickyCounter > 0)
  2248.       {
  2249.          _loc4_ = 1;
  2250.       }
  2251.       var _loc5_ = _loc4_;
  2252.       if(_loc5_ < 1)
  2253.       {
  2254.          _loc5_ == 1;
  2255.       }
  2256.       if(Key.isDown(_global.avatarRight) && !Key.isDown(_global.avatarLeft))
  2257.       {
  2258.          this.vecMomentum._x += this.numSensitivity * _loc5_;
  2259.          if(this.vecMomentum._x > this.numAvatarMaxVelocity * _loc4_)
  2260.          {
  2261.             this.vecMomentum._x = this.numAvatarMaxVelocity * _loc4_;
  2262.          }
  2263.       }
  2264.       if(Key.isDown(_global.avatarLeft) && !Key.isDown(_global.avatarRight))
  2265.       {
  2266.          this.vecMomentum._x -= this.numSensitivity * _loc5_;
  2267.          if(this.vecMomentum._x < this.numAvatarMaxVelocity * _loc4_ * -1)
  2268.          {
  2269.             this.vecMomentum._x = this.numAvatarMaxVelocity * _loc4_ * -1;
  2270.          }
  2271.       }
  2272.       if(Key.isDown(_global.avatarDown) && !Key.isDown(_global.avatarUp))
  2273.       {
  2274.          this.vecMomentum._y += this.numSensitivity * _loc5_;
  2275.          if(this.vecMomentum._y > this.numAvatarMaxVelocity * _loc4_)
  2276.          {
  2277.             this.vecMomentum._y = this.numAvatarMaxVelocity * _loc4_;
  2278.          }
  2279.       }
  2280.       if(Key.isDown(_global.avatarUp) && !Key.isDown(_global.avatarDown))
  2281.       {
  2282.          this.vecMomentum._y -= this.numSensitivity * _loc5_;
  2283.          if(this.vecMomentum._y < this.numAvatarMaxVelocity * _loc4_ * -1)
  2284.          {
  2285.             this.vecMomentum._y = this.numAvatarMaxVelocity * _loc4_ * -1;
  2286.          }
  2287.       }
  2288.       if(!Key.isDown(_global.avatarLeft) && !Key.isDown(_global.avatarRight))
  2289.       {
  2290.          if(this.vecMomentum._x > 0)
  2291.          {
  2292.             this.vecMomentum._x -= this.numResistence * _loc5_;
  2293.          }
  2294.          if(this.vecMomentum._x < 0)
  2295.          {
  2296.             this.vecMomentum._x += this.numResistence * _loc5_;
  2297.          }
  2298.          if(this.vecMomentum._x >= -0.3 && this.vecMomentum._x <= 0.3)
  2299.          {
  2300.             this.vecMomentum._x = 0;
  2301.          }
  2302.       }
  2303.       if(!Key.isDown(_global.avatarUp) && !Key.isDown(_global.avatarDown))
  2304.       {
  2305.          if(this.vecMomentum._y > 0)
  2306.          {
  2307.             this.vecMomentum._y -= this.numResistence * _loc5_;
  2308.          }
  2309.          if(this.vecMomentum._y < 0)
  2310.          {
  2311.             this.vecMomentum._y += this.numResistence * _loc5_;
  2312.          }
  2313.          if(this.vecMomentum._y >= -0.3 && this.vecMomentum._y <= 0.3)
  2314.          {
  2315.             this.vecMomentum._y = 0;
  2316.          }
  2317.       }
  2318.       this.RotateTank();
  2319.       _loc6_._x = this.vecMomentum._x * -1;
  2320.       _loc6_._y = this.vecMomentum._y * -1;
  2321.       if(this.stickyCounter > 0)
  2322.       {
  2323.          this.stickyCounter = this.stickyCounter - 1;
  2324.          if(this.stickyCounter == 0)
  2325.          {
  2326.             _root.avatar.gun.effects.gotoAndStop(1);
  2327.             this.vecMomentum._x = _loc6_._x * 0.1 * -1;
  2328.             this.vecMomentum._y = _loc6_._y * 0.1 * -1;
  2329.          }
  2330.          else
  2331.          {
  2332.             _loc6_._x *= 0.1;
  2333.             _loc6_._y *= 0.1;
  2334.          }
  2335.       }
  2336.       return _loc6_;
  2337.    }
  2338.    function RotateTank()
  2339.    {
  2340.       if(this.vecMomentum._x != 0 || this.vecMomentum._y != 0)
  2341.       {
  2342.          var _loc3_ = Math.atan2(this.vecMomentum._y,this.vecMomentum._x);
  2343.          var _loc4_ = 360 * _loc3_ / 6.283185307179586;
  2344.          _root.avatar.bottom._rotation = _loc4_;
  2345.       }
  2346.    }
  2347.    function RotateGun()
  2348.    {
  2349.       if(this.upgradePath.currentNode.nodeData._turnMode == 2)
  2350.       {
  2351.          var _loc13_ = this.vecMomentum.AngleToAlign(_root.avatar.gun._rotation,this.vecMomentum.GetLength() / 2,0.5);
  2352.          if(this.stickyCounter > 0)
  2353.          {
  2354.             _loc13_ *= 0.1;
  2355.          }
  2356.          _root.avatar.gun._rotation += _loc13_;
  2357.       }
  2358.       else
  2359.       {
  2360.          var _loc3_ = new Vector();
  2361.          _loc3_._x = _xmouse - _root.avatar._x;
  2362.          _loc3_._y = _ymouse - _root.avatar._y;
  2363.          var _loc8_ = Math.atan2(_loc3_._y,_loc3_._x);
  2364.          var _loc9_ = 360 * _loc8_ / 6.283185307179586;
  2365.          _root.avatar.gun._rotation = _loc9_;
  2366.       }
  2367.       if(this.upgradePath.currentNode.nodeData._turnMode == 2)
  2368.       {
  2369.          var _loc4_ = 0;
  2370.          while(_loc4_ < this.upgradePath.currentNode.nodeData._arrPrimaryWeapons.length)
  2371.          {
  2372.             var _loc10_ = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[_loc4_].type;
  2373.             var _loc6_ = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[_loc4_].name;
  2374.             var _loc7_ = false;
  2375.             switch(_loc10_)
  2376.             {
  2377.                case 3:
  2378.                case 16:
  2379.                case 28:
  2380.                   _loc7_ = true;
  2381.                   break;
  2382.                default:
  2383.                   _loc7_ = false;
  2384.                   break;
  2385.             }
  2386.             if(_loc7_ == true)
  2387.             {
  2388.                var _loc5_ = {x:_root.avatar.gun[_loc6_]._x,y:_root.avatar.gun[_loc6_]._y};
  2389.                _root.avatar.gun.localToGlobal(_loc5_);
  2390.                _loc3_ = new Vector();
  2391.                _loc3_._x = _root._xmouse - _loc5_.x;
  2392.                _loc3_._y = _root._ymouse - _loc5_.y;
  2393.                _loc8_ = Math.atan2(_loc3_._y,_loc3_._x);
  2394.                _loc9_ = 360 * _loc8_ / 6.283185307179586;
  2395.                _root.avatar.gun[_loc6_]._rotation = _loc9_ - _root.avatar.gun._rotation;
  2396.             }
  2397.             _loc4_ = _loc4_ + 1;
  2398.          }
  2399.          _loc4_ = 0;
  2400.          while(_loc4_ < this.upgradePath.currentNode.nodeData._arrSecondaryWeapons.length)
  2401.          {
  2402.             _loc10_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc4_].type;
  2403.             _loc6_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc4_].name;
  2404.             _loc7_ = false;
  2405.             switch(_loc10_)
  2406.             {
  2407.                case 3:
  2408.                case 16:
  2409.                   _loc7_ = true;
  2410.                   break;
  2411.                default:
  2412.                   _loc7_ = false;
  2413.                   break;
  2414.             }
  2415.             if(_loc7_ == true)
  2416.             {
  2417.                _loc5_ = {x:_root.avatar.gun[_loc6_]._x,y:_root.avatar.gun[_loc6_]._y};
  2418.                _root.avatar.gun.localToGlobal(_loc5_);
  2419.                _loc3_ = new Vector();
  2420.                _loc3_._x = _root._xmouse - _loc5_.x;
  2421.                _loc3_._y = _root._ymouse - _loc5_.y;
  2422.                _loc8_ = Math.atan2(_loc3_._y,_loc3_._x);
  2423.                _loc9_ = 360 * _loc8_ / 6.283185307179586;
  2424.                _root.avatar.gun[_loc6_]._rotation = _loc9_ - _root.avatar.gun._rotation;
  2425.             }
  2426.             _loc4_ = _loc4_ + 1;
  2427.          }
  2428.       }
  2429.    }
  2430.    function ShootGun()
  2431.    {
  2432.       if(_global.gamePaused == false)
  2433.       {
  2434.          if(this.avatarLife.Get() >= 76 && this.avatarLife.Get() <= 200 && this.secondBulletCounter != 1)
  2435.          {
  2436.             this.secondBulletCounter = 3;
  2437.          }
  2438.          var thisRef = this;
  2439.          var _loc4_ = "avatarBullet_" + this.numBulletDepth;
  2440.          var _loc6_ = new Vector();
  2441.          _loc6_._x = Math.cos(3.141592653589793 * _root.avatar.gun._rotation / 180) * 10;
  2442.          _loc6_._y = Math.sin(3.141592653589793 * _root.avatar.gun._rotation / 180) * 10;
  2443.          var _loc5_ = {x:_root.avatar.gun.emitter._x,y:_root.avatar.gun.emitter._y};
  2444.          if(this.avatarLife.Get() >= 201 && this.avatarLife.Get() <= 370 || this.avatarLife.Get() >= 371)
  2445.          {
  2446.             _loc5_.x = _root.avatar.gun.emitter1._x;
  2447.             _loc5_.y = _root.avatar.gun.emitter1._y;
  2448.          }
  2449.          _root.avatar.gun.localToGlobal(_loc5_);
  2450.          _root.attachMovie("component_bubble_red",_loc4_,this.numBulletDepth);
  2451.          _root[_loc4_]._x = _loc5_.x;
  2452.          _root[_loc4_]._y = _loc5_.y;
  2453.          _root[_loc4_].SetMovement(_loc6_._x,_loc6_._y);
  2454.          _root[_loc4_]._enemy = false;
  2455.          this.numBulletDepth = this.numBulletDepth + 1;
  2456.          this.arrBullets.push(_loc4_);
  2457.          _global.SoundManager.PlaySound("shoot");
  2458.          _root[_loc4_].removeCallback = function(myName)
  2459.          {
  2460.             thisRef.RemoveBullet(myName);
  2461.          };
  2462.          if(this.avatarLife.Get() >= 201 && this.avatarLife.Get() <= 370)
  2463.          {
  2464.             _loc4_ = "avatarBullet_" + this.numBulletDepth;
  2465.             _loc5_.x = _root.avatar.gun.emitter2._x;
  2466.             _loc5_.y = _root.avatar.gun.emitter2._y;
  2467.             _root.avatar.gun.localToGlobal(_loc5_);
  2468.             _root.attachMovie("component_bubble_red",_loc4_,this.numBulletDepth);
  2469.             _root[_loc4_]._x = _loc5_.x;
  2470.             _root[_loc4_]._y = _loc5_.y;
  2471.             _root[_loc4_].SetMovement(_loc6_._x,_loc6_._y);
  2472.             _root[_loc4_]._enemy = false;
  2473.             this.numBulletDepth = this.numBulletDepth + 1;
  2474.             this.arrBullets.push(_loc4_);
  2475.             _root[_loc4_].removeCallback = function(myName)
  2476.             {
  2477.                thisRef.RemoveBullet(myName);
  2478.             };
  2479.             _loc4_ = "avatarBullet_" + this.numBulletDepth;
  2480.             _loc5_.x = _root.avatar.gun.emitter3._x;
  2481.             _loc5_.y = _root.avatar.gun.emitter3._y;
  2482.             _root.avatar.gun.localToGlobal(_loc5_);
  2483.             _root.attachMovie("component_bubble_red",_loc4_,this.numBulletDepth);
  2484.             _root[_loc4_]._x = _loc5_.x;
  2485.             _root[_loc4_]._y = _loc5_.y;
  2486.             _root[_loc4_].SetMovement(_loc6_._x,_loc6_._y);
  2487.             _root[_loc4_]._enemy = false;
  2488.             this.numBulletDepth = this.numBulletDepth + 1;
  2489.             this.arrBullets.push(_loc4_);
  2490.             _root[_loc4_].removeCallback = function(myName)
  2491.             {
  2492.                thisRef.RemoveBullet(myName);
  2493.             };
  2494.          }
  2495.          else if(this.avatarLife.Get() >= 371)
  2496.          {
  2497.             _loc4_ = "avatarBullet_" + this.numBulletDepth;
  2498.             _loc5_.x = _root.avatar.gun.emitter2._x;
  2499.             _loc5_.y = _root.avatar.gun.emitter2._y;
  2500.             _root.avatar.gun.localToGlobal(_loc5_);
  2501.             _root.attachMovie("component_bubble_red",_loc4_,this.numBulletDepth);
  2502.             _root[_loc4_]._x = _loc5_.x;
  2503.             _root[_loc4_]._y = _loc5_.y;
  2504.             _root[_loc4_]._xscale = 300;
  2505.             _root[_loc4_]._yscale = 300;
  2506.             _root[_loc4_]._damage = 8;
  2507.             _loc6_._x *= 0.5;
  2508.             _loc6_._y *= 0.5;
  2509.             _root[_loc4_].SetMovement(_loc6_._x,_loc6_._y);
  2510.             _root[_loc4_]._enemy = false;
  2511.             this.numBulletDepth = this.numBulletDepth + 1;
  2512.             this.arrBullets.push(_loc4_);
  2513.             _root[_loc4_].removeCallback = function(myName)
  2514.             {
  2515.                thisRef.RemoveBullet(myName);
  2516.             };
  2517.          }
  2518.       }
  2519.    }
  2520.    function MouseDown()
  2521.    {
  2522.       this.blnPrimaryActive = true;
  2523.    }
  2524.    function MouseUp()
  2525.    {
  2526.       this.blnPrimaryActive = false;
  2527.    }
  2528.    function OperateAvatarSecondaryWeapons()
  2529.    {
  2530.       if(this.intSecondaryCounter == 0)
  2531.       {
  2532.          var _loc3_ = 0;
  2533.          while(_loc3_ < this.upgradePath.currentNode.nodeData._arrSecondaryWeapons.length)
  2534.          {
  2535.             var _loc4_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc3_].type;
  2536.             var _loc2_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc3_].name;
  2537.             var _loc5_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc3_].delay;
  2538.             switch(_loc4_)
  2539.             {
  2540.                case 6:
  2541.                   this.Gun_Mines(_loc2_);
  2542.                   break;
  2543.                case 8:
  2544.                   this.Gun_Shield();
  2545.                   break;
  2546.                case 10:
  2547.                   this.Gun_Teleport();
  2548.                   break;
  2549.                case 12:
  2550.                   this.Gun_Seekers(_loc2_);
  2551.                   break;
  2552.                case 14:
  2553.                   this.Gun_ShortStun(_loc2_);
  2554.                   break;
  2555.                case 15:
  2556.                   this.Gun_DamageBurst(_loc2_);
  2557.                   break;
  2558.                case 16:
  2559.                   this.Gun_Sticky(_loc2_);
  2560.                   break;
  2561.                case 19:
  2562.                   this.Gun_StarBurst(_loc2_);
  2563.                   break;
  2564.                case 21:
  2565.                   this.Gun_AreaBurstCannon(_loc2_);
  2566.                   break;
  2567.                case 22:
  2568.                   this.Gun_StickyBurst(_loc2_);
  2569.                   break;
  2570.                case 23:
  2571.                   this.Gun_LargeStun(_loc2_);
  2572.                   break;
  2573.                case 27:
  2574.                   this.Gun_MassiveCannon(_loc2_);
  2575.                   break;
  2576.                case 30:
  2577.                   this.Gun_Infector(_loc2_);
  2578.                   break;
  2579.                case 32:
  2580.                   this.Gun_Convert(_loc2_);
  2581.                   break;
  2582.                case 33:
  2583.                   this.Gun_FighterBay(_loc2_);
  2584.             }
  2585.             this.intSecondaryCounter = _loc5_;
  2586.             _loc3_ = _loc3_ + 1;
  2587.          }
  2588.          this.blnFireRateFlag = true;
  2589.       }
  2590.    }
  2591.    function OperateAvatarWeapons()
  2592.    {
  2593.       if(this.intPrimaryCounter == 0)
  2594.       {
  2595.          if(this.intAssembledState == 0)
  2596.          {
  2597.             if(this.blnPrimaryActive == true)
  2598.             {
  2599.                var _loc2_ = 0;
  2600.                while(_loc2_ < this.upgradePath.currentNode.nodeData._arrPrimaryWeapons.length)
  2601.                {
  2602.                   var _loc3_ = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[_loc2_].type;
  2603.                   var _loc4_ = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[_loc2_].name;
  2604.                   var _loc5_ = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[_loc2_].delay;
  2605.                   switch(_loc3_)
  2606.                   {
  2607.                      case 1:
  2608.                         this.Gun_BasicCannon(_loc4_);
  2609.                         break;
  2610.                      case 2:
  2611.                         this.Gun_2Parallel(_loc4_);
  2612.                         break;
  2613.                      case 3:
  2614.                         this.Gun_HeavyCannon(_loc4_);
  2615.                         break;
  2616.                      case 4:
  2617.                         this.Gun_3Spread(_loc4_);
  2618.                         break;
  2619.                      case 5:
  2620.                         this.Gun_3Parallel(_loc4_);
  2621.                         break;
  2622.                      case 7:
  2623.                         this.Gun_5Parallel(_loc4_);
  2624.                         break;
  2625.                      case 9:
  2626.                         this.Gun_PierceShot(_loc4_,1);
  2627.                         break;
  2628.                      case 11:
  2629.                         this.Gun_UpgradedMachineGun(_loc4_);
  2630.                         break;
  2631.                      case 13:
  2632.                         this.Gun_5Spread(_loc4_);
  2633.                         break;
  2634.                      case 18:
  2635.                         this.Gun_PierceShot(_loc4_,2);
  2636.                         break;
  2637.                      case 20:
  2638.                         this.Gun_2ParallelLargeMG(_loc4_);
  2639.                         break;
  2640.                      case 25:
  2641.                         this.Gun_ExplosivePierceShot(_loc4_);
  2642.                         break;
  2643.                      case 28:
  2644.                         this.Gun_BulletBuster(_loc4_);
  2645.                         break;
  2646.                      case 29:
  2647.                         this.Gun_Leecher(_loc4_);
  2648.                         break;
  2649.                      case 31:
  2650.                         this.Gun_Mitosis(_loc4_);
  2651.                   }
  2652.                   this.intPrimaryCounter = _loc5_;
  2653.                   _loc2_ = _loc2_ + 1;
  2654.                }
  2655.                this.blnFireRateFlag = true;
  2656.             }
  2657.          }
  2658.       }
  2659.       else if(this.intPrimaryCounter > 0)
  2660.       {
  2661.          this.intPrimaryCounter = this.intPrimaryCounter - 1;
  2662.       }
  2663.       if(this.intSecondaryCounter > 0)
  2664.       {
  2665.          this.intSecondaryCounter = this.intSecondaryCounter - 1;
  2666.       }
  2667.       if(this.upgradePath.currentNode.nodeData._hasAutoGuns == true)
  2668.       {
  2669.          this.AimAvatarAutoWeapons();
  2670.          if(this.intAutoCounter > 0)
  2671.          {
  2672.             this.intAutoCounter = this.intAutoCounter - 1;
  2673.          }
  2674.          else if(this.intAutoCounter == 0)
  2675.          {
  2676.             this.FireAvatarAutoWeapons();
  2677.          }
  2678.       }
  2679.       _loc2_ = 0;
  2680.       while(_loc2_ < this.upgradePath.currentNode.nodeData._arrSecondaryWeapons.length)
  2681.       {
  2682.          _loc3_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc2_].type;
  2683.          _loc4_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc2_].name;
  2684.          _loc5_ = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[_loc2_].delay;
  2685.          if(_loc3_ === 26)
  2686.          {
  2687.             this.Manage_OrbitalSeekers(_loc2_);
  2688.          }
  2689.          _loc2_ = _loc2_ + 1;
  2690.       }
  2691.       if(this.intShieldCounter > 0)
  2692.       {
  2693.          this.intShieldCounter = this.intShieldCounter - 1;
  2694.       }
  2695.    }
  2696.    function AimAvatarAutoWeapons()
  2697.    {
  2698.       if(this.transitionState == 0)
  2699.       {
  2700.          var i = 0;
  2701.          while(i < this.upgradePath.currentNode.nodeData._arrPrimaryWeapons.length)
  2702.          {
  2703.             var gunType = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].type;
  2704.             var gunName = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].name;
  2705.             var gunDelay = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].delay;
  2706.             var blnIsAutoFire = false;
  2707.             if(gunType === 17)
  2708.             {
  2709.                blnIsAutoFire = true;
  2710.             }
  2711.             if(blnIsAutoFire == true)
  2712.             {
  2713.                var gunTarget = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].target;
  2714.                if(gunTarget != "")
  2715.                {
  2716.                   var gunRef = eval("_root.avatar.gun." + gunName);
  2717.                   var point = {x:gunRef._x,y:gunRef._y};
  2718.                   _root.avatar.gun.localToGlobal(point);
  2719.                   var bulletSpeed = 0;
  2720.                   var _loc0_ = null;
  2721.                   if((_loc0_ = gunType) !== 17)
  2722.                   {
  2723.                      bulletSpeed = 10;
  2724.                   }
  2725.                   else
  2726.                   {
  2727.                      bulletSpeed = 10;
  2728.                   }
  2729.                   var aimVector = new Vector();
  2730.                   aimVector._x = _root[gunTarget]._x - point.x;
  2731.                   aimVector._y = _root[gunTarget]._y - point.y;
  2732.                   var aimPoint = _root[gunTarget].PredictTargetLocation(aimVector.GetLength(),bulletSpeed);
  2733.                   aimVector._x = aimPoint.x - point.x;
  2734.                   aimVector._y = aimPoint.y - point.y;
  2735.                   _root.avatar.gun[gunName]._rotation = aimVector.GetAngle() - _root.avatar.gun._rotation;
  2736.                }
  2737.             }
  2738.             i++;
  2739.          }
  2740.       }
  2741.    }
  2742.    function FireAvatarAutoWeapons()
  2743.    {
  2744.       if(this.transitionState == 0)
  2745.       {
  2746.          var i = 0;
  2747.          while(i < this.upgradePath.currentNode.nodeData._arrPrimaryWeapons.length)
  2748.          {
  2749.             var gunType = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].type;
  2750.             var gunName = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].name;
  2751.             var gunDelay = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].delay;
  2752.             var blnIsAutoFire = false;
  2753.             if(gunType === 17)
  2754.             {
  2755.                blnIsAutoFire = true;
  2756.             }
  2757.             if(blnIsAutoFire == true)
  2758.             {
  2759.                var gunTarget = this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].target;
  2760.                if(gunTarget != "")
  2761.                {
  2762.                   if(gunType === 17)
  2763.                   {
  2764.                      this.Gun_SmallAutoCannon(gunName);
  2765.                   }
  2766.                }
  2767.                var gunRef = eval("_root.avatar.gun." + gunName);
  2768.                var point = {x:gunRef._x,y:gunRef._y};
  2769.                gunRef._parent.localToGlobal(point);
  2770.                this.upgradePath.currentNode.nodeData._arrPrimaryWeapons[i].target = this.world.current.GetClosestUnit(point.x,point.y);
  2771.                this.intAutoCounter = gunDelay;
  2772.             }
  2773.             i++;
  2774.          }
  2775.       }
  2776.    }
  2777.    function Manage_OrbitalSeekers(gunIndex)
  2778.    {
  2779.       var gunType = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[gunIndex].type;
  2780.       var gunName = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[gunIndex].name;
  2781.       var gunDelay = this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[gunIndex].delay;
  2782.       if(this.arrAllySeekers.length < 5)
  2783.       {
  2784.          if(this.intSecondaryCounter == 0)
  2785.          {
  2786.             var gunRef = eval("_root.avatar.gun." + gunName);
  2787.             var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2788.             gunRef.localToGlobal(point);
  2789.             var spawnedName = "avatarSeeker_" + this.numBulletDepth;
  2790.             _root.attachMovie("Ally_Orbital_Seeker",spawnedName,this.numBulletDepth);
  2791.             _root[spawnedName]._x = point.x;
  2792.             _root[spawnedName]._y = point.y;
  2793.             _root[spawnedName]._damage = 5;
  2794.             this.arrAllySeekers.push({name:spawnedName,from:gunName});
  2795.             this.numBulletDepth = this.numBulletDepth + 1;
  2796.             if(this.numBulletDepth > 105000)
  2797.             {
  2798.                this.numBulletDepth = 100000;
  2799.             }
  2800.             this.intSecondaryCounter = gunDelay;
  2801.          }
  2802.       }
  2803.    }
  2804.    function Gun_Shield()
  2805.    {
  2806.       var _loc2_ = new Vector();
  2807.       _loc2_._x = 250;
  2808.       _loc2_._y = 200;
  2809.       this.CreateEffect("shield_avatar",_loc2_,true,"avatar");
  2810.       this.intShieldCounter = 25;
  2811.    }
  2812.    function Gun_BasicCannon(myGunName)
  2813.    {
  2814.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2815.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2816.       gunRef.localToGlobal(point);
  2817.       var vecStart = new Vector();
  2818.       vecStart._x = point.x;
  2819.       vecStart._y = point.y;
  2820.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  2821.       _global.SoundManager.PlaySound("shoot");
  2822.    }
  2823.    function Gun_SmallAutoCannon(myGunName)
  2824.    {
  2825.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2826.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2827.       gunRef.localToGlobal(point);
  2828.       var vecStart = new Vector();
  2829.       vecStart._x = point.x;
  2830.       vecStart._y = point.y;
  2831.       var useRotation = _root.avatar.gun._rotation;
  2832.       useRotation += gunRef._rotation;
  2833.       this.AvatarFireBullet(vecStart,useRotation,10,100,1);
  2834.    }
  2835.    function Gun_UpgradedMachineGun(myGunName)
  2836.    {
  2837.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2838.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2839.       gunRef.localToGlobal(point);
  2840.       var vecStart = new Vector();
  2841.       vecStart._x = point.x;
  2842.       vecStart._y = point.y;
  2843.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,11,100,2);
  2844.       _global.SoundManager.PlaySound("shoot");
  2845.    }
  2846.    function Gun_HeavyCannon(myGunName)
  2847.    {
  2848.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2849.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2850.       gunRef.localToGlobal(point);
  2851.       var vecStart = new Vector();
  2852.       vecStart._x = point.x;
  2853.       vecStart._y = point.y;
  2854.       var useRotation = _root.avatar.gun._rotation;
  2855.       if(this.upgradePath.currentNode.nodeData._turnMode == 2)
  2856.       {
  2857.          useRotation += gunRef._rotation;
  2858.       }
  2859.       this.AvatarFireBullet(vecStart,useRotation,7.5,300,5);
  2860.       _global.SoundManager.PlaySound("shoot");
  2861.    }
  2862.    function Gun_MassiveCannon(myGunName)
  2863.    {
  2864.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2865.       gunRef.bullet_mc._visible = true;
  2866.       gunRef.bullet_mc.gotoAndPlay(2);
  2867.    }
  2868.    function Fire_MassiveCannon(myGunName)
  2869.    {
  2870.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2871.       this.FlashScreen();
  2872.       this.ShakeScreen(80);
  2873.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2874.       gunRef.localToGlobal(point);
  2875.       var vecStart = new Vector();
  2876.       vecStart._x = point.x;
  2877.       vecStart._y = point.y;
  2878.       var bulletName = this.AvatarFireSpecialBullet(vecStart,_root.avatar.gun._rotation,10,100,90,"massive_bullet");
  2879.       _root[bulletName]._type = 7;
  2880.       _root[bulletName]._rotation = _root.avatar.gun._rotation;
  2881.    }
  2882.    function Gun_Sticky(myGunName)
  2883.    {
  2884.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2885.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2886.       gunRef.localToGlobal(point);
  2887.       var vecStart = new Vector();
  2888.       vecStart._x = point.x;
  2889.       vecStart._y = point.y;
  2890.       var useRotation = _root.avatar.gun._rotation;
  2891.       if(this.upgradePath.currentNode.nodeData._turnMode == 2)
  2892.       {
  2893.          useRotation += gunRef._rotation;
  2894.       }
  2895.       var bulletName = this.AvatarFireSpecialBullet(vecStart,useRotation,7.5,100,0,"sticky");
  2896.       _root[bulletName]._type = 3;
  2897.       _global.SoundManager.PlaySound("shoot");
  2898.    }
  2899.    function Gun_StickyBurst(myGunName)
  2900.    {
  2901.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2902.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2903.       gunRef.localToGlobal(point);
  2904.       var vecStart = new Vector();
  2905.       vecStart._x = point.x;
  2906.       vecStart._y = point.y;
  2907.       var useRotation = 0;
  2908.       while(useRotation < 360)
  2909.       {
  2910.          var bulletName = this.AvatarFireSpecialBullet(vecStart,useRotation,7.5,100,0,"sticky");
  2911.          _root[bulletName]._type = 3;
  2912.          useRotation += 10;
  2913.       }
  2914.       _global.SoundManager.PlaySound("shoot");
  2915.    }
  2916.    function Gun_AreaBurstCannon(myGunName, subType)
  2917.    {
  2918.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2919.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2920.       gunRef.localToGlobal(point);
  2921.       var vecStart = new Vector();
  2922.       vecStart._x = point.x;
  2923.       vecStart._y = point.y;
  2924.       var bulletName = this.AvatarFireSpecialBullet(vecStart,_root.avatar.gun._rotation,7,300,20,"component_bubble_orange_flashing");
  2925.       _root[bulletName]._type = 5;
  2926.       _global.SoundManager.PlaySound("shoot");
  2927.    }
  2928.    function Gun_StarBurst(myGunName)
  2929.    {
  2930.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2931.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2932.       gunRef.localToGlobal(point);
  2933.       var vecStart = new Vector();
  2934.       vecStart._x = point.x;
  2935.       vecStart._y = point.y;
  2936.       var bulletName = this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,7.5,200,15);
  2937.       _root[bulletName]._type = 4;
  2938.       _global.SoundManager.PlaySound("shoot");
  2939.    }
  2940.    function Gun_BulletBuster(myGunName)
  2941.    {
  2942.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2943.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2944.       gunRef.localToGlobal(point);
  2945.       var vecStart = new Vector();
  2946.       vecStart._x = point.x;
  2947.       vecStart._y = point.y;
  2948.       var useRotation = _root.avatar.gun._rotation;
  2949.       if(this.upgradePath.currentNode.nodeData._turnMode == 2)
  2950.       {
  2951.          useRotation += gunRef._rotation;
  2952.       }
  2953.       var bulletName = this.AvatarFireSpecialBullet(vecStart,useRotation,10,100,0,"bullet_buster");
  2954.       _root[bulletName]._type = 8;
  2955.       this.arrBulletBusters.push(bulletName);
  2956.       _global.SoundManager.PlaySound("shoot");
  2957.    }
  2958.    function SpawnStartBurstShard(xLoc, yLoc, intRotation)
  2959.    {
  2960.       var _loc3_ = new Vector();
  2961.       _loc3_._x = xLoc;
  2962.       _loc3_._y = yLoc;
  2963.       var _loc4_ = this.AvatarFireSpecialBullet(_loc3_,intRotation,14,100,5,"sniper_bullet");
  2964.       _root[_loc4_]._rotation = intRotation;
  2965.       _root[_loc4_]._type = 2;
  2966.    }
  2967.    function Gun_Leecher(myGunName)
  2968.    {
  2969.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2970.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2971.       gunRef.localToGlobal(point);
  2972.       var vecStart = new Vector();
  2973.       vecStart._x = point.x;
  2974.       vecStart._y = point.y;
  2975.       var bulletName = this.AvatarFireSpecialBullet(vecStart,_root.avatar.gun._rotation,10,100,8,"leecher_bullet");
  2976.       _root[bulletName]._rotation = _root.avatar.gun._rotation;
  2977.       _root[bulletName]._type = 9;
  2978.       _global.SoundManager.PlaySound("shoot");
  2979.    }
  2980.    function Gun_PierceShot(myGunName, subType)
  2981.    {
  2982.       var gunRef = eval("_root.avatar.gun." + myGunName);
  2983.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  2984.       gunRef.localToGlobal(point);
  2985.       var vecStart = new Vector();
  2986.       vecStart._x = point.x;
  2987.       vecStart._y = point.y;
  2988.       var intDamage = 0;
  2989.       if(subType == 1)
  2990.       {
  2991.          intDamage = 8;
  2992.       }
  2993.       else if(subType == 2)
  2994.       {
  2995.          intDamage = 14;
  2996.       }
  2997.       var bulletName = this.AvatarFireSpecialBullet(vecStart,_root.avatar.gun._rotation,14,100,intDamage,"sniper_bullet");
  2998.       _root[bulletName]._rotation = _root.avatar.gun._rotation;
  2999.       _root[bulletName]._type = 2;
  3000.       _global.SoundManager.PlaySound("shoot");
  3001.    }
  3002.    function Gun_ExplosivePierceShot(myGunName)
  3003.    {
  3004.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3005.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3006.       gunRef.localToGlobal(point);
  3007.       var vecStart = new Vector();
  3008.       vecStart._x = point.x;
  3009.       vecStart._y = point.y;
  3010.       var bulletName = this.AvatarFireSpecialBullet(vecStart,_root.avatar.gun._rotation,14,100,25,"sniper_bullet");
  3011.       _root[bulletName]._rotation = _root.avatar.gun._rotation;
  3012.       _root[bulletName]._type = 6;
  3013.       _global.SoundManager.PlaySound("shoot");
  3014.    }
  3015.    function Gun_2Parallel(myGunName)
  3016.    {
  3017.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3018.       var point = {x:gunRef.emitter1._x,y:gunRef.emitter1._y};
  3019.       gunRef.localToGlobal(point);
  3020.       var vecStart = new Vector();
  3021.       vecStart._x = point.x;
  3022.       vecStart._y = point.y;
  3023.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3024.       point = {x:gunRef.emitter2._x,y:gunRef.emitter2._y};
  3025.       gunRef.localToGlobal(point);
  3026.       vecStart = new Vector();
  3027.       vecStart._x = point.x;
  3028.       vecStart._y = point.y;
  3029.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3030.       _global.SoundManager.PlaySound("shoot");
  3031.    }
  3032.    function Gun_2ParallelLargeMG(myGunName)
  3033.    {
  3034.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3035.       var point = {x:gunRef.emitter1._x,y:gunRef.emitter1._y};
  3036.       gunRef.localToGlobal(point);
  3037.       var vecStart = new Vector();
  3038.       vecStart._x = point.x;
  3039.       vecStart._y = point.y;
  3040.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,9,200,2);
  3041.       point = {x:gunRef.emitter2._x,y:gunRef.emitter2._y};
  3042.       gunRef.localToGlobal(point);
  3043.       vecStart = new Vector();
  3044.       vecStart._x = point.x;
  3045.       vecStart._y = point.y;
  3046.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,9,200,2);
  3047.       _global.SoundManager.PlaySound("shoot");
  3048.    }
  3049.    function Gun_3Spread(myGunName)
  3050.    {
  3051.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3052.       var point = {x:gunRef.emitter1._x,y:gunRef.emitter1._y};
  3053.       gunRef.localToGlobal(point);
  3054.       var vecStart = new Vector();
  3055.       vecStart._x = point.x;
  3056.       vecStart._y = point.y;
  3057.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3058.       var point = {x:gunRef.emitter2._x,y:gunRef.emitter2._y};
  3059.       gunRef.localToGlobal(point);
  3060.       var vecStart = new Vector();
  3061.       vecStart._x = point.x;
  3062.       vecStart._y = point.y;
  3063.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation - 30,10,100,1);
  3064.       var point = {x:gunRef.emitter3._x,y:gunRef.emitter3._y};
  3065.       gunRef.localToGlobal(point);
  3066.       var vecStart = new Vector();
  3067.       vecStart._x = point.x;
  3068.       vecStart._y = point.y;
  3069.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation + 30,10,100,1);
  3070.       _global.SoundManager.PlaySound("shoot");
  3071.    }
  3072.    function Gun_5Spread(myGunName)
  3073.    {
  3074.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3075.       var point = {x:gunRef.emitter1._x,y:gunRef.emitter1._y};
  3076.       gunRef.localToGlobal(point);
  3077.       var vecStart = new Vector();
  3078.       vecStart._x = point.x;
  3079.       vecStart._y = point.y;
  3080.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation - 20,10,100,1);
  3081.       var point = {x:gunRef.emitter2._x,y:gunRef.emitter2._y};
  3082.       gunRef.localToGlobal(point);
  3083.       var vecStart = new Vector();
  3084.       vecStart._x = point.x;
  3085.       vecStart._y = point.y;
  3086.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation - 10,10,100,1);
  3087.       var point = {x:gunRef.emitter3._x,y:gunRef.emitter3._y};
  3088.       gunRef.localToGlobal(point);
  3089.       var vecStart = new Vector();
  3090.       vecStart._x = point.x;
  3091.       vecStart._y = point.y;
  3092.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3093.       var point = {x:gunRef.emitter4._x,y:gunRef.emitter4._y};
  3094.       gunRef.localToGlobal(point);
  3095.       var vecStart = new Vector();
  3096.       vecStart._x = point.x;
  3097.       vecStart._y = point.y;
  3098.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation + 10,10,100,1);
  3099.       var point = {x:gunRef.emitter5._x,y:gunRef.emitter5._y};
  3100.       gunRef.localToGlobal(point);
  3101.       var vecStart = new Vector();
  3102.       vecStart._x = point.x;
  3103.       vecStart._y = point.y;
  3104.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation + 20,10,100,1);
  3105.       _global.SoundManager.PlaySound("shoot");
  3106.    }
  3107.    function Gun_3Parallel(myGunName)
  3108.    {
  3109.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3110.       var point = {x:gunRef.emitter1._x,y:gunRef.emitter1._y};
  3111.       gunRef.localToGlobal(point);
  3112.       var vecStart = new Vector();
  3113.       vecStart._x = point.x;
  3114.       vecStart._y = point.y;
  3115.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3116.       point = {x:gunRef.emitter2._x,y:gunRef.emitter2._y};
  3117.       gunRef.localToGlobal(point);
  3118.       vecStart = new Vector();
  3119.       vecStart._x = point.x;
  3120.       vecStart._y = point.y;
  3121.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3122.       point = {x:gunRef.emitter3._x,y:gunRef.emitter3._y};
  3123.       gunRef.localToGlobal(point);
  3124.       vecStart = new Vector();
  3125.       vecStart._x = point.x;
  3126.       vecStart._y = point.y;
  3127.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3128.       _global.SoundManager.PlaySound("shoot");
  3129.    }
  3130.    function Gun_5Parallel(myGunName)
  3131.    {
  3132.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3133.       var point = {x:gunRef.emitter1._x,y:gunRef.emitter1._y};
  3134.       gunRef.localToGlobal(point);
  3135.       var vecStart = new Vector();
  3136.       vecStart._x = point.x;
  3137.       vecStart._y = point.y;
  3138.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3139.       point = {x:gunRef.emitter2._x,y:gunRef.emitter2._y};
  3140.       gunRef.localToGlobal(point);
  3141.       vecStart = new Vector();
  3142.       vecStart._x = point.x;
  3143.       vecStart._y = point.y;
  3144.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3145.       point = {x:gunRef.emitter3._x,y:gunRef.emitter3._y};
  3146.       gunRef.localToGlobal(point);
  3147.       vecStart = new Vector();
  3148.       vecStart._x = point.x;
  3149.       vecStart._y = point.y;
  3150.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3151.       point = {x:gunRef.emitter4._x,y:gunRef.emitter4._y};
  3152.       gunRef.localToGlobal(point);
  3153.       vecStart = new Vector();
  3154.       vecStart._x = point.x;
  3155.       vecStart._y = point.y;
  3156.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3157.       point = {x:gunRef.emitter5._x,y:gunRef.emitter5._y};
  3158.       gunRef.localToGlobal(point);
  3159.       vecStart = new Vector();
  3160.       vecStart._x = point.x;
  3161.       vecStart._y = point.y;
  3162.       this.AvatarFireBullet(vecStart,_root.avatar.gun._rotation,10,100,1);
  3163.       _global.SoundManager.PlaySound("shoot");
  3164.    }
  3165.    function Gun_Mines(myGunName)
  3166.    {
  3167.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3168.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3169.       gunRef.localToGlobal(point);
  3170.       var vecStart = new Vector();
  3171.       vecStart._x = point.x;
  3172.       vecStart._y = point.y;
  3173.       this.AvatarFireSpecialBullet(vecStart,_root.avatar.gun._rotation,0,100,8,"mine_2");
  3174.       _global.SoundManager.PlaySound("shoot");
  3175.    }
  3176.    function Gun_Teleport()
  3177.    {
  3178.       if(this.transitionState == 0)
  3179.       {
  3180.          var _loc3_ = new Vector();
  3181.          _loc3_._x = -1 * (_root._xmouse - _root.avatar._x);
  3182.          _loc3_._y = -1 * (_root._ymouse - _root.avatar._y);
  3183.          this.Effect_Teleport(_root.avatar._x,_root.avatar._y);
  3184.          this.FlashScreen();
  3185.          this.MoveWorld(_loc3_);
  3186.       }
  3187.    }
  3188.    function Gun_ShortStun(myGunName)
  3189.    {
  3190.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3191.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3192.       gunRef.localToGlobal(point);
  3193.       this.Effect_ShortStun(point.x,point.y);
  3194.       this.FlashScreen();
  3195.       this.ShakeScreen(20);
  3196.       var arrStunned = this.world.current.GetUnitsWithinDistance(point.x,point.y,125);
  3197.       var i = 0;
  3198.       while(i < arrStunned.length)
  3199.       {
  3200.          this.Effect_Stunned(_root[arrStunned[i]]._x,_root[arrStunned[i]]._y);
  3201.          _root[arrStunned[i]].Stun(120);
  3202.          i++;
  3203.       }
  3204.    }
  3205.    function Gun_LargeStun(myGunName)
  3206.    {
  3207.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3208.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3209.       gunRef.localToGlobal(point);
  3210.       this.Effect_LargeStun(point.x,point.y);
  3211.       this.FlashScreen();
  3212.       this.ShakeScreen(35);
  3213.       var arrStunned = this.world.current.GetUnitsWithinDistance(point.x,point.y,200);
  3214.       var i = 0;
  3215.       while(i < arrStunned.length)
  3216.       {
  3217.          this.Effect_Stunned(_root[arrStunned[i]]._x,_root[arrStunned[i]]._y);
  3218.          _root[arrStunned[i]].Stun(180);
  3219.          i++;
  3220.       }
  3221.    }
  3222.    function Gun_DamageBurst(myGunName)
  3223.    {
  3224.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3225.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3226.       gunRef.localToGlobal(point);
  3227.       this.DamageBurst(point.x,point.y,8);
  3228.    }
  3229.    function Gun_Convert(myGunName)
  3230.    {
  3231.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3232.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3233.       gunRef.localToGlobal(point);
  3234.       this.Effect_Convert(point.x,point.y);
  3235.       this.FlashScreen();
  3236.       this.ShakeScreen(60);
  3237.       this.world.current.ConvertDrones();
  3238.    }
  3239.    function SpawnSeeker(xloc, yloc, intDamage, intType)
  3240.    {
  3241.       var _loc3_ = "avatarSeeker_" + this.numBulletDepth;
  3242.       if(intType == 3)
  3243.       {
  3244.          _root.attachMovie("Ally_Orbital_Seeker",_loc3_,this.numBulletDepth);
  3245.       }
  3246.       else
  3247.       {
  3248.          _root.attachMovie("Ally_Seeker",_loc3_,this.numBulletDepth);
  3249.       }
  3250.       _root[_loc3_]._x = xloc;
  3251.       _root[_loc3_]._y = yloc;
  3252.       _root[_loc3_]._damage = intDamage;
  3253.       this.arrAllySeekers.push({name:_loc3_,from:""});
  3254.       this.numBulletDepth = this.numBulletDepth + 1;
  3255.       if(this.numBulletDepth > 105000)
  3256.       {
  3257.          this.numBulletDepth = 100000;
  3258.       }
  3259.    }
  3260.    function Gun_Seekers(myGunName)
  3261.    {
  3262.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3263.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3264.       gunRef.localToGlobal(point);
  3265.       var spawnedName = "avatarSeeker_" + this.numBulletDepth;
  3266.       _root.attachMovie("Ally_Seeker",spawnedName,this.numBulletDepth);
  3267.       _root[spawnedName]._x = point.x;
  3268.       _root[spawnedName]._y = point.y;
  3269.       _root[spawnedName]._damage = 10;
  3270.       this.arrAllySeekers.push({name:spawnedName,from:myGunName});
  3271.       this.numBulletDepth = this.numBulletDepth + 1;
  3272.       if(this.numBulletDepth > 105000)
  3273.       {
  3274.          this.numBulletDepth = 100000;
  3275.       }
  3276.    }
  3277.    function Gun_FighterBay(myGunName)
  3278.    {
  3279.       var blnFound = false;
  3280.       var i = 0;
  3281.       while(i < this.arrAllies.length)
  3282.       {
  3283.          if(_root[this.arrAllies[i]]._strCreatedBy == myGunName)
  3284.          {
  3285.             blnFound = true;
  3286.             break;
  3287.          }
  3288.          i++;
  3289.       }
  3290.       if(blnFound == false)
  3291.       {
  3292.          var gunRef = eval("_root.avatar.gun." + myGunName);
  3293.          var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3294.          gunRef.localToGlobal(point);
  3295.          this.SpawnFighter(point.x,point.y,gunRef._rotation,myGunName);
  3296.       }
  3297.    }
  3298.    function SpawnFighter(xloc, yloc, intRotation, myGunName)
  3299.    {
  3300.       var _loc3_ = "ally_" + this.numAllyDepth;
  3301.       _root.attachMovie("Ally_Fighter",_loc3_,this.numAllyDepth);
  3302.       _root[_loc3_]._x = xloc;
  3303.       _root[_loc3_]._y = yloc;
  3304.       _root[_loc3_]._rotation = intRotation;
  3305.       _root[_loc3_]._strCreatedBy = myGunName;
  3306.       this.arrAllies.push(_loc3_);
  3307.       this.numAllyDepth = this.numAllyDepth + 1;
  3308.       if(this.numAllyDepth > 600)
  3309.       {
  3310.          this.numAllyDepth = 560;
  3311.       }
  3312.    }
  3313.    function CleanAllies()
  3314.    {
  3315.       var _loc4_ = this.arrAllies.slice();
  3316.       var _loc3_ = 0;
  3317.       while(_loc3_ < _loc4_.length)
  3318.       {
  3319.          _root[_loc4_[_loc3_]].Dock();
  3320.          _loc3_ = _loc3_ + 1;
  3321.       }
  3322.    }
  3323.    function PauseAllies()
  3324.    {
  3325.       var _loc3_ = 0;
  3326.       while(_loc3_ < this.arrAllies.length)
  3327.       {
  3328.          _root[this.arrAllies[_loc3_]].TurnOff();
  3329.          _loc3_ = _loc3_ + 1;
  3330.       }
  3331.    }
  3332.    function UnPauseAllies()
  3333.    {
  3334.       var _loc3_ = 0;
  3335.       while(_loc3_ < this.arrAllies.length)
  3336.       {
  3337.          _root[this.arrAllies[_loc3_]].TurnOn();
  3338.          _loc3_ = _loc3_ + 1;
  3339.       }
  3340.    }
  3341.    function Gun_Mitosis(myGunName)
  3342.    {
  3343.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3344.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3345.       gunRef.localToGlobal(point);
  3346.       this.SpawnMitosis(point.x,point.y,3);
  3347.       _global.SoundManager.PlaySound("shoot");
  3348.    }
  3349.    function SpawnMitosis(xloc, yloc, round)
  3350.    {
  3351.       var _loc3_ = "avatarSeeker_" + this.numBulletDepth;
  3352.       _root.attachMovie("Ally_Mitosis",_loc3_,this.numBulletDepth);
  3353.       _root[_loc3_]._x = xloc;
  3354.       _root[_loc3_]._y = yloc;
  3355.       _root[_loc3_]._damage = 12;
  3356.       _root[_loc3_].intRound = round;
  3357.       var _loc4_ = 100;
  3358.       switch(round)
  3359.       {
  3360.          case 3:
  3361.             _loc4_ = 125;
  3362.             break;
  3363.          case 2:
  3364.             _loc4_ = 100;
  3365.             break;
  3366.          case 1:
  3367.             _loc4_ = 80;
  3368.             break;
  3369.          case 0:
  3370.             _loc4_ = 60;
  3371.       }
  3372.       _root[_loc3_]._yscale = _loc0_ = _loc4_;
  3373.       _root[_loc3_]._xscale = _loc0_;
  3374.       this.arrAllySeekers.push({name:_loc3_,from:""});
  3375.       this.numBulletDepth = this.numBulletDepth + 1;
  3376.       if(this.numBulletDepth > 105000)
  3377.       {
  3378.          this.numBulletDepth = 100000;
  3379.       }
  3380.       return _loc3_;
  3381.    }
  3382.    function Gun_Infector(myGunName)
  3383.    {
  3384.       var gunRef = eval("_root.avatar.gun." + myGunName);
  3385.       var point = {x:gunRef.emitter._x,y:gunRef.emitter._y};
  3386.       gunRef.localToGlobal(point);
  3387.       var spawnedName = "avatarSeeker_" + this.numBulletDepth;
  3388.       _root.attachMovie("Ally_Infector",spawnedName,this.numBulletDepth);
  3389.       _root[spawnedName]._x = point.x;
  3390.       _root[spawnedName]._y = point.y;
  3391.       _root[spawnedName]._damage = 0;
  3392.       _root[spawnedName]._type = 3;
  3393.       _root[spawnedName].intState = 3;
  3394.       this.arrAllySeekers.push({name:spawnedName,from:myGunName});
  3395.       this.numBulletDepth = this.numBulletDepth + 1;
  3396.       if(this.numBulletDepth > 105000)
  3397.       {
  3398.          this.numBulletDepth = 100000;
  3399.       }
  3400.    }
  3401.    function Gun_SpawnInfectors(xloc, yloc, num2Spawn)
  3402.    {
  3403.       var _loc4_ = 0;
  3404.       while(_loc4_ < num2Spawn)
  3405.       {
  3406.          var _loc3_ = "avatarSeeker_" + this.numBulletDepth;
  3407.          _root.attachMovie("Ally_Infector",_loc3_,this.numBulletDepth);
  3408.          _root[_loc3_]._x = xloc;
  3409.          _root[_loc3_]._y = yloc;
  3410.          _root[_loc3_]._damage = 0;
  3411.          _root[_loc3_]._type = 3;
  3412.          _root[_loc3_].intState = 2;
  3413.          this.arrAllySeekers.push({name:_loc3_,from:""});
  3414.          this.numBulletDepth = this.numBulletDepth + 1;
  3415.          if(this.numBulletDepth > 105000)
  3416.          {
  3417.             this.numBulletDepth = 100000;
  3418.          }
  3419.          _loc4_ = _loc4_ + 1;
  3420.       }
  3421.    }
  3422.    function AvatarFireBullet(emitterPos, direction, speed, size, damage)
  3423.    {
  3424.       var thisRef = this;
  3425.       var _loc3_ = "avatarBullet_" + this.numBulletDepth;
  3426.       var _loc4_ = new Vector();
  3427.       _loc4_._x = Math.cos(3.141592653589793 * direction / 180) * speed;
  3428.       _loc4_._y = Math.sin(3.141592653589793 * direction / 180) * speed;
  3429.       if(size == 100)
  3430.       {
  3431.          _root.attachMovie("component_bubble_orange_opt",_loc3_,this.numBulletDepth);
  3432.       }
  3433.       else
  3434.       {
  3435.          _root.attachMovie("component_bubble_orange",_loc3_,this.numBulletDepth);
  3436.       }
  3437.       _root[_loc3_]._x = emitterPos._x;
  3438.       _root[_loc3_]._y = emitterPos._y;
  3439.       _root[_loc3_]._xscale = size;
  3440.       _root[_loc3_]._yscale = size;
  3441.       _root[_loc3_]._damage = damage;
  3442.       _root[_loc3_].SetMovement(_loc4_._x,_loc4_._y);
  3443.       _root[_loc3_]._enemy = false;
  3444.       this.numBulletDepth = this.numBulletDepth + 1;
  3445.       if(this.numBulletDepth > 105000)
  3446.       {
  3447.          this.numBulletDepth = 100000;
  3448.       }
  3449.       this.arrBullets.push(_loc3_);
  3450.       _root[_loc3_].removeCallback = function(myName)
  3451.       {
  3452.          thisRef.RemoveBullet(myName);
  3453.       };
  3454.       return _loc3_;
  3455.    }
  3456.    function AvatarFireSpecialBullet(emitterPos, direction, speed, size, damage, type)
  3457.    {
  3458.       var thisRef = this;
  3459.       if(type == "mine_2")
  3460.       {
  3461.          var _loc3_ = "avatarBullet_" + this.numMineDepth;
  3462.       }
  3463.       else
  3464.       {
  3465.          _loc3_ = "avatarBullet_" + this.numBulletDepth;
  3466.       }
  3467.       var _loc4_ = new Vector();
  3468.       _loc4_._x = Math.cos(3.141592653589793 * direction / 180) * speed;
  3469.       _loc4_._y = Math.sin(3.141592653589793 * direction / 180) * speed;
  3470.       if(type == "mine_2")
  3471.       {
  3472.          _root.attachMovie(type,_loc3_,this.numMineDepth);
  3473.       }
  3474.       else
  3475.       {
  3476.          _root.attachMovie(type,_loc3_,this.numBulletDepth);
  3477.       }
  3478.       _root[_loc3_]._x = emitterPos._x;
  3479.       _root[_loc3_]._y = emitterPos._y;
  3480.       _root[_loc3_]._xscale = size;
  3481.       _root[_loc3_]._yscale = size;
  3482.       _root[_loc3_]._damage = damage;
  3483.       _root[_loc3_].SetMovement(_loc4_._x,_loc4_._y);
  3484.       _root[_loc3_]._enemy = false;
  3485.       if(type == "mine_2")
  3486.       {
  3487.          this.numMineDepth = this.numMineDepth + 1;
  3488.          if(this.numMineDepth > 199)
  3489.          {
  3490.             this.numMineDepth = 100;
  3491.          }
  3492.       }
  3493.       else
  3494.       {
  3495.          this.numBulletDepth = this.numBulletDepth + 1;
  3496.          if(this.numBulletDepth > 105000)
  3497.          {
  3498.             this.numBulletDepth = 100000;
  3499.          }
  3500.       }
  3501.       this.arrBullets.push(_loc3_);
  3502.       _root[_loc3_].removeCallback = function(myName)
  3503.       {
  3504.          thisRef.RemoveBullet(myName);
  3505.       };
  3506.       return _loc3_;
  3507.    }
  3508.    function DamageBurst(xLoc, yLoc, numDamage)
  3509.    {
  3510.       this.Effect_DamageBurst(xLoc,yLoc);
  3511.       this.FlashScreen();
  3512.       this.ShakeScreen(20);
  3513.       var _loc4_ = this.world.current.GetUnitsWithinDistance(xLoc,yLoc,150);
  3514.       var _loc3_ = 0;
  3515.       while(_loc3_ < _loc4_.length)
  3516.       {
  3517.          this.Effect_PierceExplosion(_root[_loc4_[_loc3_]]._x,_root[_loc4_[_loc3_]]._y);
  3518.          _root[_loc4_[_loc3_]].ReceiveDamage(numDamage,"");
  3519.          _loc3_ = _loc3_ + 1;
  3520.       }
  3521.    }
  3522.    function SmallDamageBurst(xLoc, yLoc)
  3523.    {
  3524.       this.Effect_SmallDamageBurst(xLoc,yLoc);
  3525.       this.FlashScreen();
  3526.       this.ShakeScreen(10);
  3527.       var _loc4_ = this.world.current.GetUnitsWithinDistance(xLoc,yLoc,75);
  3528.       var _loc3_ = 0;
  3529.       while(_loc3_ < _loc4_.length)
  3530.       {
  3531.          this.Effect_PierceExplosion(_root[_loc4_[_loc3_]]._x,_root[_loc4_[_loc3_]]._y);
  3532.          _root[_loc4_[_loc3_]].ReceiveDamage(10,"");
  3533.          _loc3_ = _loc3_ + 1;
  3534.       }
  3535.    }
  3536.    function EnemyFire(emitterPos, direction, speed, size, damage)
  3537.    {
  3538.       damage *= 3;
  3539.       var thisRef = this;
  3540.       var _loc3_ = "enemyBullet_" + this.numBulletDepth;
  3541.       var _loc4_ = new Vector();
  3542.       _loc4_._x = Math.cos(3.141592653589793 * direction / 180) * speed;
  3543.       _loc4_._y = Math.sin(3.141592653589793 * direction / 180) * speed;
  3544.       if(size == 100)
  3545.       {
  3546.          _root.attachMovie("component_bubble_red_opt",_loc3_,this.numBulletDepth);
  3547.       }
  3548.       else
  3549.       {
  3550.          _root.attachMovie("component_bubble_red",_loc3_,this.numBulletDepth);
  3551.       }
  3552.       _root[_loc3_]._x = emitterPos._x;
  3553.       _root[_loc3_]._y = emitterPos._y;
  3554.       _root[_loc3_]._xscale = size;
  3555.       _root[_loc3_]._yscale = size;
  3556.       _root[_loc3_]._damage = damage;
  3557.       _root[_loc3_].SetMovement(_loc4_._x,_loc4_._y);
  3558.       _root[_loc3_]._enemy = true;
  3559.       this.numBulletDepth = this.numBulletDepth + 1;
  3560.       if(this.numBulletDepth > 105000)
  3561.       {
  3562.          this.numBulletDepth = 100000;
  3563.       }
  3564.       this.arrBullets.push(_loc3_);
  3565.       _root[_loc3_].removeCallback = function(myName)
  3566.       {
  3567.          thisRef.RemoveBullet(myName);
  3568.       };
  3569.    }
  3570.    function EnemyFireSpecial(myType, emitterPos, direction, speed, size, damage)
  3571.    {
  3572.       if(myType == "mine")
  3573.       {
  3574.          damage *= 3;
  3575.          var thisRef = this;
  3576.          var _loc3_ = "enemyBullet_" + this.numBulletDepth;
  3577.          var _loc5_ = new Vector();
  3578.          _loc5_._x = 0;
  3579.          _loc5_._y = 0;
  3580.          _root.attachMovie("mine_1",_loc3_,this.numBulletDepth);
  3581.          _root[_loc3_]._x = emitterPos._x;
  3582.          _root[_loc3_]._y = emitterPos._y;
  3583.          _root[_loc3_]._xscale = size;
  3584.          _root[_loc3_]._yscale = size;
  3585.          _root[_loc3_]._damage = damage;
  3586.          _root[_loc3_].SetMovement(_loc5_._x,_loc5_._y);
  3587.          _root[_loc3_]._enemy = true;
  3588.          this.numBulletDepth = this.numBulletDepth + 1;
  3589.          this.arrBullets.push(_loc3_);
  3590.          _root[_loc3_].removeCallback = function(myName)
  3591.          {
  3592.             thisRef.RemoveBullet(myName);
  3593.          };
  3594.       }
  3595.       else if(myType == "sticky")
  3596.       {
  3597.          damage *= 3;
  3598.          var thisRef = this;
  3599.          _loc3_ = "enemySticky_" + this.numBulletDepth;
  3600.          _loc5_ = new Vector();
  3601.          _loc5_._x = Math.cos(3.141592653589793 * direction / 180) * speed;
  3602.          _loc5_._y = Math.sin(3.141592653589793 * direction / 180) * speed;
  3603.          _root.attachMovie("sticky",_loc3_,this.numBulletDepth);
  3604.          _root[_loc3_]._x = emitterPos._x;
  3605.          _root[_loc3_]._y = emitterPos._y;
  3606.          _root[_loc3_]._xscale = size;
  3607.          _root[_loc3_]._yscale = size;
  3608.          _root[_loc3_]._damage = damage;
  3609.          _root[_loc3_].SetMovement(_loc5_._x,_loc5_._y);
  3610.          _root[_loc3_]._enemy = true;
  3611.          this.numBulletDepth = this.numBulletDepth + 1;
  3612.          this.arrBullets.push(_loc3_);
  3613.          _root[_loc3_].removeCallback = function(myName)
  3614.          {
  3615.             thisRef.RemoveBullet(myName);
  3616.          };
  3617.       }
  3618.    }
  3619.    function outputPoints()
  3620.    {
  3621.       var _loc4_ = this.deltaList.length;
  3622.       var _loc2_ = 0;
  3623.       while(_loc2_ < _loc4_)
  3624.       {
  3625.          var _loc3_ = this.deltaList[_loc2_];
  3626.          _loc2_ = _loc2_ + 1;
  3627.       }
  3628.    }
  3629.    function BuildPointList()
  3630.    {
  3631.       this.deltaX = this.dblDestX - _root.avatar._x;
  3632.       this.deltaY = this.dblDestY - _root.avatar._y;
  3633.       var _loc12_ = this.easeFrames * this.checkFactor(this.easeFrames);
  3634.       var _loc10_ = this.deltaX / _loc12_;
  3635.       var _loc9_ = this.deltaY / _loc12_;
  3636.       if(this.easeFrames > 0)
  3637.       {
  3638.          var _loc8_ = undefined;
  3639.          _loc8_ = this.EaseIn();
  3640.          var _loc11_ = _loc8_.length;
  3641.          var _loc3_ = 0;
  3642.          while(_loc3_ < _loc11_)
  3643.          {
  3644.             var _loc4_ = _loc8_[_loc3_];
  3645.             var _loc5_ = _loc10_ * _loc4_;
  3646.             var _loc7_ = _loc9_ * _loc4_;
  3647.             var _loc6_ = new Point(_loc5_,_loc7_);
  3648.             this.deltaList.push(_loc6_);
  3649.             _loc3_ = _loc3_ + 1;
  3650.          }
  3651.       }
  3652.    }
  3653.    function EaseIn()
  3654.    {
  3655.       var _loc4_ = new Array();
  3656.       var _loc5_ = 1.5707963267948966 / this.easeFrames;
  3657.       var _loc2_ = 1;
  3658.       while(_loc2_ <= this.easeFrames)
  3659.       {
  3660.          var _loc3_ = _loc2_ * _loc5_;
  3661.          _loc4_.push(Math.sin(_loc3_));
  3662.          _loc2_ = _loc2_ + 1;
  3663.       }
  3664.       return _loc4_;
  3665.    }
  3666.    function EaseOut()
  3667.    {
  3668.       var _loc4_ = new Array();
  3669.       var _loc5_ = 1.5707963267948966 / this.easeFrames;
  3670.       var _loc2_ = 1;
  3671.       while(_loc2_ <= this.easeFrames)
  3672.       {
  3673.          var _loc3_ = _loc2_ * _loc5_;
  3674.          _loc4_.push(Math.sin(_loc3_ + 1.5707963267948966));
  3675.          _loc2_ = _loc2_ + 1;
  3676.       }
  3677.       return _loc4_;
  3678.    }
  3679.    function checkFactor(howMany)
  3680.    {
  3681.       var _loc4_ = undefined;
  3682.       if(howMany == this.easeFrames)
  3683.       {
  3684.          _loc4_ = this.EaseOut();
  3685.       }
  3686.       var _loc5_ = _loc4_.length;
  3687.       var _loc3_ = 0;
  3688.       var _loc2_ = 0;
  3689.       while(_loc2_ < _loc5_)
  3690.       {
  3691.          _loc3_ += _loc4_[_loc2_];
  3692.          _loc2_ = _loc2_ + 1;
  3693.       }
  3694.       return _loc3_ / howMany;
  3695.    }
  3696.    function CreateEffect(effectName, effectLocation, lockLocation, lockTarget)
  3697.    {
  3698.       var _loc3_ = "effect_" + this.effectDepth;
  3699.       _root.attachMovie(effectName,_loc3_,this.effectDepth);
  3700.       _root[_loc3_].gotoAndStop(effectName);
  3701.       _root[_loc3_]._x = effectLocation._x;
  3702.       _root[_loc3_]._y = effectLocation._y;
  3703.       this.arrEffects.push({name:_loc3_,locked:lockLocation,target:lockTarget});
  3704.       this.effectDepth = this.effectDepth + 1;
  3705.       if(this.effectDepth > 60000)
  3706.       {
  3707.          this.effectDepth = 50000;
  3708.       }
  3709.       return _loc3_;
  3710.    }
  3711.    function CreateUnderEffect(effectName, effectLocation, lockLocation, lockTarget)
  3712.    {
  3713.       var tempName = "effect_" + this.underEffectDepth;
  3714.       _root.effects_mc.attachMovie(effectName,tempName,this.underEffectDepth);
  3715.       var point = {x:effectLocation._x,y:effectLocation._y};
  3716.       _root.effects_mc.globalToLocal(point);
  3717.       var myEffect = eval("_root.effects_mc." + tempName);
  3718.       myEffect._x = point.x;
  3719.       myEffect._y = point.y;
  3720.       this.arrUnderEffects.push({name:tempName,locked:lockLocation,target:lockTarget});
  3721.       this.underEffectDepth = this.underEffectDepth + 1;
  3722.       if(this.underEffectDepth > 60000)
  3723.       {
  3724.          this.underEffectDepth = 10;
  3725.       }
  3726.       return tempName;
  3727.    }
  3728.    function CleanEffects()
  3729.    {
  3730.       var _loc3_ = 0;
  3731.       while(_loc3_ < this.arrEffects.length)
  3732.       {
  3733.          _root[this.arrEffects[_loc3_].name].removeMovieClip();
  3734.          _loc3_ = _loc3_ + 1;
  3735.       }
  3736.       delete this.arrEffects;
  3737.       this.arrEffects = new Array();
  3738.       _loc3_ = 0;
  3739.       while(_loc3_ < this.arrUnderEffects.length)
  3740.       {
  3741.          _root.effects_mc[this.arrUnderEffects[_loc3_].name].removeMovieClip();
  3742.          _loc3_ = _loc3_ + 1;
  3743.       }
  3744.       delete this.arrUnderEffects;
  3745.       this.arrUnderEffects = new Array();
  3746.    }
  3747.    function RemoveEffect(strName)
  3748.    {
  3749.       var _loc3_ = 0;
  3750.       while(_loc3_ < this.arrEffects.length)
  3751.       {
  3752.          if(strName == this.arrEffects[_loc3_].name)
  3753.          {
  3754.             _root[this.arrEffects[_loc3_].name].removeMovieClip();
  3755.             this.arrEffects.splice(_loc3_,1);
  3756.             break;
  3757.          }
  3758.          _loc3_ = _loc3_ + 1;
  3759.       }
  3760.    }
  3761.    function RemoveUnderEffect(strName)
  3762.    {
  3763.       var _loc3_ = 0;
  3764.       while(_loc3_ < this.arrUnderEffects.length)
  3765.       {
  3766.          if(strName == this.arrUnderEffects[_loc3_].name)
  3767.          {
  3768.             _root.effects_mc[this.arrUnderEffects[_loc3_].name].removeMovieClip();
  3769.             this.arrUnderEffects.splice(_loc3_,1);
  3770.             break;
  3771.          }
  3772.          _loc3_ = _loc3_ + 1;
  3773.       }
  3774.    }
  3775.    function MoveEffects(moveVector)
  3776.    {
  3777.       var _loc3_ = 0;
  3778.       while(_loc3_ < this.arrEffects.length)
  3779.       {
  3780.          if(this.arrEffects[_loc3_].locked == false)
  3781.          {
  3782.             _root[this.arrEffects[_loc3_].name]._x += moveVector._x;
  3783.             _root[this.arrEffects[_loc3_].name]._y += moveVector._y;
  3784.          }
  3785.          else
  3786.          {
  3787.             _root[this.arrEffects[_loc3_].name]._x = _root[this.arrEffects[_loc3_].target]._x;
  3788.             _root[this.arrEffects[_loc3_].name]._y = _root[this.arrEffects[_loc3_].target]._y;
  3789.          }
  3790.          _loc3_ = _loc3_ + 1;
  3791.       }
  3792.       _loc3_ = 0;
  3793.       while(_loc3_ < this.arrUnderEffects.length)
  3794.       {
  3795.          if(this.arrUnderEffects[_loc3_].locked == false)
  3796.          {
  3797.             _root.effects_mc[this.arrUnderEffects[_loc3_].name]._x += moveVector._x;
  3798.             _root.effects_mc[this.arrUnderEffects[_loc3_].name]._y += moveVector._y;
  3799.          }
  3800.          else
  3801.          {
  3802.             var _loc4_ = {x:_root[this.arrUnderEffects[_loc3_].target]._x,y:_root[this.arrUnderEffects[_loc3_].target]._y};
  3803.             _root.effects_mc.globalToLocal(_loc4_);
  3804.             _root.effects_mc[this.arrUnderEffects[_loc3_].name]._x = _loc4_.x;
  3805.             _root.effects_mc[this.arrUnderEffects[_loc3_].name]._y = _loc4_.y;
  3806.          }
  3807.          _loc3_ = _loc3_ + 1;
  3808.       }
  3809.    }
  3810.    function ScaleMiniBubble()
  3811.    {
  3812.       var _loc3_ = _root.avatar._width;
  3813.       var _loc4_ = _root.avatar._height;
  3814.       var _loc2_ = Math.round(Math.sqrt(_loc3_ * _loc3_ + _loc4_ * _loc4_)) - 5;
  3815.       _loc2_ /= 2;
  3816.       if(_loc2_ < 59.5)
  3817.       {
  3818.          _loc2_ = 59.5;
  3819.       }
  3820.       _root.miniBubblesLayer_mc.miniBubble._width = _root.miniBubblesLayer_mc.miniBubble._height = _loc2_ * 2;
  3821.       _root.miniBubblesLayer_mc.miniBubble._x = - _loc2_;
  3822.       _root.miniBubblesLayer_mc.miniBubble._y = - _loc2_;
  3823.    }
  3824.    function FlashScreen()
  3825.    {
  3826.       _root.flash_mc._visible = true;
  3827.       _root.flash_mc.gotoAndStop(2);
  3828.       _root.flash_mc.inside.gotoAndPlay(1);
  3829.    }
  3830.    function ShakeScreen(newDuration)
  3831.    {
  3832.       if(this.intShakeDuration == 0)
  3833.       {
  3834.          this.intShakeDuration = newDuration;
  3835.          this.intShakeStart = newDuration;
  3836.          this.intShakeCounter = 3;
  3837.          this.vecScreenCoords._x = _root.avatar._x;
  3838.          this.vecScreenCoords._y = _root.avatar._y;
  3839.       }
  3840.    }
  3841.    function HaltShaking()
  3842.    {
  3843.       if(this.vecScreenCoords._x != _root.avatar._x || this.vecScreenCoords._y != _root.avatar._y)
  3844.       {
  3845.          this.intShakeDuration = 0;
  3846.          var _loc5_ = this.vecScreenCoords._x - _root.avatar._x;
  3847.          var _loc4_ = this.vecScreenCoords._y - _root.avatar._y;
  3848.          _root.avatar._x = this.vecScreenCoords._x;
  3849.          _root.avatar._y = this.vecScreenCoords._y;
  3850.          var _loc3_ = new Vector();
  3851.          _loc3_._x = _loc5_;
  3852.          _loc3_._y = _loc4_;
  3853.          this.MoveWorld(_loc3_);
  3854.       }
  3855.    }
  3856.    function ManageShaking()
  3857.    {
  3858.       if(_global.gamePaused == false || _global.gamePaused == true && this.intBossState == 2)
  3859.       {
  3860.          if(this.intShakeDuration > 0)
  3861.          {
  3862.             this.intShakeDuration = this.intShakeDuration - 1;
  3863.             if(this.intShakeDuration == 0)
  3864.             {
  3865.                this.HaltShaking();
  3866.             }
  3867.             else
  3868.             {
  3869.                this.intShakeCounter = this.intShakeCounter - 1;
  3870.                if(this.intShakeCounter == 0)
  3871.                {
  3872.                   this.intShakeCounter = 3;
  3873.                   var _loc6_ = this.intShakeDuration / this.intShakeStart;
  3874.                   var _loc4_ = 4;
  3875.                   if(this.intShakeStart > 45)
  3876.                   {
  3877.                      _loc4_ = 6;
  3878.                   }
  3879.                   var _loc8_ = this.vecScreenCoords._x + this.RandNum(-1 * _loc4_,_loc4_) * _loc6_;
  3880.                   var _loc7_ = this.vecScreenCoords._y + this.RandNum(-1 * _loc4_,_loc4_) * _loc6_;
  3881.                   var _loc10_ = _loc8_ - _root.avatar._x;
  3882.                   var _loc9_ = _loc7_ - _root.avatar._y;
  3883.                   _root.avatar._x = _loc8_;
  3884.                   _root.avatar._y = _loc7_;
  3885.                   var _loc5_ = new Vector();
  3886.                   _loc5_._x = _loc10_;
  3887.                   _loc5_._y = _loc9_;
  3888.                   this.MoveWorld(_loc5_);
  3889.                }
  3890.             }
  3891.          }
  3892.       }
  3893.    }
  3894.    function RemoveAllySeekers()
  3895.    {
  3896.       var _loc3_ = 0;
  3897.       while(_loc3_ < this.arrAllySeekers.length)
  3898.       {
  3899.          if(_root[this.arrAllySeekers[_loc3_].name]._type != 2)
  3900.          {
  3901.             _root[this.arrAllySeekers[_loc3_].name].removeMovieClip();
  3902.             this.arrAllySeekers.splice(_loc3_,1);
  3903.             _loc3_ = _loc3_ - 1;
  3904.          }
  3905.          else if(_root[this.arrAllySeekers[_loc3_].name].intState != 2)
  3906.          {
  3907.             _root[this.arrAllySeekers[_loc3_].name].removeMovieClip();
  3908.             this.arrAllySeekers.splice(_loc3_,1);
  3909.             _loc3_ = _loc3_ - 1;
  3910.          }
  3911.          _loc3_ = _loc3_ + 1;
  3912.       }
  3913.    }
  3914.    function RemoveAllAllySeekers()
  3915.    {
  3916.       var _loc3_ = 0;
  3917.       while(_loc3_ < this.arrAllySeekers.length)
  3918.       {
  3919.          _root[this.arrAllySeekers[_loc3_].name].removeMovieClip();
  3920.          _loc3_ = _loc3_ + 1;
  3921.       }
  3922.       delete this.arrAllySeekers;
  3923.       this.arrAllySeekers = new Array();
  3924.    }
  3925.    function RemoveAlly(strName)
  3926.    {
  3927.       var _loc2_ = 0;
  3928.       while(_loc2_ < this.arrAllies.length)
  3929.       {
  3930.          if(strName == this.arrAllies[_loc2_])
  3931.          {
  3932.             this.arrAllies.splice(_loc2_,1);
  3933.             break;
  3934.          }
  3935.          _loc2_ = _loc2_ + 1;
  3936.       }
  3937.    }
  3938.    function ReportSeekerDead(strName)
  3939.    {
  3940.       var _loc2_ = 0;
  3941.       while(_loc2_ < this.arrAllySeekers.length)
  3942.       {
  3943.          if(this.arrAllySeekers[_loc2_].name == strName)
  3944.          {
  3945.             this.arrAllySeekers.splice(_loc2_,1);
  3946.             break;
  3947.          }
  3948.          _loc2_ = _loc2_ + 1;
  3949.       }
  3950.    }
  3951.    function GetNearestEnemy(testX, testY)
  3952.    {
  3953.       return this.world.current.GetClosestUnit(testX,testY);
  3954.    }
  3955.    function RandNum(minVal, maxVal)
  3956.    {
  3957.       return Math.round(Math.random() * (maxVal - minVal)) + minVal;
  3958.    }
  3959.    function ManageDisassembly()
  3960.    {
  3961.       if(this.upgradePath.currentNode.nodeData._arrSecondaryWeapons[0].type == 24)
  3962.       {
  3963.          if(this.intAssembledState == 1)
  3964.          {
  3965.             this.intAssembledFrame = this.intAssembledFrame + 1;
  3966.             _root.avatar.gun.gotoAndStop(this.intAssembledFrame);
  3967.             if(this.intAssembledFrame == 16)
  3968.             {
  3969.                this.intAssembledState = 2;
  3970.                this.AvatarBreakApart();
  3971.             }
  3972.          }
  3973.          else if(this.intAssembledState != 2)
  3974.          {
  3975.             if(this.intAssembledState == 3)
  3976.             {
  3977.                if(this.intAssembledFrame == 16)
  3978.                {
  3979.                   if(this.AvatarCheckIfAssembled() == true)
  3980.                   {
  3981.                      this.AvatarComeTogether();
  3982.                      this.intAssembledFrame = 15;
  3983.                      _root.avatar.gun.gotoAndStop(this.intAssembledFrame);
  3984.                   }
  3985.                }
  3986.                else
  3987.                {
  3988.                   this.intAssembledFrame = this.intAssembledFrame - 1;
  3989.                   _root.avatar.gun.gotoAndStop(this.intAssembledFrame);
  3990.                   if(this.intAssembledFrame == 1)
  3991.                   {
  3992.                      this.intAssembledState = 0;
  3993.                   }
  3994.                }
  3995.             }
  3996.          }
  3997.       }
  3998.    }
  3999.    function AvatarBreakApart()
  4000.    {
  4001.       var i = 1;
  4002.       while(i < 20)
  4003.       {
  4004.          if(i != 6)
  4005.          {
  4006.             var bubbleName = i + "_mc";
  4007.             var spawnName = i + "_reg";
  4008.             if(i < 5)
  4009.             {
  4010.                _root.attachMovie("component_bubble_yellow_disassembled",bubbleName,530 + i);
  4011.             }
  4012.             else
  4013.             {
  4014.                _root.attachMovie("component_bubble_disassembled",bubbleName,530 + i);
  4015.             }
  4016.             var scaleThis = 100;
  4017.             switch(i)
  4018.             {
  4019.                case 1:
  4020.                   scaleThis = 60;
  4021.                   break;
  4022.                case 2:
  4023.                   scaleThis = 130;
  4024.                   break;
  4025.                case 3:
  4026.                   scaleThis = 61.5;
  4027.                   break;
  4028.                case 4:
  4029.                   scaleThis = 61.5;
  4030.                   break;
  4031.                case 5:
  4032.                   scaleThis = 100;
  4033.                   break;
  4034.                case 7:
  4035.                   scaleThis = 100;
  4036.                   break;
  4037.                case 8:
  4038.                   scaleThis = 68.5;
  4039.                   break;
  4040.                case 9:
  4041.                   scaleThis = 68.5;
  4042.                   break;
  4043.                case 10:
  4044.                   scaleThis = 60;
  4045.                   break;
  4046.                case 11:
  4047.                   scaleThis = 60;
  4048.                   break;
  4049.                case 12:
  4050.                   scaleThis = 100;
  4051.                   break;
  4052.                case 13:
  4053.                   scaleThis = 56.6;
  4054.                   break;
  4055.                case 14:
  4056.                   scaleThis = 56.6;
  4057.                   break;
  4058.                case 15:
  4059.                   scaleThis = 60;
  4060.                   break;
  4061.                case 16:
  4062.                   scaleThis = 100;
  4063.                   break;
  4064.                case 17:
  4065.                   scaleThis = 60;
  4066.                   break;
  4067.                case 18:
  4068.                   scaleThis = 56.6;
  4069.                   break;
  4070.                case 19:
  4071.                   scaleThis = 56.6;
  4072.             }
  4073.             _root[bubbleName]._yscale = _loc0_ = scaleThis;
  4074.             _root[bubbleName]._xscale = _loc0_;
  4075.             var targetClip = eval("_root.avatar.gun." + spawnName);
  4076.             var point = {x:targetClip._x,y:targetClip._y};
  4077.             _root.avatar.gun.localToGlobal(point);
  4078.             _root[bubbleName]._x = point.x;
  4079.             _root[bubbleName]._y = point.y;
  4080.             _root[bubbleName].SetCounter(this.RandNum(2,18));
  4081.          }
  4082.          i++;
  4083.       }
  4084.    }
  4085.    function AvatarComeTogether()
  4086.    {
  4087.       var _loc2_ = 1;
  4088.       while(_loc2_ <= 19)
  4089.       {
  4090.          var _loc3_ = _loc2_ + "_mc";
  4091.          _root[_loc3_].removeMovieClip();
  4092.          _loc2_ = _loc2_ + 1;
  4093.       }
  4094.    }
  4095.    function AvatarCheckIfAssembled()
  4096.    {
  4097.       var _loc2_ = 1;
  4098.       while(_loc2_ <= 19)
  4099.       {
  4100.          var _loc3_ = _loc2_ + "_mc";
  4101.          if(_root[_loc3_]._isReady == false)
  4102.          {
  4103.             return false;
  4104.          }
  4105.          _loc2_ = _loc2_ + 1;
  4106.       }
  4107.       return true;
  4108.    }
  4109.    function Effect_PierceExplosion(xLoc, yLoc)
  4110.    {
  4111.       var _loc3_ = new Vector();
  4112.       _loc3_._x = xLoc;
  4113.       _loc3_._y = yLoc;
  4114.       _root[this.CreateEffect("pierce_shot_hit",_loc3_,false,"")]._rotation = this.RandNum(0,360);
  4115.    }
  4116.    function Effect_SeekerExplosion(xLoc, yLoc)
  4117.    {
  4118.       var _loc2_ = new Vector();
  4119.       _loc2_._x = xLoc;
  4120.       _loc2_._y = yLoc;
  4121.       this.CreateEffect("seeker_explosion",_loc2_,false,"");
  4122.    }
  4123.    function Effect_Stunned(xLoc, yLoc)
  4124.    {
  4125.       var _loc2_ = new Vector();
  4126.       _loc2_._x = xLoc;
  4127.       _loc2_._y = yLoc;
  4128.       this.CreateEffect("stunned",_loc2_,false,"");
  4129.    }
  4130.    function Effect_Teleport(xLoc, yLoc)
  4131.    {
  4132.       var _loc2_ = new Vector();
  4133.       _loc2_._x = xLoc;
  4134.       _loc2_._y = yLoc;
  4135.       this.CreateEffect("teleport_anim",_loc2_,false,"");
  4136.    }
  4137.    function Effect_ShortStun(xLoc, yLoc)
  4138.    {
  4139.       var _loc2_ = new Vector();
  4140.       _loc2_._x = xLoc;
  4141.       _loc2_._y = yLoc;
  4142.       this.CreateUnderEffect("stun_burst",_loc2_,false,"");
  4143.    }
  4144.    function Effect_LargeStun(xLoc, yLoc)
  4145.    {
  4146.       var _loc2_ = new Vector();
  4147.       _loc2_._x = xLoc;
  4148.       _loc2_._y = yLoc;
  4149.       this.CreateUnderEffect("stun_burst_large",_loc2_,false,"");
  4150.    }
  4151.    function Effect_DamageBurst(xLoc, yLoc)
  4152.    {
  4153.       var _loc2_ = new Vector();
  4154.       _loc2_._x = xLoc;
  4155.       _loc2_._y = yLoc;
  4156.       this.CreateUnderEffect("damage_burst",_loc2_,false,"");
  4157.    }
  4158.    function Effect_SmallDamageBurst(xLoc, yLoc)
  4159.    {
  4160.       var _loc2_ = new Vector();
  4161.       _loc2_._x = xLoc;
  4162.       _loc2_._y = yLoc;
  4163.       this.CreateUnderEffect("damage_burst_small",_loc2_,false,"");
  4164.    }
  4165.    function Effect_Sticky(xLoc, yLoc)
  4166.    {
  4167.       var _loc3_ = new Vector();
  4168.       _loc3_._x = xLoc;
  4169.       _loc3_._y = yLoc;
  4170.       var _loc4_ = this.CreateEffect("sticky_effect",_loc3_,false,"");
  4171.       _root[_loc4_]._rotation = this.RandNum(0,360);
  4172.       return _loc4_;
  4173.    }
  4174.    function Effect_Leech(xLoc, yLoc)
  4175.    {
  4176.       var _loc2_ = new Vector();
  4177.       _loc2_._x = xLoc;
  4178.       _loc2_._y = yLoc;
  4179.       this.CreateEffect("leech_effect",_loc2_,false,"");
  4180.    }
  4181.    function Effect_Infect(xLoc, yLoc, targetName)
  4182.    {
  4183.       var _loc2_ = new Vector();
  4184.       _loc2_._x = xLoc;
  4185.       _loc2_._y = yLoc;
  4186.       return this.CreateEffect("effect_infected",_loc2_,true,targetName);
  4187.    }
  4188.    function Effect_Convert(xLoc, yLoc)
  4189.    {
  4190.       var _loc2_ = new Vector();
  4191.       _loc2_._x = xLoc;
  4192.       _loc2_._y = yLoc;
  4193.       this.CreateUnderEffect("effect_convert",_loc2_,false,"");
  4194.    }
  4195.    function IsHelpNeeded()
  4196.    {
  4197.       if(this.avatarLife.Get() < this.maxAvatarLife * 0.8)
  4198.       {
  4199.          return true;
  4200.       }
  4201.       return false;
  4202.    }
  4203.    function IsBossNeeded(xloc, yloc)
  4204.    {
  4205.       if(this.blnBoss == false && this.intJumpsAsMax > 2)
  4206.       {
  4207.          this.blnBoss = true;
  4208.          this.intBossState = 1;
  4209.          this.intBossX = xloc;
  4210.          this.intBossY = yloc;
  4211.          return true;
  4212.       }
  4213.       return false;
  4214.    }
  4215.    function GetMaxLife()
  4216.    {
  4217.       return this.maxAvatarLife;
  4218.    }
  4219.    function CheckListAndAdd(myType)
  4220.    {
  4221.       var _loc4_ = false;
  4222.       var _loc3_ = 0;
  4223.       while(_loc3_ < _global.encountered.length)
  4224.       {
  4225.          if(_global.encountered[_loc3_] == myType)
  4226.          {
  4227.             _loc4_ = true;
  4228.             break;
  4229.          }
  4230.          _loc3_ = _loc3_ + 1;
  4231.       }
  4232.       if(_loc4_ == false)
  4233.       {
  4234.          _global.encountered.push(myType);
  4235.          this.blnFlushList = true;
  4236.       }
  4237.    }
  4238.    function FlushEncounteredList()
  4239.    {
  4240.       if(this.blnFlushList == true)
  4241.       {
  4242.          this.blnFlushList = false;
  4243.          if(this.mySharedObject.data.firstTime != undefined)
  4244.          {
  4245.             this.mySharedObject.data.enemyList = _global.encountered;
  4246.             this.mySharedObject.flush();
  4247.          }
  4248.       }
  4249.    }
  4250.    function IsAvatarLocked(myId)
  4251.    {
  4252.       var _loc2_ = 0;
  4253.       while(_loc2_ < _global.encounteredStates.length)
  4254.       {
  4255.          if(_global.encounteredStates[_loc2_] == myId)
  4256.          {
  4257.             return false;
  4258.          }
  4259.          _loc2_ = _loc2_ + 1;
  4260.       }
  4261.       return true;
  4262.    }
  4263. }
  4264.