Laser turret behavior changes

This commit is contained in:
Anuken 2020-04-10 19:15:14 -04:00
parent 67a084a5e7
commit 758ace353e
2 changed files with 13 additions and 8 deletions

View File

@ -120,7 +120,6 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
drag(type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f));
//apply knockback based on spawns
//TODO move elsewhere
if(team() != state.rules.waveTeam){
float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f;
for(Tile spawn : spawner.getSpawns()){

View File

@ -23,6 +23,12 @@ public class LaserTurret extends PowerTurret{
coolantMultiplier = 1f;
}
@Override
public void init(){
consumes.powerCond(powerUse, entity -> ((LaserTurretEntity)entity).bullet != null || ((LaserTurretEntity)entity).target != null);
super.init();
}
@Override
public void setStats(){
super.setStats();
@ -49,7 +55,7 @@ public class LaserTurret extends PowerTurret{
bullet.time(0f);
heat = 1f;
recoil = recoilAmount;
bulletLife -= Time.delta();
bulletLife -= Time.delta() / Math.max(efficiency(), 0.00001f);
if(bulletLife <= 0f){
bullet = null;
}
@ -62,19 +68,19 @@ public class LaserTurret extends PowerTurret{
return;
}
if(reload >= reloadTime && (consValid() || tile.isEnemyCheat())){
if(reload <= 0 && (consValid() || tile.isEnemyCheat())){
BulletType type = peekAmmo();
shoot(type);
reload = 0f;
reload = reloadTime;
}else{
Liquid liquid = liquids().current();
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
float used = baseReloadSpeed() * (tile.isEnemyCheat() ? maxUsed : Math.min(liquids().get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier;
reload += used;
liquids().remove(liquid, used);
float used = (tile.isEnemyCheat() ? maxUsed * Time.delta() : Math.min(liquids.get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier;
reload -= used;
liquids.remove(liquid, used);
if(Mathf.chance(0.06 * used)){
coolEffect.at(x + Mathf.range(size * tilesize / 2f), y + Mathf.range(size * tilesize / 2f));
@ -84,7 +90,7 @@ public class LaserTurret extends PowerTurret{
@Override
protected void turnToTarget(float targetRot){
rotation = Angles.moveToward(rotation, targetRot, rotatespeed * delta() * (bulletLife > 0f ? firingMoveFract : 1f));
rotation = Angles.moveToward(rotation, targetRot, efficiency() * rotatespeed * delta() * (bulletLife > 0f ? firingMoveFract : 1f));
}
@Override