diff --git a/build.gradle b/build.gradle index 1e7b9188ea..d38ab95196 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.anuken:ucore:532dc82873' + compile 'com.github.anuken:ucore:779c75e1b2' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/assets-raw/sprites/icon-dirium.png b/core/assets-raw/sprites/icon-dirium.png new file mode 100644 index 0000000000..e68f3fba96 Binary files /dev/null and b/core/assets-raw/sprites/icon-dirium.png differ diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 41079ce257..985ce3aee5 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -202,42 +202,42 @@ blocks/grassedge index: -1 blocks/iron1 rotate: false - xy: 80, 11 + xy: 80, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron2 rotate: false - xy: 80, 1 + xy: 90, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron3 rotate: false - xy: 90, 11 + xy: 90, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/irondrill rotate: false - xy: 90, 1 + xy: 100, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ironwall rotate: false - xy: 100, 11 + xy: 100, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/junction rotate: false - xy: 100, 1 + xy: 110, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -272,28 +272,28 @@ blocks/mortarturret index: -1 blocks/mossblock rotate: false - xy: 110, 1 + xy: 120, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 110, 1 + xy: 120, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 120, 11 + xy: 120, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pump rotate: false - xy: 130, 11 + xy: 130, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -307,35 +307,35 @@ blocks/repairturret index: -1 blocks/rock rotate: false - xy: 130, 1 + xy: 140, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 rotate: false - xy: 140, 11 + xy: 140, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2shadow rotate: false - xy: 140, 1 + xy: 150, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow rotate: false - xy: 150, 11 + xy: 150, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/router rotate: false - xy: 150, 1 + xy: 160, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -356,21 +356,21 @@ blocks/shotgunturret index: -1 blocks/shrub rotate: false - xy: 160, 11 + xy: 160, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shrubshadow rotate: false - xy: 160, 1 + xy: 170, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/smelter rotate: false - xy: 170, 11 + xy: 170, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -384,21 +384,21 @@ blocks/sniperturret index: -1 blocks/steelconveyor rotate: false - xy: 170, 1 + xy: 180, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 180, 11 + xy: 180, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 180, 1 + xy: 190, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -412,49 +412,49 @@ blocks/stone index: -1 blocks/stone1 rotate: false - xy: 190, 11 + xy: 190, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 190, 1 + xy: 200, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 200, 13 + xy: 200, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock rotate: false - xy: 200, 3 + xy: 210, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 210, 13 + xy: 210, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 210, 3 + xy: 220, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 220, 13 + xy: 220, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -468,42 +468,42 @@ blocks/stoneedge index: -1 blocks/stonewall rotate: false - xy: 220, 3 + xy: 230, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium1 rotate: false - xy: 230, 13 + xy: 230, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 230, 3 + xy: 240, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 240, 13 + xy: 240, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 240, 3 + xy: 250, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 250, 13 + xy: 250, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -517,7 +517,7 @@ blocks/turret index: -1 blocks/water rotate: false - xy: 250, 3 + xy: 260, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -566,7 +566,7 @@ enemies/firemech index: -1 enemies/mech1 rotate: false - xy: 110, 11 + xy: 110, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -578,34 +578,41 @@ icon-coal orig: 8, 8 offset: 0, 0 index: -1 -icon-iron +icon-dirium rotate: false xy: 469, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -icon-steel +icon-iron rotate: false xy: 479, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -icon-stone +icon-steel rotate: false xy: 489, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -icon-titanium +icon-stone rotate: false xy: 499, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 +icon-titanium + rotate: false + xy: 80, 11 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 laser rotate: false xy: 77, 5 @@ -622,35 +629,35 @@ laserend index: -1 player rotate: false - xy: 120, 1 + xy: 130, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapon-blaster rotate: false - xy: 260, 13 + xy: 260, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapon-flamethrower rotate: false - xy: 260, 3 + xy: 270, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapon-multigun rotate: false - xy: 270, 13 + xy: 270, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapon-trishot rotate: false - xy: 270, 3 + xy: 280, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index fcf6901be2..bdb3b321ee 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/src/io/anuke/mindustry/Control.java b/core/src/io/anuke/mindustry/Control.java index 28c59d1082..592a22d392 100644 --- a/core/src/io/anuke/mindustry/Control.java +++ b/core/src/io/anuke/mindustry/Control.java @@ -59,6 +59,8 @@ public class Control extends ControlModule{ Inputs.addProcessor(new AndroidInput()); } + Effects.setShakeFalloff(10000f); + Draw.addSurface("shadow", Core.cameraScale); atlas = new Atlas("sprites.atlas"); @@ -215,7 +217,7 @@ public class Control extends ControlModule{ } public void coreDestroyed(){ - Effects.shake(5, 6); + Effects.shake(5, 6, camera.position.x, camera.position.y); Sounds.play("corexplode"); Tile core = World.core; for(int i = 0; i < 16; i ++){ @@ -306,7 +308,7 @@ public class Control extends ControlModule{ } if(Inputs.keyDown(Keys.SPACE)){ - Effects.shake(6, 4); + Effects.shake(6, 4, Graphics.mouseWorld().x, Graphics.mouseWorld().y); } if(Inputs.keyDown(Keys.Y)){ diff --git a/core/src/io/anuke/mindustry/EffectLoader.java b/core/src/io/anuke/mindustry/EffectLoader.java index f97e6a4220..4c981844f3 100644 --- a/core/src/io/anuke/mindustry/EffectLoader.java +++ b/core/src/io/anuke/mindustry/EffectLoader.java @@ -7,12 +7,29 @@ import com.badlogic.gdx.graphics.Color; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; import io.anuke.ucore.graphics.Hue; +import io.anuke.ucore.util.Angles; public class EffectLoader{ static Color lightRed = Hue.mix(Color.WHITE, Color.FIREBRICK, 0.1f); public static void create(){ + Effects.create("shellsmoke", 21, e -> { + Angles.randLenVectors(e.id, 8, 1f + e.ifract()*16f, (x, y)->{ + float size = 2f+e.fract()*5f; + Draw.color(Color.LIGHT_GRAY, Color.DARK_GRAY, e.ifract()); + Draw.rect("circle", e.x + x, e.y + y, size, size); + Draw.reset(); + }); + }); + + Effects.create("shellexplosion", 15, e -> { + Draw.thickness(1.3f - e.ifract()); + Draw.color(Hue.mix(Color.WHITE, Color.ORANGE, e.ifract())); + Draw.circle(e.x, e.y, 1f + e.ifract() * 7f); + Draw.reset(); + }); + Effects.create("place", 16, e -> { Draw.thickness(3f - e.ifract() * 2f); Draw.square(e.x, e.y, Vars.tilesize / 2f + e.ifract() * 3f); @@ -54,6 +71,13 @@ public class EffectLoader{ Draw.reset(); }); + Effects.create("laserhit", 10, e -> { + Draw.thickness(1f); + Draw.color(Hue.mix(Color.WHITE, Color.SKY, e.ifract())); + Draw.spikes(e.x, e.y, e.ifract() * 2f, 2, 6); + Draw.reset(); + }); + Effects.create("shoot", 8, e -> { Draw.thickness(1f); Draw.color(Hue.mix(Color.WHITE, Color.GOLD, e.ifract())); diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index f151936895..fdc1d1978b 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -4,11 +4,19 @@ import com.badlogic.gdx.graphics.Color; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; +import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.BaseBulletType; +import io.anuke.ucore.util.Angles; +import io.anuke.ucore.util.Mathf; public abstract class BulletType extends BaseBulletType{ public static final BulletType + none = new BulletType(0f, 0){ + public void draw(Bullet b){ + + } + }, stone = new BulletType(1.5f, 2){ public void draw(Bullet b){ Draw.color("gray"); @@ -30,6 +38,52 @@ public abstract class BulletType extends BaseBulletType{ Draw.reset(); } }, + shell = new BulletType(1.1f, 110){ + { + lifetime = 110f; + } + public void draw(Bullet b){ + float rad = 8f; + Draw.color(Color.GRAY); + Draw.rect("circle", b.x, b.y, rad, rad); + rad += Mathf.sin(Timers.time(), 3f, 1f); + Draw.color(Color.ORANGE); + Draw.rect("circle", b.x, b.y, rad/1.7f, rad/1.7f); + Draw.reset(); + } + + public void update(Bullet b){ + if(Timers.get(b, "smoke", 7)){ + Effects.effect("smoke", b.x + Mathf.range(2), b.y + Mathf.range(2)); + } + } + + public void despawned(Bullet b){ + removed(b); + } + + public void removed(Bullet b){ + Effects.shake(3f, 3f, b); + + Effects.effect("shellsmoke", b); + Effects.effect("shellexplosion", b); + + Angles.circle(20, f->{ + Angles.translation(f, 5f); + new Bullet(shellshot, b.owner, b.x + Angles.x(), b.y + Angles.y(), f).add(); + }); + } + }, + shellshot = new BulletType(1.5f, 5){ + { + lifetime = 7f; + } + public void draw(Bullet b){ + // Draw.color("orange"); + // Draw.rect("bullet", b.x, b.y, b.angle()); + // Draw.reset(); + } + }, small = new BulletType(1.5f, 1){ public void draw(Bullet b){ Draw.color("orange"); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index bb4978026f..a08a85c22e 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -33,7 +33,7 @@ public class Player extends DestructibleEntity{ public void onDeath(){ remove(); Effects.effect("explosion", this); - Effects.shake(4f, 5f); + Effects.shake(4f, 5f, this); Effects.sound("die", this); Vars.control.setRespawnTime(respawnduration); diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index 5a23401634..4d3e9bb13c 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -49,7 +49,7 @@ public class TileEntity extends Entity{ } tile.setBlock(Blocks.air); - Effects.shake(4f, 4f); + Effects.shake(4f, 4f, this); Effects.effect("explosion", this); Effects.sound("break", this); diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 463538100b..7cdf998163 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -104,7 +104,7 @@ public class Enemy extends DestructibleEntity{ @Override public void onDeath(){ Effects.effect("explosion", this); - Effects.shake(3f, 4f); + Effects.shake(3f, 4f, this); Effects.sound("explosion", this); remove(); dead = true; diff --git a/core/src/io/anuke/mindustry/resource/Item.java b/core/src/io/anuke/mindustry/resource/Item.java index ce0c7ce006..9097f6a7c3 100644 --- a/core/src/io/anuke/mindustry/resource/Item.java +++ b/core/src/io/anuke/mindustry/resource/Item.java @@ -1,5 +1,5 @@ package io.anuke.mindustry.resource; public enum Item{ - stone, iron, coal, steel, titanium, hypanium; + stone, iron, coal, steel, titanium, dirium; } diff --git a/core/src/io/anuke/mindustry/resource/Recipe.java b/core/src/io/anuke/mindustry/resource/Recipe.java index 3a7907bb60..2dd559e543 100644 --- a/core/src/io/anuke/mindustry/resource/Recipe.java +++ b/core/src/io/anuke/mindustry/resource/Recipe.java @@ -26,7 +26,7 @@ public enum Recipe{ flameturret(defense, WeaponBlocks.flameturret, stack(Item.iron, 25), stack(Item.steel, 18)), sniperturret(defense, WeaponBlocks.sniperturret, stack(Item.iron, 30), stack(Item.steel, 20)), laserturret(defense, WeaponBlocks.laserturret, stack(Item.steel, 20), stack(Item.titanium, 20)), - mortarturret(defense, WeaponBlocks.mortarturret, stack(Item.steel, 25), stack(Item.titanium, 25)), + mortarturret(defense, WeaponBlocks.mortarturret, stack(Item.steel, 40), stack(Item.titanium, 30)), healturret(defense, WeaponBlocks.repairturret, stack(Item.iron, 45)), megahealturret(defense, WeaponBlocks.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 40)), diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index d0a584c7b5..1817119e3d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -145,12 +145,12 @@ public class ProductionBlocks{ { health = 90; requirements = new Item[]{Item.titanium, Item.steel}; - result = Item.hypanium; + result = Item.dirium; } @Override public String description(){ - return "Takes in steel + titanium, outputs hypanium."; + return "Takes in steel + titanium, outputs dirium."; } }, diff --git a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java index 82e2b34f27..97c8933363 100644 --- a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java @@ -1,9 +1,12 @@ package io.anuke.mindustry.world.blocks; +import com.badlogic.gdx.graphics.Color; + import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.types.LaserTurret; import io.anuke.mindustry.world.blocks.types.RepairTurret; import io.anuke.mindustry.world.blocks.types.Turret; import io.anuke.ucore.core.Timers; @@ -102,25 +105,27 @@ public class WeaponBlocks{ //TODO mortarturret = new Turret("mortarturret"){ { + rotatespeed = 0.1f; formalName = "flak turret"; range = 120; reload = 120f; - bullet = BulletType.sniper; - ammo = Item.coal; + bullet = BulletType.shell; + ammo = Item.stone; health = 110; } }, //TODO - laserturret = new Turret("laserturret"){ + laserturret = new LaserTurret("laserturret"){ { + beamColor = Color.SKY; formalName = "laser turret"; range = 60; - reload = 40f; - bullet = BulletType.sniper; - ammo = Item.coal; + reload = 4f; + damage = 9; + ammo = Item.stone; health = 110; } }, diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Crafter.java b/core/src/io/anuke/mindustry/world/blocks/types/Crafter.java index 060e1dc0d9..1b4920ffb2 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Crafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Crafter.java @@ -41,6 +41,13 @@ public class Crafter extends Block{ @Override public boolean accept(Item item, Tile dest, Tile source){ - return item == Item.iron || item == Item.coal; + boolean craft = false; + for(Item req : requirements){ + if(item == req){ + craft = true; + break; + } + } + return craft; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/LaserTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/LaserTurret.java index cd8472ebbe..ebcdb433ef 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/LaserTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/LaserTurret.java @@ -8,32 +8,43 @@ import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; +import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; public class LaserTurret extends Turret{ protected Color beamColor = Color.WHITE.cpy(); - protected String hiteffect = "hit"; + protected String hiteffect = "laserhit"; protected int damage = 4; + protected float cone = 15f; public LaserTurret(String name) { super(name); } + @Override + public String description(){ + return "[turretinfo]Ammo: "+(ammo==null ? "N/A" : ammo.name())+"\nRange: " + (int)range + "\nDamage: " + damage; + } + @Override public void shoot(Tile tile){ TurretEntity entity = tile.entity(); Enemy enemy = entity.target; - enemy.damage(damage); - Effects.effect(hiteffect, enemy.x + Mathf.range(3), enemy.y + Mathf.range(3)); + if(Angles.angleDist(entity.rotation, Angles.angle(tile.worldx(), tile.worldy(), enemy.x, enemy.y)) < cone){ + enemy.damage(damage); + Effects.effect(hiteffect, enemy.x + Mathf.range(3), enemy.y + Mathf.range(3)); + } } @Override public void drawOver(Tile tile){ TurretEntity entity = tile.entity(); - if(entity.target != null){ + if(entity.target != null && + Angles.angleDist(entity.rotation, Angles.angle(tile.worldx(), tile.worldy(), entity.target.x, entity.target.y)) <= cone){ + float x = tile.worldx(), y = tile.worldy(); float x2 = entity.target.x, y2 = entity.target.y; @@ -50,9 +61,11 @@ public class LaserTurret extends Turret{ Draw.line(x, y, x2, y2); Draw.thickness(1f); Draw.rect("circle", x2, y2, 5f, 5f); - Draw.reset(); + } + Draw.reset(); + super.drawOver(tile); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/RepairTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/RepairTurret.java index 4da40a0fc6..dd1f62064b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/RepairTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/RepairTurret.java @@ -20,16 +20,20 @@ public class RepairTurret extends Turret{ public void update(Tile tile){ TurretEntity entity = tile.entity(); - if(Timers.get(entity, "target", targetInterval)){ + if(Timers.get(entity, "blocktarget", targetInterval)){ entity.blockTarget = World.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true); } - if(entity.target != null){ - float target = entity.angleTo(entity.target); + if(entity.blockTarget != null){ + float target = entity.angleTo(entity.blockTarget); entity.rotation = Mathf.slerp(entity.rotation, target, 0.16f*Timers.delta()); - if(Timers.get(tile, reload) && Angles.angleDist(target, entity.rotation) < 10){ - entity.target.health++; + if(Timers.get(tile, "reload", reload) && Angles.angleDist(target, entity.rotation) < shootCone){ + entity.blockTarget.health++; + + if(entity.blockTarget.health > entity.blockTarget.health) + entity.blockTarget.health = entity.blockTarget.maxhealth; + } } } @@ -43,7 +47,7 @@ public class RepairTurret extends Turret{ public void drawOver(Tile tile){ TurretEntity entity = tile.entity(); - if(entity.blockTarget != null){ + if(entity.blockTarget != null && Angles.angleDist(entity.angleTo(entity.blockTarget), entity.rotation) < 10){ float x = tile.worldx(), y = tile.worldy(); float x2 = entity.blockTarget.x, y2 = entity.blockTarget.y; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Turret.java b/core/src/io/anuke/mindustry/world/blocks/types/Turret.java index 7292aedc3c..127c5c0a3a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Turret.java @@ -28,10 +28,12 @@ public class Turret extends Block{ protected float range = 50f; protected float reload = 10f; protected String shootsound = "shoot"; - protected BulletType bullet; + protected BulletType bullet = BulletType.iron; protected Item ammo; protected int ammoMultiplier = 20; protected int maxammo = 400; + protected float rotatespeed = 0.2f; + protected float shootCone = 8f; public Turret(String name) { super(name); @@ -68,7 +70,7 @@ public class Turret extends Block{ @Override public void drawPlace(int x, int y, boolean valid){ //TODO? - //Draw.color(Color.PURPLE); + Draw.color(Color.PURPLE); Draw.thick(1f); Draw.dashcircle(x*Vars.tilesize, y*Vars.tilesize, range); } @@ -92,22 +94,27 @@ public class Turret extends Block{ entity.removeItem(ammo, 1); } + if(entity.target != null && entity.target.isDead()) + entity.target = null; + if(entity.ammo > 0){ if(Timers.get(entity, "target", targetInterval)){ entity.target = (Enemy)Entities.getClosest(tile.worldx(), tile.worldy(), range, e->{ - return e instanceof Enemy; + return e instanceof Enemy && !((Enemy)e).isDead(); }); } if(entity.target != null){ - entity.rotation = MathUtils.lerpAngleDeg(entity.rotation, - Angles.predictAngle(tile.worldx(), tile.worldy(), - entity.target.x, entity.target.y, entity.target.xvelocity, entity.target.yvelocity, bullet.speed), - 0.2f*Timers.delta()); + + float targetRot = Angles.predictAngle(tile.worldx(), tile.worldy(), + entity.target.x, entity.target.y, entity.target.xvelocity, entity.target.yvelocity, bullet.speed); + + entity.rotation = MathUtils.lerpAngleDeg(entity.rotation, targetRot, + rotatespeed*Timers.delta()); float reload = Vars.multiplier*this.reload; - if(Timers.get(tile, reload)){ + if(Angles.angleDist(entity.rotation, targetRot) < shootCone && Timers.get(tile, "reload", reload)){ Effects.sound(shootsound, entity); shoot(tile); entity.ammo --; diff --git a/desktop/gifexport/recording1505786780.gif b/desktop/gifexport/recording1505786780.gif new file mode 100644 index 0000000000..eb68ae812e Binary files /dev/null and b/desktop/gifexport/recording1505786780.gif differ diff --git a/desktop/gifexport/recording1505786792.gif b/desktop/gifexport/recording1505786792.gif new file mode 100644 index 0000000000..55f5ab7dda Binary files /dev/null and b/desktop/gifexport/recording1505786792.gif differ diff --git a/desktop/gifexport/recording1505786908.gif b/desktop/gifexport/recording1505786908.gif new file mode 100644 index 0000000000..45279b86bb Binary files /dev/null and b/desktop/gifexport/recording1505786908.gif differ diff --git a/desktop/gifexport/recording1505787089.gif b/desktop/gifexport/recording1505787089.gif new file mode 100644 index 0000000000..8dddfb4e02 Binary files /dev/null and b/desktop/gifexport/recording1505787089.gif differ diff --git a/desktop/gifexport/recording1505787280.gif b/desktop/gifexport/recording1505787280.gif new file mode 100644 index 0000000000..2b2c25084c Binary files /dev/null and b/desktop/gifexport/recording1505787280.gif differ diff --git a/desktop/gifexport/recording1505787294.gif b/desktop/gifexport/recording1505787294.gif new file mode 100644 index 0000000000..28372ca2a8 Binary files /dev/null and b/desktop/gifexport/recording1505787294.gif differ diff --git a/desktop/gifexport/recording1505794124.gif b/desktop/gifexport/recording1505794124.gif new file mode 100644 index 0000000000..7e55192204 Binary files /dev/null and b/desktop/gifexport/recording1505794124.gif differ diff --git a/desktop/gifexport/recording1505794136.gif b/desktop/gifexport/recording1505794136.gif new file mode 100644 index 0000000000..016e9d82ae Binary files /dev/null and b/desktop/gifexport/recording1505794136.gif differ diff --git a/desktop/gifexport/recording1505794220.gif b/desktop/gifexport/recording1505794220.gif new file mode 100644 index 0000000000..8cd79f74c8 Binary files /dev/null and b/desktop/gifexport/recording1505794220.gif differ diff --git a/desktop/gifexport/recording1505796415.gif b/desktop/gifexport/recording1505796415.gif new file mode 100644 index 0000000000..b83c6a0c85 Binary files /dev/null and b/desktop/gifexport/recording1505796415.gif differ diff --git a/desktop/gifexport/recording1505796422.gif b/desktop/gifexport/recording1505796422.gif new file mode 100644 index 0000000000..c47e9094ec Binary files /dev/null and b/desktop/gifexport/recording1505796422.gif differ diff --git a/desktop/gifexport/recording1505796438.gif b/desktop/gifexport/recording1505796438.gif new file mode 100644 index 0000000000..52e14dc08c Binary files /dev/null and b/desktop/gifexport/recording1505796438.gif differ diff --git a/desktop/gifexport/recording1505796455.gif b/desktop/gifexport/recording1505796455.gif new file mode 100644 index 0000000000..48a2e27ed7 Binary files /dev/null and b/desktop/gifexport/recording1505796455.gif differ diff --git a/desktop/gifexport/recording1505796485.gif b/desktop/gifexport/recording1505796485.gif new file mode 100644 index 0000000000..bcae1d6d2e Binary files /dev/null and b/desktop/gifexport/recording1505796485.gif differ