forked from YeOldeWH/MonsterMinigameWormholeWarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoplay.noUpdate.user.js
2444 lines (2029 loc) · 73.4 KB
/
autoplay.noUpdate.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 Ye Olde Megajump
// @namespace https://github.com/YeOldeWH/MonsterMinigameWormholeWarp
// @description A script that runs the Steam Monster Minigame for you. Now with megajump. Brought to you by the Ye Olde Wormhole Schemers and DannyDaemonic
// @version 7.0.3
// @match *://steamcommunity.com/minigame/towerattack*
// @match *://steamcommunity.com//minigame/towerattack*
// @grant none
// @updateURL https://raw.githubusercontent.com/YeOldeWH/MonsterMinigameWormholeWarp/master/autoplay.noUpdate.user.js
// @downloadURL https://raw.githubusercontent.com/YeOldeWH/MonsterMinigameWormholeWarp/master/autoplay.noUpdate.user.js
// ==/UserScript==
// IMPORTANT: Update the @version property above to a higher number such as 1.1 and 1.2 when you update the script! Otherwise, Tamper / Greasemonkey users will not update automatically.
(function(w) {
"use strict";
// OPTIONS
var clickRate = 20;
var logLevel = 1; // 5 is the most verbose, 0 disables all log
var wormholeOn100 = 1;
var likeNewOn100 = 0;
var medicOn100 = 1;
var clicksOnBossLevel = 0;
var upgThreshold = 100;
var minAbilityUsePercent = 0.3;
var enableAutoClicker = true;
var enableAutoUpgradeHP = true;
var enableAutoUpgradeClick = true;
var enableAutoUpgradeDPS = false;
var enableAutoUpgradeElemental = true;
var enableAutoPurchase = true;
var enableAutoBadgePurchase = true;
var removeInterface = getPreferenceBoolean("removeInterface", true); // get rid of a bunch of pointless DOM
var removeParticles = getPreferenceBoolean("removeParticles", true);
var removeFlinching = getPreferenceBoolean("removeFlinching", true);
var removeCritText = getPreferenceBoolean("removeCritText", false);
var removeAllText = getPreferenceBoolean("removeAllText", false);
var enableFingering = getPreferenceBoolean("enableFingering", true);
var disableRenderer = getPreferenceBoolean("disableRenderer", true);
var enableTrollTrack = getPreferenceBoolean("enableTrollTrack", false);
var enableElementLock = getPreferenceBoolean("enableElementLock", true);
var enableAutoRefresh = getPreferenceBoolean("enableAutoRefresh", typeof GM_info !== "undefined");
var enableChen = getPreferenceBoolean("enableChen", false);
var autoRefreshMinutes = 15; // Lowering to 15 minutes
var autoRefreshMinutesRandomDelay = 5; // Lowering to 5 minutes
var autoRefreshSecondsCheckLoadedDelay = 30;
var predictTicks = 0;
var predictJumps = 0;
var predictLastWormholesUpdate = 0;
// Auto refresh handler delay
var autoRefreshDuringBossDelayTotal = 0; // Total delay already passed
var autoRefreshDuringBossDelay = 60000; // Delay during the boss (ms)
var autoRefreshDuringBossDelayStep = 2500; // Delay 'step' (until we try again)
// DO NOT MODIFY
var isPastFirstRun = false;
var isAlreadyRunning = false;
var refreshTimer = null;
var currentClickRate = enableAutoClicker ? clickRate : 0;
var lastLevel = 0;
var lastLevelTimeTaken = [{
level: 0,
levelsGained: 0,
timeStarted: 0,
timeTakenInSeconds: 0
}];
var approxYOWHClients = 0;
var skipsLastJump = 0;
var updateSkips = false;
var trt_oldCrit = function() {};
var trt_oldPush = function() {};
var trt_oldRender = function() {};
var ELEMENTS = {
LockedElement: -1
};
var UPGRADES = {
LIGHT_ARMOR: 0,
AUTO_FIRE_CANNON: 1,
ARMOR_PIERCING_ROUND: 2,
DAMAGE_TO_FIRE_MONSTERS: 3,
DAMAGE_TO_WATER_MONSTERS: 4,
DAMAGE_TO_AIR_MONSTERS: 5,
DAMAGE_TO_EARTH_MONSTERS: 6,
LUCKY_SHOT: 7,
HEAVY_ARMOR: 8,
ADVANCED_TARGETING: 9,
EXPLOSIVE_ROUNDS: 10,
MEDICS: 11,
MORALE_BOOSTER: 12,
GOOD_LUCK_CHARMS: 13,
METAL_DETECTOR: 14,
DECREASE_COOLDOWNS: 15,
TACTICAL_NUKE: 16,
CLUSTER_BOMB: 17,
NAPALM: 18,
BOSS_LOOT: 19,
ENERGY_SHIELDS: 20,
FARMING_EQUIPMENT: 21,
RAILGUN: 22,
PERSONAL_TRAINING: 23,
AFK_EQUIPMENT: 24,
NEW_MOUSE_BUTTON: 25,
CYBERNETIC_ENHANCEMENTS: 26,
LEVEL_1_SENTRY_GUN: 27,
TITANIUM_MOUSE_BUTTON: 28
};
var ABILITIES = {
FIRE_WEAPON: 1,
CHANGE_LANE: 2,
RESPAWN: 3,
CHANGE_TARGET: 4,
MORALE_BOOSTER: 5,
GOOD_LUCK_CHARMS: 6,
MEDICS: 7,
METAL_DETECTOR: 8,
DECREASE_COOLDOWNS: 9,
TACTICAL_NUKE: 10,
CLUSTER_BOMB: 11,
NAPALM: 12,
RESURRECTION: 13,
CRIPPLE_SPAWNER: 14,
CRIPPLE_MONSTER: 15,
MAX_ELEMENTAL_DAMAGE: 16,
RAINING_GOLD: 17,
CRIT: 18,
PUMPED_UP: 19,
THROW_MONEY_AT_SCREEN: 20,
GOD_MODE: 21,
TREASURE: 22,
STEAL_HEALTH: 23,
REFLECT_DAMAGE: 24,
FEELING_LUCKY: 25,
WORMHOLE: 26,
LIKE_NEW: 27
};
var ENEMY_TYPE = {
SPAWNER: 0,
CREEP: 1,
BOSS: 2,
MINIBOSS: 3,
TREASURE: 4
};
var BOSS_DISABLED_ABILITIES = [
ABILITIES.MORALE_BOOSTER,
ABILITIES.GOOD_LUCK_CHARMS,
ABILITIES.TACTICAL_NUKE,
ABILITIES.CLUSTER_BOMB,
ABILITIES.NAPALM,
ABILITIES.CRIT,
ABILITIES.CRIPPLE_SPAWNER,
ABILITIES.CRIPPLE_MONSTER,
ABILITIES.MAX_ELEMENTAL_DAMAGE,
ABILITIES.REFLECT_DAMAGE,
ABILITIES.STEAL_HEALTH,
ABILITIES.THROW_MONEY_AT_SCREEN
];
var CONTROL = {
speedThreshold: 2000,
rainingRounds: 100,
disableGoldRainLevels: 500,
rainingSafeRounds: 9
};
var GAME_STATUS = {
LOBBY: 1,
RUNNING: 2,
OVER: 3
};
var wormholesUsedOnLevel = 0;
// Try to disable particles straight away,
// if not yet available, they will be disabled in firstRun
disableParticles();
// Define custom getters for document.hidden and the prefixed versions, so the game
// doesn't stop ticking in the background.
if (Object.defineProperty) {
var props = ['hidden', 'webkitHidden', 'mozHidden', 'msHidden'];
for (var i = 0; i < props.length; ++i)
Object.defineProperty(document, props[i], {value: false});
}
if(!getPreferenceBoolean("alertShown", false)) {
w.ShowAlertDialog(
'Ye Olde Megajump',
'<div style="color:#FF5252">This dialog will be shown just once, so please read through it.<br><br></div>' +
'<h3 style="color:yellow">This script does not lag your game,<br>we are limiting it to 1 frame per second to lower CPU usage.</h3>' +
'<p>We have multiple options to configure this script, and disabling FPS limiter is one of them.</p>' +
'<p><a href="https://github.com/YeOldeWH/MonsterMinigameWormholeWarp" target="_blank">You can report issues on GitHub</a></p>' +
'<p>Thanks and have fun!</p>'
).done(function(strButton) {
setPreference("alertShown", true);
});
}
function s() {
return w.g_Minigame.m_CurrentScene;
}
function firstRun() {
advLog("Starting YOWH Script.", 1);
trt_oldCrit = s().DoCritEffect;
trt_oldPush = s().m_rgClickNumbers.push;
trt_oldRender = w.g_Minigame.Render;
toggleFingering();
if(enableElementLock) {
lockElements();
}
if (enableAutoRefresh) {
autoRefreshPage(autoRefreshMinutes);
}
toggleRenderer();
// disable particle effects - this drastically reduces the game's memory leak
disableParticles();
// disable enemy flinching animation when they get hit
if(removeFlinching && w.CEnemy) {
w.CEnemy.prototype.TakeDamage = function() {};
w.CEnemySpawner.prototype.TakeDamage = function() {};
w.CEnemyBoss.prototype.TakeDamage = function() {};
}
if(removeCritText) {
toggleCritText();
}
if(removeAllText) {
toggleAllText();
}
// style
var styleNode = document.createElement('style');
styleNode.type = 'text/css';
var styleText = [
// Page content
".pagecontent {padding: 0}",
// Align abilities to the left
"#abilitiescontainer {text-align: left;}",
// Activitylog and ability list
"#activeinlanecontainer {padding-left: 10px;}",
"#activeinlanecontainer:hover {height: auto; background-image: radial-gradient(circle farthest-corner at 32px 0px, rgba(0,124,182,0.1), #11111C); padding-bottom: 10px; position:absolute; z-index: 1;}",
"#activeinlanecontainer:hover + #activitylog {margin-top: 88px;}",
"#activitylog {margin-top: 20px}",
// Hide leave game button
".leave_game_btn {display: none;}",
// Option menu
".game_options {height: auto;}",
".game_options .toggle_sfx_btn {margin: 6px 7px 0px 2px; float: right;}",
".game_options .toggle_music_btn {margin-right: 2px; float: right;}",
".options_box {background-color: #000; width: 940px; padding: 12px; box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.6); color: #EDEDED; margin: 4px auto 0; overflow: auto; float: left;}",
".options_box span.asterisk {color: #FF5252; font-size: 24px; line-height: 4px; vertical-align: bottom;}",
".options_column {-moz-column-count: 2; -webkit-column-count: 2; column-count: 2; width: 50%; float: left;}",
".options_column label {display: inline-block;}",
".options_column input {float: left;}",
".options_column input[type=number] {margin: 6px 5px 0 0; padding: 2px 0px 0px 4px;}",
".options_column input[name=setLogLevel] {width: 25px;}",
".options_column span.asterisk {line-height: 14px;}",
// Element lock box
".lock_elements_box {width: 165px; top: -76px; left: 303px; box-sizing: border-box; line-height: 1rem; padding: 7px 10px; position: absolute; color: #EDEDED;}",
// Breadcrumbs
".breadcrumbs {color: #bbb;}",
".bc_span {text-shadow: 1px 1px 0px rgba( 0, 0, 0, 0.3 );}",
".bc_room {color: #ACE191;}",
".bc_level {color: #FFA07A;}",
".bc_time {color: #9AC0FF;}",
".bc_worms {color: #FFF79A;}",
// Adjustments for hard to see areas on the new background
"#upgradesscroll, #activityscroll {opacity: 0.75;}",
".teamhealth {background: rgba( 240, 240, 255, 0.2 );}",
"#upgrades .title_upgrates {color: #67C;}",
// Always show ability count
".abilitytemplate > a > .abilityitemquantity {visibility: visible; pointer-events: none;}",
".tv_ui {background-image: url(http://i.imgur.com/vM1gTFY.gif);}",
"#Chen {position: absolute; bottom: 0px; left: 770px; width: 286px; height: 250px; background-image: url(//i.imgur.com/xMbQChA.png); }",
""
];
styleNode.textContent = styleText.join("");
document.head.appendChild(styleNode);
if( removeInterface ) {
var node = document.getElementById("global_header");
if (node && node.parentNode) {
node.parentNode.removeChild( node );
}
node = document.getElementById("footer");
if (node && node.parentNode) {
node.parentNode.removeChild( node );
}
node = document.getElementById("footer_spacer");
if (node && node.parentNode) {
node.parentNode.removeChild( node );
}
document.body.style.backgroundPosition = "0 0";
}
originalUpdateLog = CUI.prototype.UpdateLog;
// Set to match preferences
toggleTrackTroll();
toggleChen();
// Add cool background
$J('body.flat_page.game').css('background-image', 'url(http://i.imgur.com/P8TB236.jpg)');
// Add "players in game" label
var titleActivity = document.querySelector( '.title_activity' );
var playersInGame = document.createElement( 'span' );
playersInGame.innerHTML = '<span id=\"players_in_game\">0/1500</span> Players in room<br>';
titleActivity.insertBefore(playersInGame, titleActivity.firstChild);
ELEMENTS.PlayersInGame = document.getElementById("players_in_game");
var info_box = document.querySelector(".leave_game_helper");
info_box.className = "options_box";
var options_menu = document.querySelector(".game_options");
var sfx_btn = document.querySelector(".toggle_sfx_btn");
options_menu.insertBefore(info_box, sfx_btn);
info_box.innerHTML = '<b>OPTIONS</b>' + ((typeof GM_info !== "undefined") ? ' (v' + GM_info.script.version + ')' : '') + '<br>Settings marked with a <span class="asterisk">*</span> requires a refresh to take effect.<hr>';
var options1 = document.createElement("div");
options1.className = "options_column";
options1.appendChild(makeCheckBox("removeInterface", "Remove interface", removeInterface, handleEvent, true));
options1.appendChild(makeCheckBox("removeParticles", "Remove particle effects", removeParticles, handleEvent, true));
options1.appendChild(makeCheckBox("removeFlinching", "Remove flinching effects", removeFlinching, handleEvent, true));
options1.appendChild(makeCheckBox("removeCritText", "Remove crit text", removeCritText, toggleCritText, false));
options1.appendChild(makeCheckBox("removeAllText", "Remove all text", removeAllText, toggleAllText, false));
options1.appendChild(makeCheckBox("disableRenderer", "Limit frames per second to increase performance", disableRenderer, toggleRenderer, false));
options1.appendChild(makeCheckBox("enableChen", "Honk Honk?", enableChen, toggleChen, false));
info_box.appendChild(options1);
var options2 = document.createElement("div");
options2.className = "options_column";
if (typeof GM_info !== "undefined") {
options2.appendChild(makeCheckBox("enableAutoRefresh", "Enable AutoRefresh (mitigate memory leak)", enableAutoRefresh, toggleAutoRefresh, false));
}
options2.appendChild(makeCheckBox("enableFingering", "Enable targeting pointer", enableFingering, toggleFingering, false));
options2.appendChild(makeCheckBox("enableTrollTrack", "Enable tracking trolls", enableTrollTrack, toggleTrackTroll, false));
options2.appendChild(makeNumber("setLogLevel", "Change the log level (you shouldn't need to touch this)", logLevel, 0, 5, updateLogLevel));
info_box.appendChild(options2);
//Elemental upgrades lock
var ab_box = document.getElementById("abilities");
var lock_elements_box = document.createElement("div");
lock_elements_box.className = "lock_elements_box";
lock_elements_box.title = "To maximise team damage players should max only one element. But distributions of elements through people should be equal. So we calculated your element using your unique ID. Upgrade your element to make maximum performance or disable this checkbox.";
var lock_elements_checkbox = makeCheckBox("enableElementLock", "Lock element upgrades for more team dps", enableElementLock, toggleElementLock, false);
lock_elements_box.appendChild(lock_elements_checkbox);
ab_box.appendChild(lock_elements_box);
//Smack the TV Easter Egg
$J('#gamecontainer').append('<div id="tvsmacker" style="position: absolute; top: 360px; right: 640px; bottom: 360px; left: 640px;"></div>').append('<style>'
+ 'div#tvsmacker::before, div#tvsmacker::after {'
+ ' content: "Smack TV";'
+ ' color: orange;'
+ ' line-height: 45px;'
+ ' font-size: 14px;'
+ ' font-family: "Press Start 2P", "Lucida Console", Consolas, Arial;'
+ ' display: block;'
+ ' cursor: -moz-grab;'
+ ' cursor: -webkit-grab;'
+ ' cursor: grab;'
+ ' width: 720px;'
+ ' height: 45px;'
+ ' text-align: center;'
+ ' margin-top: -10px;'
+ ' margin-bottom: 10px;'
+ ' transition: linear 0.1s;'
+ '}'
+ 'div#tvsmacker::before {'
+ ' margin-left: 270px;'
+ ' transform: rotate(90deg);'
+ '}'
+ 'div#tvsmacker::after {'
+ ' margin-left: -990px;'
+ ' transform: rotate(270deg);'
+ '}'
+ 'div#tvsmacker:hover::before {'
+ ' margin-left: 290px;'
+ '}'
+ 'div#tvsmacker:hover::after {'
+ ' margin-left: -1010px;'
+ '}'
+ '</style>');
$J('#tvsmacker').click(function () { SmackTV(); });
enhanceTooltips();
isPastFirstRun = true;
}
// Valve's update
var originalUpdateLog = null;
// The trolltrack
var localUpdateLog = function( rgLaneLog ) {
var abilities = this.m_Game.m_rgTuningData.abilities;
var level = getGameLevel();
if( !this.m_Game.m_rgPlayerTechTree ) return;
var nHighestTime = 0;
for( var i=rgLaneLog.length-1; i >= 0; i--) {
var rgEntry = rgLaneLog[i];
if( isNaN( rgEntry.time ) ) rgEntry.time = this.m_nActionLogTime + 1;
if( rgEntry.time <= this.m_nActionLogTime ) continue;
// If performance concerns arise move the level check out and swap switch for if.
switch( rgEntry.type ) {
case 'ability':
if ( (level % 100 !== 0 && [26].indexOf(rgEntry.ability) > -1) || (level % 100 === 0 && [10, 11, 12, 15, 20].indexOf(rgEntry.ability) > -1) ) {
var ele = this.m_eleUpdateLogTemplate.clone();
$J(ele).data('abilityid', rgEntry.ability);
$J('.name', ele).text(rgEntry.actor_name).attr("style", "color: red; font-weight: bold;");
$J('.ability', ele).text(abilities[rgEntry.ability].name + " on level " + level);
$J('img', ele).attr('src', g_rgIconMap['ability_' + rgEntry.ability].icon);
$J(ele).v_tooltip({tooltipClass: 'ta_tooltip', location: 'top'});
this.m_eleUpdateLogContainer[0].insertBefore(ele[0], this.m_eleUpdateLogContainer[0].firstChild);
advLog(rgEntry.actor_name + " used " + s().m_rgTuningData.abilities[ rgEntry.ability ].name + " on level " + level, 1);
if(rgEntry.ability == ABILITIES.WORMHOLE) {
wormholesUsedOnLevel++;
}
}
break;
default:
console.log("Unknown action log type: %s", rgEntry.type);
console.log(rgEntry);
}
if(rgEntry.time > nHighestTime) nHighestTime = rgEntry.time;
}
if( nHighestTime > this.m_nActionLogTime ) this.m_nActionLogTime = nHighestTime;
var e = this.m_eleUpdateLogContainer[0];
while(e.children.length > 20 ) {
e.children[e.children.length-1].remove();
}
};
function disableParticles() {
if (w.CSceneGame) {
w.CSceneGame.prototype.DoScreenShake = function() {};
if(removeParticles) {
w.CSceneGame.prototype.SpawnEmitter = function(emitter) {
emitter.emit = false;
return emitter;
};
var particles = s().m_rgActiveParticles;
if(particles) {
if (particles[ 7 ]) {
particles[ 7 ][0].emit = false;
particles[ 7 ][1].emit = false;
}
if (particles[ 5 ]) {
particles[ 5 ][0].emit = false;
}
if (particles[ 6 ]) {
particles[ 6 ][0].emit = false;
particles[ 6 ][1].emit = false;
}
if (particles[ 8 ]) {
particles[ 8 ][0].emit = false;
particles[ 8 ][1].emit = false;
particles[ 8 ][2].emit = false;
}
if (particles[ 9 ]) {
particles[ 9 ][0].emit = false;
particles[ 9 ][1].emit = false;
}
}
}
}
}
function getTimeleft() {
var cTime = new Date();
var cHours = cTime.getUTCHours();
var cMins = cTime.getUTCMinutes();
var timeLeft = 60 - cMins;
if (cHours == 15) {
return timeLeft;
}
return 61;
}
function updateLevelTimeTracker() {
if (lastLevelTimeTaken[0].level !== getGameLevel()) {
lastLevelTimeTaken.unshift({level: getGameLevel(),
levelsGained: -1,
timeStarted: s().m_rgGameData.timestamp,
timeTakenInSeconds: -1});
var previousLevel = lastLevelTimeTaken[1];
previousLevel.levelsGained = getGameLevel() - previousLevel.level;
previousLevel.timeTakenInSeconds = s().m_rgGameData.timestamp - previousLevel.timeStarted;
}
if (lastLevelTimeTaken.length > 10) {
lastLevelTimeTaken.pop();
}
}
function MainLoop() {
var status = s().m_rgGameData.status;
if(status != GAME_STATUS.RUNNING) {
if(disableRenderer) {
s().Tick();
}
return;
}
var level = getGameLevel();
updateLevelTimeTracker();
updateApproxYOWHClients();
if (!isAlreadyRunning) {
isAlreadyRunning = true;
if( level !== lastLevel ) {
// Clear any unsent abilities still in the queue when our level changes
s().m_rgAbilityQueue.clear();
// update skips if applicable
if (updateSkips) {
skipsLastJump = level - lastLevel;
updateSkips = false;
}
wormholesUsedOnLevel = 0;
}
if (level % 100 == 0) {
// On a WH level, jump everyone with wormholes to lane 0, unless there is a boss there, in which case jump to lane 1.
var targetLane = 0;
// Check lane 0, enemy 0 to see if it's a boss
var enemyData = s().GetEnemy(0, 0).m_data;
if(typeof enemyData !== "undefined"){
var enemyType = enemyData.type;
if(enemyType == ENEMY_TYPE.BOSS) {
advLog('In lane 0, there is a boss, avoiding', 4);
targetLane = 1;
var enemyDataLaneOne = s().GetEnemy(1, 0).m_data;
var enemyDataLaneTwo = s().GetEnemy(2, 0).m_data;
if(typeof enemyDataLaneOne != "undefined" && typeof enemyDataLaneTwo == "undefined"){
//Lane 1 has monsters. Lane 2 is empty. Switch to lane 2 instead.
targetLane = 2;
}
}
}
if( s().m_rgPlayerData.current_lane != targetLane ) {
advLog('Moving player to wormhole lane ' + targetLane, 4);
s().TryChangeLane(targetLane); // put everyone in the same lane
}
updateSkips = true;
// GoGo Chen
honkingIntenstifys(true);
} else {
goToLaneWithBestTarget(level);
honkingIntenstifys(false);
}
attemptRespawn();
if (level % 100 !== 0 && w.SteamDB_Wormhole_Timer) {
w.clearInterval(w.SteamDB_Wormhole_Timer);
w.SteamDB_Wormhole_Timer = false;
}
var timeLeft = getTimeleft(); // Time left in minutes
if(level % 100 == 0){
useAbilitiesAt100();
} else if(timeLeft <= 15) {
useAllAbilities();
} else {
useAbilities(level);
}
updatePlayersInGame();
if( level !== lastLevel ) {
if (level % 100 === 0) {
enableAbility(ABILITIES.WORMHOLE);
enableAbility(ABILITIES.LIKE_NEW);
} else {
disableAbility(ABILITIES.WORMHOLE);
disableAbility(ABILITIES.LIKE_NEW);
}
lastLevel = level;
updateLevelInfoTitle(level);
refreshPlayerData();
}
// only AutoUpgrade after we've spend all badge points
if(s().m_rgPlayerTechTree) {
if(s().m_rgPlayerTechTree.badge_points === 0) {
useAutoUpgrade();
useAutoPurchaseAbilities();
}
else {
useAutoBadgePurchase();
}
}
var absoluteCurrentClickRate = 0;
if(currentClickRate > 0) {
var levelRainingMod = level % CONTROL.rainingRounds;
absoluteCurrentClickRate = level > CONTROL.speedThreshold && (levelRainingMod === 0 || 3 >= (CONTROL.rainingRounds - levelRainingMod)) ? 0 : currentClickRate;
var wormholesOnLine = getActiveAbilityLaneCount(ABILITIES.WORMHOLE);
var levelsUntilBoss = (CONTROL.rainingRounds - (level % CONTROL.rainingRounds));
if(levelsUntilBoss < 10 && (wormholesOnLine > levelsUntilBoss || wormholesUsedOnLevel > levelsUntilBoss)) {
advLog("Too much wormholes for throttle back. WH: " + wormholesOnLine + " / "+ wormholesUsedOnLevel+" > lvl: " + levelsUntilBoss, 4);
absoluteCurrentClickRate = currentClickRate;
}
else {
// throttle back as we approach
if(levelsUntilBoss < 5) {
absoluteCurrentClickRate = Math.round(currentClickRate * 0.1 * levelsUntilBoss);
}
}
//If at the boss level, dont click at all
if (level % CONTROL.rainingRounds == 0) {
absoluteCurrentClickRate = clicksOnBossLevel;
}
s().m_nClicks += absoluteCurrentClickRate;
}
s().m_nLastTick = false;
w.g_msTickRate = 1000;
var damagePerClick = s().CalculateDamage(
s().m_rgPlayerTechTree.damage_per_click,
s().m_rgGameData.lanes[s().m_rgPlayerData.current_lane].element
);
advLog("Ticked. Current clicks per second: " + absoluteCurrentClickRate + ". Current damage per second: " + (damagePerClick * absoluteCurrentClickRate), 4);
if(disableRenderer) {
s().Tick();
requestAnimationFrame(function() {
w.g_Minigame.Renderer.render(s().m_Container);
});
}
isAlreadyRunning = false;
if( absoluteCurrentClickRate > 0) {
var enemy = s().GetEnemy(
s().m_rgPlayerData.current_lane,
s().m_rgPlayerData.target);
if (enemy) {
displayText(
enemy.m_Sprite.position.x - (enemy.m_nLane * 440),
enemy.m_Sprite.position.y - 52,
"-" + w.FormatNumberForDisplay((damagePerClick * absoluteCurrentClickRate), 5),
"#aaf"
);
if( s().m_rgStoredCrits.length > 0 ) {
var rgDamage = s().m_rgStoredCrits.reduce(function(a,b) {
return a + b;
});
s().m_rgStoredCrits.length = 0;
s().DoCritEffect( rgDamage, enemy.m_Sprite.position.x - (enemy.m_nLane * 440), enemy.m_Sprite.position.y + 17, 'Crit!' );
}
var goldPerClickPercentage = s().m_rgGameData.lanes[s().m_rgPlayerData.current_lane].active_player_ability_gold_per_click;
if (goldPerClickPercentage > 0 && enemy.m_data.hp > 0) {
var goldPerSecond = enemy.m_data.gold * goldPerClickPercentage * absoluteCurrentClickRate;
s().ClientOverride('player_data', 'gold', s().m_rgPlayerData.gold + goldPerSecond);
s().ApplyClientOverrides('player_data', true);
advLog(
"Raining gold ability is active in current lane. Percentage per click: " + goldPerClickPercentage
+ "%. Approximately gold per second: " + goldPerSecond,
4
);
displayText(
enemy.m_Sprite.position.x - (enemy.m_nLane * 440),
enemy.m_Sprite.position.y - 17,
"+" + w.FormatNumberForDisplay(goldPerSecond, 5),
"#e1b21e"
);
}
}
}
}
}
function useAutoBadgePurchase() {
if(!enableAutoBadgePurchase) { return; }
// id = ability
// ratio = how much of the remaining badges to spend
//Note: this isn't an actual ratio, because badge points get reduced and the values don't add to 1
//For now, this is not a problem, but for stylistic reasons, should eventually be changed.
//Regular users buy ratio
if (likeNewOn100 == 1 && wormholeOn100 == 1) {
// High Level, "Waste Not" Users
var abilityPriorityList = [
{ id: ABILITIES.WORMHOLE, ratio: 0.5 },
{ id: ABILITIES.LIKE_NEW, ratio: 1 },
{ id: ABILITIES.CRIT, ratio: 1 },
{ id: ABILITIES.TREASURE, ratio: 1 },
{ id: ABILITIES.PUMPED_UP, ratio: 1 },
];
} else if (likeNewOn100 == 1) {
// Like New Buyers
var abilityPriorityList = [
{ id: ABILITIES.WORMHOLE, ratio: 0 },
{ id: ABILITIES.LIKE_NEW, ratio: 1 },
{ id: ABILITIES.CRIT, ratio: 1 },
{ id: ABILITIES.TREASURE, ratio: 1 },
{ id: ABILITIES.PUMPED_UP, ratio: 1 },
];
} else {
// Regular User Buy Ratio
var abilityPriorityList = [
{ id: ABILITIES.WORMHOLE, ratio: 1 },
{ id: ABILITIES.LIKE_NEW, ratio: 0 },
{ id: ABILITIES.CRIT, ratio: 1 },
{ id: ABILITIES.TREASURE, ratio: 1 },
{ id: ABILITIES.PUMPED_UP, ratio: 1 },
];
}
var badgePoints = s().m_rgPlayerTechTree.badge_points;
var abilityData = s().m_rgTuningData.abilities;
var abilityPurchaseQueue = [];
for (var i = 0; i < abilityPriorityList.length; i++) {
var id = abilityPriorityList[i].id;
var ratio = abilityPriorityList[i].ratio;
var cost = abilityData[id].badge_points_cost;
var portion = parseInt(badgePoints * ratio);
badgePoints -= portion;
while(portion >= cost) {
abilityPurchaseQueue.push(id);
portion -= cost;
}
badgePoints += portion;
}
s().m_rgPurchaseItemsQueue = s().m_rgPurchaseItemsQueue.concat(abilityPurchaseQueue);
s().m_UI.UpdateSpendBadgePointsDialog();
}
function toggleAutoBadgePurchase(event) {
var value = enableAutoBadgePurchase;
if(event !== undefined) {
value = handleCheckBox(event);
}
enableAutoBadgePurchase = value;
}
function useAllAbilities() {
for(var key in ABILITIES) {
if(ABILITIES[key] == ABILITIES.WORMHOLE) { continue; }
if(ABILITIES[key] == ABILITIES.LIKE_NEW) { continue; }
tryUsingAbility(ABILITIES[key]);
}
}
function isBossLevel(level) {
return level % 100 === 0
}
function updateApproxYOWHClients() {
var APPROXIMATE_WH_PER_PERSON_PER_SECOND = 10;
if (lastLevelTimeTaken.length < 2) {
return;
}
var lastLevel = lastLevelTimeTaken[1].level;
if (isBossLevel(lastLevel)) {
var levelsJumped = getGameLevel() - lastLevel;
var bossLevelTime = lastLevelTimeTaken[1].timeTakenInSeconds;
var possiblyInaccurateCount = Math.round(levelsJumped / (bossLevelTime * APPROXIMATE_WH_PER_PERSON_PER_SECOND));
if (possiblyInaccurateCount < 1500) {
approxYOWHClients = possiblyInaccurateCount;
} else {
console.log("Inaccurate count of YOWH Clients: ",possiblyInaccurateCount,
", levelsJumped: ", levelsJumped,
", bossLevelTime: ", bossLevelTime,
", lastLevelTimeTaken", lastLevelTimeTaken);
}
}
}
function levelsPerSec() {
if (lastLevelTimeTaken.length < 2) {
return 0;
}
var timeSpentOnBosses = 0;
var levelsGainedFromBosses = 0;
lastLevelTimeTaken.filter(function(levelInfo) {
return isBossLevel(levelInfo.level);
}).map(function(levelInfo) {
timeSpentOnBosses += levelInfo.timeTakenInSeconds;
levelsGainedFromBosses += levelInfo.levelsGained;
})
return Math.round(((getGameLevel() - lastLevelTimeTaken.slice(-1).pop().level - levelsGainedFromBosses)
/ (s().m_rgGameData.timestamp - lastLevelTimeTaken.slice(-1).pop().timeStarted - timeSpentOnBosses)) * 1000 ) / 1000;
}
//at level 100 spam WH, Like New, and medics, based on your role
function useAbilitiesAt100() {
if (wormholeOn100 && !w.SteamDB_Wormhole_Timer) {
advLog("At level % 100 = 0, forcing the use of wormholes nonstop", 2);
// Fire one off now, so we don't wait the interval
if (bHaveItem(ABILITIES.WORMHOLE)) triggerAbility(ABILITIES.WORMHOLE);
w.SteamDB_Wormhole_Timer = w.setInterval(function(){
if (getGameLevel() % 100 !== 0) {
// We're not on a *00 level anymore, stop!!
w.clearInterval(w.SteamDB_Wormhole_Timer);
w.SteamDB_Wormhole_Timer = false;
return;
}
if (bHaveItem(ABILITIES.WORMHOLE)) triggerAbility(ABILITIES.WORMHOLE); //wormhole
}, 100);
/* ^ DO NOT TOUCH THIS. The fundamental idea of this strat is that we get as many wormhole
jumps in as we can when we hit a boss level. The server seems capable of taking a max of ~10wh/s
feel free to use the following (hasty) code to manually verify in console:
// 1. Note down number of remaining wormholes
var dateStart = Date.now(); var interval = setInterval(function() { g_Server.UseAbilities($J.noop, $J.noop, {requested_abilities: [{ability: 26}]}); }, 100);
// 2. Count 10 roughly 10 mississippi's (or however long you want), you will get the exact time taken between start and stop
clearInterval(interval); console.log("Time: ", (dateStop - dateStart) / 1000);
// => 13.002
// 3. Click on any ability that can be used to refresh the abilities table from the server
// 4. Subtract the old wormhole count from the new wormhole count and divide by the time taken to get wh/s
Generally wh/s will be somewhere between 2-8 - I've never seen it go higher than 9.5, hence the 100ms resolution.
Changing this to 50ms will not give you 20 wh/s.
Changing this to 1000ms will leave wormholes on the table, so to speak.
Yes, there will be overflow, but this a GOOD thing. a few wormholes that overflow and get us *closer* to the
next level x00 boss helps!
*/
}
//This should equate to approximately 1.8 Like News per second
if (likeNewOn100) {
advLog("At level % 100 = 0, forcing the use of a like new", 2);
tryUsingAbility(ABILITIES.LIKE_NEW, false, true); //like new
} else {
// if people have LIKE_NEWs, there's no harm in letting them use them
if (Math.random() <= 0.05) {
tryUsingAbility(ABILITIES.LIKE_NEW, false, true);
}
}
if (medicOn100) {
advLog("At level % 100 = 0, forcing the use of a medic", 2);
tryUsingAbility(ABILITIES.MEDICS, false, true); //medics
}
}
function useAutoPurchaseAbilities() {
if(!enableAutoPurchase || autoupgrade_update_hilight) { return; }
var elms = document.querySelectorAll(".container_purchase > div:not([class~='cantafford'])");
if(elms.length === 0) { return; }
var pData = s().m_rgPlayerData;
[].forEach.call(elms, function(elm) {
if(elm.style.display !== "") { return; }
var idx = parseInt(elm.id.split('_')[1]);
if(s().GetUpgradeCost(idx) < pData.gold) {
s().TryUpgrade(elm.querySelector('.link'));
}
});
}
var autoupgrade_update_hilight = true;
var autoupgrade_hp_threshold = 0;
function useAutoUpgrade() {
if(!enableAutoUpgradeDPS
&& !enableAutoUpgradeClick
&& !enableAutoUpgradeHP
&& !enableAutoUpgradeElemental
) {
autoupgrade_update_hilight = false;
return;
}
// fixes hiligh when we tick before elements are created
if(!document.querySelector('.container_upgrades')
|| !document.querySelector('.container_upgrades').hasChildNodes()
) {
return;
}
var upg_order = [
UPGRADES.ARMOR_PIERCING_ROUND,
UPGRADES.LIGHT_ARMOR,
UPGRADES.AUTO_FIRE_CANNON,
UPGRADES.LUCKY_SHOT,
];
if(enableAutoUpgradeElemental && ELEMENTS.LockedElement !== -1) { upg_order.push(ELEMENTS.LockedElement+3); }
var upg_map = {};
upg_order.forEach(function(i) { upg_map[i] = {}; });
var pData = s().m_rgPlayerData;
var pTree = s().m_rgPlayerTechTree;
var cache = s().m_UI.m_rgElementCache;
// calculate hp threshold based on mob dps
var mob = s().m_rgEnemies[0];
if(!!mob) {
var threshold = mob.m_data.dps * 300 * 2.5;
if(threshold > autoupgrade_hp_threshold) {
autoupgrade_hp_threshold = threshold;
}
}
var upg_enabled = [