Block explosion damage rule
This commit is contained in:
@@ -30,7 +30,8 @@ public class Damage{
|
|||||||
private static Unit tmpUnit;
|
private static Unit tmpUnit;
|
||||||
|
|
||||||
/** Creates a dynamic explosion based on specified parameters. */
|
/** 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){
|
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++){
|
for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i++){
|
||||||
int branches = 5 + Mathf.clamp((int)(power / 30), 1, 20);
|
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)));
|
Time.run(i * 2f + Mathf.random(4f), () -> Lightning.create(Team.derelict, Pal.power, 3, x, y, Mathf.random(360f), branches + Mathf.range(2)));
|
||||||
@@ -49,6 +50,7 @@ public class Damage{
|
|||||||
Fx.blockExplosionSmoke.at(x + Mathf.range(radius), y + Mathf.range(radius));
|
Fx.blockExplosionSmoke.at(x + Mathf.range(radius), y + Mathf.range(radius));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(explosiveness > 15f){
|
if(explosiveness > 15f){
|
||||||
Fx.shockwave.at(x, y);
|
Fx.shockwave.at(x, y);
|
||||||
|
|||||||
@@ -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){
|
if(!floor().solid && !floor().isLiquid){
|
||||||
Effect.rubble(x, y, block.size);
|
Effect.rubble(x, y, block.size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
public void destroy(){
|
public void destroy(){
|
||||||
float explosiveness = 2f + item().explosiveness * stack().amount;
|
float explosiveness = 2f + item().explosiveness * stack().amount;
|
||||||
float flammability = item().flammability * 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;
|
float shake = hitSize / 3f;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public class Rules{
|
|||||||
public boolean canGameOver = true;
|
public boolean canGameOver = true;
|
||||||
/** Whether reactors can explode and damage other blocks. */
|
/** Whether reactors can explode and damage other blocks. */
|
||||||
public boolean reactorExplosions = true;
|
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. */
|
/** Whether units use and require ammo. */
|
||||||
public boolean unitAmmo = false;
|
public boolean unitAmmo = false;
|
||||||
/** How fast unit pads build units. */
|
/** How fast unit pads build units. */
|
||||||
|
|||||||
Reference in New Issue
Block a user