diff --git a/src/crawler_arena/CVars.java b/src/crawler_arena/CVars.java index 41dda14..767bcca 100644 --- a/src/crawler_arena/CVars.java +++ b/src/crawler_arena/CVars.java @@ -1,12 +1,13 @@ package crawler_arena; import arc.struct.*; -import mindustry.content.UnitTypes; +import mindustry.content.*; import mindustry.game.Team; import mindustry.type.UnitType; +import mindustry.world.Block; public class CVars{ - public static int unitCap = 64; + public static int unitCap = 96; public static float tipChance = 1f / 30000f; public static int bossWave = 25; @@ -28,7 +29,7 @@ public class CVars{ public static float crawlerSpeedBase = 0.43f; public static float statScalingNormal = 1f / 100f; public static float extraScalingRamp = 1f / 2f; - public static float healthMultiplierBase = 1f / 4f; + public static float healthMultiplierBase = 1f / 5f; public static float firstWaveDelay = 15f; public static float waveDelay = 10f; @@ -41,10 +42,15 @@ public class CVars{ public static int reinforcementFactor = 3; // amount of reinforcements is integer-divided by this number public static int reinforcementScaling = 2; public static int reinforcementMax = 60 * reinforcementFactor; + public static float rareAidChance = 1f / 5f; + + public static ObjectIntMap aidBlockAmounts = new ObjectIntMap<>(); + public static ObjectIntMap rareAidBlockAmounts = new ObjectIntMap<>(); + public static ObjectIntMap unitCosts = new ObjectIntMap<>(); public static float playerCrawlerHealth = 400f; public static float playerCrawlerArmor = 10f; - public static float playerCrawlerCooldown = 80f; + public static float playerCrawlerCooldown = 60f; public static float playerMonoHealth = 100000f; public static float playerMonoArmor = 10f; public static float playerMonoCooldown = 300f; @@ -60,15 +66,91 @@ public class CVars{ public static ObjectIntMap enemyCrawlerCuts = new ObjectIntMap<>(); public static ObjectFloatMap defaultEnemySpeeds = new ObjectFloatMap<>(); static { + enemyTypes.each(type -> defaultEnemySpeeds.put(type, type.speed)); + enemyCrawlerCuts.putAll(UnitTypes.atrax, 10, UnitTypes.spiroct, 50, UnitTypes.arkyid, 1000, UnitTypes.toxopid, 20000); + enemyThresholds.putAll(UnitTypes.atrax, 100, UnitTypes.spiroct, 400, UnitTypes.arkyid, 1000, UnitTypes.toxopid, 20000); - enemyTypes.each(type -> defaultEnemySpeeds.put(type, type.speed)); + + unitCosts.putAll(UnitTypes.nova, 100, + UnitTypes.pulsar, 300, + UnitTypes.quasar, 2000, + UnitTypes.vela, 15000, + UnitTypes.corvus, 250000, + + UnitTypes.dagger, 25, + UnitTypes.mace, 200, + UnitTypes.fortress, 1500, + UnitTypes.scepter, 20000, + UnitTypes.reign, 250000, + + UnitTypes.crawler, 7500, + UnitTypes.atrax, 250, + UnitTypes.spiroct, 1500, + UnitTypes.arkyid, 25000, + UnitTypes.toxopid, 325000, + + UnitTypes.flare, 75, + UnitTypes.horizon, 250, + UnitTypes.zenith, 2500, + UnitTypes.antumbra, 18000, + UnitTypes.eclipse, 175000, + + UnitTypes.retusa, 400, + UnitTypes.oxynoe, 850, + UnitTypes.cyerce, 5000, + UnitTypes.aegires, 30000, + UnitTypes.navanax, 350000, + + UnitTypes.risso, 500, + UnitTypes.minke, 750, + UnitTypes.bryde, 5000, + UnitTypes.sei, 75000, + UnitTypes.omura, 1500000, + + UnitTypes.mono, 3750000, + UnitTypes.poly, 100000, + UnitTypes.mega, 2500, + UnitTypes.quad, 25000, + UnitTypes.oct, 250000); + + aidBlockAmounts.putAll(Blocks.liquidSource, 4, + Blocks.powerSource, 4, + Blocks.itemSource, 6, + Blocks.constructor, 1, + Blocks.deconstructor, 1, + + Blocks.thoriumWallLarge, 8, + Blocks.surgeWallLarge, 4, + + Blocks.mendProjector, 3, + Blocks.forceProjector, 2, + Blocks.repairPoint, 4, + Blocks.repairTurret, 2, + + Blocks.overdriveProjector, 1, + + Blocks.arc, 6, + Blocks.lancer, 4, + Blocks.ripple, 2, + Blocks.cyclone, 1, + Blocks.swarmer, 2, + Blocks.tsunami, 1, + Blocks.spectre, 1, + Blocks.foreshadow, 1); + + rareAidBlockAmounts.putAll(Blocks.largeConstructor, 1, + Blocks.coreNucleus, 1, + Blocks.groundFactory, 1, + Blocks.airFactory, 1, + Blocks.navalFactory, 1, + Blocks.overdriveDome, 4); } public static float crawlerHealthRamp = 1f; public static float crawlerSpeedRamp = 0.003f; diff --git a/src/crawler_arena/CrawlerArenaMod.java b/src/crawler_arena/CrawlerArenaMod.java index 112b555..10a3bd3 100644 --- a/src/crawler_arena/CrawlerArenaMod.java +++ b/src/crawler_arena/CrawlerArenaMod.java @@ -31,80 +31,14 @@ public class CrawlerArenaMod extends Plugin { public static int worldWidth, worldHeight, worldCenterX, worldCenterY, wave = 1; public static float statScaling = 1f; - public static ObjectIntMap unitCosts = new ObjectIntMap<>(); public static ObjectIntMap money = new ObjectIntMap<>(); public static ObjectMap units = new ObjectMap<>(); public static ObjectIntMap unitIDs = new ObjectIntMap<>(); - public static ObjectIntMap aidBlockAmounts = new ObjectIntMap<>(); public static long timer = Time.millis(); @Override public void init(){ - unitCosts.putAll(UnitTypes.nova, 100, - UnitTypes.pulsar, 300, - UnitTypes.quasar, 2000, - UnitTypes.vela, 15000, - UnitTypes.corvus, 250000, - - UnitTypes.dagger, 25, - UnitTypes.mace, 200, - UnitTypes.fortress, 1500, - UnitTypes.scepter, 20000, - UnitTypes.reign, 250000, - - UnitTypes.crawler, 7500, - UnitTypes.atrax, 250, - UnitTypes.spiroct, 1500, - UnitTypes.arkyid, 25000, - UnitTypes.toxopid, 325000, - - UnitTypes.flare, 75, - UnitTypes.horizon, 250, - UnitTypes.zenith, 2500, - UnitTypes.antumbra, 18000, - UnitTypes.eclipse, 175000, - - UnitTypes.retusa, 400, - UnitTypes.oxynoe, 850, - UnitTypes.cyerce, 5000, - UnitTypes.aegires, 30000, - UnitTypes.navanax, 350000, - - UnitTypes.risso, 500, - UnitTypes.minke, 750, - UnitTypes.bryde, 5000, - UnitTypes.sei, 75000, - UnitTypes.omura, 1500000, - - UnitTypes.mono, 3750000, - UnitTypes.poly, 100000, - UnitTypes.mega, 2500, - UnitTypes.quad, 25000, - UnitTypes.oct, 250000); - - aidBlockAmounts.putAll(Blocks.liquidSource, 4, - Blocks.powerSource, 4, - Blocks.itemSource, 6, - Blocks.constructor, 1, - - Blocks.thoriumWallLarge, 8, - Blocks.surgeWallLarge, 4, - - Blocks.mendProjector, 3, - Blocks.forceProjector, 2, - Blocks.repairPoint, 4, - Blocks.repairTurret, 2, - - Blocks.arc, 6, - Blocks.lancer, 4, - Blocks.ripple, 2, - Blocks.cyclone, 1, - Blocks.swarmer, 2, - Blocks.tsunami, 1, - Blocks.spectre, 1, - Blocks.foreshadow, 1); - content.units().each(u -> u.defaultController = FlyingAI::new); UnitTypes.crawler.defaultController = ArenaAI::new; UnitTypes.atrax.defaultController = ArenaAI::new; @@ -233,7 +167,6 @@ 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() && unitIDs.containsValue(u.id), Unit::kill); waveIsOver = true; } if(!waveIsOver){ @@ -275,8 +208,14 @@ public void spawnReinforcements(){ } for (int i = 0; i < megas.size; i++){ - Block block = Seq.with(aidBlockAmounts.keys()).get(Mathf.random(0, aidBlockAmounts.size - 1)); - blocks.put(block, aidBlockAmounts.get(block)); + Block block; + if(Mathf.chance(rareAidChance / aidBlockAmounts.size)){ + block = Seq.with(rareAidBlockAmounts.keys()).random(); + blocks.put(block, rareAidBlockAmounts.get(block)); + }else{ + block = Seq.with(aidBlockAmounts.keys()).random(); + blocks.put(block, aidBlockAmounts.get(block)); + } } blocks.each((block, amount) -> { @@ -289,8 +228,11 @@ public void spawnReinforcements(){ } public void respawnPlayer(Player p){ - if(p.unit().id != unitIDs.get(p.uuid(), -1)) p.unit().kill(); if(p.dead() || p.unit().id != unitIDs.get(p.uuid())){ + Unit oldUnit = Groups.unit.getByID(unitIDs.get(p.uuid())); + if(oldUnit != null && oldUnit != p.unit()){ + oldUnit.kill(); + } 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 @@ -451,18 +393,38 @@ public void reset(){ @Override public void registerClientCommands(CommandHandler handler){ - handler.register("upgrade", "", "Upgrade to another unit", (args, player) -> { + handler.register("upgrade", " [amount]", "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; } + int amount = 1; + if(args.length == 2){ + try{ + amount = Integer.parseInt(args[1]); + }catch(NumberFormatException e){ + Bundle.bundled(player, "exceptions.invalid-amount"); + return; + } + } + if(amount < 1){ + Bundle.bundled(player, "exceptions.invalid-amount"); + return; + } + + if(Groups.unit.count(u -> u.type == newUnitType && u.team == state.rules.defaultTeam) > unitCap - amount){ + Bundle.bundled(player, "commands.upgrade.too-many-units"); + 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)); + if(money.get(player.uuid()) >= unitCosts.get(newUnitType) * amount){ + if(!player.dead() && player.unit().type == newUnitType || amount > 1){ + for(int i = 0; i < amount; i++){ + Unit newUnit = newUnitType.spawn(player.x + Mathf.random(), player.y + Mathf.random()); + setUnit(newUnit); + } + money.put(player.uuid(), money.get(player.uuid()) - unitCosts.get(newUnitType) * amount); Bundle.bundled(player, "commands.upgrade.already"); return; } @@ -488,11 +450,11 @@ public void registerClientCommands(CommandHandler handler){ try{ amount = Integer.parseInt(args[0]); }catch(NumberFormatException e){ - Bundle.bundled(player, "commands.give.invalid-amount"); + Bundle.bundled(player, "exceptions.invalid-amount"); return; } if(amount <= 0){ - Bundle.bundled(player, "commands.give.invalid-amount"); + Bundle.bundled(player, "exceptions.invalid-amount"); return; } diff --git a/src/resources/bundles/bundle_en.properties b/src/resources/bundles/bundle_en.properties index a14f4d2..278c1a1 100644 --- a/src/resources/bundles/bundle_en.properties +++ b/src/resources/bundles/bundle_en.properties @@ -22,14 +22,17 @@ commands.upgrade.unit-not-found = [scarlet]Unit not found! Use [orange]/upgrades commands.upgrade.already = [green]Additional unit purchased. commands.upgrade.success = [green]Upgrade successful! commands.upgrade.not-enough-money = [scarlet]You don't have enough money to upgrade to this unit! +commands.upgrade.too-many-units = [scarlet]There are too many units of that type on the map. + commands.upgrades.header = [accent]Available units to upgrade:\n[] commands.give.player-not-found = [scarlet]Player not found! Note that you don't have to type the full name. -commands.give.invalid-amount = [scarlet]Invalid amount. commands.give.success = [yellow]{0} [green]coins given to {1}[green]. commands.give.money-recieved = [yellow]{0} [green]coins recieved from {1}[green]. commands.give.not-enough-money = [scarlet]You don't have enough money. +exceptions.invalid-amount = [scarlet]Invalid amount. + commands.info = [accent]Money is gained in equal amounts for every player after a wave ends.\ \nMoney can only decrease by buying units.\ \nYour money is displayed at the top of the screen.\ diff --git a/src/resources/bundles/bundle_ru.properties b/src/resources/bundles/bundle_ru.properties index e32f12a..39d9f52 100644 --- a/src/resources/bundles/bundle_ru.properties +++ b/src/resources/bundles/bundle_ru.properties @@ -22,14 +22,17 @@ commands.upgrade.unit-not-found = [scarlet]Юнит не найден! Испо commands.upgrade.already = [scarlet]Дополнительный юнит куплен. commands.upgrade.success = [green]Юнит успешно улучшен! commands.upgrade.not-enough-money = [scarlet]На балансе недостаточно средств для приобретения этого юнита! +commands.upgrade.too-many-units = [scarlet]На карте слишком много юнитов этого типа. + commands.upgrades.header = [accent]Список доступных юнитов для прокачки:\n[] commands.give.player-not-found = [scarlet]Игрок не найден! Учтите, что писать полное имя не нужно. -commands.give.invalid-amount = [scarlet]Неподходящее количество. commands.give.success = [yellow]{0} [green]монет передано {1}[green]. commands.give.money-recieved = [yellow]{0} [green]монет получено от {1}[green]. commands.give.not-enough-money = [scarlet]На балансе недостаточно средств. +exceptions.invalid-amount = [scarlet]Неподходящее количество. + commands.info = [accent]После каждой волны всем игрокам начисляется одинаковое количество монет.\ \nМонеты можно потратить на прокачку юнитов.\ \nТвой баланс отображается вверху экрана.\