This commit is contained in:
Anuken 2021-07-25 20:55:59 -04:00
parent f3b6f0a29b
commit aab79a90fb
3 changed files with 11 additions and 4 deletions

View file

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

View file

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

View file

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