Experimental rule for randomized air unit targets
This commit is contained in:
@@ -69,7 +69,10 @@ public class WaveSpawner{
|
|||||||
if(spawned == 0) continue;
|
if(spawned == 0) continue;
|
||||||
|
|
||||||
if(state.isCampaign()){
|
if(state.isCampaign()){
|
||||||
spawned = Math.max(1, Mathf.round(spawned * state.getPlanet().campaignRules.difficulty.enemySpawnMultiplier));
|
//when spawning a boss, round down, so 1.5x (hard) * 1 boss does not result in 2 bosses
|
||||||
|
spawned = Math.max(1, group.effect == StatusEffects.boss ?
|
||||||
|
(int)(spawned * state.getPlanet().campaignRules.difficulty.enemySpawnMultiplier) :
|
||||||
|
Mathf.round(spawned * state.getPlanet().campaignRules.difficulty.enemySpawnMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
int spawnedf = spawned;
|
int spawnedf = spawned;
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import mindustry.gen.*;
|
|||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
import static mindustry.world.meta.BlockFlag.*;
|
||||||
|
|
||||||
//TODO very strange idle behavior sometimes
|
|
||||||
public class FlyingAI extends AIController{
|
public class FlyingAI extends AIController{
|
||||||
|
final static BlockFlag[] randomTargets = {core, storage, generator, launchPad, factory, repair, battery, reactor, drill};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMovement(){
|
public void updateMovement(){
|
||||||
@@ -44,6 +45,21 @@ public class FlyingAI extends AIController{
|
|||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(state.rules.randomAirTargeting){
|
||||||
|
//when there are no waves, it's just random based on the unit
|
||||||
|
Mathf.rand.setSeed(unit.type.id + (state.rules.waves ? state.wave : unit.id));
|
||||||
|
//try a few random flags first
|
||||||
|
for(int attempt = 0; attempt < 5; attempt++){
|
||||||
|
Teamc result = targetFlag(x, y, randomTargets[Mathf.rand.random(randomTargets.length - 1)], true);
|
||||||
|
if(result != null) return result;
|
||||||
|
}
|
||||||
|
//try the closest target
|
||||||
|
Teamc result = target(x, y, range, air, ground);
|
||||||
|
if(result != null) return result;
|
||||||
|
//default to the core
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
|
||||||
for(var flag : unit.type.targetFlags){
|
for(var flag : unit.type.targetFlags){
|
||||||
if(flag == null){
|
if(flag == null){
|
||||||
Teamc result = target(x, y, range, air, ground);
|
Teamc result = target(x, y, range, air, ground);
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ public class CampaignRules{
|
|||||||
rules.showSpawns = showSpawns;
|
rules.showSpawns = showSpawns;
|
||||||
rules.teams.get(rules.waveTeam).blockHealthMultiplier = difficulty.enemyHealthMultiplier;
|
rules.teams.get(rules.waveTeam).blockHealthMultiplier = difficulty.enemyHealthMultiplier;
|
||||||
rules.teams.get(rules.waveTeam).unitHealthMultiplier = difficulty.enemyHealthMultiplier;
|
rules.teams.get(rules.waveTeam).unitHealthMultiplier = difficulty.enemyHealthMultiplier;
|
||||||
|
rules.randomAirTargeting = difficulty.ordinal() >= Difficulty.hard.ordinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ public class Rules{
|
|||||||
public boolean fire = true;
|
public boolean fire = true;
|
||||||
/** Whether units use and require ammo. */
|
/** Whether units use and require ammo. */
|
||||||
public boolean unitAmmo = false;
|
public boolean unitAmmo = false;
|
||||||
|
/** EXPERIMENTAL! If true, air units target random things each wave instead of only generators. */
|
||||||
|
public boolean randomAirTargeting = false;
|
||||||
/** EXPERIMENTAL! If true, blocks will update in units and share power. */
|
/** EXPERIMENTAL! If true, blocks will update in units and share power. */
|
||||||
public boolean unitPayloadUpdate = false;
|
public boolean unitPayloadUpdate = false;
|
||||||
/** If true, units' payloads are destroy()ed when the unit is destroyed. */
|
/** If true, units' payloads are destroy()ed when the unit is destroyed. */
|
||||||
|
|||||||
Reference in New Issue
Block a user