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 8, 2022
1 parent 5c2b8d3 commit bef2393
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 11 deletions.
11 changes: 10 additions & 1 deletion src/crawler_arena/CVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class CVars{
public static int reinforcementScaling = 2;
public static int reinforcementMax = 60 * reinforcementFactor;
public static float rareAidChance = 1f / 5f;
public static float blockDropChance = 1f / 25f;

public static ObjectIntMap<Block> aidBlockAmounts = new ObjectIntMap<>();
public static ObjectIntMap<Block> rareAidBlockAmounts = new ObjectIntMap<>();
Expand All @@ -52,14 +53,19 @@ public class CVars{
public static float playerCrawlerArmor = 10f;
public static float playerCrawlerCooldown = 60f;
public static float playerMonoHealth = 100000f;
public static float playerMonoArmor = 10f;
public static float playerMonoArmor = 20f;
public static float playerMonoCooldown = 300f;
public static Seq<UnitType> playerMonoSpawnTypes = Seq.with(UnitTypes.navanax, UnitTypes.toxopid, UnitTypes.corvus);
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 float ultraDaggerChance = 1f / 1000f;
public static float ultraDaggerHealth = 1000f;
public static float ultraDaggerArmor = 100f;
public static float ultraDaggerCooldown = 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<UnitType> enemyThresholds = new ObjectIntMap<>();
Expand Down Expand Up @@ -155,6 +161,9 @@ public class CVars{
public static float crawlerHealthRamp = 1f;
public static float crawlerSpeedRamp = 0.003f;

public static int bossT1Cap = 2;
public static int bossT2Cap = 5;
public static int bossT3Cap = 8;
public static float bossHealthMultiplier = 6f;
public static float bossScepterDelayBase = 1200f;
}
93 changes: 86 additions & 7 deletions src/crawler_arena/CrawlerArenaMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

import arc.Core;
import arc.Events;
import arc.graphics.Color;
import arc.math.Mathf;
import arc.struct.*;
import arc.util.*;
import arc.util.pooling.Pools;
import mindustry.ai.types.FlyingAI;
import mindustry.content.Blocks;
import mindustry.content.StatusEffects;
import mindustry.content.UnitTypes;
import mindustry.content.*;
import mindustry.entities.abilities.UnitSpawnAbility;
import mindustry.entities.bullet.SapBulletType;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.Team;
import mindustry.gen.*;
import mindustry.graphics.Pal;
import mindustry.mod.Plugin;
import mindustry.net.Administration;
import mindustry.type.UnitType;
import mindustry.type.*;
import mindustry.world.Block;
import mindustry.world.Tile;
import mindustry.world.blocks.payloads.BuildPayload;
import mindustry.world.blocks.storage.CoreBlock;

import static mindustry.Vars.*;
import static crawler_arena.CVars.*;
Expand Down Expand Up @@ -170,7 +172,7 @@ public void init(){
waveIsOver = true;
}
if(!waveIsOver){
enemyTypes.each(type -> type.speed += enemySpeedBoost * Time.delta);
enemyTypes.each(type -> type.speed += enemySpeedBoost * Time.delta * statScaling);
}
});

Expand Down Expand Up @@ -216,6 +218,35 @@ public void spawnReinforcements(){
block = Seq.with(aidBlockAmounts.keys()).random();
blocks.put(block, aidBlockAmounts.get(block));
}
if(block instanceof CoreBlock || Mathf.chance(blockDropChance)){
int range = 10;
int x = 0;
int y = 0;
boolean valid = false;
int j = 0;
while((!valid && j < 100) || world.tile(x, y) == null){
x = world.width() / 2 + Mathf.random(-range, range);
y = world.height() / 2 + Mathf.random(-range, range);
valid = true;
for(int xi = x - (block.size - 1) / 2; xi <= x + block.size / 2; xi++){
for(int yi = y - (block.size - 1) / 2; yi <= y + block.size / 2; yi++){
if(world.tile(xi, yi).build != null){
valid = false;
}
}
}
range++;
j++;
}
final float xf = x * tilesize;
final float yf = y * tilesize; // why did it require me to final these
Call.effect(Fx.blockCrash, xf, yf, 0, Color.white, block);
Time.run(100f, () -> {
Call.soundAt(Sounds.explosionbig, xf, yf, 1, 1);
Call.effect(Fx.spawnShockwave, xf, yf, block.size * 60f, Color.white);
world.tileWorld(xf, yf).setNet(block, state.rules.defaultTeam, 0);
});
}
}

blocks.each((block, amount) -> {
Expand Down Expand Up @@ -261,6 +292,31 @@ public void respawnPlayer(Player p){
}
}

public void applyStatus(Unit unit, float duration, int amount, StatusEffect... effects){
Seq<StatusEntry> entries = new Seq<>();
for(int i = 0; i < amount; i++){
for(StatusEffect effect : effects){
StatusEntry entry = Pools.obtain(StatusEntry.class, StatusEntry::new);
entry.set(effect, duration);
entries.add(entry);
}
}
var fields = unit.getClass().getFields();
for(var field : fields){
if(field.getName().equals("statuses")){
try{
if(field.get(unit) instanceof Seq s){
s.addAll(entries);
}
}catch(Exception e){
}
}
}
}
public void applyStatus(Unit unit, float duration, StatusEffect... effects){
applyStatus(unit, duration, 1, effects);
}

public void spawnEnemy(UnitType unit, int spX, int spY){
int sX = 32;
int sY = 32;
Expand All @@ -279,11 +335,25 @@ public void spawnEnemy(UnitType unit, int spX, int spY){

Unit u = unit.spawn(state.rules.waveTeam, sX, sY);
u.armor = 0f;
u.maxHealth *= (statScaling * healthMultiplierBase * (unit == UnitTypes.reign ? bossHealthMultiplier : 1f));
u.maxHealth *= statScaling * healthMultiplierBase;
u.health = u.maxHealth;
if(statScaling >= 2f){
applyStatus(u, Float.MAX_VALUE, (int)statScaling / 2, StatusEffects.overdrive, StatusEffects.overclock);
}

if(unit == UnitTypes.reign){
u.apply(StatusEffects.boss);
if(Groups.player.size() > bossT1Cap){
u.apply(StatusEffects.overclock);
}
if(Groups.player.size() > bossT2Cap){
u.apply(StatusEffects.overdrive);
}
if(Groups.player.size() > bossT3Cap){
applyStatus(u, Float.MAX_VALUE, StatusEffects.overdrive, StatusEffects.overclock);
}
u.maxHealth *= bossHealthMultiplier * Mathf.sqrt(Groups.player.size());
u.health = u.maxHealth;
u.abilities.add(new UnitSpawnAbility(UnitTypes.scepter, bossScepterDelayBase / Groups.player.size(), 0, -32));
}
}
Expand Down Expand Up @@ -311,6 +381,7 @@ else if(wave == bossWave + 1){
if(crawlers > crawlersCeiling && wave > bossWave){
crawlers = crawlersCeiling;
statScaling = 1f + (float)(wave - bossWave) * extraScalingRamp;
statScaling = Mathf.pow(statScaling, 1.5f);
}

UnitTypes.crawler.health += crawlerHealthRamp * wave * statScaling;
Expand Down Expand Up @@ -351,8 +422,10 @@ public void setUnit(Unit unit){
unit.maxHealth = playerMonoHealth;
unit.health = unit.maxHealth;
unit.armor = playerMonoArmor;
unit.abilities.add(new UnitSpawnAbility(UnitTypes.navanax, playerMonoCooldown, 0f, -8f));
unit.abilities.add(new UnitSpawnAbility(playerMonoSpawnTypes.random(), playerMonoCooldown, 0f, -8f));
unit.apply(StatusEffects.boss);
unit.apply(StatusEffects.overclock, Float.MAX_VALUE);
unit.apply(StatusEffects.overdrive, Float.MAX_VALUE);
}else if(unit.type == UnitTypes.poly){
unit.maxHealth = playerPolyHealth;
unit.health = unit.maxHealth;
Expand All @@ -371,6 +444,12 @@ public void setUnit(Unit unit){
unit.abilities.each(ability -> ability instanceof UnitSpawnAbility, ability -> {
if(ability instanceof UnitSpawnAbility spawnAbility) spawnAbility.spawnTime = playerOmuraCooldown;
});
}else if(unit.type == UnitTypes.dagger && Mathf.chance(ultraDaggerChance)){
unit.maxHealth = ultraDaggerHealth;
unit.health = unit.maxHealth;
unit.armor = ultraDaggerArmor;
unit.abilities.add(new UnitSpawnAbility(UnitTypes.dagger, ultraDaggerCooldown, 0f, -1f));
applyStatus(unit, Float.MAX_VALUE, 2, StatusEffects.overclock, StatusEffects.overdrive, StatusEffects.boss);
}
unit.controller(new FlyingAI());
}
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 @@ -3,8 +3,8 @@
import arc.math.Mathf;
import arc.math.geom.Vec2;
import mindustry.ai.types.GroundAI;
import mindustry.gen.Call;
import mindustry.gen.Payloadc;
import mindustry.gen.*;
import mindustry.world.blocks.payloads.*;

import static mindustry.Vars.*;

Expand All @@ -14,7 +14,7 @@ public class ReinforcementAI extends GroundAI {
public void updateUnit(){
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(unit.x - world.width() * tilesize / 2f > -120f && unit instanceof Payloadc){
if(world.width() * tilesize / 2f - unit.x < 120f){
Call.payloadDropped(unit, unit.x, unit.y);
}
if(unit.x > world.width() * 7){
Expand Down

0 comments on commit bef2393

Please sign in to comment.