From c6b60a262036d74c07fc77e4bd6bd5674f0ce9fb Mon Sep 17 00:00:00 2001 From: MEEP of Faith <54301439+MEEPofFaith@users.noreply.github.com> Date: Tue, 12 Jan 2021 06:39:27 -0800 Subject: [PATCH] `shootLength` for other turrets that aren't `PointDefenceTurret`s (#4312) --- .../world/blocks/defense/turrets/LaserTurret.java | 2 +- .../blocks/defense/turrets/TractorBeamTurret.java | 6 +++--- .../world/blocks/defense/turrets/Turret.java | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java index fd971e55d7..8ac3461dd3 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -55,7 +55,7 @@ public class LaserTurret extends PowerTurret{ if(bulletLife > 0 && bullet != null){ wasShooting = true; - tr.trns(rotation, size * tilesize / 2f, 0f); + tr.trns(rotation, shootLength, 0f); bullet.rotation(rotation); bullet.set(x + tr.x, y + tr.y); bullet.time(0f); diff --git a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java index 42e33dc2e3..a56d648b3d 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java @@ -24,8 +24,9 @@ public class TractorBeamTurret extends BaseTurret{ public @Load("block-@size") TextureRegion baseRegion; public @Load("@-laser") TextureRegion laser; public @Load("@-laser-end") TextureRegion laserEnd; - + public float shootCone = 6f; + public float shootLength = 5f; public float laserWidth = 0.6f; public float force = 0.3f; public float scaledForce = 0f; @@ -141,12 +142,11 @@ public class TractorBeamTurret extends BaseTurret{ if(any){ Draw.z(Layer.bullet); float ang = angleTo(lastX, lastY); - float len = 5f; Draw.mixcol(laserColor, Mathf.absin(4f, 0.6f)); Drawf.laser(team, laser, laserEnd, - x + Angles.trnsx(ang, len), y + Angles.trnsy(ang, len), + x + Angles.trnsx(ang, shootLength), y + Angles.trnsy(ang, shootLength), lastX, lastY, strength * efficiency() * laserWidth); Draw.mixcol(); diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 60b31fa8d7..ab320b7863 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -54,6 +54,7 @@ public class Turret extends ReloadTurret{ public float coolantUsage = 0.2f; public float shootCone = 8f; public float shootShake = 0f; + public float shootLength = -1; public float xRand = 0f; /** Currently used for artillery only. */ public float minRange = 0f; @@ -122,6 +123,8 @@ public class Turret extends ReloadTurret{ hasLiquids = true; consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, coolantUsage)).update(false).boost(); } + + if(shootLength < 0) shootLength = size * tilesize / 2f; super.init(); } @@ -371,14 +374,14 @@ public class Turret extends ReloadTurret{ if(chargeTime > 0){ useAmmo(); - tr.trns(rotation, size * tilesize / 2f); + tr.trns(rotation, shootLength); chargeBeginEffect.at(x + tr.x, y + tr.y, rotation); chargeSound.at(x + tr.x, y + tr.y, 1); for(int i = 0; i < chargeEffects; i++){ Time.run(Mathf.random(chargeMaxDelay), () -> { if(!isValid()) return; - tr.trns(rotation, size * tilesize / 2f); + tr.trns(rotation, shootLength); chargeEffect.at(x + tr.x, y + tr.y, rotation); }); } @@ -387,7 +390,7 @@ public class Turret extends ReloadTurret{ Time.run(chargeTime, () -> { if(!isValid()) return; - tr.trns(rotation, size * tilesize / 2f); + tr.trns(rotation, shootLength); recoil = recoilAmount; heat = 1f; bullet(type, rotation + Mathf.range(inaccuracy)); @@ -403,7 +406,7 @@ public class Turret extends ReloadTurret{ recoil = recoilAmount; - tr.trns(rotation, size * tilesize / 2f, Mathf.range(xRand)); + tr.trns(rotation, shootLength, Mathf.range(xRand)); bullet(type, rotation + Mathf.range(inaccuracy)); effects(); useAmmo(); @@ -418,10 +421,10 @@ public class Turret extends ReloadTurret{ if(alternate){ float i = (shotCounter % shots) - (shots-1)/2f; - tr.trns(rotation - 90, spread * i + Mathf.range(xRand), size * tilesize / 2f); + tr.trns(rotation - 90, spread * i + Mathf.range(xRand), shootLength); bullet(type, rotation + Mathf.range(inaccuracy)); }else{ - tr.trns(rotation, size * tilesize / 2f, Mathf.range(xRand)); + tr.trns(rotation, shootLength, Mathf.range(xRand)); for(int i = 0; i < shots; i++){ bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i - (int)(shots / 2f)) * spread);