Skip to content

Commit

Permalink
Sync crit
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Jun 6, 2024
1 parent bf35f4a commit b34f4d9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/progressed/entities/bullet/physical/CritBulletType.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import static mindustry.Vars.*;

public class CritBulletType extends BasicBulletType{
protected static Rand critRand = new Rand();

public float critChance = 0.15f, critMultiplier = 5f;
public Effect critEffect = OtherFx.crit;
public boolean bouncing, despawnHitEffects = true;
Expand All @@ -36,6 +38,13 @@ public CritBulletType(float speed, float damage){
this(speed, damage, "bullet");
}

public static boolean critChance(Bullet b, float chance){
if(chance >= 1) return true;

critRand.setSeed(b.id);
return critRand.nextFloat() < chance;
}

@Override
public void init(){
super.init();
Expand All @@ -45,7 +54,9 @@ public void init(){

@Override
public void init(Bullet b){
if(b.data == null) b.data = Mathf.chance(critChance) ? "crit" : null;
if(b.data == null){
b.data = critChance(b, critChance) ? "crit" : null;
}
if(isCrit(b)) b.damage *= critMultiplier;

super.init(b);
Expand Down

0 comments on commit b34f4d9

Please sign in to comment.