From 5d1ec319bcf3d91952740c440d760c096bb62348 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 17 Nov 2023 19:12:56 -0500 Subject: [PATCH] BulletType delayFrags workaround --- core/src/mindustry/entities/bullet/BulletType.java | 8 +++++++- core/src/mindustry/entities/bullet/LaserBulletType.java | 1 + core/src/mindustry/entities/bullet/RailBulletType.java | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index b4c632ab98..4ab4c929a4 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -160,6 +160,8 @@ public class BulletType extends Content implements Cloneable{ /** Bullet type that is created when this bullet expires. */ public @Nullable BulletType fragBullet = null; + /** If true, frag bullets are delayed to the next frame. Fixes obscure bugs with piercing bullet types spawning frags immediately and screwing up the Damage temporary variables. */ + public boolean delayFrags = false; /** Degree spread range of fragmentation bullets. */ public float fragRandomSpread = 360f; /** Uniform spread between each frag bullet in degrees. */ @@ -446,7 +448,11 @@ public class BulletType extends Content implements Cloneable{ Effect.shake(hitShake, hitShake, b); if(fragOnHit){ - createFrags(b, x, y); + if(delayFrags && fragBullet != null && fragBullet.delayFrags){ + Core.app.post(() -> createFrags(b, x, y)); + }else{ + createFrags(b, x, y); + } } createPuddles(b, x, y); createIncend(b, x, y); diff --git a/core/src/mindustry/entities/bullet/LaserBulletType.java b/core/src/mindustry/entities/bullet/LaserBulletType.java index 7450824c4a..c6c7c3de21 100644 --- a/core/src/mindustry/entities/bullet/LaserBulletType.java +++ b/core/src/mindustry/entities/bullet/LaserBulletType.java @@ -38,6 +38,7 @@ public class LaserBulletType extends BulletType{ hittable = false; absorbable = false; removeAfterPierce = false; + delayFrags = true; } public LaserBulletType(){ diff --git a/core/src/mindustry/entities/bullet/RailBulletType.java b/core/src/mindustry/entities/bullet/RailBulletType.java index 46f04bdb31..276a428e4e 100644 --- a/core/src/mindustry/entities/bullet/RailBulletType.java +++ b/core/src/mindustry/entities/bullet/RailBulletType.java @@ -24,6 +24,7 @@ public class RailBulletType extends BulletType{ collides = false; keepVelocity = false; lifetime = 1f; + delayFrags = true; } @Override