Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya246 authored Jan 7, 2022
1 parent 964cf01 commit dbf39b6
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 46 deletions.
25 changes: 17 additions & 8 deletions src/crawler_arena/CVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@

import arc.struct.*;
import mindustry.content.UnitTypes;
import mindustry.game.Team;
import mindustry.type.UnitType;

public class CVars{
public static int unitCap = 64;
public static float tipChance = 1f / 30000f;

public static int bossWave = 25;
public static int crawlersCeiling = 10000000;
public static int maxUnits = 2000;
public static int keepCrawlers = 800;
public static float crawlersExpBase = 2.71f;
public static float crawlersRamp = 1f / 2f;
public static float crawlersExpBase = 2.2f;
public static float crawlersRamp = 1f / 1.5f;
public static float extraCrawlersRamp = 1f / 150f;
public static float crawlersMultiplier = 1f / 10f;

public static float moneyExpBase = 2.71f;
public static float moneyRamp = 1f / 2f;
public static float moneyExpBase = 2.2f;
public static float moneyRamp = 1f / 1.5f;
public static float extraMoneyRamp = 1f / 4000f;
public static float moneyMultiplier = 6f;
public static float moneyMultiplier = 4f;

public static float enemySpeedBoost = 0.00002f;
public static float crawlerHealthBase = 60f;
public static float crawlerSpeedBase = 0.43f;
public static float statScalingNormal = 1f / 100f;
Expand All @@ -32,6 +35,7 @@ public class CVars{
public static float reinforcementWaveDelayBase = 50f;
public static float reinforcementWaveDelayRamp = 3f;

public static Team reinforcementTeam = Team.blue;
public static int reinforcementMinWave = 8;
public static int reinforcementSpacing = 2;
public static int reinforcementFactor = 3; // amount of reinforcements is integer-divided by this number
Expand All @@ -40,17 +44,21 @@ public class CVars{

public static float playerCrawlerHealth = 400f;
public static float playerCrawlerArmor = 10f;
public static float playerCrawlerCooldown = 60f;
public static float playerCrawlerCooldown = 80f;
public static float playerMonoHealth = 100000f;
public static float playerMonoArmor = 10f;
public static float playerMonoCooldown = 300f;
public static float playerPolyHealth = 500f;
public static float playerPolyArmor = 100f;
public static float playerPolyCooldown = 60f;
public static float playerOmuraHealth = 100000f;
public static float playerOmuraArmor = 20f;
public static float playerOmuraCooldown = 30f;

public static Seq<UnitType> enemyTypes = Seq.with(UnitTypes.toxopid, UnitTypes.arkyid, UnitTypes.spiroct, UnitTypes.atrax); // *MUST* be ordered from most to least powerful
public static ObjectIntMap enemyThresholds = new ObjectIntMap<>();
public static ObjectIntMap enemyCrawlerCuts = new ObjectIntMap<>();
public static ObjectIntMap<UnitType> enemyThresholds = new ObjectIntMap<>();
public static ObjectIntMap<UnitType> enemyCrawlerCuts = new ObjectIntMap<>();
public static ObjectFloatMap<UnitType> defaultEnemySpeeds = new ObjectFloatMap<>();
static {
enemyCrawlerCuts.putAll(UnitTypes.atrax, 10,
UnitTypes.spiroct, 50,
Expand All @@ -60,6 +68,7 @@ public class CVars{
UnitTypes.spiroct, 400,
UnitTypes.arkyid, 1000,
UnitTypes.toxopid, 20000);
enemyTypes.each(type -> defaultEnemySpeeds.put(type, type.speed));
}
public static float crawlerHealthRamp = 1f;
public static float crawlerSpeedRamp = 0.003f;
Expand Down
126 changes: 100 additions & 26 deletions src/crawler_arena/CrawlerArenaMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public class CrawlerArenaMod extends Plugin {
public static ObjectIntMap<UnitType> unitCosts = new ObjectIntMap<>();
public static ObjectIntMap<String> money = new ObjectIntMap<>();
public static ObjectMap<String, UnitType> units = new ObjectMap<>();
public static ObjectIntMap<String> unitIDs = new ObjectIntMap<>();
public static ObjectIntMap<Block> aidBlockAmounts = new ObjectIntMap<>();

public static Team reinforcementTeam = Team.blue;

public static long timer = Time.millis();

@Override
Expand All @@ -54,7 +53,7 @@ public void init(){
UnitTypes.scepter, 20000,
UnitTypes.reign, 250000,

UnitTypes.crawler, 2500,
UnitTypes.crawler, 7500,
UnitTypes.atrax, 250,
UnitTypes.spiroct, 1500,
UnitTypes.arkyid, 25000,
Expand All @@ -70,7 +69,7 @@ public void init(){
UnitTypes.oxynoe, 850,
UnitTypes.cyerce, 5000,
UnitTypes.aegires, 30000,
UnitTypes.navanax, 1500000,
UnitTypes.navanax, 350000,

UnitTypes.risso, 500,
UnitTypes.minke, 750,
Expand All @@ -79,7 +78,7 @@ public void init(){
UnitTypes.omura, 1500000,

UnitTypes.mono, 3750000,
UnitTypes.poly, 50000,
UnitTypes.poly, 100000,
UnitTypes.mega, 2500,
UnitTypes.quad, 25000,
UnitTypes.oct, 250000);
Expand All @@ -93,8 +92,8 @@ public void init(){

Blocks.mendProjector, 3,
Blocks.forceProjector, 2,
Blocks.repairTurret, 2,
Blocks.repairPoint, 4,
Blocks.repairTurret, 2,

Blocks.arc, 6,
Blocks.lancer, 4,
Expand Down Expand Up @@ -138,12 +137,12 @@ public void init(){
UnitTypes.reign.maxRange = 8000f;

UnitTypes.poly.maxRange = 2000f;
UnitTypes.omura.health = 45000f;

UnitTypes.reign.speed = 2.5f;

UnitTypes.poly.abilities.add(new UnitSpawnAbility(UnitTypes.poly, 300f, 0f, -32f));
UnitTypes.poly.health = 200f;
UnitTypes.poly.abilities.add(new UnitSpawnAbility(UnitTypes.poly, 480f, 0f, -32f));
UnitTypes.poly.health = 125f;
UnitTypes.poly.speed = 1.5f;

UnitTypes.arkyid.weapons.each(w -> {
if(w.bullet instanceof SapBulletType sap) sap.sapStrength = 0f;
Expand All @@ -159,7 +158,7 @@ public void init(){
state.rules.canGameOver = false;
state.rules.waveTimer = false;
state.rules.waves = true;
state.rules.unitCap = 128;
state.rules.unitCap = unitCap;
Call.setRules(state.rules);
});

Expand All @@ -176,19 +175,43 @@ public void init(){
Events.on(PlayerJoin.class, event -> {
if(!money.containsKey(event.player.uuid()) || !units.containsKey(event.player.uuid())){
Bundle.bundled(event.player, "events.join.welcome");
money.put(event.player.uuid(), 0);
money.put(event.player.uuid(), (int)(money.get(event.player.uuid(), 0) + Mathf.pow(moneyExpBase, 1f + wave * moneyRamp + Mathf.pow(wave, 2) * extraMoneyRamp) * moneyMultiplier));
units.put(event.player.uuid(), UnitTypes.dagger);
}else Bundle.bundled(event.player, "events.join.already-played");
respawnPlayer(event.player);
respawnPlayer(event.player);
}else{
Bundle.bundled(event.player, "events.join.already-played");
if(unitIDs.containsKey(event.player.uuid())){
Unit swapTo = Groups.unit.getByID(unitIDs.get(event.player.uuid()));
if(swapTo != null){
if(swapTo.getPlayer() != null && unitIDs.containsKey(swapTo.getPlayer().uuid())){
Player intruder = swapTo.getPlayer();
Unit swapIntruderTo = Groups.unit.getByID(unitIDs.get(intruder.uuid()));
if(swapIntruderTo != null){
intruder.unit(swapIntruderTo);
}else{
intruder.clearUnit();
}
}
Timer.schedule(() -> event.player.unit(swapTo), 1f);
}
}else{
respawnPlayer(event.player);
}
}
});

Events.run(Trigger.update, () -> {
if(gameIsOver) return;

if(!Groups.unit.contains(u -> u.team == state.rules.defaultTeam)){
gameIsOver = true;
Bundle.sendToChat("events.gameover.lose");
Timer.schedule(() -> Events.fire(new GameOverEvent(state.rules.waveTeam)), 2f);
if(wave > bossWave){
Bundle.sendToChat("events.gameover.win");
Timer.schedule(() -> Events.fire(new GameOverEvent(state.rules.defaultTeam)), 2f);
}else{
Bundle.sendToChat("events.gameover.lose");
Timer.schedule(() -> Events.fire(new GameOverEvent(state.rules.waveTeam)), 2f);
}
return;
}

Expand All @@ -210,9 +233,12 @@ public void init(){
respawnPlayer(p);
money.put(p.uuid(), (int)(money.get(p.uuid(), 0) + Mathf.pow(moneyExpBase, 1f + wave * moneyRamp + Mathf.pow(wave, 2) * extraMoneyRamp) * moneyMultiplier));
});
Groups.unit.each(u -> !u.isPlayer(), Unit::kill);
Groups.unit.each(u -> !u.isPlayer() && unitIDs.containsValue(u.id), Unit::kill);
waveIsOver = true;
}
if(!waveIsOver){
enemyTypes.each(type -> type.speed += enemySpeedBoost * Time.delta);
}
});

netServer.admins.addActionFilter(action -> action.type != Administration.ActionType.breakBlock && action.type != Administration.ActionType.placeBlock);
Expand Down Expand Up @@ -263,9 +289,13 @@ public void spawnReinforcements(){
}

public void respawnPlayer(Player p){
if(p.dead()){
if(p.unit().id != unitIDs.get(p.uuid(), -1)) p.unit().kill();
if(p.dead() || p.unit().id != unitIDs.get(p.uuid())){
Tile tile = world.tile(worldCenterX / 8 + Mathf.random(-3, 3), worldCenterY / 8 + Mathf.random(-3, 3));
UnitType type = units.get(p.uuid());
if(type == null){ // why does this happen
type = UnitTypes.dagger;
}
int x = tile.x;
if(!type.flying && tile.solid()){
while (x > 0 && world.tile(x, tile.y).solid()){
Expand All @@ -279,6 +309,7 @@ public void respawnPlayer(Player p){
Unit unit = type.spawn(x * tilesize, tile.worldy());
setUnit(unit);
p.unit(unit);
unitIDs.put(p.uuid(), unit.id);
return;
}

Expand Down Expand Up @@ -353,6 +384,7 @@ else if(wave == bossWave + 1){
totalTarget -= typeCount;
typeCounts.put(type, typeCount);
crawlers -= typeCount * enemyCrawlerCuts.get(type) / 2;
type.speed = defaultEnemySpeeds.get(type, 1f);
}
crawlers = Math.min(crawlers, keepCrawlers);

Expand Down Expand Up @@ -387,6 +419,16 @@ public void setUnit(Unit unit){
unit.apply(StatusEffects.overclock, Float.MAX_VALUE);
unit.apply(StatusEffects.overdrive, Float.MAX_VALUE);
if(unit.abilities.find(ability -> ability instanceof UnitSpawnAbility) instanceof UnitSpawnAbility ability) ability.spawnTime = playerPolyCooldown;
}else if(unit.type == UnitTypes.omura){
unit.maxHealth = playerOmuraHealth;
unit.health = unit.maxHealth;
unit.armor = playerOmuraArmor;
unit.apply(StatusEffects.boss);
unit.apply(StatusEffects.overclock, Float.MAX_VALUE);
unit.apply(StatusEffects.overdrive, Float.MAX_VALUE);
unit.abilities.each(ability -> ability instanceof UnitSpawnAbility, ability -> {
if(ability instanceof UnitSpawnAbility spawnAbility) spawnAbility.spawnTime = playerOmuraCooldown;
});
}
unit.controller(new FlyingAI());
}
Expand All @@ -399,41 +441,73 @@ public void reset(){
UnitTypes.crawler.health = crawlerHealthBase;
money.clear();
units.clear();
unitIDs.clear();
Groups.player.each(p -> {
money.put(p.uuid(), 0);
units.put(p.uuid(), UnitTypes.dagger);
respawnPlayer(p);
Timer.schedule(() -> respawnPlayer(p), 1f);
});
}

@Override
public void registerClientCommands(CommandHandler handler){
handler.<Player>register("upgrade", "<type>", "commands.upgrade.description", (args, player) -> {
handler.<Player>register("upgrade", "<type>", "Upgrade to another unit", (args, player) -> {
UnitType newUnitType = Seq.with(unitCosts.keys()).find(u -> u.name.equalsIgnoreCase(args[0]));
if(newUnitType == null){
Bundle.bundled(player, "commands.upgrade.unit-not-found");
return;
}

if(!player.dead() && player.unit().type == newUnitType){
Bundle.bundled(player, "commands.upgrade.already");
return;
}

if(money.get(player.uuid()) >= unitCosts.get(newUnitType)){
if(!player.dead() && player.unit().type == newUnitType){
Unit newUnit = newUnitType.spawn(player.x, player.y);
setUnit(newUnit);
money.put(player.uuid(), money.get(player.uuid()) - unitCosts.get(newUnitType));
Bundle.bundled(player, "commands.upgrade.already");
return;
}
Unit newUnit = newUnitType.spawn(player.x, player.y);
setUnit(newUnit);
player.unit(newUnit);
money.put(player.uuid(), money.get(player.uuid()) - unitCosts.get(newUnitType));
units.put(player.uuid(), newUnitType);
unitIDs.put(player.uuid(), newUnit.id);
Bundle.bundled(player, "commands.upgrade.success");

}else Bundle.bundled(player, "commands.upgrade.not-enough-money");
});

handler.<Player>register("information", "commands.information.description", (args, player) -> Bundle.bundled(player, "commands.info"));
handler.<Player>register("give", "<amount> <name...>", "Give money to another player", (args, player) -> {
Player giveTo = Groups.player.find(p -> Strings.stripColors(p.name).toLowerCase().contains(args[1].toLowerCase()));
if(giveTo == null){
Bundle.bundled(player, "commands.give.player-not-found");
return;
}

int amount;
try{
amount = Integer.parseInt(args[0]);
}catch(NumberFormatException e){
Bundle.bundled(player, "commands.give.invalid-amount");
return;
}
if(amount <= 0){
Bundle.bundled(player, "commands.give.invalid-amount");
return;
}

if(money.get(player.uuid()) >= amount){
money.put(player.uuid(), money.get(player.uuid()) - amount);
money.put(giveTo.uuid(), money.get(giveTo.uuid()) + amount);
Bundle.bundled(player, "commands.give.success", amount, giveTo.coloredName());
Bundle.bundled(giveTo, "commands.give.money-recieved", amount, player.coloredName());

}else Bundle.bundled(player, "commands.give.not-enough-money");
});

handler.<Player>register("info", "Show info about the Crawler Arena gamemode", (args, player) -> Bundle.bundled(player, "commands.info"));

handler.<Player>register("upgrades", "commands.upgrades.description", (args, player) -> {
handler.<Player>register("upgrades", "Show units you can upgrade to", (args, player) -> {
StringBuilder upgrades = new StringBuilder(Bundle.format("commands.upgrades.header", Bundle.findLocale(player)));
IntSeq sortedUnitCosts = unitCosts.values().toArray();
sortedUnitCosts.sort();
Expand Down
6 changes: 3 additions & 3 deletions src/crawler_arena/ReinforcementAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import mindustry.gen.Call;
import mindustry.gen.Payloadc;

import static mindustry.Vars.world;
import static mindustry.Vars.*;

public class ReinforcementAI extends GroundAI {

@Override
public void updateUnit(){
if(unit.team == CrawlerArenaMod.reinforcementTeam){
if(unit.team == CVars.reinforcementTeam){
unit.moveAt(new Vec2().trns(Mathf.atan2(world.width() * 4 - unit.x, world.height() * 4 - unit.y), unit.speed()));
if(Math.abs(unit.x - world.width() * 4) < 120 && unit instanceof Payloadc){
if(unit.x - world.width() * tilesize / 2f > -120f && unit instanceof Payloadc){
Call.payloadDropped(unit, unit.x, unit.y);
}
if(unit.x > world.width() * 7){
Expand Down
2 changes: 1 addition & 1 deletion src/crawler_arena/SwarmAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SwarmAI extends FlyingAI {
public float avoidRange2 = avoidRange * avoidRange;
public float swarmCollectRange = 1200f;
public float kiteRange = 0.8f;
public int swarmCount = 24;
public int swarmCount = 10;

@Override
public void updateMovement(){
Expand Down
Loading

0 comments on commit dbf39b6

Please sign in to comment.