From 9059238aee0f2e83b361fab77015f32fb7444951 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 26 Aug 2018 20:02:29 -0400 Subject: [PATCH] Fixed lancer turning incorrectly / Buffed lancer --- .../content/bullets/TurretBullets.java | 4 ++-- .../io/anuke/mindustry/entities/Damage.java | 2 +- .../blocks/defense/turrets/LaserTurret.java | 21 ++++++++++++++++++- .../world/blocks/defense/turrets/Turret.java | 10 +++++++-- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java index 8ca36b398d..20aa35c138 100644 --- a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java @@ -123,11 +123,11 @@ public class TurretBullets extends BulletList implements ContentList{ } }; - lancerLaser = new BulletType(0.001f, 110){ + lancerLaser = new BulletType(0.001f, 140){ Color[] colors = {Palette.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Palette.lancerLaser, Color.WHITE}; float[] tscales = {1f, 0.7f, 0.5f, 0.2f}; float[] lenscales = {1f, 1.1f, 1.13f, 1.14f}; - float length = 90f; + float length = 100f; { hiteffect = BulletFx.hitLancer; diff --git a/core/src/io/anuke/mindustry/entities/Damage.java b/core/src/io/anuke/mindustry/entities/Damage.java index af1d73f53e..c9d593d5bf 100644 --- a/core/src/io/anuke/mindustry/entities/Damage.java +++ b/core/src/io/anuke/mindustry/entities/Damage.java @@ -88,7 +88,7 @@ public class Damage{ tr.trns(angle, length); world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> { Tile tile = world.tile(cx, cy); - if(tile != null && tile.entity != null && tile.entity.collide(hitter)){ + if(tile != null && tile.entity != null && tile.target().getTeamID() != team.ordinal() && tile.entity.collide(hitter)){ tile.entity.collision(hitter); Effects.effect(effect, tile.worldx(), tile.worldy()); } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java index 63115407cf..36e2dcebfe 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks.defense.turrets; import io.anuke.mindustry.content.fx.Fx; +import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.type.AmmoType; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Effects; @@ -24,7 +25,7 @@ public class LaserTurret extends PowerTurret{ @Override public void shoot(Tile tile, AmmoType ammo){ - TurretEntity entity = tile.entity(); + LaserTurretEntity entity = tile.entity(); useAmmo(tile); @@ -39,6 +40,8 @@ public class LaserTurret extends PowerTurret{ }); } + entity.shooting = true; + Timers.run(chargeTime, () -> { if(!isTurret(tile)) return; tr.trns(entity.rotation, size * tilesize / 2); @@ -46,6 +49,22 @@ public class LaserTurret extends PowerTurret{ entity.heat = 1f; bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy)); effects(tile); + entity.shooting = false; }); } + + @Override + public boolean shouldTurn(Tile tile){ + LaserTurretEntity entity = tile.entity(); + return !entity.shooting; + } + + @Override + public TileEntity getEntity(){ + return new LaserTurretEntity(); + } + + public class LaserTurretEntity extends TurretEntity{ + public boolean shooting; + } } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java index edff051533..80cab51df7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java @@ -193,6 +193,7 @@ public abstract class Turret extends Block{ } if(!Units.invalidateTarget(entity.target, tile.getTeam(), tile.drawx(), tile.drawy())){ + AmmoType type = peekAmmo(tile); float speed = type.bullet.speed; if(speed < 0.1f) speed = 9999999f; @@ -208,7 +209,9 @@ public abstract class Turret extends Block{ entity.rotation = 0; } - entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * Timers.delta()); + if(shouldTurn(tile)){ + entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * Timers.delta()); + } if(Angles.angleDist(entity.rotation, targetRot) < shootCone){ updateShooting(tile); @@ -217,6 +220,10 @@ public abstract class Turret extends Block{ } } + public boolean shouldTurn(Tile tile){ + return true; + } + /** * Consume ammo and return a type. */ @@ -314,7 +321,6 @@ public abstract class Turret extends Block{ } public static class TurretEntity extends TileEntity{ - public TileEntity blockTarget; public Array ammo = new ThreadArray<>(); public int totalAmmo; public float reload;