1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-12-22 18:21:18 +00:00

React on clickbuffs

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-04-15 21:19:28 +02:00
parent b44253f8c2
commit c0fa250964
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Automate CookieClicker // @name Automate CookieClicker
// @namespace https://luzifer.io/ // @namespace https://luzifer.io/
// @version 0.12.0 // @version 0.13.0
// @description Automate everything! // @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me> // @author Knut Ahlers <knut@ahlers.me>
// @source https://github.com/Luzifer/automate-cookie-clicker // @source https://github.com/Luzifer/automate-cookie-clicker
@ -52,11 +52,11 @@ function executeAutoActions() {
} }
} }
function checkCPS() { function controlAutoClicker() {
let cps = Game.cookiesPs; let cps = Game.cookiesPs;
if (cps < 3000) { if (cps < 3000 || hasActiveClickBuff()) {
if (window.autoClicker == undefined) { if (window.autoClicker == undefined) {
window.autoClicker = window.setInterval(autoClick, 1); window.autoClicker = window.setInterval(autoClick, 100);
} }
} else { } else {
if (window.autoClicker != undefined) { if (window.autoClicker != undefined) {
@ -76,12 +76,20 @@ function getMaxBuy() {
return Math.max(Math.ceil((topPurchaseCount + 1) / purchaseSteps), 1) * purchaseSteps; 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() { function installHelper() {
// Startup notification // Startup notification
let version = GM_info.script.version; let version = GM_info.script.version;
note('Version ' + version + ' loaded.'); note('Version ' + version + ' loaded.');
window.checkCPS = window.setInterval(checkCPS, 1000); window.controlAutoClicker = window.setInterval(controlAutoClicker, 1000);
// Enable automatic purchasing of upgrades / elements // Enable automatic purchasing of upgrades / elements
window.autoPurchase = window.setInterval(executeAutoActions, 500); window.autoPurchase = window.setInterval(executeAutoActions, 500);