Advertisement
mwtvz

Untitled

May 23rd, 2018
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.28 KB | None | 0 0
  1. //cookie bot: auto-play-through cookie clicker
  2.  
  3. var AutoPlay;
  4.  
  5. if(!AutoPlay) AutoPlay = {};
  6. AutoPlay.version = "2.01"
  7. AutoPlay.gameVersion = "2.0106";
  8. AutoPlay.robotName="Automated ";
  9. AutoPlay.delay=0;
  10. AutoPlay.night=false;
  11. AutoPlay.finished=false;
  12.  
  13. AutoPlay.run = function () {
  14. AutoPlay.activities = AutoPlay.mainActivity;
  15. if (Game.AscendTimer>0 || Game.ReincarnateTimer>0) return;
  16. if (AutoPlay.delay>0) { AutoPlay.delay--; return; }
  17. if (AutoPlay.nightMode()) { var age=Date.now()-Game.lumpT; AutoPlay.cheatSugarLumps(age); return; }
  18. AutoPlay.handleClicking();
  19. AutoPlay.handleGoldenCookies();
  20. AutoPlay.handleBuildings();
  21. AutoPlay.handleUpgrades();
  22. AutoPlay.handleSeasons();
  23. AutoPlay.handleSugarLumps();
  24. AutoPlay.handleDragon();
  25. AutoPlay.handleWrinklers();
  26. AutoPlay.handleAscend();
  27. AutoPlay.handleNotes();
  28. }
  29.  
  30. //===================== Night Mode ==========================
  31. AutoPlay.preNightMode = function() { var h=(new Date).getHours(); return(h>=25); }
  32.  
  33. AutoPlay.nightMode = function() {
  34. var h=(new Date).getHours();
  35. if(h>=0 && h<25) { // be active
  36. AutoPlay.addActivity('Daytime! The bot is working.');
  37. if (AutoPlay.night) AutoPlay.useLump();
  38. AutoPlay.night=false;
  39. var gs=Game.Upgrades["Golden switch [on]"]; if(gs.unlocked) {
  40. if (Game.isMinigameReady(Game.Objects["Temple"])) {
  41. AutoPlay.removeSpirit(1,"asceticism");
  42. // AutoPlay.assignSpirit(1,"decadence",0);
  43. // AutoPlay.assignSpirit(2,"labor",0);
  44. }
  45. gs.buy();
  46. }
  47. AutoPlay.nightAtGarden(false);
  48. return false;
  49. }
  50. if (AutoPlay.night) { AutoPlay.addActivity('The bot is sleeping.'); return true; } //really sleep now
  51. AutoPlay.addActivity('Preparing for the night.');
  52. var gs=Game.Upgrades["Golden switch [off]"]; if(gs.unlocked) {
  53. AutoPlay.handleGoldenCookies();
  54. var buffCount=0;
  55. for (var i in Game.buffs) { if(Game.buffs[i].time>=0) buffCount++; }
  56. if((buffCount==1 && Game.hasBuff("Clot")) || h<7) gs.buy();
  57. if(!gs.bought) return true; // do not activate spirits before golden switch
  58. if (Game.isMinigameReady(Game.Objects["Temple"])) {
  59. // AutoPlay.assignSpirit(0,"mother",1);
  60. AutoPlay.removeSpirit(1,"decadence");
  61. AutoPlay.removeSpirit(2,"labor");
  62. AutoPlay.assignSpirit(1,"asceticism",1);
  63. AutoPlay.assignSpirit(2,"industry",1);
  64. }
  65. }
  66. AutoPlay.nightAtGarden(true);
  67. AutoPlay.night=true;
  68. return true;
  69. }
  70.  
  71. //===================== Handle Cookies and Golden Cookies ==========================
  72. AutoPlay.handleGoldenCookies = function() { // pop the first golden cookie or reindeer
  73. if(Game.shimmerTypes['golden'].n>=4 && !Game.Achievements['Four-leaf cookie'].won) return;
  74. for(sx in Game.shimmers) {
  75. var s=Game.shimmers[sx];
  76. if((s.type!="golden") || (s.life<Game.fps) || (!Game.Achievements["Early bird"].won)) { s.pop(); return; }
  77. if((s.life/Game.fps)<(s.dur-2) && (Game.Achievements["Fading luck"].won)) { s.pop(); return; }
  78. } }
  79.  
  80. AutoPlay.handleClicking = function() {
  81. if (!Game.Achievements["Neverclick"].won && (Game.cookieClicks<=15) ) { AutoPlay.addActivity('Waiting for neverclick.'); return; }
  82. if (Game.ascensionMode==1 && AutoPlay.endPhase() && !Game.Achievements["True Neverclick"].won && (!Game.cookieClicks) ) { AutoPlay.addActivity('Waiting for true neverclick.'); return; }
  83. if(!Game.Achievements["Uncanny clicker"].won) { for(i=1; i<6; i++) setTimeout(Game.ClickCookie, 50*i); }
  84. if (Game.ascensionMode==1 && Game.Achievements["Hardcore"].won) setTimeout(Game.ClickCookie, 150);
  85. Game.ClickCookie();
  86. }
  87.  
  88. //===================== Handle Upgrades ==========================
  89. AutoPlay.handleUpgrades = function() {
  90. if (!Game.Achievements["Hardcore"].won && Game.UpgradesOwned==0) return;
  91. Game.UpgradesById.forEach(function(e) { if (e.unlocked && !e.bought && e.canBuy() && !AutoPlay.avoidbuy(e)) { e.buy(true); } });
  92. }
  93.  
  94. AutoPlay.avoidbuy = function(up) { //normally we do not buy 227, 71, 73, rolling pins
  95. switch(up.id) {
  96. case 71: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won &&
  97. (!Game.Achievements["Reincarnation"].won || Game.Upgrades["Arcane sugar"].bought); // brainsweep
  98. case 73: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won; // elder pact
  99. case 74: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Upgrades["Elder Covenant"].unlocked; // elder pledge
  100. case 84: return Game.Upgrades["Elder Pledge"].bought; // elder covenant
  101. // case 85: return Game.Upgrades["Elder Covenant"].bought; // revoke elder covenant
  102. case 227: return true; // choco egg
  103. default: return up.pool=="toggle";
  104. } }
  105.  
  106. //===================== Handle Buildings ==========================
  107. AutoPlay.handleBuildings = function() {
  108. var buyAmount=100, checkAmount=1;
  109. if ((Date.now()-Game.startDate) > 10*60*1000) buyAmount=1; // buy single after 10 minutes
  110. if (Game.resets && Game.ascensionMode!=1 && Game.isMinigameReady(Game.Objects["Temple"]) && Game.Objects["Temple"].minigame.slot[0]==10 // Rigidel is in slot 0
  111. && Game.BuildingsOwned%10==0 && (Date.now()-Game.startDate) > 2*60*1000) // do not use factor 10 in the first 2 minutes after descend
  112. buyAmount=checkAmount=10;
  113. var cpc=0; // relative strength of cookie production
  114. 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; } };
  115. for(i = Game.ObjectsById.length-1; i >= 0; i--) {
  116. var me = Game.ObjectsById[i];
  117. if ((me.storedCps/me.price > cpc/2 || me.amount % 50 >= 40) && (me.getSumPrice(checkAmount)<Game.cookies)) { me.buy(buyAmount); return; }
  118. }
  119. 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
  120. var minIdx=0, minPrice=Game.ObjectsById[minIdx].price;
  121. for(var i = Game.ObjectsById.length-1; i >= 0; i--){ if (Game.ObjectsById[i].price < minPrice) { minPrice=Game.ObjectsById[i].price; minIdx=i; } };
  122. Game.ObjectsById[minIdx].buy();
  123. } }
  124.  
  125. //===================== Handle Seasons ==========================
  126. AutoPlay.handleSeasons = function() {
  127. if (!Game.Upgrades["Season switcher"].bought || Game.ascensionMode==1) return;
  128. if (AutoPlay.seasonFinished(Game.season)) {
  129. switch (Game.season) {
  130. case "christmas": Game.Upgrades["Bunny biscuit"].buy(); break; // go to easter
  131. case "easter": Game.Upgrades["Lovesick biscuit"].buy(); break; // go to valentine
  132. case "valentines": Game.Upgrades["Ghostly biscuit"].buy(); break; // go to halloween
  133. default: Game.Upgrades["Festive biscuit"].buy(); break; // go to christmas
  134. } } else AutoPlay.addActivity('Waiting for all results in '+Game.season+'.');
  135. if (Game.Upgrades["A festive hat"].bought && ! Game.Upgrades["Santa's dominion"].unlocked) { // develop santa
  136. Game.specialTab="santa"; Game.UpgradeSanta(); Game.ToggleSpecialMenu(0);
  137. } }
  138.  
  139. AutoPlay.valentineUpgrades = range(169,174);
  140. AutoPlay.christmasUpgrades = [168].concat(range(152,166)).concat(range(143,149));
  141. AutoPlay.easterUpgrades = range(210,229);
  142. AutoPlay.halloweenUpgrades = range(134,140);
  143. AutoPlay.allSeasonUpgrades = AutoPlay.valentineUpgrades.concat(AutoPlay.christmasUpgrades).concat(AutoPlay.easterUpgrades).concat(AutoPlay.halloweenUpgrades);
  144.  
  145. AutoPlay.allUnlocked = function(l) { return l.every(function (u) { return Game.UpgradesById[u].unlocked; }); }
  146.  
  147. AutoPlay.seasonFinished = function(s) {
  148. if (s == '') return true;
  149. switch (s) {
  150. case "valentines": return AutoPlay.allUnlocked(AutoPlay.valentineUpgrades);
  151. case "christmas": if (AutoPlay.allUnlocked(AutoPlay.allSeasonUpgrades)) return false; else return AutoPlay.allUnlocked(AutoPlay.christmasUpgrades);
  152. case "easter": return (Game.Achievements["Hide & seek champion"].won && (AutoPlay.allUnlocked(AutoPlay.easterUpgrades)));
  153. case "halloween": return AutoPlay.allUnlocked(AutoPlay.halloweenUpgrades);
  154. default: return true;
  155. } }
  156.  
  157. //===================== Handle Sugarlumps ==========================
  158. AutoPlay.level1Order=[2,6,7]; // unlocking in this order for the minigames
  159. AutoPlay.level10Order=[2,7]; // finishing in this order
  160. AutoPlay.minLumps=AutoPlay.level1Order.length+55*AutoPlay.level10Order.length;
  161. AutoPlay.levelAchievements=range(307,320).concat([336]);
  162. AutoPlay.lumpRelatedAchievements=range(266,272).concat(AutoPlay.levelAchievements);
  163.  
  164. AutoPlay.handleSugarLumps = function() {
  165. if (!Game.canLumps()) return; //do not work with sugar lumps before enabled
  166. var age=Date.now()-Game.lumpT;
  167. if (age>=Game.lumpMatureAge && Game.lumpCurrentType==0 && Game.lumpsTotal>AutoPlay.minLumps && !Game.Achievements["Hand-picked"].won) AutoPlay.harvestLump();
  168. // if(Game.lumpCurrentType==0) AutoPlay.farmGoldenSugarLumps(age); // not needed now, because we cheat sugar lumps
  169. if (age>=Game.lumpRipeAge) AutoPlay.harvestLump(); // normal harvesting, should check !masterCopy
  170. AutoPlay.cheatSugarLumps(age);
  171. AutoPlay.useLump();
  172. AutoPlay.handleMinigames();
  173. }
  174.  
  175. AutoPlay.cheatLumps=false;
  176. AutoPlay.cheatSugarLumps = function(age) { // divide lump ripe time by 600, making hours into few minutes
  177. if(AutoPlay.finished) return;
  178. for(a in Game.AchievementsById) { var me=Game.AchievementsById[a]; if (!(me.won || me.pool=="dungeon" || AutoPlay.lumpRelatedAchievements.indexOf(me.id)>=0)) return; }
  179. AutoPlay.cheatLumps=true; // after checking that only lump related achievements are missing
  180. AutoPlay.addActivity('Cheating sugar lumps.');
  181. var cheatReduction=60*10;
  182. var cheatDelay=Game.lumpRipeAge/cheatReduction;
  183. if(age<Game.lumpRipeAge-cheatDelay) Game.lumpT-=cheatDelay*(cheatReduction-1);
  184. if (AutoPlay.nightMode() && age>Game.lumpRipeAge) { Game.lumpT-=60*60*1000; }
  185. }
  186.  
  187. AutoPlay.harvestLump = function() {
  188. Game.clickLump(); //could reload if golden lump and below 6 harvested (much work, little payback)
  189. AutoPlay.useLump();
  190. }
  191.  
  192. AutoPlay.useLump = function() { // recursive call just needed if we have many sugar lumps
  193. if(!Game.lumps) return;
  194. for(i in AutoPlay.level1Order) { var me = Game.ObjectsById[AutoPlay.level1Order[i]]; if(!me.level && Game.lumps) { me.levelUp(); AutoPlay.useLump(); return; } };
  195. 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; } };
  196. 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; } };
  197. // for(i = Game.ObjectsById.length-1; i >= 0; i--) Game.ObjectsById[i].levelUp(); -- do not use sugar lumps for more than level 10
  198. }
  199.  
  200. AutoPlay.copyWindows=[]; // need to init in the code some place
  201. AutoPlay.masterSaveCopy=0;
  202. AutoPlay.masterLoadCopy=0;
  203. AutoPlay.copyCount=100;
  204.  
  205. // golden sugar lumps = 1 in 2000 (ordinary) -> about 5 years
  206. AutoPlay.farmGoldenSugarLumps = function(age) { // this is tested and it works (some kind of cheating) - do this only in endgame
  207. if(Game.Achievements["All-natural cane sugar"].won) return;
  208. if(AutoPlay.nextAchievement!=Game.Achievements["All-natural cane sugar"].id) return;
  209. if (AutoPlay.masterSaveCopy) { AutoPlay.debugInfo("back to save master"); Game.LoadSave(AutoPlay.masterSaveCopy); AutoPlay.masterSaveCopy=0; return; }
  210. if (age<Game.lumpRipeAge && age>=Game.lumpMatureAge) {
  211. if (AutoPlay.copyWindows.length>=AutoPlay.copyCount) { AutoPlay.debugInfo("creating master load copy"); AutoPlay.masterLoadCopy=Game.WriteSave(1); } // check rather !masterCopy
  212. if (AutoPlay.copyWindows.length) {
  213. Game.LoadSave(AutoPlay.copyWindows.pop());
  214. if (Game.lumpCurrentType) AutoPlay.debugInfo("found lump with type " + Game.lumpCurrentType);
  215. if (Game.lumpCurrentType==2) {
  216. AutoPlay.info("YESS, golden lump");
  217. AutoPlay.masterLoadCopy=0; AutoPlay.copyWindows=[];
  218. } } else if (AutoPlay.masterLoadCopy) { AutoPlay.debugInfo("going back to master copy"); Game.LoadSave(AutoPlay.masterLoadCopy); AutoPlay.masterLoadCopy=0; }
  219. }
  220. if (age>=Game.lumpRipeAge && AutoPlay.copyWindows.length<AutoPlay.copyCount) {
  221. if(!AutoPlay.copyWindows.length) AutoPlay.info("farming golden sugar lumps.");
  222. AutoPlay.masterSaveCopy=Game.WriteSave(1);
  223. Game.clickLump();
  224. AutoPlay.copyWindows.push(Game.WriteSave(1));
  225. }
  226. }
  227.  
  228. AutoPlay.handleMinigames = function() {
  229. // wizard towers: grimoires
  230. if (Game.isMinigameReady(Game.Objects["Wizard tower"])) {
  231. var me=Game.Objects["Wizard tower"];
  232. var g=me.minigame;
  233. var sp=g.spells["hand of fate"]; // try to get a sugar lump in backfiring
  234. if(Game.shimmerTypes['golden'].n && g.magic>=g.getSpellCost(sp) && (g.magic/g.magicM >= 0.95)) { g.castSpell(sp); }
  235. if (Game.shimmerTypes['golden'].n == 2 && !Game.Achievements["Four-leaf cookie"].won && Game.lumps>0 && g.magic>=g.getSpellCost(sp)) { g.castSpell(sp); }
  236. if (Game.shimmerTypes['golden'].n == 3 && !Game.Achievements["Four-leaf cookie"].won) { g.lumpRefill.click(); g.castSpell(sp); }
  237. }
  238. // temples: pantheon
  239. if (Game.isMinigameReady(Game.Objects["Temple"])) {
  240. var age=Date.now()-Game.lumpT;
  241. if(Game.lumpRipeAge-age < 61*60*1000 && !AutoPlay.cheatLumps) AutoPlay.assignSpirit(0,"order",0);
  242. else if (AutoPlay.preNightMode() && Game.lumpOverripeAge-age < 9*60*60*1000 && (new Date).getMinutes()==59 && !AutoPlay.cheatLumps) AutoPlay.assignSpirit(0,"order",0);
  243. else AutoPlay.assignSpirit(0,"mother",0);
  244. AutoPlay.assignSpirit(1,"decadence",0);
  245. AutoPlay.assignSpirit(2,"labor",0);
  246. }
  247. // farms: garden
  248. if (Game.isMinigameReady(Game.Objects["Farm"])) {
  249. var g=Game.Objects["Farm"].minigame;
  250. AutoPlay.planting(g);
  251. AutoPlay.harvesting(g);
  252. if(Game.Objects["Farm"].level>8 && !AutoPlay.plantCookies) { // have all plants and all cookies
  253. if(/*!Game.Achievements["Seedless to nay"].won &&*/ !AutoPlay.finished)
  254. g.harvestAll(); g.askConvert(); Game.ConfirmPrompt(); //convert garden in order to get more sugar lumps
  255. }
  256. }
  257. }
  258.  
  259. AutoPlay.nightAtGarden = function(on) {
  260. if(!Game.isMinigameReady(Game.Objects["Farm"])) return;
  261. if(on!=Game.Objects["Farm"].minigame.freeze) FireEvent(l('gardenTool-2'),'click'); // (un)freeze garden
  262. }
  263.  
  264. AutoPlay.plantDependencies = [
  265. ['dummy','dummy','dummy'], // just to fill index 0
  266. ['queenbeetLump','queenbeet','queenbeet'], // need to know its index
  267. ['everdaisy','elderwort','tidygrass'], // need to know its index
  268. // critical path
  269. ['thumbcorn','bakerWheat','bakerWheat'],
  270. ['cronerice','bakerWheat','thumbcorn'],
  271. ['gildmillet','thumbcorn','cronerice'],
  272. ['clover','bakerWheat','gildmillet'],
  273. ['shimmerlily','gildmillet','clover'],
  274. ['elderwort','cronerice','shimmerlily'],
  275. //level 1
  276. ['chocoroot','bakerWheat','brownMold'],
  277. ['wrinklegill','crumbspore','brownMold'],
  278. ['whiteMildew','brownMold','brownMold'],
  279. ['doughshroom','crumbspore','crumbspore'],
  280. ['bakeberry','bakerWheat','bakerWheat'],
  281. //level 2
  282. ['whiteChocoroot','chocoroot','whiteMildew'],
  283. ['queenbeet','chocoroot','bakeberry'],
  284. //level 3
  285. ['tidygrass','bakerWheat','whiteChocoroot'],
  286. //level 5
  287. ['greenRot','clover','whiteMildew'],
  288. //level 6
  289. ['whiskerbloom','whiteChocoroot','shimmerlily'],
  290. ['keenmoss','brownMold','greenRot'],
  291. //endpoints
  292. ['goldenClover','bakerWheat','gildmillet'],
  293. ['glovemorel','thumbcorn','crumbspore'],
  294. ['wardlichen','cronerice','whiteMildew'],
  295. ['duketater','queenbeet','queenbeet'],
  296. ['chimerose','whiskerbloom','shimmerlily'],
  297. ['nursetulip','whiskerbloom','whiskerbloom'],
  298. ['drowsyfern','chocoroot','keenmoss'],
  299. ['cheapcap','crumbspore','shimmerlily'],
  300. ['foolBolete','greenRot','doughshroom'],
  301. ['shriekbulb','wrinklegill','elderwort'],
  302. ['ichorpuff','crumbspore','elderwort']
  303. ];
  304.  
  305. if(!AutoPlay.plantList) AutoPlay.plantList=[0,0,0,0];
  306. AutoPlay.plantPending=false; // Is there a plant we want and that is not mature yet?
  307.  
  308. AutoPlay.sectorText = function(sector) {
  309. if(Game.Objects["Farm"].level>4) return (sector%2?'right ':'left ')+(sector<2?'bottom':'top');
  310. else if (Game.Objects["Farm"].level==4) return (sector%2?'right ':'left ');
  311. else return 'middle';
  312. }
  313.  
  314. AutoPlay.findPlants = function(game,idx) {
  315. var couldPlant=0;
  316. if(AutoPlay.plantList[idx]!=0) {// already used
  317. var oldPlant=AutoPlay.plantDependencies[AutoPlay.plantList[idx]][0];
  318. AutoPlay.addActivity("trying to get plant " + oldPlant + " on sector " + AutoPlay.sectorText(idx) + '.');
  319. // AutoPlay.info("currently we have " + oldPlant + " and it is unlocked " + game.plants[oldPlant].unlocked);
  320. if(game.plants[oldPlant].unlocked) AutoPlay.plantList[idx]=0; else return true;
  321. }
  322. for(i = 3; i < AutoPlay.plantDependencies.length; i++) {
  323. var plant=AutoPlay.plantDependencies[i][0];
  324. if(!game.plants[plant].unlocked && game.plants[AutoPlay.plantDependencies[i][1]].unlocked && game.plants[AutoPlay.plantDependencies[i][2]].unlocked) { // want to get the plant
  325. if(AutoPlay.plantList.includes(i)) couldPlant=i; // it is already in another slot - remember it
  326. else { AutoPlay.plantList[idx]=i; AutoPlay.info("planting " + plant + " onto " + idx); return true; }
  327. }
  328. }
  329. var chkx=(idx%2)?0:5; var chky=(idx>1)?0:5; // did not find any more normal plants to handle, check expensive methods
  330. if(game.isTileUnlocked(chkx,chky)) { // only plant if the spot is big enough
  331. if(!game.plants["everdaisy"].unlocked) {
  332. if(AutoPlay.plantList.includes(2)) couldPlant=2;
  333. else { AutoPlay.plantList[idx]=2; AutoPlay.info("expensive planting everdaisy onto " + idx); return true; }
  334. }
  335. if(!game.plants["queenbeetLump"].unlocked) {
  336. if(AutoPlay.plantList.includes(1)) couldPlant=1;
  337. else { AutoPlay.plantList[idx]=1; AutoPlay.info("expensive planting queenbeetLump onto " + idx); return true; }
  338. }
  339. }
  340. if(!couldPlant) return false;
  341. // did not find anything else to do, join one of the others
  342. //AutoPlay.plantList[idx]=(idx==0)?couldPlant:AutoPlay.plantList[idx>2?1:0];
  343. AutoPlay.plantList[idx]=couldPlant;
  344. AutoPlay.info("(re)planting " + AutoPlay.plantDependencies[AutoPlay.plantList[idx]][0] + " onto " + idx);
  345. return true;
  346. }
  347.  
  348. AutoPlay.planting = function(game) {
  349. if(!game.plants["meddleweed"].unlocked) { AutoPlay.addActivity("waiting for meddleweed."); AutoPlay.switchSoil(0,'fertilizer'); return; } // wait for meddleweed to appear
  350. if(!game.plants["crumbspore"].unlocked || !game.plants["brownMold"].unlocked) { // use meddleweed to get them
  351. AutoPlay.addActivity("Trying to get crumbspore and brown mold.");
  352. for(var x=0;x<6;x++) for(var y=0;y<6;y++) if(game.isTileUnlocked(x,y)) AutoPlay.plantSeed("meddleweed",x,y);
  353. return;
  354. }
  355. if(!AutoPlay.findPlants(game,0)) { AutoPlay.plantList=[0,0,0,0]; for(var i=0; i<4; i++) AutoPlay.plantSector(i,'','','dummy'); return; }
  356. AutoPlay.switchSoil(0,AutoPlay.plantPending?'fertilizer':'woodchips'); // want many mutations
  357. if(Game.Objects["Farm"].level<4) {
  358. AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],3,2); AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][2],3,3);
  359. if(game.isTileUnlocked(3,4)) AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],3,4);
  360. return;
  361. }
  362. AutoPlay.findPlants(game,1);
  363. if(Game.Objects["Farm"].level==4) { // now we are at level 4
  364. if(AutoPlay.plantList[1]==0) { AutoPlay.info("Warning: Do not know what to plant in sector 2."); return; } // should never happen
  365. AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],4,2);
  366. AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][2],4,3);
  367. AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],4,4);
  368. AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[1]][1],1,2);
  369. AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[1]][2],1,3);
  370. AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[1]][1],1,4);
  371. return;
  372. }
  373. AutoPlay.findPlants(game,2); AutoPlay.findPlants(game,3); // now we have four areas to build
  374. for(var sector=0; sector<4; sector++) {
  375. var dep=AutoPlay.plantDependencies[AutoPlay.plantList[sector]];
  376. AutoPlay.plantSector(sector, dep[1], dep[2], dep[0]);
  377. }
  378. }
  379.  
  380. AutoPlay.plantSector = function(sector,plant1,plant2,plant0) { // The plants will be synchronized due to night mode
  381. var X=(sector%2)?0:3;
  382. var Y=(sector>1)?0:3;
  383. if(plant0=="dummy") {
  384. var thePlant=AutoPlay.seedCalendar(sector);
  385. //AutoPlay.info("plantSector " + sector + " with " + thePlant);
  386. for(var x = X; x < X+3; x++) for(var y = Y; y < Y+3; y++) { AutoPlay.plantSeed(thePlant,x,y); }
  387. return;
  388. }
  389. if(plant0=="queenbeetLump") {
  390. for (var y = Y; y < Y+3; y++) { AutoPlay.plantSeed(plant1,X,y); AutoPlay.plantSeed(plant2,X+2,y); }
  391. AutoPlay.plantSeed(plant1,X+1,Y); AutoPlay.plantSeed(plant2,X+1,Y+2);
  392. return;
  393. }
  394. if(plant0=="everdaisy") {
  395. for (var y = Y; y < Y+3; y++) { AutoPlay.plantSeed(plant1,X,y); AutoPlay.plantSeed(plant2,X+2,y); }
  396. return;
  397. }
  398. AutoPlay.plantSeed(plant1,X+1,Y); AutoPlay.plantSeed(plant2,X+1,Y+1); AutoPlay.plantSeed(plant1,X+1,Y+2);
  399. }
  400.  
  401. AutoPlay.plantCookies = false;
  402.  
  403. AutoPlay.plantSeed = function(seed,whereX,whereY) {
  404. var g=Game.Objects["Farm"].minigame;
  405. if(!g.isTileUnlocked(whereX,whereY)) return; // do not plant onto locked tiles
  406. var oldPlant=(g.getTile(whereX,whereY))[0];
  407. if (oldPlant!=0) { // slot is already planted, try to get rid of it
  408. if(g.plantsById[oldPlant-1].key!=seed) AutoPlay.cleanSeed(g,whereX,whereY);
  409. return;
  410. }
  411. if(!g.canPlant(g.plants[seed])) return;
  412. //AutoPlay.info("planting seed ...");
  413. FireEvent(g.plants[seed].l,"click");
  414. g.clickTile(whereX,whereY);
  415. }
  416.  
  417. AutoPlay.seedCalendar = function(sector) {
  418. var g=Game.Objects["Farm"].minigame;
  419. AutoPlay.plantCookies = true;
  420. if(!Game.Upgrades["Wheat slims"].bought && g.plants["bakerWheat"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); AutoPlay.addActivity("Trying to get Wheat slims."); return "bakerWheat"; }
  421. if(!Game.Upgrades["Elderwort biscuits"].bought && g.plants["elderwort"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); AutoPlay.addActivity("Trying to get Elderwort cookies."); return "elderwort"; }
  422. if(!Game.Upgrades["Bakeberry cookies"].bought && g.plants["bakeberry"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); AutoPlay.addActivity("Trying to get Bakeberry cookies."); return "bakeberry"; }
  423. if(!Game.Upgrades["Fern tea"].bought && g.plants["drowsyfern"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); AutoPlay.addActivity("Trying to get Fern tea."); return "drowsyfern"; }
  424. if(!Game.Upgrades["Duketater cookies"].bought && g.plants["duketater"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); AutoPlay.addActivity("Trying to get Duketater cookies."); return "duketater"; }
  425. if(!Game.Upgrades["Green yeast digestives"].bought && g.plants["greenRot"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); AutoPlay.addActivity("Trying to get Green yeast digestives."); return "greenRot"; }
  426. if(!Game.Upgrades["Ichor syrup"].bought && g.plants["ichorpuff"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); AutoPlay.addActivity("Trying to get Ichor syrup."); return "ichorpuff"; }
  427. AutoPlay.plantCookies = false;
  428. AutoPlay.switchSoil(sector,'clay'); //only when mature, otherwise it should be fertilizer
  429. //use garden to get cps and sugarlumps
  430. return "whiskerbloom"; // approx. 1.5% cps add. - should use with nursetulip in the middle
  431. /* even better: chocoroot has only 1% cps, but also gets 3 mins of cps - harvest on high cps - predictable growth, put on fertilizer first, then on clay, keep them synchronized
  432. plant something meaningful at night
  433. bakeberry also 1%cps and good harvest
  434. */
  435. }
  436.  
  437. AutoPlay.cleaningGarden = function(game) {
  438. if(Game.Objects["Farm"].level<4) {
  439. if(AutoPlay.plantList[0]==0) return;
  440. for(var y=2;y<5;y++) { AutoPlay.cleanSeed(game,2,y); AutoPlay.cleanSeed(game,4,y); }
  441. } else {
  442. for(var sector=0; sector<4; sector++) AutoPlay.cleanSector(game,sector,AutoPlay.plantDependencies[AutoPlay.plantList[sector]][0]);
  443. }
  444. }
  445.  
  446. AutoPlay.cleanSector = function(game,sector,plant0) {
  447. if(plant0=="dummy") return; // do not clean when we are at work
  448. var X=(sector%2)?0:3;
  449. var Y=(sector>1)?0:3;
  450. if(plant0=="queenbeetLump") { AutoPlay.cleanSeed(game,X+1,Y+1); return; }
  451. if(plant0=="everdaisy") {
  452. for (var y = Y; y < Y+3; y++) AutoPlay.cleanSeed(game,X+1,y);
  453. return;
  454. }
  455. if(plant0=="all") {
  456. for(var x=X;x<X+3;x++) for(var y=Y;y<Y+3;y++) { AutoPlay.cleanSeed(game,x,y); }
  457. return;
  458. }
  459. for(var y=Y;y<Y+3;y++) { AutoPlay.cleanSeed(game,X,y); AutoPlay.cleanSeed(game,X+2,y); }
  460. }
  461.  
  462. AutoPlay.cleanSeed = function(g,x,y) {
  463. if(!g.isTileUnlocked(x,y)) return;
  464. var tile=g.getTile(x,y);
  465. if (tile[0] == 0) return;
  466. if ((!g.plantsById[tile[0]-1].unlocked) && (tile[1]<=g.plantsById[tile[0]-1].mature)) return;
  467. g.harvest(x,y);
  468. }
  469.  
  470. AutoPlay.harvesting = function(game) {
  471. AutoPlay.cleaningGarden(game);
  472. AutoPlay.plantPending=false;
  473. for(var x=0;x<6;x++) for(var y=0;y<6;y++) if(game.isTileUnlocked(x,y)) {
  474. var tile=game.getTile(x,y);
  475. if(tile[0]) {
  476. var plant=game.plantsById[tile[0]-1];
  477. if(!plant.unlocked) { AutoPlay.plantPending=true; /*AutoPlay.info(plant.name + " is still growing, do not disturb!");*/ }
  478. if (tile[0] != 0) { // some plant in this slot
  479. if (AutoPlay.plantCookies && tile[1]>=game.plantsById[tile[0]-1].mature) game.harvest(x,y); // is mature and can give cookies
  480. if (plant.ageTick+plant.ageTickR+tile[1] > 100) AutoPlay.harvest(game,x,y); // would die in next round
  481. } } }
  482. }
  483.  
  484. AutoPlay.harvest = function(game,x,y) {
  485. game.harvest(x,y);
  486. var sector = ((x<3)?1:0)+((y<3)?2:0);
  487. var deps=AutoPlay.plantDependencies[AutoPlay.plantList[sector]];
  488. if(deps[1] == deps[2]) AutoPlay.cleanSector(game,sector,"all");
  489. }
  490.  
  491. AutoPlay.switchSoil = function(sector,which) { // 'dirt','fertilizer','clay','pebbles','woodchips'
  492. // cannot buy if (M.freeze || M.soil==me.id || M.nextSoil>Date.now() || M.parent.bought<me.req){return false;}
  493. if(sector) return;
  494. FireEvent(l('gardenSoil-'+Game.Objects["Farm"].minigame.soils[which].id),'click');
  495. }
  496.  
  497. AutoPlay.assignSpirit = function(slot, god, force) {
  498. var g=Game.Objects["Temple"].minigame;
  499. if(g.swaps+force<3) return;
  500. if(g.slot[slot]==g.gods[god].id) return;
  501. g.slotHovered=slot; g.dragging=g.gods[god]; g.dropGod();
  502. }
  503.  
  504. AutoPlay.removeSpirit = function(slot, god) {
  505. var g=Game.Objects["Temple"].minigame;
  506. if(g.slot[slot]!=g.gods[god].id) return;
  507. g.slotHovered=-1; g.dragging=g.gods[god]; g.dropGod();
  508. }
  509.  
  510. //===================== Handle Wrinklers ==========================
  511. AutoPlay.handleWrinklers = function() {
  512. var doPop = (((Game.season == "easter") || (Game.season == "halloween")) && !AutoPlay.seasonFinished(Game.season));
  513. doPop = doPop || (Game.Upgrades["Unholy bait"].bought && !Game.Achievements["Moistburster"].won);
  514. doPop = doPop || (AutoPlay.endPhase() && !Game.Achievements["Last Chance to See"].won);
  515. if (doPop) AutoPlay.addActivity("Popping wrinklers for droppings and/or achievements.");
  516. if (doPop) Game.wrinklers.forEach(function(w) { if (w.close==1) w.hp = 0; } );
  517. }
  518.  
  519. //===================== Handle Small Achievements ==========================
  520. AutoPlay.backupHeight=0;
  521. AutoPlay.handleSmallAchievements = function() {
  522. if(!Game.Achievements["Tabloid addiction"].won) { for (i = 0; i < 50; i++) { Game.tickerL.click(); } }
  523. if(!Game.Achievements["Here you go"].won) Game.Achievements["Here you go"].click();
  524. if(!Game.Achievements["Tiny cookie"].won) Game.ClickTinyCookie();
  525. var bakeryName = Game.bakeryName;
  526. if(!Game.Achievements["God complex"].won) { Game.bakeryName = "Orteil"; Game.bakeryNamePrompt(); Game.ConfirmPrompt(); }
  527. if(!Game.Achievements["What's in a name"].won || Game.bakeryName.slice(0,AutoPlay.robotName.length)!=AutoPlay.robotName) {
  528. Game.bakeryName = AutoPlay.robotName+bakeryName; Game.bakeryNamePrompt(); Game.ConfirmPrompt();
  529. }
  530. 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
  531. if(!Game.Achievements["Third-party"].won) Game.Win("Third-party"); // cookie bot is a third party itself
  532. if(!Game.Achievements["Cookie-dunker"].won && Game.milkProgress > 1 && Game.milkHd>0.34) {
  533. if(AutoPlay.backupHeight) { Game.LeftBackground.canvas.height=AutoPlay.backupHeight; AutoPlay.backupHeight=0; }
  534. else { AutoPlay.backupHeight=Game.LeftBackground.canvas.height; Game.LeftBackground.canvas.height=400; setTimeout(AutoPlay.unDunk, 20*1000); }
  535. }
  536. }
  537.  
  538. AutoPlay.unDunk = function() {
  539. if(!Game.Achievements["Cookie-dunker"].won) { setTimeout(AutoPlay.unDunk, 20*1000); return; }
  540. Game.LeftBackground.canvas.height=AutoPlay.backupHeight; AutoPlay.backupHeight=0;
  541. }
  542.  
  543. //===================== Handle Ascend ==========================
  544. AutoPlay.ascendLimit = 0.9*Math.floor(2*(1-Game.ascendMeterPercent));
  545.  
  546. AutoPlay.handleAscend = function() {
  547. if (Game.OnAscend) { AutoPlay.doReincarnate(); AutoPlay.findNextAchievement(); return; }
  548. if (Game.ascensionMode==1 && !AutoPlay.canContinue()) AutoPlay.doAscend("reborn mode did not work, retry.",0);
  549. if (AutoPlay.preNightMode()) return; //do not ascend right before the night
  550. if (AutoPlay.plantPending) return; // do not ascend when we wait for a plant to mature
  551. var ascendDays=10;
  552. if (AutoPlay.endPhase() && !Game.Achievements["Endless cycle"].won && Game.Upgrades["Sucralosia Inutilis"].bought) { // this costs 2 minutes per 2 ascend
  553. if ((Game.ascendMeterLevel > 0) && ((AutoPlay.ascendLimit < Game.ascendMeterLevel*Game.ascendMeterPercent) || ((Game.prestige+Game.ascendMeterLevel)%1000==777)))
  554. { AutoPlay.doAscend("go for 1000 ascends",0); }
  555. }
  556. if (Game.Upgrades["Permanent upgrade slot V"].bought && !Game.Achievements["Reincarnation"].won) { // this costs 3+2 minute per 2 ascend
  557. if ((Game.ascendMeterLevel > 0) && ((AutoPlay.ascendLimit < Game.ascendMeterLevel*Game.ascendMeterPercent) ))
  558. { AutoPlay.doAscend("go for 100 ascends",0); }
  559. }
  560. if (AutoPlay.endPhase() && (Date.now()-Game.startDate) > ascendDays*24*60*60*1000) {
  561. AutoPlay.doAscend("ascend after " + ascendDays + " days just while waiting for next achievement.",1);
  562. }
  563. var newPrestige=(Game.prestige+Game.ascendMeterLevel)%1000000;
  564. if (AutoPlay.endPhase() && !Game.Upgrades["Lucky digit"].bought && Game.ascendMeterLevel>0 && ((Game.prestige+Game.ascendMeterLevel)%10 == 7)) { AutoPlay.doAscend("ascend for lucky digit.",0); }
  565. if (AutoPlay.endPhase() && !Game.Upgrades["Lucky number"].bought && Game.ascendMeterLevel>0 && ((Game.prestige+Game.ascendMeterLevel)%1000 == 777)) { AutoPlay.doAscend("ascend for lucky number.",0); }
  566. if (!Game.Upgrades["Lucky payout"].bought && Game.ascendMeterLevel>0 && AutoPlay.endPhase() && (Game.heavenlyChips > 77777777) && (newPrestige <= 777777) && (newPrestige >= 777777-Game.ascendMeterLevel)) {
  567. AutoPlay.doAscend("ascend for lucky payout.",0);
  568. }
  569. if (Game.AchievementsById[AutoPlay.nextAchievement].won) {
  570. var date=new Date();
  571. date.setTime(Date.now()-Game.startDate);
  572. var legacyTime=Game.sayTime(date.getTime()/1000*Game.fps,-1);
  573. date.setTime(Date.now()-Game.fullDate);
  574. var fullTime=Game.sayTime(date.getTime()/1000*Game.fps,-1);
  575. AutoPlay.doAscend("have achievement: " + Game.AchievementsById[AutoPlay.nextAchievement].desc + " after " + legacyTime + "(total: " + fullTime + ")",1);
  576. } }
  577.  
  578. AutoPlay.canContinue = function() {
  579. if (!Game.Achievements["Neverclick"].won && Game.cookieClicks<=15) return true;
  580. if (!Game.Achievements["True Neverclick"].won && Game.cookieClicks==0) return true;
  581. if (!Game.Achievements["Hardcore"].won && Game.UpgradesOwned==0) return true;
  582. if (!Game.Achievements["Speed baking I"].won && (Date.now()-Game.startDate <= 1000*60*35)) return true;
  583. if (!Game.Achievements["Speed baking II"].won && (Date.now()-Game.startDate <= 1000*60*25)) return true;
  584. if (!Game.Achievements["Speed baking III"].won && (Date.now()-Game.startDate <= 1000*60*15)) return true;
  585. return false;
  586. }
  587.  
  588. AutoPlay.doReincarnate = function() {
  589. AutoPlay.delay=10; AutoPlay.buyHeavenlyUpgrades();
  590. if(!Game.Achievements["Neverclick"].won || !Game.Achievements["Hardcore"].won) { Game.PickAscensionMode(); Game.nextAscensionMode=1; Game.ConfirmPrompt(); }
  591. if(AutoPlay.endPhase() && AutoPlay.mustRebornAscend()) { Game.PickAscensionMode(); Game.nextAscensionMode=1; Game.ConfirmPrompt(); }
  592. Game.Reincarnate(true);
  593. if (AutoPlay.loggingInfo) setTimeout(AutoPlay.logging, 20*1000);
  594. AutoPlay.ascendLimit = 0.9*Math.floor(2*(1-Game.ascendMeterPercent));
  595. }
  596.  
  597. AutoPlay.mustRebornAscend = function() { return !([78,93,94,95].every(function(a) { return Game.AchievementsById[a].won; })); }
  598.  
  599. AutoPlay.doAscend = function(str,log) {
  600. AutoPlay.debugInfo(str);
  601. AutoPlay.loggingInfo=log?str:0;
  602. // if(AutoPlay.checkAllAchievementsOK(false)) { AutoPlay.logging(); return; } // do not ascend when we are finished
  603. if(Game.wrinklers.some(function(w) { return w.close; } )) AutoPlay.assignSpirit(0,"scorn",1);
  604. Game.wrinklers.forEach(function(w) { if (w.close==1) w.hp=0; } ); // pop all wrinklers
  605. if (Game.isMinigameReady(Game.Objects["Farm"])) Game.Objects["Farm"].minigame.harvestAll(); // harvest garden
  606. if (Game.Upgrades["Chocolate egg"].unlocked && !Game.Upgrades["Chocolate egg"].bought) {
  607. if (Game.dragonLevel>=9) { // setting first aura to earth shatterer
  608. Game.specialTab="dragon"; Game.SetDragonAura(5,0);
  609. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  610. }
  611. Game.ObjectsById.forEach(function(e) { e.sell(e.amount); } );
  612. Game.Upgrades["Chocolate egg"].buy();
  613. } else { AutoPlay.delay=10; Game.Ascend(true); }
  614. }
  615.  
  616. //===================== Handle Achievements ==========================
  617. AutoPlay.wantedAchievements = [82, 12, 89, 130, 108, 223, 224, 225, 226, 227, 228, 229, 230, 279, 280, 372, 373, 374, 375, 390, 391, 366];
  618. AutoPlay.nextAchievement=AutoPlay.wantedAchievements[0];
  619.  
  620. AutoPlay.endPhase = function() { return AutoPlay.wantedAchievements.indexOf(AutoPlay.nextAchievement)<0; }
  621.  
  622. AutoPlay.mainActivity="doing nothing in particular";
  623.  
  624. AutoPlay.setMainActivity = function(str) {
  625. AutoPlay.mainActivity=str;
  626. AutoPlay.debugInfo(str);
  627. }
  628.  
  629. AutoPlay.findNextAchievement = function() {
  630. AutoPlay.handleSmallAchievements();
  631. for(i = 0; i < AutoPlay.wantedAchievements.length; i++) {
  632. if (!(Game.AchievementsById[AutoPlay.wantedAchievements[i]].won)) {
  633. AutoPlay.nextAchievement = AutoPlay.wantedAchievements[i];
  634. AutoPlay.setMainActivity("trying to get achievement: " + Game.AchievementsById[AutoPlay.nextAchievement].desc);
  635. return;
  636. }
  637. }
  638. AutoPlay.checkAllAchievementsOK(true);
  639. }
  640.  
  641. AutoPlay.checkAllAchievementsOK = function(log) { // could remove the parameter ...
  642. for (var i in Game.Achievements) {
  643. var me=Game.Achievements[i];
  644. if (!me.won && me.pool!="dungeon" && me.id!=367) { // missing achievement, but do not stop for legacy of one year
  645. if(log) AutoPlay.setMainActivity("Missing achievement #" + me.id + ": " + me.desc + ", try to get it now.");
  646. if(log) AutoPlay.nextAchievement=me.id;
  647. return false;
  648. } }
  649. for (var i in Game.Upgrades) {
  650. var me=Game.Upgrades[i];
  651. if (me.pool=='prestige' && !me.bought) { // we have not all prestige upgrades yet
  652. if(log) AutoPlay.nextAchievement=AutoPlay.wantedAchievements[AutoPlay.wantedAchievements.length-1];
  653. if(log) AutoPlay.setMainActivity("Prestige upgrade " + me.name + " is missing, waiting to buy it.");
  654. if(log) Game.RemoveAchiev(Game.AchievementsById[AutoPlay.nextAchievement].name);
  655. return false;
  656. } }
  657. if(!Game.Achievements["So much to do so much to see"].won) { //wait until the end of the year - achievement 367
  658. var me=Game.Achievements["So much to do so much to see"];
  659. if(log) AutoPlay.setMainActivity("Missing achievement #" + me.id + ": " + me.desc + ", try to get it now.");
  660. if(log) AutoPlay.nextAchievement=me.id;
  661. return false;
  662. }
  663. // finished with playing: idle further
  664. AutoPlay.finished=true;
  665. if(log) AutoPlay.setMainActivity("My job is done here, have a nice day. I am still idling along.");
  666. if(log) AutoPlay.nextAchievement=99; // follow the white rabbit (from dungeons)
  667. return false;
  668. }
  669.  
  670. AutoPlay.leaveGame = function() {
  671. clearInterval(AutoPlay.autoPlayer); //stop autoplay:
  672. AutoPlay.info("My job is done here, have a nice day.");
  673. if(Game.bakeryName.slice(0,AutoPlay.robotName.length)==AutoPlay.robotName) {
  674. Game.bakeryName = Game.bakeryName.slice(AutoPlay.robotName.length); Game.bakeryNamePrompt(); Game.ConfirmPrompt();
  675. }
  676. return true;
  677. }
  678.  
  679. AutoPlay.findMissingAchievements = function() { // just for testing purposes
  680. for (var i in Game.Achievements) {
  681. var me=Game.Achievements[i];
  682. if (!me.won && me.pool!="dungeon") { // missing achievement
  683. AutoPlay.debugInfo("missing achievement #" + me.id + ": " + me.desc);
  684. } }
  685. for (var i in Game.Upgrades) {
  686. var me=Game.Upgrades[i];
  687. if (me.pool=='prestige' && !me.bought) { // we have not all prestige upgrades yet
  688. AutoPlay.debugInfo("prestige upgrade " + me.name + " is missing.");
  689. } } }
  690.  
  691. //===================== Handle Heavenly Upgrades ==========================
  692. 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,
  693. AutoPlay.kittens = [31,32,54,108,187,320,321,322,425,442];
  694. AutoPlay.cursors = [0,1,2,3,4,5,6,43,82,109,188,189];
  695. AutoPlay.chancemakers = [416,417,418,419,420,421,422,423,441];
  696. AutoPlay.butterBiscuits = [334,335,336,337,400];
  697.  
  698. AutoPlay.buyHeavenlyUpgrades = function() {
  699. AutoPlay.prioUpgrades.forEach(function(id) { var e=Game.UpgradesById[id]; if (e.canBePurchased && !e.bought && e.buy(true)) { AutoPlay.info("buying "+e.name); } });
  700. Game.UpgradesById.forEach(function(e) { if (e.canBePurchased && !e.bought && e.buy(true)) { AutoPlay.info("buying "+e.name); } });
  701. AutoPlay.assignPermanentSlot(1,AutoPlay.kittens);
  702. AutoPlay.assignPermanentSlot(2,AutoPlay.chancemakers);
  703. if(!Game.Achievements["Reincarnation"].won) { // for many ascends
  704. AutoPlay.assignPermanentSlot(0,AutoPlay.cursors);
  705. AutoPlay.assignPermanentSlot(3,[52]); // lucky day
  706. AutoPlay.assignPermanentSlot(4,[53]); // serendipity
  707. } else { //collect rare things
  708. AutoPlay.assignPermanentSlot(0,AutoPlay.butterBiscuits);
  709. AutoPlay.assignPermanentSlot(3,[226]); // omelette
  710. if(Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won)
  711. AutoPlay.assignPermanentSlot(4,[72]); // arcane sugar
  712. else AutoPlay.assignPermanentSlot(4,[53]); // serendipity
  713. }
  714. }
  715.  
  716. AutoPlay.assignPermanentSlot = function(slot,options) {
  717. if (!Game.UpgradesById[264+slot].bought) return;
  718. Game.AssignPermanentSlot(slot);
  719. for (var i=options.length-1; i>=0; i--) { if(Game.UpgradesById[options[i]].bought) { Game.PutUpgradeInPermanentSlot(options[i],slot); break; } }
  720. Game.ConfirmPrompt();
  721. }
  722.  
  723. //===================== Handle Dragon ==========================
  724. AutoPlay.handleDragon = function() {
  725. if (Game.Upgrades["A crumbly egg"].unlocked) {
  726. if (Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost()) {
  727. Game.specialTab="dragon"; Game.UpgradeDragon(); Game.ToggleSpecialMenu(0);
  728. } }
  729. if ((Game.dragonAura==0) && (Game.dragonLevel>=5)) { // set first aura to kitten (breath of milk)
  730. Game.specialTab="dragon"; Game.SetDragonAura(1,0);
  731. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  732. }
  733. if ((Game.dragonAura==1) && (Game.dragonLevel>=19)) { // set first aura to prism (radiant appetite)
  734. Game.specialTab="dragon"; Game.SetDragonAura(15,0);
  735. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  736. }
  737. if ((Game.dragonAura2==0) && (Game.dragonLevel>=Game.dragonLevels.length-1)) { // set second aura to kitten (breath of milk)
  738. Game.specialTab="dragon"; Game.SetDragonAura(1,1);
  739. Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  740. } }
  741.  
  742. //===================== Auxiliary ==========================
  743.  
  744. AutoPlay.info = function(s) { console.log("### "+s); Game.Notify("Automatic Playthrough",s,1,100); }
  745. AutoPlay.debugInfo = function(s) { console.log("======> "+s); Game.Notify("Debugging CookieBot",s,1,20); }
  746.  
  747. AutoPlay.logging = function() {
  748. var before=window.localStorage.getItem("autoplayLog");
  749. var toAdd="#logging autoplay V" + AutoPlay.version + " with " + AutoPlay.loggingInfo + "\n" + Game.WriteSave(1) + "\n";
  750. AutoPlay.loggingInfo=0;
  751. window.localStorage.setItem("autoplayLog",before+toAdd);
  752. }
  753.  
  754. AutoPlay.saveLog = function() { // for testing and getting the log out
  755. var text=window.localStorage.getItem("autoplayLog");
  756. var blob=new Blob([text],{type:'text/plain;charset=utf-8'});
  757. saveAs(blob,'autoPlaySave.txt');
  758. }
  759.  
  760. AutoPlay.handleNotes = function() {
  761. for (var i in Game.Notes) {
  762. if (Game.Notes[i].quick==0) { Game.Notes[i].life=2000*Game.fps; Game.Notes[i].quick=1; }
  763. } }
  764.  
  765. function range(start, end) {
  766. var foo = [];
  767. for (var i = start; i <= end; i++) { foo.push(i); }
  768. return foo;
  769. }
  770.  
  771. //===================== Cheats for Testing ==========================
  772. //create golden cookie: Game.shimmerTypes.golden.time = Game.shimmerTypes.golden.maxTime; or new Game.shimmer("golden")
  773. //golden cookie with building special: var newShimmer=new Game.shimmer("golden");newShimmer.force="building special";
  774.  
  775. //===================== Init & Start ==========================
  776.  
  777. AutoPlay.whatTheBotIsDoing = function() {
  778. return '<div style="padding:8px;width:400px;font-size:11px;text-align:center;">'+
  779. '<span style="color:#6f6;font-size:18px"> What is the bot doing?</span>'+
  780. '<div class="line"></div>'+
  781. AutoPlay.activities+
  782. '</div>';
  783. }
  784.  
  785. AutoPlay.addActivity = function(str) {
  786. AutoPlay.activities+= '<div class="line"></div>'+str;
  787. }
  788.  
  789. AutoPlay.info("Pre-release for gardening.");
  790. if (AutoPlay.autoPlayer) { AutoPlay.info("replacing old version of autoplay"); clearInterval(AutoPlay.autoPlayer); }
  791. AutoPlay.autoPlayer = setInterval(AutoPlay.run, 300); // was 100 before, but that is too quick
  792. AutoPlay.findNextAchievement();
  793. l('versionNumber').innerHTML='v. '+Game.version+" (with autoplay v."+AutoPlay.version+")";
  794. l('versionNumber').innerHTML='v. '+Game.version+' <span '+Game.getDynamicTooltip('AutoPlay.whatTheBotIsDoing','this')+">(with autoplay v."+AutoPlay.version+")"+'</span>';
  795. 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