From 1629afe49181be233bc81d370f2aa1fd0b13c24b Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sun, 9 Apr 2023 13:12:24 -0700 Subject: [PATCH] Ammo obliteration (#8498) * alwaysShooting for turrets similar to alwaysShooting for weapons * Weapon alwaysShooting takes shootCone into account Speaking of untested PRs... --- core/src/mindustry/type/Weapon.java | 2 +- .../world/blocks/defense/turrets/Turret.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 201a071c1d..7b9c341fb9 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -396,7 +396,7 @@ public class Weapon implements Cloneable{ mount.warmup >= minWarmup && //must be warmed up unit.vel.len() >= minShootVelocity && //check velocity requirements (mount.reload <= 0.0001f || (alwaysContinuous && mount.bullet == null)) && //reload has to be 0, or it has to be an always-continuous weapon - Angles.within(rotate ? mount.rotation : unit.rotation + baseRotation, mount.targetRotation, shootCone) //has to be within the cone + (alwaysShooting || Angles.within(rotate ? mount.rotation : unit.rotation + baseRotation, mount.targetRotation, shootCone)) //has to be within the cone ){ shoot(unit, mount, bulletX, bulletY, shootAngle); diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index ff35b122f9..6fc1f5ae10 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -83,6 +83,8 @@ public class Turret extends ReloadTurret{ public boolean displayAmmoMultiplier = true; /** If false, 'under' blocks like conveyors are not targeted. */ public boolean targetUnderBlocks = true; + /** If true, the turret will always shoot when it has ammo, regardless of targets in range or any control. */ + public boolean alwaysShooting = false; /** Function for choosing which unit to target. */ public Sortf unitSort = UnitSorts.closest; /** Filter for types of units to attack. */ @@ -304,7 +306,7 @@ public class Turret extends ReloadTurret{ } public boolean isShooting(){ - return (isControlled() ? unit.isShooting() : logicControlled() ? logicShooting : target != null); + return alwaysShooting || (isControlled() ? unit.isShooting() : logicControlled() ? logicShooting : target != null); } @Override @@ -425,11 +427,16 @@ public class Turret extends ReloadTurret{ turnToTarget(targetRot); } - if(Angles.angleDist(rotation, targetRot) < shootCone && canShoot){ + if(!alwaysShooting && Angles.angleDist(rotation, targetRot) < shootCone && canShoot){ wasShooting = true; updateShooting(); } } + + if(alwaysShooting){ + wasShooting = true; + updateShooting(); + } } if(coolant != null){