Advertisement
Gimlao

Cookie Cheater

Apr 23rd, 2015
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var interval = 250;
  2. var autoBuy = true;
  3. var autoBuyTxt = "on";
  4. var autoClickerTxt = "on";
  5. var autoClicker = setInterval(function () {
  6.     if (autoClickerTxt == "on")
  7.       Game.ClickCookie();
  8.   }, 0);
  9. var autoGoldClicker = setInterval(function () {
  10.     if (autoClickerTxt == "on" && Game.goldenCookie.life > 0 && Game.goldenCookie.wrath == 0)
  11.       Game.goldenCookie.click();
  12.   }, interval);
  13.  
  14. document.addEventListener('keydown', function (event) {
  15.   if (event.keyCode == 65) {
  16.     autoBuy = !autoBuy;
  17.     if (autoBuy) {
  18.       autoBuyTxt = "on";
  19.     } else {
  20.       autoBuyTxt = "off";
  21.     }
  22.   }
  23. });
  24.  
  25. document.addEventListener('keydown', function (event) {
  26.   if (event.keyCode == 90) {
  27.     if (autoClickerTxt == "on") {
  28.       autoClickerTxt = "off";
  29.     } else {
  30.       autoClickerTxt = "on";
  31.     }
  32.   }
  33. });
  34.  
  35. var cookieBot = setInterval(function () {
  36.     if (autoBuy == true) {
  37.       Game.ObjectsById[optimalBuilding()].buy();
  38.     } else {
  39.       optimalBuilding();
  40.     }
  41.   }, interval);
  42.  
  43. function optimalBuilding() {
  44.   cpc = Number.MAX_VALUE;
  45.   var x = 0;
  46.   cps = 0
  47.     for (i = Game.ObjectsById.length - 1; i >= 0; i--) {
  48.       var me = Game.ObjectsById[i];
  49.       CpSlower = 0;
  50.       for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
  51.         CpSlower += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
  52.       }
  53.       me.amount++;
  54.       CpSupper = 0;
  55.       for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
  56.         CpSupper += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
  57.       }
  58.       me.amount--;
  59.       var myCpS = (CpSupper - CpSlower) * Game.globalCpsMult;
  60.       var cpc2 = me.price * (Game.cookiesPs + myCpS) / myCpS;
  61.       if (cpc2 < cpc) {
  62.         cpc = cpc2;
  63.         x = i;
  64.         cps = myCpS
  65.       }
  66.     }
  67.  
  68.     var time = (Math.round(Game.ObjectsById[x].price) - Game.cookies) / Game.cookiesPs;
  69.   time = time < 0 ? 0 : Beautify(time);
  70.  
  71.   var numb = (Math.abs(Game.computedMouseCps / Game.cookiesPs));
  72.   numb = numb.toFixed(3);
  73.  
  74.   var txt = "Buying " + Game.ObjectsById[x].name + " for " +
  75.     Beautify(Math.round(Game.ObjectsById[x].price)) + "!" +
  76.     "<br>This will take " + time + " seconds without manually clicking." +
  77.     "<br>Each click would save you " + numb + " seconds." +
  78.     "<br>Press A to toggle auto-buy. Auto-buy is currently " + autoBuyTxt + "." +
  79.     "<br>Press Z to toggle auto-clicker. Auto-clicker is currently " + autoClickerTxt + ".";
  80.   Game.Ticker = txt;
  81.   Game.TickerAge = interval;
  82.   return x;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement