Added LaserTurret class / Updated bundles
This commit is contained in:
@@ -217,7 +217,7 @@ public class AmmoTypes implements ContentList{
|
||||
|
||||
spectreLaser = new AmmoType(TurretBullets.lancerLaser);
|
||||
|
||||
meltdownLaser = new AmmoType(TurretBullets.lancerLaser);
|
||||
meltdownLaser = new AmmoType(TurretBullets.meltdownLaser);
|
||||
|
||||
fuseShotgun = new AmmoType(Items.densealloy, TurretBullets.fuseShot, 1f){{
|
||||
shootEffect = Fx.none;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
};
|
||||
}};
|
||||
|
||||
lancer = new LaserTurret("lancer"){{
|
||||
lancer = new ChargeTurret("lancer"){{
|
||||
range = 90f;
|
||||
chargeTime = 60f;
|
||||
chargeMaxDelay = 30f;
|
||||
@@ -105,7 +105,7 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
|
||||
arc = new PowerTurret("arc"){{
|
||||
shootType = AmmoTypes.arc;
|
||||
reload = 30f;
|
||||
reload = 40f;
|
||||
shootShake = 1f;
|
||||
powerUsed = 5f;
|
||||
powerCapacity = 30f;
|
||||
@@ -218,7 +218,7 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
ammoTypes = new AmmoType[]{AmmoTypes.bulletDenseBig, AmmoTypes.bulletPyratiteBig, AmmoTypes.bulletThoriumBig};
|
||||
reload = 4f;
|
||||
restitution = 0.1f;
|
||||
ammoUseEffect = ShootFx.shellEjectMedium;
|
||||
ammoUseEffect = ShootFx.shellEjectBig;
|
||||
range = 200f;
|
||||
inaccuracy = 4f;
|
||||
recoil = 3f;
|
||||
@@ -232,9 +232,15 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
health = 155 * size * size;
|
||||
}};
|
||||
|
||||
meltdown = new PowerTurret("meltdown"){{
|
||||
meltdown = new LaserTurret("meltdown"){{
|
||||
shootType = AmmoTypes.meltdownLaser;
|
||||
shootCone = 40f;
|
||||
size = 4;
|
||||
powerUsed = 10f;
|
||||
range = 140f;
|
||||
reload = 60f;
|
||||
shootDuration = 60f;
|
||||
powerCapacity = 50f;
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class TurretBullets extends BulletList implements ContentList{
|
||||
public static BulletType fireball, basicFlame, lancerLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning, driverBolt, healBullet, arc;
|
||||
public static BulletType fireball, basicFlame, lancerLaser, meltdownLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning, driverBolt, healBullet, arc;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -161,6 +161,41 @@ public class TurretBullets extends BulletList implements ContentList{
|
||||
}
|
||||
};
|
||||
|
||||
meltdownLaser = new BulletType(0.001f, 140){
|
||||
Color[] colors = {Palette.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Palette.lancerLaser, Color.WHITE};
|
||||
float[] tscales = {1f, 0.7f, 0.5f, 0.2f};
|
||||
float[] lenscales = {1f, 1.1f, 1.13f, 1.14f};
|
||||
float length = 100f;
|
||||
|
||||
{
|
||||
hiteffect = BulletFx.hitLancer;
|
||||
despawneffect = Fx.none;
|
||||
hitsize = 4;
|
||||
lifetime = 16f;
|
||||
pierce = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
float baseLen = length * b.fout();
|
||||
|
||||
Lines.lineAngle(b.x, b.y, b.angle(), baseLen);
|
||||
for(int s = 0; s < 3; s++){
|
||||
Draw.color(colors[s]);
|
||||
for(int i = 0; i < tscales.length; i++){
|
||||
Lines.stroke(7f * b.fout() * (s == 0 ? 1.5f : s == 1 ? 1f : 0.3f) * tscales[i]);
|
||||
Lines.lineAngle(b.x, b.y, b.angle(), baseLen * lenscales[i]);
|
||||
}
|
||||
}
|
||||
Draw.reset();
|
||||
}
|
||||
};
|
||||
|
||||
fuseShot = new BulletType(0.01f, 70){
|
||||
int rays = 3;
|
||||
float raySpace = 2f;
|
||||
|
||||
@@ -37,23 +37,23 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
public Bullet(){
|
||||
}
|
||||
|
||||
public static void create(BulletType type, TeamTrait owner, float x, float y, float angle){
|
||||
create(type, owner, owner.getTeam(), x, y, angle);
|
||||
public static Bullet create(BulletType type, TeamTrait owner, float x, float y, float angle){
|
||||
return create(type, owner, owner.getTeam(), x, y, angle);
|
||||
}
|
||||
|
||||
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle){
|
||||
create(type, owner, team, x, y, angle, 1f);
|
||||
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle){
|
||||
return create(type, owner, team, x, y, angle, 1f);
|
||||
}
|
||||
|
||||
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl){
|
||||
create(type, owner, team, x, y, angle, velocityScl, 1f, null);
|
||||
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl){
|
||||
return create(type, owner, team, x, y, angle, velocityScl, 1f, null);
|
||||
}
|
||||
|
||||
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){
|
||||
create(type, owner, team, x, y, angle, velocityScl, lifetimeScl, null);
|
||||
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){
|
||||
return create(type, owner, team, x, y, angle, velocityScl, lifetimeScl, null);
|
||||
}
|
||||
|
||||
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
|
||||
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
|
||||
Bullet bullet = Pooling.obtain(Bullet.class, Bullet::new);
|
||||
bullet.type = type;
|
||||
bullet.owner = owner;
|
||||
@@ -78,14 +78,15 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
bullet.set(x, y);
|
||||
|
||||
bullet.add();
|
||||
return bullet;
|
||||
}
|
||||
|
||||
public static void create(BulletType type, Bullet parent, float x, float y, float angle){
|
||||
create(type, parent.owner, parent.team, x, y, angle);
|
||||
public static Bullet create(BulletType type, Bullet parent, float x, float y, float angle){
|
||||
return create(type, parent.owner, parent.team, x, y, angle);
|
||||
}
|
||||
|
||||
public static void create(BulletType type, Bullet parent, float x, float y, float angle, float velocityScl){
|
||||
create(type, parent.owner, parent.team, x, y, angle, velocityScl);
|
||||
public static Bullet create(BulletType type, Bullet parent, float x, float y, float angle, float velocityScl){
|
||||
return create(type, parent.owner, parent.team, x, y, angle, velocityScl);
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class UnitDrops{
|
||||
private static final int maxItems = 200;
|
||||
private static Item[] dropTable;
|
||||
|
||||
public static void dropItems(BaseUnit unit){
|
||||
//just don't drop anything for now
|
||||
/*
|
||||
if(Vars.itemGroup.size() > maxItems || unit.getTeam() != Team.red){
|
||||
return;
|
||||
}
|
||||
@@ -28,6 +25,6 @@ public class UnitDrops{
|
||||
unit.getVelocity().x + Mathf.range(3f), unit.getVelocity().y + Mathf.range(3f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package io.anuke.mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class ChargeTurret extends PowerTurret{
|
||||
|
||||
protected float chargeTime = 30f;
|
||||
protected int chargeEffects = 5;
|
||||
protected float chargeMaxDelay = 10f;
|
||||
protected Effect chargeEffect = Fx.none;
|
||||
protected Effect chargeBeginEffect = Fx.none;
|
||||
|
||||
public ChargeTurret(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shoot(Tile tile, AmmoType ammo){
|
||||
LaserTurretEntity entity = tile.entity();
|
||||
|
||||
useAmmo(tile);
|
||||
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
Effects.effect(chargeBeginEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
|
||||
for(int i = 0; i < chargeEffects; i++){
|
||||
Timers.run(Mathf.random(chargeMaxDelay), () -> {
|
||||
if(!isTurret(tile)) return;
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
Effects.effect(chargeEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
});
|
||||
}
|
||||
|
||||
entity.shooting = true;
|
||||
|
||||
Timers.run(chargeTime, () -> {
|
||||
if(!isTurret(tile)) return;
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
entity.recoil = recoil;
|
||||
entity.heat = 1f;
|
||||
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
|
||||
effects(tile);
|
||||
entity.shooting = false;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldTurn(Tile tile){
|
||||
LaserTurretEntity entity = tile.entity();
|
||||
return !entity.shooting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
return new LaserTurretEntity();
|
||||
}
|
||||
|
||||
public class LaserTurretEntity extends TurretEntity{
|
||||
public boolean shooting;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import io.anuke.mindustry.content.fx.BlockFx;
|
||||
import io.anuke.mindustry.entities.effect.Fire;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
|
||||
@@ -13,13 +12,9 @@ import io.anuke.ucore.util.Mathf;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class CooledTurret extends Turret{
|
||||
/**
|
||||
* How much reload is lowered by for each unit of liquid of heat capacity 1.
|
||||
*/
|
||||
/**How much reload is lowered by for each unit of liquid of heat capacity 1.*/
|
||||
protected float coolantMultiplier = 1f;
|
||||
/**
|
||||
* Max coolant used per tick.
|
||||
*/
|
||||
/**Max coolant used per tick.*/
|
||||
protected float maxUsed = 1f;
|
||||
protected Effect coolEffect = BlockFx.fuelburn;
|
||||
|
||||
@@ -28,7 +23,7 @@ public class CooledTurret extends Turret{
|
||||
hasLiquids = true;
|
||||
liquidCapacity = 20f;
|
||||
|
||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f, 0.01f)).update(false).optional(true);
|
||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.01f)).update(false).optional(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,11 +40,6 @@ public class CooledTurret extends Turret{
|
||||
if(Mathf.chance(0.04 * used)){
|
||||
Effects.effect(coolEffect, tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
|
||||
}
|
||||
|
||||
//don't use oil as coolant, thanks
|
||||
if(Mathf.chance(liquid.flammability / 10f * used)){
|
||||
Fire.create(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,62 +1,63 @@
|
||||
package io.anuke.mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class LaserTurret extends PowerTurret{
|
||||
|
||||
protected float chargeTime = 30f;
|
||||
protected int chargeEffects = 5;
|
||||
protected float chargeMaxDelay = 10f;
|
||||
protected Effect chargeEffect = Fx.none;
|
||||
protected Effect chargeBeginEffect = Fx.none;
|
||||
protected float firingMoveFract = 0.25f;
|
||||
protected float shootDuration = 100f;
|
||||
|
||||
public LaserTurret(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shoot(Tile tile, AmmoType ammo){
|
||||
protected void updateShooting(Tile tile){
|
||||
LaserTurretEntity entity = tile.entity();
|
||||
|
||||
useAmmo(tile);
|
||||
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
Effects.effect(chargeBeginEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
|
||||
for(int i = 0; i < chargeEffects; i++){
|
||||
Timers.run(Mathf.random(chargeMaxDelay), () -> {
|
||||
if(!isTurret(tile)) return;
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
Effects.effect(chargeEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
});
|
||||
if(entity.bulletLife > 0 && entity.bullet != null){
|
||||
tr.trns(entity.rotation, size * tilesize / 2, 0f);
|
||||
entity.bullet.setRotation(entity.rotation);
|
||||
entity.bullet.set(tile.drawx() + tr.x, tile.drawy() + tr.y);
|
||||
entity.bullet.time(0f);
|
||||
entity.bulletLife -= Timers.delta();
|
||||
if(entity.bulletLife <= 0f){
|
||||
entity.bullet = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
entity.shooting = true;
|
||||
if(entity.reload >= reload){
|
||||
AmmoType type = peekAmmo(tile);
|
||||
|
||||
Timers.run(chargeTime, () -> {
|
||||
if(!isTurret(tile)) return;
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
entity.recoil = recoil;
|
||||
entity.heat = 1f;
|
||||
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
|
||||
effects(tile);
|
||||
entity.shooting = false;
|
||||
});
|
||||
shoot(tile, type);
|
||||
|
||||
entity.reload = 0f;
|
||||
}else{
|
||||
entity.reload += tile.entity.delta() * peekAmmo(tile).reloadMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldTurn(Tile tile){
|
||||
protected void turnToTarget(Tile tile, float targetRot){
|
||||
LaserTurretEntity entity = tile.entity();
|
||||
return !entity.shooting;
|
||||
|
||||
entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * entity.delta() * (entity.bulletLife <= 0f ? firingMoveFract : 1f));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bullet(Tile tile, BulletType type, float angle){
|
||||
LaserTurretEntity entity = tile.entity();
|
||||
|
||||
entity.bullet = Bullet.create(type, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
|
||||
entity.bulletLife = shootDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +65,8 @@ public class LaserTurret extends PowerTurret{
|
||||
return new LaserTurretEntity();
|
||||
}
|
||||
|
||||
public class LaserTurretEntity extends TurretEntity{
|
||||
public boolean shooting;
|
||||
class LaserTurretEntity extends TurretEntity{
|
||||
Bullet bullet;
|
||||
float bulletLife;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
|
||||
if(shouldTurn(tile)){
|
||||
entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * entity.delta());
|
||||
turnToTarget(tile, targetRot);
|
||||
}
|
||||
|
||||
if(Angles.angleDist(entity.rotation, targetRot) < shootCone){
|
||||
@@ -235,6 +235,12 @@ public abstract class Turret extends Block{
|
||||
tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir));
|
||||
}
|
||||
|
||||
protected void turnToTarget(Tile tile, float targetRot){
|
||||
TurretEntity entity = tile.entity();
|
||||
|
||||
entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * entity.delta());
|
||||
}
|
||||
|
||||
public boolean shouldTurn(Tile tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user