Skip to content

Commit d898215

Browse files
authored
Add files via upload
1 parent 460fc17 commit d898215

File tree

1 file changed

+64
-12
lines changed

1 file changed

+64
-12
lines changed

src/crawler_arena/CrawlerArenaMod.java

+64-12
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121
import mindustry.ai.types.*;
2222
import mindustry.entities.abilities.*;
2323
import ArenaAI.*;
24+
import ReinforcementAI.*;
2425
import mindustry.ai.Pathfinder;
2526
import arc.Core.*;
2627
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;
2732

2833
public class CrawlerArenaMod extends Plugin {
2934

@@ -34,6 +39,9 @@ public class CrawlerArenaMod extends Plugin {
3439
public static Seq<UnitType> upgradeableUnits = new Seq<>();
3540
public static ObjectMap<String, UnitType> upgradeableUnitNames = new ObjectMap<>();
3641
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<>();
3745
public static ObjectMap<UnitType, int[]> unitCosts = new ObjectMap<>();
3846
public static boolean waveIsOver = false;
3947
public static String unitNames = "";
@@ -46,13 +54,20 @@ public class CrawlerArenaMod extends Plugin {
4654

4755
@Override
4856
public void init(){
57+
Log.info("Crawler arena loading start...");
4958
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});
5059
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);
5160
upgradeableUnits.each(u -> {
52-
unitCosts.put(u, new int[]{unitCostsBase.get(0)[0]});
61+
unitCosts.put(u, unitCostsBase.get(0));
5362
upgradeableUnitNames.put(u.name, u);
5463
unitCostsBase.remove(0);
5564
});
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+
});
5671
upgradeableUnits.each(u -> {
5772
unitNames += u.name + " " + unitCosts.get(u)[0] + ", ";
5873
});
@@ -74,6 +89,7 @@ public void init(){
7489
UnitTypes.arkyid.maxRange = 8000;
7590
UnitTypes.toxopid.defaultController = ArenaAI::new;
7691
UnitTypes.toxopid.maxRange = 8000;
92+
UnitTypes.mega.defaultController = ReinforcementAI::new;
7793

7894
Events.on(WorldLoadEvent.class, e -> {
7995
if(Team.sharded.core() != null){
@@ -88,6 +104,7 @@ public void init(){
88104
worldCenterX = worldWidth / 2;
89105
worldCenterY = worldHeight / 2;
90106
firstWaveLaunched = false;
107+
waveIsOver = true;
91108
timer = 0f;
92109
newGame();
93110
});
@@ -118,23 +135,25 @@ public void init(){
118135

119136
Events.run(Trigger.update, () -> {
120137
boolean doGameOver = !Groups.unit.contains(u -> {return u.team == Team.sharded;});
121-
if(gameIsOver){
122-
return;
123-
} else if(doGameOver){
138+
if(doGameOver && !gameIsOver){
124139
Call.sendMessage("[red]You have lost.");
125140
gameIsOver = true;
126141
Timer.schedule(() -> {Events.fire(new GameOverEvent(Team.crux));}, 2);
127-
Groups.unit.each(u -> {u.kill();});
128-
return;
129142
};
130143
timer += Time.delta / 60;
131144
if(Mathf.chance(1 / 3000 * Time.delta)){
132145
Call.sendMessage("[cyan]Do /info to view info about upgrading.");
133146
};
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+
};
136156
respawnPlayers();
137-
Timer.schedule(() -> {nextWave();}, 10);
138157
waveIsOver = true;
139158
money.each((p, m) -> {m[0] += Mathf.pow(2.71f, 1f + wave / 2 + Mathf.pow(wave, 2) / 4000f) * 5f;});
140159
};
@@ -146,6 +165,7 @@ public void init(){
146165
};
147166
});
148167
});
168+
Log.info("Crawler arena loaded.");
149169
}
150170

151171
public void newGame(){
@@ -159,21 +179,53 @@ public void newGame(){
159179
};
160180
state.wave = 1;
161181
wave = 1;
162-
Timer.schedule(()->{gameIsOver = false;}, 1);
182+
Timer.schedule(()->{gameIsOver = false;}, 5);
163183
UnitTypes.crawler.speed = 0.43f;
164184
UnitTypes.crawler.health = 60;
165185
units.clear();
166186
money.clear();
167187
setupUnits();
188+
rewritePlayers();
168189
respawnPlayers();
169190
Call.sendMessage("[red]First wave in 15 seconds.");
170191
Timer.schedule(() -> {nextWave();}, 15);
171192
firstWaveLaunched = true;
172193
}
173194

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+
174223
public void setupUnits(){
175224
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+
};
177229
units.put(p.uuid(), UnitTypes.dagger.create(Team.sharded));
178230
money.put(p.uuid(), new float[]{10f});
179231
});
@@ -193,7 +245,7 @@ public void rewritePlayers(){
193245
public void respawnPlayers(){
194246
Groups.unit.each(u -> {
195247
if(findPlayer(u) == null){
196-
u.kill();
248+
u.destroy();
197249
};
198250
});
199251
Groups.player.each(p -> {

0 commit comments

Comments
 (0)