diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 86719ed541..63a1092317 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -138,9 +138,6 @@ public class BulletType extends Content implements Cloneable{ public boolean reflectable = true; /** Whether this projectile can be absorbed by shields. */ public boolean absorbable = true; - /** Whether to move the bullet back depending on delta to fix some delta-time related issues. - * Do not change unless you know what you're doing. */ - public boolean backMove = true; /** If true, the angle param in create is ignored. */ public boolean ignoreSpawnAngle = false; /** Chance for this bullet to be created. */ @@ -928,14 +925,11 @@ public class BulletType extends Content implements Cloneable{ bullet.aimY = aimY; bullet.initVel(angle, speed * velocityScl * (velocityScaleRandMin != 1f || velocityScaleRandMax != 1f ? Mathf.random(velocityScaleRandMin, velocityScaleRandMax) : 1f)); - if(backMove){ - bullet.set(x - bullet.vel.x * Time.delta, y - bullet.vel.y * Time.delta); - }else{ - bullet.set(x, y); - } + bullet.set(x, y); + bullet.lastX = x; + bullet.lastY = y; bullet.lifetime = lifetime * lifetimeScl * (lifeScaleRandMin != 1f || lifeScaleRandMax != 1f ? Mathf.random(lifeScaleRandMin, lifeScaleRandMax) : 1f); bullet.data = data; - bullet.drag = drag; bullet.hitSize = hitSize; bullet.mover = mover; bullet.damage = (damage < 0 ? this.damage : damage) * bullet.damageMultiplier(); diff --git a/core/src/mindustry/entities/bullet/PointBulletType.java b/core/src/mindustry/entities/bullet/PointBulletType.java index 863327a583..ff7504b57a 100644 --- a/core/src/mindustry/entities/bullet/PointBulletType.java +++ b/core/src/mindustry/entities/bullet/PointBulletType.java @@ -18,7 +18,6 @@ public class PointBulletType extends BulletType{ collides = false; reflectable = false; keepVelocity = false; - backMove = false; } @Override diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 74c1eca3db..f3176adb1a 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -22,14 +22,14 @@ import static mindustry.Vars.*; @EntityDef(value = {Bulletc.class}, pooled = true, serialize = false) @Component(base = true) -abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{ +abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Bulletc, Timerc{ @Import Team team; @Import Entityc owner; @Import float x, y, damage, lastX, lastY, time, lifetime; - @Import Vec2 vel; IntSeq collided = new IntSeq(6); BulletType type; + Vec2 vel = new Vec2(); Object data; float fdata; @@ -39,6 +39,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw //setting this variable to true prevents lifetime from decreasing for a frame. transient boolean keepAlive; + transient boolean justSpawned = true; /** Unlike the owner, the shooter is the original entity that created this bullet. For a second-stage missile, the shooter would be the turret, but the owner would be the last missile stage.*/ transient Entityc shooter; transient @Nullable Tile aimTile; @@ -151,6 +152,15 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @Override public void update(){ + //for one frame, bullets do not move - this is because bullet.update() is called immediately after the weapon updates + //if the bullet moved immediately, it would spawn visually offset from the weapon at low FPS values + if(!justSpawned){ + x += vel.x * Time.delta; + y += vel.y * Time.delta; + vel.scl(Math.max(1f - type.drag * Time.delta, 0)); + } + justSpawned = false; + if(mover != null){ mover.move(self()); }