New waves for sectors, quite possibly broken

This commit is contained in:
Anuken 2020-10-08 19:33:54 -04:00
parent 68f11df55d
commit e2b58528d0
2 changed files with 57 additions and 41 deletions

View file

@ -1,5 +1,6 @@
package mindustry.game;
import arc.func.*;
import arc.math.*;
import arc.struct.*;
import arc.util.*;
@ -58,6 +59,7 @@ public class DefaultWaves{
unitScaling = 1;
unitAmount = 4;
spacing = 2;
shieldScaling = 10f;
}},
new SpawnGroup(mace){{
@ -65,6 +67,7 @@ public class DefaultWaves{
spacing = 3;
unitScaling = 1;
end = 40;
shieldScaling = 20f;
}},
new SpawnGroup(mace){{
@ -86,6 +89,7 @@ public class DefaultWaves{
begin = 16;
unitScaling = 1;
spacing = 2;
shieldScaling = 20f;
}},
new SpawnGroup(dagger){{
@ -200,7 +204,7 @@ public class DefaultWaves{
}
//TODO move elsewhere
public static Seq<SpawnGroup> generate(){
public static Seq<SpawnGroup> generate(float difficulty){
UnitType[][] species = {
{dagger, mace, fortress, scepter, reign},
{nova, pulsar, quasar, vela, corvus},
@ -216,54 +220,66 @@ public class DefaultWaves{
Seq<SpawnGroup> out = new Seq<>();
//max reasonable wave, after which everything gets boring
int cap = 400;
int cap = 200;
//main sequence
float shieldStart = 30, shieldsPerWave = 12;
UnitType[] curSpecies = Structs.random(species);
int curTier = 0;
for(int i = 0; i < cap;){
int f = i;
int next = Mathf.random(15, 25);
Intc createProgression = start -> {
//main sequence
UnitType[] curSpecies = Structs.random(species);
int curTier = 0;
float shieldAmount = Math.max((i - shieldStart) * shieldsPerWave, 0);
for(int i = start; i < cap;){
int f = i;
int next = Mathf.random(8, 16);
//main progression
out.add(new SpawnGroup(curSpecies[Math.min(curTier, curSpecies.length - 1)]){{
unitAmount = f == 0 ? 1 : 10;
begin = f;
end = f + next >= cap ? never : f + next;
max = 16;
unitScaling = Mathf.random(1f, 2f);
shields = shieldAmount;
shieldScaling = shieldsPerWave;
}});
float shieldAmount = Math.max((i - shieldStart) * shieldsPerWave, 0);
//extra progression that tails out, blends in
out.add(new SpawnGroup(curSpecies[Math.min(curTier, curSpecies.length - 1)]){{
unitAmount = 6;
begin = f + next;
end = f + next + Mathf.random(8, 12);
max = 10;
unitScaling = Mathf.random(2f);
spacing = Mathf.random(2, 3);
shields = shieldAmount;
shieldScaling = shieldsPerWave;
}});
//main progression
out.add(new SpawnGroup(curSpecies[Math.min(curTier, curSpecies.length - 1)]){{
unitAmount = f == 0 ? 1 : 10;
begin = f;
end = f + next >= cap ? never : f + next;
max = 16;
unitScaling = Mathf.random(1f, 2f);
shields = shieldAmount;
shieldScaling = shieldsPerWave;
}});
i += next;
if(curTier < 3 || Mathf.chance(0.2)){
curTier ++;
//extra progression that tails out, blends in
out.add(new SpawnGroup(curSpecies[Math.min(curTier, curSpecies.length - 1)]){{
unitAmount = 6;
begin = f + next;
end = f + next + Mathf.random(8, 12);
max = 10;
unitScaling = Mathf.random(2f);
spacing = Mathf.random(2, 3);
shields = shieldAmount;
shieldScaling = shieldsPerWave;
}});
i += next;
if(curTier < 3 || Mathf.chance(0.2)){
curTier ++;
}
//do not spawn bosses
curTier = Math.min(curTier, 3);
//small chance to switch species
if(Mathf.chance(0.3)){
curSpecies = Structs.random(species);
}
}
};
//do not spawn bosses
curTier = Math.min(curTier, 3);
createProgression.get(0);
//small chance to switch species
if(Mathf.chance(0.3)){
curSpecies = Structs.random(species);
}
int step = 5 + Mathf.random(3);
while(step <= cap){
createProgression.get(step);
step += (int)(Mathf.random(15, 30) * Mathf.lerp(1f, 0.4f, difficulty));
}
int bossWave = Mathf.random(30, 60);

View file

@ -394,13 +394,13 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
state.rules.attackMode = true;
}else{
state.rules.winWave = 15 * (int)Math.max(difficulty * 5, 1);
state.rules.winWave = 15 * (int)Math.max(difficulty * 10, 1);
}
state.rules.waves = true;
//TODO better waves
state.rules.spawns = defaultWaves.get();
state.rules.spawns = DefaultWaves.generate(difficulty);
}
@Override