Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var interval = 250;
- var autoBuy = true;
- var autoBuyTxt = "on";
- var autoClickerTxt = "on";
- var autoClicker = setInterval(function () {
- if (autoClickerTxt == "on")
- Game.ClickCookie();
- }, 0);
- var autoGoldClicker = setInterval(function () {
- if (autoClickerTxt == "on" && Game.goldenCookie.life > 0 && Game.goldenCookie.wrath == 0)
- Game.goldenCookie.click();
- }, interval);
- document.addEventListener('keydown', function (event) {
- if (event.keyCode == 65) {
- autoBuy = !autoBuy;
- if (autoBuy) {
- autoBuyTxt = "on";
- } else {
- autoBuyTxt = "off";
- }
- }
- });
- document.addEventListener('keydown', function (event) {
- if (event.keyCode == 90) {
- if (autoClickerTxt == "on") {
- autoClickerTxt = "off";
- } else {
- autoClickerTxt = "on";
- }
- }
- });
- var cookieBot = setInterval(function () {
- if (autoBuy == true) {
- Game.ObjectsById[optimalBuilding()].buy();
- } else {
- optimalBuilding();
- }
- }, interval);
- function optimalBuilding() {
- cpc = Number.MAX_VALUE;
- var x = 0;
- cps = 0
- for (i = Game.ObjectsById.length - 1; i >= 0; i--) {
- var me = Game.ObjectsById[i];
- CpSlower = 0;
- for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
- CpSlower += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
- }
- me.amount++;
- CpSupper = 0;
- for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
- CpSupper += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
- }
- me.amount--;
- var myCpS = (CpSupper - CpSlower) * Game.globalCpsMult;
- var cpc2 = me.price * (Game.cookiesPs + myCpS) / myCpS;
- if (cpc2 < cpc) {
- cpc = cpc2;
- x = i;
- cps = myCpS
- }
- }
- var time = (Math.round(Game.ObjectsById[x].price) - Game.cookies) / Game.cookiesPs;
- time = time < 0 ? 0 : Beautify(time);
- var numb = (Math.abs(Game.computedMouseCps / Game.cookiesPs));
- numb = numb.toFixed(3);
- var txt = "Buying " + Game.ObjectsById[x].name + " for " +
- Beautify(Math.round(Game.ObjectsById[x].price)) + "!" +
- "<br>This will take " + time + " seconds without manually clicking." +
- "<br>Each click would save you " + numb + " seconds." +
- "<br>Press A to toggle auto-buy. Auto-buy is currently " + autoBuyTxt + "." +
- "<br>Press Z to toggle auto-clicker. Auto-clicker is currently " + autoClickerTxt + ".";
- Game.Ticker = txt;
- Game.TickerAge = interval;
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement