diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 8b85fbf4ab..447828f90b 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -795,6 +795,7 @@ public class Blocks implements ContentList{ requirements(Category.defense, ItemStack.with(Items.plastanium, 5, Items.metaglass, 2)); health = 190 * wallHealthMultiplier; insulated = true; + absorbLasers = true; }}; plastaniumWallLarge = new Wall("plastanium-wall-large"){{ @@ -802,6 +803,7 @@ public class Blocks implements ContentList{ health = 190 * wallHealthMultiplier * 4; size = 2; insulated = true; + absorbLasers = true; }}; thoriumWall = new Wall("thorium-wall"){{ @@ -1484,7 +1486,7 @@ public class Blocks implements ContentList{ powerUse = 2.5f; shootShake = 2f; shootEffect = Fx.lancerLaserShoot; - smokeEffect = Fx.lancerLaserShootSmoke; + smokeEffect = Fx.none; chargeEffect = Fx.lancerLaserCharge; chargeBeginEffect = Fx.lancerLaserChargeBegin; heatColor = Color.red; diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index 0ff88c9164..7af54291dc 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -884,8 +884,9 @@ public class Fx{ lancerLaserShootSmoke = new Effect(26f, e -> { color(Color.white); + float length = e.data == null ? 70f : (Float)e.data; - randLenVectors(e.id, 7, 70f, e.rotation, 0f, (x, y) -> { + randLenVectors(e.id, 7, length, e.rotation, 0f, (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f); }); diff --git a/core/src/mindustry/entities/bullet/LaserBulletType.java b/core/src/mindustry/entities/bullet/LaserBulletType.java index 31c6054765..1595e5e263 100644 --- a/core/src/mindustry/entities/bullet/LaserBulletType.java +++ b/core/src/mindustry/entities/bullet/LaserBulletType.java @@ -8,9 +8,15 @@ import mindustry.content.*; import mindustry.entities.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.world.*; + +import static mindustry.Vars.world; public class LaserBulletType extends BulletType{ + protected static Tile furthest; + protected Color[] colors = {Pal.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Pal.lancerLaser, Color.white}; + protected Effect laserEffect = Fx.lancerLaserShootSmoke; protected float length = 160f; protected float width = 15f; protected float lengthFalloff = 0.5f; @@ -24,7 +30,7 @@ public class LaserBulletType extends BulletType{ hitEffect = Fx.hitLancer; despawnEffect = Fx.none; shootEffect = Fx.hitLancer; - smokeEffect = Fx.lancerLaserShootSmoke; + smokeEffect = Fx.none; hitSize = 4; lifetime = 16f; pierce = true; @@ -42,13 +48,27 @@ public class LaserBulletType extends BulletType{ @Override public void init(Bulletc b){ - Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), length); + Tmp.v1.trns(b.rotation(), length); + + furthest = null; + + world.raycast(b.tileX(), b.tileY(), world.toTile(b.x() + Tmp.v1.x), world.toTile(b.y() + Tmp.v1.y), + (x, y) -> (furthest = world.tile(x, y)) != null && furthest.block().absorbLasers); + + float resultLength = furthest != null ? Math.max(6f, b.dst(furthest.worldx(), furthest.worldy())) : length; + + Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), resultLength); + if(furthest != null) b.data(resultLength); + + laserEffect.at(b.x(), b.y(), b.rotation(), resultLength * 0.75f); } @Override public void draw(Bulletc b){ + float realLength = b.data() == null ? length : (Float)b.data(); + float f = Mathf.curve(b.fin(), 0f, 0.2f); - float baseLen = length * f; + float baseLen = realLength * f; float cwidth = width; float compound = 1f; diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 1f4eadd391..e706110633 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -86,6 +86,8 @@ public class Block extends UnlockableContent{ public boolean insulated = false; /** whether the sprite is a full square. */ public boolean squareSprite = true; + /** whether this block absorbs laser attacks. */ + public boolean absorbLasers = false; /** tile entity health */ public int health = -1; /** base block explosiveness */