Improved fireballs and general block explosions
This commit is contained in:
@@ -32,6 +32,7 @@ public class LiquidBlocks {
|
||||
liquidtank = new LiquidRouter("liquidtank") {{
|
||||
size = 3;
|
||||
liquidCapacity = 1500f;
|
||||
health = 500;
|
||||
}},
|
||||
|
||||
liquidjunction = new LiquidJunction("liquidjunction"),
|
||||
|
||||
@@ -43,6 +43,26 @@ public class EnvironmentFx {
|
||||
Draw.color();
|
||||
}),
|
||||
|
||||
fireballsmoke = new Effect(25f, e -> {
|
||||
Draw.color(Color.GRAY);
|
||||
|
||||
Angles.randLenVectors(e.id, 1, 2f + e.fin()*7f, (x, y) -> {
|
||||
Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
}),
|
||||
|
||||
ballfire = new Effect(25f, e -> {
|
||||
Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin());
|
||||
|
||||
Angles.randLenVectors(e.id, 2, 2f + e.fin()*7f, (x, y) -> {
|
||||
Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
}),
|
||||
|
||||
freezing = new Effect(40f, e -> {
|
||||
Draw.color(Liquids.cryofluid.color);
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ public class ExplosionFx {
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
bigShockwave = new Effect(10f, 80f, e -> {
|
||||
Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin());
|
||||
Lines.stroke(e.fout()*3f);
|
||||
Lines.circle(e.x, e.y, e.fin()*50f);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
nuclearShockwave = new Effect(10f, 200f, e -> {
|
||||
Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin());
|
||||
Lines.stroke(e.fout()*3f + 0.2f);
|
||||
@@ -51,8 +58,8 @@ public class ExplosionFx {
|
||||
|
||||
blockExplosion = new Effect(30, e -> {
|
||||
e.scaled(7, i -> {
|
||||
Lines.stroke(3f * i.fout());
|
||||
Lines.circle(e.x, e.y, 3f + i.fin()*10f);
|
||||
Lines.stroke(3.1f * i.fout());
|
||||
Lines.circle(e.x, e.y, 3f + i.fin()*14f);
|
||||
});
|
||||
|
||||
Draw.color(Color.GRAY);
|
||||
@@ -63,12 +70,23 @@ public class ExplosionFx {
|
||||
});
|
||||
|
||||
Draw.color(Palette.lighterOrange, Palette.lightOrange, Color.GRAY, e.fin());
|
||||
Lines.stroke(1.5f * e.fout());
|
||||
Lines.stroke(1.7f * e.fout());
|
||||
|
||||
Angles.randLenVectors(e.id + 1, 8, 1f + 23f * e.finpow(), (x, y) -> {
|
||||
Angles.randLenVectors(e.id + 1, 9, 1f + 23f * e.finpow(), (x, y) -> {
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), 1f + e.fout()*3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
blockExplosionSmoke = new Effect(30, e -> {
|
||||
Draw.color(Color.GRAY);
|
||||
|
||||
Angles.randLenVectors(e.id, 6, 4f + 30f * e.finpow(), (x, y) ->{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout()*3f);
|
||||
Fill.circle(e.x + x/2f, e.y + y/2f, e.fout()*1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,6 +98,10 @@ public abstract class Unit extends SyncEntity {
|
||||
velocity.scl(Mathf.clamp(1f-drag* floor.dragMultiplier* Timers.delta()));
|
||||
}
|
||||
|
||||
public void applyEffect(StatusEffect effect, float intensity){
|
||||
status.handleApply(this, effect, intensity);
|
||||
}
|
||||
|
||||
public void damagePeriodic(float amount){
|
||||
damage(amount * Timers.delta(), Timers.get(this, "damageeffect", 20));
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Physics;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class DamageArea{
|
||||
private static Rectangle rect = new Rectangle();
|
||||
@@ -65,6 +63,24 @@ public class DamageArea{
|
||||
Units.getNearbyEnemies(team, rect, cons);
|
||||
}
|
||||
|
||||
/**Damages all entities and blocks in a radius that are enemies of the team.*/
|
||||
public static void damageUnits(Team team, float x, float y, float size, float damage, Consumer<Unit> acceptor) {
|
||||
Consumer<Unit> cons = entity -> {
|
||||
if (!entity.hitbox.getRect(entity.x, entity.y).overlaps(rect)) {
|
||||
return;
|
||||
}
|
||||
entity.damage(damage);
|
||||
acceptor.accept(entity);
|
||||
};
|
||||
|
||||
rect.setSize(size * 2).setCenter(x, y);
|
||||
if (team != null) {
|
||||
Units.getNearbyEnemies(team, rect, cons);
|
||||
} else {
|
||||
Units.getNearby(rect, cons);
|
||||
}
|
||||
}
|
||||
|
||||
/**Damages everything in a radius.*/
|
||||
public static void damage(float x, float y, float radius, float damage){
|
||||
damage(null, x, y, radius, damage);
|
||||
@@ -78,7 +94,8 @@ public class DamageArea{
|
||||
}
|
||||
float amount = calculateDamage(x, y, entity.x, entity.y, radius, damage);
|
||||
entity.damage(amount);
|
||||
entity.velocity.add(tr.set(entity.x - x, entity.y - y).setLength(Mathf.clamp(damage/2f, 0, 6)));
|
||||
//TODO better velocity displacement
|
||||
entity.velocity.add(tr.set(entity.x - x, entity.y - y).setLength(damage*2f));
|
||||
};
|
||||
|
||||
rect.setSize(radius *2).setCenter(x, y);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -11,6 +12,7 @@ import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.effectGroup;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Fire extends TimedEntity {
|
||||
@@ -43,9 +45,6 @@ public class Fire extends TimedEntity {
|
||||
GridPoint2 p = Mathf.select(Geometry.d4);
|
||||
Tile other = world.tile(tile.x + p.x, tile.y + p.y);
|
||||
new Fire(other).add();
|
||||
//if(other != null && other.target().entity != null && !other.entity.hasFire()){
|
||||
//other.entity.setFire();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +54,7 @@ public class Fire extends TimedEntity {
|
||||
if(damage){
|
||||
entity.damage(0.4f);
|
||||
}
|
||||
DamageArea.damageUnits(null, tile.worldx(), tile.worldy(), tilesize, 3f, unit -> unit.applyEffect(StatusEffects.burning, 0.8f));
|
||||
}
|
||||
|
||||
if(Mathf.chance(0.05 * Timers.delta())){
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.TimedEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
@@ -22,8 +24,8 @@ public class Fireball extends TimedEntity {
|
||||
set(x, y);
|
||||
this.rotation = rotation;
|
||||
this.color = color;
|
||||
lifetime = 40f + Mathf.random(40f);
|
||||
speed = 0.3f + Mathf.random(2f);
|
||||
lifetime = 30f + Mathf.random(40f);
|
||||
speed = 0.6f + Mathf.random(2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +42,14 @@ public class Fireball extends TimedEntity {
|
||||
new Fire(tile).add();
|
||||
}
|
||||
}
|
||||
|
||||
if(Mathf.chance(0.1 * Timers.delta())){
|
||||
Effects.effect(EnvironmentFx.fireballsmoke, x, y);
|
||||
}
|
||||
|
||||
if(Mathf.chance(0.1 * Timers.delta())){
|
||||
Effects.effect(EnvironmentFx.ballfire, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -264,15 +264,28 @@ public class Block extends BaseBlock {
|
||||
});
|
||||
}
|
||||
|
||||
float e = explosiveness;
|
||||
int waves = Mathf.clamp((int)(explosiveness / 4), 0, 30);
|
||||
|
||||
for(int i = 0; i < waves; i ++){
|
||||
int f = i;
|
||||
Timers.run(i*2f, () -> {
|
||||
DamageArea.damage(x, y, Mathf.clamp(size * tilesize + e, 0, 50f) * ((f + 1f)/waves), e/2f);
|
||||
Effects.effect(ExplosionFx.blockExplosionSmoke, x + Mathf.range(size * tilesize/2f), y + Mathf.range(size * tilesize/2f));
|
||||
});
|
||||
}
|
||||
|
||||
if(explosiveness > 15f){
|
||||
Effects.effect(ExplosionFx.shockwave, x, y);
|
||||
}
|
||||
|
||||
if(explosiveness > 30f){
|
||||
Effects.effect(ExplosionFx.bigShockwave, x, y);
|
||||
}
|
||||
|
||||
float shake = Math.min(explosiveness/4f + 3f, 9f);
|
||||
Effects.shake(shake, shake, x, y);
|
||||
Effects.effect(ExplosionFx.blockExplosion, x, y);
|
||||
|
||||
DamageArea.damage(x, y, Mathf.clamp(size * tilesize + explosiveness, 0, 60f), 5 + explosiveness);
|
||||
}
|
||||
|
||||
public float getFlammability(Tile tile){
|
||||
|
||||
Reference in New Issue
Block a user