Advertisement
Guest User

testbot

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