From 69cb000395858cfe4688e899760b3e0f3bc76c4f Mon Sep 17 00:00:00 2001 From: JasonP01 <131086642+JasonP01@users.noreply.github.com> Date: Wed, 2 Sep 2026 01:13:48 +0200 Subject: [PATCH] fix chance in remote places --- .../entities/bullet/EmpBulletType.java | 5 ++++- .../defense/turrets/TractorBeamTurret.java | 6 +++++- core/src/mindustry/world/meta/StatValues.java | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/core/src/mindustry/entities/bullet/EmpBulletType.java b/core/src/mindustry/entities/bullet/EmpBulletType.java index 139c181bde..1bd7ceabda 100644 --- a/core/src/mindustry/entities/bullet/EmpBulletType.java +++ b/core/src/mindustry/entities/bullet/EmpBulletType.java @@ -1,5 +1,6 @@ package mindustry.entities.bullet; +import arc.math.*; import mindustry.*; import mindustry.content.*; import mindustry.entities.*; @@ -57,7 +58,9 @@ public class EmpBulletType extends BasicBulletType{ hitPowerEffect.at(other.x, other.y, b.angleTo(other), hitColor); chainEffect.at(x, y, 0, hitColor, other); other.damage(damage * unitDamageScl); - other.apply(status, statusDuration); + if(Mathf.chance(getStatusChance(b))){ + other.apply(status, statusDuration); + } } }); } diff --git a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java index 7132167695..8f4681d6a6 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java @@ -30,6 +30,7 @@ public class TractorBeamTurret extends BaseTurret{ public Color laserColor = Color.white; public StatusEffect status = StatusEffects.none; public float statusDuration = 300; + public float statusChance = 1f; public Sound shootSound = Sounds.beamParallax; public float shootSoundVolume = 0.9f; @@ -59,6 +60,9 @@ public class TractorBeamTurret extends BaseTurret{ stats.add(Stat.targetsAir, targetAir); stats.add(Stat.targetsGround, targetGround); if(damage > 0) stats.add(Stat.damage, damage * 60f, StatUnit.perSecond); + if(status != StatusEffects.none && statusChance > 0f){ + stats.add(Stat.damage, StatValues.statusText(status, statusDuration, statusChance)); + } } @Override @@ -125,7 +129,7 @@ public class TractorBeamTurret extends BaseTurret{ target.damageContinuousPierce(damage * eff * timeScale * state.rules.blockDamage(team)); } - if(status != StatusEffects.none){ + if(status != StatusEffects.none && Mathf.chance(statusChance)){ target.apply(status, statusDuration); } diff --git a/core/src/mindustry/world/meta/StatValues.java b/core/src/mindustry/world/meta/StatValues.java index 83818065dc..dee8755b90 100644 --- a/core/src/mindustry/world/meta/StatValues.java +++ b/core/src/mindustry/world/meta/StatValues.java @@ -225,6 +225,16 @@ public class StatValues{ return withTooltip(element, content, false); } + /** Displays the chance for status effects */ + public static String statusText(StatusEffect status, float duration, float chance){ + return (chance < 1f ? Core.bundle.format("stat.chance", Strings.autoFixed(chance * 100f, 4)) : "") + + (status.hasEmoji() ? status.emoji() + " " : "") + + "[stat]" + status.localizedName + + (status.reactive ? "" : + "[lightgray] ~ [stat]" + Strings.autoFixed(duration / 60f, 1) + + "[lightgray] " + Core.bundle.get("unit.seconds")); + } + /** Displays an item with a specified amount. */ private static Stack stack(TextureRegion region, int amount, @Nullable UnlockableContent content, boolean tooltip){ Stack stack = new Stack(); @@ -885,15 +895,6 @@ public class StatValues{ }); } - private static String statusText(StatusEffect status, float duration, float chance){ - return (chance < 1f ? Core.bundle.format("stat.chance", Strings.autoFixed(chance * 100f, 4)) : "") + - (status.hasEmoji() ? status.emoji() + " " : "") + - "[stat]" + status.localizedName + - (status.reactive ? "" : - "[lightgray] ~ [stat]" + Strings.autoFixed(duration / 60f, 1) + - "[lightgray] " + Core.bundle.get("unit.seconds")); - } - //for AmmoListValue private static Cell sep(Table table, String text){ table.row();