Fixed #5648
This commit is contained in:
@@ -2055,6 +2055,7 @@ public class UnitTypes implements ContentList{
|
||||
rotateSpeed = 1.4f;
|
||||
rotateShooting = false;
|
||||
ammoType = AmmoTypes.powerHigh;
|
||||
ammoCapacity = 40;
|
||||
|
||||
//clip size is massive due to energy field
|
||||
clipSize = 250f;
|
||||
|
||||
@@ -14,6 +14,8 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class EnergyFieldAbility extends Ability{
|
||||
private static final Seq<Healthc> all = new Seq<>();
|
||||
|
||||
@@ -31,6 +33,7 @@ public class EnergyFieldAbility extends Ability{
|
||||
public float effectRadius = 5f, sectorRad = 0.14f, rotateSpeed = 0.5f;
|
||||
public int sectors = 5;
|
||||
public Color color = Pal.heal;
|
||||
public boolean useAmmo = true;
|
||||
|
||||
protected float timer, curStroke;
|
||||
protected boolean anyNearby = false;
|
||||
@@ -88,8 +91,7 @@ public class EnergyFieldAbility extends Ability{
|
||||
|
||||
curStroke = Mathf.lerpDelta(curStroke, anyNearby ? 1 : 0, 0.09f);
|
||||
|
||||
if((timer += Time.delta) >= reload){
|
||||
|
||||
if((timer += Time.delta) >= reload && (!useAmmo || unit.ammo > 0 || !state.rules.unitAmmo)){
|
||||
Tmp.v1.trns(unit.rotation - 90, x, y).add(unit.x, unit.y);
|
||||
float rx = Tmp.v1.x, ry = Tmp.v1.y;
|
||||
anyNearby = false;
|
||||
@@ -143,6 +145,10 @@ public class EnergyFieldAbility extends Ability{
|
||||
|
||||
if(anyNearby){
|
||||
shootSound.at(unit);
|
||||
|
||||
if(useAmmo && state.rules.unitAmmo){
|
||||
unit.ammo --;
|
||||
}
|
||||
}
|
||||
|
||||
timer = 0f;
|
||||
|
||||
@@ -384,9 +384,9 @@ public class UnitType extends UnlockableContent{
|
||||
|
||||
//dynamically create ammo capacity based on firing rate
|
||||
if(ammoCapacity < 0){
|
||||
float shotsPerSecond = weapons.sumf(w -> 60f / w.reload);
|
||||
float shotsPerSecond = weapons.sumf(w -> w.useAmmo ? 60f / w.reload : 0f);
|
||||
//duration of continuous fire without reload
|
||||
float targetSeconds = 30;
|
||||
float targetSeconds = 35;
|
||||
|
||||
ammoCapacity = Math.max(1, (int)(shotsPerSecond * targetSeconds));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user