From c0fa250964a3571c73d0a65ed0704e983674fafb Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 15 Apr 2018 21:19:28 +0200 Subject: [PATCH] React on clickbuffs Signed-off-by: Knut Ahlers --- autocookieclicker.user.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/autocookieclicker.user.js b/autocookieclicker.user.js index 07d0dbd..41197e7 100644 --- a/autocookieclicker.user.js +++ b/autocookieclicker.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Automate CookieClicker // @namespace https://luzifer.io/ -// @version 0.12.0 +// @version 0.13.0 // @description Automate everything! // @author Knut Ahlers // @source https://github.com/Luzifer/automate-cookie-clicker @@ -52,11 +52,11 @@ function executeAutoActions() { } } -function checkCPS() { +function controlAutoClicker() { let cps = Game.cookiesPs; - if (cps < 3000) { + if (cps < 3000 || hasActiveClickBuff()) { if (window.autoClicker == undefined) { - window.autoClicker = window.setInterval(autoClick, 1); + window.autoClicker = window.setInterval(autoClick, 100); } } else { if (window.autoClicker != undefined) { @@ -76,12 +76,20 @@ function getMaxBuy() { return Math.max(Math.ceil((topPurchaseCount + 1) / purchaseSteps), 1) * purchaseSteps; } +function hasActiveClickBuff() { + var hasBuff = false; + for (key in Game.buffs) { + if (Game.buffs[key].multClick) hasBuff = true; + } + return hasBuff; +} + function installHelper() { // Startup notification let version = GM_info.script.version; note('Version ' + version + ' loaded.'); - window.checkCPS = window.setInterval(checkCPS, 1000); + window.controlAutoClicker = window.setInterval(controlAutoClicker, 1000); // Enable automatic purchasing of upgrades / elements window.autoPurchase = window.setInterval(executeAutoActions, 500);