diff --git a/core/assets/maps/aware.msav b/core/assets/maps/aware.msav index 2f07f04fb1..b0d9bfdb71 100644 Binary files a/core/assets/maps/aware.msav and b/core/assets/maps/aware.msav differ diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 2324623269..e4dfc4b997 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -152,6 +152,14 @@ public class Logic implements ApplicationListener{ } }); + Events.on(BlockDestroyEvent.class, e -> { + //TODO maybe make it a separate rule? + //makes cores go derelict in RTS mode, helps clean things up + if(e.tile.build instanceof CoreBuild core && core.team.isAI() && core.team.rules().rtsAi){ + core.team.data().makeDerelict(core.x, core.y, state.rules.enemyCoreBuildRadius); + } + }); + //send out items to each client Events.on(TurnEvent.class, e -> { if(net.server() && state.isCampaign()){ @@ -167,7 +175,9 @@ public class Logic implements ApplicationListener{ //listen to core changes; if all cores have been destroyed, set to derelict. Events.on(CoreChangeEvent.class, e -> Core.app.post(() -> { if(state.rules.cleanupDeadTeams && state.rules.pvp && !e.core.isAdded() && e.core.team != Team.derelict && e.core.team.cores().isEmpty()){ - e.core.team.data().destroyToDerelict(); + Core.app.post(() -> { + e.core.team.data().destroyToDerelict(); + }); } })); } diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index 153fd640f5..1b3cfa61c9 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -272,12 +272,7 @@ public class Teams{ //convert all team tiles to neutral, randomly killing them for(var b : builds){ - //TODO this may cause a lot of packet spam, optimize? - Call.setTeam(b, Team.derelict); - - if(Mathf.chance(0.25)){ - Time.run(Mathf.random(0f, 60f * 6f), b::kill); - } + scheduleDerelict(b); } //kill all units randomly @@ -289,6 +284,29 @@ public class Teams{ })); } + /** Make all buildings within this range derelict / explode. */ + public void makeDerelict(float x, float y, float range){ + var builds = new Seq(); + if(buildings != null){ + buildings.intersect(x - range, y - range, range * 2f, range * 2f, builds); + } + + for(var build : builds){ + if(build.within(x, y, range)){ + scheduleDerelict(build); + } + } + } + + private void scheduleDerelict(Building build){ + //TODO this may cause a lot of packet spam, optimize? + Call.setTeam(build, Team.derelict); + + if(Mathf.chance(0.25)){ + Time.run(Mathf.random(0f, 60f * 6f), build::kill); + } + } + @Nullable public Seq unitCache(UnitType type){ if(unitsByType == null || unitsByType.length <= type.id || unitsByType[type.id] == null) return null;