-
Notifications
You must be signed in to change notification settings - Fork 214
/
AutoTrimps2.js
218 lines (195 loc) · 10.3 KB
/
AutoTrimps2.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
// ==UserScript==
// @name AutoTrimpsV2+genBTC
// @namespace https://github.com/zininzinin/AutoTrimps
// @version 2.1.5.2-genbtc-12-23-2016+Modular
// @description try to take over the world!
// @author zininzinin, spindrjr, belaith, ishakaru, genBTC
// @include *trimps.github.io*
// @include *kongregate.com/games/GreenSatellite/trimps
// @grant none
// ==/UserScript==
var ATversion = '2.1.5.2-genbtc-12-23-2016+Modular';
////////////////////////////////////////////////////////////////////////////////
//Main Loader Initialize Function (loads first, load everything else)///////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////
var atscript = document.getElementById('AutoTrimps-script')
, base = 'https://zininzinin.github.io/AutoTrimps/'
, module = 'modules/'
;
if (atscript !== null) {
base = atscript.getAttribute('src').replace(/AutoTrimps2\.js$/, '');
}
//Load stuff needed to load other stuff:
document.head.appendChild(document.createElement('script')).src = base + module + 'utils.js';
function initializeAutoTrimps() {
loadPageVariables();
document.head.appendChild(document.createElement('script')).src = base + 'NewUI2.js';
document.head.appendChild(document.createElement('script')).src = base + 'Graphs.js';
//Load modules:
var modules = ['query', 'upgrades', 'heirlooms', 'buildings', 'jobs', 'equipment', 'gather', 'autostance', 'battlecalc', 'automaps', 'autobreedtimer', 'dynprestige', 'autofight', 'scryer', 'portal', 'other'];
for (var i=0,len=modules.length; i<len; i++) {
document.head.appendChild(document.createElement('script')).src = base + module + modules[i] + '.js';
}
//Autoperks
if (typeof(AutoPerks) === 'undefined')
document.head.appendChild(document.createElement('script')).src = base + module + 'autoperks.js';
else
debug('AutoPerks is now included in Autotrimps, please disable the tampermonkey script for AutoPerks to remove this message!', '*spinner3');
toggleSettingsMenu();
toggleSettingsMenu();
//
debug('AutoTrimps v' + ATversion + ' Loaded!', '*spinner3');
}
function printChangelog() {
tooltip('confirm', null, 'update', '\
<br>12/23 v2.1.5.2 - You are on the outdated zininzinin branch. Please Update to the genBTC branch\
<br><a href="https://github.com/genbtc/AutoTrimps/" target="#">Visit the github here</a>\
', 'cancelTooltip()', 'Script Update Notice ' + ATversion);
}
////////////////////////////////////////
//Main DELAY Loop///////////////////////
////////////////////////////////////////
//Magic Numbers/////////////////////////
var runInterval = 100; //How often to loop through logic
var startupDelay = 2000; //How long to wait for everything to load
setTimeout(delayStart, startupDelay);
function delayStart() {
initializeAutoTrimps();
printChangelog();
setTimeout(delayStartAgain, startupDelay);
}
function delayStartAgain(){
setInterval(mainLoop, runInterval);
setInterval(guiLoop, runInterval*10);
updateCustomButtons();
document.getElementById('Prestige').value = autoTrimpSettings.PrestigeBackup.selected;
//MODULESdefault = MODULES;
//MODULESdefault = Object.assign({}, MODULES);
MODULESdefault = JSON.parse(JSON.stringify(MODULES));
}
////////////////////////////////////////
//Global Main vars /////////////////////
////////////////////////////////////////
////////////////////////////////////////
var AutoTrimpsDebugTabVisible = true;
var enableDebug = true; //Spam console
var autoTrimpSettings = {};
var MODULES = {};
var MODULESdefault = {};
var autoTrimpVariables = {};
var bestBuilding;
var scienceNeeded;
var breedFire = false;
var shouldFarm = false;
var enoughDamage = true;
var enoughHealth = true;
var baseDamage = 0;
var baseBlock = 0;
var baseHealth = 0;
var preBuyAmt;
var preBuyFiring;
var preBuyTooltip;
var preBuymaxSplit;
var ATrunning = true;
var magmiteSpenderChanged = false;
var BAFsetting, oldBAFsetting;
var currentworld = 0;
var lastrunworld = 0;
var aWholeNewWorld = false;
var needGymystic = true;
//reset stuff that may not have gotten cleaned up on portal
function mainCleanup() {
lastrunworld = currentworld;
currentworld = game.global.world;
aWholeNewWorld = lastrunworld != currentworld;
//run once per portal:
if (currentworld == 1 && aWholeNewWorld) {
lastHeliumZone = 0;
zonePostpone = 0;
//for the dummies like me who always forget to turn automaps back on after portaling
if(getPageSetting('RunUniqueMaps') && !game.upgrades.Battle.done && autoTrimpSettings.AutoMaps.enabled == false)
settingChanged("AutoMaps");
}
}
////////////////////////////////////////
//Main LOGIC Loop///////////////////////
////////////////////////////////////////
////////////////////////////////////////
function mainLoop() {
if (ATrunning == false) return;
ATrunning = true;
if(game.options.menu.showFullBreed.enabled != 1) toggleSetting("showFullBreed"); //more detail
addbreedTimerInsideText.innerHTML = parseFloat(game.global.lastBreedTime/1000).toFixed(1) + 's'; //add hidden next group breed timer;
if (armycount.className != "tooltipadded") addToolTipToArmyCount();
mainCleanup();
if(getPageSetting('PauseScript') || game.options.menu.pauseGame.enabled || game.global.viewingUpgrades) return;
game.global.addonUser = true;
game.global.autotrimps = {
firstgiga: getPageSetting('FirstGigastation'),
deltagiga: getPageSetting('DeltaGigastation')
}
//auto-close breaking the world textbox
if(document.getElementById('tipTitle').innerHTML == 'The Improbability') cancelTooltip();
//auto-close the corruption at zone 181 textbox
if(document.getElementById('tipTitle').innerHTML == 'Corruption') cancelTooltip();
//auto-close the Spire notification checkbox
if(document.getElementById('tipTitle').innerHTML == 'Spire') cancelTooltip();
setTitle(); //set the browser title
setScienceNeeded(); //determine how much science is needed
//EXECUTE CORE LOGIC
if (getPageSetting('ExitSpireCell') >0) exitSpireCell(); //"Exit Spire After Cell" (other.js)
if (getPageSetting('WorkerRatios')) workerRatios(); //"Auto Worker Ratios" (jobs.js)
if (getPageSetting('BuyUpgrades')) buyUpgrades(); //"Buy Upgrades" (upgrades.js)
autoGoldenUpgrades(); //"AutoGoldenUpgrades" (other.js)
if (getPageSetting('BuyStorage')) buyStorage(); //"Buy Storage" (buildings.js)
if (getPageSetting('BuyBuildings')) buyBuildings(); //"Buy Buildings" (buildings.js)
needGymystic = false; //reset this after buyBuildings
if (getPageSetting('BuyJobs')) buyJobs(); //"Buy Jobs" (jobs.js)
if (getPageSetting('ManualGather2')<=2) manualLabor(); //"Auto Gather/Build" (gather.js)
else if (getPageSetting('ManualGather2')==3) manualLabor2(); //"Auto Gather/Build #2" (")
if (getPageSetting('AutoMaps')) autoMap(); //"Auto Maps" (automaps.js)
if (getPageSetting('GeneticistTimer') >= 0) autoBreedTimer(); //"Geneticist Timer" / "Auto Breed Timer" (autobreedtimer.js)
if (autoTrimpSettings.AutoPortal.selected != "Off") autoPortal(); //"Auto Portal" (hidden until level 40) (portal.js)
if (getPageSetting('AutoHeirlooms2')) autoHeirlooms2(); //"Auto Heirlooms 2" (heirlooms.js)
else if (getPageSetting('AutoHeirlooms')) autoHeirlooms();//"Auto Heirlooms" (")
if (getPageSetting('AutoUpgradeHeirlooms') && !heirloomsShown) autoNull(); //"Auto Upgrade Heirlooms" (heirlooms.js)
if (getPageSetting('TrapTrimps') && game.global.trapBuildAllowed && game.global.trapBuildToggled == false) toggleAutoTrap(); //"Trap Trimps"
if (getPageSetting('AutoRoboTrimp')) autoRoboTrimp(); //"AutoRoboTrimp" (other.js)
autoLevelEquipment(); //"Buy Armor", "Buy Armor Upgrades", "Buy Weapons", "Buy Weapons Upgrades" (equipment.js)
if (getPageSetting('UseScryerStance')) useScryerStance(); //"Use Scryer Stance" (scryer.js)
else if (getPageSetting('AutoStance')<=1) autoStance(); //"Auto Stance" (autostance.js)
else if (getPageSetting('AutoStance')==2) autoStance2(); //"Auto Stance #2" (")
BAFsetting = getPageSetting('BetterAutoFight');
if (BAFsetting==1) betterAutoFight(); //"Better Auto Fight" (autofight.js)
else if (BAFsetting==2) betterAutoFight2(); //"Better Auto Fight2" (")
else if (BAFsetting==0 && BAFsetting!=oldBAFsetting && game.global.autoBattle && game.global.pauseFight) pauseFight(); //turn on autofight on once when BAF is toggled off.
else if (BAFsetting==0 && game.global.world == 1 && game.global.autoBattle && game.global.pauseFight) pauseFight(); //turn on autofight on lvl 1 if its off.
else if (BAFsetting==0 && !game.global.autoBattle && game.global.soldierHealth == 0) betterAutoFight(); //use BAF as a backup for pre-Battle situations
oldBAFsetting = BAFsetting; //enables built-in autofight once when disabled
if (getPageSetting('DynamicPrestige2')>0) prestigeChanging2(); //"Dynamic Prestige" (dynprestige.js)
else autoTrimpSettings.Prestige.selected = document.getElementById('Prestige').value; //if we dont want to, just make sure the UI setting and the internal setting are aligned.
//Auto Magmite Spender
try {
if (getPageSetting('AutoMagmiteSpender2')==2 && !magmiteSpenderChanged)
autoMagmiteSpender(); //(other.js)
} catch (err) {
debug("Error encountered in AutoMagmiteSpender(Always): " + err.message,"general");
}
//Runs any user provided scripts - by copying and pasting a function named userscripts() into the Chrome Dev console. (F12)
if (userscriptOn) userscripts();
//rinse, repeat
return;
}
//GUI Updates happen on this thread, every 1000ms, concurrently
function guiLoop() {
updateCustomButtons();
}
// Userscript loader. write your own!
var userscriptOn = true; //controls the looping of userscripts and can be self-disabled
var globalvar0,globalvar1,globalvar2,globalvar3,globalvar4,globalvar5,globalvar6,globalvar7,globalvar8,globalvar9;
//left blank intentionally. the user will provide this. blank global vars are included as an example
function userscripts()
{
//insert code here:
}