Better target priority + underBullets for pierce

This commit is contained in:
Anuken
2022-04-11 15:11:10 -04:00
parent ea9e5ae632
commit e2abc055a2
16 changed files with 37 additions and 7 deletions

View File

@@ -3,7 +3,8 @@ package mindustry.entities;
/** Higher priority blocks will always get targeted over those of lower priority, regardless of distance. */
public class TargetPriority{
public static final float
wall = -1f,
wall = -2f,
transport = -1f,
base = 0f,
constructing = 1f,
turret = 2f,

View File

@@ -559,6 +559,8 @@ public class BulletType extends Content implements Cloneable{
bullet.owner = owner;
bullet.team = team;
bullet.time = 0f;
bullet.originX = x;
bullet.originY = y;
bullet.aimTile = world.tileWorld(aimX, aimY);
bullet.initVel(angle, speed * velocityScl);
if(backMove){

View File

@@ -38,6 +38,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
private float rotation;
transient @Nullable Tile aimTile;
transient float originX, originY;
transient @Nullable Mover mover;
transient boolean absorbed, hit;
transient @Nullable Trail trail;
@@ -177,7 +178,12 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
if(build != null && isAdded() &&
//should underBullet detection be disabled for piercing bullets?
//|| type.pierceBuilding
(!build.block.underBullets || (aimTile != null && aimTile.build == build))
(!build.block.underBullets ||
//direct hit on correct tile
(aimTile != null && aimTile.build == build) ||
//a piercing bullet overshot the aim tile, it's fine to hit things now
(type.pierce && aimTile != null && dst(originX, originY) > aimTile.dst(originX, originY) + 2f))
&& build.collide(self()) && type.testCollision(self(), build)
&& !build.dead() && (type.collidesTeam || build.team != team) && !(type.pierceBuilding && hasCollided(build.id))){