-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMDGenesis.java
executable file
·210 lines (186 loc) · 7.24 KB
/
MDGenesis.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
import com.swath.*;
import com.swath.cmd.*;
/**
* @author Mind Dagger
*/
public class MDGenesis extends UserDefinedScript {
private Parameter planet;
private Parameter number;
private Parameter name;
private Parameter increment;
private Parameter startNumber;
private int owner;
private Parameter fuel;
private Parameter SD;
private Parameter twarp;
private Parameter atomic;
private Parameter adjacent;
private Planet[] p;
private PlanetClass[] planets;
public String getName() {
return "MD Genesis";
}
public boolean initScript() throws Exception {
if(!atPrompt(Swath.COMMAND_PROMPT)){
throw new Exception("Must be at Command Prompt.");
}
planets = Swath.getAllPlanetClasses();
planet = new Parameter("Type of planet to make.");
for(int i=0;i < planets.length; i++)
{
if(!planets[i].name().equals("")){
planet.addChoice(i, planets[i].name());
}
}
planet.setCurrentChoice(0);
fuel = new Parameter("Fuel Source");
fuel.setType(Parameter.CHOICE);
fuel.addChoice(0,"Port: "+Swath.sector.portName());
p = Swath.sector.planets();
for(int i = 0;i < p.length;i++){
fuel.addChoice(p[i].id(),"Planet #"+p[i].id()+" "+p[i].name());
}
fuel.setCurrentChoice(0);
if(Swath.you.alignment() < 1000){
twarp = new Parameter("Twarp next to SD for refills?");
}
else{
twarp = new Parameter("Twarp to SD for refills?");
}
twarp.setType(Parameter.BOOLEAN);
twarp.setBoolean(false);
SD = new Parameter("StarDock Sector?");
SD.setType(Parameter.INTEGER);
SD.setInteger(Swath.main.stardock());
SD.setIntegerRange(1,20000);
if(Swath.you.alignment() < 1000){
adjacent = new Parameter("Adjacent SD Sector:");
adjacent.setType(Parameter.INTEGER);
adjacent.setInteger(0);
adjacent.setIntegerRange(1,20000);
}
atomic = new Parameter("Number of torps and detonators to buy?");
atomic.setType(Parameter.INTEGER);
atomic.setInteger(1);
atomic.setIntegerRange(1,20);
number = new Parameter("How many to make?");
number.setType(Parameter.INTEGER);
number.setInteger(1);
number.setIntegerRange(1,80);
name = new Parameter("Name for planet(s)?");
name.setType(Parameter.STRING);
name.setString("xXx");
name.setMaxStringLength(15);
increment = new Parameter("Add Numbers To Name?");
increment.setType(Parameter.BOOLEAN);
increment.setBoolean(false);
startNumber = new Parameter("Start Numbers From:");
startNumber.setType(Parameter.INTEGER);
startNumber.setInteger(1);
startNumber.setIntegerRange(0,10000);
if(Swath.you.corporation() != null){
owner = Swath.CORPORATE;
}
else{
owner = Swath.PERSONAL;
}
registerParam(planet);
registerParam(name);
registerParam(number);
registerParam(increment);
registerParam(startNumber);
registerParam(twarp);
registerParam(fuel);
registerParam(atomic);
registerParam(SD);
if(Swath.you.alignment() < 1000){
registerParam(adjacent);
}
return true;
}
public boolean runScript() throws Exception {
int count = 0;
int startingSector = Swath.sector.sector();
DisplayCurrentInfo.exec(true);
if(twarp.getBoolean() && Swath.ship.fuel() < Swath.ship.holds()){
try{
JettisonCargo.exec();
}
catch(Exception e){
}
}
String planetName = name.getString();
PlanetClass currentPlanet = (PlanetClass)(planets[planet.getCurrentChoice()]);
boolean isDone = false;
if(Swath.ship.transWarpDrive() != Ship.NO_TWD && (Swath.ship.atomicDevices() <= 0 || Swath.ship.genesisTorpedos() <= 0) && twarp.getBoolean()){
refuel();
if(Swath.you.alignment() >= 1000 && startingSector != SD.getInteger()){
TransWarp.exec(SD.getInteger());
}
else if(Swath.you.alignment() < 1000 && Swath.sector.sector() != SD.getInteger() && !Swath.sector.isStarDock()){
TransWarp.exec(adjacent.getInteger());
Move.exec(SD.getInteger());
}
LandOnStarDock.exec(true);
BuyItems.exec(BuyItems.ATOMIC_DETONATORS,atomic.getInteger());
BuyItems.exec(BuyItems.GENESIS_TORPEDOES,atomic.getInteger());
LeaveStarDock.exec();
if(startingSector != SD.getInteger()){
TransWarp.exec(startingSector);
}
}
while(Swath.ship.atomicDevices() > 0 && Swath.ship.genesisTorpedos() > 0 && !isDone){
DisplayCurrentInfo.exec(true);
if(increment.getBoolean()){
planetName = name.getString()+" "+(count+startNumber.getInteger());
}
if(FastCreatePlanet.exec(planetName,currentPlanet,owner,"++ MD Genesis 1.0 ++")){
count++;
if(count >= number.getInteger()){
isDone = true;
}
}
if(Swath.ship.transWarpDrive() != Ship.NO_TWD && (Swath.ship.atomicDevices() <= 0 || Swath.ship.genesisTorpedos() <= 0) && twarp.getBoolean()){
refuel();
if(Swath.you.alignment() >= 1000 && startingSector != SD.getInteger()){
TransWarp.exec(SD.getInteger());
}
else if(Swath.you.alignment() < 1000 && Swath.sector.sector() != SD.getInteger() && !Swath.sector.isStarDock()){
TransWarp.exec(adjacent.getInteger());
Move.exec(SD.getInteger());
}
LandOnStarDock.exec(true);
BuyItems.exec(BuyItems.ATOMIC_DETONATORS,atomic.getInteger());
BuyItems.exec(BuyItems.GENESIS_TORPEDOES,atomic.getInteger());
LeaveStarDock.exec();
if(startingSector != SD.getInteger()){
TransWarp.exec(startingSector);
}
}
}
if(!isDone){
if(Swath.ship.atomicDevices() <= 0){
SendSSRadioMessage.exec("(MD Genesis) Out of atomic detonators.");
}
if(Swath.ship.genesisTorpedos() <= 0){
SendSSRadioMessage.exec("(MD Genesis) Out of genesis torpedos.");
}
}
return true;
}
private void refuel() throws Exception {
DisplayCurrentInfo.exec(true);
//Refuel
try{
Trade.exec(Swath.ship.emptyHolds(),0,0);
}
catch(Exception e){
UpgradePort.exec(Swath.FUEL_ORE,26);
try{
Trade.exec(Swath.ship.emptyHolds(),0,0);
}
catch(Exception f){
}
}
}
}