Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.32 KB | None | 0 0
  1. ShowTooltips=true;
  2.  
  3. document.getElementById("resourceColumn").innerHTML += '<input id="chkBuyStorage" title="Autobuy storage" style="left: 50%; top: 50%; position: absolute;" type="checkbox" checked="checked">';
  4. AutoBuyStorage=function ()
  5. {
  6. if (!document.getElementById("chkBuyStorage"))
  7. {
  8. document.getElementById("resourceColumn").innerHTML += '<input id="chkBuyStorage" title="Autobuy storage" style="left: 50%; top: 50%; position: absolute;" type="checkbox" checked="checked">';
  9. }
  10. return document.getElementById("chkBuyStorage").checked;
  11. }
  12.  
  13. document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyWarps" title="Autobuy Warpstations" style=right:100; position: absolute;" type="checkbox">';
  14. AutoBuyWarp=function ()
  15. {
  16. if (!document.getElementById("chkBuyWarps"))
  17. {
  18. document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyWarps" title="Autobuy Warpstations" style=right:100; position: absolute;" type="checkbox">';
  19. }
  20. return document.getElementById("chkBuyWarps").checked;
  21. }
  22.  
  23. document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyNursery" title="Autobuy Nurseries" style=right:50; position: absolute;" type="checkbox">';
  24. AutoBuyNursery=function ()
  25. {
  26. if (!document.getElementById("chkBuyNursery"))
  27. {
  28. document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyNursery" title="autobuy Nurseries" style=right:50; position: absolute;" type="checkbox">';
  29. }
  30. return document.getElementById("chkBuyNursery").checked;
  31. }
  32.  
  33. document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyBuilding" title="Autobuy buildings other than Nurseries and Warpstations. Housing types will stop being bought automatically once they become obsolete." type="checkbox">';
  34. AutoBuyBuilding=function ()
  35. {
  36. if (!document.getElementById("chkBuyBuilding"))
  37. {
  38. document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyBuilding" title="Autobuy buildings other than Nurseries and Warpstations. Housing types will stop being bought automatically once they become obsolete." type="checkbox">';
  39. }
  40. return document.getElementById("chkBuyBuilding").checked;
  41. }
  42.  
  43. document.getElementById("upgradesTitleSpan").innerHTML = '<input id="chkBuyUpgrades" title="Autobuy non-equipment upgrades" type="checkbox" align="right">Upgrades';
  44. AutoBuyUpgrades=function ()
  45. {
  46. if (!document.getElementById("chkBuyUpgrades"))
  47. {
  48. document.getElementById("upgradesTitleSpan").innerHTML = '<input id="chkBuyUpgrades" title="Autobuy non-equipment upgrades" type="checkbox" align="right">Upgrades"';
  49. }
  50. return document.getElementById("chkBuyUpgrades").checked;
  51. }
  52.  
  53. document.getElementById("equipmentTitleSpan").innerHTML += '<table><tr><td><input id="chkBuyEquipH" title="Autobuy armor" type="checkbox"><input id="chkBuyEquipA" title="Autobuy weapons" type="checkbox"></td></tr><tr><td><input id="chkBuyPrestigeH" title="Autobuy armor upgrades" type="checkbox"><input id="chkBuyPrestigeA" title="Autobuy weapon upgrades" type="checkbox"></td></tr></table>';
  54. AutoBuyEquipH=function ()
  55. {
  56. if (!document.getElementById("chkBuyEquipH"))
  57. {
  58. document.getElementById("equipmentTitleSpan").innerHTML += '<table><tr><td><input id="chkBuyEquipH" title="Autobuy armor" type="checkbox"><input id="chkBuyEquipA" title="Autobuy weapons" type="checkbox"></td></tr><tr><td><input id="chkBuyPrestigeH" title="Autobuy armor upgrades" type="checkbox"><input id="chkBuyPrestigeA" title="Autobuy weapon upgrades" type="checkbox"></td></tr></table>';
  59. }
  60. return document.getElementById("chkBuyEquipH").checked;
  61. }
  62. AutoBuyPrestigeH=function ()
  63. {
  64. if (!document.getElementById("chkBuyPrestigeH"))
  65. {
  66. document.getElementById("equipmentTitleSpan").innerHTML += '<table><tr><td><input id="chkBuyEquipH" title="Autobuy armor" type="checkbox"><input id="chkBuyEquipA" title="Autobuy weapons" type="checkbox"></td></tr><tr><td><input id="chkBuyPrestigeH" title="Autobuy armor upgrades" type="checkbox"><input id="chkBuyPrestigeA" title="Autobuy weapon upgrades" type="checkbox"></td></tr></table>';
  67. }
  68. return document.getElementById("chkBuyPrestigeH").checked;
  69. }
  70. AutoBuyEquipA=function ()
  71. {
  72. if (!document.getElementById("chkBuyEquipA"))
  73. {
  74. document.getElementById("equipmentTitleSpan").innerHTML += '<table><tr><td><input id="chkBuyEquipH" title="Autobuy armor" type="checkbox"><input id="chkBuyEquipA" title="Autobuy weapons" type="checkbox"></td></tr><tr><td><input id="chkBuyPrestigeH" title="Autobuy armor upgrades" type="checkbox"><input id="chkBuyPrestigeA" title="Autobuy weapon upgrades" type="checkbox"></td></tr></table>';
  75. }
  76. return document.getElementById("chkBuyEquipA").checked;
  77. }
  78. AutoBuyPrestigeA=function ()
  79. {
  80. if (!document.getElementById("chkBuyPrestigeA"))
  81. {
  82. document.getElementById("equipmentTitleSpan").innerHTML += '<table><tr><td><input id="chkBuyEquipH" title="Autobuy armor" type="checkbox"><input id="chkBuyEquipA" title="Autobuy weapons" type="checkbox"></td></tr><tr><td><input id="chkBuyPrestigeH" title="Autobuy armor upgrades" type="checkbox"><input id="chkBuyPrestigeA" title="Autobuy weapon upgrades" type="checkbox"></td></tr></table>';
  83. }
  84. return document.getElementById("chkBuyPrestigeA").checked;
  85. }
  86.  
  87. document.getElementById("badGuyName").outerHTML = '<input id="chkAutoChangeFormation" title="Change formations automatically" type="checkbox" checked="checked">' + document.getElementById("badGuyName").outerHTML;
  88. AutoChangeFormation=function ()
  89. {
  90. if (!document.getElementById("chkAutoChangeFormation"))
  91. {
  92. document.getElementById("badGuyName").outerHTML = '<input id="chkAutoChangeFormation" title="Change formations automatically" type="checkbox" checked="checked">' + document.getElementById("badGuyName").outerHTML;
  93. }
  94. return document.getElementById("chkAutoChangeFormation").checked;
  95. }
  96.  
  97. OldTooltip=tooltip;
  98.  
  99. tooltip=function(a,b,c,d,e,f,g,h,i,j,k,l,m)
  100. {
  101. if (ShowTooltips || a=='hide')
  102. {
  103. OldTooltip(a,b,c,d,e,f,g,h,i,j,k,l,m);
  104. }
  105. }
  106.  
  107. BuyDaBuilding=function(what)
  108. {
  109. ShowTooltips=false;
  110. buyBuilding(what);
  111. ShowTooltips=true;
  112. }
  113.  
  114. BuyDaEquip=function(what)
  115. {
  116. ShowTooltips=false;
  117. buyEquipment(what);
  118. ShowTooltips=true;
  119. }
  120.  
  121. BuyDaUpgrade=function(what)
  122. {
  123. ShowTooltips=false;
  124. buyUpgrade(what);
  125. ShowTooltips=true;
  126. }
  127.  
  128. TheThings={
  129. 'Dagger':{
  130. Upgrade: 'Dagadder',
  131. Stat:'attack',
  132. Resource:'metal',
  133. Equip:true
  134. },
  135. 'Mace':{
  136. Upgrade: 'Megamace',
  137. Stat:'attack',
  138. Resource:'metal',
  139. Equip:true
  140. },
  141. 'Polearm':{
  142. Upgrade: 'Polierarm',
  143. Stat:'attack',
  144. Resource:'metal',
  145. Equip:true
  146. },
  147. 'Battleaxe':{
  148. Upgrade: 'Axeidic',
  149. Stat:'attack',
  150. Resource:'metal',
  151. Equip:true
  152. },
  153. 'Greatsword':{
  154. Upgrade: 'Greatersword',
  155. Stat:'attack',
  156. Resource:'metal',
  157. Equip:true
  158. },
  159. 'Boots':{
  160. Upgrade: 'Bootboost',
  161. Stat:'health',
  162. Resource:'metal',
  163. Equip:true
  164. },
  165. 'Helmet':{
  166. Upgrade: 'Hellishmet',
  167. Stat:'health',
  168. Resource:'metal',
  169. Equip:true
  170. },
  171. 'Pants':{
  172. Upgrade: 'Pantastic',
  173. Stat:'health',
  174. Resource:'metal',
  175. Equip:true
  176. },
  177. 'Shoulderguards':{
  178. Upgrade: 'Smoldershoulder',
  179. Stat:'health',
  180. Resource:'metal',
  181. Equip:true
  182. },
  183. 'Breastplate':{
  184. Upgrade: 'Bestplate',
  185. Stat:'health',
  186. Resource:'metal',
  187. Equip:true
  188. },
  189. 'Arbalest':{
  190. Upgrade: 'Harmbalest',
  191. Stat:'attack',
  192. Resource:'metal',
  193. Equip:true
  194. },
  195. 'Gambeson':{
  196. Upgrade: 'GambesOP',
  197. Stat:'health',
  198. Resource:'metal',
  199. Equip:true
  200. },
  201. 'Shield':{
  202. Upgrade: 'Supershield',
  203. Stat:'health',
  204. Resource:'wood',
  205. Equip:true
  206. },
  207. 'Gym':{
  208. Upgrade: 'Gymystic',
  209. Stat:'block',
  210. Resource:'wood',
  211. Equip:false
  212. }
  213. }
  214.  
  215. function GetObject(what)
  216. {
  217. var Thing=TheThings[what];
  218. return Thing.Equip?game.equipment[what]:game.buildings[what];
  219. }
  220.  
  221. function Factor(what)
  222. {
  223. var Thing=TheThings[what];
  224. var Object=GetObject(what);
  225. if (what=='Shield')
  226. {
  227. if (Object.blockNow)
  228. {
  229. Thing.Stat='block';
  230. }
  231. else
  232. {
  233. Thing.Stat='health';
  234. }
  235. }
  236.  
  237. var Eff=Effect(Object,Thing);
  238. var Cos=Cost(Object,Thing);
  239. var Res=Eff/Cos;
  240. var Status='white';
  241. var Wall=false;
  242.  
  243. //white - Upgrade is not available
  244. //yellow - Upgrade is not affordable
  245. //orange - Upgrade is affordable, but will lower stats
  246. //red - Yes, do it now!
  247. if (!game.upgrades[Thing.Upgrade].locked)
  248. {
  249. //Evaluating upgrade!
  250. var CanAfford=canAffordTwoLevel(game.upgrades[Thing.Upgrade]);
  251. if (Thing.Equip)
  252. {
  253. var NextEff=PrestigeValue(Thing.Upgrade);
  254. var NextCost=getNextPrestigeCost(Thing.Upgrade) * Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level);
  255. Wall=NextEff/NextCost>Res;
  256. }
  257.  
  258. if (!CanAfford)
  259. {
  260. Status='yellow';
  261. }
  262. else
  263. {
  264. if (!Thing.Equip)
  265. {
  266. //Gymystic is always cool, fuck shield
  267. Status='red';
  268. }
  269. else
  270. {
  271. var CurrEff=Object.level*Eff;
  272.  
  273. var NeedLevel=Math.ceil(CurrEff/NextEff);
  274. var Ratio=Object.cost[Thing.Resource][1];
  275.  
  276. var NeedResource=NextCost*(Math.pow(Ratio,NeedLevel)-1)/(Ratio-1);
  277.  
  278. if (game.resources[Thing.Resource].owned>NeedResource)
  279. {
  280. Status='red';
  281. }
  282. else
  283. {
  284. Status='orange';
  285. }
  286. }
  287. }
  288. }
  289.  
  290. return {
  291. Stat:Thing.Stat,
  292. Factor:Res,
  293. Status:Status,
  294. Wall:Wall
  295. };
  296. }
  297.  
  298. function Effect(Object,Thing)
  299. {
  300. if (Thing.Equip)
  301. {
  302. return Object[Thing.Stat+'Calculated'];
  303. }
  304. else
  305. {
  306. //That be Gym
  307. var oldBlock = Object.increase.by*Object.owned;
  308. var Mod=game.upgrades.Gymystic.done?(game.upgrades.Gymystic.modifier + (0.01 * (game.upgrades.Gymystic.done - 1))):1;
  309. var newBlock=Object.increase.by*(Object.owned+1)*Mod;
  310. return newBlock-oldBlock;
  311. }
  312. }
  313.  
  314. function Cost(Object,Thing)
  315. {
  316. var price = parseFloat(getBuildingItemPrice(Object, Thing.Resource, Thing.Equip));
  317. if (Thing.Equip) price = Math.ceil(price * (Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level)));
  318. return price;
  319. }
  320.  
  321. function PrestigeValue(what)
  322. {
  323. var name = game.upgrades[what].prestiges;
  324. var equipment = game.equipment[name];
  325. var stat;
  326. if (equipment.blockNow) stat = "block";
  327. else stat = (typeof equipment.health !== 'undefined') ? "health" : "attack";
  328. var toReturn = Math.round(equipment[stat] * Math.pow(1.19, ((equipment.prestige) * game.global.prestige[stat]) + 1));
  329. return toReturn;
  330. }
  331.  
  332. function EvalAll()
  333. {
  334. var Best={
  335. 'healthwood':{Factor:0,Name:'',Wall:false,Status:'white'},
  336. 'healthmetal':{Factor:0,Name:'',Wall:false,Status:'white'},
  337. 'attackmetal':{Factor:0,Name:'',Wall:false,Status:'white'},
  338. 'blockwood':{Factor:0,Name:'',Wall:false,Status:'white'},
  339. };
  340.  
  341. for (var what in TheThings)
  342. {
  343. var Object=GetObject(what);
  344. if (!Object.locked)
  345. {
  346. document.getElementById(what).style.color='white';
  347. var Evaluation=Factor(what);
  348. var BKey=TheThings[what].Stat+TheThings[what].Resource;
  349. //console.log(BKey);
  350. if (Best[BKey].Factor==0 || Best[BKey].Factor<Evaluation.Factor)
  351. {
  352. Best[BKey].Factor=Evaluation.Factor;
  353. Best[BKey].Name=what;
  354. Best[BKey].Wall=Evaluation.Wall;
  355. Best[BKey].Status=Evaluation.Status;
  356. }
  357. document.getElementById(what).style.borderColor=Evaluation.Status;
  358. if (Evaluation.Status!='white' && Evaluation.Status!='yellow')
  359. {
  360. document.getElementById(TheThings[what].Upgrade).style.color=Evaluation.Status;
  361. }
  362. if (Evaluation.Status=='yellow')
  363. {
  364. document.getElementById(TheThings[what].Upgrade).style.color='white';
  365. }
  366. if (Evaluation.Wall)
  367. {
  368. document.getElementById(what).style.color='yellow';
  369. }
  370.  
  371. if(
  372. Evaluation.Status=='red'
  373. &&
  374. (
  375. (
  376. AutoBuyPrestigeA()
  377. &&
  378. TheThings[what].Stat=='attack'
  379. )
  380. ||
  381. (
  382. AutoBuyPrestigeH()
  383. &&
  384. (
  385. TheThings[what].Stat=='health'
  386. ||
  387. TheThings[what].Stat=='block'
  388. )
  389. )
  390. )
  391. )
  392. {
  393. var upgrade = TheThings[what].Upgrade;
  394. console.log('Wanna do upgrade '+upgrade);
  395. BuyDaUpgrade(upgrade);
  396. }
  397. }
  398. }
  399.  
  400. for (var stat in Best)
  401. {
  402. if (Best[stat].Name!='')
  403. {
  404. var DaThing=TheThings[Best[stat].Name];
  405. document.getElementById(Best[stat].Name).style.color=Best[stat].Wall?'orange':'red';
  406. if (
  407. (
  408. AutoBuyEquipA()
  409. &&
  410. DaThing.Stat=='attack'
  411. )
  412. ||
  413. (
  414. AutoBuyEquipH()
  415. &&
  416. (
  417. DaThing.Stat=='health'
  418. ||
  419. DaThing.Stat=='block'
  420. )
  421. )
  422. )
  423. {
  424. if (DaThing.Equip && !Best[stat].Wall && canAffordBuilding(Best[stat].Name, null, null, true))
  425. {
  426. console.log('Wanna level equip '+Best[stat].Name);
  427. BuyDaEquip(Best[stat].Name);
  428. }
  429. }
  430. }
  431. }
  432. }
  433.  
  434. setInterval('EvalAll()',250);
  435.  
  436. Builder={
  437. Buys: {},
  438. Start: function(what, counter)
  439. {
  440. this.Buys[what]=setInterval(function()
  441. {
  442. if (what=='Warpstation') //Special cases!
  443. {
  444. if (AutoBuyBuilding() && AutoBuyWarp() && !game.buildings[what].locked && canAffordBuilding(what))
  445. {
  446. console.log('Wanna buy '+what);
  447. BuyDaBuilding(what);
  448. }
  449. else if (
  450. (
  451. counter!=null
  452. &&
  453. game.buildings[what].owned>=counter+game.upgrades.Gigastation.done*counter/10.0
  454. )
  455. &&
  456. AutoBuyUpgrades()
  457. &&
  458. !game.upgrades.Gigastation.locked
  459. )
  460. {
  461. if (canAffordTwoLevel(game.upgrades.Gigastation))
  462. {
  463. var upgrade = 'Gigastation';
  464. console.log('Wanna do upgrade '+upgrade);
  465. BuyDaUpgrade(upgrade);
  466. }
  467. }
  468. }
  469. else if (AutoBuyBuilding() && !game.buildings[what].locked && canAffordBuilding(what))
  470. {
  471. if (counter==null || game.buildings[what].purchased<counter)
  472. {
  473. if (what=='Collector') // Special cases FTW
  474. {
  475. var Coll=game.buildings.Collector;
  476. var Warp=game.buildings.Warpstation;
  477. if (!Warp.locked)
  478. {
  479. CollGemCost=Coll.cost.gems[0]*Math.pow(Coll.cost.gems[1],Coll.purchased);
  480. CollEffect=Coll.increase.by/CollGemCost;
  481.  
  482. WarpGemCost=Warp.cost.gems[0]*Math.pow(Warp.cost.gems[1],Warp.purchased);
  483. WarpEffect=Warp.increase.by/WarpGemCost;
  484. }
  485. if (Warp.locked || CollEffect>WarpEffect || game.resources.gems.owned>CollGemCost+WarpGemCost)
  486. {
  487. console.log('Wanna buy '+what);
  488. BuyDaBuilding(what);
  489. }
  490. }
  491. else if (what=='Nursery')
  492. {
  493. if(AutoBuyNursery())
  494. {
  495. var Wanna=true;
  496. if (game.jobs.Geneticist.locked && (GetBreedTime()<GeneticistTimeLimit()+1 || game.buildings.Nursery.purchased!=game.buildings.Nursery.owned))
  497. {
  498. Wanna=false;
  499. }
  500. if (!game.buildings.Collector.locked && !game.global.brokenPlanet && game.buildings.Collector.purchased<game.buildings.Nursery.purchased/10)
  501. {
  502. Wanna=false;
  503. }
  504. if (Wanna)
  505. {
  506. console.log('Wanna buy '+what);
  507. BuyDaBuilding(what);
  508. }
  509. }
  510. }
  511. else
  512. {
  513. console.log('Wanna buy '+what);
  514. BuyDaBuilding(what);
  515. }
  516. }
  517. }
  518. },250);
  519. },
  520. Stop: function(what)
  521. {
  522. if (this.Buys[what])
  523. {
  524. clearInterval(this.Buys[what]);
  525. delete this.Buys[what];
  526. }
  527. }
  528. }
  529.  
  530. setInterval(function(){
  531. var packMod = 1 + game.portal.Packrat.level * game.portal.Packrat.modifier;
  532. var motMod = 1 + game.portal.Motivation.level * game.portal.Motivation.modifier;
  533. var Bs={'Barn':'food','Shed':'wood','Forge':'metal'};
  534. var Js={'Barn':'Farmer','Shed':'Lumberjack','Forge':'Miner'};
  535.  
  536. for (var B in Bs)
  537. {
  538. var Res=game.resources[Bs[B]];
  539. var Job=game.jobs[Js[B]];
  540. if (Res.owned>Res.max*packMod*0.9 || Job.owned*Job.modifier*motMod*600>Res.max*packMod)
  541. {
  542. //console.log(B+': '+Bs[B]+' - '+game.resources[Bs[B]].owned+'/'+(game.resources[Bs[B]].max*packMod*0.99));
  543. if (AutoBuyStorage() && canAffordBuilding(B))
  544. {
  545. console.log('Wanna buy '+B);
  546. BuyDaBuilding(B);
  547. }
  548. }
  549. }
  550. },
  551. 250);
  552.  
  553. Us=[
  554. 'Coordination',
  555. 'Speedminer',
  556. 'Speedlumber',
  557. 'Speedfarming',
  558. 'Speedscience',
  559. 'Megaminer',
  560. 'Megalumber',
  561. 'Megafarming',
  562. 'Megascience',
  563. 'Efficiency',
  564. 'Potency',
  565. 'TrainTacular',
  566. 'Miners',
  567. 'Scientists',
  568. 'Trainers',
  569. 'Explorers',
  570. 'Blockmaster',
  571. 'Battle',
  572. 'Bloodlust',
  573. 'Bounty',
  574. 'Egg',
  575. 'Anger',
  576. 'Formations',
  577. 'Dominance',
  578. 'Barrier',
  579. 'UberHut',
  580. 'UberHouse',
  581. 'UberMansion',
  582. 'UberHotel',
  583. 'UberResort'
  584. ];
  585.  
  586. setInterval(function(){
  587. for (var U in Us)
  588. {
  589. var name=Us[U];
  590. var up=game.upgrades[Us[U]];
  591. if (AutoBuyUpgrades() && up.allowed>up.done && canAffordTwoLevel(up))
  592. {
  593. if (name=='Potency')
  594. {
  595. if ((game.jobs.Geneticist.locked && GetBreedTime()>GeneticistTimeLimit()+1) || !game.jobs.Geneticist.locked)
  596. {
  597. console.log('Wanna read '+name);
  598. BuyDaUpgrade(name);
  599. }
  600. }
  601. else
  602. {
  603. if (name!='Coordination')
  604. {
  605. console.log('Wanna read '+name);
  606. }
  607. BuyDaUpgrade(name);
  608. }
  609. }
  610. }
  611. },
  612. 250);
  613.  
  614. Builder.Start('Hut',75)
  615. Builder.Start('House',75)
  616. Builder.Start('Gym')
  617. Builder.Start('Mansion',75)
  618. Builder.Start('Hotel',75)
  619. Builder.Start('Resort',75)
  620. Builder.Start('Gateway',20)
  621. Builder.Start('Wormhole',0)
  622. Builder.Start('Collector', 250)
  623. Builder.Start('Warpstation',27)
  624. Builder.Start('Tribute')
  625. Builder.Start('Nursery')
  626.  
  627. function InitializeJobsTextboxes()
  628. {
  629. //Initialize the autobuy jobs checkbox along with the five textboxes, to make sure they're ordered correctly.
  630. //document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkBuyJobs" title="autobuy Jobs" type="checkbox"><input id="txtGeneticistTimeLimit" title="balance Geneticists for this breeding time" style="width: 50px; height: 25px; color: black;" type="text" value="30"></input>';
  631. //document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantFarmers" title="desired ratio of Farmers" style="width: 50px; height: 25px; color: black;" type="text" value=".325"></input>';
  632. //document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantLumbers" title="desired ratio of Lumbers" style="width: 50px; height: 25px; color: black;" type="text" value=".275"></input>';
  633. //document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantMiners" title="desired ratio of Miners" style="width: 50px; height: 25px; color: black;" type="text" value=".5"></input>';
  634. //document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantScientists" title="desired ratio of Scientists" style="width: 50px; height: 25px; color: black;" type="text" value="0"></input>';
  635. }
  636.  
  637. document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkBuyJobs" title="Autobuy Farmer/Lumberjack/Miner/Scientist/Geneticist jobs using the inputted ratios and breed time" type="checkbox"></input>';
  638. document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantFarmers" title="Desired ratio of Farmers" style="width: 50px; height: 25px; color: black;" type="text" value="0"></input>';
  639. document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantLumbers" title="Desired ratio of Lumberjacks" style="width: 50px; height: 25px; color: black;" type="text" value="0"></input>';
  640. document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantMiners" title="Desired ratio of Miners" style="width: 50px; height: 25px; color: black;" type="text" value="1"></input>';
  641.  
  642. document.getElementById("jobsTitleSpan").innerHTML += '<br><input id="txtGeneticistTimeLimit" title="Balance Geneticists for this breeding time" style="width: 50px; height: 25px; color: black;" type="text" value="30"></input>';
  643. document.getElementById("jobsTitleSpan").innerHTML += '<input id="txtWantScientists" title="Desired ratio of Scientists" style="width: 50px; height: 25px; color: black;" type="text" value="0"></input>';
  644. document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkPurchaseTrainers" title="Autobuy Trainers" type="checkbox"></input>';
  645. document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkPurchaseExplorers" title="Autobuy Explorers" type="checkbox"></input>';
  646. document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkTrainersExplorersExtraResources" title="only buy the next Trainer or Explorer if you have the resources for 15 more (the Purchase Trainers or Purchase Explorers checkbox must be enabled as well)" type="checkbox" checked="checked"></input>';
  647.  
  648. AutoBuyJobs=function ()
  649. {
  650. if (!document.getElementById("chkBuyJobs"))
  651. {
  652. InitializeJobsTextboxes();
  653. }
  654. return document.getElementById("chkBuyJobs").checked;
  655. }
  656.  
  657. PurchaseTrainersCheckbox=function ()
  658. {
  659. if (!document.getElementById("chkPurchaseTrainers"))
  660. {
  661. InitializeJobsTextboxes();
  662. }
  663. return document.getElementById("chkPurchaseTrainers").checked;
  664. }
  665.  
  666. PurchaseExplorersCheckbox=function ()
  667. {
  668. if (!document.getElementById("chkPurchaseExplorers"))
  669. {
  670. InitializeJobsTextboxes();
  671. }
  672. return document.getElementById("chkPurchaseExplorers").checked;
  673. }
  674.  
  675.  
  676. TrainersExplorersExtraResourcesCheckbox=function ()
  677. {
  678. if (!document.getElementById("chkTrainersExplorersExtraResources"))
  679. {
  680. InitializeJobsTextboxes();
  681. }
  682. return document.getElementById("chkTrainersExplorersExtraResources").checked;
  683. }
  684.  
  685. GeneticistTimeLimit=function ()
  686. {
  687. if (!document.getElementById("txtGeneticistTimeLimit"))
  688. {
  689. InitializeJobsTextboxes();
  690. }
  691. var BT=parseFloat(document.getElementById("txtGeneticistTimeLimit").value) || 3;
  692. BT=(BT>3 && game.global.challengeActive=="Electricity")?3:BT;
  693. return BT;
  694. }
  695.  
  696. WantFarmers=function ()
  697. {
  698. if (!document.getElementById("txtWantFarmers"))
  699. {
  700. InitializeJobsTextboxes();
  701. }
  702. var WF=parseFloat(document.getElementById("txtWantFarmers").value) || 0;
  703. return WF;
  704. }
  705.  
  706. WantLumbers=function ()
  707. {
  708. if (!document.getElementById("txtWantLumbers"))
  709. {
  710. InitializeJobsTextboxes();
  711. }
  712. var WL=parseFloat(document.getElementById("txtWantLumbers").value) || 0;
  713. return WL;
  714. }
  715.  
  716. WantMiners=function ()
  717. {
  718. if (!document.getElementById("txtWantMiners"))
  719. {
  720. InitializeJobsTextboxes();
  721. }
  722. var WM=parseFloat(document.getElementById("txtWantMiners").value) || 0;
  723. return WM;
  724. }
  725.  
  726. WantScientists=function ()
  727. {
  728. if (!document.getElementById("txtWantScientists"))
  729. {
  730. InitializeJobsTextboxes();
  731. }
  732. var WS=parseFloat(document.getElementById("txtWantScientists").value) || 0;
  733. return WS;
  734. }
  735.  
  736. function MaxWorkers()
  737. {
  738. return Math.ceil(game.resources.trimps.realMax() / 2);
  739. }
  740.  
  741. function FreeWorkers()
  742. {
  743. return MaxWorkers()-game.resources.trimps.employed;
  744. }
  745.  
  746. function canAffordJobLight(what, take, HowMany) {
  747. var trimps = game.resources.trimps;
  748. var toBuy = HowMany;
  749. var job = game.jobs[what];
  750. for (var costItem in job.cost) {
  751. if (!checkJobItem(what, take, costItem, null, toBuy)) return false;
  752. }
  753. if (take) return toBuy;
  754. return true;
  755. }
  756.  
  757. function TryAddGuys(what, HowMany)
  758. {
  759. var workspaces = FreeWorkers();
  760. if (workspaces < HowMany) return;
  761. if (!canAffordJobLight(what, false, HowMany)) return 0;
  762. var added = canAffordJobLight(what, true, HowMany);
  763. game.jobs[what].owned += added;
  764. game.resources.trimps.employed += added;
  765. return added;
  766. }
  767.  
  768. function TryRemoveGuys(what, HowMany)
  769. {
  770. if (game.jobs[what].owned < 1) return 0;
  771.  
  772. var toR=(game.jobs[what].owned < HowMany) ? game.jobs[what].owned : HowMany;
  773.  
  774. game.resources.trimps.employed -= toR;
  775. game.jobs[what].owned -= toR;
  776. if (game.jobs[what].owned < 0) game.jobs[what].owned = 0;
  777. if (game.resources.trimps.employed < 0) game.resources.trimps.employed = 0;
  778. return toR;
  779. }
  780.  
  781. function canAffordJobLight(what, take, HowMany) {
  782. var trimps = game.resources.trimps;
  783. var toBuy = HowMany;
  784. var job = game.jobs[what];
  785. for (var costItem in job.cost) {
  786. if (!checkJobItem(what, take, costItem, null, toBuy)) return false;
  787. }
  788. if (take) return toBuy;
  789. return true;
  790. }
  791.  
  792. function GetBreedTime()
  793. {
  794. /*var trimps = game.resources.trimps;
  795. var trimpsMax = trimps.realMax();
  796. var Soldiers= game.portal.Coordinated.level ? game.portal.Coordinated.currentSend: game.resources.trimps.maxSoldiers;
  797.  
  798. var potencyMod = trimps.potencyMod;
  799.  
  800. potencyMod += (potencyMod * game.portal.Pheromones.level * game.portal.Pheromones.modifier);
  801. if (game.jobs.Geneticist.owned > 0) potencyMod *= Math.pow(.98, game.jobs.Geneticist.owned);
  802. if (game.unlocks.quickTrimps) potencyMod *= 2;
  803.  
  804. if (!game.global.brokenPlanet) potencyMod *= 10;
  805.  
  806. if (game.global.challengeActive == "Toxicity" && game.challenges.Toxicity.stacks > 0){
  807. potencyMod *= Math.pow(game.challenges.Toxicity.stackMult, game.challenges.Toxicity.stacks);
  808. }
  809.  
  810. var max = Math.ceil((trimpsMax - trimps.employed) * 0.05);
  811.  
  812. var timeRemaining = log10((trimpsMax - max - trimps.employed) / (trimpsMax - max - Soldiers - trimps.employed)) / log10(1 + (potencyMod / 10));
  813.  
  814. /*console.error("trimps: " + game.resources.trimps);
  815. console.error("trimpsMax: " + trimps.realMax());
  816. console.error("game.jobs.Geneticist.owned: " + game.jobs.Geneticist.owned);
  817.  
  818. console.error("game.global.brokenPlanet: " + game.global.brokenPlanet);
  819. console.error("trimps.employed: " + trimps.employed);
  820. console.error("Soldiers: " + Soldiers);
  821.  
  822. console.error("game.portal.Pheromones.level: " + game.portal.Pheromones.level);
  823. console.error("trimps.potency: " + trimps.potency);
  824. console.error("game.portal.Pheromones.modifier: " + game.portal.Pheromones.modifier);
  825. console.error("time remaining: " + timeRemaining);
  826.  
  827. return timeRemaining;
  828. */
  829.  
  830. var trimps = game.resources.trimps;
  831. var trimpsMax = trimps.realMax();
  832. var Soldiers= game.portal.Coordinated.level ? game.portal.Coordinated.currentSend: game.resources.trimps.maxSoldiers;
  833. //var breeding = trimps.owned - trimps.employed;
  834.  
  835. var potencyMod = trimps.potency;
  836. //Add potency (book)
  837. if (game.upgrades.Potency.done > 0) potencyMod *= Math.pow(1.1, game.upgrades.Potency.done);
  838. //Add Nurseries
  839. if (game.buildings.Nursery.owned > 0) potencyMod *= Math.pow(1.01, game.buildings.Nursery.owned);
  840. //Add Venimp
  841. if (game.unlocks.impCount.Venimp > 0) potencyMod *= Math.pow(1.003, game.unlocks.impCount.Venimp);
  842. //Broken Planet
  843. if (game.global.brokenPlanet) potencyMod /= 10;
  844. //Pheromones
  845. potencyMod *= 1+ (game.portal.Pheromones.level * game.portal.Pheromones.modifier);
  846. //Geneticist
  847. if (game.jobs.Geneticist.owned > 0) potencyMod *= Math.pow(.98, game.jobs.Geneticist.owned);
  848. //Quick Trimps
  849. if (game.unlocks.quickTrimps) potencyMod *= 2;
  850. if (game.global.challengeActive == "Daily"){
  851. if (typeof game.global.dailyChallenge.dysfunctional !== 'undefined'){
  852. potencyMod *= dailyModifiers.dysfunctional.getMult(game.global.dailyChallenge.dysfunctional.strength);
  853. }
  854. if (typeof game.global.dailyChallenge.toxic !== 'undefined'){
  855. potencyMod *= dailyModifiers.toxic.getMult(game.global.dailyChallenge.toxic.strength, game.global.dailyChallenge.toxic.stacks);
  856. }
  857. }
  858. if (game.global.challengeActive == "Toxicity" && game.challenges.Toxicity.stacks > 0){
  859. potencyMod *= Math.pow(game.challenges.Toxicity.stackMult, game.challenges.Toxicity.stacks);
  860. }
  861. if (game.global.voidBuff == "slowBreed"){
  862. potencyMod *= 0.2;
  863. }
  864. potencyMod = calcHeirloomBonus("Shield", "breedSpeed", potencyMod);
  865. //breeding = breeding * potencyMod;
  866.  
  867. potencyMod = (1 + (potencyMod / 10));
  868. var timeRemaining = log10((trimpsMax - trimps.employed) / (trimps.owned - trimps.employed)) / log10(potencyMod);
  869. timeRemaining /= 10;
  870.  
  871.  
  872.  
  873. //Calculate full breed time
  874. var fullBreed = 0;
  875. var adjustedMax = (game.portal.Coordinated.level) ? game.portal.Coordinated.currentSend : trimps.maxSoldiers;
  876. var totalTime = log10((trimpsMax - trimps.employed) / (trimpsMax - adjustedMax - trimps.employed)) / log10(potencyMod);
  877. totalTime /= 10;
  878. //game.global.breedTime = adjustedMax / breeding;
  879. /*if (game.jobs.Geneticist.locked == false && game.global.Geneticistassist && game.global.GeneticistassistSetting > 0){
  880. var target = game.global.GeneticistassistSetting;
  881. //tired of typing Geneticistassist
  882. var GAElem = document.getElementById('Geneticistassist');
  883. var GAIndicator = document.getElementById('GAIndicator');
  884. var canRun = false;
  885. if (lastGAToggle == -1) canRun = true;
  886. else if (new Date().getTime() > lastGAToggle + 2000){
  887. lastGAToggle = -1;
  888. canRun = true;
  889. }
  890. if (GAElem && canRun){
  891. var thresh = totalTime * 0.02;
  892. var compareTime = (timeRemaining > 5 && (timeRemaining > target + 1)) ? (timeRemaining - 1) : totalTime;
  893. if (!isFinite(thresh)) thresh = 0;
  894. if (!isFinite(compareTime)) compareTime = 999;
  895. if (compareTime < target) {
  896. swapClass("state", "stateHiring", GAElem);
  897.  
  898. if (game.resources.food.owned * 0.01 < getNextGeneticistCost()){
  899. GAIndicator.innerHTML = " (<span style='font-size: 0.8em' class='glyphicon glyphicon-apple'></span>)";
  900. }
  901. else if (timeRemaining < 5) {
  902. addGeneticist();
  903. GAIndicator.innerHTML = " (+)";
  904. }
  905. else GAIndicator.innerHTML = " (<span style='font-size: 0.8em' class='icmoon icon-clock3'></span>)";
  906. }
  907. else if (compareTime - thresh > target) {
  908. swapClass("state", "stateFiring", GAElem);
  909. GAIndicator.innerHTML = " (-)";
  910. removeGeneticist();
  911. }
  912. else {
  913. swapClass("state", "stateHappy", GAElem);
  914. GAIndicator.innerHTML = "";
  915. }
  916. }
  917. }*/
  918. //timeRemaining = (game.options.menu.showFullBreed.enabled > 0) ? timeRemaining.toFixed(1) : Math.ceil(timeRemaining);
  919.  
  920. //console.error("totalTime.toFixed(1): " + totalTime.toFixed(1));
  921. //console.error("totalTime: " + totalTime);
  922. //console.error("game.global.breedTime: " + game.global.breedTime);
  923.  
  924. return totalTime;
  925. }
  926.  
  927. var geneA = 1;
  928. var geneB = 0;
  929. var geneC = 0;
  930. var geneD = 0;
  931. var geneMod = 0.05;
  932. var bufferPlus = 0;
  933. if (game.global.challengeActive == "Toxicity")
  934. {
  935. bufferPlus = 400
  936. }
  937. else
  938. {
  939. bufferPlus = 0
  940. }
  941.  
  942. TheJobs=[
  943. {
  944. Name:'Explorer',
  945. Want:1,
  946. Buffer:0,
  947. Increase:function(want){return game.jobs.Explorer.owned<100?10:0;}
  948. },
  949. {
  950. Name:'Trainer',
  951. Want:1,
  952. Buffer:0,
  953. Increase:function(want){return Math.ceil((game.jobs.Trainer.owned+1)/100);}
  954. },
  955. {
  956. Name:'Farmer',
  957. Want: (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantFarmers()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists())),
  958. Buffer:102+bufferPlus,
  959. Increase:function(want){return Math.ceil(want/10);}
  960. },
  961. {
  962. Name:'Lumberjack',
  963. Want: (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantLumbers()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists())),
  964. Buffer:101+bufferPlus,
  965. Increase:function(want){return Math.ceil(want/10);}
  966. },
  967. {
  968. Name:'Miner',
  969. Want: (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantMiners()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists())),
  970. Buffer:100+bufferPlus,
  971. Increase:function(want){return Math.ceil(want/10);}
  972. },
  973. {
  974. Name:'Scientist',
  975. Want: (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantScientists()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists())),
  976. Buffer:103+bufferPlus,
  977. Increase:function(want){return Math.ceil(want/10);}
  978. },
  979. {
  980. Name:'Geneticist',
  981. Want:1,
  982. Buffer:0,
  983. Increase:function(want){
  984. var GBT=GeneticistTimeLimit();
  985. var RBT=GetBreedTime();
  986. GBT=(GBT<1)?1:((GBT>30?30:GBT)); //Bounds the player input between 1s and 30s.
  987.  
  988. if(RBT < GBT - 0.05) //+ 0.3)
  989. {
  990. geneD = geneC;
  991. geneC = geneB;
  992. geneB = geneA;
  993. geneA = 1;
  994. if (geneA + geneB + geneC + geneD != 0)
  995. geneMod = 0.05;
  996. else geneMod += 0.1;
  997. return 1;
  998. }
  999. else
  1000. {
  1001. if(RBT > GBT + geneMod) //+ 0.9 variable)
  1002. {
  1003. geneD = geneC;
  1004. geneC = geneB;
  1005. geneB = geneA;
  1006. geneA = -1;
  1007. if (geneA + geneB + geneC + geneD == 0)
  1008. geneMod += 0.1;
  1009. else geneMod = 0.05;
  1010. return -1;
  1011. }
  1012. else return 0;
  1013. }
  1014. //return (RBT<GBT+0.3)?1:((RBT>GBT+0.9)?-1:0);
  1015. }
  1016. }
  1017. ];
  1018.  
  1019. function JobsTime()
  1020. {
  1021. var MaxW=MaxWorkers();
  1022. var FreeW=FreeWorkers();
  1023. for (var TJ in TheJobs)
  1024. {
  1025. var TheJob=TheJobs[TJ];
  1026. if (!game.jobs[TheJob.Name].locked && document.getElementById(TheJob.Name))
  1027. {
  1028. if(TheJob.Name=='Trainer' && game.resources.trimps.owned>MaxWorkers())
  1029. {
  1030. if(PurchaseTrainersCheckbox())
  1031. {
  1032. var amount_to_afford = 0;
  1033. if(TrainersExplorersExtraResourcesCheckbox())
  1034. amount_to_afford = 15;
  1035.  
  1036. if(canAffordJobLight(TheJob.Name, false, amount_to_afford))
  1037. {
  1038. var added=TryAddGuys(TheJob.Name,1);
  1039. if (added>0)
  1040. {
  1041. //console.log('Want '+Want+' of '+TheJob.Name);
  1042. FreeW-=added;
  1043. }
  1044. }
  1045. }
  1046. }
  1047. else if(TheJob.Name=='Explorer' && game.resources.trimps.owned>MaxWorkers())
  1048. {
  1049. if(PurchaseExplorersCheckbox())
  1050. {
  1051. var amount_to_afford = 0;
  1052. if(TrainersExplorersExtraResourcesCheckbox())
  1053. amount_to_afford = 15;
  1054.  
  1055. if(canAffordJobLight(TheJob.Name, false, amount_to_afford))
  1056. {
  1057. var added=TryAddGuys(TheJob.Name,1);
  1058. if (added>0)
  1059. {
  1060. //console.log('Want '+Want+' of '+TheJob.Name);
  1061. FreeW-=added;
  1062. }
  1063. }
  1064. }
  1065. }
  1066. else if (AutoBuyJobs())
  1067. {
  1068. //Update the want values to match the input boxes.
  1069. if(TheJob.Name=='Farmer')
  1070. TheJob.Want = (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantFarmers()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists()));
  1071. else if(TheJob.Name=='Lumberjack')
  1072. TheJob.Want = (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantLumbers()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists()));
  1073. else if(TheJob.Name=='Miner')
  1074. TheJob.Want = (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantMiners()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists()));
  1075. else if(TheJob.Name=='Scientist')
  1076. TheJob.Want = (WantMiners() + WantFarmers() + WantLumbers() + WantScientists()<=0)?0:(WantScientists()/(WantMiners() + WantFarmers() + WantLumbers() + WantScientists()));
  1077.  
  1078. var Target=Math.floor((MaxW-TheJob.Buffer)*TheJob.Want);
  1079. var Want=Math.min(FreeW-TheJob.Buffer,TheJob.Increase(Math.min(FreeW-TheJob.Buffer, Target-game.jobs[TheJob.Name].owned)));
  1080.  
  1081.  
  1082. if (Want>0 && game.resources.trimps.owned>MaxWorkers())
  1083. {
  1084. var added=TryAddGuys(TheJob.Name,Want);
  1085. if (added>0)
  1086. {
  1087. //console.log('Want '+Want+' of '+TheJob.Name);
  1088. FreeW-=added;
  1089. }
  1090. }
  1091. else if (Want<0 && TheJob.Name=='Geneticist')
  1092. {
  1093. //console.log('Want '+Want+' of '+TheJob.Name);
  1094. var removed=TryRemoveGuys(TheJob.Name, -Want);
  1095. if (removed>0)
  1096. {
  1097. //console.log('Want '+Want+' of '+TheJob.Name);
  1098. FreeW+=removed;
  1099. }
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105.  
  1106. setInterval('JobsTime()',250);
  1107.  
  1108.  
  1109. //Handles auto-changing formations (to Heap or Barrier against Fast enemies and Dominance against non-Fast)
  1110. function CheckChangeFormation()
  1111. {
  1112. if(AutoChangeFormation() && game.upgrades.Formations.done && getCurrentEnemy() != null) //If the checkbox is checked
  1113. {
  1114. //get back to a baseline of no stance (X)
  1115. calcBaseDamageinX();
  1116. //no need to continue
  1117. //if (game.global.gridArray.length === 0) return;
  1118.  
  1119. //start analyzing autostance
  1120. var missingHealth = game.global.soldierHealthMax - game.global.soldierHealth;
  1121. var newSquadRdy = game.resources.trimps.realMax() <= game.resources.trimps.owned + 1;
  1122. var dHealth = baseHealth/2;
  1123. var xHealth = baseHealth;
  1124. var bHealth = baseHealth/2;
  1125. var hHealth = baseHealth * 4;
  1126.  
  1127. if (!game.global.mapsActive && !game.global.preMapsActive) { //In maps
  1128. enemy = getCurrentEnemy();
  1129. var enemyFast = game.global.challengeActive == "Slow" || ((((game.badGuys[enemy.name].fast || enemy.corrupted) && game.global.challengeActive != "Nom") && game.global.challengeActive != "Coordinate"));
  1130. var enemyHealth = enemy.health;
  1131. var enemyDamage = enemy.attack * 1.2; //changed by genBTC from 1.19 (there is no fluctuation)
  1132. //check for world Corruption
  1133. if (enemy.corrupted && enemy.corrupted != "none"){ //enemy.corrupted is set to "none" for holiday enemies (pumpkimps/presimpts)
  1134. enemyHealth *= getCorruptScale("health");
  1135. enemyDamage *= getCorruptScale("attack");
  1136. }
  1137. if (enemy && enemy.corrupted == 'corruptStrong') {
  1138. enemyDamage *= 2;
  1139. }
  1140. if (enemy && enemy.corrupted == 'corruptTough') {
  1141. enemyHealth *= 5;
  1142. }
  1143. if (game.global.challengeActive == 'Lead') {
  1144. enemyDamage *= (1 + (game.challenges.Lead.stacks * 0.04));
  1145. }
  1146. if (game.global.challengeActive == 'Watch') {
  1147. enemyDamage *= 1.25;
  1148. }
  1149.  
  1150. if (game.global.challengeActive == "Daily"){
  1151. if (typeof game.global.dailyChallenge.badStrength !== 'undefined'){
  1152. enemyDamage *= dailyModifiers.badStrength.getMult(game.global.dailyChallenge.badStrength.strength);
  1153. }
  1154. if (typeof game.global.dailyChallenge.bloodthirst !== 'undefined'){
  1155. enemyDamage *= dailyModifiers.bloodthirst.getMult(game.global.dailyChallenge.bloodthirst.strength, game.global.dailyChallenge.bloodthirst.stacks)
  1156. }
  1157. }
  1158.  
  1159. var pierceMod = 0;
  1160. if (game.global.challengeActive == "Lead") pierceMod += (game.challenges.Lead.stacks * 0.001);
  1161. var dDamage = enemyDamage - baseBlock / 2 > enemyDamage * (0.2 + pierceMod) ? enemyDamage - baseBlock / 2 : enemyDamage * (0.2 + pierceMod);
  1162. var xDamage = enemyDamage - baseBlock > enemyDamage * (0.2 + pierceMod) ? enemyDamage - baseBlock : enemyDamage * (0.2 + pierceMod);
  1163. var bDamage = enemyDamage - baseBlock * 4 > enemyDamage * (0.1 + pierceMod) ? enemyDamage - baseBlock * 4 : enemyDamage * (0.1 + pierceMod);
  1164. var hDamage = enemyDamage - baseBlock / 2 > enemyDamage * (0.2 + pierceMod) ? enemyDamage - baseBlock / 2 : enemyDamage * (0.2 + pierceMod);
  1165.  
  1166. } else if (game.global.mapsActive && !game.global.preMapsActive) { //In zones (not maps)
  1167. enemy = getCurrentEnemy();
  1168. var enemyFast = game.global.challengeActive == "Slow" || ((((game.badGuys[enemy.name].fast || enemy.corrupted) && game.global.challengeActive != "Nom") || game.global.voidBuff == "doubleAttack") && game.global.challengeActive != "Coordinate");
  1169. var enemyHealth = enemy.health;
  1170. var enemyDamage = enemy.attack * 1.2; //changed by genBTC from 1.19 (there is no fluctuation)
  1171. //check for voidmap Corruption
  1172. if (getCurrentMapObject().location == "Void" && enemy.corrupted){
  1173. enemyHealth *= (getCorruptScale("health") / 2).toFixed(1);
  1174. enemyDamage *= (getCorruptScale("attack") / 2).toFixed(1);
  1175. }
  1176. if (enemy && enemy.corrupted == 'corruptStrong') {
  1177. enemyDamage *= 2;
  1178. }
  1179. if (enemy && enemy.corrupted == 'corruptTough') {
  1180. enemyHealth *= 5;
  1181. }
  1182. if (game.global.challengeActive == 'Lead') {
  1183. enemyDamage *= (1 + (game.challenges.Lead.stacks * 0.04));
  1184. }
  1185. if (game.global.challengeActive == 'Watch') {
  1186. enemyDamage *= 1.25;
  1187. }
  1188.  
  1189. if (game.global.challengeActive == "Daily"){
  1190. if (typeof game.global.dailyChallenge.badStrength !== 'undefined'){
  1191. enemyDamage *= dailyModifiers.badStrength.getMult(game.global.dailyChallenge.badStrength.strength);
  1192. }
  1193. if (typeof game.global.dailyChallenge.badMapStrength !== 'undefined' && game.global.mapsActive){
  1194. enemyDamage *= dailyModifiers.badMapStrength.getMult(game.global.dailyChallenge.badMapStrength.strength);
  1195. }
  1196. if (typeof game.global.dailyChallenge.bloodthirst !== 'undefined'){
  1197. enemyDamage *= dailyModifiers.bloodthirst.getMult(game.global.dailyChallenge.bloodthirst.strength, game.global.dailyChallenge.bloodthirst.stacks)
  1198. }
  1199. }
  1200.  
  1201. var dDamage = enemyDamage - baseBlock / 2 > 0 ? enemyDamage - baseBlock / 2 : 0;
  1202. var dVoidCritDamage = enemyDamage*5 - baseBlock / 2 > 0 ? enemyDamage*5 - baseBlock / 2 : 0;
  1203. var xDamage = enemyDamage - baseBlock > 0 ? enemyDamage - baseBlock : 0;
  1204. var xVoidCritDamage = enemyDamage*5 - baseBlock > 0 ? enemyDamage*5 - baseBlock : 0;
  1205. var bDamage = enemyDamage - baseBlock * 4 > 0 ? enemyDamage - baseBlock * 4 : 0;
  1206. var hDamage = enemyDamage - baseBlock / 2 > 0 ? enemyDamage - baseBlock / 2 : 0;
  1207. }
  1208.  
  1209. var drainChallenge = game.global.challengeActive == 'Nom' || game.global.challengeActive == "Toxicity";
  1210.  
  1211. if (game.global.challengeActive == "Electricity" || game.global.challengeActive == "Mapocalypse") {
  1212. dDamage+= dHealth * game.global.radioStacks * 0.1;
  1213. xDamage+= xHealth * game.global.radioStacks * 0.1;
  1214. bDamage+= bHealth * game.global.radioStacks * 0.1;
  1215. hDamage+= hHealth * game.global.radioStacks * 0.1;
  1216. } else if (drainChallenge) {
  1217. dDamage += dHealth/20;
  1218. xDamage += xHealth/20;
  1219. bDamage += bHealth/20;
  1220. hDamage += hHealth/20;
  1221. } else if (game.global.challengeActive == "Crushed") {
  1222. if(dHealth > baseBlock /2)
  1223. dDamage = enemyDamage*5 - baseBlock / 2 > 0 ? enemyDamage*5 - baseBlock / 2 : 0;
  1224. if(xHealth > baseBlock)
  1225. xDamage = enemyDamage*5 - baseBlock > 0 ? enemyDamage*5 - baseBlock : 0;
  1226. if(hHealth > baseBlock / 2)
  1227. hDamage = enemyDamage*5 - baseBlock / 2 > 0 ? enemyDamage*5 - baseBlock / 2: 0;
  1228. }
  1229. if (game.global.voidBuff == "bleed" || (enemy && enemy.corrupted == 'corruptBleed')) {
  1230. dDamage += game.global.soldierHealth * 0.2;
  1231. xDamage += game.global.soldierHealth * 0.2;
  1232. bDamage += game.global.soldierHealth * 0.2;
  1233. hDamage += game.global.soldierHealth * 0.2;
  1234. }
  1235.  
  1236. baseDamage *= (game.global.titimpLeft > 0 ? 2 : 1); //consider titimp
  1237. //double attack is OK if the buff isn't double attack, or we will survive a double attack, or we are going to one-shot them (so they won't be able to double attack)
  1238. var doubleAttackOK = (game.global.voidBuff != 'doubleAttack' || (enemy && enemy.corrupted != 'corruptDbl')) || ((newSquadRdy && dHealth > dDamage * 2) || dHealth - missingHealth > dDamage * 2) || enemyHealth < baseDamage;
  1239. //lead attack ok if challenge isn't lead, or we are going to one shot them, or we can survive the lead damage
  1240. var leadDamage = game.challenges.Lead.stacks * 0.0005;
  1241. var leadAttackOK = game.global.challengeActive != 'Lead' || enemyHealth < baseDamage || ((newSquadRdy && dHealth > dDamage + (dHealth * leadDamage)) || (dHealth - missingHealth > dDamage + (dHealth * leadDamage)));
  1242. //added voidcrit.
  1243. //voidcrit is OK if the buff isn't crit-buff, or we will survive a crit, or we are going to one-shot them (so they won't be able to crit)
  1244. var isCritVoidMap = game.global.voidBuff == 'getCrit' || (enemy && enemy.corrupted == 'corruptCrit');
  1245. var voidCritinDok = !isCritVoidMap || (!enemyFast ? enemyHealth < baseDamage : false) || (newSquadRdy && dHealth > dVoidCritDamage) || (dHealth - missingHealth > dVoidCritDamage);
  1246. var voidCritinXok = !isCritVoidMap || (!enemyFast ? enemyHealth < baseDamage : false) || (newSquadRdy && xHealth > xVoidCritDamage) || (xHealth - missingHealth > xVoidCritDamage);
  1247.  
  1248. //If the Dominance formation is not used, the formation with the lowest damage recieved to health ratio will be used.
  1249. xRatio = (xDamage / xHealth) / 2;
  1250. hRatio = hDamage / hHealth;
  1251. bRatio = bDamage / bHealth;
  1252.  
  1253. if (!game.global.preMapsActive) //&& game.global.soldierHealth > 0)
  1254. {
  1255. //Overkill calculations.
  1256. var avgDamage = (baseDamage * (1-getPlayerCritChance()) + (baseDamage * getPlayerCritChance() * getPlayerCritDamageMult()));
  1257. var avgScryerDamage = avgDamage * .5;
  1258. var avgDominanceDamage = avgDamage * 4;
  1259.  
  1260. var num_hits_in_scryer_to_kill_average_enemy = Math.ceil(getCurrentEnemy(1).maxHealth / avgScryerDamage);
  1261. //var num_hits_in_dominance_to_kill_average_enemy = Math.ceil(getCurrentEnemy(1).maxHealth / avgDominanceDamage);
  1262.  
  1263. var overkill_damage_scryer = avgScryerDamage * (game.portal.Overkill.level * 0.005);
  1264. var overkill_damage_dominance = avgDominanceDamage * (game.portal.Overkill.level * 0.005);
  1265.  
  1266. var next_enemy_health_after_overkill_scryer = getCurrentEnemy(1).maxHealth - overkill_damage_scryer;
  1267. var next_enemy_health_after_overkill_dominance = getCurrentEnemy(1).maxHealth - overkill_damage_dominance;
  1268.  
  1269. //Scryer stance. Use in the world if you're above zone 180 and not on a corruption cell or improbability (unless your next attack will kill the enemy, so you can get a Scryer bonus on the next enemy),
  1270. //and in maps if you can overkill a cell or one-shot it with Scryer active but Dominance won't overkill.
  1271. if(game.global.highestLevelCleared >= 180 && (next_enemy_health_after_overkill_scryer < 0 || (game.global.mapsActive && num_hits_in_scryer_to_kill_average_enemy == 1 && next_enemy_health_after_overkill_dominance > 0))
  1272. || (!game.global.mapsActive && game.global.world >= mutations.Corruption.start() && ((enemy.corrupted == null || enemy.corrupted == "none" || enemy.corrupted == "") && game.global.lastClearedCell != 98) || avgScryerDamage * 1.1 > enemy.health && (!enemyFast || (enemyFast && dHealth > dDamage)))) //The 1.2 is not required
  1273. {
  1274. /*console.log("enemy.corrupted: " + enemy.corrupted);
  1275. console.log("avgDamage: " + avgDamage);
  1276. console.log("overkill_damage_scryer: " + overkill_damage_scryer);
  1277. console.log("num_hits_in_scryer_to_kill_average_enemy: " + num_hits_in_scryer_to_kill_average_enemy);
  1278. console.log("next_enemy_health_after_overkill_scryer: " + next_enemy_health_after_overkill_scryer);*/
  1279. setFormation(4);
  1280. }
  1281. //If you can get away with using the Dominance formation, do so, especially if a new group of trimps is ready and waiting.
  1282. else if(game.upgrades.Dominance.done && (!enemyFast || (enemyFast && dHealth > dDamage)))
  1283. {
  1284. setFormation(2);
  1285. }
  1286. else if(game.upgrades.Barrier.done && enemyFast && bRatio < hRatio && bRatio < xRatio)
  1287. {
  1288. setFormation(3);
  1289. }
  1290. else if(game.upgrades.Formations.done && enemyFast && hRatio < xRatio && (!game.upgrades.Barrier.done || game.upgrades.Barrier.done && hRatio < bRatio))
  1291. {
  1292. setFormation(1);
  1293. }
  1294. else //No formation should also be used for non-fast enemies before Dominance is unlocked.
  1295. {
  1296. setFormation("0");
  1297. }
  1298.  
  1299.  
  1300. /*if (!enemyFast && game.upgrades.Dominance.done && enemyHealth < baseDamage && (newSquadRdy || (dHealth - missingHealth > 0 && !drainChallenge) || (drainChallenge && dHealth - missingHealth > dHealth/20))) {
  1301. setFormation(2);
  1302. //use D stance if: new army is ready&waiting / can survive void-double-attack or we can one-shot / can survive lead damage / can survive void-crit-dmg
  1303. } else if (game.upgrades.Dominance.done && ((newSquadRdy && dHealth > dDamage) || dHealth - missingHealth > dDamage) && doubleAttackOK && leadAttackOK && voidCritinDok ) {
  1304. setFormation(2);
  1305. //if CritVoidMap, switch out of D stance if we cant survive. Do various things.
  1306. } else if (isCritVoidMap && !voidCritinDok) {
  1307. //if we are already in X and the NEXT potential crit would take us past the point of being able to return to D/B, switch to B.
  1308. if (game.global.formation == "0" && game.global.soldierHealth - xVoidCritDamage < game.global.soldierHealthMax/2){
  1309. if (game.upgrades.Barrier.done && (newSquadRdy || (missingHealth < game.global.soldierHealthMax/2)) )
  1310. setFormation(3);
  1311. }
  1312. //else if we can totally block all crit damage in X mode, OR we can't survive-crit in D, but we can in X, switch to X.
  1313. // NOTE: during next loop, the If-block above may immediately decide it wants to switch to B.
  1314. else if (xVoidCritDamage == 0 || (game.global.formation == 2 && voidCritinXok)){
  1315. setFormation("0");
  1316. }
  1317. //otherwise, stuff:
  1318. else {
  1319. if (game.global.formation == "0"){
  1320. if (game.upgrades.Barrier.done && (newSquadRdy || (missingHealth < game.global.soldierHealthMax/2)) )
  1321. setFormation(3);
  1322. else
  1323. setFormation(1);
  1324. }
  1325. else if (game.upgrades.Barrier.done && game.global.formation == 2)
  1326. setFormation(3);
  1327. }
  1328. } else if (game.upgrades.Formations.done && ((newSquadRdy && xHealth > xDamage) || xHealth - missingHealth > xDamage)) {
  1329. //in lead challenge, switch to H if about to die, so doesn't just die in X mode without trying
  1330. if ((game.global.challengeActive == 'Lead') && (xHealth - missingHealth < xDamage + (xHealth * leadDamage)))
  1331. setFormation(1);
  1332. else
  1333. setFormation("0");
  1334. } else if (game.upgrades.Barrier.done && ((newSquadRdy && bHealth > bDamage) || bHealth - missingHealth > bDamage)) {
  1335. setFormation(3); //does this ever run?
  1336. } else if (game.upgrades.Formations.done) {
  1337. setFormation(1);
  1338. } else
  1339. setFormation("0");
  1340. */
  1341. }
  1342.  
  1343. baseDamage /= (game.global.titimpLeft > 0 ? 2 : 1); //unconsider titimp :P
  1344. }
  1345. }
  1346.  
  1347. function getCorruptScale(type) {
  1348. switch (type) {
  1349. case "attack":
  1350. return mutations.Corruption.statScale(3);
  1351.  
  1352. case "health":
  1353. return mutations.Corruption.statScale(10);
  1354. }
  1355. }
  1356.  
  1357. function calcBaseDamageinX() {
  1358. //baseDamage
  1359. baseDamage = game.global.soldierCurrentAttack * 2 * (1 + (game.global.achievementBonus / 100)) * ((game.global.antiStacks * game.portal.Anticipation.level * game.portal.Anticipation.modifier) + 1) * (1 + (game.global.roboTrimpLevel * 0.2));
  1360. //D stance
  1361. if (game.global.formation == 2) {
  1362. baseDamage /= 4;
  1363. } else if (game.global.formation != "0") {
  1364. baseDamage *= 2;
  1365. }
  1366.  
  1367. //baseBlock
  1368. baseBlock = game.global.soldierCurrentBlock;
  1369. //B stance
  1370. if (game.global.formation == 3) {
  1371. baseBlock /= 4;
  1372. } else if (game.global.formation != "0") {
  1373. baseBlock *= 2;
  1374. }
  1375.  
  1376. //baseHealth
  1377. baseHealth = game.global.soldierHealthMax;
  1378. //H stance
  1379. if (game.global.formation == 1) {
  1380. baseHealth /= 4;
  1381. } else if (game.global.formation != "0") {
  1382. baseHealth *= 2;
  1383. }
  1384. //S stance is accounted for (combination of all the above's else clauses)
  1385. }
  1386.  
  1387. function getCurrentEnemy(current) {
  1388. if (!current)
  1389. current = 1;
  1390. var enemy;
  1391. if (!game.global.mapsActive && !game.global.preMapsActive) {
  1392. if (typeof game.global.gridArray[game.global.lastClearedCell + current] === 'undefined') {
  1393. enemy = game.global.gridArray[game.global.gridArray.length - 1];
  1394. } else {
  1395. enemy = game.global.gridArray[game.global.lastClearedCell + current];
  1396. }
  1397. } else if (game.global.mapsActive && !game.global.preMapsActive) {
  1398. if (typeof game.global.mapGridArray[game.global.lastClearedMapCell + current] === 'undefined') {
  1399. enemy = game.global.mapGridArray[game.global.gridArray.length - 1];
  1400. } else {
  1401. enemy = game.global.mapGridArray[game.global.lastClearedMapCell + current];
  1402. }
  1403. }
  1404. return enemy;
  1405. }
  1406.  
  1407. setInterval('CheckChangeFormation()',250);
  1408.  
  1409.  
  1410.  
  1411.  
  1412. var toxicity_gave_up_on_running_maps_for_this_zone = false;
  1413. var time_entered_maps_to_farm = 0;
  1414. var zone_last_farmed_at = 7;
  1415. var chkAutoProgress_was_checked_last_frame = false;
  1416. var chkToxicityRun_was_checked_last_frame = false;
  1417. var map_level = 1;
  1418.  
  1419. document.getElementById("battleBtnsColumn").innerHTML += '<input id="chkAutoProgress" title="Auto-progress. Maps will be farmed for the inputted number of minutes, every inputted number of zones. Stops before ending certain challenges, so you can run void maps." type="checkbox" align="right"></input>';
  1420. document.getElementById("battleBtnsColumn").innerHTML += '<input id="txtMinutesToFarmMaps" title="Farm maps for X minutes near the end of selected zones. A value of 0 means maps will never be farmed." style="width: 50px; height: 25px; color: black;" type="text" value="10"></input>';
  1421. document.getElementById("battleBtnsColumn").innerHTML += '<input id="txtZoneFrequencyToFarmMaps" title="Farm maps every X zones. A value of 0 means maps will never be farmed." style="width: 50px; height: 25px; color: black;" type="text" value="1"></input>';
  1422. document.getElementById("battleBtnsColumn").innerHTML += '<input id="chkSiphonology1" title="Farm maps one level lower than your current zone. Applies to both Auto-Progress and Toxicity Run checkboxes." type="checkbox" align="right"></input>';
  1423. document.getElementById("battleBtnsColumn").innerHTML += '<br><input id="chkToxicityRun" title="During Toxicity runs, max Toxicity stacks will be reached before advancing. Farms maps indefinitely at zone 165, so you have a chance to run void maps before completing the challenge. Overrides the Auto-Progress checkbox." type="checkbox" align="right"></input>';
  1424. document.getElementById("battleBtnsColumn").innerHTML += '<input id="txtToxicityRunMinimumZone" title="The minimum zone at which to start going for maximum Toxicity stacks." style="width: 50px; height: 25px; color: black;" type="text" value="60"></input>';
  1425.  
  1426. //Called regularly, regardless of whether you're on a Toxicity run.
  1427. function CheckAutoProgressStuff()
  1428. {
  1429. if(document.getElementById("chkAutoProgress").checked && !chkAutoProgress_was_checked_last_frame)
  1430. {
  1431. //zone_last_farmed_at = game.global.world; //Pretend you farmed at your current zone when the checkbox is first checked
  1432. if(game.global.mapsActive)
  1433. {
  1434. if (!game.global.repeatMap) //Set "Repeat" on.
  1435. repeatClicked();
  1436.  
  1437. if(game.options.menu.repeatUntil.enabled == 1)
  1438. toggleSetting('repeatUntil');
  1439. if(game.options.menu.repeatUntil.enabled == 2)
  1440. toggleSetting('repeatUntil');
  1441.  
  1442. if(game.options.menu.exitTo.enabled != 1)
  1443. toggleSetting('exitTo');
  1444.  
  1445. time_entered_maps_to_farm = Date.now();
  1446. }
  1447.  
  1448. chkAutoProgress_was_checked_last_frame = true;
  1449. }
  1450.  
  1451. if(!document.getElementById("chkAutoProgress").checked && chkAutoProgress_was_checked_last_frame)
  1452. chkAutoProgress_was_checked_last_frame = false;
  1453.  
  1454. if(!game.global.preMapsActive && document.getElementById("chkAutoProgress").checked)
  1455. {
  1456. var minutes_to_farm_maps = parseFloat(document.getElementById("txtMinutesToFarmMaps").value);
  1457. var zone_frequency_to_farm_maps = parseInt(document.getElementById("txtZoneFrequencyToFarmMaps").value);
  1458. if(minutes_to_farm_maps > 0 && zone_frequency_to_farm_maps > 0)
  1459. {
  1460. if(!game.global.mapsActive && game.global.lastClearedCell > 93 && ((zone_last_farmed_at < game.global.world && zone_last_farmed_at + zone_frequency_to_farm_maps <= game.global.world) || (game.global.challengeActive == "Lead" && game.global.world == 180))) //If you haven't farmed this zone but are supposed to now
  1461. {
  1462. mapsClicked();
  1463.  
  1464. //Abandon your army
  1465. if(!game.global.mapsActive)
  1466. mapsClicked();
  1467.  
  1468. //Farm a map.
  1469. SetFarmingMapSettings();
  1470. CreateAndEnterMapWithChosenSettingsIfPossible();
  1471.  
  1472. zone_last_farmed_at = game.global.world;
  1473. time_entered_maps_to_farm = Date.now();
  1474. }
  1475. else if(game.global.mapsActive && zone_last_farmed_at < game.global.world) //If the player brought you into maps while the box was checked
  1476. {
  1477. zone_last_farmed_at = game.global.world;
  1478. time_entered_maps_to_farm = Date.now();
  1479. }
  1480. else if(game.global.mapsActive && Date.now() - time_entered_maps_to_farm > minutes_to_farm_maps * 60000 && (game.global.challengeActive != "Lead" || (game.global.challengeActive == "Lead" && game.global.world != 180)))
  1481. ExitMaps();
  1482. }
  1483. else if(game.global.mapsActive && (game.global.challengeActive != "Lead" || (game.global.challengeActive == "Lead" && game.global.world != 180)))
  1484. ExitMaps();
  1485. }
  1486. }
  1487.  
  1488. function CheckToxicityRunStuff()
  1489. {
  1490. if(game.global.challengeActive == 'Toxicity')
  1491. {
  1492. if(document.getElementById("chkToxicityRun").checked && !chkToxicityRun_was_checked_last_frame)
  1493. {
  1494. //zone_last_farmed_at = game.global.world; //Pretend you farmed at your current zone when the checkbox is first checked
  1495. if(game.global.mapsActive && game.global.world > parseInt(document.getElementById("txtToxicityRunMinimumZone").value))
  1496. {
  1497. if (!game.global.repeatMap) //Set "Repeat" on.
  1498. repeatClicked();
  1499.  
  1500. if(game.options.menu.repeatUntil.enabled == 1)
  1501. toggleSetting('repeatUntil');
  1502. if(game.options.menu.repeatUntil.enabled == 2)
  1503. toggleSetting('repeatUntil');
  1504.  
  1505. if(game.options.menu.exitTo.enabled != 1)
  1506. toggleSetting('exitTo');
  1507. }
  1508.  
  1509. chkToxicityRun_was_checked_last_frame = true;
  1510. }
  1511.  
  1512. if(!document.getElementById("chkToxicityRun").checked && chkToxicityRun_was_checked_last_frame)
  1513. chkToxicityRun_was_checked_last_frame = false;
  1514.  
  1515. if(toxicity_gave_up_on_running_maps_for_this_zone == true && game.global.lastClearedCell <= 93) //Presumably the previous zone, where you couldn't map, has been finished
  1516. toxicity_gave_up_on_running_maps_for_this_zone = false;
  1517.  
  1518. if(!game.global.preMapsActive && document.getElementById("chkToxicityRun").checked)
  1519. {
  1520. if(game.global.world < 166)
  1521. {
  1522. if(toxicity_gave_up_on_running_maps_for_this_zone == false && !game.global.mapsActive && game.global.lastClearedCell > 93 && game.challenges.Toxicity.stacks < 1500 && game.global.world > parseInt(document.getElementById("txtToxicityRunMinimumZone").value)) //If you're near the end of a zone past zone 59 and don't have max stacks...
  1523. {
  1524. mapsClicked();
  1525.  
  1526. //Abandon your army
  1527. if(!game.global.mapsActive)
  1528. mapsClicked();
  1529.  
  1530. //Farm a map.
  1531. SetFarmingMapSettings();
  1532. CreateAndEnterMapWithChosenSettingsIfPossible();
  1533. }
  1534. if(game.global.mapsActive)
  1535. {
  1536. if(game.challenges.Toxicity.stacks >= 1500 && game.global.world != 165) //Once you've finished accumulating stacks, exit back to the world. Never leave the maps when at zone 165, so you can do void maps.
  1537. ExitMaps();
  1538. }
  1539. }
  1540. }
  1541. }
  1542. }
  1543.  
  1544. function SetFarmingMapSettings()
  1545. {
  1546. var useGardens = game.global.decayDone;
  1547.  
  1548. map_level = game.global.world;
  1549.  
  1550. //if(game.portal.Siphonology.level > 0)
  1551. // map_level = map_level - 1;
  1552. if(document.getElementById("chkSiphonology1").checked)
  1553. map_level = map_level - 1;
  1554. document.getElementById("mapLevelInput").value = map_level;
  1555.  
  1556. sizeAdvMapsRange.value = 0;
  1557. adjustMap('size', 0);
  1558. difficultyAdvMapsRange.value = 9;
  1559. adjustMap('difficulty', 9);
  1560. lootAdvMapsRange.value = 9;
  1561. adjustMap('loot', 9);
  1562. biomeAdvMapsSelect.value = useGardens ? "Plentiful" : "Mountain";
  1563.  
  1564. if (updateMapCost(true) > game.resources.fragments.owned) //If you don't have enough fragments
  1565. {
  1566. adjustMap('size', 0);
  1567. adjustMap('difficulty', 9);
  1568. adjustMap('loot', 0);
  1569. biomeAdvMapsSelect.value = "Random";
  1570. }
  1571.  
  1572. if (updateMapCost(true) > game.resources.fragments.owned) //If you still don't have enough fragments
  1573. {
  1574. adjustMap('size', 0);
  1575. adjustMap('difficulty', 0);
  1576. adjustMap('loot', 0);
  1577. biomeAdvMapsSelect.value = "Random";
  1578. }
  1579. }
  1580.  
  1581.  
  1582. function CreateAndEnterMapWithChosenSettingsIfPossible()
  1583. {
  1584. //If you STILL don't have enough fragments, go back to the world and just finish the zone.
  1585. if (updateMapCost(true) > game.resources.fragments.owned)
  1586. {
  1587. toxicity_gave_up_on_running_maps_for_this_zone = true;
  1588.  
  1589. mapsClicked();
  1590. }
  1591. else //If you have enough fragments to make the map.
  1592. {
  1593. recycleBelow(true); //Recycle all maps, for space purposes and to abandon any half-finished maps from before.
  1594.  
  1595. var result = buyMap();
  1596.  
  1597. var map_just_created;
  1598. for (var map in game.global.mapsOwnedArray)
  1599. {
  1600. if(map.level == map_level)
  1601. map_just_created = map;
  1602. }
  1603. if(map_just_created != null)
  1604. selectedMap = map_just_created.id;
  1605.  
  1606. runMap();
  1607.  
  1608. if (!game.global.repeatMap) //Set "Repeat" on.
  1609. repeatClicked();
  1610.  
  1611. if(game.options.menu.repeatUntil.enabled == 1)
  1612. toggleSetting('repeatUntil');
  1613. if(game.options.menu.repeatUntil.enabled == 2)
  1614. toggleSetting('repeatUntil');
  1615.  
  1616. if(game.options.menu.exitTo.enabled != 1) toggleSetting('exitTo');
  1617. }
  1618. }
  1619.  
  1620. function ExitMaps()
  1621. {
  1622. //Should ensure it's "exit to world"
  1623. //if(game.options.menu.exitTo.enabled != 0)
  1624. // toggleSetting('exitTo');
  1625.  
  1626. //mapsClicked();
  1627.  
  1628. //Abandon your army if necessary
  1629. //if(game.global.mapsActive)
  1630. // mapsClicked();
  1631.  
  1632. //Since abandoning your trimps brings you to the map chamber, change Repeat to Off.
  1633. if (game.global.repeatMap) //Set Repeat off.
  1634. repeatClicked();
  1635. }
  1636.  
  1637. function CheckAutoProgressCheckboxes()
  1638. {
  1639.  
  1640. if(document.getElementById("chkToxicityRun").checked && game.global.challengeActive != 'Toxicity') //Disallow checking the Tox checkbox while not on Tox runs
  1641. document.getElementById("chkToxicityRun").checked = false;
  1642.  
  1643. /*if(document.getElementById("chkAutoProgress").checked && document.getElementById("chkToxicityRun").checked) //If both the AutoProgress and ToxicityRun checkboxes are still checked, uncheck one.
  1644. {
  1645. //Keep the checkbox that was just checked, checked, and remove the check on the other one.
  1646. if(!chkAutoProgress_was_checked_last_frame)
  1647. document.getElementById("chkToxicityRun").checked = false;
  1648. else
  1649. document.getElementById("chkAutoProgress").checked = false;
  1650. }*/
  1651.  
  1652. //The Toxicity checkbox takes precedence if they're both checked.
  1653. if(document.getElementById("chkToxicityRun").checked && game.global.challengeActive == 'Toxicity' && game.global.world >= parseInt(document.getElementById("txtToxicityRunMinimumZone").value))
  1654. CheckToxicityRunStuff();
  1655. else if(document.getElementById("chkAutoProgress").checked)
  1656. CheckAutoProgressStuff();
  1657.  
  1658. chkAutoProgress_was_checked_last_frame = document.getElementById("chkAutoProgress").checked;
  1659. chkToxicityRun_was_checked_last_frame = document.getElementById("chkToxicityRun").checked;
  1660. }
  1661.  
  1662. setInterval('CheckAutoProgressCheckboxes()',250);
  1663.  
  1664. document.getElementById("upgradesTitleSpan").outerHTML += '<input id="chkBuyOutWarpstationsBeforeUpgrading" title="Spend your available metal on warpstations before autobuying the next gigastation." type="checkbox" checked="checked">';
  1665. document.getElementById("upgradesTitleSpan").outerHTML += '<input id="txtGigastationDelta" title="Delta. Increase the number of Warpstations between automatic Gigastation purchases by this amount for every Gigastation you have already purchased." style="width: 50px; height: 25px; color: black;" type="text" value="0"></input>';
  1666. document.getElementById("upgradesTitleSpan").outerHTML += '<input id="txtAutobuyGigastations" title="Autobuy Gigastations when the inputted amount of warpstations is reached. A value of 0 means Gigastations will not be purchased. Ignores values below 10, to help fight accidental purchases." style="width: 50px; height: 25px; color: black;" type="text" value="0"></input>';
  1667. document.getElementById("upgradesTitleSpan").outerHTML += '<br><input id="chkAutobuyGigastations" title="Autobuy Gigastations when the inputted amount of warpstations is reached." type="checkbox">';
  1668.  
  1669. function AutobuyGigastations()
  1670. {
  1671. if(document.getElementById("chkAutobuyGigastations").checked)
  1672. {
  1673. var warpstations_per_giga = parseInt(document.getElementById("txtAutobuyGigastations").value);
  1674. var gigastation_delta = parseInt(document.getElementById("txtGigastationDelta").value);
  1675.  
  1676. if(warpstations_per_giga > 0 && warpstations_per_giga > 9 && game.buildings.Warpstation.owned >= warpstations_per_giga + game.upgrades.Gigastation.done * gigastation_delta)
  1677. {
  1678. if(document.getElementById("chkBuyOutWarpstationsBeforeUpgrading").checked)
  1679. {
  1680. while(canAffordBuilding('Warpstation'))
  1681. {
  1682. console.log('Buying warps in AutobuyGigastations');
  1683. BuyDaBuilding('Warpstation');
  1684. }
  1685. }
  1686.  
  1687. buyUpgrade('Gigastation', true, true);
  1688. }
  1689. }
  1690. }
  1691.  
  1692. setInterval('AutobuyGigastations()',250);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement