Dorten

TrimpsHelper

Aug 17th, 2015
19,909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ShowTooltips=true;
  2.  
  3. document.getElementById("resourceColumn").innerHTML += '<input id="chkBuyStorage" title="autobuy Storage" style="left: 50%; top: 50%; position: absolute;" type="checkbox">';
  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">';
  9.     }
  10.     return document.getElementById("chkBuyStorage").checked;
  11. }
  12.  
  13. document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyBuilding" title="autobuy Buildings" type="checkbox">';
  14. AutoBuyBuilding=function ()
  15. {
  16.     if (!document.getElementById("chkBuyBuilding"))
  17.     {
  18.         document.getElementById("buildingsTitleSpan").outerHTML += '<input id="chkBuyBuilding" title="autobuy Storage" type="checkbox">';
  19.     }
  20.     return document.getElementById("chkBuyBuilding").checked;
  21. }
  22.  
  23. document.getElementById("upgradesTitleSpan").outerHTML += '<input id="chkBuyUpgrades" title="autobuy non eqipment Upgrades" type="checkbox">';
  24. AutoBuyUpgrades=function ()
  25. {
  26.     if (!document.getElementById("chkBuyUpgrades"))
  27.     {
  28.         document.getElementById("upgradesTitleSpan").outerHTML += '<input id="chkBuyUpgrades" title="autobuy non eqipment Upgrades" type="checkbox">';
  29.     }
  30.     return document.getElementById("chkBuyUpgrades").checked;
  31. }
  32.  
  33. 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>';
  34. AutoBuyEquipH=function ()
  35. {
  36.     if (!document.getElementById("chkBuyEquipH"))
  37.     {
  38.         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>';
  39.     }
  40.     return document.getElementById("chkBuyEquipH").checked;
  41. }
  42. AutoBuyPrestigeH=function ()
  43. {
  44.     if (!document.getElementById("chkBuyPrestigeH"))
  45.     {
  46.         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>';
  47.     }
  48.     return document.getElementById("chkBuyPrestigeH").checked;
  49. }
  50. AutoBuyEquipA=function ()
  51. {
  52.     if (!document.getElementById("chkBuyEquipA"))
  53.     {
  54.         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>';
  55.     }
  56.     return document.getElementById("chkBuyEquipA").checked;
  57. }
  58. AutoBuyPrestigeA=function ()
  59. {
  60.     if (!document.getElementById("chkBuyPrestigeA"))
  61.     {
  62.         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>';
  63.     }
  64.     return document.getElementById("chkBuyPrestigeA").checked;
  65. }
  66.  
  67. OldTooltip=tooltip;
  68.  
  69. tooltip=function(a,b,c,d,e,f,g,h,i,j,k,l,m)
  70. {
  71.     if (ShowTooltips || a=='hide')
  72.     {
  73.         OldTooltip(a,b,c,d,e,f,g,h,i,j,k,l,m);
  74.     }
  75. }
  76.  
  77. BuyDaBuilding=function(what)
  78. {
  79.     ShowTooltips=false;
  80.     buyBuilding(what);
  81.     ShowTooltips=true;
  82. }
  83.  
  84. BuyDaEquip=function(what)
  85. {
  86.     ShowTooltips=false;
  87.     buyEquipment(what);
  88.     ShowTooltips=true;
  89. }
  90.  
  91. BuyDaUpgrade=function(what)
  92. {
  93.     ShowTooltips=false;
  94.     buyUpgrade(what);
  95.     ShowTooltips=true;
  96. }
  97.  
  98. TheThings={
  99.         'Dagger':{
  100.             Upgrade: 'Dagadder',
  101.             Stat:'attack',
  102.             Resource:'metal',
  103.             Equip:true
  104.             },
  105.         'Mace':{
  106.             Upgrade: 'Megamace',
  107.             Stat:'attack',
  108.             Resource:'metal',
  109.             Equip:true
  110.             },
  111.         'Polearm':{
  112.             Upgrade: 'Polierarm',
  113.             Stat:'attack',
  114.             Resource:'metal',
  115.             Equip:true
  116.             },
  117.         'Battleaxe':{
  118.             Upgrade: 'Axeidic',
  119.             Stat:'attack',
  120.             Resource:'metal',
  121.             Equip:true
  122.             },
  123.         'Greatsword':{
  124.             Upgrade: 'Greatersword',
  125.             Stat:'attack',
  126.             Resource:'metal',
  127.             Equip:true
  128.             },
  129.         'Boots':{
  130.             Upgrade: 'Bootboost',
  131.             Stat:'health',
  132.             Resource:'metal',
  133.             Equip:true
  134.             },
  135.         'Helmet':{
  136.             Upgrade: 'Hellishmet',
  137.             Stat:'health',
  138.             Resource:'metal',
  139.             Equip:true
  140.             },
  141.         'Pants':{
  142.             Upgrade: 'Pantastic',
  143.             Stat:'health',
  144.             Resource:'metal',
  145.             Equip:true
  146.             },
  147.         'Shoulderguards':{
  148.             Upgrade: 'Smoldershoulder',
  149.             Stat:'health',
  150.             Resource:'metal',
  151.             Equip:true
  152.             },
  153.         'Breastplate':{
  154.             Upgrade: 'Bestplate',
  155.             Stat:'health',
  156.             Resource:'metal',
  157.             Equip:true
  158.             },
  159.         'Arbalest':{
  160.             Upgrade: 'Harmbalest',
  161.             Stat:'attack',
  162.             Resource:'metal',
  163.             Equip:true
  164.         },
  165.         'Gambeson':{
  166.             Upgrade: 'GambesOP',
  167.             Stat:'health',
  168.             Resource:'metal',
  169.             Equip:true
  170.         },
  171.         'Shield':{
  172.             Upgrade: 'Supershield',
  173.             Stat:'health',
  174.             Resource:'wood',
  175.             Equip:true
  176.             },
  177.         'Gym':{
  178.             Upgrade: 'Gymystic',
  179.             Stat:'block',
  180.             Resource:'wood',
  181.             Equip:false
  182.             }
  183.     }
  184.    
  185. function GetObject(what)   
  186. {
  187.     var Thing=TheThings[what];
  188.     return Thing.Equip?game.equipment[what]:game.buildings[what];
  189. }
  190.    
  191. function Factor(what)
  192. {
  193.     var Thing=TheThings[what];
  194.     var Object=GetObject(what);
  195.     if (what=='Shield')
  196.     {
  197.         if (Object.blockNow)
  198.         {
  199.             Thing.Stat='block';
  200.         }
  201.         else
  202.         {
  203.             Thing.Stat='health';
  204.         }
  205.     }
  206.    
  207.     var Eff=Effect(Object,Thing);
  208.     var Cos=Cost(Object,Thing);
  209.     var Res=Eff/Cos;
  210.     var Status='white';
  211.     var Wall=false;
  212.    
  213.     //white - Upgrade is not available
  214.     //yellow - Upgrade is not affordable
  215.     //orange - Upgrade is affordable, but will lower stats
  216.     //red - Yes, do it now!
  217.     if (!game.upgrades[Thing.Upgrade].locked)
  218.     {
  219.         //Evaluating upgrade!
  220.         var CanAfford=canAffordTwoLevel(game.upgrades[Thing.Upgrade]);
  221.         if (Thing.Equip)
  222.         {
  223.             var NextEff=PrestigeValue(Thing.Upgrade);
  224.             var NextCost=getNextPrestigeCost(Thing.Upgrade) * Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level);
  225.             Wall=NextEff/NextCost>Res;
  226.         }
  227.        
  228.         if (!CanAfford)
  229.         {
  230.             Status='yellow';
  231.         }
  232.         else
  233.         {
  234.             if (!Thing.Equip)
  235.             {
  236.                 //Gymystic is always cool, fuck shield
  237.                 Status='red';
  238.             }
  239.             else
  240.             {
  241.                 var CurrEff=Object.level*Eff;
  242.                
  243.                 var NeedLevel=Math.ceil(CurrEff/NextEff);
  244.                 var Ratio=Object.cost[Thing.Resource][1];
  245.                
  246.                 var NeedResource=NextCost*(Math.pow(Ratio,NeedLevel)-1)/(Ratio-1);
  247.                
  248.                 if (game.resources[Thing.Resource].owned>NeedResource)
  249.                 {
  250.                     Status='red';
  251.                 }
  252.                 else
  253.                 {
  254.                     Status='orange';
  255.                 }
  256.             }
  257.         }
  258.     }
  259.    
  260.     return {
  261.         Stat:Thing.Stat,
  262.         Factor:Res,
  263.         Status:Status,
  264.         Wall:Wall
  265.     };
  266. }
  267.  
  268. function Effect(Object,Thing)
  269. {
  270.     if (Thing.Equip)
  271.     {
  272.         return Object[Thing.Stat+'Calculated'];
  273.     }
  274.     else
  275.     {
  276.         //That be Gym
  277.         var oldBlock = Object.increase.by*Object.owned;
  278.         var Mod=game.upgrades.Gymystic.done?(game.upgrades.Gymystic.modifier + (0.01 * (game.upgrades.Gymystic.done - 1))):1;
  279.         var newBlock=Object.increase.by*(Object.owned+1)*Mod;
  280.         return newBlock-oldBlock;
  281.     }
  282. }
  283.  
  284. function Cost(Object,Thing)
  285. {
  286.     var price = parseFloat(getBuildingItemPrice(Object, Thing.Resource, Thing.Equip));
  287.     if (Thing.Equip) price = Math.ceil(price * (Math.pow(1 - game.portal.Artisanistry.modifier, game.portal.Artisanistry.level)));
  288.     return price;
  289. }
  290.  
  291. function PrestigeValue(what)
  292. {
  293.     var name = game.upgrades[what].prestiges;
  294.     var equipment = game.equipment[name];
  295.     var stat;
  296.     if (equipment.blockNow) stat = "block";
  297.     else stat = (typeof equipment.health !== 'undefined') ? "health" : "attack";
  298.     var toReturn = Math.round(equipment[stat] * Math.pow(1.19, ((equipment.prestige) * game.global.prestige[stat]) + 1));
  299.     return toReturn;
  300. }
  301.  
  302. function EvalAll()
  303. {
  304.     var Best={
  305.         'healthwood':{Factor:0,Name:'',Wall:false,Status:'white'},
  306.         'healthmetal':{Factor:0,Name:'',Wall:false,Status:'white'},
  307.         'attackmetal':{Factor:0,Name:'',Wall:false,Status:'white'},
  308.         'blockwood':{Factor:0,Name:'',Wall:false,Status:'white'},
  309.     };
  310.  
  311.     for (var what in TheThings)
  312.     {
  313.         var Object=GetObject(what);
  314.         if (!Object.locked)
  315.         {
  316.             document.getElementById(what).style.color='white';
  317.             var Evaluation=Factor(what);
  318.             var BKey=TheThings[what].Stat+TheThings[what].Resource;
  319.             //console.log(BKey);
  320.             if (Best[BKey].Factor==0 || Best[BKey].Factor<Evaluation.Factor)
  321.             {
  322.                 Best[BKey].Factor=Evaluation.Factor;
  323.                 Best[BKey].Name=what;
  324.                 Best[BKey].Wall=Evaluation.Wall;
  325.                 Best[BKey].Status=Evaluation.Status;
  326.             }
  327.             document.getElementById(what).style.borderColor=Evaluation.Status;
  328.             if (Evaluation.Status!='white' && Evaluation.Status!='yellow')
  329.             {              
  330.                 document.getElementById(TheThings[what].Upgrade).style.color=Evaluation.Status;
  331.             }
  332.             if (Evaluation.Status=='yellow')
  333.             {
  334.                 document.getElementById(TheThings[what].Upgrade).style.color='white';
  335.             }
  336.             if (Evaluation.Wall)
  337.             {
  338.                 document.getElementById(what).style.color='yellow';
  339.             }
  340.            
  341.             if(
  342.                 Evaluation.Status=='red'
  343.                 &&
  344.                 (
  345.                     (
  346.                         AutoBuyPrestigeA()
  347.                         &&
  348.                         TheThings[what].Stat=='attack'
  349.                     )
  350.                     ||
  351.                     (
  352.                         AutoBuyPrestigeH()
  353.                         &&
  354.                         (
  355.                             TheThings[what].Stat=='health'
  356.                             ||
  357.                             TheThings[what].Stat=='block'
  358.                         )
  359.                     )
  360.                 )
  361.             )
  362.             {
  363.                 var upgrade = TheThings[what].Upgrade;
  364.                 console.log('Wanna do upgrade '+upgrade);
  365.                 BuyDaUpgrade(upgrade);
  366.             }
  367.         }
  368.     }
  369.    
  370.     for (var stat in Best)
  371.     {
  372.         if (Best[stat].Name!='')
  373.         {
  374.             var DaThing=TheThings[Best[stat].Name];
  375.             document.getElementById(Best[stat].Name).style.color=Best[stat].Wall?'orange':'red';
  376.             if (
  377.                     (
  378.                         AutoBuyEquipA()
  379.                         &&
  380.                         DaThing.Stat=='attack'
  381.                     )
  382.                     ||
  383.                     (
  384.                         AutoBuyEquipH()
  385.                         &&
  386.                         (
  387.                             DaThing.Stat=='health'
  388.                             ||
  389.                             DaThing.Stat=='block'
  390.                         )
  391.                     )
  392.                 )
  393.             {
  394.                 if (DaThing.Equip && !Best[stat].Wall && canAffordBuilding(Best[stat].Name, null, null, true))
  395.                 {
  396.                     console.log('Wanna level equip '+Best[stat].Name);
  397.                     BuyDaEquip(Best[stat].Name);
  398.                 }
  399.             }
  400.         }
  401.     }  
  402. }
  403.  
  404. setInterval('EvalAll()',250);
  405.  
  406. Builder={
  407.     Buys: {},
  408.     Start: function(what, counter)
  409.     {
  410.         this.Buys[what]=setInterval(function()
  411.         {
  412.             if (what=='Warpstation') //Special cases!
  413.             {
  414.                 if (AutoBuyBuilding() && !game.buildings[what].locked && canAffordBuilding(what))
  415.                 {
  416.                     console.log('Wanna buy '+what);
  417.                     BuyDaBuilding(what);
  418.                 }
  419.                 else if (
  420.                     (
  421.                             counter!=null
  422.                             &&
  423.                             game.buildings[what].owned>=counter+game.upgrades.Gigastation.done*counter/10.0
  424.                     )
  425.                     &&
  426.                     AutoBuyUpgrades()
  427.                     &&
  428.                     !game.upgrades.Gigastation.locked
  429.                 )
  430.                 {                  
  431.                     if (canAffordTwoLevel(game.upgrades.Gigastation))
  432.                     {
  433.                         var upgrade = 'Gigastation';
  434.                         console.log('Wanna do upgrade '+upgrade);
  435.                         BuyDaUpgrade(upgrade);
  436.                     }                      
  437.                 }
  438.             }
  439.             else if (AutoBuyBuilding() && !game.buildings[what].locked && canAffordBuilding(what))
  440.             {
  441.                 if (counter==null || game.buildings[what].purchased<counter)
  442.                 {
  443.                     if (what=='Collector') // Special cases FTW
  444.                     {
  445.                         var Coll=game.buildings.Collector;
  446.                         var Warp=game.buildings.Warpstation;
  447.                         if (!Warp.locked)
  448.                         {
  449.                             CollGemCost=Coll.cost.gems[0]*Math.pow(Coll.cost.gems[1],Coll.purchased);
  450.                             CollEffect=Coll.increase.by/CollGemCost;
  451.                            
  452.                             WarpGemCost=Warp.cost.gems[0]*Math.pow(Warp.cost.gems[1],Warp.purchased);
  453.                             WarpEffect=Warp.increase.by/WarpGemCost;
  454.                         }
  455.                         if (Warp.locked || CollEffect>WarpEffect || game.resources.gems.owned>CollGemCost+WarpGemCost)
  456.                         {
  457.                             console.log('Wanna buy '+what);
  458.                             BuyDaBuilding(what);
  459.                         }
  460.                     }
  461.                     else if (what=='Nursery')
  462.                     {
  463.                         var Wanna=true;
  464.                         if (game.jobs.Geneticist.locked && (GetBreedTime()<GeneticistTimeLimit()+1 || game.buildings.Nursery.purchased!=game.buildings.Nursery.owned))
  465.                         {
  466.                             Wanna=false;
  467.                         }
  468.                         if (!game.buildings.Collector.locked && !game.global.brokenPlanet && game.buildings.Collector.purchased<game.buildings.Nursery.purchased/10)
  469.                         {
  470.                             Wanna=false;
  471.                         }
  472.                         if (Wanna)
  473.                         {
  474.                             console.log('Wanna buy '+what);
  475.                             BuyDaBuilding(what);
  476.                         }
  477.                     }
  478.                     else
  479.                     {
  480.                         console.log('Wanna buy '+what);
  481.                         BuyDaBuilding(what);
  482.                     }
  483.                 }
  484.             }
  485.         },250);
  486.     },
  487.     Stop: function(what)
  488.     {
  489.         if (this.Buys[what])
  490.         {
  491.             clearInterval(this.Buys[what]);
  492.             delete this.Buys[what];
  493.         }
  494.     }
  495. }
  496.  
  497. setInterval(function(){
  498.     var packMod = 1 + game.portal.Packrat.level * game.portal.Packrat.modifier;
  499.     var motMod = 1 + game.portal.Motivation.level * game.portal.Motivation.modifier;
  500.     var Bs={'Barn':'food','Shed':'wood','Forge':'metal'};
  501.     var Js={'Barn':'Farmer','Shed':'Lumberjack','Forge':'Miner'};
  502.    
  503.     for (var B in Bs)
  504.     {
  505.         var Res=game.resources[Bs[B]];
  506.         var Job=game.jobs[Js[B]];
  507.         if (Res.owned>Res.max*packMod*0.9 || Job.owned*Job.modifier*motMod*600>Res.max*packMod)
  508.         {
  509.             //console.log(B+': '+Bs[B]+' - '+game.resources[Bs[B]].owned+'/'+(game.resources[Bs[B]].max*packMod*0.99));
  510.             if (AutoBuyStorage() && canAffordBuilding(B))
  511.             {
  512.                 console.log('Wanna buy '+B);
  513.                 BuyDaBuilding(B);
  514.             }
  515.         }
  516.     }
  517. },
  518. 250);
  519.  
  520. Us=[
  521.         'Coordination',
  522.         'Speedminer',
  523.         'Speedlumber',
  524.         'Speedfarming',
  525.         'Speedscience',
  526.         'Megaminer',
  527.         'Megalumber',
  528.         'Megafarming',
  529.         'Megascience',
  530.         'Efficiency',
  531.         'Potency',
  532.         'TrainTacular',
  533.         'Miners',
  534.         'Scientists',
  535.         'Trainers',
  536.         'Explorers',
  537.         'Blockmaster',
  538.         'Battle',
  539.         'Bloodlust',
  540.         'Bounty',
  541.         'Egg',
  542.         'Anger',
  543.         'Formations',
  544.         'Dominance',
  545.         'Barrier',
  546.         'UberHut',
  547.         'UberHouse',
  548.         'UberMansion',
  549.         'UberHotel',
  550.         'UberResort'
  551.     ];
  552.  
  553. setInterval(function(){
  554.     for (var U in Us)
  555.     {
  556.         var name=Us[U];
  557.         var up=game.upgrades[Us[U]];
  558.         if (AutoBuyUpgrades() && up.allowed>up.done && canAffordTwoLevel(up))
  559.         {
  560.             if (name=='Potency')
  561.             {
  562.                 if ((game.jobs.Geneticist.locked && GetBreedTime()>GeneticistTimeLimit()+1) || !game.jobs.Geneticist.locked)
  563.                 {
  564.                     console.log('Wanna read '+name);
  565.                     BuyDaUpgrade(name);
  566.                 }
  567.             }
  568.             else
  569.             {
  570.                 if (name!='Coordination')
  571.                 {
  572.                     console.log('Wanna read '+name);
  573.                 }
  574.                 BuyDaUpgrade(name);
  575.             }
  576.         }
  577.     }
  578. },
  579. 250);
  580.  
  581. Builder.Start('Hut',75)
  582. Builder.Start('House',75)
  583. Builder.Start('Gym')
  584. Builder.Start('Mansion',75)
  585. Builder.Start('Hotel',75)
  586. Builder.Start('Resort',75)
  587. Builder.Start('Gateway',20)
  588. Builder.Start('Wormhole',10)
  589. Builder.Start('Collector', 250)
  590. Builder.Start('Warpstation',27)
  591. Builder.Start('Tribute')
  592. Builder.Start('Nursery')
  593.  
  594. document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkBuyJobs" title="autobuy Jobs" type="checkbox"><input id="txtGeneticistTimeLimit" title="balance Geneticists for this breeding time" style="width: 40px; height: 25px; color: black;" type="text" value="30"></input>';
  595. AutoBuyJobs=function ()
  596. {
  597.     if (!document.getElementById("chkBuyJobs"))
  598.     {
  599.         document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkBuyJobs" title="autobuy Jobs" type="checkbox"><input id="txtGeneticistTimeLimit" title="balance Geneticists for this breeding time" style="width: 40px; height: 25px; color: black;" type="text" value="30"></input>';
  600.     }
  601.     return document.getElementById("chkBuyJobs").checked;
  602. }
  603.  
  604. GeneticistTimeLimit=function ()
  605. {
  606.     if (!document.getElementById("txtGeneticistTimeLimit"))
  607.     {
  608.                 document.getElementById("jobsTitleSpan").innerHTML += '<input id="chkBuyJobs" title="autobuy Jobs" type="checkbox"><input id="txtGeneticistTimeLimit" title="balance Geneticists for this breeding time" style="width: 40px; height: 25px; color: black;" type="text" value="30"></input>';
  609.     }
  610.     var BT=parseInt(document.getElementById("txtGeneticistTimeLimit").value) || 3;
  611.     BT=(BT>3 && game.global.challengeActive=="Electricity")?3:BT;
  612.     return BT;
  613. }
  614.  
  615. function MaxWorkers()
  616. {
  617.     return Math.ceil(game.resources.trimps.realMax() / 2);
  618. }
  619.  
  620. function FreeWorkers()
  621. {
  622.     return MaxWorkers()-game.resources.trimps.employed;
  623. }
  624.  
  625. function canAffordJobLight(what, take, HowMany) {
  626.     var trimps = game.resources.trimps;
  627.     var toBuy = HowMany;
  628.     var job = game.jobs[what];
  629.     for (var costItem in job.cost) {
  630.         if (!checkJobItem(what, take, costItem, null, toBuy)) return false;
  631.     }
  632.     if (take) return toBuy;
  633.     return true;
  634. }
  635.  
  636. function TryAddGuys(what, HowMany)
  637. {
  638.     var workspaces = FreeWorkers();
  639.     if (workspaces < HowMany) return;
  640.     if (!canAffordJobLight(what, false, HowMany)) return 0;
  641.     var added = canAffordJobLight(what, true, HowMany);
  642.     game.jobs[what].owned += added;
  643.     game.resources.trimps.employed += added;
  644.     return added;
  645. }
  646.  
  647. function TryRemoveGuys(what, HowMany)
  648. {
  649.     if (game.jobs[what].owned < 1) return 0;
  650.    
  651.     var toR=(game.jobs[what].owned < HowMany) ? game.jobs[what].owned : HowMany;
  652.    
  653.     game.resources.trimps.employed -= toR;
  654.     game.jobs[what].owned -= toR;
  655.     if (game.jobs[what].owned < 0) game.jobs[what].owned = 0;
  656.     if (game.resources.trimps.employed < 0) game.resources.trimps.employed = 0;
  657.     return toR;
  658. }
  659.  
  660. function canAffordJobLight(what, take, HowMany) {
  661.     var trimps = game.resources.trimps;
  662.     var toBuy = HowMany;
  663.     var job = game.jobs[what];
  664.     for (var costItem in job.cost) {
  665.         if (!checkJobItem(what, take, costItem, null, toBuy)) return false;
  666.     }
  667.     if (take) return toBuy;
  668.     return true;
  669. }
  670.  
  671. function GetBreedTime()
  672. {
  673.     var trimps = game.resources.trimps;
  674.     var trimpsMax = trimps.realMax();
  675.     var Soldiers= game.portal.Coordinated.level ? game.portal.Coordinated.currentSend: game.resources.trimps.maxSoldiers;
  676.    
  677.     var potencyMod = trimps.potency;
  678.    
  679.     potencyMod += (potencyMod * game.portal.Pheromones.level * game.portal.Pheromones.modifier);
  680.     if (game.jobs.Geneticist.owned > 0) potencyMod *= Math.pow(.98, game.jobs.Geneticist.owned);
  681.     if (game.unlocks.quickTrimps) potencyMod *= 2;
  682.    
  683.     if (!game.global.brokenPlanet) potencyMod *= 10;
  684.    
  685.     if (game.global.challengeActive == "Toxicity" && game.challenges.Toxicity.stacks > 0){
  686.         potencyMod *= Math.pow(game.challenges.Toxicity.stackMult, game.challenges.Toxicity.stacks);
  687.     }
  688.    
  689.     var max = Math.ceil((trimpsMax - trimps.employed) * 0.05);
  690.    
  691.     var timeRemaining = log10((trimpsMax - max - trimps.employed) / (trimpsMax - max - Soldiers - trimps.employed)) / log10(1 + (potencyMod / 10));
  692.    
  693.     return timeRemaining;
  694. }
  695.  
  696. TheJobs=[
  697.     {
  698.         Name:'Explorer',
  699.         Want:1,
  700.         Buffer:0,
  701.         Increase:function(want){return game.jobs.Explorer.owned<100?10:0;}
  702.     },
  703.     {
  704.         Name:'Trainer',
  705.         Want:1,
  706.         Buffer:0,
  707.         Increase:function(want){return Math.ceil((game.jobs.Trainer.owned+1)/100);}
  708.     },
  709.     {
  710.         Name:'Geneticist',
  711.         Want:1,
  712.         Buffer:0,
  713.         Increase:function(want){
  714.             var BT=GeneticistTimeLimit();
  715.             var RBT=GetBreedTime();
  716.             BT=(BT<1)?1:((BT>30?30:BT));
  717.             return (RBT<BT+0.3)?1:((RBT>BT+0.9)?-1:0);
  718.         }
  719.     },
  720.     {
  721.         Name:'Miner',
  722.         Want:0.3,
  723.         Buffer:104,
  724.         Increase:function(want){return Math.ceil(want/10);}
  725.     },
  726.     {
  727.         Name:'Farmer',
  728.         Want:0.3,
  729.         Buffer:102,
  730.         Increase:function(want){return Math.ceil(want/10);}
  731.     },
  732.     {
  733.         Name:'Lumberjack',
  734.         Want:0.3,
  735.         Buffer:100,
  736.         Increase:function(want){return Math.ceil(want/10);}
  737.     },
  738.     {
  739.         Name:'Scientist',
  740.         Want:0.1,
  741.         Buffer:50,
  742.         Increase:function(want){
  743.             return Math.ceil((Math.min(10000,game.jobs.Lumberjack.owned)-game.jobs.Scientist.owned)/10);
  744.         }
  745.     }
  746. ];
  747.  
  748. function JobsTime()
  749. {
  750.     var MaxW=MaxWorkers();
  751.     var FreeW=FreeWorkers();
  752.     for (var TJ in TheJobs)
  753.     {
  754.         var TheJob=TheJobs[TJ];
  755.         if (!game.jobs[TheJob.Name].locked && AutoBuyJobs())
  756.         {
  757.             if (document.getElementById(TheJob.Name))
  758.             {
  759.                 var Target=Math.floor((MaxW-TheJob.Buffer)*TheJob.Want);
  760.                 var Want=Math.min(FreeW-TheJob.Buffer,TheJob.Increase(Math.min(FreeW-TheJob.Buffer, Target-game.jobs[TheJob.Name].owned)));
  761.                 if (Want>0 && game.resources.trimps.owned>MaxWorkers())
  762.                 {
  763.                     var added=TryAddGuys(TheJob.Name,Want);
  764.                     if (added>0)
  765.                     {
  766.                         //console.log('Want '+Want+' of '+TheJob.Name);
  767.                         FreeW-=added;
  768.                     }
  769.                 }
  770.                 else if (Want<0 && TheJob.Name=='Geneticist')
  771.                 {
  772.                     //console.log('Want '+Want+' of '+TheJob.Name);
  773.                     var removed=TryRemoveGuys(TheJob.Name, -Want);
  774.                     if (removed>0)
  775.                     {
  776.                         //console.log('Want '+Want+' of '+TheJob.Name);
  777.                         FreeW+=removed;
  778.                     }
  779.                 }
  780.             }
  781.         }
  782.     }
  783. }
  784.  
  785. setInterval('JobsTime()',250);
  786.  
  787. var ManualGather='metal';
  788. function ManualLabor()
  789. {
  790.     if (game.global.playerGathering && game.global.playerGathering!='buildings' && game.global.playerGathering!='science')
  791.     {
  792.         ManualGather=game.global.playerGathering;
  793.     }
  794.     if ((game.global.buildingsQueue.length > 2)||(game.global.buildingsQueue.length > 0 && game.global.playerModifier>1000)&& game.global.playerGathering!='buildings')
  795.     {
  796.         setGather('buildings');
  797.     }
  798.     else if (game.global.playerModifier*60>game.resources.science.owned)
  799.     {
  800.         setGather('science');
  801.     }
  802.     else
  803.     {
  804.         setGather(ManualGather);          
  805.     }
  806. }
  807.  
  808. setInterval('ManualLabor()',250);
Advertisement
Add Comment
Please, Sign In to add comment