1
0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-09-18 23:02:56 +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==
// @name Automate CookieClicker
// @namespace https://luzifer.io/
// @version 0.12.0
// @version 0.13.0
// @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me>
// @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);