diff --git a/core/src/mindustry/ai/types/DefenderAI.java b/core/src/mindustry/ai/types/DefenderAI.java index f03ce425ad..d16e1ac907 100644 --- a/core/src/mindustry/ai/types/DefenderAI.java +++ b/core/src/mindustry/ai/types/DefenderAI.java @@ -28,7 +28,7 @@ public class DefenderAI extends AIController{ public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){ //Sort by max health and closer target. - var result = Units.closest(unit.team, x, y, Math.max(range, 400f), u -> !u.dead() && u.type != unit.type, (u, tx, ty) -> -u.maxHealth + Mathf.dst2(u.x, u.y, tx, ty) / 6400f); + var result = Units.closest(unit.team, x, y, Math.max(range, 400f), u -> !u.dead() && u.type != unit.type && u.targetable(unit.team), (u, tx, ty) -> -u.maxHealth + Mathf.dst2(u.x, u.y, tx, ty) / 6400f); if(result != null) return result; //return core if found diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index 0a7b2a83f6..563d9048b8 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -374,7 +374,7 @@ public class Damage{ tmpUnit = null; Units.nearbyEnemies(hitter.team, rect, e -> { - if((tmpUnit != null && e.dst2(x, y) > tmpUnit.dst2(x, y)) || !e.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround)) return; + if((tmpUnit != null && e.dst2(x, y) > tmpUnit.dst2(x, y)) || !e.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround) || !e.targetable(hitter.team)) return; e.hitbox(hitrect); Rect other = hitrect; @@ -468,7 +468,7 @@ public class Damage{ /** Damages all entities and blocks in a radius that are enemies of the team. */ public static void damage(Team team, float x, float y, float radius, float damage, boolean complete, boolean air, boolean ground, boolean scaled, Bullet source){ Cons cons = entity -> { - if(entity.team == team || !entity.hittable() || !entity.within(x, y, radius + (scaled ? entity.hitSize / 2f : 0f)) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ + if(entity.team == team || !entity.checkTarget(air, ground) || !entity.hittable() || !entity.within(x, y, radius + (scaled ? entity.hitSize / 2f : 0f))){ return; } diff --git a/core/src/mindustry/entities/abilities/EnergyFieldAbility.java b/core/src/mindustry/entities/abilities/EnergyFieldAbility.java index d8bde36599..631355c7db 100644 --- a/core/src/mindustry/entities/abilities/EnergyFieldAbility.java +++ b/core/src/mindustry/entities/abilities/EnergyFieldAbility.java @@ -101,7 +101,7 @@ public class EnergyFieldAbility extends Ability{ if(hitUnits){ Units.nearby(null, rx, ry, range, other -> { - if(other != unit && (other.isFlying() ? targetAir : targetGround)){ + if(other != unit && other.checkTarget(targetAir, targetGround) && other.targetable(unit.team)){ all.add(other); } }); diff --git a/core/src/mindustry/entities/bullet/FlakBulletType.java b/core/src/mindustry/entities/bullet/FlakBulletType.java index 9184527a10..16a51243b4 100644 --- a/core/src/mindustry/entities/bullet/FlakBulletType.java +++ b/core/src/mindustry/entities/bullet/FlakBulletType.java @@ -30,7 +30,7 @@ public class FlakBulletType extends BasicBulletType{ if(b.time >= flakDelay && b.fdata >= 0 && b.timer(2, flakInterval)){ Units.nearbyEnemies(b.team, Tmp.r1.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> { //fdata < 0 means it's primed to explode - if(b.fdata < 0f || !unit.checkTarget(collidesAir, collidesGround) || !unit.type.targetable) return; + if(b.fdata < 0f || !unit.checkTarget(collidesAir, collidesGround) || !unit.targetable(b.team)) return; if(unit.within(b, explodeRange + unit.hitSize/2f)){ //mark as primed diff --git a/core/src/mindustry/entities/bullet/PointBulletType.java b/core/src/mindustry/entities/bullet/PointBulletType.java index a4fe032b52..8bd5f4a779 100644 --- a/core/src/mindustry/entities/bullet/PointBulletType.java +++ b/core/src/mindustry/entities/bullet/PointBulletType.java @@ -16,6 +16,7 @@ public class PointBulletType extends BulletType{ scaleLife = true; lifetime = 100f; collides = false; + reflectable = false; keepVelocity = false; backMove = false; } @@ -42,7 +43,7 @@ public class PointBulletType extends BulletType{ float range = 1f; Units.nearbyEnemies(b.team, px - range, py - range, range*2f, range*2f, e -> { - if(e.dead()) return; + if(e.dead() || !e.checkTarget(collidesAir, collidesGround) || !e.hittable()) return; e.hitbox(Tmp.r1); if(!Tmp.r1.contains(px, py)) return; @@ -56,7 +57,7 @@ public class PointBulletType extends BulletType{ if(result != null){ b.collision(result, px, py); - }else{ + }else if(collidesTiles){ Building build = Vars.world.buildWorld(px, py); if(build != null && build.team != b.team){ build.collision(b);