From ee412c61fc120c9241a0ecd74dce72e0234eb3fd Mon Sep 17 00:00:00 2001 From: "nuri (smol)" <75618732+SMOLKEYS@users.noreply.github.com> Date: Sat, 30 Mar 2024 03:01:59 +0800 Subject: [PATCH] pierceFragCap (#9684) Co-authored-by: SMOLKEYS --- core/src/mindustry/entities/bullet/BulletType.java | 5 ++++- core/src/mindustry/entities/comp/BulletComp.java | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 64737495e7..85bd903395 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -176,6 +176,8 @@ public class BulletType extends Content implements Cloneable{ public float fragLifeMin = 1f, fragLifeMax = 1f; /** Random offset of frag bullets from the parent bullet. */ public float fragOffsetMin = 1f, fragOffsetMax = 7f; + /** How many times this bullet can release frag bullets, if pierce = true. */ + public int pierceFragCap = -1; /** Bullet that is created at a fixed interval. */ public @Nullable BulletType intervalBullet; @@ -509,12 +511,13 @@ public class BulletType extends Content implements Cloneable{ } public void createFrags(Bullet b, float x, float y){ - if(fragBullet != null && (fragOnAbsorb || !b.absorbed)){ + if(fragBullet != null && (fragOnAbsorb || !b.absorbed) && !(b.frags >= pierceFragCap && pierceFragCap > 0)){ for(int i = 0; i < fragBullets; i++){ float len = Mathf.random(fragOffsetMin, fragOffsetMax); float a = b.rotation() + Mathf.range(fragRandomSpread / 2) + fragAngle + ((i - fragBullets/2) * fragSpread); fragBullet.create(b, x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a, Mathf.random(fragVelocityMin, fragVelocityMax), Mathf.random(fragLifeMin, fragLifeMax)); } + b.frags++; } } diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 7483d66496..d9c3aef000 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -45,6 +45,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw transient @Nullable Mover mover; transient boolean absorbed, hit; transient @Nullable Trail trail; + transient int frags; @Override public void getCollisions(Cons consumer){