-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacroSSM.java
executable file
·497 lines (433 loc) · 15.5 KB
/
MacroSSM.java
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
import com.swath.*;
import com.swath.cmd.*;
import java.io.*;
import java.util.*;
import java.text.*;
import javax.swing.*;
import java.awt.*;
//MacroSSM alpha 1/29/03
// ansi animation off
// silence all messages
// haggle off
// autokill figs turned on
// try to have a good amount of experience like minimum 5000+, ideally 8000+
//
// go browse your shipcategory in the computer's C command first.
// then the script will automatically know your maxholds and maxfighters.
// if youre in an alien ship you will probably have to enter maxholds and maxfighters manually.
// ---------------------------------------------------------------------------------------------
// Alpha version: sometimes it fake busts, and the script still does not recover after a fake bust.
// report bugs on swath discussion forum, post ideas for new features there too,
// and especially ideas on how to increase credits per hour, or how to catch fake busts...
// you will probably get podded if you use this script when other people are online
// but then again that goes for any wssm script...
// ---------------------------------------------------------------------------------------------
// regarding the status reports that are generated:
// loop credits per hour measures the earning potential of the current SSM loop.
// it is how much you would expect to make if you kept looping at these two ports
// indefinitely without busting for an hour straight. Use it like a speedometer.
// overall credits per hour measures how much you can actually expect to have at the end of 1 hour.
// it includes the time and credits wasted refurbing and hunting down evil pairs,
// and it wont really be useful till the script has been running 5-10 minutes or so.
// ---------------------------------------------------------------------------------------------
// thanks mongoose for the code to learn from, supg for his TWX WSSM script
// come play me unlimited at borg.exiled.org
public class MacroSSM extends UserDefinedScript {
private Parameter m_maxholds;
private Parameter m_maxfigs;
private Parameter m_stealfactor;
private Parameter m_class0port;
int scred,sexp,salign;
int lcred,lexp,lalign;
long stime,ltime;
final JLabel label1 = new JLabel("<html><b>Loop credits per hour:</b></html>");
final JLabel label2 = new JLabel("$<computing>");
final JLabel label3 = new JLabel("<html><b>Overall credits per hour:</b></html>");
final JLabel label4 = new JLabel("$<computing>");
final JLabel label5 = new JLabel("Credits at start of script:");
final JLabel label6 = new JLabel("$<computing>");
final JLabel label7 = new JLabel("Current credits:");
final JLabel label8 = new JLabel("$<computing>");
final JLabel label9 = new JLabel("Time elapsed in seconds");
final JLabel label10 = new JLabel("<computing>");
public String getName() {
return "Vito WorldSSM";
}
public String getDescription() {
return "This script will WorldSSM. It bypasses the Swath Command API\n"+
"and inlines macro strings for speed. 1/29/03";
}
public boolean initScript() throws Exception {
int recholds = 0;
int recfigs = 0;
if (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
PrintText.exec("\nStart this script at the command prompt\n");
return false;
}
try {
recholds = Swath.ship.shipCategory().maxHolds();
}
catch (Throwable t) {
PrintTrace.exec("Problem getting maxholds");
}
PrintTrace.exec("The ship category max is "+recholds+" holds.");
if (recholds < 10) {
recholds = 250;
}
try {
recfigs = Swath.ship.shipCategory().maxFighters();
}
catch (Throwable t) {
PrintTrace.exec("Problem getting maxfighters");
}
PrintTrace.exec("The ship category max is "+recfigs+" fighters.");
if (recfigs < 10) {
recfigs = 20000;
}
m_maxholds = new Parameter("Maximum holds your ship can have");
m_maxholds.setType(Parameter.INTEGER);
m_maxholds.setInteger(recholds);
registerParam(m_maxholds);
m_maxfigs = new Parameter("Maximum fighters your ship can have");
m_maxfigs.setType(Parameter.INTEGER);
m_maxfigs.setInteger(recfigs);
registerParam(m_maxfigs);
m_stealfactor = new Parameter("Steal factor");
m_stealfactor.setType(Parameter.INTEGER);
m_stealfactor.setInteger(25);
registerParam(m_stealfactor);
m_class0port = new Parameter("Class 0 port");
m_class0port.setType(Parameter.INTEGER);
m_class0port.setInteger(1);
registerParam(m_class0port);
return true;
}
public boolean endScript() throws Exception {
throw(new Exception());
}
public boolean runScript() throws Exception {
scred = Swath.you.credits();
sexp = Swath.you.experience();
salign = Swath.you.alignment();
//stime = Calendar.getInstance().getTimeInMillis();
stime = Calendar.getInstance().getTime().getTime();
PrintTrace.exec("Starting at "+Calendar.getInstance().getTime().toString());
int class0port = m_class0port.getInteger();
int maxholds = m_maxholds.getInteger();
Random r = new Random();
int prevsector = Swath.sector.sector();
//**************************STATUS WINDOW***************************
//credit to mongoose for his getsectors script
JPanel panel = Tools.createJPanel();
JFrame frame = Tools.createJFrame("MacroSSM Status", 1, 1);
panel.setLayout(new GridLayout(0, 2));
panel.add(label1);
panel.add(label2);
panel.add(label3);
panel.add(label4);
panel.add(label5);
panel.add(label6);
panel.add(label7);
panel.add(label8);
panel.add(label9);
panel.add(label10);
frame.getContentPane().add(panel);
frame.pack();
frame.setResizable(false);
frame.setVisible(true);
label6.setText(NumberFormat.getCurrencyInstance().format(scred));
label8.setText(NumberFormat.getCurrencyInstance().format(scred));
//*********************************************************************
while (true) {
if (maxholds > Swath.ship.holds()) {
VitoMove(class0port);
refurb();
int rnd = r.nextInt(Swath.main.sectors());
VitoMove(rnd);
}
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
SendString.exec("#SHSD/");
WaitForText.exec("AtmDt");
boolean goodneighbor = false;
int neighborsect = 0;
//Am I at an evil twin?
if (evilTwin(Swath.sector.sector())) {
for (int i=0; i < Swath.sector.warps(); i++) {
if (goodneighbor == false) {
if (evilTwin(Swath.sector.warpSectors()[i])) {
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
SendString.exec("CF"+Swath.sector.warpSectors()[i]+"\r"+Swath.sector.sector()+"\rQ");
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
while (Tools.findRoute(Swath.sector.warpSectors()[i],Swath.sector.sector()).length < 1) {
Thread.sleep(25);
}
if (Tools.findRoute(Swath.sector.warpSectors()[i],Swath.sector.sector()).length == 2) {
goodneighbor = true;
neighborsect = Swath.sector.warpSectors()[i];
}
}
}
}
}
//if I got a evil twin next to me
if (goodneighbor) {
//then SSM
boolean keepgoing = VitoSSM(Swath.sector.sector(),neighborsect);
if (keepgoing) {
}
else {
frame.dispose();
endScript();
}
}
else {
//credit to supg for this method in his script
int bestmove = 1;
int bestscore = 999999;
for (int i=0; i < Swath.sector.warps(); i++) {
int score = 999;
Sector n = Swath.getSector(Swath.sector.warpSectors()[i]);
// here's where you tally the score of sector n
if (n.spaceName().equals("The Federation.")) {
score = score + 99999;
}
if (n.anomaly()) {
score = score + 99999;
PrintTrace.exec("Anomaly in sector"+n.sector());
}
if ((n.warps() == 1) && (n.warpSectors()[0] == Swath.sector.sector())) {
score = score + 99999;
}
if ((n.density() == 100) && (n.portStatus() == Sector.PORT_AVAILABLE)) {
score = score - 2;
}
if (n.density() > 200) {
score = score + n.density();
}
if (n.sector() == prevsector) {
score = score + 75;
}
if (n.portStatus() == Sector.PORT_AVAILABLE) {
score = score - 2;
if (n.portInfo()[2] == Sector.BUYING) {
score = score - 6;
}
}
if (n.busted() != null) {
score = score + 100;
}
if (n.sector() == Swath.main.lastRobStealSector()) {
score = score + 50;
}
score = score - r.nextInt(10);
if (score < bestscore) {
bestscore = score;
bestmove = n.sector();
}
}
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep (25);
}
prevsector = Swath.sector.sector();
VitoMove(bestmove);
while (Swath.sector.sector() == prevsector) {
Thread.sleep(25);
}
}
}
}
public boolean evilTwin(int n) throws Exception {
boolean b = false;
Sector s = Swath.getSector(n);
//if its an xxB port
if (s.portInfo()[2] == Sector.BUYING) {
//if not busted
if (s.busted() == null) {
//if not last R/S sector
if (Swath.main.lastRobStealSector() != n) {
//if not fedspace
if (!(s.spaceName().equals("The Federation."))) {
//if theres no enemy figs
if (s.fighters() == 0 && (!(s.ftrOwner().isYou() || s.ftrOwner().isYourCorporation()))){
//if theres no mines
if (s.armidMines() == 0) {
SendString.exec("CR"+n+"\rQ");
WaitForText.exec("deactivated");
while (s.portAmounts()[2] == -1) {
Thread.sleep(25);
}
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
//if the port isnt drained
if (s.portAmounts()[2] > 250) {
b = true;
}
}
}
}
}
}
}
return b;
}
public void refurb() throws Exception {
int maxholds = m_maxholds.getInteger();
int maxfigs = m_maxfigs.getInteger();
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
SendString.exec("DPTYA"+(maxholds-Swath.ship.holds())+"\rYB"+Math.min((Swath.you.credits()/300),maxfigs - Swath.ship.fighters() )+"\rQD/");
WaitForText.exec("AtmDt");
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
return;
}
public void status() throws Exception {
int ecred = Swath.you.credits();
int eexp = Swath.you.experience();
int ealign = Swath.you.alignment();
//long etime = Calendar.getInstance().getTimeInMillis();
long etime = Calendar.getInstance().getTime().getTime();
label8.setText(NumberFormat.getCurrencyInstance().format(ecred));
int netcred = ecred - scred;
int netexp = eexp - sexp;
int netalign = ealign - salign;
long nettime = (etime - stime)/1000 ;
if (nettime < 1) {
nettime = 1;
}
label10.setText(nettime+" ");
String netcph = NumberFormat.getCurrencyInstance().format(3600 * (netcred/nettime));
label4.setText(netcph);
int thiscred = ecred - lcred;
int thisexp = eexp - lexp;
int thisalign = ealign - lalign;
long thistime = (etime - ltime)/1000 ;
if (thistime < 1) {
thistime = 1;
}
String thiscph = NumberFormat.getCurrencyInstance().format(3600 * (thiscred/thistime));
label2.setText(thiscph);
}
public void VitoMove(int dest) throws Exception{
int class0port=m_class0port.getInteger();
int sf=m_stealfactor.getInteger();
int here = Swath.main.currSector();
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
//Plot the course if not adjacent
if ((Tools.findRoute(here,dest).length > 2) || (Tools.findRoute(here,dest).length == 0)) {
SendString.exec("CF\r"+dest+"\rQ");
Thread.sleep(1000);
}
while (Swath.main.prompt() != Swath.COMMAND_PROMPT){
Thread.sleep(25);
}
int[] path = Tools.findRoute(here,dest);
for (int i=1; i<path.length; i++) {
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
Move.exec(path[i]);
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
if (Swath.ship.equipment() < Math.min(Swath.ship.holds(),Swath.you.experience()/sf)) {
if (Swath.sector.portStatus() == Sector.PORT_AVAILABLE) {
if (Swath.sector.portInfo()[2] == Sector.SELLING) {
if (Swath.sector.busted() == null) {
if (Swath.sector.sector() != Swath.main.lastRobStealSector() ) {
//then grab some equ
try {
SendString.exec("PR\rS3"+Math.min(Swath.ship.holds()-Swath.ship.equipment(),Swath.you.experience()/sf)+"\r/");
String str =WaitForText.exec("AtmDt",3000);
}
catch (Throwable t) {
if (t.toString().indexOf("Busted") > -1) {
VitoMove(class0port);
}
else {
endScript();
}
}
}
}
}
}
}
}
return;
}
public boolean VitoSSM(int s1, int s2) throws Exception{
int sf=m_stealfactor.getInteger();
Random r = new Random();
String str=" ";
String[] waitforme = {"aren't that many","Success"};
//Move to the other sector to help clear any possible crap
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
Move.exec(s2);
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
Thread.sleep(25);
}
try {
//Upgrade port and steal initial product if need be, otherwise just sell steal
if ((Swath.ship.equipment() + 5 < Math.min(Swath.ship.holds(),Swath.you.experience()/sf)) || (Swath.ship.fuel() > 0) || (Swath.ship.organics() > 0)) {
if (Swath.ship.fuel() > 0 || Swath.ship.organics() > 0) {
JettisonCargo.exec();
}
SendString.exec("<O3"+Math.min(((Swath.ship.holds()-Swath.ship.equipment())/10)+2,(Swath.you.experience()/(sf*10))+2)+"\rQPR\rS3"+Math.min(Swath.ship.holds(),Swath.you.experience()/sf)+"\r/");
str =WaitForText.exec(waitforme,3000);
while (str.indexOf("aren't that many") > -1) {
SendString.exec("O31\rQPR\rS3"+Math.min(Swath.ship.holds(),Swath.you.experience()/sf)+"\r/");
str = WaitForText.exec(waitforme,5000);
}
}
lcred = Swath.you.credits();
lexp = Swath.you.experience();
lalign = Swath.you.alignment();
//ltime = Calendar.getInstance().getTimeInMillis();
ltime = Calendar.getInstance().getTime().getTime();
//now start the loop
while (true) {
SendString.exec("<PT\r\r0\r0\rPR\rS3"+Math.min(Swath.ship.holds(),Swath.you.experience()/sf)+"\r/");
str =WaitForText.exec(waitforme,5000);
Thread.sleep(25);
while (str.indexOf("aren't that many") > -1) {
SendString.exec("O31\rQPR\rS3"+Math.min(Swath.ship.holds(),Swath.you.experience()/sf)+"\r/");
str = WaitForText.exec(waitforme,5000);
}
status();
}
}
catch (Throwable t) {
if (t.toString().indexOf("Busted") > -1) {
return true;
}
if (t.toString().indexOf("Timeout") > -1) {
PrintTrace.exec("Maybe this port is maxed out");
while (Swath.main.prompt() != Swath.COMMAND_PROMPT) {
PrintTrace.exec("Sleeping in VitoSSM Timeout");
Thread.sleep(25);
}
EnterComputer.exec();
PortReport.exec(Swath.sector.sector());
LeaveComputer.exec();
int rnd = r.nextInt(Swath.main.sectors());
VitoMove(rnd);
return true;
}
return false;
}
}
}