diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index 36a211758b..1488f9a02c 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -180,6 +180,7 @@ public class UnitTypes implements ContentList{ isFlying = true; health = 75; engineOffset = 5.5f; + range = 140f; weapon = new Weapon("chain-blaster"){{ length = 1.5f; reload = 28f; @@ -198,6 +199,7 @@ public class UnitTypes implements ContentList{ isFlying = true; targetAir = false; engineOffset = 7.8f; + range = 140f; weapon = new Weapon("bomber"){{ length = 0f; width = 2f; diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 019af657c1..b3d5f594e2 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -248,6 +248,7 @@ public class NetClient implements ApplicationListener{ for(int i = 0; i < cores; i++){ int pos = input.readInt(); Tile tile = world.tile(pos); + if(tile != null && tile.entity != null){ tile.entity.items.read(input); }else{ diff --git a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java index 2542e79bdd..0262658248 100644 --- a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java @@ -129,7 +129,10 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } public void targetClosest(){ - target = Units.getClosestTarget(team, x, y, Math.max(getWeapon().bullet.range(), type.range), u -> type.targetAir || !u.isFlying()); + TargetTrait newTarget = Units.getClosestTarget(team, x, y, Math.max(getWeapon().bullet.range(), type.range), u -> type.targetAir || !u.isFlying()); + if(newTarget != null){ + target = newTarget; + } } public TileEntity getClosestEnemyCore(){ diff --git a/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java b/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java index ff628a98b8..6f011652d9 100644 --- a/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java @@ -47,7 +47,7 @@ public abstract class FlyingUnit extends BaseUnit{ attack(type.attackLength); if((Angles.near(angleTo(target), rotation, type.shootCone) || getWeapon().ignoreRotation) //bombers and such don't care about rotation - && dst(target) < Math.max(getWeapon().bullet.range(), type.range)){ + && dst(target) < getWeapon().bullet.range()){ BulletType ammo = getWeapon().bullet; if(type.rotateWeapon){ @@ -75,8 +75,9 @@ public abstract class FlyingUnit extends BaseUnit{ targetClosest(); targetClosestEnemyFlag(BlockFlag.target); - if(target != null){ + if(target != null && !Units.invalidateTarget(target, team, x, y)){ setState(attack); + return; } target = getClosestCore(); diff --git a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java index 1b0dfd3dc8..f7dc634a44 100644 --- a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java @@ -54,10 +54,11 @@ public abstract class GroundUnit extends BaseUnit{ patrol = new UnitState(){ public void update(){ TileEntity target = getClosestCore(); + if(target != null){ if(dst(target) > 400f){ moveAwayFromCore(); - }else{ + }else if(!(!Units.invalidateTarget(GroundUnit.this.target, GroundUnit.this) && dst(GroundUnit.this.target) < getWeapon().bullet.range())){ patrol(); } } diff --git a/core/src/io/anuke/mindustry/entities/type/TileEntity.java b/core/src/io/anuke/mindustry/entities/type/TileEntity.java index fa302ada5f..80f9b7fefa 100644 --- a/core/src/io/anuke/mindustry/entities/type/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/type/TileEntity.java @@ -63,6 +63,10 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ public static void onTileDamage(Tile tile, float health){ if(tile.entity != null){ tile.entity.health = health; + + if(tile.entity.damaged()){ + world.indexer.notifyTileDamaged(tile.entity); + } } } @@ -151,7 +155,9 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ if(health <= 0){ Call.onTileDestroyed(tile); - }else if(preHealth >= maxHealth() - 0.00001f && health < maxHealth() && world != null){ //when just damaged + } + + if(preHealth >= maxHealth() - 0.00001f && health < maxHealth() && world != null){ //when just damaged world.indexer.notifyTileDamaged(this); } } diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index bba017a950..e79c614a6f 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -229,7 +229,9 @@ public class MobileInput extends InputHandler implements GestureListener{ } Draw.color(); }else{ - float rad = (tile.block().size * tilesize / 2f - 1) * request.scale; + float rad = Math.max((tile.block().size * tilesize / 2f - 1) * request.scale, 1f); + + if(rad <= 1.01f) return; Draw.mixcol(); //draw removing request Draw.tint(Pal.removeBack);