Ammo obliteration (#8498)

* alwaysShooting for turrets

similar to alwaysShooting for weapons

* Weapon alwaysShooting takes shootCone into account

Speaking of untested PRs...
This commit is contained in:
MEEPofFaith
2023-04-09 13:12:24 -07:00
committed by GitHub
parent 3b1e5eadd9
commit 1629afe491
2 changed files with 10 additions and 3 deletions

View File

@@ -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);

View File

@@ -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){