From 9aa45b2a7c58fd2c96f6304061588e08d275e418 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Mon, 8 May 2023 14:05:27 -0700 Subject: [PATCH 1/4] Attempt healing targetting even if the bullet doesn't collide with ground targets (#8516) --- core/src/mindustry/world/blocks/defense/turrets/Turret.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 6fc1f5ae10..2a3862837f 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -468,10 +468,10 @@ public class Turret extends ReloadTurret{ target = Units.bestEnemy(team, x, y, range, e -> !e.dead() && !e.isGrounded() && unitFilter.get(e), unitSort); }else{ target = Units.bestTarget(team, x, y, range, e -> !e.dead() && unitFilter.get(e) && (e.isGrounded() || targetAir) && (!e.isGrounded() || targetGround), b -> targetGround && buildingFilter.get(b), unitSort); + } - if(target == null && canHeal()){ - target = Units.findAllyTile(team, x, y, range, b -> b.damaged() && b != this); - } + if(target == null && canHeal()){ + target = Units.findAllyTile(team, x, y, range, b -> b.damaged() && b != this); } } From 552d6a2e9fd52c8abbd467116aaa06322f5e2fda Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Mon, 8 May 2023 15:41:56 -0700 Subject: [PATCH 2/4] Smoother Screenshake Reduction (#8310) * Smoother Screenshake Reduction Screen shake will now always reach 0 no matter the intensity or duration without being cut off early. * Keep the max reduction rate --- core/src/mindustry/core/Renderer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index 1966f79cd2..a0cb1b37f3 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -72,6 +72,8 @@ public class Renderer implements ApplicationListener{ landPTimer, //intensity for screen shake shakeIntensity, + //reduction rate of screen shake + shakeReduction, //current duration of screen shake shakeTime; //for landTime > 0: if true, core is currently *launching*, otherwise landing. @@ -83,14 +85,15 @@ public class Renderer implements ApplicationListener{ Shaders.init(); Events.on(ResetEvent.class, e -> { - shakeTime = shakeIntensity = 0f; + shakeTime = shakeIntensity = shakeReduction = 0f; camShakeOffset.setZero(); }); } public void shake(float intensity, float duration){ - shakeIntensity = Math.max(shakeIntensity, intensity); + shakeIntensity = Math.max(shakeIntensity, Mathf.clamp(intensity, 0, 100)); shakeTime = Math.max(shakeTime, duration); + shakeReduction = Math.max(shakeReduction, shakeIntensity / shakeTime); } public void addEnvRenderer(int mask, Runnable render){ @@ -210,7 +213,7 @@ public class Renderer implements ApplicationListener{ float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * 0.75f; camShakeOffset.setToRandomDirection().scl(Mathf.random(intensity)); camera.position.add(camShakeOffset); - shakeIntensity -= 0.25f * Time.delta; + shakeIntensity -= shakeReduction * Time.delta; shakeTime -= Time.delta; shakeIntensity = Mathf.clamp(shakeIntensity, 0f, 100f); }else{ From 2289f29bd50f78c5b0693316c62e5806abbe0e7a Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Tue, 9 May 2023 06:33:59 -0700 Subject: [PATCH 3/4] Revert Math.max in shakeReduction (#8570) --- core/src/mindustry/core/Renderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index a0cb1b37f3..1eb37957f2 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -93,7 +93,7 @@ public class Renderer implements ApplicationListener{ public void shake(float intensity, float duration){ shakeIntensity = Math.max(shakeIntensity, Mathf.clamp(intensity, 0, 100)); shakeTime = Math.max(shakeTime, duration); - shakeReduction = Math.max(shakeReduction, shakeIntensity / shakeTime); + shakeReduction = shakeIntensity / shakeTime; } public void addEnvRenderer(int mask, Runnable render){ From 1373381554e87ac8420d26a998a6009201f550d8 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Tue, 9 May 2023 17:34:13 -0700 Subject: [PATCH 4/4] Properly handle missile units shooting more missile units (#8359) * Properly handle missile units shooting more missile units * Remove `shooter`, just pass down the owner --- core/src/mindustry/entities/bullet/BulletType.java | 10 ++++++---- core/src/mindustry/type/Weapon.java | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 9797160948..5528832126 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -554,7 +554,7 @@ public class BulletType extends Content implements Cloneable{ public void init(Bullet b){ - if(killShooter && b.owner() instanceof Healthc h){ + if(killShooter && b.owner() instanceof Healthc h && !h.dead()){ h.kill(); } @@ -700,7 +700,6 @@ public class BulletType extends Content implements Cloneable{ return create(owner, team, x, y, angle, -1, velocityScl, lifetimeScl, null); } - public @Nullable Bullet create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Mover mover){ return create(owner, team, x, y, angle, -1, velocityScl, lifetimeScl, null, mover); } @@ -732,24 +731,27 @@ public class BulletType extends Content implements Cloneable{ Unit spawned = spawnUnit.create(team); spawned.set(x, y); spawned.rotation = angle; + //immediately spawn at top speed, since it was launched if(spawnUnit.missileAccelTime <= 0f){ spawned.vel.trns(angle, spawnUnit.speed); } + //assign unit owner if(spawned.controller() instanceof MissileAI ai){ if(owner instanceof Unit unit){ ai.shooter = unit; } - if(owner instanceof ControlBlock control){ ai.shooter = control.unit(); } - } spawned.add(); } + //Since bullet init is never called, handle killing shooter here + if(killShooter && owner instanceof Healthc h && !h.dead()) h.kill(); + //no bullet returned return null; } diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index a52b423dba..b195b92e59 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -10,6 +10,7 @@ import arc.math.geom.*; import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.*; +import mindustry.ai.types.*; import mindustry.annotations.Annotations.*; import mindustry.audio.*; import mindustry.content.*; @@ -456,7 +457,8 @@ public class Weapon implements Cloneable{ lifeScl = bullet.scaleLife ? Mathf.clamp(Mathf.dst(bulletX, bulletY, mount.aimX, mount.aimY) / bullet.range) : 1f, angle = angleOffset + shootAngle + Mathf.range(inaccuracy + bullet.inaccuracy); - mount.bullet = bullet.create(unit, unit.team, bulletX, bulletY, angle, -1f, (1f - velocityRnd) + Mathf.random(velocityRnd), lifeScl, null, mover, mount.aimX, mount.aimY); + Entityc shooter = unit.controller() instanceof MissileAI ai ? ai.shooter : unit; //Pass the missile's shooter down to its bullets + mount.bullet = bullet.create(shooter, unit.team, bulletX, bulletY, angle, -1f, (1f - velocityRnd) + Mathf.random(velocityRnd), lifeScl, null, mover, mount.aimX, mount.aimY); handleBullet(unit, mount, mount.bullet); if(!continuous){