This repository has been archived by the owner on Jul 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathminified.js
2 lines (2 loc) · 50.7 KB
/
minified.js
1
2
function startAllAutos(){startAutoRespawner(),startAutoClicker(),startAutoTargetSwapper(),startAutoAbilityUser(),startAutoItemUser(),startAutoUpgradeManager()}function loadSettings(){WebStorage.GetLocal("autoClickerEnabled")===!1&&toggleAutoClicker(),WebStorage.GetLocal("autoTargetSwapperEnabled")===!1&&toggleAutoTargetSwapper(),WebStorage.GetLocal("autoAbilityUserEnabled")===!1&&toggleAutoAbilityUser(),WebStorage.GetLocal("autoConsumableUserEnabled")===!1&&toggleAutoItemUser(),WebStorage.GetLocal("autoUpgraderEnabled")===!1&&toggleAutoUpgradeManager(),WebStorage.GetLocal("particleSpamEnabled")&&(spammer=setInterval(spamNoClick,1e3/clicksPerSecond),updateToggle("particles",!1)),WebStorage.GetLocal("fpsThrottleEnabled")===!0&&toggleFPS(),WebStorage.GetLocal("spamStatBoostersEnabled")===!1&&toggleSpamStatBoosters(),null!==WebStorage.GetLocal("survivalTime")&&(survivalTime=WebStorage.GetLocal("survivalTime"),$J("#survival_time").html(survivalTime))}function stopAllAutos(){stopAutoClicker(),stopAutoRespawner(),stopAutoTargetSwapper(),stopAutoAbilityUser(),stopAutoItemUser(),stopAutoUpgradeManager()}function startAutoClicker(){return autoClicker?void console.log("Autoclicker is already running!"):(autoClicker=setInterval(function(){if(gameRunning()){var e=Math.floor(Math.random()*autoClickerVariance*2)-autoClickerVariance,t=clicksPerSecond+e;g_Minigame.m_CurrentScene.m_nClicks+=t,g_msTickRate=1100;var a=g_Minigame.m_CurrentScene.m_rgGameData.lanes[g_Minigame.m_CurrentScene.m_rgPlayerData.current_lane].active_player_ability_gold_per_click,n=getTarget();if(n&&a>0&&n.m_data.hp>0){var r=n.m_data.gold*a*g_Minigame.m_CurrentScene.m_nClicks;g_Minigame.m_CurrentScene.ClientOverride("player_data","gold",g_Minigame.m_CurrentScene.m_rgPlayerData.gold+r),g_Minigame.m_CurrentScene.ApplyClientOverrides("player_data",!0)}var i=g_Minigame.m_CurrentScene.m_rgStoredCrits.length;if(g_Minigame.m_CurrentScene.m_rgStoredCrits=[],debug){i>1&&console.log("Clicking "+g_Minigame.m_CurrentScene.m_nClicks+" times this second. ("+i+" crits)."),console.log(1==i?"Clicking "+g_Minigame.m_CurrentScene.m_nClicks+" times this second. (1 crit).":"Clicking "+g_Minigame.m_CurrentScene.m_nClicks+" times this second.");var o=g_Minigame.m_CurrentScene.CalculateDamage(g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_per_click*userMaxElementMultiiplier*g_Minigame.m_CurrentScene.m_nClicks),s="(unknown)";o>1e9?s=o/1e9+"B":o>1e6?s=o/1e6+"M":o>1e3&&(s=o/1e3+"K"),console.log("We did roughly "+s+" damage in the last second.")}}},autoClickerFreq),void console.log("autoClicker has been started."))}function stopAutoClicker(){autoClicker?(clearInterval(autoClicker),autoClicker=null,console.log("autoClicker has been stopped.")):console.log("No autoClicker is running to stop.")}function startAutoAbilityUser(){return autoAbilityUser?void console.log("autoAbilityUser is already running!"):(autoAbilityUser=setInterval(function(){debug&&console.log("Checking if it's useful to use an ability.");var e=g_Minigame.CurrentScene().m_rgPlayerData.hp/g_Minigame.CurrentScene().m_rgPlayerTechTree.max_hp*100,t=getTarget(),a=g_Minigame.m_CurrentScene.m_rgGameData.lanes[g_Minigame.CurrentScene().m_rgPlayerData.current_lane],n=getGameLevel();for(var r in ABILITIES)if(ABILITIES.hasOwnProperty(r)){var i=ABILITIES[r];if(i>=ABILITIES.RESURRECTION){var o=i==ABILITIES.THROW_MONEY_AT_SCREEN;hasTimeLeftToUseConsumable(i,o)&&castAbility(i)}}if(hasAbility(ABILITIES.WORMHOLE)&&autoUseConsumables&&(n%CONTROL.rainingRounds===0&&n>CONTROL.speedThreshold||hasTimeLeftToUseConsumable(ABILITIES.WORMHOLE,!1))&&(debug&&console.log("Casting Wormhole! Allons-y!!!"),castAbility(ABILITIES.WORMHOLE)),spamStatBoosters&&(getAbilityItemQuantity(18)&&castAbility(18),getAbilityItemQuantity(19)&&castAbility(19)),t){var s=t.m_data.hp/t.m_data.max_hp*100,l=g_Minigame.m_CurrentScene.m_rgLaneData[g_Minigame.CurrentScene().m_rgPlayerData.current_lane].friendly_dps,u=t.m_data.hp/l,g=g_Minigame.m_CurrentScene.m_nCurrentLevel+1>=CONTROL.speedThreshold&&(g_Minigame.m_CurrentScene.m_nCurrentLevel+1)%CONTROL.rainingRounds!==0,c=2==t.m_data.type||t.m_data.type===!1;if(c&&s>75&&!currentLaneHasAbility(9)&&hasAbility(9)&&castAbility(9),0===t.m_data.type&&g_Minigame.m_CurrentScene.m_nCurrentLevel+1>=CONTROL.speedThreshold||c&&g){var d=hasAbility(ABILITIES.MORALE_BOOSTER),p=hasAbility(ABILITIES.GOOD_LUCK_CHARMS),m=hasAbility(ABILITIES.CRIT)&&autoUseConsumables;if(s>=90&&autoUseConsumables&&(hasAbility(ABILITIES.CRIPPLE_SPAWNER)||hasAbility(ABILITIES.CRIPPLE_MONSTER)))hasAbility(ABILITIES.CRIPPLE_SPAWNER)?castAbility(ABILITIES.CRIPPLE_SPAWNER):hasAbility(ABILITIES.CRIPPLE_MONSTER)&&castAbility(ABILITIES.CRIPPLE_MONSTER);else if(d||m||p){var _=abilityIsUnlocked(ABILITIES.MORALE_BOOSTER),b=abilityIsUnlocked(ABILITIES.GOOD_LUCK_CHARMS);if(!_&&!m||!b||(d||m)&&(p||!b)){var h=currentLaneHasAbility(ABILITIES.DECREASE_COOLDOWNS);(s>=70||h&&s>=60)&&(h||hasAbility(ABILITIES.DECREASE_COOLDOWNS)||!abilityIsUnlocked(ABILITIES.DECREASE_COOLDOWNS)||abilityCooldown(ABILITIES.DECREASE_COOLDOWNS)>60)&&(hasAbility(ABILITIES.DECREASE_COOLDOWNS)&&!currentLaneHasAbility(ABILITIES.DECREASE_COOLDOWNS)?(debug&&console.log("Triggering Decrease Cooldown!"),castAbility(ABILITIES.DECREASE_COOLDOWNS)):(m?(debug&&console.log("Using Crit!"),castAbility(ABILITIES.CRIT)):d&&(debug&&console.log("Casting Morale Booster!"),castAbility(ABILITIES.MORALE_BOOSTER)),p&&(debug&&console.log("Casting Good Luck Charm!"),castAbility(ABILITIES.GOOD_LUCK_CHARMS))))}}hasAbility(ABILITIES.TACTICAL_NUKE)&&(s>=useNukeOnSpawnerAbovePercent||2==t.m_data.type&&s>=useNukeOnBossAbovePercent)?(debug&&console.log("Nuclear launch detected."),castAbility(ABILITIES.TACTICAL_NUKE)):0===t.m_data.type&&hasAbility(ABILITIES.NAPALM)&&s>=useNukeOnSpawnerAbovePercent&&a.enemies.length>=4?(debug&&console.log("Triggering napalm!"),castAbility(ABILITIES.NAPALM)):0===t.m_data.type&&hasAbility(ABILITIES.CLUSTER_BOMB)&&s>=useNukeOnSpawnerAbovePercent&&a.enemies.length>=4&&(debug&&console.log("Triggering cluster bomb!"),castAbility(ABILITIES.CLUSTER_BOMB)),c&&(hasAbility(ABILITIES.MAX_ELEMENTAL_DAMAGE)&&autoUseConsumables&&s>useNukeOnBossAbovePercent&&(debug&&console.log("Using Max Elemental Damage on boss."),castAbility(ABILITIES.MAX_ELEMENTAL_DAMAGE)),hasAbility(ABILITIES.REFLECT_DAMAGE)&&autoUseConsumables&&s>useNukeOnBossAbovePercent&&(debug&&console.log("Using Reflect Damage on boss."),castAbility(ABILITIES.REFLECT_DAMAGE)))}else!g&&c&&(g||hasAbility(ABILITIES.RAINING_GOLD)&&autoUseConsumables&&s>useRainingGoldAbovePercent&&u>30&&n>CONTROL.disableGoldRainLevels&&(n<=CONTROL.speedThreshold||n%CONTROL.rainingRounds===0)&&(debug&&console.log("Using Raining Gold on boss."),castAbility(ABILITIES.RAINING_GOLD)));var A=hasAbility(ABILITIES.TREASURE)&&autoUseConsumables;(c||4==t.m_data.type)&&10>u&&(hasAbility(ABILITIES.METAL_DETECTOR)||A)&&(A?(debug&&console.log("Using Metal Detector via Treasure."),castAbility(ABILITIES.TREASURE)):(debug&&console.log("Using Metal Detector."),castAbility(ABILITIES.METAL_DETECTOR)))}for(var f=0,v=0,S=1;10>S;S++){var y=10*(S-1)+5;f+=y*a.player_hp_buckets[S],v+=a.player_hp_buckets[S]}var C=f/v,T=v/(v+a.player_hp_buckets[0])*100;if((useMedicsAtPercent>=e||useMedicsAtLanePercent>=C&&T>useMedicsAtLanePercentAliveReq)&&!g_Minigame.m_CurrentScene.m_bIsDead){debug&&(useMedicsAtPercent>=e&&console.log("Health below threshold. Need medics!"),useMedicsAtLanePercent>=C&&T>useMedicsAtLanePercentAliveReq&&console.log("Average lane below threshold. Need medics!"));var I=hasAbility(ABILITIES.PUMPED_UP)&&autoUseConsumables,E=hasAbility(ABILITIES.STEAL_HEALTH)&&autoUseConsumables;(hasAbility(ABILITIES.MEDICS)||I)&¤tLaneHasAbility(ABILITIES.MEDICS)<2?I?(debug&&console.log("Using Medics via Pumped Up!"),castAbility(ABILITIES.PUMPED_UP)):(debug&&console.log("Using Medics!"),castAbility(ABILITIES.MEDICS)):E&&useMedicsAtPercent>=e?(debug&&console.log("Using Steal Health in place of Medics!"),castAbility(ABILITIES.STEAL_HEALTH)):debug&&console.log("No medics to unleash!")}if(hasAbility(ABILITIES.RESURRECTION)&&autoUseConsumables&&a.player_hp_buckets[0]>=useResurrectToSaveCount&&(debug&&console.log("Using resurrection to save "+a.player_hp_buckets[0]+" lane allies."),castAbility(ABILITIES.RESURRECTION)),hasAbility(ABILITIES.LIKE_NEW)&&autoUseConsumables){var M=0;for(S=5;12>=S;S++)abilityIsUnlocked(S)&&(M+=abilityCooldown(S));1e3*M>=useLikeNewAboveCooldown&&(debug&&console.log("Using like new to save a total of "+M+" seconds of cooldown."),castAbility(ABILITIES.LIKE_NEW))}},abilityUseCheckFreq),void console.log("autoAbilityUser has been started."))}function startAutoItemUser(){autoUseConsumables=!0,console.log("Automatic use of consumables has been enabled.")}function stopAutoAbilityUser(){autoAbilityUser?(clearInterval(autoAbilityUser),autoAbilityUser=null,console.log("autoAbilityUser has been stopped.")):console.log("No autoAbilityUser is running to stop.")}function stopAutoItemUser(){autoUseConsumables=!1,console.log("Automatic use of consumables has been disabled.")}function disableAutoNukes(){useNukeOnSpawnerAbovePercent=200,console.log("Automatic nukes have been disabled")}function startAutoRespawner(){return autoRespawner?void console.log("autoRespawner is already running!"):(autoRespawner=setInterval(function(){debug&&console.log("Checking if the player is dead."),g_Minigame.m_CurrentScene.m_bIsDead&&(debug&&console.log("Player is dead. Respawning."),RespawnPlayer())},respawnCheckFreq),void console.log("autoRespawner has been started."))}function stopAutoRespawner(){autoRespawner?(clearInterval(autoRespawner),autoRespawner=null,console.log("autoRespawner has been stopped.")):console.log("No autoRespawner is running to stop.")}function startAutoTargetSwapper(){return autoTargetSwapper?void console.log("autoTargetSwapper is already running!"):(updateUserElementMultipliers(),autoTargetSwapperElementUpdate=setInterval(updateUserElementMultipliers,elementUpdateRate),autoTargetSwapper=setInterval(function(){debug&&console.log("Looking for a new target.");var e=getTarget();g_Minigame.m_CurrentScene.m_rgEnemies.each(function(t){compareMobPriority(t,e)&&(e=t)});var t=getTarget();e.m_data&&t.m_data&&e.m_data.id!=t.m_data.id?(debug&&null!==swapReason&&(console.log(swapReason),swapReason=null),g_Minigame.m_CurrentScene.m_rgPlayerData.current_lane!=e.m_nLane&&g_Minigame.m_CurrentScene.TryChangeLane(e.m_nLane),g_Minigame.m_CurrentScene.TryChangeTarget(e.m_nID)):e.m_data&&g_Minigame.m_CurrentScene.m_rgPlayerData.current_lane!=e.m_nLane&&g_Minigame.m_CurrentScene.TryChangeLane(e.m_nLane)},targetSwapperFreq),void console.log("autoTargetSwapper has been started."))}function stopAutoTargetSwapper(){autoTargetSwapper?(clearInterval(autoTargetSwapper),autoTargetSwapper=null,console.log("autoTargetSwapper has been stopped.")):console.log("No autoTargetSwapper is running to stop.")}function startAutoUpgradeManager(){function e(){if(debug&&console.log("Checking for worthwhile upgrades"),o=g_Minigame.CurrentScene(),!o.m_bUpgradesBusy&&(-1===l.id&&(t&&$J(document.body).removeClass("upgrade_waiting"),b(!0),T(!0),I()),-1!==l.id&&a&&l.cost<=o.m_rgPlayerData.gold)){var e=$J(".link",document.getElementById("upgr_"+l.id)).get(0);e?o.TryUpgrade(e):console.error("failed to find upgrade")}}if(autoUpgradeManager)return void console.log("UpgradeManager is already running!");var t=!0,a=!0,n=1,r=[.4,.3,.2,.1],i=clicksPerSecond+Math.ceil(autoClickerVariance/2),o=g_Minigame.CurrentScene(),s=!1,l={id:-1,cost:0},u=[{id:0,level:1},{id:11,level:1},{id:2,level:10},{id:1,level:10}],g=[11,13,16,18,17,14,15,12],c=7,d=[3,4,5,6],p=[],m=[],_=[];Object.keys(o.m_rgTuningData.upgrades).sort(function(e,t){return e-t}).forEach(function(e){var t=o.m_rgTuningData.upgrades[e];switch(t.type){case 0:p.push(+e);break;case 1:m.push(+e);break;case 2:_.push(+e)}});var b=function(){var e=!1;return function(t){return(!e||t)&&(e=d.map(function(e){return{id:e,level:o.GetUpgradeLevel(e)}}).sort(function(e,t){return t.level-e.level})),e}}(),h=function(e){return e=e||b(),o.m_rgTuningData.upgrades[4].multiplier*e.reduce(function(e,t,a){return e+t.level*r[a]},0)},A=function(e){if(!o.bHaveUpgrade(e))return!1;var t=o.m_rgTuningData.upgrades[e],a=t.required_upgrade;if(void 0!==a){var n=t.required_upgrade_level||1;return n<=o.GetUpgradeLevel(a)}return!0},f=function(e,t){var a,n=o.m_rgTuningData.upgrades[e],r=0,i=0,s=o.GetUpgradeLevel(e);void 0===t&&(t=s+1);for(var l=t-s;l>0;l--)r+=n.multiplier,i+=n.cost*Math.pow(n.cost_exponential_base,t-l);var u=n.required_upgrade;if(void 0!==u){var g=f(u,n.required_upgrade_level||1);g.cost>0&&(r+=g.boost,i+=g.cost,a=g.required||u)}return{boost:r,cost:i,required:a}},v=function(){for(var e,t,a={id:-1,cost:0};u.length>0;){if(e=u[0],t=e.id,o.GetUpgradeLevel(t)<e.level){a={id:t,cost:o.GetUpgradeCost(t)};break}u.shift()}return a},S=function(){var e={id:-1,cost:0};return autoBuyAbilities&&g.some(function(t){return A(t)&&o.GetUpgradeLevel(t)<1?(e={id:t,cost:o.GetUpgradeCost(t)},!0):void 0}),e},y=function(){var e,t,a={id:-1,cost:0,hpg:0};return p.forEach(function(n){e=f(n),t=o.m_rgTuningData.player.hp*e.boost/e.cost,t>=a.hpg&&(void 0!==e.required&&(n=e.required),cost=o.GetUpgradeCost(n),(cost<=o.m_rgPlayerData.gold||0===a.cost||cost<a.cost)&&(a={id:n,cost:cost,hpg:t}))}),a},C=function(){var e,t,a,r,s,l={id:-1,cost:0,dpg:0},u=o.m_rgPlayerTechTree.damage_per_click,g=o.m_rgTuningData.player.damage_per_click,d=o.m_rgPlayerTechTree.damage_multiplier_crit,p=.01*getAbilityItemQuantity(18),v=Math.min(o.m_rgPlayerTechTree.crit_percentage+p,1),S=b(),y=h(S);m.forEach(function(t){e=f(t),r=o.m_rgPlayerTechTree.base_dps*e.boost/i/e.cost,r>=l.dpg&&(void 0!==e.required&&(t=e.required),l={id:t,cost:o.GetUpgradeCost(t),dpg:r})}),A(c)&&(t=o.m_rgTuningData.upgrades[c],s=u*v*t.multiplier,a=o.GetUpgradeCost(c),r=s/a,r>=l.dpg&&(l={id:c,cost:a,dpg:r})),_.forEach(function(t){e=f(t),r=g*e.boost*(v*d+(1-v)*y)/e.cost,r>=l.dpg&&(void 0!==e.required&&(t=e.required),l={id:t,cost:o.GetUpgradeCost(t),dpg:r})}),t=o.m_rgTuningData.upgrades[4];var C=S.reduce(function(e,t){return e+t.level},1);a=t.cost*Math.pow(t.cost_exponential_base,C);var T=S.map(function(e){return{level:e.level}}),I=T[n-1].level;if(T[n-1].level++,n>1){var E=T[n-2].level;I>=E&&(T[n-2].level=I+1,T[n-1].level=E)}if(s=u*(1-v)*(h(T)-y),r=s/a,r>l.dpg){var M=S.filter(function(e){return e.level==I});M=M[Math.floor(Math.random()*M.length)].id,l={id:M,cost:a,dpg:r}}return l},T=function(){var e=!1;return function(t){if(e===!1||t){var a=o.m_rgPlayerTechTree.max_hp,n=o.m_rgGameData.lanes.reduce(function(e,t){return Math.max(e,t.enemies.reduce(function(e,t){return e+t.dps},0))},0);e=a/(n||4*o.m_rgGameData.level)}return e}}(),I=function(){if(l=v(),-1===l.id)if(T()<survivalTime)l=y();else{var e=C(),a=S();l=e.cost<a.cost||-1===a.id?e:a}-1!==l.id&&(t&&($J(".next_upgrade").removeClass("next_upgrade"),$J(document.getElementById("upgr_"+l.id)).addClass("next_upgrade")),debug&&console.log("next buy:",o.m_rgTuningData.upgrades[l.id].name,"("+FormatNumberForDisplay(l.cost)+")"))},E=function(e,t,a){var n=t+"_upgradeManager";e.prototype[n]||(e.prototype[n]=e.prototype[t]),e.prototype[t]=function(){this[n].apply(this,arguments),a.apply(this,arguments)}};if(E(CSceneGame,"TryUpgrade",function(){this.m_bUpgradesBusy&&(t&&$J(document.body).addClass("upgrade_waiting"),l.id=-1)}),E(CSceneGame,"ChangeLevel",function(){T(!0)<survivalTime&&I()}),upgradeManagerPrefilter=function(t,a,n){/ChooseUpgrade/.test(t.url)?n.success(function(){window.setTimeout(e,0)}).fail(function(){o.m_bNeedTechTree=!0,s=!0}):/GetPlayerData/.test(t.url)&&s&&n.success(function(t){var a=g_Server.m_protobuf_GetPlayerDataResponse.decode(t).toRaw(!0,!0);a.tech_tree&&(s=!1,o.m_bUpgradesBusy=!1,window.setTimeout(e,0))})},$J(document.body).removeClass("upgrade_waiting"),$J(".next_upgrade").removeClass("next_upgrade"),t){var M=function(e,t){return"-webkit-"+e+": "+t+"; "+e+": "+t+";"},w=".next_upgrade { "+M("filter","brightness(1.5) contrast(2)")+" }\n.next_upgrade.cantafford { "+M("filter","contrast(1.3)")+" }\n.next_upgrade .info .name, .next_upgrade.element_upgrade .level { color: #e1b21e; }\n#upgrades .next_upgrade .link { "+M("filter","brightness(0.8) hue-rotate(120deg)")+" }\n#elements .next_upgrade .link { "+M("filter","hue-rotate(120deg)")+" }\n.next_upgrade .cost { "+M("filter","hue-rotate(-120deg)")+" }\n.upgrade_waiting .next_upgrade { "+M("animation","blink 1s infinite alternate")+" }\n@-webkit-keyframes blink { to { opacity: 0.5; } }\n@keyframes blink { to { opacity: 0.5; } }",L=document.getElementById("upgradeManagerStyles");L||(L=document.createElement("style"),$J(L).attr("id","upgradeManagerStyles").appendTo("head")),$J(L).html(w)}autoUpgradeManager=setInterval(e,upgradeManagerFreq),console.log("autoUpgradeManager has been started.")}function stopAutoUpgradeManager(){function e(e,t){e.prototype[t]=e.prototype[t+"_upgradeManager"]||e.prototype[t]}autoUpgradeManager?(clearInterval(autoUpgradeManager),autoUpgradeManager=null,e(CSceneGame,"TryUpgrade"),e(CSceneGame,"ChangeLevel"),$J(document.body).removeClass("upgrade_waiting"),$J(".next_upgrade").removeClass("next_upgrade"),console.log("autoUpgradeManager has been stopped.")):console.log("No autoUpgradeManager is running to stop.")}function startFPSThrottle(){if(fpsThrottle)return void console.log("fpsThrottling is already running!");gameOldRenderer=g_Minigame.Render;var e=PIXI.ticker.shared;e.autoStart=!1,e.stop(),g_Minigame.Render=function(){},$J("#uicontainer").append('<div id="slow_fps_dialog"><div class="waiting_for_players_ctn"><div class="title_waiting">Currently in slow FPS mode to maximize performance, toggle this off in the settings if you want full FPS</div></div></div>'),$J("#slow_fps_dialog").css({position:"absolute",top:"0",left:"0",right:"0",height:"100%","background-color":"rgba(0,0,0,0.6)",color:"white","text-align":"center","font-size":"12px","z-index":"9",padding:"10px"});var t=function(){gameRunning()&&(m_nLastTick=!1,g_Minigame.CurrentScene().Tick(),requestAnimationFrame(function(){g_Minigame.Renderer.render(g_Minigame.CurrentScene().m_Container)}))};fpsThrottle=setInterval(t,slowRenderingFreq),console.log("fpsThrottle has been started.")}function stopFPSThrottle(){if(fpsThrottle){clearInterval(fpsThrottle);var e=PIXI.ticker.shared;e.autoStart=!0,e.start(),g_Minigame.Render=gameOldRenderer,g_Minigame.Render(),$J("#slow_fps_dialog").remove(),fpsThrottle=null,console.log("fpsThrottle has been stopped.")}else console.log("No fpsThrottle is running to stop.")}function initGUI(){updatePlayersInLane(),updatePlayersInRoom(),setInterval(function(){updatePlayersInLane(),updatePlayersInRoom()},1e4),addPointer(),addExtraUI(),CSceneGame.prototype.ClearNewPlayer=function(){if(this.m_spriteFinger){{WebStorage.SetLocal("mg_how2click",1)}$J("#newplayer").hide()}},CUI.prototype.UpdateLootNotification=function(){if(this.m_Game.m_rgPlayerData.loot&&0!==this.m_Game.m_rgPlayerData.loot.length&&this.m_Game.m_rgGameData.level>=lastLootLevel+10&&(0===lastLootCache.length||lastLootCache.toString()!==this.m_Game.m_rgPlayerData.loot.toString())){$J("#loot_notification").show();for(var e=this.m_Game.m_rgTuningData.abilities,t="",a=0;a<this.m_Game.m_rgPlayerData.loot.length;++a){var n=this.m_Game.m_rgPlayerData.loot[a];0!==a&&(t+=", "),t+=e[n.ability].name}$J("#loot_name").text(t),setTimeout(function(){$J("#loot_notification").fadeOut(1e3)},5e3),lastLootLevel=this.m_Game.m_rgGameData.level,lastLootCache=this.m_Game.m_rgPlayerData.loot,this.m_Game.m_rgPlayerData.loot=[]}}}function addPointer(){g_Minigame.m_CurrentScene.m_rgFingerTextures=[];for(var e=26,t=49,a=0;4>a;a++)for(var n=0;5>n;n++)g_Minigame.m_CurrentScene.m_rgFingerTextures.push(new PIXI.Texture(g_rgTextureCache.pointer.texture,{x:n*e,y:a*t,width:e,height:t}));g_Minigame.m_CurrentScene.m_nFingerIndex=0,g_Minigame.m_CurrentScene.m_spriteFinger=new PIXI.Sprite(g_Minigame.m_CurrentScene.m_rgFingerTextures[g_Minigame.m_CurrentScene.m_nFingerIndex]),g_Minigame.m_CurrentScene.m_spriteFinger.scale.x=g_Minigame.m_CurrentScene.m_spriteFinger.scale.y=2,g_Minigame.m_CurrentScene.m_containerParticles.addChild(g_Minigame.m_CurrentScene.m_spriteFinger)}function updatePlayersInLane(){var e="???";g_Minigame.m_CurrentScene.m_rgLaneData[g_Minigame.m_CurrentScene.m_rgPlayerData.current_lane]&&(e=g_Minigame.m_CurrentScene.m_rgLaneData[g_Minigame.m_CurrentScene.m_rgPlayerData.current_lane].players),$J("#players_in_lane").html(e)}function updatePlayersInRoom(){var e="???";g_Minigame.m_CurrentScene.m_rgLaneData[0]&&(e=g_Minigame.m_CurrentScene.m_rgLaneData[0].players+g_Minigame.m_CurrentScene.m_rgLaneData[1].players+g_Minigame.m_CurrentScene.m_rgLaneData[2].players),$J("#players_in_room").html(e)}function initEndDate(){var e=new Date;return e.getUTCHours()>=16&&e.setUTCDate(e.getUTCDate()+1),e.setUTCHours(16,0,0,0),e}function updateStats(){var e=function(){var e=getSecondsUntilEnd(),t=Math.floor(e/3600),a=Math.floor((e-3600*t)/60),n=e-3600*t-60*a,r="";return t>0?(r+=1==t?"an hour":t+" hours",a>1&&(r+=" and "+a+" minute"+(1==a?"":"s"))):a>0?(r+=1==a?"a minute":a+" minutes",n>1&&(r+=" and "+n+" second"+(1==n?"":"s"))):r+=1>=n?"about a second":"about "+n+" seconds",r};$J("#avg_completion_rate").html(parseFloat(getSecondsPerLevel()).toFixed(2)),$J("#estimated_end_level").html(Math.round(getSecondsUntilEnd()/getSecondsPerLevel()+g_Minigame.m_CurrentScene.m_rgGameData.level)),$J("#remaining_time").html(e())}function addExtraUI(){var e=$J(".title_activity").html();$J(".title_activity").html(e+' [<span id="players_in_room">0</span> in room]'),$J("#gamecontainer").append('<div id="settings"></div>'),$J("#settings").css({position:"absolute",background:"url('"+getUploadedFilePath("master/img/settings.png?v2")+"')","background-repeat":"no-repeat","background-position":"0px 0px",height:"300px",width:"500px","margin-top":"2px",bottom:"-65px",right:"10px","padding-top":"15px","padding-left":"12px"}),$J("#settings").append('<div id="music_toggle" class="toggle"><span class="value disabled"></span><span class="title">Music: </span></div>'),$J("#settings").append('<div id="sfx_toggle" class="toggle"><span class="value disabled"></span><span class="title">SFX: </span></div>'),$J("#settings").append('<div id="autoclicker_toggle" class="toggle"><span class="value enabled"></span><span class="title">Auto-Clicker: </span></div>'),$J("#settings").append('<div id="autotargetswapper_toggle" class="toggle"><span class="value enabled"></span><span class="title">Target Swapper: </span></div>'),$J("#settings").append('<div id="autoabilityuse_toggle" class="toggle"><span class="value enabled"></span><span class="title">Ability Use: </span></div>'),$J("#settings").append('<div id="autoconsume_toggle" class="toggle"><span class="value enabled"></span><span class="title">Consumable Use: </span></div>'),$J("#settings").append('<div id="autoupgrade_toggle" class="toggle"><span class="value enabled"></span><span class="title">Auto Upgrader: </span></div>'),$J("#settings").append('<div id="spamStatBoosters_toggle" class="toggle"><span class="value enabled"></span><span class="title">Spam StatBoosts: </span></div>'),$J("#settings").append('<div id="fps_toggle" class="toggle"><span class="value disabled"></span><span class="title">FPS Limiter: </span></div>'),$J("#settings").append('<div id="particles_toggle" class="toggle"><span class="value disabled"></span><span class="title">Particles: </span></div>'),$J("#settings").append('<div id="survival_time_toggle" class="toggle"><span class="title" style="top: 0px;">Survival Time: <span id="increase_survival" class="arrow"> ^ </span></span><span class="title" style="top: 0px;"><span id="survival_time">30</span> seconds<span id="decrease_survival" class="arrow"> v </span></span></div>'),$J("#sfx_toggle").click(function(e){e.stopPropagation(),toggleSFX(!0)}),$J("#music_toggle").click(function(e){e.stopPropagation(),toggleMusic(!0)}),$J("#autoclicker_toggle").click(function(e){e.stopPropagation(),toggleAutoClicker()}),$J("#autotargetswapper_toggle").click(function(e){e.stopPropagation(),toggleAutoTargetSwapper()}),$J("#autoabilityuse_toggle").click(function(e){e.stopPropagation(),toggleAutoAbilityUser()}),$J("#autoconsume_toggle").click(function(e){e.stopPropagation(),toggleAutoItemUser()}),$J("#autoupgrade_toggle").click(function(e){e.stopPropagation(),toggleAutoUpgradeManager()}),$J("#fps_toggle").click(function(e){e.stopPropagation(),toggleFPS()}),$J("#particles_toggle").click(function(e){e.stopPropagation(),toggleSpammer()}),$J("#spamStatBoosters_toggle").click(function(e){e.stopPropagation(),toggleSpamStatBoosters()}),$J("#increase_survival").click(function(e){e.stopPropagation(),survivalTime+=10,WebStorage.SetLocal("survivalTime",survivalTime),$J("#survival_time").html(survivalTime)}),$J("#decrease_survival").click(function(e){e.stopPropagation(),0>survivalTime-10||(survivalTime-=10,WebStorage.SetLocal("survivalTime",survivalTime),$J("#survival_time").html(survivalTime))}),toggleSFX(!1),toggleMusic(!1),$J("#settings").click(function(){var e=$J("#settings");e.animate({bottom:-65==parseInt(e.css("bottom"),10)?-e.outerHeight():-65})}),$J("#gamecontainer").append('<div id="statistics"></div>'),$J("#statistics").css({position:"absolute",background:"url('"+getUploadedFilePath("master/img/stats.png")+"')","background-repeat":"no-repeat","background-position":"0px 0px",height:"250px",width:"500px","margin-top":"2px",bottom:"-65px",left:"10px","padding-top":"15px","padding-left":"25px"}),$J("#statistics").append('<div id="stat_player_dpc" class="stat"><span class="title">Dmg Per Click: </span><span class="value">0</span></div>'),$J("#statistics").append('<div id="stat_player_dps" class="stat"><span class="title">Dmg Per Second: </span><span class="value">0</span></div>'),$J("#statistics").append('<div id="stat_player_crit" class="stat"><span class="title">Critical Chance: </span><span class="value">0</span></div>'),$J("#statistics").append('<div id="stat_crit_mul" class="stat"><span class="title">Critical Dmg Multiplier: </span><span class="value">0</span></div>'),$J("#statistics").append('<div id="stat_elemental_mul" class="stat"><span class="title">Elemental Multiplier: </span><span class="value">0</span></div>'),$J("#statistics").append('<div id="stat_elemental_dpc" class="stat"><span class="title">Elemental DPC: </span><span class="value">0</span></div>'),$J("#statistics").append('<div id="stat_elemental_dps" class="stat"><span class="title">Elemental DPS: </span><span class="value">0</span></div>'),$J("#statistics").append('<div id="stat_boss_loot" class="stat"><span class="title">Boss Loot Chance: </span><span class="value">0</span></div>'),$J("#footer_spacer").css({height:"175px"}),$J("canvas").css({position:"relative","z-index":"5"}),$J("#uicontainer").css({"z-index":"6"}),setTimeout(function(){$J(".tv_ui").css({background:"url('"+getUploadedFilePath("master/img/game_frame_tv.png")+"')"}),$J("#info_block").append('<div id="irc_join" style="height: 30px"></div>'),$J("#irc_join").click(function(e){e.stopPropagation(),window.open("http://chat.mibbit.com/?channel=%23SMG_"+g_GameID+"&server=irc.mibbit.net&nick="+getUserName(),"_blank")})},1e3),setInterval(function(){function e(){return Math.max(g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_air,g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_earth,g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_fire,g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_water)}$J("#statistics #stat_player_dpc .value").html(FormatNumberForDisplay(g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_per_click,5)),$J("#statistics #stat_player_dps .value").html(FormatNumberForDisplay(g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_per_click*clicksPerSecond,5)),$J("#statistics #stat_player_crit .value").html(FormatNumberForDisplay(Math.round(100*g_Minigame.m_CurrentScene.m_rgPlayerTechTree.crit_percentage),5)+"%"),$J("#statistics #stat_crit_mul .value").html(FormatNumberForDisplay(g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_crit,5)+"x"),$J("#statistics #stat_elemental_mul .value").html(FormatNumberForDisplay(e())+"x"),$J("#statistics #stat_elemental_dpc .value").html(FormatNumberForDisplay(e()*g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_per_click,5)),$J("#statistics #stat_elemental_dps .value").html(FormatNumberForDisplay(e()*g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_per_click*clicksPerSecond,5)),$J("#statistics #stat_boss_loot .value").html(FormatNumberForDisplay(Math.round(100*g_Minigame.m_CurrentScene.m_rgPlayerTechTree.boss_loot_drop_percentage,5))+"%")},1e3),$J("#statistics").click(function(){var e=$J("#statistics");e.animate({bottom:-65==parseInt(e.css("bottom"),10)?-e.outerHeight():-65})}),customCSS(),addCustomButtons(),$J("#footer").css("z-index",-1)}function addCustomButtons(){$J('<div style="height: 52px; position: absolute; bottom: 85px; left: 828px; z-index: 12;" onclick="SmackTV();"><br><br><span style="font-size:10px; padding: 12px; color: gold;">Smack TV</span></div>').insertBefore("#row_bottom"),$J(".game_options").remove(),$J('<a href="http://steamcommunity.com/minigame/" class="leave_game_btn"><span style="padding-right: 50px;">Close</span><br><span style="padding-right: 50px;">Game</span></a>').insertAfter("#settings"),$J(".leave_game_btn").css({width:"120px",position:"absolute",bottom:"72px","z-index":"12",left:"340px",background:"url('http://steamcommunity-a.akamaihd.net/public/images/promo/towerattack/leave_game_btn.png')","background-repeat":"no-repeat","background-position":"-75px 0px",height:"56px","float":"right","margin-right":"7px","padding-top":"14px",cursor:"pointer"}),$J('<div class="leave_game_helper">You can safely close the game or leave this screen at any time—you will continue collecting gold and damaging monsters even while away from your computer. Check back occasionally to see how you\'re doing and use in-game gold to purchase upgrades.</div>').insertAfter("#settings"),$J(".leave_game_helper").css({left:"150px",top:"initial",bottom:"-20px","z-index":"12"}),$J(".leave_game_btn").mouseover(function(){$J(".leave_game_helper").show()}).mouseout(function(){$J(".leave_game_helper").hide()}),$J(".leave_game_helper").hide();var e=document.querySelector(".breadcrumbs");if(e){var t=document.createElement("span");t.textContent=" > ",e.appendChild(t),t=document.createElement("span"),t.style.color="#D4E157",t.style.textShadow="1px 1px 0px rgba( 0, 0, 0, 0.3 )",t.textContent="Room "+g_GameID,e.appendChild(t),t=document.createElement("span"),t.textContent=" > ",e.appendChild(t),t=document.createElement("span"),t.style.color="#F089B2",t.style.textShadow="1px 1px 0px rgba( 0, 0, 0, 0.3 )",t.innerHTML='Expected Level: <span id="estimated_end_level">0</span>, Seconds Per Level <span id="avg_completion_rate">0</span>',e.appendChild(t),t=document.createElement("span"),t.textContent=" > ",e.appendChild(t),t=document.createElement("span"),t.style.color="#ACA5F2",t.style.textShadow="1px 1px 0px rgba( 0, 0, 0, 0.3 )",t.innerHTML='Remaining Time: <span id="remaining_time">0 Seconds</span>.',e.appendChild(t),updateStats(),setInterval(function(){updateStats()},1e4),"undefined"!=typeof GM_info&&(t=document.createElement("span"),t.style.cssFloat="right",t.style.color="#D4E157",t.style.textShadow="1px 1px 0px rgba( 0, 0, 0, 0.3 )",t.innerHTML='<a target="_blank" href="'+GM_info.script.namespace+'">'+GM_info.script.name+" v"+GM_info.script.version+"</a>",e.appendChild(t))}}function customCSS(){var e="";e+="#settings .toggle { position: relative; margin-top: 10px; width: 30%; height: 32px; z-index: 0; float: left; margin-left: 10px;} ",e+="#settings span.title { position: relative; top: 10px; float: right; right:15px; text-align:right; width: 80%;} ",e+="#settings span.value { position: relative; float: right; right:10px; display: inline-block; z-index:11; cursor: pointer;} ",e+="#settings span.value.enabled { background: url('"+getUploadedFilePath("master/img/icons.png")+"'); background-repeat: no-repeat;background-position:0px 0px;width:30px;height:30px; } ",e+="#settings span.value.enabled:hover { background: url('"+getUploadedFilePath("master/img/icons.png")+"'); background-repeat: no-repeat;background-position:-30px 0px;width:30px;height:30px; } ",e+="#settings span.value.disabled { background: url('"+getUploadedFilePath("master/img/icons.png")+"'); background-repeat: no-repeat;background-position:0px -30px;width:30px;height:32px; } ",e+="#settings span.value.disabled:hover { background: url('"+getUploadedFilePath("master/img/icons.png")+"'); background-repeat: no-repeat;background-position:-30px -30px;width:30px;height:32px; } ",e+="#statistics .stat { position: relative; margin-top: 5px; width: 40%; height: 32px; z-index: 0; margin-left: 25px; float:left;} ",e+="#statistics span.value { position: relative; float: right; margin-right: 30px; text-align: right; width: 100%;} ",e+="#statistics span.title { position: relative; width: 100%; font-weight: bold;} ",e+=".toggle_btn {background: #d6d6d6;-webkit-border-radius: 7; -moz-border-radius: 7; border-radius: 7px; color: #333; text-decoration: none; text-align: center;cursor: pointer;font-weight: bold;} ",e+=".toggle_btn:hover { background: #85c8f2; text-decoration: none; color: #fff;cursor: pointer;font-weight: bold;} ",e+="#activeinlanecontainer:hover {height:auto;background:rgba(50,50,50,0.9);padding-bottom:10px;position:absolute;z-index:1} #activeinlanecontainer:hover ~ #activitylog {margin-top:97px} #activitylog {margin-top: 29px} ",e+="#leaderboard_wrapper {overflow: hidden; height: 360px; width: 261px; position: relative; margin: 50px 0px 0px 5px; padding: 5px;} #activeinlanecontainer:hover ~ #leaderboard_wrapper {margin-top: 118px}",e+="#info_hp { position:relative; top:28px; text-align: center;}",e+="#irc_join {position: relative; width: 175px; height: 30px; top: -50px; left: 30px; cursor: pointer;}",e+=".arrow {font-weight: bold; background-color: #bebebe; width: 20px; color: #434340; border-radius: 7px; float: right; text-align: center; margin-top: -2px; margin-left: 10px; }",$J("head").append("<style>"+e+"</style>")
}function updateToggle(e,t){t?$J("#"+e+"_toggle span.value").removeClass("enabled").addClass("disabled"):$J("#"+e+"_toggle span.value").removeClass("disabled").addClass("enabled")}function toggleSFX(e){var t=WebStorage.GetLocal("minigame_mute");e&&(t=!t,WebStorage.SetLocal("minigame_mute",t)),updateToggle("sfx",t)}function toggleMusic(e){e&&g_AudioManager.ToggleMusic(),updateToggle("music",WebStorage.GetLocal("minigame_mutemusic"))}function toggleAutoClicker(){autoClicker?stopAutoClicker():startAutoClicker(),WebStorage.SetLocal("autoClickerEnabled",null!==autoClicker),updateToggle("autoclicker",!autoClicker)}function toggleAutoTargetSwapper(){autoTargetSwapper?stopAutoTargetSwapper():startAutoTargetSwapper(),WebStorage.SetLocal("autoTargetSwapperEnabled",null!==autoTargetSwapper),updateToggle("autotargetswapper",!autoTargetSwapper)}function toggleAutoAbilityUser(){autoAbilityUser?stopAutoAbilityUser():startAutoAbilityUser(),WebStorage.SetLocal("autoAbilityUserEnabled",null!==autoAbilityUser),updateToggle("autoabilityuse",!autoAbilityUser)}function toggleAutoItemUser(){autoUseConsumables?stopAutoItemUser():startAutoItemUser(),WebStorage.SetLocal("autoConsumableUserEnabled",autoUseConsumables),updateToggle("autoconsume",!autoUseConsumables)}function toggleAutoUpgradeManager(){autoUpgradeManager?stopAutoUpgradeManager():startAutoUpgradeManager(),WebStorage.SetLocal("autoUpgraderEnabled",null!==autoClicker),updateToggle("autoupgrade",!autoUpgradeManager)}function toggleFPS(){fpsThrottle?stopFPSThrottle():startFPSThrottle(),WebStorage.SetLocal("fpsThrottleEnabled",null!==fpsThrottle),updateToggle("fps",null===fpsThrottle)}function toggleSpamStatBoosters(){spamStatBoosters=!spamStatBoosters,WebStorage.SetLocal("spamStatBoostersEnabled",spamStatBoosters),updateToggle("spamStatBoosters",!spamStatBoosters)}function spamNoClick(){if(autoClicker){var e=g_Minigame.m_CurrentScene.m_nClicks;g_Minigame.m_CurrentScene.DoClick({data:{getLocalPosition:function(){var e=getTarget(),t=440*e.m_nLane;return{x:e.m_Sprite.position.x-t,y:e.m_Sprite.position.y-52}}}}),g_Minigame.m_CurrentScene.m_nClicks=e}}function toggleSpammer(){spammer?(clearInterval(spammer),WebStorage.SetLocal("particleSpamEnabled",!1),spammer=null):confirm("Are you SURE you want to do this? This leads to massive memory leaks fairly quickly.")&&(WebStorage.SetLocal("particleSpamEnabled",!0),spammer=setInterval(spamNoClick,1e3/clicksPerSecond)),updateToggle("particles",null===spammer)}function initLeaderboard(){var e=document.createElement("div");e.id="leaderboard_wrapper",e.style.display="none",document.getElementById("col_right").appendChild(e);var t=document.createElement("table");t.id="leaderboard";var a=document.createElement("tr");a.style.fontSize="11px",a.style.color="#ddd";var n=document.createElement("th"),r=document.createElement("th"),i=document.createElement("th");n.appendChild(document.createTextNode("Rank")),r.appendChild(document.createTextNode("Name")),i.appendChild(document.createTextNode("Level")),a.appendChild(n),a.appendChild(r),a.appendChild(i),t.appendChild(a),document.getElementById("leaderboard_wrapper").appendChild(t);var o=document.createElement("div");o.style.fontSize="12px",o.style.textAlign="center",o.innerHTML='Data by <a href="http://steamga.me/" style="color:#ddd;" alt="http://steamga.me/" target="_blank">steamga.me</a>',document.getElementById("leaderboard_wrapper").appendChild(o);var s=document.createElement("div");s.id="leaderboard_toggler",s.onclick=function(){toggleLeaderboard()},s.style.position="absolute",s.style.bottom="-48px",s.style.color="black",s.style.textAlign="center",s.style.width="261px",s.style.cursor="pointer",s.appendChild(document.createTextNode("Show Leaderboards")),document.getElementById("col_right").appendChild(s),getLeaderboard(),setInterval(function(){getLeaderboard()},3e4)}function drawLeaderboardRoom(e){var t=document.createElement("tr");t.className="leaderboard_item",t.style.height="23px",t.style.fontSize="10px";var a=document.createElement("td");a.appendChild(document.createTextNode("#"+e.position));var n=document.createElement("td");n.style.textAlign="center",n.appendChild(document.createTextNode(e.name));var r=document.createElement("td");r.style.textAlign="right",r.appendChild(document.createTextNode(e.level)),e.id==g_GameID&&(t.style.color="#d4e157"),t.appendChild(a),t.appendChild(n),t.appendChild(r),document.getElementById("leaderboard").appendChild(t)}function getLeaderboard(){GM_xmlhttpRequest({method:"GET",url:"http://steamga.me/data/api/leaderboard.json",onload:function(e){console.log("Downloading new leaderboard...");for(var t=document.getElementsByClassName("leaderboard_item");t.length>0;)t[0].parentNode.removeChild(t[0]);var a=JSON.parse(e.responseText),n=Object.keys(a).map(function(e){return a[e]});n.sort(function(e,t){return t.level-e.level}),n.map(function(e){drawLeaderboardRoom(e)})}})}function toggleLeaderboard(){var e=document.getElementById("leaderboard_wrapper"),t=document.getElementById("activitylog"),a=document.getElementById("leaderboard_toggler");"block"==e.style.display?(e.style.display="none",t.style.display="block",a.innerHTML="Show Leaderboards"):(e.style.display="block",t.style.display="none",a.innerHTML="Show Activity")}function getSecondsUntilEnd(){return endDate.getTime()/1e3-g_Minigame.m_CurrentScene.m_nTime}function getSecondsPerLevel(){return(g_Minigame.m_CurrentScene.m_rgGameData.timestamp-g_Minigame.m_CurrentScene.m_rgGameData.timestamp_game_start)/g_Minigame.m_CurrentScene.m_rgGameData.level}function hasTimeLeftToUseConsumable(e,t){return(17==e||22==e)&&(t*=6),t?getSecondsUntilEnd()<=getAbilityItemQuantity(e)*abilityCooldown(e):getSecondsUntilEnd()<=getAbilityItemQuantity(e)*abilityCooldown(e)+60*minutesBufferForConsumableDump}function getEstimatedLevelsLeft(){return getSecondsUntilEnd()/getSecondsPerLevel()}function castAbility(e){hasAbility(e)&&(e<=ABILITIES.NAPALM&&null!==document.getElementById("ability_"+e)?g_Minigame.CurrentScene().TryAbility(document.getElementById("ability_"+e).childElements()[0]):null!==document.getElementById("abilityitem_"+e)&&g_Minigame.CurrentScene().TryAbility(document.getElementById("abilityitem_"+e).childElements()[0]))}function currentLaneHasAbility(e){return laneHasAbility(g_Minigame.CurrentScene().m_rgPlayerData.current_lane,e)}function laneHasAbility(e,t){try{return g_Minigame.m_CurrentScene.m_rgLaneData[e].abilities[t]?g_Minigame.m_CurrentScene.m_rgLaneData[e].abilities[t]:0}catch(a){return 0}}function abilityIsUnlocked(e){return e<=ABILITIES.NAPALM?(1<<e&g_Minigame.CurrentScene().m_rgPlayerTechTree.unlocked_abilities_bitfield)>0:getAbilityItemQuantity(e)>0}function getAbilityItemQuantity(e){for(var t=0;t<g_Minigame.CurrentScene().m_rgPlayerTechTree.ability_items.length;++t){var a=g_Minigame.CurrentScene().m_rgPlayerTechTree.ability_items[t];if(a.ability==e)return a.quantity}return 0}function abilityCooldown(e){return g_Minigame.CurrentScene().GetCooldownForAbility(e)}function hasAbility(e){return abilityIsUnlocked(e)&&abilityCooldown(e)<=0}function updateUserElementMultipliers(){gameRunning()&&g_Minigame.m_CurrentScene.m_rgPlayerTechTree&&(userElementMultipliers[3]=g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_air,userElementMultipliers[4]=g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_earth,userElementMultipliers[1]=g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_fire,userElementMultipliers[2]=g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_multiplier_water,userMaxElementMultiiplier=Math.max.apply(null,userElementMultipliers))}function getMobTypePriority(e){if(!e||!e.m_data)return-1;switch(mobType=e.m_data.type){case 1:return 0;case 0:return 1;case 3:return 2;case 2:return 3;case 4:return 4;case!1:return 4;default:return-1}}function compareMobPriority(e,t){if(!e)return!1;if(!t)return swapReason="Swapping off a non-existent mob.",!0;var a=g_Minigame.CurrentScene().m_rgPlayerData.hp/g_Minigame.CurrentScene().m_rgPlayerTechTree.max_hp*100,n=laneHasAbility(e.m_nLane,ABILITIES.MEDICS)||laneHasAbility(e.m_nLane,ABILITIES.STEAL_HEALTH),r=laneHasAbility(t.m_nLane,ABILITIES.MEDICS)||laneHasAbility(t.m_nLane,ABILITIES.STEAL_HEALTH),i=laneHasAbility(e.m_nLane,ABILITIES.RAINING_GOLD),o=laneHasAbility(t.m_nLane,ABILITIES.RAINING_GOLD),s=getMobTypePriority(e),l=getMobTypePriority(t),u=userElementMultipliers[g_Minigame.m_CurrentScene.m_rgGameData.lanes[e.m_nLane].element],g=userElementMultipliers[g_Minigame.m_CurrentScene.m_rgGameData.lanes[t.m_nLane].element];laneHasAbility(e.m_nLane,ABILITIES.MAX_ELEMENTAL_DAMAGE)&&(u=userMaxElementMultiiplier),laneHasAbility(t.m_nLane,ABILITIES.MAX_ELEMENTAL_DAMAGE)&&(g=userMaxElementMultiiplier);var c=e.m_data.hp,d=t.m_data.hp;if(e.m_bIsDestroyed||0>=c)return!1;if(t.m_bIsDestroyed||0>=d)return swapReason="Swapping off a destroyed mob.",!0;if(i!=o){if(i>o&&(3==t.m_data.type||1==t.m_data.type))return swapReason="Switching to target with Raining Gold.",!0}else if(s!=l){if(s>l)return swapReason="Switching to higher priority target.",!0}else if(seekHealingPercent>=a&&!g_Minigame.m_CurrentScene.m_bIsDead){if(n!=r&&n)return swapReason="Swapping to lane with active healing.",!0}else if(u!=g){if(u>g)return swapReason="Switching to elementally weaker target.",!0}else if(c!=d&&d>c)return swapReason="Switching to lower HP target.",!0;return!1}function getTarget(){try{var e=g_Minigame.m_CurrentScene.GetEnemy(g_Minigame.m_CurrentScene.m_rgPlayerData.current_lane,g_Minigame.m_CurrentScene.m_rgPlayerData.target);return e}catch(t){return null}}function gameRunning(){try{return"object"==typeof g_Minigame&&2==g_Minigame.m_CurrentScene.m_rgGameData.status}catch(e){return!1}}function getUploadedFilePath(e){return"undefined"!=typeof GM_info?GM_info.script.namespace.replace("github","raw.githubusercontent")+"/"+e:"https://raw.githubusercontent.com/ensingm2/SteamMonsterGameScript/"+e}function subLong(e,t){var a,n=function(e,t){var a="";if(t.length>e.length&&(a=e,e=t,t=a),a=(parseInt(e.slice(-9),10)+parseInt(t.slice(-9),10)).toString(),e=e.slice(0,-9),t=t.slice(0,-9),a.length>9){if(""===e)return a;e=n(e,"1"),a=a.slice(1)}else if(e.length)for(;a.length<9;)a="0"+a;return""===t?e+a:n(e,t)+a};if(a=(parseInt("1"+e.slice(-9),10)-parseInt(t.slice(-9),10)).toString(),e=e.slice(0,-9),t=t.slice(0,-9),10===a.length||""===e)a=a.slice(1);else if(t=t.length?n(t,"1"):"1",e.length)for(;a.length<9;)a="0"+a;return""===t?a=(e+a).replace(/^0+/,""):subLong(e,t)+a}function getAccountId(e){return parseInt(subLong(""+e,"76561197960265728"))}function getUserName(){return g_Minigame.m_CurrentScene.m_rgPlayerNameCache?g_Minigame.m_CurrentScene.m_rgPlayerNameCache[getAccountId(g_steamID)]:"Unknown"}function getGameLevel(){return g_Minigame.m_CurrentScene.m_rgGameData.level+1}var debug=!1,clicksPerSecond=g_TuningData.abilities[1].max_num_clicks,autoClickerVariance=Math.floor(clicksPerSecond/10);clicksPerSecond-=Math.ceil(autoClickerVariance/2);var respawnCheckFreq=5e3,targetSwapperFreq=1e3,abilityUseCheckFreq=2e3,itemUseCheckFreq=5e3,seekHealingPercent=20,upgradeManagerFreq=5e3,slowRenderingFreq=1e3,autoBuyAbilities=!1,refreshDelay=36e5,spamStatBoosters=!0,useNukeOnBossAbovePercent=25,CONTROL={speedThreshold:2e3,rainingRounds:100,disableGoldRainLevels:200},useMedicsAtPercent=40,useMedicsAtLanePercent=70,useMedicsAtLanePercentAliveReq=30,useNukeOnSpawnerAbovePercent=75,useMetalDetectorOnBossBelowPercent=30,useStealHealthAtPercent=15,useRainingGoldAbovePercent=50,useLikeNewAboveCooldown=1422e4,useResurrectToSaveCount=150,minutesBufferForConsumableDump=10,survivalTime=10,autoClickerFreq=1e3,autoRespawner,autoClicker,autoTargetSwapper,autoTargetSwapperElementUpdate,autoAbilityUser,autoUpgradeManager,fpsThrottle,spammer,elementUpdateRate=6e4,autoUseConsumables=!0,userElementMultipliers=[1,1,1,1],userMaxElementMultiiplier=1,swapReason,lastLootLevel=0,lastLootCache=[],ABILITIES={FIRE_WEAPON:1,CHANGE_LANE:2,RESPAWN:3,CHANGE_TARGET:4,MORALE_BOOSTER:5,GOOD_LUCK_CHARMS:6,MEDICS:7,METAL_DETECTOR:8,DECREASE_COOLDOWNS:9,TACTICAL_NUKE:10,CLUSTER_BOMB:11,NAPALM:12,RESURRECTION:13,CRIPPLE_SPAWNER:14,CRIPPLE_MONSTER:15,MAX_ELEMENTAL_DAMAGE:16,RAINING_GOLD:17,CRIT:18,PUMPED_UP:19,THROW_MONEY_AT_SCREEN:20,GOD_MODE:21,TREASURE:22,STEAL_HEALTH:23,REFLECT_DAMAGE:24,FEELING_LUCKY:25,WORMHOLE:26,LIKE_NEW:27},startAttempts=0,startAll=setInterval(function(){return gameRunning()?(clearInterval(startAll),startAllAutos(),initGUI(),loadSettings(),"undefined"!=typeof unsafeWindow&&initLeaderboard(),"function"==typeof runMaster&&(location.search.match(/slave/)?runSlave():runMaster()),setInterval(function(p){return p.Tick=eval("("+(""+p.Tick).replace(/document\.(hidden|webkitHidden|mozHidden|msHidden)/g,!1)+")"),function(){p=g_Minigame.m_CurrentScene,p&&document.hidden&&p.Tick()}}(CSceneGame.prototype),1e3),void setTimeout(function(){var e=setInterval(function(){var t=getTarget(),a=!currentLaneHasAbility(ABILITIES.RAINING_GOLD)&&4!=t.m_data.type&&2!=t.m_data.type&&3!=t.m_data.type&&t.m_data.type!==!1;a&&(clearInterval(e),location.reload())},15e3)},refreshDelay)):void(1!=g_Minigame.m_CurrentScene.m_rgGameData.status&&(startAttempts>15&&location.reload(),startAttempts++))},1e3);if("undefined"!=typeof unsafeWindow){unsafeWindow.debug=debug,unsafeWindow.clicksPerSecond=clicksPerSecond,unsafeWindow.autoClickerVariance=autoClickerVariance,unsafeWindow.respawnCheckFreq=respawnCheckFreq,unsafeWindow.targetSwapperFreq=targetSwapperFreq,unsafeWindow.abilityUseCheckFreq=abilityUseCheckFreq,unsafeWindow.itemUseCheckFreq=itemUseCheckFreq,unsafeWindow.seekHealingPercent=seekHealingPercent,unsafeWindow.upgradeManagerFreq=upgradeManagerFreq,unsafeWindow.autoBuyAbilities=autoBuyAbilities,unsafeWindow.fpsThrottle=fpsThrottle,unsafeWindow.useMedicsAtPercent=useMedicsAtPercent,unsafeWindow.useMedicsAtLanePercent=useMedicsAtLanePercent,unsafeWindow.useMedicsAtLanePercentAliveReq=useMedicsAtLanePercentAliveReq,unsafeWindow.useNukeOnSpawnerAbovePercent=useNukeOnSpawnerAbovePercent,unsafeWindow.useMetalDetectorOnBossBelowPercent=useMetalDetectorOnBossBelowPercent,unsafeWindow.useStealHealthAtPercent=useStealHealthAtPercent,unsafeWindow.useRainingGoldAbovePercent=useRainingGoldAbovePercent,unsafeWindow.autoUseConsumables=autoUseConsumables,unsafeWindow.useResurrectToSaveCount=useResurrectToSaveCount,unsafeWindow.spamStatBoosters=spamStatBoosters,unsafeWindow.slaveWindowUICleanup=slaveWindowUICleanup,unsafeWindow.slaveWindowPeriodicRestart=slaveWindowPeriodicRestart,unsafeWindow.slaveWindowPeriodicRestartInterval=slaveWindowPeriodicRestartInterval,unsafeWindow.useNukeOnBossAbovePercent=useNukeOnBossAbovePercent,unsafeWindow.startAutoClicker=startAutoClicker,unsafeWindow.startAutoRespawner=startAutoRespawner,unsafeWindow.startAutoTargetSwapper=startAutoTargetSwapper,unsafeWindow.startAutoAbilityUser=startAutoAbilityUser,unsafeWindow.startAutoItemUser=startAutoItemUser,unsafeWindow.startAllAutos=startAllAutos,unsafeWindow.startAutoUpgradeManager=startAutoUpgradeManager,unsafeWindow.stopAutoClicker=stopAutoClicker,unsafeWindow.stopAutoRespawner=stopAutoRespawner,unsafeWindow.stopAutoTargetSwapper=stopAutoTargetSwapper,unsafeWindow.stopAutoAbilityUser=stopAutoAbilityUser,unsafeWindow.stopAutoItemUser=stopAutoItemUser,unsafeWindow.stopAutoUpgradeManager=stopAutoUpgradeManager,unsafeWindow.stopAllAutos=stopAllAutos,unsafeWindow.disableAutoNukes=disableAutoNukes,unsafeWindow.castAbility=castAbility,unsafeWindow.hasAbility=hasAbility,unsafeWindow.abilityIsUnlocked=abilityIsUnlocked,unsafeWindow.abilityCooldown=abilityCooldown,unsafeWindow.toggleAutoClicker=toggleAutoClicker,unsafeWindow.toggleAutoTargetSwapper=toggleAutoTargetSwapper,unsafeWindow.toggleAutoAbilityUser=toggleAutoAbilityUser,unsafeWindow.toggleAutoItemUser=toggleAutoItemUser,unsafeWindow.toggleAutoUpgradeManager=toggleAutoUpgradeManager,unsafeWindow.spamNoClick=spamNoClick,unsafeWindow.toggleSpammer=toggleSpammer,unsafeWindow.getTarget=getTarget,unsafeWindow.currentLaneHasAbility=currentLaneHasAbility,unsafeWindow.laneHasAbility=laneHasAbility,unsafeWindow.getMobTypePriority=getMobTypePriority,unsafeWindow.updateStats=updateStats;var varSetter=setInterval(function(){debug&&console.log("updating options"),debug=unsafeWindow.debug,clicksPerSecond=unsafeWindow.clicksPerSecond,autoClickerVariance=unsafeWindow.autoClickerVariance,respawnCheckFreq=unsafeWindow.respawnCheckFreq,targetSwapperFreq=unsafeWindow.targetSwapperFreq,abilityUseCheckFreq=unsafeWindow.abilityUseCheckFreq,itemUseCheckFreq=unsafeWindow.itemUseCheckFreq,seekHealingPercent=unsafeWindow.seekHealingPercent,upgradeManagerFreq=unsafeWindow.upgradeManagerFreq,autoBuyAbilities=unsafeWindow.autoBuyAbilities,fpsThrottle=unsafeWindow.fpsThrottle,useMedicsAtPercent=unsafeWindow.useMedicsAtPercent,useMedicsAtLanePercent=unsafeWindow.useMedicsAtLanePercent,useMedicsAtLanePercentAliveReq=unsafeWindow.useMedicsAtLanePercentAliveReq,useNukeOnSpawnerAbovePercent=unsafeWindow.useNukeOnSpawnerAbovePercent,useMetalDetectorOnBossBelowPercent=unsafeWindow.useMetalDetectorOnBossBelowPercent,useStealHealthAtPercent=unsafeWindow.useStealHealthAtPercent,useRainingGoldAbovePercent=unsafeWindow.useRainingGoldAbovePercent,useResurrectToSaveCount=unsafeWindow.useResurrectToSaveCount,spamStatBoosters=unsafeWindow.spamStatBoosters,useNukeOnBossAbovePercent=unsafeWindow.useNukeOnBossAbovePercent},5e3);unsafeWindow.getDebug=function(){return debug},unsafeWindow.setDebug=function(e){debug=e}}var upgradeManagerPrefilter;upgradeManagerPrefilter||$J.ajaxPrefilter(function(){void 0!==upgradeManagerPrefilter&&upgradeManagerPrefilter.apply(this,arguments)});var gameOldRenderer=function(){},endDate=initEndDate();