Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var interval = 250;
- var autoBuy = true;
- var autoBuyTxt = "on";
- var name;
- var price;
- var cpsItem;
- var selected=0;
- var currentCps=Game.cookiesPs;
- var selectedItem
- document.addEventListener('keydown', function(event) {
- if(event.keyCode == 65) {
- autoBuy = !autoBuy;
- autoBuyTxt = autoBuy ? "on" : "off";
- }
- });
- function OptimalItem()
- {
- var cpc = Number.MAX_VALUE;
- var sel;
- for(i = Game.UpgradesInStore.length-1; i >= 0; i--)
- {
- var cps1 = 0;
- var me = Game.UpgradesInStore[i];
- var x = Game.UpgradesInStore[i].id;
- if (x != 64 && x != 74 && x != 84 && x != 85 && x != 181 && x != 182 && x != 183 && x != 184)
- {
- Game.UpgradesById[x].toggle();
- Game.CalculateGains();
- for(j = Game.ObjectsById.length-1; j >= 0; j--){ cps1 += Game.ObjectsById[j].cps()*Game.ObjectsById[j].amount; }
- var cps2 = cps1 * Game.globalCpsMult;
- Game.UpgradesById[x].toggle();
- Game.CalculateGains();
- var myCps = cps2 - currentCps;
- var cpsUpgrade = me.basePrice *(Game.cookiesPs + myCps) / myCps;
- if (cpsUpgrade < cpc && myCps >= 0.1)
- {
- cpc = cpsUpgrade;
- sel = me;
- cpsItem = myCps;
- name = me.name;
- price = Math.round(me.basePrice);
- }
- }
- }
- for(i = Game.ObjectsById.length-1; i >= 0; i--){
- var cps1=0;
- var me = Game.ObjectsById[i];
- me.amount++;
- Game.CalculateGains();
- for(j = Game.ObjectsById.length-1; j >= 0; j--){ cps1 += Game.ObjectsById[j].cps()*Game.ObjectsById[j].amount;}
- var cps2 = cps1 * Game.globalCpsMult;
- me.amount--;
- Game.CalculateGains();
- var myCps = cps2 - currentCps;
- var cpsBuilding = me.price *(Game.cookiesPs + myCps) / myCps;
- if (cpsBuilding < cpc && myCps >= 0.1)
- {
- cpc = cpsBuilding;
- sel = me;
- cpsItem = myCps;
- name = me.name;
- price = Math.round(me.price);
- }
- }
- currentCps = Game.cookiesPs;
- selected=1;
- selectedItem=sel;
- }
- function Display()
- {
- var time = (price - Game.cookies) / Game.cookiesPs;
- time = time < 0 ? 0 : Beautify(time);
- var numb = (Math.abs(Game.computedMouseCps / Game.cookiesPs));
- numb = numb.toFixed(3);
- Game.Ticker = "Buying " + name + " for " + Beautify(price) + " at " + Beautify(Math.round(price / (cpsItem*Game.globalCpsMult))) + " cookies per CPS!" + "<br>This will take " + time + " seconds without manually clicking." + "<br>Each click would save you " + numb + " seconds." + "<br>Click A to toggle auto-buy. Auto-buy is currently " + autoBuyTxt;
- Game.TickerAge = interval;
- }
- var cookieBot = setInterval(function () {
- if(autoBuy && Game.cookies >= price && selected==1){selectedItem.buy(); Display; selected=0;}
- else if(selected==0 || currentCps!=Game.cookiesPs){OptimalItem(); Display();}
- else if(selected==1){Display();}}, interval
- );
Advertisement
Add Comment
Please, Sign In to add comment