From 06921b53be47ec0b4801b997a6dc57333398cb09 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 20 Nov 2020 12:53:09 -0500 Subject: [PATCH] Fixed #3493 --- .../defense/turrets/TractorBeamTurret.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java index 62d313a0aa..974171c71f 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java @@ -76,6 +76,8 @@ public class TractorBeamTurret extends BaseTurret{ target = Units.closestEnemy(team, x, y, range, u -> u.checkTarget(targetAir, targetGround)); } + Log.info(target); + //consume coolant if(target != null && acceptCoolant){ float maxUsed = consumes.get(ConsumeType.liquid).amount; @@ -93,33 +95,34 @@ public class TractorBeamTurret extends BaseTurret{ coolant = 1f + (used * liquid.heatCapacity * coolantMultiplier); } + any = false; + //look at target - if(target != null && target.within(this, range) && target.team() != team && target.type.flying && efficiency() > 0.01f){ + if(target != null && target.within(this, range) && target.team() != team && target.type.flying && efficiency() > 0.02f){ if(!headless){ control.sound.loop(shootSound, this, shootSoundVolume); } - any = true; float dest = angleTo(target); rotation = Angles.moveToward(rotation, dest, rotateSpeed * edelta()); lastX = target.x; lastY = target.y; strength = Mathf.lerpDelta(strength, 1f, 0.1f); - if(damage > 0){ - target.damageContinuous(damage * efficiency()); - } - - if(status != StatusEffects.none){ - target.apply(status, statusDuration); - } - //shoot when possible if(Angles.within(rotation, dest, shootCone)){ + if(damage > 0){ + target.damageContinuous(damage * efficiency()); + } + + if(status != StatusEffects.none){ + target.apply(status, statusDuration); + } + + any = true; target.impulse(Tmp.v1.set(this).sub(target).limit((force + (1f - target.dst(this) / range) * scaledForce) * efficiency() * timeScale)); } }else{ - target = null; strength = Mathf.lerpDelta(strength, 0, 0.1f); } }