Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.24 KB | None | 0 0
  1. //cookie bot: auto-play-through cookie clicker
  2. var AutoPlay;
  3.  
  4. if(!AutoPlay) AutoPlay = {};
  5. AutoPlay.version = "2.0"
  6. AutoPlay.gameVersion = "2.0042";
  7. AutoPlay.robotName="Automated ";
  8. AutoPlay.delay=0;
  9. AutoPlay.night=false;
  10.  
  11. AutoPlay.run = function () {
  12. if (Game.AscendTimer>0 || Game.ReincarnateTimer>0) return;
  13. if (AutoPlay.delay>0) { AutoPlay.delay--; return; }
  14. if (AutoPlay.nightMode()) { var age=Date.now()-Game.lumpT; AutoPlay.cheatSugarLumps(age); return; }
  15. AutoPlay.handleClicking();
  16. AutoPlay.handleGoldenCookies();
  17. AutoPlay.handleBuildings();
  18. AutoPlay.handleUpgrades();
  19. AutoPlay.handleSeasons();
  20. AutoPlay.handleSugarLumps();
  21. AutoPlay.handleDragon();
  22. AutoPlay.handleWrinklers();
  23. AutoPlay.handleAscend();
  24. AutoPlay.handleNotes();
  25. }
  26.  
  27. //===================== Night Mode ==========================
  28. AutoPlay.preNightMode = function() { var h=(new Date).getHours(); return(h>=22); }
  29.  
  30. AutoPlay.nightMode = function() {
  31. var h=(new Date).getHours();
  32. if(h>=7 && h<23) { // be active
  33. if (AutoPlay.night) AutoPlay.useLump();
  34. AutoPlay.night=false;
  35. var gs=Game.Upgrades["Golden switch [on]"]; if(gs.unlocked) {
  36. if (Game.isMinigameReady(Game.Objects["Temple"])) {
  37. AutoPlay.removeSpirit(1,"asceticism");
  38. // AutoPlay.assignSpirit(1,"decadence",0);
  39. // AutoPlay.assignSpirit(2,"labor",0);
  40. }
  41. gs.buy();
  42. }
  43. return false;
  44. }
  45. if (AutoPlay.night) return true; //really sleep now
  46. var gs=Game.Upgrades["Golden switch [off]"]; if(gs.unlocked) {
  47. AutoPlay.handleGoldenCookies();
  48. var buffCount=0;
  49. for (var i in Game.buffs) { if(Game.buffs[i].time>=0) buffCount++; }
  50. if((buffCount==1 && Game.hasBuff("Clot")) || h<7) gs.buy();
  51. if(!gs.bought) return true; // do not activate spirits before golden switch
  52. if (Game.isMinigameReady(Game.Objects["Temple"])) {
  53. // AutoPlay.assignSpirit(0,"mother",1);
  54. AutoPlay.removeSpirit(1,"decadence");
  55. AutoPlay.removeSpirit(2,"labor");
  56. AutoPlay.assignSpirit(1,"asceticism",1);
  57. AutoPlay.assignSpirit(2,"industry",1);
  58. }
  59. }
  60. AutoPlay.night=true;
  61. return true;
  62. }
  63.  
  64. //===================== Handle Cookies and Golden Cookies ==========================
  65. AutoPlay.handleGoldenCookies = function() { // pop the first golden cookie or reindeer
  66. if(Game.shimmerTypes['golden'].n>=4 && !Game.Achievements['Four-leaf cookie'].won) return;
  67. for(sx in Game.shimmers) {
  68. var s=Game.shimmers[sx];
  69. if((s.type!="golden") || (s.life<Game.fps) || (!Game.Achievements["Early bird"].won)) { s.pop(); return; }
  70. if((s.life/Game.fps)<(s.dur-2) && (Game.Achievements["Fading luck"].won)) { s.pop(); return; }
  71. } }
  72.  
  73. AutoPlay.handleClicking = function() {
  74. if (!Game.Achievements["Neverclick"].won && (Game.cookieClicks<=15) ) return;
  75. if (Game.ascensionMode==1 && AutoPlay.endPhase() && !Game.Achievements["True Neverclick"].won && (!Game.cookieClicks) ) return;
  76. if(!Game.Achievements["Uncanny clicker"].won) { for(i=1; i<6; i++) setTimeout(Game.ClickCookie, 50*i); }
  77. if (Game.ascensionMode==1 && Game.Achievements["Hardcore"].won) setTimeout(Game.ClickCookie, 150);
  78. Game.ClickCookie();
  79. }
  80.  
  81. //===================== Handle Upgrades ==========================
  82. AutoPlay.handleUpgrades = function() {
  83. if (!Game.Achievements["Hardcore"].won && Game.UpgradesOwned==0) return;
  84. Game.UpgradesById.forEach(function(e) { if (e.unlocked && !e.bought && e.canBuy() && !AutoPlay.avoidbuy(e)) { e.buy(true); } });
  85. }
  86.  
  87. AutoPlay.avoidbuy = function(up) { //normally we do not buy 227, 71, 73, rolling pins
  88. switch(up.id) {
  89. case 71: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won &&
  90. (!Game.Achievements["Reincarnation"].won || Game.Upgrades["Arcane sugar"].bought); // brainsweep
  91. case 73: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won; // elder pact
  92. case 74: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Upgrades["Elder Covenant"].unlocked; // elder pledge
  93. case 84: return Game.Upgrades["Elder Pledge"].bought; // elder covenant
  94. // case 85: return Game.Upgrades["Elder Covenant"].bought; // revoke elder covenant
  95. case 227: return true; // choco egg
  96. default: return up.pool=="toggle";
  97. } }
  98.  
  99. //===================== Handle Buildings ==========================
  100. AutoPlay.handleBuildings = function() {
  101. var buyAmount=100, checkAmount=1;
  102. if ((Date.now()-Game.startDate) > 10*60*1000) buyAmount=1; // buy single after 10 minutes
  103. if (Game.resets && Game.ascensionMode!=1 && Game.isMinigameReady(Game.Objects["Temple"]) && Game.Objects["Temple"].minigame.slot[0]==10 // Rigidel is in slot 0
  104. && Game.BuildingsOwned%10==0 && (Date.now()-Game.startDate) > 2*60*1000) // do not use factor 10 in the first 2 minutes after descend
  105. buyAmount=checkAmount=10;
  106. var cpc=0; // relative strength of cookie production
  107. for(var i = Game.ObjectsById.length-1; i >= 0; i--){ var me = Game.ObjectsById[i]; var mycpc = me.storedCps / me.price; if (mycpc > cpc) { cpc = mycpc; } };
  108. for(i = Game.ObjectsById.length-1; i >= 0; i--) {
  109. var me = Game.ObjectsById[i];
  110. if ((me.storedCps/me.price > cpc/2 || me.amount % 50 >= 40) && (me.getSumPrice(checkAmount)<Game.cookies)) { me.buy(buyAmount); return; }
  111. }
  112. if(Game.resets && Game.ascensionMode!=1 && Game.isMinigameReady(Game.Objects["Temple"]) && Game.Objects["Temple"].minigame.slot[0]==10 && Game.BuildingsOwned%10!=0) { // Rigidel is in slot 0, buy the cheapest
  113. var minIdx=0, minPrice=Game.ObjectsById[minIdx].price;
  114. for(var i = Game.ObjectsById.length-1; i >= 0; i--){ if (Game.ObjectsById[i].price < minPrice) { minPrice=Game.ObjectsById[i].price; minIdx=i; } };
  115. Game.ObjectsById[minIdx].buy();
  116. } }
  117.  
  118. //===================== Handle Seasons ==========================
  119. AutoPlay.handleSeasons = function() {
  120. if (!Game.Upgrades["Season switcher"].bought || Game.ascensionMode==1) return;
  121. if (AutoPlay.seasonFinished(Game.season)) {
  122. switch (Game.season) {
  123. case "christmas": Game.Upgrades["Bunny biscuit"].buy(); break; // go to easter
  124. case "easter": Game.Upgrades["Lovesick biscuit"].buy(); break; // go to valentine
  125. case "valentines": Game.Upgrades["Ghostly biscuit"].buy(); break; // go to halloween
  126. default: Game.Upgrades["Festive biscuit"].buy(); break; // go to christmas
  127. } }
  128. if (Game.Upgrades["A festive hat"].bought && ! Game.Upgrades["Santa's dominion"].unlocked) { // develop santa
  129. Game.specialTab="santa"; Game.UpgradeSanta(); Game.ToggleSpecialMenu(0);
  130. } }
  131.  
  132. AutoPlay.valentineUpgrades = range(169,174);
  133. AutoPlay.christmasUpgrades = [168].concat(range(152,166)).concat(range(143,149));
  134. AutoPlay.easterUpgrades = range(210,229);
  135. AutoPlay.halloweenUpgrades = range(134,140);
  136. AutoPlay.allSeasonUpgrades = AutoPlay.valentineUpgrades.concat(AutoPlay.christmasUpgrades).concat(AutoPlay.easterUpgrades).concat(AutoPlay.halloweenUpgrades);
  137.  
  138. AutoPlay.allUnlocked = function(l) { return l.every(function (u) { return Game.UpgradesById[u].unlocked; }); }
  139.  
  140. AutoPlay.seasonFinished = function(s) {
  141. if (s == '') return true;
  142. switch (s) {
  143. case "valentines": return AutoPlay.allUnlocked(AutoPlay.valentineUpgrades);
  144. case "christmas": if (AutoPlay.allUnlocked(AutoPlay.allSeasonUpgrades)) return false; else return AutoPlay.allUnlocked(AutoPlay.christmasUpgrades);
  145. case "easter": return (Game.Achievements["Hide & seek champion"].won && (AutoPlay.allUnlocked(AutoPlay.easterUpgrades)));
  146. case "halloween": return AutoPlay.allUnlocked(AutoPlay.halloweenUpgrades);
  147. default: return true;
  148. } }
  149.  
  150. //===================== Handle Sugarlumps ==========================
  151. AutoPlay.level1Order=[6,7]; // unlocking in this order for the minigames
  152. AutoPlay.level10Order=[7,14,13,12,11]; // finishing in this order
  153. AutoPlay.levelAchievements=range(307,320).concat([336]);
  154. AutoPlay.lumpRelatedAchievements=range(266,272).concat(AutoPlay.levelAchievements);
  155.  
  156. AutoPlay.handleSugarLumps = function() {
  157. if (Game.resets==0 || Game.ascensionMode==1) return; //do not work with sugar lumps when born again
  158. var age=Date.now()-Game.lumpT;
  159. if (age>=Game.lumpMatureAge && Game.lumpCurrentType==0 && !Game.Achievements["Hand-picked"].won) AutoPlay.harvestLump();
  160. // if(Game.lumpCurrentType==0) AutoPlay.farmGoldenSugarLumps(age); // not needed now, because we cheat sugar lumps
  161. if (age>=Game.lumpRipeAge) AutoPlay.harvestLump(); // normal harvesting, should check !masterCopy
  162. AutoPlay.cheatSugarLumps(age);
  163. AutoPlay.handleMinigames();
  164. }
  165.  
  166. AutoPlay.cheatLumps=false;
  167. AutoPlay.cheatSugarLumps = function(age) { // divide lump ripe time by 600, making hours into few minutes
  168. for(a in Game.AchievementsById) { var me=Game.AchievementsById[a]; if (!(me.won || me.pool=="dungeon" || AutoPlay.lumpRelatedAchievements.indexOf(me.id)>=0)) return; }
  169. AutoPlay.cheatLumps=true; // after checking that only lump related achievements are missing
  170. var cheatReduction=60*10;
  171. var cheatDelay=Game.lumpRipeAge/cheatReduction;
  172. if(age<Game.lumpRipeAge-cheatDelay) Game.lumpT-=cheatDelay*(cheatReduction-1);
  173. if (AutoPlay.nightMode() && age>Game.lumpRipeAge) { Game.lumpT-=60*60*1000; }
  174. }
  175.  
  176. AutoPlay.harvestLump = function() {
  177. Game.clickLump(); //could reload if golden lump and below 6 harvested (much work, little payback)
  178. AutoPlay.useLump();
  179. }
  180.  
  181. AutoPlay.useLump = function() { // recursive call just needed if we have many sugar lumps
  182. for(i in AutoPlay.level1Order) { var me = Game.ObjectsById[AutoPlay.level1Order[i]]; if(!me.level && Game.lumps) { me.levelUp(); AutoPlay.useLump(); return; } };
  183. for(i in AutoPlay.level10Order) { var me = Game.ObjectsById[AutoPlay.level10Order[i]]; if(me.level<10) { if(me.level<Game.lumps) { me.levelUp(); AutoPlay.useLump(); } return; } };
  184. for(i = Game.ObjectsById.length-1; i >= 0; i--) { var me = Game.ObjectsById[i]; if(me.level<10 && me.level<Game.lumps) { me.levelUp(); AutoPlay.useLump(); return; } };
  185. for(i = Game.ObjectsById.length-1; i >= 0; i--) Game.ObjectsById[i].levelUp();
  186. }
  187.  
  188. AutoPlay.copyWindows=[]; // need to init in the code some place
  189. AutoPlay.masterSaveCopy=0;
  190. AutoPlay.masterLoadCopy=0;
  191. AutoPlay.copyCount=100;
  192.  
  193. // golden sugar lumps = 1 in 2000 (ordinary) -> about 5 years
  194. AutoPlay.farmGoldenSugarLumps = function(age) { // //this is tested and it works (some kind of cheating) - do this only in endgame
  195. if(Game.Achievements["All-natural cane sugar"].won) return;
  196. if(AutoPlay.nextAchievement!=Game.Achievements["All-natural cane sugar"].id) return;
  197. if (AutoPlay.masterSaveCopy) { AutoPlay.debugInfo("back to save master"); Game.LoadSave(AutoPlay.masterSaveCopy); AutoPlay.masterSaveCopy=0; return; }
  198. if (age<Game.lumpRipeAge && age>=Game.lumpMatureAge) {
  199. if (AutoPlay.copyWindows.length>=AutoPlay.copyCount) { AutoPlay.debugInfo("creating master load copy"); AutoPlay.masterLoadCopy=Game.WriteSave(1); } // check rather !masterCopy
  200. if (AutoPlay.copyWindows.length) {
  201. Game.LoadSave(AutoPlay.copyWindows.pop());
  202. if (Game.lumpCurrentType) AutoPlay.debugInfo("found lump with type " + Game.lumpCurrentType);
  203. if (Game.lumpCurrentType==2) {
  204. AutoPlay.info("YESS, golden lump");
  205. AutoPlay.masterLoadCopy=0; AutoPlay.copyWindows=[];
  206. } } else if (AutoPlay.masterLoadCopy) { AutoPlay.debugInfo("going back to master copy"); Game.LoadSave(AutoPlay.masterLoadCopy); AutoPlay.masterLoadCopy=0; }
  207. }
  208. if (age>=Game.lumpRipeAge && AutoPlay.copyWindows.length<AutoPlay.copyCount) {
  209. if(!AutoPlay.copyWindows.length) AutoPlay.info("farming golden sugar lumps.");
  210. AutoPlay.masterSaveCopy=Game.WriteSave(1);
  211. Game.clickLump();
  212. AutoPlay.copyWindows.push(Game.WriteSave(1));
  213. }
  214. }
  215.  
  216. AutoPlay.handleMinigames = function() {
  217. // wizard towers: grimoires
  218. if (Game.isMinigameReady(Game.Objects["Wizard tower"])) {
  219. var me=Game.Objects["Wizard tower"];
  220. var g=me.minigame;
  221. var sp=g.spells["hand of fate"]; // try to get a sugar lump in backfiring
  222. if(Game.shimmerTypes['golden'].n && g.magic>=g.getSpellCost(sp) && (g.magic/g.magicM >= 0.95)) { g.castSpell(sp); }
  223. if (Game.shimmerTypes['golden'].n == 2 && !Game.Achievements["Four-leaf cookie"].won && Game.lumps>0 && g.magic>=g.getSpellCost(sp)) { g.castSpell(sp); }
  224. if (Game.shimmerTypes['golden'].n == 3 && !Game.Achievements["Four-leaf cookie"].won) { g.lumpRefill.click(); g.castSpell(sp); }
  225. }
  226. // temples: pantheon
  227. if (Game.isMinigameReady(Game.Objects["Temple"])) {
  228. var age=Date.now()-Game.lumpT;
  229. if(Game.lumpRipeAge-age < 61*60*1000 && !AutoPlay.cheatLumps) AutoPlay.assignSpirit(0,"order",0);
  230. else if (AutoPlay.preNightMode() && Game.lumpOverripeAge-age < 9*60*60*1000 && (new Date).getMinutes()==59 && !AutoPlay.cheatLumps) AutoPlay.assignSpirit(0,"order",0);
  231. else AutoPlay.assignSpirit(0,"mother",0);
  232. AutoPlay.assignSpirit(1,"decadence",0);
  233. AutoPlay.assignSpirit(2,"labor",0);
  234. }
  235. }
  236.  
  237. AutoPlay.assignSpirit = function(slot, god, force) {
  238. var g=Game.Objects["Temple"].minigame;
  239. if(g.swaps+force<3) return;
  240. if(g.slot[slot]==g.gods[god].id) return;
  241. g.slotHovered=slot; g.dragging=g.gods[god]; g.dropGod();
  242. }
  243.  
  244. AutoPlay.removeSpirit = function(slot, god) {
  245. var g=Game.Objects["Temple"].minigame;
  246. if(g.slot[slot]!=g.gods[god].id) return;
  247. g.slotHovered=-1; g.dragging=g.gods[god]; g.dropGod();
  248. }
  249.  
  250. //===================== Handle Wrinklers ==========================
  251. AutoPlay.handleWrinklers = function() {
  252. var doPop = (((Game.season == "easter") || (Game.season == "halloween")) && !AutoPlay.seasonFinished(Game.season));
  253. doPop = doPop || (Game.Upgrades["Unholy bait"].bought && !Game.Achievements["Moistburster"].won);
  254. doPop = doPop || (AutoPlay.endPhase() && !Game.Achievements["Last Chance to See"].won);
  255. if (doPop) Game.wrinklers.forEach(function(w) { if (w.close==1) w.hp = 0; } );
  256. }
  257.  
  258. //===================== Handle Small Achievements ==========================
  259. AutoPlay.backupHeight=0;
  260. AutoPlay.handleSmallAchievements = function() {
  261. if(!Game.Achievements["Tabloid addiction"].won) { for (i = 0; i < 50; i++) { Game.tickerL.click(); } }
  262. if(!Game.Achievements["Here you go"].won) Game.Achievements["Here you go"].click();
  263. if(!Game.Achievements["Tiny cookie"].won) Game.ClickTinyCookie();
  264. if(!Game.Achievements["God complex"].won) { Game.bakeryName = "Orteil"; Game.bakeryNamePrompt(); Game.ConfirmPrompt(); }
  265. if(!Game.Achievements["What's in a name"].won || Game.bakeryName.slice(0,AutoPlay.robotName.length)!=AutoPlay.robotName) {
  266. Game.bakeryName = AutoPlay.robotName+Game.bakeryName; Game.bakeryNamePrompt(); Game.ConfirmPrompt();
  267. }
  268. if(AutoPlay.endPhase() && !Game.Achievements["Cheated cookies taste awful"].won) Game.Win("Cheated cookies taste awful"); // only take this at the end, after all is done
  269. if(!Game.Achievements["Third-party"].won) Game.Win("Third-party"); // cookie bot is a third party itself
  270. if(!Game.Achievements["Cookie-dunker"].won && Game.milkProgress > 1 && Game.milkHd>0.34) {
  271. if(AutoPlay.backupHeight) { Game.LeftBackground.canvas.height=AutoPlay.backupHeight; AutoPlay.backupHeight=0; }
  272. else { AutoPlay.backupHeight=Game.LeftBackground.canvas.height; Game.LeftBackground.canvas.height=400; setTimeout(AutoPlay.unDunk, 20*1000); }
  273. }
  274. }
  275.  
  276. AutoPlay.unDunk = function() {
  277. if(!Game.Achievements["Cookie-dunker"].won) { setTimeout(AutoPlay.unDunk, 20*1000); return; }
  278. Game.LeftBackground.canvas.height=AutoPlay.backupHeight; AutoPlay.backupHeight=0;
  279. }
  280.  
  281. //===================== Handle Ascend ==========================
  282. AutoPlay.ascendLimit = 0.9*Math.floor(2*(1-Game.ascendMeterPercent));
  283.  
  284. AutoPlay.handleAscend = function() {
  285. if (Game.OnAscend) { AutoPlay.doReincarnate(); AutoPlay.findNextAchievement(); return; }
  286. if (Game.ascensionMode==1 && !AutoPlay.canContinue()) AutoPlay.doAscend("reborn mode did not work, retry.",0);
  287. if (AutoPlay.preNightMode()) return; //do not ascend right before the night
  288. var ascendDays=10;
  289. if (AutoPlay.endPhase() && !Game.Achievements["Endless cycle"].won && Game.Upgrades["Sucralosia Inutilis"].bought) { // this costs 2 minutes per 2 ascend
  290. if ((Game.ascendMeterLevel > 0) && ((AutoPlay.ascendLimit < Game.ascendMeterLevel*Game.ascendMeterPercent) || ((Game.prestige+Game.ascendMeterLevel)%1000==777)))
  291. { AutoPlay.doAscend("go for 1000 ascends",0); }
  292. }
  293. if (Game.Upgrades["Permanent upgrade slot V"].bought && !Game.Achievements["Reincarnation"].won) { // this costs 3+2 minute per 2 ascend
  294. if ((Game.ascendMeterLevel > 0) && ((AutoPlay.ascendLimit < Game.ascendMeterLevel*Game.ascendMeterPercent) ))
  295. { AutoPlay.doAscend("go for 100 ascends",0); }
  296. }
  297. if (AutoPlay.endPhase() && (Date.now()-Game.startDate) > ascendDays*24*60*60*1000) {
  298. AutoPlay.doAscend("ascend after " + ascendDays + " days just while waiting for next achievement.",1);
  299. }
  300. var newPrestige=(Game.prestige+Game.ascendMeterLevel)%1000000;
  301. if (AutoPlay.endPhase() && !Game.Upgrades["Lucky digit"].bought && Game.ascendMeterLevel>0 && ((Game.prestige+Game.ascendMeterLevel)%10 == 7)) { AutoPlay.doAscend("ascend for lucky digit.",0); }
  302. if (AutoPlay.endPhase() && !Game.Upgrades["Lucky number"].bought && Game.ascendMeterLevel>0 && ((Game.prestige+Game.ascendMeterLevel)%1000 == 777)) { AutoPlay.doAscend("ascend for lucky number.",0); }
  303. if (!Game.Upgrades["Lucky payout"].bought && Game.ascendMeterLevel>0 && AutoPlay.endPhase() && (Game.heavenlyChips > 77777777) && (newPrestige <= 777777) && (newPrestige >= 777777-Game.ascendMeterLevel)) {
  304. AutoPlay.doAscend("ascend for lucky payout.",0);
  305. }
  306. if (Game.AchievementsById[AutoPlay.nextAchievement].won) {
  307. var date=new Date();
  308. date.setTime(Date.now()-Game.startDate);
  309. var legacyTime=Game.sayTime(date.getTime()/1000*Game.fps,-1);
  310. date.setTime(Date.now()-Game.fullDate);
  311. var fullTime=Game.sayTime(date.getTime()/1000*Game.fps,-1);
  312. AutoPlay.doAscend("have achievement: " + Game.AchievementsById[AutoPlay.nextAchievement].desc + " after " + legacyTime + "(total: " + fullTime + ")",1);
  313. } }
  314.  
  315. AutoPlay.canContinue = function() {
  316. if (!Game.Achievements["Neverclick"].won && Game.cookieClicks<=15) return true;
  317. if (!Game.Achievements["True Neverclick"].won && Game.cookieClicks==0) return true;
  318. if (!Game.Achievements["Hardcore"].won && Game.UpgradesOwned==0) return true;
  319. if (!Game.Achievements["Speed baking I"].won && (Date.now()-Game.startDate <= 1000*60*35)) return true;
  320. if (!Game.Achievements["Speed baking II"].won && (Date.now()-Game.startDate <= 1000*60*25)) return true;
  321. if (!Game.Achievements["Speed baking III"].won && (Date.now()-Game.startDate <= 1000*60*15)) return true;
  322. return false;
  323. }
  324.  
  325. AutoPlay.doReincarnate = function() {
  326. AutoPlay.delay=10; AutoPlay.buyHeavenlyUpgrades();
  327. if(!Game.Achievements["Neverclick"].won || !Game.Achievements["Hardcore"].won) { Game.PickAscensionMode(); Game.nextAscensionMode=1; Game.ConfirmPrompt(); }
  328. if(AutoPlay.endPhase() && AutoPlay.mustRebornAscend()) { Game.PickAscensionMode(); Game.nextAscensionMode=1; Game.ConfirmPrompt(); }
  329. Game.Reincarnate(true);
  330. if (AutoPlay.loggingInfo) setTimeout(AutoPlay.logging, 20*1000);
  331. AutoPlay.ascendLimit = 0.9*Math.floor(2*(1-Game.ascendMeterPercent));
  332. }
  333.  
  334. AutoPlay.mustRebornAscend = function() { return !([78,93,94,95].every(function(a) { return Game.AchievementsById[a].won; })); }
  335.  
  336. AutoPlay.doAscend = function(str,log) {
  337. AutoPlay.debugInfo(str);
  338. AutoPlay.loggingInfo=log?str:0;
  339. if(AutoPlay.checkAllAchievementsOK(false)) { AutoPlay.logging(); return; } // do not ascend when we are finished
  340. if(Game.wrinklers.some(function(w) { return w.close; } )) AutoPlay.assignSpirit(0,"scorn",1);
  341. Game.wrinklers.forEach(function(w) { if (w.close==1) w.hp=0; } ); // pop all wrinklers
  342. if (Game.Upgrades["Chocolate egg"].unlocked && !Game.Upgrades["Chocolate egg"].bought) {
  343. if (Game.dragonLevel>=9) { // setting first aura to earth shatterer
  344. Game.specialTab="dragon"; Game.SetDragonAura(5,0);
  345. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  346. }
  347. Game.ObjectsById.forEach(function(e) { e.sell(e.amount); } );
  348. Game.Upgrades["Chocolate egg"].buy();
  349. } else { AutoPlay.delay=10; Game.Ascend(true); }
  350. }
  351.  
  352. //===================== Handle Achievements ==========================
  353. AutoPlay.wantedAchievements = [82, 12, 89, 130, 108, 223, 224, 225, 226, 227, 228, 229, 230, 279, 280, 332];
  354. AutoPlay.nextAchievement=AutoPlay.wantedAchievements[0];
  355.  
  356. AutoPlay.endPhase = function() { return AutoPlay.wantedAchievements.indexOf(AutoPlay.nextAchievement)<0; }
  357.  
  358. AutoPlay.findNextAchievement = function() {
  359. AutoPlay.handleSmallAchievements();
  360. for(i = 0; i < AutoPlay.wantedAchievements.length; i++) {
  361. if (!(Game.AchievementsById[AutoPlay.wantedAchievements[i]].won))
  362. { AutoPlay.nextAchievement = AutoPlay.wantedAchievements[i]; AutoPlay.debugInfo("trying to get achievement: " + Game.AchievementsById[AutoPlay.nextAchievement].desc); return; }
  363. }
  364. AutoPlay.checkAllAchievementsOK(true);
  365. }
  366.  
  367. AutoPlay.checkAllAchievementsOK = function(log) {
  368. for (var i in Game.Achievements) {
  369. var me=Game.Achievements[i];
  370. if (!me.won && me.pool!="dungeon") { // missing achievement
  371. if(log) AutoPlay.info("Missing achievement #" + me.id + ": " + me.desc + ", try to get it now.");
  372. if(log) AutoPlay.nextAchievement=me.id;
  373. return false;
  374. } }
  375. for (var i in Game.Upgrades) {
  376. var me=Game.Upgrades[i];
  377. if (me.pool=='prestige' && !me.bought) { // we have not all prestige upgrades yet
  378. AutoPlay.nextAchievement=AutoPlay.wantedAchievements[AutoPlay.wantedAchievements.length-1];
  379. if(log) AutoPlay.info("Prestige upgrade " + me.name + " is missing, waiting to buy it.");
  380. if(log) Game.RemoveAchiev(Game.AchievementsById[AutoPlay.nextAchievement].name);
  381. return false;
  382. } }
  383. clearInterval(AutoPlay.autoPlayer); //stop autoplay:
  384. AutoPlay.info("My job is done here, have a nice day.");
  385. if(Game.bakeryName.slice(0,AutoPlay.robotName.length)==AutoPlay.robotName) {
  386. Game.bakeryName = Game.bakeryName.slice(AutoPlay.robotName.length); Game.bakeryNamePrompt(); Game.ConfirmPrompt();
  387. }
  388. return true;
  389. }
  390.  
  391. AutoPlay.findMissingAchievements = function() { // just for testing purposes
  392. for (var i in Game.Achievements) {
  393. var me=Game.Achievements[i];
  394. if (!me.won && me.pool!="dungeon") { // missing achievement
  395. AutoPlay.debugInfo("missing achievement #" + me.id + ": " + me.desc);
  396. } }
  397. for (var i in Game.Upgrades) {
  398. var me=Game.Upgrades[i];
  399. if (me.pool=='prestige' && !me.bought) { // we have not all prestige upgrades yet
  400. AutoPlay.debugInfo("prestige upgrade " + me.name + " is missing.");
  401. } } }
  402.  
  403. //===================== Handle Heavenly Upgrades ==========================
  404. AutoPlay.prioUpgrades = [363,323,411,412,413,264,265,266,267,268,181,282,283,284,291,393,394]; // legacy, dragon, lucky upgrades, permanent slots, season switcher, better golden cookies, kittens, synergies,
  405. AutoPlay.kittens = [31,32,54,108,187,320,321,322,425,442];
  406. AutoPlay.cursors = [0,1,2,3,4,5,6,43,82,109,188,189];
  407. AutoPlay.chancemakers = [416,417,418,419,420,421,422,423,441];
  408. AutoPlay.butterBiscuits = [334,335,336,337,400];
  409.  
  410. AutoPlay.buyHeavenlyUpgrades = function() {
  411. AutoPlay.prioUpgrades.forEach(function(id) { var e=Game.UpgradesById[id]; if (e.canBePurchased && !e.bought && e.buy(true)) { AutoPlay.info("buying "+e.name); } });
  412. Game.UpgradesById.forEach(function(e) { if (e.canBePurchased && !e.bought && e.buy(true)) { AutoPlay.info("buying "+e.name); } });
  413. AutoPlay.assignPermanentSlot(1,AutoPlay.kittens);
  414. AutoPlay.assignPermanentSlot(2,AutoPlay.chancemakers);
  415. if(!Game.Achievements["Reincarnation"].won) { // for many ascends
  416. AutoPlay.assignPermanentSlot(0,AutoPlay.cursors);
  417. AutoPlay.assignPermanentSlot(3,[52]); // lucky day
  418. AutoPlay.assignPermanentSlot(4,[53]); // serendipity
  419. } else { //collect rare things
  420. AutoPlay.assignPermanentSlot(0,AutoPlay.butterBiscuits);
  421. AutoPlay.assignPermanentSlot(3,[226]); // omelette
  422. if(Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won)
  423. AutoPlay.assignPermanentSlot(4,[72]); // arcane sugar
  424. else AutoPlay.assignPermanentSlot(4,[53]); // serendipity
  425. }
  426. }
  427.  
  428. AutoPlay.assignPermanentSlot = function(slot,options) {
  429. if (!Game.UpgradesById[264+slot].bought) return;
  430. Game.AssignPermanentSlot(slot);
  431. for (var i=options.length-1; i>=0; i--) { if(Game.UpgradesById[options[i]].bought) { Game.PutUpgradeInPermanentSlot(options[i],slot); break; } }
  432. Game.ConfirmPrompt();
  433. }
  434.  
  435. //===================== Handle Dragon ==========================
  436. AutoPlay.handleDragon = function() {
  437. if (Game.Upgrades["A crumbly egg"].unlocked) {
  438. if (Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost()) {
  439. Game.specialTab="dragon"; Game.UpgradeDragon(); Game.ToggleSpecialMenu(0);
  440. } }
  441. if ((Game.dragonAura==0) && (Game.dragonLevel>=5)) { // set first aura to kitten (breath of milk)
  442. Game.specialTab="dragon"; Game.SetDragonAura(1,0);
  443. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  444. }
  445. if ((Game.dragonAura==1) && (Game.dragonLevel>=19)) { // set first aura to prism (radiant appetite)
  446. Game.specialTab="dragon"; Game.SetDragonAura(15,0);
  447. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  448. }
  449. if ((Game.dragonAura2==0) && (Game.dragonLevel>=Game.dragonLevels.length-1)) { // set second aura to kitten (breath of milk)
  450. Game.specialTab="dragon"; Game.SetDragonAura(1,1);
  451. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  452. } }
  453.  
  454. //===================== Auxiliary ==========================
  455.  
  456. AutoPlay.info = function(s) { console.log("### "+s); Game.Notify("Automatic Playthrough",s,1,100); }
  457. AutoPlay.debugInfo = function(s) { console.log("======> "+s); Game.Notify("Debugging CookieBot",s,1,20); }
  458.  
  459. AutoPlay.logging = function() {
  460. var before=window.localStorage.getItem("autoplayLog");
  461. var toAdd="#logging autoplay V" + AutoPlay.version + " with " + AutoPlay.loggingInfo + "\n" + Game.WriteSave(1) + "\n";
  462. AutoPlay.loggingInfo=0;
  463. window.localStorage.setItem("autoplayLog",before+toAdd);
  464. }
  465.  
  466. AutoPlay.saveLog = function() { // for testing and getting the log out
  467. var text=window.localStorage.getItem("autoplayLog");
  468. var blob=new Blob([text],{type:'text/plain;charset=utf-8'});
  469. saveAs(blob,'autoPlaySave.txt');
  470. }
  471.  
  472. AutoPlay.handleNotes = function() {
  473. for (var i in Game.Notes) {
  474. if (Game.Notes[i].quick==0) { Game.Notes[i].life=2000*Game.fps; Game.Notes[i].quick=1; }
  475. } }
  476.  
  477. function range(start, end) {
  478. var foo = [];
  479. for (var i = start; i <= end; i++) { foo.push(i); }
  480. return foo;
  481. }
  482.  
  483. //===================== Cheats for Testing ==========================
  484. //create golden cookie: Game.shimmerTypes.golden.time = Game.shimmerTypes.golden.maxTime; or new Game.shimmer("golden")
  485. //golden cookie with building special: var newShimmer=new Game.shimmer("golden");newShimmer.force="building special";
  486.  
  487. //===================== Init & Start ==========================
  488.  
  489. if (AutoPlay.autoPlayer) { AutoPlay.info("replacing old version of autoplay"); clearInterval(AutoPlay.autoPlayer); }
  490. if (Game.version == AutoPlay.gameVersion) {
  491. AutoPlay.autoPlayer = setInterval(AutoPlay.run, 300); // was 100 before, but that is too quick
  492. AutoPlay.findNextAchievement();
  493. l('versionNumber').innerHTML='v. '+Game.version+" (with autoplay v."+AutoPlay.version+")";
  494. } else info("cookieBot works only with cookie clicker version " + gameVersion);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement