Skip to content

Commit

Permalink
pierceFragCap (#9684)
Browse files Browse the repository at this point in the history
Co-authored-by: SMOLKEYS <[email protected]>
  • Loading branch information
SMOLKEYS and SMOLKEYS authored Mar 29, 2024
1 parent 64d1a1f commit ee412c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/mindustry/entities/bullet/BulletType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -509,12 +511,13 @@ public void createSplashDamage(Bullet b, float x, float y){
}

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++;
}
}

Expand Down
1 change: 1 addition & 0 deletions core/src/mindustry/entities/comp/BulletComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<QuadTree> consumer){
Expand Down

0 comments on commit ee412c6

Please sign in to comment.