Block explosion damage rule

This commit is contained in:
Anuken
2020-08-25 12:46:41 -04:00
parent 7239c2cf08
commit da360f54e9
4 changed files with 22 additions and 17 deletions

View File

@@ -30,24 +30,26 @@ 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){
for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i++){ if(damage){
int branches = 5 + Mathf.clamp((int)(power / 30), 1, 20); for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i++){
Time.run(i * 2f + Mathf.random(4f), () -> Lightning.create(Team.derelict, Pal.power, 3, x, y, Mathf.random(360f), branches + Mathf.range(2))); 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++){ 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)); 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++){ for(int i = 0; i < waves; i++){
int f = i; int f = i;
Time.run(i * 2f, () -> { Time.run(i * 2f, () -> {
Damage.damage(x, y, Mathf.clamp(radius + explosiveness, 0, 50f) * ((f + 1f) / waves), explosiveness / 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)); Fx.blockExplosionSmoke.at(x + Mathf.range(radius), y + Mathf.range(radius));
}); });
}
} }
if(explosiveness > 15f){ if(explosiveness > 15f){

View File

@@ -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);
} }

View File

@@ -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;

View File

@@ -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. */