-
Notifications
You must be signed in to change notification settings - Fork 260
/
enhancedautoclicker.user.js
1244 lines (1157 loc) · 60.2 KB
/
enhancedautoclicker.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name [Pokeclicker] Enhanced Auto Clicker
// @namespace Pokeclicker Scripts
// @author Optimatum (Original/Credit: Ephenia, Ivan Lay, Novie53, andrew951, Kaias26, kevingrillet)
// @description Clicks through battles, with adjustable speed, and provides various insightful statistics. Also includes an automatic gym battler and automatic dungeon explorer with multiple pathfinding modes.
// @copyright https://github.com/Ephenia
// @license GPL-3.0 License
// @version 3.5.4
// @homepageURL https://github.com/Ephenia/Pokeclicker-Scripts/
// @supportURL https://github.com/Ephenia/Pokeclicker-Scripts/issues
// @downloadURL https://raw.githubusercontent.com/Ephenia/Pokeclicker-Scripts/master/enhancedautoclicker.user.js
// @updateURL https://raw.githubusercontent.com/Ephenia/Pokeclicker-Scripts/master/enhancedautoclicker.user.js
// @match https://www.pokeclicker.com/
// @icon https://www.google.com/s2/favicons?domain=pokeclicker.com
// @grant unsafeWindow
// @run-at document-idle
// ==/UserScript==
class EnhancedAutoClicker {
// Constants
static ticksPerSecond = 20;
static maxClickMultiplier = 5;
// Auto Clicker
static autoClickState = ko.observable(validateStorage('autoClickState', false));
static autoClickMultiplier = validateStorage('autoClickMultiplier', 1, (v) => (Number.isInteger(v) && v >= 1));
static autoClickerLoop;
// Auto Gym
static autoGymState = ko.observable(validateStorage('autoGymState', false));
static autoGymSelect = validateStorage('autoGymSelect', 0, [0, 1, 2, 3, 4]);
// Auto Dungeon
static autoDungeonState = ko.observable(validateStorage('autoDungeonState', false));
static autoDungeonFinishBeforeStopping = validateStorage('autoDungeonFinishBeforeStopping', true);
static autoDungeonEncounterMode = validateStorage('autoDungeonEncounterMode', false);
static autoDungeonChestMode = validateStorage('autoDungeonChestMode', false);
static autoDungeonLootTier = validateStorage('autoDungeonLootTier', 0, [...Object.keys(baseLootTierChance).keys()]);
static autoDungeonAlwaysOpenRareChests = validateStorage('autoDungeonAlwaysOpenRareChests', false);
static autoDungeonTracker = {
ID: 0,
floor: null,
floorSize: null,
flashTier: null,
flashCols: null,
coords: null,
bossCoords: null,
encounterCoords: null,
chestCoords: null,
floorExplored: false,
floorFinished: false,
dungeonFinished: false,
stopAfterFinishing: false,
};
// Clicker statistics calculator
static autoClickCalcLoop;
static autoClickCalcEfficiencyDisplayMode = validateStorage('autoClickCalcEfficiencyDisplayMode', 0, [0, 1]);
static autoClickCalcDamageDisplayMode = validateStorage('autoClickCalcDamageDisplayMode', 0, [0, 1]);
static autoClickCalcTracker = {
lastUpdate: null,
playerState: -1,
playerLocation: null,
ticks: null,
clicks: null,
enemies: null,
areaHealth: null,
};
// Computed observables for visual bindings
static autoGymOn = ko.pureComputed(() => {
return this.autoClickState() && this.autoGymState();
});
/* Initialization */
static initOverrides() {
// Add data bindings immediately, before the game initializes Knockout
this.addGraphicsBindings();
// Override static class methods
this.overrideGymRunner();
this.overrideDungeonRunner();
}
static initAutoClicker() {
const battleView = document.getElementsByClassName('battle-view')[0];
var elemAC = document.createElement("table");
elemAC.innerHTML = `<tbody>
<tr>
<td colspan="4">
<button id="auto-click-start" class="btn btn-${this.autoClickState() ? 'success' : 'danger'} btn-block" style="font-size:8pt;">
Auto Click [${this.autoClickState() ? 'ON' : 'OFF'}]<br />
<div id="auto-click-info">
<!-- calculator display will be set by resetCalculator() -->
</div>
</button>
<div id="click-rate-cont">
<div id="auto-click-rate-info">
Click Attack Rate: ${(this.ticksPerSecond * this.autoClickMultiplier).toLocaleString('en-US', {maximumFractionDigits: 2})}/s
</div>
<input id="auto-click-rate" type="range" min="1" max="${this.maxClickMultiplier}" value="${this.autoClickMultiplier}">
</div>
</td>
</tr>
<tr>
<td style="display: flex; column-gap: 2px;">
<div style="flex: auto;">
<button id="auto-dungeon-start" class="btn btn-block btn-${this.autoDungeonState() ? 'success' : 'danger'}" style="font-size: 8pt;">
Auto Dungeon [${this.autoDungeonState() ? 'ON' : 'OFF'}]
</button>
</div>
<div id="auto-dungeon-encounter-mode" style="flex: initial; max-height: 30px; max-width: 30px; padding: 2px;">
<img title="Auto Dungeon fights mode" src="assets/images/dungeons/encounter.png" height="100%" style="${this.autoDungeonEncounterMode ? '' : 'filter: grayscale(100%);'}" />
</div>
<div id="auto-dungeon-chest-mode" style="flex: initial; max-height: 30px; max-width: 40px; padding: 2px;">
<img title="Auto Dungeon chest mode" src="assets/images/dungeons/chest.png" height="100%" style="${this.autoDungeonChestMode ? '' : 'filter: grayscale(100%)'}" />
</div>
<div style="flex: initial; display: flex; flex-direction: column;">
<div id="auto-dungeon-loottier" class="dropdown show">
<button type="button" class="text-left custom-select col-12 btn btn-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="max-height:30px; display:flex; flex:1; align-items:center;">
<img id="auto-dungeon-loottier-img" src="assets/images/dungeons/chest-${Object.keys(baseLootTierChance)[this.autoDungeonLootTier]}.png" style="height:100%;">
</button>
<div id="auto-dungeon-loottier-dropdown" class="border-secondary dropdown-menu col-12">
${Object.keys(baseLootTierChance).map((tier, i) => `<div class="dropdown-item" value="${i}"><img src="assets/images/dungeons/chest-${tier}.png"></div>` ).join('\n')}
</div>
</div>
</div>
<div style="flex: auto;">
<button id="auto-gym-start" class="btn btn-block btn-${this.autoGymState() ? 'success' : 'danger'}" style="font-size: 8pt;">
Auto Gym [${this.autoGymState() ? 'ON' : 'OFF'}]
</button>
</div>
<div style="flex: initial; display: flex; flex-direction: column;">
<select id="auto-gym-select" value="${this.autoGymSelect}" style="flex: auto;">
<option value="0">#1</option>
<option value="1">#2</option>
<option value="2">#3</option>
<option value="3">#4</option>
<option value="4">#5</option>
</select>
</div>
</td>
</tr>
</tbody>`;
battleView.before(elemAC);
this.resetCalculator(); // initializes calculator display
const settingsBody = createScriptSettingsContainer('Enhanced Auto Clicker');
const settingsToAdd = [];
// Dropdowns
let dropdownsToAdd = [
['autoClickCalcEfficiencyDisplayMode', 'Auto Clicker efficiency display mode', this.autoClickCalcEfficiencyDisplayMode, ['Percentage', 'Ticks/s']],
['autoClickCalcDamageDisplayMode', 'Auto Clicker damage display mode', this.autoClickCalcDamageDisplayMode, ['Click Attacks', 'Damage']]
];
dropdownsToAdd.forEach(([name, text, value, options]) => {
const newSetting = document.createElement('tr')
settingsToAdd.push(newSetting);
newSetting.innerHTML = `<td class="p-2 col-md-8">
${text}
</td>
<td class="p-0 col-md-4">
<select id="select-${name}" class="form-control" value="${value}">
${options.map((desc, val) => `<option value="${val}">${desc}</option>`).join('\n')}
</select>
</td>`;
});
// Checkboxes
let checkboxesToAdd = [
['autoDungeonFinishBeforeStopping', 'Auto Dungeon finishes dungeons before turning off', this.autoDungeonFinishBeforeStopping],
['autoDungeonAlwaysOpenRareChests', 'Always open visible targeted chests', this.autoDungeonAlwaysOpenRareChests],
];
checkboxesToAdd.forEach(([name, text, isChecked]) => {
const newSetting = document.createElement('tr')
settingsToAdd.push(newSetting);
newSetting.innerHTML = `<td class="p-2 col-md-8">
<label class="m-0" for="checkbox-${name}">${text}</label>
</td><td class="p-2 col-md-4">
<input id="checkbox-${name}" type="checkbox">
</td>`;
newSetting.querySelector(`#checkbox-${name}`).checked = isChecked;
});
settingsBody.append(...settingsToAdd);
document.getElementById('auto-gym-select').value = this.autoGymSelect;
document.getElementById('auto-click-start').addEventListener('click', () => { EnhancedAutoClicker.toggleAutoClick(); });
document.getElementById('auto-click-rate').addEventListener('change', (event) => { EnhancedAutoClicker.changeClickMultiplier(event); });
document.getElementById('auto-gym-start').addEventListener('click', () => { EnhancedAutoClicker.toggleAutoGym(); });
document.getElementById('auto-gym-select').addEventListener('change', (event) => { EnhancedAutoClicker.changeSelectedGym(event); });
document.getElementById('auto-dungeon-start').addEventListener('click', () => { EnhancedAutoClicker.toggleAutoDungeon(true); });
document.getElementById('auto-dungeon-encounter-mode').addEventListener('click', () => { EnhancedAutoClicker.toggleAutoDungeonEncounterMode(); });
document.getElementById('auto-dungeon-chest-mode').addEventListener('click', () => { EnhancedAutoClicker.toggleAutoDungeonChestMode(); });
document.getElementById('checkbox-autoDungeonFinishBeforeStopping').addEventListener('change', () => { EnhancedAutoClicker.toggleAutoDungeonFinishBeforeStopping(); });
document.getElementById('checkbox-autoDungeonAlwaysOpenRareChests').addEventListener('change', () => { EnhancedAutoClicker.toggleAutoDungeonAlwaysOpenRareChests(); });
document.getElementById('select-autoClickCalcEfficiencyDisplayMode').addEventListener('change', (event) => { EnhancedAutoClicker.changeCalcEfficiencyDisplayMode(event); });
document.getElementById('select-autoClickCalcDamageDisplayMode').addEventListener('change', (event) => { EnhancedAutoClicker.changeCalcDamageDisplayMode(event); });
document.querySelectorAll('#auto-dungeon-loottier-dropdown > div').forEach((elem) => {
elem.addEventListener('click', () => { EnhancedAutoClicker.changeAutoDungeonLootTier(elem.getAttribute('value')); });
});
addGlobalStyle('#auto-click-info { display: flex; flex-direction: row; justify-content: center; }');
addGlobalStyle('#auto-click-info > div { width: 33.3%; }');
addGlobalStyle('#click-rate-cont { display: flex; flex-direction: column; align-items: stretch; }');
addGlobalStyle('#auto-dungeon-loottier-dropdown img { max-height: 30px; width: auto; }');
if (this.autoClickState()) {
this.toggleAutoClickerLoop();
}
}
/**
* Add extra Knockout data bindings to optionally disable (most) gym and dungeon graphics
*/
static addGraphicsBindings() {
// Add gymView data bindings
var gymContainer = document.querySelector('div[data-bind="if: App.game.gameState === GameConstants.GameState.gym"]');
// Always hide stop button during autoGym, even with graphics enabled
var restartButton = gymContainer.querySelector('button[data-bind="visible: GymRunner.autoRestart()"]');
restartButton.setAttribute('data-bind', 'visible: GymRunner.autoRestart() && !EnhancedAutoClicker.autoGymOn()');
}
/* Settings event handlers */
static toggleAutoClick() {
const element = document.getElementById('auto-click-start');
this.autoClickState(!this.autoClickState());
localStorage.setItem('autoClickState', this.autoClickState());
this.autoClickState() ? element.classList.replace('btn-danger', 'btn-success') : element.classList.replace('btn-success', 'btn-danger');
if (!this.autoClickState()) {
if (this.autoGymState()) {
this.toggleAutoGym();
}
if (this.autoDungeonState()) {
this.toggleAutoDungeon();
}
}
this.toggleAutoClickerLoop();
}
static changeClickMultiplier(event) {
// TODO decide on a better range / function
const multiplier = +event.target.value;
if (Number.isInteger(multiplier) && multiplier > 0) {
this.autoClickMultiplier = multiplier;
localStorage.setItem("autoClickMultiplier", this.autoClickMultiplier);
var displayNum = (this.ticksPerSecond * this.autoClickMultiplier).toLocaleString('en-US', {maximumFractionDigits: 2});
document.getElementById('auto-click-rate-info').innerText = `Click Attack Rate: ${displayNum}/s`;
this.toggleAutoClickerLoop();
}
}
static toggleAutoGym() {
const element = document.getElementById('auto-gym-start');
const newState = !this.autoGymState();
if (newState && !this.canStartAutoGym()) {
// Don't turn on if there's no gym here
return;
} else if (newState && this.autoDungeonState()) {
// Only one mode may be active at a time
return;
}
this.autoGymState(newState);
localStorage.setItem('autoGymState', this.autoGymState());
this.autoGymState() ? element.classList.replace('btn-danger', 'btn-success') : element.classList.replace('btn-success', 'btn-danger');
element.textContent = `Auto Gym [${this.autoGymState() ? 'ON' : 'OFF'}]`;
if (this.autoGymState()) {
if (!this.autoClickState()) {
// Turn on the auto clicker if necessary
this.toggleAutoClick();
}
} else {
// Assume we can't reach this point with only the built-in auto restart running, so it's safe to stop it
GymRunner.autoRestart(false);
}
}
static changeSelectedGym(event) {
const val = +event.target.value;
if ([0, 1, 2, 3, 4].includes(val)) {
this.autoGymSelect = val;
localStorage.setItem("autoGymSelect", this.autoGymSelect);
// In case currently fighting a gym
if (this.autoClickState() && this.autoGymState()) {
// Only break out of this script's auto restart, not the built-in one
GymRunner.autoRestart(false);
}
}
}
static toggleAutoDungeon(allowSlowStop = false) {
const element = document.getElementById('auto-dungeon-start');
let newState = !this.autoDungeonState();
if (DungeonGuides.hired()) {
// Auto Dungeon can't run alongside dungeon guides, force stop
newState = false;
allowSlowStop = false;
Notifier.notify({
type: NotificationConstants.NotificationOption.warning,
title: 'Enhanced Auto Clicker',
message: `Auto Dungeon mode is not compatible with Dungeon Guides.`,
timeout: GameConstants.SECOND * 15,
});
} else if (newState && !this.canStartAutoDungeon()) {
// Don't turn on if there's no dungeon here
return;
} else if (newState && this.autoGymState()) {
// Only one mode may be active at a time
return;
}
localStorage.setItem('autoDungeonState', newState);
if (allowSlowStop && this.autoDungeonFinishBeforeStopping && App.game.gameState === GameConstants.GameState.dungeon &&
(!newState && !this.autoDungeonTracker.stopAfterFinishing)) {
// Instead of stopping immediately, wait and exit after beating this dungeon
this.autoDungeonTracker.stopAfterFinishing = true;
} else {
this.autoDungeonState(newState);
this.autoDungeonTracker.stopAfterFinishing = false;
}
element.classList.remove('btn-success', 'btn-danger', 'btn-warning');
element.classList.add(this.autoDungeonTracker.stopAfterFinishing ? 'btn-warning' : (newState ? 'btn-success' : 'btn-danger'));
element.textContent = `Auto Dungeon [${newState ? 'ON' : 'OFF'}]`;
if (newState) {
// Trigger a dungeon scan
this.autoDungeonTracker.ID = -1;
if (!this.autoClickState()) {
// Turn on the auto clicker if necessary
this.toggleAutoClick();
}
}
}
static toggleAutoDungeonEncounterMode() {
this.autoDungeonEncounterMode = !this.autoDungeonEncounterMode;
$('#auto-dungeon-encounter-mode img').css('filter', `${this.autoDungeonEncounterMode ? '' : 'grayscale(100%)' }`);
localStorage.setItem('autoDungeonEncounterMode', this.autoDungeonEncounterMode);
this.autoDungeonTracker.coords = null;
}
static toggleAutoDungeonChestMode() {
this.autoDungeonChestMode = !this.autoDungeonChestMode;
$('#auto-dungeon-chest-mode img').css('filter', `${this.autoDungeonChestMode ? '' : 'grayscale(100%)' }`);
localStorage.setItem('autoDungeonChestMode', this.autoDungeonChestMode);
this.autoDungeonTracker.coords = null;
}
static changeAutoDungeonLootTier(tier) {
const val = +tier;
if ([...Object.keys(baseLootTierChance).keys()].includes(val)) {
this.autoDungeonLootTier = val;
document.getElementById('auto-dungeon-loottier-img').setAttribute('src', `assets/images/dungeons/chest-${Object.keys(baseLootTierChance)[val]}.png`);
localStorage.setItem("autoDungeonLootTier", this.autoDungeonLootTier);
}
}
static toggleAutoDungeonFinishBeforeStopping() {
this.autoDungeonFinishBeforeStopping = !this.autoDungeonFinishBeforeStopping;
if (!this.autoDungeonFinishBeforeStopping && this.autoDungeonTracker.stopAfterFinishing) {
this.toggleAutoDungeon();
}
localStorage.setItem('autoDungeonFinishBeforeStopping', this.autoDungeonFinishBeforeStopping);
}
static toggleAutoDungeonAlwaysOpenRareChests() {
this.autoDungeonAlwaysOpenRareChests = !this.autoDungeonAlwaysOpenRareChests;
localStorage.setItem('autoDungeonAlwaysOpenRareChests', this.autoDungeonAlwaysOpenRareChests);
}
static changeCalcEfficiencyDisplayMode(event) {
const val = +event.target.value;
if (val != this.autoClickCalcEfficiencyDisplayMode && [0, 1].includes(val)) {
this.autoClickCalcEfficiencyDisplayMode = val;
localStorage.setItem('autoClickCalcEfficiencyDisplayMode', this.autoClickCalcEfficiencyDisplayMode);
this.resetCalculator();
}
}
static changeCalcDamageDisplayMode(event) {
const val = +event.target.value;
if (val != this.autoClickCalcDamageDisplayMode && [0, 1].includes(val)) {
this.autoClickCalcDamageDisplayMode = val;
localStorage.setItem('autoClickCalcDamageDisplayMode', this.autoClickCalcDamageDisplayMode);
this.resetCalculator();
}
}
/* Auto Clicker */
/**
* Resets and, if enabled, restarts autoclicker
* -While enabled, runs <ticksPerSecond> times per second in active battle
*/
static toggleAutoClickerLoop() {
var delay = Math.ceil(1000 / this.ticksPerSecond);
clearInterval(this.autoClickerLoop);
// Restart stats calculator
this.resetCalculator();
// Only use click multiplier while autoclicking
this.overrideClickAttack(this.autoClickState() ? this.autoClickMultiplier : 1);
if (this.autoClickState()) {
// Start autoclicker loop
this.autoClickerLoop = setInterval(() => EnhancedAutoClicker.autoClicker(), delay);
} else {
if (this.autoGymState()) {
GymRunner.autoRestart(false);
}
}
}
/**
* One tick of the autoclicker
* -Performs click attacks while in an active battle
* -Outside of battle, runs Auto Dungeon and Auto Gym
*/
static autoClicker() {
// Click while in a normal battle
if (App.game.gameState === GameConstants.GameState.fighting) {
Battle.clickAttack(this.autoClickMultiplier);
}
// ...or gym battle
else if (App.game.gameState === GameConstants.GameState.gym) {
GymBattle.clickAttack(this.autoClickMultiplier);
}
// ...or dungeon battle
else if (App.game.gameState === GameConstants.GameState.dungeon && DungeonRunner.fighting()) {
DungeonBattle.clickAttack(this.autoClickMultiplier);
}
// ...or temporary battle
else if (App.game.gameState === GameConstants.GameState.temporaryBattle) {
TemporaryBattleBattle.clickAttack(this.autoClickMultiplier);
}
// If not battling, progress through dungeon
else if (this.autoDungeonState()) {
this.autoDungeon();
}
// If not battling gym, start battling
else if (this.autoGymState()) {
this.autoGym();
}
// Turn off autoclicker in certain game states to avoid lag
else if (App.game.gameState === GameConstants.GameState.battleFrontier || App.game.gameState === GameConstants.GameState.safari) {
this.toggleAutoClick();
}
this.autoClickCalcTracker.ticks[0]++;
}
/**
* Override the game's function for Click Attack to:
* - make multiple clicks at once via multiplier
* - support changing the attack speed cap for higher tick speeds
*/
static overrideClickAttack(clickMultiplier = 1) {
// Set delay based on the autoclicker's tick rate
// (lower to give setInterval some wiggle room)
const delay = Math.min(Math.ceil(1000 / this.ticksPerSecond) - 10, 50);
Battle.clickAttack = function () {
// click attacks disabled and we already beat the starter
if (App.game.challenges.list.disableClickAttack.active() && player.regionStarters[GameConstants.Region.kanto]() != GameConstants.Starter.None) {
return;
}
const now = Date.now();
if (this.lastClickAttack > now - delay) {
return;
}
if (!this.enemyPokemon()?.isAlive()) {
return;
}
this.lastClickAttack = now;
// Don't autoclick more than needed for lethal
const clickDamage = App.game.party.calculateClickAttack(true);
var clicks = Math.min(clickMultiplier, Math.ceil(this.enemyPokemon().health() / clickDamage));
GameHelper.incrementObservable(App.game.statistics.clickAttacks, clicks);
this.enemyPokemon().damage(clickDamage * clicks);
if (!this.enemyPokemon().isAlive()) {
this.defeatPokemon();
}
}
}
/* Auto Gym */
/**
* Starts selected gym with auto restart enabled
*/
static autoGym() {
if (this.canStartAutoGym()) {
// Find all unlocked gyms in the current town
var gymList = player.town.content.filter((c) => (c.constructor.name == "Gym" && c.isUnlocked()));
if (gymList.length > 0) {
var gymIndex = Math.min(this.autoGymSelect, gymList.length - 1);
// Start in auto restart mode
GymRunner.startGym(gymList[gymIndex], true);
return;
}
}
// Disable if we aren't in a location with unlocked gyms
this.toggleAutoGym();
}
static canStartAutoGym() {
return App.game.gameState === GameConstants.GameState.gym || (App.game.gameState === GameConstants.GameState.town &&
player.town.content.some((c) => c.constructor.name == "Gym" && c.isUnlocked())
);
}
/**
* Override GymRunner built-in functions:
* -Add auto gym equivalent of gymWon() to save on performance by not loading town between
*/
static overrideGymRunner() {
GymRunner.gymWonNormal = GymRunner.gymWon;
// Version with free auto restart
GymRunner.gymWonAuto = function(gym) {
if (GymRunner.running()) {
GymRunner.running(false);
// First time defeating this gym
if (!App.game.badgeCase.hasBadge(gym.badgeReward)) {
gym.firstWinReward();
}
GameHelper.incrementObservable(App.game.statistics.gymsDefeated[GameConstants.getGymIndex(gym.town)]);
// Award money for defeating gym as we're auto clicking
App.game.wallet.gainMoney(gym.moneyReward);
if (GymRunner.autoRestart()) {
// Unlike the original function, autoclicker doesn't charge the player money
GymRunner.startGym(GymRunner.gymObservable(), GymRunner.autoRestart(), false);
return;
}
// Send the player back to the town they were in
player.town = gym.parent;
App.game.gameState = GameConstants.GameState.town;
}
}
// Only use our version when auto gym is running
GymRunner.gymWon = function(...args) {
if (EnhancedAutoClicker.autoClickState() && EnhancedAutoClicker.autoGymState()) {
GymRunner.gymWonAuto(...args);
} else {
GymRunner.gymWonNormal(...args);
}
}
}
/* Auto Dungeon */
/**
* Automatically begins and progresses through dungeons with multiple pathfinding options
*/
static autoDungeon() { // TODO more thoroughly test switching between modes and enabling/disabling within a dungeon
// Progress through dungeon
if (App.game.gameState === GameConstants.GameState.dungeon) {
if (DungeonRunner.fighting() || DungeonBattle.catching()) {
// Can't do anything while in a battle
return;
}
// Scan each new dungeon floor
if (this.autoDungeonTracker.ID !== DungeonRunner.dungeonID || this.autoDungeonTracker.floor !== DungeonRunner.map.playerPosition().floor) {
this.scanDungeon();
}
// If boss has been defeated, wait for the dungeon restart (delayed to allow quest updates)
if (this.autoDungeonTracker.dungeonFinished) {
return;
}
// Reset pathfinding coordinates to entrance
if (this.autoDungeonTracker.coords == null) {
this.autoDungeonTracker.coords = new Point(Math.floor(this.autoDungeonTracker.floorSize / 2), this.autoDungeonTracker.floorSize - 1, this.autoDungeonTracker.floor);
}
const floorMap = DungeonRunner.map.board()[this.autoDungeonTracker.floor];
// All targets visible, fight enemies / open chests then finish floor
if (floorMap[this.autoDungeonTracker.bossCoords.y][this.autoDungeonTracker.bossCoords.x].isVisible &&
!((this.autoDungeonChestMode || this.autoDungeonEncounterMode) && !this.autoDungeonTracker.floorExplored)) {
this.clearDungeon();
}
// Explore dungeon to reveal boss + any target tiles
else {
this.exploreDungeon();
}
}
// Begin dungeon
else if (this.canStartAutoDungeon()) {
// Enter dungeon if unlocked and affordable
DungeonRunner.initializeDungeon(player.town.dungeon);
} else {
// Disable if locked, can't afford entry cost, or there's no dungeon here
this.toggleAutoDungeon();
}
}
static canStartAutoDungeon() {
if (!(App.game.gameState === GameConstants.GameState.dungeon || (App.game.gameState === GameConstants.GameState.town && player.town instanceof DungeonTown))) {
return false;
}
if (DungeonGuides.hired()) {
return false;
}
const dungeon = player.town.dungeon;
return dungeon?.isUnlocked() && App.game.wallet.hasAmount(new Amount(dungeon.tokenCost, GameConstants.Currency.dungeonToken));
}
/**
* Scans current dungeon floor for relevant locations and pathfinding data
*/
static scanDungeon() {
// Reset / update tracker values
this.autoDungeonTracker.ID = DungeonRunner.dungeonID;
this.autoDungeonTracker.floor = DungeonRunner.map.playerPosition().floor;
this.autoDungeonTracker.floorSize = DungeonRunner.map.floorSizes[DungeonRunner.map.playerPosition().floor];
this.autoDungeonTracker.encounterCoords = [];
this.autoDungeonTracker.chestCoords = [];
this.autoDungeonTracker.coords = null;
this.autoDungeonTracker.targetCoords = null;
this.autoDungeonTracker.floorExplored = false;
this.autoDungeonTracker.floorFinished = false;
this.autoDungeonTracker.dungeonFinished = false;
// Scan for chest and boss coordinates
var dungeonBoard = DungeonRunner.map.board()[this.autoDungeonTracker.floor];
for (var y = 0; y < dungeonBoard.length; y++) {
for (var x = 0; x < dungeonBoard[y].length; x++) {
let tile = dungeonBoard[y][x];
if (tile.type() == GameConstants.DungeonTileType.enemy) {
this.autoDungeonTracker.encounterCoords.push(new Point(x, y, this.autoDungeonTracker.floor));
} else if (tile.type() == GameConstants.DungeonTileType.chest) {
let lootTier = Object.keys(baseLootTierChance).indexOf(tile.metadata.tier);
this.autoDungeonTracker.chestCoords.push({'xy': new Point(x, y, this.autoDungeonTracker.floor), 'tier': lootTier});
} else if (tile.type() == GameConstants.DungeonTileType.boss || tile.type() == GameConstants.DungeonTileType.ladder) {
this.autoDungeonTracker.bossCoords = new Point(x, y, this.autoDungeonTracker.floor);
}
}
}
// Sort chests by descending rarity
this.autoDungeonTracker.chestCoords.sort((a, b) => b.tier - a.tier);
// TODO find a more future-proof way to get flash distance
this.autoDungeonTracker.flashTier = DungeonFlash.tiers.findIndex(tier => tier === DungeonRunner.map.flash);
this.autoDungeonTracker.flashCols = [];
let flashRadius = DungeonRunner.map.flash?.playerOffset[0] ?? 0;
// Calculate minimum columns to fully reveal dungeon with Flash
if (flashRadius > 0) {
let cols = new Set();
cols.add(flashRadius);
let i = this.autoDungeonTracker.floorSize - flashRadius - 1;
while (i > flashRadius) {
cols.add(i);
i -= flashRadius * 2 + 1;
}
this.autoDungeonTracker.flashCols = [...cols].sort();
}
}
/**
* Explores dungeon to reveal tiles, skipping columns that can be efficiently revealed by Flash
*/
static exploreDungeon() {
const dungeonBoard = DungeonRunner.map.board()[this.autoDungeonTracker.floor];
var hasMoved = false;
var stuckInLoopCounter = 0;
while (!hasMoved) {
// End of column
if (this.autoDungeonTracker.coords.y == 0) {
if (this.autoDungeonTracker.coords.x <= 0 || this.autoDungeonTracker.coords.x === this.autoDungeonTracker.flashCols[0]) {
// Done exploring, clearDungeon() will take over from here
this.autoDungeonTracker.floorExplored = true;
return;
}
// Move to start of next column
this.autoDungeonTracker.coords.y = this.autoDungeonTracker.floorSize - 1;
if (this.autoDungeonTracker.coords.x >= this.autoDungeonTracker.floorSize - 1 || this.autoDungeonTracker.coords.x === this.autoDungeonTracker.flashCols.at(-1)) {
// Done with this side, move to other side of the entrance
this.autoDungeonTracker.coords.x = Math.floor(this.autoDungeonTracker.floorSize / 2) - 1;
} else {
// Move away from the entrance
this.autoDungeonTracker.coords.x += (this.autoDungeonTracker.coords.x >= Math.floor(this.autoDungeonTracker.floorSize / 2) ? 1 : -1);
}
// Dungeon has Flash unlocked, skip columns not in optimal flash pathing
} else if (this.autoDungeonTracker.flashTier > -1
&& this.autoDungeonTracker.coords.y == (this.autoDungeonTracker.floorSize - 1)
&& !this.autoDungeonTracker.flashCols.includes(this.autoDungeonTracker.coords.x)) {
// Move one column further from the entrance
this.autoDungeonTracker.coords.x += (this.autoDungeonTracker.coords.x >= Math.floor(this.autoDungeonTracker.floorSize / 2) ? 1 : -1);
}
// Move through current column
else {
this.autoDungeonTracker.coords.y -= 1;
}
// One move per tick to look more natural
if (!dungeonBoard[this.autoDungeonTracker.coords.y][this.autoDungeonTracker.coords.x].isVisited) {
DungeonRunner.map.moveToCoordinates(this.autoDungeonTracker.coords.x, this.autoDungeonTracker.coords.y);
hasMoved = true;
}
stuckInLoopCounter++;
if (stuckInLoopCounter > 100) {
console.warn(`Auto Dungeon got stuck in a loop while moving to tile \'${GameConstants.DungeonTileType[dungeonBoard[this.autoDungeonTracker.targetCoords.y][this.autoDungeonTracker.targetCoords.x].type()]}\' (${this.autoDungeonTracker.targetCoords.x}, ${this.autoDungeonTracker.targetCoords.y})`);
this.toggleAutoDungeon();
return;
}
}
}
/**
* Clears dungeon, visiting all desired tile types. Assumes dungeon has already been explored to reveal desired tiles.
*/
static clearDungeon() {
const dungeonBoard = DungeonRunner.map.board()[this.autoDungeonTracker.floor];
var hasMoved = false;
var stuckInLoopCounter = 0;
while (!hasMoved) {
// Choose a tile to move towards
if (!this.autoDungeonTracker.targetCoords) {
this.autoDungeonTracker.targetCoords = this.chooseDungeonTargetTile();
}
this.autoDungeonTracker.coords = this.pathfindTowardDungeonTarget();
if (!this.autoDungeonTracker.coords) {
console.warn(`Auto Dungeon could not find path to target tile \'${GameConstants.DungeonTileType[dungeonBoard[this.autoDungeonTracker.targetCoords.y][this.autoDungeonTracker.targetCoords.x].type()]}\' (${this.autoDungeonTracker.targetCoords.x}, ${this.autoDungeonTracker.targetCoords.y})`);
this.toggleAutoDungeon();
return;
}
// One move per tick to look more natural
if (!(dungeonBoard[this.autoDungeonTracker.coords.y][this.autoDungeonTracker.coords.x] === DungeonRunner.map.currentTile())) {
DungeonRunner.map.moveToCoordinates(this.autoDungeonTracker.coords.x, this.autoDungeonTracker.coords.y);
hasMoved = true;
}
// Target tile reached
if (this.autoDungeonTracker.coords.x === this.autoDungeonTracker.targetCoords.x && this.autoDungeonTracker.coords.y === this.autoDungeonTracker.targetCoords.y) {
this.autoDungeonTracker.targetCoords = null;
hasMoved = true;
// Take corresponding action
const tileType = DungeonRunner.map.currentTile().type();
if (tileType === GameConstants.DungeonTileType.enemy) {
// Do nothing, fights begin automatically
} else if (tileType === GameConstants.DungeonTileType.chest) {
DungeonRunner.openChest();
} else if (tileType === GameConstants.DungeonTileType.boss) {
if (this.autoDungeonTracker.floorFinished) {
DungeonRunner.startBossFight();
}
} else if (tileType === GameConstants.DungeonTileType.ladder) {
if (this.autoDungeonTracker.floorFinished) {
DungeonRunner.nextFloor();
}
} else {
console.warn(`Auto Dungeon targeted tile type ${GameConstants.DungeonTileType[tileType]}`);
}
}
stuckInLoopCounter++;
if (stuckInLoopCounter > 5) {
console.warn(`Auto Dungeon got stuck in a loop while moving to tile \'${GameConstants.DungeonTileType[dungeonBoard[this.autoDungeonTracker.targetCoords.y][this.autoDungeonTracker.targetCoords.x].type()]}\' (${this.autoDungeonTracker.targetCoords.x}, ${this.autoDungeonTracker.targetCoords.y})`);
this.toggleAutoDungeon();
return;
}
}
}
/**
* Chooses a target tile based on auto dungeon modes and dungeon progress
*/
static chooseDungeonTargetTile() {
const dungeonBoard = DungeonRunner.map.board()[this.autoDungeonTracker.floor];
let target = null;
while (!target) {
// Boss tile not yet unlocked
if (!dungeonBoard[this.autoDungeonTracker.bossCoords.y][this.autoDungeonTracker.bossCoords.x].isVisited) {
target = this.autoDungeonTracker.bossCoords;
}
// Encounters to fight
else if (this.autoDungeonEncounterMode && this.autoDungeonTracker.encounterCoords.length) {
// Skip already-fought encounters
let encounter = this.autoDungeonTracker.encounterCoords.pop();
if (dungeonBoard[encounter.y][encounter.x].type() == GameConstants.DungeonTileType.enemy) {
target = encounter;
} else {
continue;
}
}
// Chests to open
else if (this.autoDungeonChestMode && this.autoDungeonTracker.chestCoords.length && this.autoDungeonTracker.chestCoords[0].tier >= this.autoDungeonLootTier) {
target = this.autoDungeonTracker.chestCoords.shift().xy;
}
// Open visible chests of sufficient rarity
else if (this.autoDungeonAlwaysOpenRareChests && this.autoDungeonTracker.chestCoords.some((c) => c.tier >= this.autoDungeonLootTier && dungeonBoard[c.xy.y][c.xy.x].isVisible)) {
let index = this.autoDungeonTracker.chestCoords.findIndex((c) => c.tier >= this.autoDungeonLootTier && dungeonBoard[c.xy.y][c.xy.x].isVisible);
target = this.autoDungeonTracker.chestCoords[index].xy;
this.autoDungeonTracker.chestCoords.splice(index, 1);
}
// Time to fight the boss
else {
target = this.autoDungeonTracker.bossCoords;
this.autoDungeonTracker.floorFinished = true;
}
}
return target;
}
/**
* Find next tile on the shortest path towards target via breadth-first search
*/
static pathfindTowardDungeonTarget() {
const target = this.autoDungeonTracker.targetCoords;
let result = null;
if (!target) {
return result;
}
const queue = [target];
const visited = new Set(`${target.x}-${target.y}`);
while (queue.length) {
const p = queue.shift();
if (DungeonRunner.map.hasAccessToTile(p)) {
result = p;
break;
}
const adjTiles = [[p.x - 1, p.y], [p.x + 1, p.y], [p.x, p.y - 1], [p.x, p.y + 1]];
for (let [nx, ny] of adjTiles) {
// Enqueue valid tiles not yet considered
let xy = `${nx}-${ny}`;
if (0 <= nx && nx < this.autoDungeonTracker.floorSize && 0 <= ny && ny < this.autoDungeonTracker.floorSize && !visited.has(xy)) {
queue.push(new Point(nx, ny, target.floor));
visited.add(xy);
}
}
}
return result;
}
/**
* Restart dungeon, separate from dungeonWon function so it can be called with a delay
*/
static restartDungeon() {
if (App.game.gameState !== GameConstants.GameState.dungeon) {
return;
} else if (!EnhancedAutoClicker.canStartAutoDungeon()) {
MapHelper.moveToTown(DungeonRunner.dungeon.name);
return;
}
this.autoDungeonTracker.dungeonFinished = false;
// Clear old board to force map visuals refresh
DungeonRunner.map.board([]);
DungeonRunner.initializeDungeon(DungeonRunner.dungeon);
}
/**
* Override DungeonRunner built-in functions:
* -Add dungeon ID tracking to initializeDungeon() for easier mapping
* -Add auto dungeon equivalent of dungeonWon() to save on performance by restarting without loading town
*/
static overrideDungeonRunner() {
// Differentiate between dungeons for mapping
DungeonRunner.dungeonID = 0;
const oldInit = DungeonRunner.initializeDungeon.bind(DungeonRunner);
DungeonRunner.initializeDungeon = function (...args) {
DungeonRunner.dungeonID++;
return oldInit(...args);
}
DungeonRunner.dungeonWonNormal = DungeonRunner.dungeonWon;
// Version with integrated auto-restart to avoid loading town in between dungeons
DungeonRunner.dungeonWonAuto = function () {
if (!DungeonRunner.dungeonFinished()) {
DungeonRunner.dungeonFinished(true);
// First time clearing dungeon
if (!App.game.statistics.dungeonsCleared[GameConstants.getDungeonIndex(DungeonRunner.dungeon.name)]()) {
DungeonRunner.dungeon.rewardFunction();
}
GameHelper.incrementObservable(App.game.statistics.dungeonsCleared[GameConstants.getDungeonIndex(DungeonRunner.dungeon.name)]);
if (EnhancedAutoClicker.autoDungeonTracker.stopAfterFinishing) {
EnhancedAutoClicker.toggleAutoDungeon();
}
if (EnhancedAutoClicker.autoDungeonState() && EnhancedAutoClicker.canStartAutoDungeon()) {
// Restart the dungeon with a delay, giving Defeat Dungeon Boss quests time to update
EnhancedAutoClicker.autoDungeonTracker.dungeonFinished = true;
setTimeout(() => EnhancedAutoClicker.restartDungeon(), 50);
} else {
if (!DungeonRunner.hasEnoughTokens()) {
// Notify player if they've run out of tokens
Notifier.notify({
type: NotificationConstants.NotificationOption.warning,
title: 'Enhanced Auto Clicker',
message: `Auto Dungeon mode ran out of dungeon tokens.`,
timeout: GameConstants.DAY,
});
}
if (EnhancedAutoClicker.autoDungeonState()) {
EnhancedAutoClicker.toggleAutoDungeon();
}
// Can't continue, exit auto dungeon mode
MapHelper.moveToTown(DungeonRunner.dungeon.name);
}
}
}
// Only use our version when auto dungeon is running
DungeonRunner.dungeonWon = function (...args) {
if (EnhancedAutoClicker.autoClickState() && EnhancedAutoClicker.autoDungeonState()) {
DungeonRunner.dungeonWonAuto(...args);
} else {
DungeonRunner.dungeonWonNormal(...args);
}
}
}
/* Clicker statistics calculator */
/**
* Resets calculator loop, stats trackers, and calculator display
* -If auto clicker is running, restarts calculator
*/
static resetCalculator() {
clearInterval(this.autoClickCalcLoop);
this.autoClickCalcTracker.lastUpdate = [Date.now()];
this.autoClickCalcTracker.ticks = [0];
this.autoClickCalcTracker.clicks = [App.game.statistics.clickAttacks()];
this.autoClickCalcTracker.enemies = [App.game.statistics.totalPokemonDefeated()];
this.calculateAreaHealth();
document.getElementById('auto-click-info').innerHTML = `<div>${this.autoClickCalcEfficiencyDisplayMode == 0 ? 'Clicker Efficiency' : 'Ticks/s'}:<br><div id="tick-efficiency" style="font-weight:bold;">-</div></div>
<div>${this.autoClickCalcDamageDisplayMode == 0 ? 'Click Attacks/s' : 'DPS'}:<br><div id="clicks-per-second" style="font-weight:bold;">-</div></div>
<div>Req. ${this.autoClickCalcDamageDisplayMode == 0 ? 'Clicks' : 'Click Damage'}:<br><div id="req-clicks" style="font-weight:bold;">-</div></div>
<div>Enemies/s:<br><div id="enemies-per-second" style="font-weight:bold;">-</div></div>`;
if (this.autoClickState()) {
// Start calculator
this.autoClickCalcLoop = setInterval(() => EnhancedAutoClicker.calcClickStats(), 1000);
}
}
/**
* Displays the following statistics, averaged over the last (up to) ten seconds:
* -Percentage of ticksPerSecond the autoclicker is actually executing
* -Clicks per second or damage per second, depending on display mode
* -Required number of clicks or click attack damage to one-shot the current location, depending on display mode
* --Ignores dungeon bosses and chest health increases
* -Enemies defeated per second
* Statistics are reset when the player changes locations
*/
static calcClickStats() {
if (this.hasPlayerMoved()) {
// Reset statistics on area / game state change
this.resetCalculator();
return;
}
var elem;
var clickDamage = App.game.party.calculateClickAttack(true);
var actualElapsed = (Date.now() - this.autoClickCalcTracker.lastUpdate.at(-1)) / (1000 * this.autoClickCalcTracker.lastUpdate.length);
// Percentage of maximum ticksPerSecond
elem = document.getElementById('tick-efficiency');
var avgTicks = this.autoClickCalcTracker.ticks.reduce((a, b) => a + b, 0) / this.autoClickCalcTracker.ticks.length;
avgTicks = avgTicks / actualElapsed;
if (this.autoClickCalcEfficiencyDisplayMode == 1) {
// display ticks mode
elem.innerHTML = avgTicks.toLocaleString('en-US', {maximumFractionDigits: 1} );
elem.style.color = 'gold';
} else {
// display percentage mode
var tickFraction = avgTicks / this.ticksPerSecond;
elem.innerHTML = tickFraction.toLocaleString('en-US', {style: 'percent', maximumFractionDigits: 0} );
elem.style.color = 'gold';
}
// Average clicks/damage per second
elem = document.getElementById('clicks-per-second');
var avgClicks = (App.game.statistics.clickAttacks() - this.autoClickCalcTracker.clicks.at(-1)) / this.autoClickCalcTracker.clicks.length;
avgClicks = avgClicks / actualElapsed;
if (this.autoClickCalcDamageDisplayMode == 1) {
// display damage mode
var avgDPS = avgClicks * clickDamage;
elem.innerHTML = avgDPS.toLocaleString('en-US', {maximumFractionDigits: 0});
elem.style.color = 'gold';
} else {
// display click attacks mode
elem.innerHTML = avgClicks.toLocaleString('en-US', {maximumFractionDigits: 1});
elem.style.color = 'gold';
}
// Required clicks/click damage
elem = document.getElementById('req-clicks');
if (this.autoClickCalcTracker.areaHealth == 0) {
// can't meaningfully calculate a value for this area/game state
elem.innerHTML = '-';
elem.style.removeProperty('color');
} else if (this.autoClickCalcDamageDisplayMode == 1) {
// display damage mode
var reqDamage = this.autoClickCalcTracker.areaHealth;
elem.innerHTML = reqDamage.toLocaleString('en-US');
elem.style.color = (clickDamage * this.autoClickMultiplier >= reqDamage ? 'greenyellow' : 'darkred');
} else {
// display clicks mode
var reqClicks = Math.max((this.autoClickCalcTracker.areaHealth / clickDamage), 1);
reqClicks = Math.ceil(reqClicks * 10) / 10; // round up to one decimal point
elem.innerHTML = reqClicks.toLocaleString('en-US', {maximumFractionDigits: 1});
elem.style.color = (reqClicks <= this.autoClickMultiplier ? 'greenyellow' : 'darkred');