diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 16482408fe..8a0dbfa31e 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -2811,7 +2811,6 @@ public class Blocks{ shootY = 3f; reload = 20f; - restitution = 0.03f; range = 110; shootCone = 15f; ammoUseEffect = Fx.casing1; @@ -3024,7 +3023,6 @@ public class Blocks{ recoil = 2f; reload = 80f; - cooldown = 0.03f; shake = 2f; shootEffect = Fx.lancerLaserShoot; smokeEffect = Fx.none; @@ -3227,9 +3225,7 @@ public class Blocks{ size = 2; range = 190f; reload = 31f; - restitution = 0.03f; ammoEjectBack = 3f; - cooldown = 0.03f; recoil = 3f; shake = 1f; shoot.shots = 4; @@ -3311,7 +3307,6 @@ public class Blocks{ velocityRnd = 0.1f; inaccuracy = 4f; recoil = 1f; - restitution = 0.04f; shootCone = 45f; liquidCapacity = 40f; shootEffect = Fx.shootLiquid; @@ -3330,7 +3325,6 @@ public class Blocks{ shoot = new ShootSpread(3, 20f); - restitution = 0.1f; shootCone = 30; size = 3; envEnabled |= Env.space; @@ -3444,9 +3438,7 @@ public class Blocks{ ammoEjectBack = 5f; ammoUseEffect = Fx.casing3Double; ammoPerShot = 2; - cooldown = 0.03f; velocityRnd = 0.2f; - restitution = 0.02f; recoil = 6f; shake = 2f; range = 290f; @@ -3571,8 +3563,7 @@ public class Blocks{ reload = 200f; ammoUseEffect = Fx.casing3Double; recoil = 5f; - restitution = 0.009f; - cooldown = 0.009f; + cooldownTime = reload; shake = 4f; size = 4; shootCone = 2f; @@ -3627,8 +3618,8 @@ public class Blocks{ }} ); reload = 7f; + recoilTime = reload * 2f; coolantMultiplier = 0.5f; - restitution = 0.1f; ammoUseEffect = Fx.casing3; range = 260f; inaccuracy = 3f; @@ -3736,7 +3727,6 @@ public class Blocks{ envEnabled |= Env.space; reload = 40f; recoil = 2f; - restitution = 0.03f; range = 190; shootCone = 3f; scaledHealth = 180; @@ -3794,7 +3784,6 @@ public class Blocks{ envEnabled |= Env.space; reload = 30f; recoil = 2f; - restitution = 0.03f; range = 125; shootCone = 40f; scaledHealth = 210; @@ -3952,7 +3941,6 @@ public class Blocks{ }}); }}; - restitution = 0.02f; shootWarmupSpeed = 0.08f; outlineColor = Pal.darkOutline; @@ -4034,7 +4022,6 @@ public class Blocks{ targetGround = false; inaccuracy = 8f; - restitution = 0.11f; shootWarmupSpeed = 0.08f; outlineColor = Pal.darkOutline; diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index 87e91c63aa..13c2a3f82e 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -399,6 +399,7 @@ public class ContentParser{ case "itemFlammable" -> block.consume((Consume)parser.readValue(ConsumeItemFlammable.class, child)); case "itemRadioactive" -> block.consume((Consume)parser.readValue(ConsumeItemRadioactive.class, child)); case "itemExplosive" -> block.consume((Consume)parser.readValue(ConsumeItemExplosive.class, child)); + case "itemExplode" -> block.consume((Consume)parser.readValue(ConsumeItemExplode.class, child)); case "items" -> block.consume((Consume)parser.readValue(ConsumeItems.class, child)); case "liquidFlammable" -> block.consume((Consume)parser.readValue(ConsumeLiquidFlammable.class, child)); case "liquid" -> block.consume((Consume)parser.readValue(ConsumeLiquid.class, child)); diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 001e123226..813ec46141 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -66,8 +66,10 @@ public class Weapon implements Cloneable{ public float shake = 0f; /** visual weapon knockback. */ public float recoil = 1.5f; - /** the time it returns back to its original position in ticks. uses reload time by default */ + /** time taken for weapon to return to starting position in ticks. uses reload time by default */ public float recoilTime = -1f; + /** power curve applied to visual recoil */ + public float recoilPow = 1.8f; /** ticks to cool down the heat region */ public float cooldownTime = 20f; /** projectile/effect offsets from center of weapon */ @@ -164,9 +166,10 @@ public class Weapon implements Cloneable{ float rotation = unit.rotation - 90, + realRecoil = Mathf.pow(mount.recoil, recoilPow) * recoil, weaponRotation = rotation + (rotate ? mount.rotation : 0), - wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -mount.recoil), - wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -mount.recoil); + wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -realRecoil), + wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -realRecoil); Draw.xscl = -Mathf.sign(flipSprite); Draw.rect(outlineRegion, wx, wy, weaponRotation); @@ -182,9 +185,10 @@ public class Weapon implements Cloneable{ float rotation = unit.rotation - 90, + realRecoil = Mathf.pow(mount.recoil, recoilPow) * recoil, weaponRotation = rotation + (rotate ? mount.rotation : baseRotation), - wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -mount.recoil), - wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -mount.recoil); + wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -realRecoil), + wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -realRecoil); if(shadow > 0){ Drawf.shadow(wx, wy, shadow); @@ -247,7 +251,7 @@ public class Weapon implements Cloneable{ boolean can = unit.canShoot(); float lastReload = mount.reload; mount.reload = Math.max(mount.reload - Time.delta * unit.reloadMultiplier, 0); - mount.recoil = Mathf.approachDelta(mount.recoil, 0, (Math.abs(recoil) * unit.reloadMultiplier) / recoilTime); + mount.recoil = Mathf.approachDelta(mount.recoil, 0, unit.reloadMultiplier / recoilTime); mount.warmup = Mathf.lerpDelta(mount.warmup, can && mount.shoot ? 1f : 0f, shootWarmupSpeed); mount.smoothReload = Mathf.lerpDelta(mount.smoothReload, mount.reload / reload, smoothReloadSpeed); @@ -317,7 +321,7 @@ public class Weapon implements Cloneable{ mount.bullet.rotation(weaponRotation + 90); mount.bullet.set(bulletX, bulletY); mount.reload = reload; - mount.recoil = recoil; + mount.recoil = 1f; unit.vel.add(Tmp.v1.trns(unit.rotation + 180f, mount.bullet.type.recoil)); if(shootSound != Sounds.none && !headless){ if(mount.sound == null) mount.sound = new SoundLoop(shootSound, 1f); @@ -416,7 +420,7 @@ public class Weapon implements Cloneable{ unit.vel.add(Tmp.v1.trns(shootAngle + 180f, bullet.recoil)); Effect.shake(shake, shake, bulletX, bulletY); - mount.recoil = recoil; + mount.recoil = 1f; mount.heat = 1f; } diff --git a/core/src/mindustry/type/weapons/PointDefenseWeapon.java b/core/src/mindustry/type/weapons/PointDefenseWeapon.java index d953c837c2..d9316eef30 100644 --- a/core/src/mindustry/type/weapons/PointDefenseWeapon.java +++ b/core/src/mindustry/type/weapons/PointDefenseWeapon.java @@ -58,7 +58,7 @@ public class PointDefenseWeapon extends Weapon{ bullet.shootEffect.at(shootX, shootY, rotation, color); bullet.hitEffect.at(target.x, target.y, color); shootSound.at(shootX, shootY, Mathf.random(0.9f, 1.1f)); - mount.recoil = recoil; + mount.recoil = 1f; mount.heat = 1f; } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 58bd40b52d..8cc7639120 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -106,10 +106,12 @@ public class Turret extends ReloadTurret{ public boolean linearWarmup = false; /** Visual amount by which the turret recoils back per shot. */ public float recoil = 1f; - /** TODO rename */ - public float restitution = 0.02f; - /** TODO rename */ - public float cooldown = 0.02f; + /** ticks taken for turret to return to starting position in ticks. uses reload time by default */ + public float recoilTime = -1f; + /** power curve applied to visual recoil */ + public float recoilPow = 1.8f; + /** ticks to cool down the heat region */ + public float cooldownTime = 20f; /** Visual elevation of turret shadow, -1 to use defaults. */ public float elevation = -1f; /** How much the screen shakes per shot. */ @@ -159,6 +161,8 @@ public class Turret extends ReloadTurret{ public void init(){ if(shootY == Float.NEGATIVE_INFINITY) shootY = size * tilesize / 2f; if(elevation < 0) elevation = size / 2f; + if(recoilTime < 0f) recoilTime = reload; + if(cooldownTime < 0f) cooldownTime = reload; super.init(); } @@ -339,14 +343,13 @@ public class Turret extends ReloadTurret{ wasShooting = false; - //TODO do not lerp - curRecoil = Mathf.lerpDelta(curRecoil, 0f, restitution); - heat = Mathf.lerpDelta(heat, 0f, cooldown); + curRecoil = Math.max(curRecoil - Time.delta / recoilTime , 0); + heat = Math.max(heat - Time.delta / cooldownTime, 0); unit.tile(this); unit.rotation(rotation); unit.team(team); - recoilOffset.trns(rotation, -curRecoil); + recoilOffset.trns(rotation, -Mathf.pow(curRecoil, recoilPow) * recoil); if(logicControlTime > 0){ logicControlTime -= Time.delta; @@ -550,7 +553,7 @@ public class Turret extends ReloadTurret{ Effect.shake(shake, shake, this); } - curRecoil = recoil; + curRecoil = 1f; heat = 1f; if(!consumeAmmoOnce){ diff --git a/core/src/mindustry/world/consumers/ConsumeItemExplode.java b/core/src/mindustry/world/consumers/ConsumeItemExplode.java index cb22aeb40c..64715902eb 100644 --- a/core/src/mindustry/world/consumers/ConsumeItemExplode.java +++ b/core/src/mindustry/world/consumers/ConsumeItemExplode.java @@ -18,7 +18,7 @@ public class ConsumeItemExplode extends ConsumeItemFilter{ public Effect explodeEffect = Fx.generatespark; public ConsumeItemExplode(float threshold){ - super(item -> item.explosiveness >= threshold); + this.filter = item -> item.explosiveness >= this.threshold; this.threshold = threshold; }