diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index 56acb90a22..b6a2a94440 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -30,24 +30,26 @@ public class Damage{ private static Unit tmpUnit; /** Creates a dynamic explosion based on specified parameters. */ - public static void dynamicExplosion(float x, float y, float flammability, float explosiveness, float power, float radius, Color color){ - for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i++){ - int branches = 5 + Mathf.clamp((int)(power / 30), 1, 20); - Time.run(i * 2f + Mathf.random(4f), () -> Lightning.create(Team.derelict, Pal.power, 3, x, y, Mathf.random(360f), branches + Mathf.range(2))); - } + public static void dynamicExplosion(float x, float y, float flammability, float explosiveness, float power, float radius, Color color, boolean damage){ + if(damage){ + for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i++){ + int branches = 5 + Mathf.clamp((int)(power / 30), 1, 20); + Time.run(i * 2f + Mathf.random(4f), () -> Lightning.create(Team.derelict, Pal.power, 3, x, y, Mathf.random(360f), branches + Mathf.range(2))); + } - for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i++){ - Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), Bullets.fireball.damage, 1, 1)); - } + for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i++){ + Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), Bullets.fireball.damage, 1, 1)); + } - int waves = Mathf.clamp((int)(explosiveness / 4), 0, 30); + int waves = Mathf.clamp((int)(explosiveness / 4), 0, 30); - for(int i = 0; i < waves; i++){ - int f = i; - Time.run(i * 2f, () -> { - Damage.damage(x, y, Mathf.clamp(radius + explosiveness, 0, 50f) * ((f + 1f) / waves), explosiveness / 2f); - Fx.blockExplosionSmoke.at(x + Mathf.range(radius), y + Mathf.range(radius)); - }); + for(int i = 0; i < waves; i++){ + int f = i; + Time.run(i * 2f, () -> { + Damage.damage(x, y, Mathf.clamp(radius + explosiveness, 0, 50f) * ((f + 1f) / waves), explosiveness / 2f); + Fx.blockExplosionSmoke.at(x + Mathf.range(radius), y + Mathf.range(radius)); + }); + } } if(explosiveness > 15f){ diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index c1040c979c..6a19b8d32b 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -900,7 +900,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, }); } - Damage.dynamicExplosion(x, y, flammability, explosiveness * 3.5f, power, tilesize * block.size / 2f, Pal.darkFlame); + Damage.dynamicExplosion(x, y, flammability, explosiveness * 3.5f, power, tilesize * block.size / 2f, Pal.darkFlame, state.rules.damageExplosions); + if(!floor().solid && !floor().isLiquid){ Effect.rubble(x, y, block.size); } diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 85ed95939e..92d0a08dee 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -314,7 +314,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I public void destroy(){ float explosiveness = 2f + item().explosiveness * stack().amount; float flammability = item().flammability * stack().amount; - Damage.dynamicExplosion(x, y, flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame); + Damage.dynamicExplosion(x, y, flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame, state.rules.damageExplosions); float shake = hitSize / 3f; diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index d3502845fc..b29aa0c0e1 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -38,6 +38,8 @@ public class Rules{ public boolean canGameOver = true; /** Whether reactors can explode and damage other blocks. */ public boolean reactorExplosions = true; + /** Whether friendly explosions can occur and set fire/damage other blocks. */ + public boolean damageExplosions = true; /** Whether units use and require ammo. */ public boolean unitAmmo = false; /** How fast unit pads build units. */