diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index 13c2a3f82e..9cfdb57a3d 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -279,7 +279,6 @@ public class ContentParser{ readFields(obj, data); return obj; }); - put(Ability.class, (type, data) -> { Class oc = resolve(data.getString("type", "")); data.remove("type"); diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 50d8c4d6e4..26a08c2eff 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -75,6 +75,8 @@ public class Weapon implements Cloneable{ public float shootX = 0f, shootY = 3f; /** offsets of weapon position on unit */ public float x = 5f, y = 0f; + /** Random spread on the X axis. */ + public float xRand = 0f; /** pattern used for bullets */ public ShootPattern shoot = new ShootPattern(); /** radius of shadow drawn under the weapon; <0 to disable */ @@ -398,11 +400,12 @@ public class Weapon implements Cloneable{ if(!unit.isAdded()) return; float + xSpread = Mathf.range(xRand), weaponRotation = unit.rotation - 90 + (rotate ? mount.rotation : baseRotation), mountX = unit.x + Angles.trnsx(unit.rotation - 90, x, y), mountY = unit.y + Angles.trnsy(unit.rotation - 90, x, y), - bulletX = mountX + Angles.trnsx(weaponRotation, this.shootX + xOffset, this.shootY + yOffset), - bulletY = mountY + Angles.trnsy(weaponRotation, this.shootX + xOffset, this.shootY + yOffset), + bulletX = mountX + Angles.trnsx(weaponRotation, this.shootX + xOffset + xSpread, this.shootY + yOffset), + bulletY = mountY + Angles.trnsy(weaponRotation, this.shootX + xOffset + xSpread, this.shootY + yOffset), shootAngle = bulletRotation(unit, mount, bulletX, bulletY) + angleOffset, lifeScl = bullet.scaleLife ? Mathf.clamp(Mathf.dst(bulletX, bulletY, mount.aimX, mount.aimY) / bullet.range) : 1f, angle = angleOffset + shootAngle + Mathf.range(inaccuracy); diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 178cf9254f..2a809a5889 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -56,6 +56,8 @@ public class Turret extends ReloadTurret{ public float shootCone = 8f; /** Turret shoot point. */ public float shootX = 0f, shootY = Float.NEGATIVE_INFINITY; + /** Random spread on the X axis. */ + public float xRand = 0f; /** Minimum bullet range. Used for artillery only. */ public float minRange = 0f; /** Minimum warmup needed to fire. */ @@ -533,8 +535,9 @@ public class Turret extends ReloadTurret{ if(dead || (!consumeAmmoOnce && !hasAmmo())) return; float - bulletX = x + Angles.trnsx(rotation - 90, shootX + xOffset, shootY + yOffset), - bulletY = y + Angles.trnsy(rotation - 90, shootX + xOffset, shootY + yOffset), + xSpread = Mathf.range(xRand), + bulletX = x + Angles.trnsx(rotation - 90, shootX + xOffset + xSpread, shootY + yOffset), + bulletY = y + Angles.trnsy(rotation - 90, shootX + xOffset + xSpread, shootY + yOffset), shootAngle = rotation + angleOffset + Mathf.range(inaccuracy); float lifeScl = type.scaleLife ? Mathf.clamp(Mathf.dst(bulletX, bulletY, targetPos.x, targetPos.y) / type.range, minRange / type.range, range() / type.range) : 1f;