21
21
import mindustry .ai .types .*;
22
22
import mindustry .entities .abilities .*;
23
23
import ArenaAI .*;
24
+ import ReinforcementAI .*;
24
25
import mindustry .ai .Pathfinder ;
25
26
import arc .Core .*;
26
27
import mindustry .content .StatusEffects ;
28
+ import mindustry .world .blocks .payloads .*;
29
+ import mindustry .world .Block ;
30
+ import mindustry .entities .comp .*;
31
+ import arc .util .Log ;
27
32
28
33
public class CrawlerArenaMod extends Plugin {
29
34
@@ -34,6 +39,9 @@ public class CrawlerArenaMod extends Plugin {
34
39
public static Seq <UnitType > upgradeableUnits = new Seq <>();
35
40
public static ObjectMap <String , UnitType > upgradeableUnitNames = new ObjectMap <>();
36
41
public static Seq <int []> unitCostsBase = new Seq <>();
42
+ public static Seq <Block > bringableBlocks = new Seq <>();
43
+ public static Seq <int []> bringableBlockAmounts = new Seq <>();
44
+ public static ObjectMap <Block , int []> aidBlockAmounts = new ObjectMap <>();
37
45
public static ObjectMap <UnitType , int []> unitCosts = new ObjectMap <>();
38
46
public static boolean waveIsOver = false ;
39
47
public static String unitNames = "" ;
@@ -46,13 +54,20 @@ public class CrawlerArenaMod extends Plugin {
46
54
47
55
@ Override
48
56
public void init (){
57
+ Log .info ("Crawler arena loading start..." );
49
58
unitCostsBase .addAll (new int []{200 }, new int []{200 }, new int []{325 }, new int []{75 }, new int []{400 }, new int []{1500 }, new int []{2750 }, new int []{1500 }, new int []{3000 }, new int []{1500 }, new int []{2500 }, new int []{12000 }, new int []{15000 }, new int []{30000 }, new int []{30000 }, new int []{30000 }, new int []{40000 }, new int []{175000 }, new int []{250000 }, new int []{325000 }, new int []{250000 }, new int []{1500000 });
50
59
upgradeableUnits .addAll (UnitTypes .mace , UnitTypes .atrax , UnitTypes .pulsar , UnitTypes .flare , UnitTypes .risso , UnitTypes .fortress , UnitTypes .quasar , UnitTypes .spiroct , UnitTypes .zenith , UnitTypes .mega , UnitTypes .crawler , UnitTypes .quad , UnitTypes .vela , UnitTypes .scepter , UnitTypes .antumbra , UnitTypes .arkyid , UnitTypes .sei , UnitTypes .eclipse , UnitTypes .reign , UnitTypes .toxopid , UnitTypes .corvus , UnitTypes .omura );
51
60
upgradeableUnits .each (u -> {
52
- unitCosts .put (u , new int []{ unitCostsBase .get (0 )[ 0 ]} );
61
+ unitCosts .put (u , unitCostsBase .get (0 ));
53
62
upgradeableUnitNames .put (u .name , u );
54
63
unitCostsBase .remove (0 );
55
64
});
65
+ bringableBlocks .addAll (Blocks .liquidSource , Blocks .swarmer , Blocks .cyclone , Blocks .tsunami , Blocks .powerSource , Blocks .lancer , Blocks .arc , Blocks .thoriumWallLarge , Blocks .mendProjector , Blocks .spectre , Blocks .overdriveDome );
66
+ bringableBlockAmounts .addAll (new int []{4 }, new int []{2 }, new int []{1 }, new int []{2 }, new int []{4 }, new int []{2 }, new int []{4 }, new int []{6 }, new int []{2 }, new int []{1 }, new int []{1 });
67
+ bringableBlocks .each (b -> {
68
+ aidBlockAmounts .put (b , bringableBlockAmounts .get (0 ));
69
+ bringableBlockAmounts .remove (0 );
70
+ });
56
71
upgradeableUnits .each (u -> {
57
72
unitNames += u .name + " " + unitCosts .get (u )[0 ] + ", " ;
58
73
});
@@ -74,6 +89,7 @@ public void init(){
74
89
UnitTypes .arkyid .maxRange = 8000 ;
75
90
UnitTypes .toxopid .defaultController = ArenaAI ::new ;
76
91
UnitTypes .toxopid .maxRange = 8000 ;
92
+ UnitTypes .mega .defaultController = ReinforcementAI ::new ;
77
93
78
94
Events .on (WorldLoadEvent .class , e -> {
79
95
if (Team .sharded .core () != null ){
@@ -88,6 +104,7 @@ public void init(){
88
104
worldCenterX = worldWidth / 2 ;
89
105
worldCenterY = worldHeight / 2 ;
90
106
firstWaveLaunched = false ;
107
+ waveIsOver = true ;
91
108
timer = 0f ;
92
109
newGame ();
93
110
});
@@ -118,23 +135,25 @@ public void init(){
118
135
119
136
Events .run (Trigger .update , () -> {
120
137
boolean doGameOver = !Groups .unit .contains (u -> {return u .team == Team .sharded ;});
121
- if (gameIsOver ){
122
- return ;
123
- } else if (doGameOver ){
138
+ if (doGameOver && !gameIsOver ){
124
139
Call .sendMessage ("[red]You have lost." );
125
140
gameIsOver = true ;
126
141
Timer .schedule (() -> {Events .fire (new GameOverEvent (Team .crux ));}, 2 );
127
- Groups .unit .each (u -> {u .kill ();});
128
- return ;
129
142
};
130
143
timer += Time .delta / 60 ;
131
144
if (Mathf .chance (1 / 3000 * Time .delta )){
132
145
Call .sendMessage ("[cyan]Do /info to view info about upgrading." );
133
146
};
134
- if (!Groups .unit .contains (u -> {return u .team == Team .crux ;}) && !waveIsOver && !gameIsOver ){
135
- Call .sendMessage ("[red]Next wave in 10 seconds." );
147
+ if (!Groups .unit .contains (u -> {return u .team == Team .crux ;}) && !waveIsOver ){
148
+ if (wave < 8 || wave % 4 == 0 ){
149
+ Call .sendMessage ("[red]Next wave in 10 seconds." );
150
+ Timer .schedule (() -> {nextWave ();}, 10 );
151
+ }else {
152
+ Call .sendMessage ("[yellow]Next wave in 40 seconds." );
153
+ Timer .schedule (() -> {spawnReinforcements ();}, 2 );
154
+ Timer .schedule (() -> {nextWave ();}, 40 );
155
+ };
136
156
respawnPlayers ();
137
- Timer .schedule (() -> {nextWave ();}, 10 );
138
157
waveIsOver = true ;
139
158
money .each ((p , m ) -> {m [0 ] += Mathf .pow (2.71f , 1f + wave / 2 + Mathf .pow (wave , 2 ) / 4000f ) * 5f ;});
140
159
};
@@ -146,6 +165,7 @@ public void init(){
146
165
};
147
166
});
148
167
});
168
+ Log .info ("Crawler arena loaded." );
149
169
}
150
170
151
171
public void newGame (){
@@ -159,21 +179,53 @@ public void newGame(){
159
179
};
160
180
state .wave = 1 ;
161
181
wave = 1 ;
162
- Timer .schedule (()->{gameIsOver = false ;}, 1 );
182
+ Timer .schedule (()->{gameIsOver = false ;}, 5 );
163
183
UnitTypes .crawler .speed = 0.43f ;
164
184
UnitTypes .crawler .health = 60 ;
165
185
units .clear ();
166
186
money .clear ();
167
187
setupUnits ();
188
+ rewritePlayers ();
168
189
respawnPlayers ();
169
190
Call .sendMessage ("[red]First wave in 15 seconds." );
170
191
Timer .schedule (() -> {nextWave ();}, 15 );
171
192
firstWaveLaunched = true ;
172
193
}
173
194
195
+ public void spawnReinforcements (){
196
+ Call .sendMessage ("[green]Aid package on its way." );
197
+ Seq <Unit > megas = new Seq <>();
198
+ ObjectMap <Block , int []> blocks = new ObjectMap <>();
199
+ for (int i = 0 ; i < wave ; i += 2 ){
200
+ megas .add (UnitTypes .mega .spawn (32 , worldCenterY + Mathf .random (-80 , 80 )));
201
+ };
202
+ int capacity = megas .size ;
203
+ int itemSources = Mathf .ceil (wave / 10f );
204
+ for (int i = 0 ; i < itemSources ; i ++){blocks .put (Blocks .itemSource , new int []{4 });};
205
+ capacity -= itemSources ;
206
+ for (int i = 0 ; i < capacity ; i ++){
207
+ int blockID = Mathf .random (0 , bringableBlocks .size - 1 );
208
+ Block block = bringableBlocks .get (blockID );
209
+ blocks .put (block , aidBlockAmounts .get (block ));
210
+ };
211
+ blocks .each ((b , a ) -> {
212
+ for (int i = 0 ; i < a [0 ]; i ++){
213
+ Unit mega = megas .get (0 );
214
+ if (mega instanceof Payloadc ){
215
+ Payloadc pay = (Payloadc )mega ;
216
+ pay .addPayload (new BuildPayload (b , Team .sharded ));
217
+ };
218
+ };
219
+ megas .remove (0 );
220
+ });
221
+ }
222
+
174
223
public void setupUnits (){
175
224
Groups .player .each (p -> {
176
- p .unit ().kill ();
225
+ UnitType type = p .unit ().type ;
226
+ if (type == UnitTypes .gamma || type == UnitTypes .beta || type == UnitTypes .alpha ){
227
+ p .unit ().destroy ();
228
+ };
177
229
units .put (p .uuid (), UnitTypes .dagger .create (Team .sharded ));
178
230
money .put (p .uuid (), new float []{10f });
179
231
});
@@ -193,7 +245,7 @@ public void rewritePlayers(){
193
245
public void respawnPlayers (){
194
246
Groups .unit .each (u -> {
195
247
if (findPlayer (u ) == null ){
196
- u .kill ();
248
+ u .destroy ();
197
249
};
198
250
});
199
251
Groups .player .each (p -> {
0 commit comments