New WIP missile turret

This commit is contained in:
Anuken 2022-06-29 17:37:32 -04:00
parent 4e3f7eccae
commit 36aa56f251
24 changed files with 282 additions and 52 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -569,3 +569,5 @@
63115=fracture|block-fracture-ui
63114=renale|unit-renale-ui
63113=lustre|block-lustre-ui
63112=scathe|block-scathe-ui
63111=scathe-missile|unit-scathe-missile-ui

Binary file not shown.

View file

@ -1,5 +1,6 @@
package mindustry.ai.types;
import arc.math.*;
import arc.util.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
@ -18,7 +19,7 @@ public class MissileAI extends AIController{
}
//move forward forever
unit.moveAt(vec.trns(unit.rotation, unit.speed()));
unit.moveAt(vec.trns(unit.rotation, unit.type.missileAccelTime <= 0f ? unit.speed() : Mathf.pow(Math.min(time / unit.type.missileAccelTime, 1f), 2f) * unit.speed()));
var build = unit.buildOn();

View file

@ -5,6 +5,7 @@ import arc.math.*;
import arc.struct.*;
import mindustry.*;
import mindustry.entities.*;
import mindustry.entities.abilities.*;
import mindustry.entities.bullet.*;
import mindustry.entities.effect.*;
import mindustry.entities.part.*;
@ -13,6 +14,7 @@ import mindustry.entities.pattern.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.type.unit.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.campaign.*;
@ -69,7 +71,7 @@ public class Blocks{
siliconSmelter, siliconCrucible, kiln, graphitePress, plastaniumCompressor, multiPress, phaseWeaver, surgeSmelter, pyratiteMixer, blastMixer, cryofluidMixer,
melter, separator, disassembler, sporePress, pulverizer, incinerator, coalCentrifuge,
//erekir
//crafting - erekir
siliconArcFurnace, electrolyzer, oxidationChamber, atmosphericConcentrator, electricHeater, slagHeater, phaseHeater, heatRedirector, slagIncinerator,
carbideCrucible, slagCentrifuge, surgeCrucible, cyanogenSynthesizer, phaseSynthesizer, heatReactor,
@ -134,7 +136,7 @@ public class Blocks{
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, foreshadow, spectre, meltdown, segment, parallax, tsunami,
//turrets - erekir
breach, diffuse, sublimate, titan, disperse, afflict, lustre,
breach, diffuse, sublimate, titan, disperse, afflict, lustre, scathe,
//units
groundFactory, airFactory, navalFactory,
@ -922,25 +924,6 @@ public class Blocks{
consumePower(4f);
}};
siliconArcFurnace = new GenericCrafter("silicon-arc-furnace"){{
requirements(Category.crafting, with(Items.beryllium, 70, Items.graphite, 80));
craftEffect = Fx.none;
outputItem = new ItemStack(Items.silicon, 4);
craftTime = 50f;
size = 3;
hasPower = true;
hasLiquids = false;
envEnabled |= Env.space | Env.underwater;
envDisabled = Env.none;
itemCapacity = 30;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawArcSmelt(), new DrawDefault());
fogRadius = 3;
researchCost = with(Items.beryllium, 150, Items.graphite, 50);
consumeItems(with(Items.graphite, 1, Items.sand, 4));
consumePower(6f);
}};
kiln = new GenericCrafter("kiln"){{
requirements(Category.crafting, with(Items.copper, 60, Items.graphite, 30, Items.lead, 30));
craftEffect = Fx.smeltsmoke;
@ -1157,6 +1140,27 @@ public class Blocks{
consumePower(0.50f);
}};
//erekir
siliconArcFurnace = new GenericCrafter("silicon-arc-furnace"){{
requirements(Category.crafting, with(Items.beryllium, 70, Items.graphite, 80));
craftEffect = Fx.none;
outputItem = new ItemStack(Items.silicon, 4);
craftTime = 50f;
size = 3;
hasPower = true;
hasLiquids = false;
envEnabled |= Env.space | Env.underwater;
envDisabled = Env.none;
itemCapacity = 30;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawArcSmelt(), new DrawDefault());
fogRadius = 3;
researchCost = with(Items.beryllium, 150, Items.graphite, 50);
consumeItems(with(Items.graphite, 1, Items.sand, 4));
consumePower(6f);
}};
//TODO better name
electrolyzer = new GenericCrafter("electrolyzer"){{
requirements(Category.crafting, with(Items.silicon, 50, Items.graphite, 40, Items.beryllium, 130, Items.tungsten, 80));
@ -3798,7 +3802,7 @@ public class Blocks{
smokeEffect = Fx.shootSmokeSquareSparse;
ammoMultiplier = 1;
hitColor = backColor = trailColor = Color.valueOf("ea8878");
frontColor = Color.valueOf("feb380");
frontColor = Pal.redLight;
trailWidth = 6f;
trailLength = 3;
hitEffect = despawnEffect = Fx.hitSquaresColor;
@ -3930,7 +3934,7 @@ public class Blocks{
splashDamageRadius = 65f;
splashDamage = 350f;
scaledSplashDamage = true;
backColor = hitColor = trailColor = Color.valueOf("ea8878").lerp(Color.valueOf("feb380"), 0.5f);
backColor = hitColor = trailColor = Color.valueOf("ea8878").lerp(Pal.redLight, 0.5f);
frontColor = Color.white;
ammoMultiplier = 1f;
@ -4002,7 +4006,7 @@ public class Blocks{
requirements(Category.turret, with(Items.thorium, 50, Items.oxide, 150, Items.silicon, 200, Items.beryllium, 350));
ammo(Items.tungsten, new BasicBulletType(){{
damage = 60;
damage = 65;
speed = 8.5f;
width = height = 16;
shrinkY = 0.3f;
@ -4071,7 +4075,7 @@ public class Blocks{
outlineColor = Pal.darkOutline;
scaledHealth = 280;
range = 270f;
range = 310f;
size = 4;
coolant = consume(new ConsumeLiquid(Liquids.water, 20f / 60f));
@ -4100,7 +4104,7 @@ public class Blocks{
pierceCap = 2;
fragOnHit = false;
speed = 5f;
damage = 150f;
damage = 170f;
lifetime = 80f;
width = height = 16f;
backColor = Pal.surge;
@ -4117,12 +4121,12 @@ public class Blocks{
waveRad = 40f;
}};
fragBullet = intervalBullet = new BasicBulletType(3f, 20){{
fragBullet = intervalBullet = new BasicBulletType(3f, 30){{
width = 9f;
hitSize = 5f;
height = 15f;
pierce = true;
lifetime = 30f;
lifetime = 35f;
pierceBuilding = true;
hitColor = backColor = trailColor = Pal.surge;
frontColor = Color.white;
@ -4201,7 +4205,7 @@ public class Blocks{
range = 100f;
shootType = new PointLaserBulletType(){{
damage = 150f;
damage = 140f;
buildingDamageMultiplier = 0.3f;
hitColor = Color.valueOf("fda981");
}};
@ -4257,6 +4261,154 @@ public class Blocks{
consumeLiquid(Liquids.nitrogen, 5f / 60f);
}};
scathe = new ItemTurret("scathe"){{
requirements(Category.turret, with(Items.silicon, 300, Items.graphite, 400, Items.tungsten, 450, Items.carbide, 250));
ammo(
Items.carbide, new BasicBulletType(0f, 1){{
shootEffect = Fx.shootBig;
smokeEffect = Fx.shootSmokeMissile;
spawnUnit = new MissileUnitType("scathe-missile"){{
speed = 4.6f;
maxRange = 6f;
lifetime = 60f * 5.5f;
outlineColor = Pal.darkOutline;
engineColor = trailColor = Pal.redLight;
engineLayer = Layer.effect;
engineSize = 3.1f;
engineOffset = 10f;
rotateSpeed = 0f;
trailLength = 18;
missileAccelTime = 50f;
lowAltitude = true;
fogRadius = 6f;
health = 160;
weapons.add(new Weapon(){{
shootCone = 360f;
mirror = false;
reload = 1f;
deathExplosionEffect = Fx.massiveExplosion;
shootOnDeath = true;
shake = 10f;
bullet = new ExplosionBulletType(500f, 65f){{
hitColor = Pal.redLight;
shootEffect = new MultiEffect(Fx.massiveExplosion, Fx.scatheExplosion, Fx.scatheLight, new WaveEffect(){{
lifetime = 10f;
strokeFrom = 4f;
sizeTo = 130f;
}});
fragLifeMin = 0.1f;
fragBullets = 7;
fragBullet = new ArtilleryBulletType(3.4f, 30){{
drag = 0.02f;
hitEffect = Fx.massiveExplosion;
despawnEffect = Fx.scatheSlash;
knockback = 0.8f;
lifetime = 23f;
width = height = 18f;
collidesTiles = false;
splashDamageRadius = 40f;
splashDamage = 80f;
backColor = trailColor = hitColor = Pal.redLight;
frontColor = Color.white;
smokeEffect = Fx.shootBigSmoke2;
despawnShake = 7f;
lightRadius = 30f;
lightColor = Pal.redLight;
lightOpacity = 0.5f;
trailLength = 20;
trailWidth = 3.5f;
trailEffect = Fx.none;
}};
}};
}});
abilities.add(new MoveEffectAbility(){{
effect = Fx.missileTrailSmoke;
rotation = 180f;
y = -9f;
color = Color.grays(0.6f).lerp(Pal.redLight, 0.5f).a(0.4f);
interval = 7f;
}});
}};
}}
);
drawer = new DrawTurret("reinforced-"){{
parts.add(new RegionPart("-blade"){{
progress = PartProgress.warmup;
heatProgress = PartProgress.warmup;
heatColor = Color.red;
moveRot = -22f;
moveX = 0f;
moveY = -5f;
mirror = true;
children.add(new RegionPart("-side"){{
progress = PartProgress.warmup.delay(0.6f);
heatProgress = PartProgress.recoil;
heatColor = Color.red;
mirror = true;
under = false;
moveY = -4f;
moveX = 1f;
moves.add(new PartMove(PartProgress.recoil, 1f, 6f, -40f));
}});
}},
new RegionPart("-mid"){{
progress = PartProgress.recoil;
heatProgress = PartProgress.warmup.add(-0.2f).add(p -> Mathf.sin(9f, 0.2f) * p.warmup);
mirror = false;
under = true;
moveY = -5f;
}}, new RegionPart("-missile"){{
progress = PartProgress.reload.curve(Interp.pow2In);
colorTo = new Color(1f, 1f, 1f, 0f);
color = Color.white;
mixColorTo = Pal.accent;
mixColor = new Color(1f, 1f, 1f, 0f);
outline = false;
under = true;
layerOffset = -0.01f;
moves.add(new PartMove(PartProgress.warmup.inv(), 0f, -4f, 0f));
}});
}};
recoil = 0.5f;
coolantMultiplier = 6f;
minWarmup = 0.94f;
shootWarmupSpeed = 0.03f;
targetAir = false;
shake = 6f;
ammoPerShot = 30;
maxAmmo = 30;
shootY = -1;
outlineColor = Pal.darkOutline;
size = 4;
envEnabled |= Env.space;
reload = 600f;
range = 1350;
shootCone = 1f;
scaledHealth = 220;
rotateSpeed = 0.9f;
researchCostMultiplier = 0.05f;
coolant = consume(new ConsumeLiquid(Liquids.water, 15f / 60f));
limitRange();
}};
//TODO 3 more turrets.
//endregion

View file

@ -436,12 +436,64 @@ public class Fx{
float rad = fout * ((2f + intensity) * 2.35f);
Fill.circle(e.x + x, e.y + y, rad);
Drawf.light(e.x + x, e.y + y, rad * 2.5f, Pal.berylShot, 0.5f);
Drawf.light(e.x + x, e.y + y, rad * 2.5f, b.color, 0.5f);
});
});
}
}),
missileTrailSmoke = new Effect(180f, 300f, b -> {
float intensity = 2f;
color(b.color, 0.7f);
for(int i = 0; i < 4; i++){
rand.setSeed(b.id*2 + i);
float lenScl = rand.random(0.5f, 1f);
int fi = i;
b.scaled(b.lifetime * lenScl, e -> {
randLenVectors(e.id + fi - 1, e.fin(Interp.pow10Out), (int)(2.9f * intensity), 13f * intensity, (x, y, in, out) -> {
float fout = e.fout(Interp.pow5Out) * rand.random(0.5f, 1f);
float rad = fout * ((2f + intensity) * 2.35f);
Fill.circle(e.x + x, e.y + y, rad);
Drawf.light(e.x + x, e.y + y, rad * 2.5f, b.color, 0.5f);
});
});
}
}).layer(Layer.bullet - 1f),
scatheExplosion = new Effect(60f, 160f, e -> {
color(e.color);
stroke(e.fout() * 5f);
float circleRad = 6f + e.finpow() * 60f;
Lines.circle(e.x, e.y, circleRad);
rand.setSeed(e.id);
for(int i = 0; i < 16; i++){
float angle = rand.random(360f);
float lenRand = rand.random(0.5f, 1f);
Tmp.v1.trns(angle, circleRad);
for(int s : Mathf.signs){
Drawf.tri(e.x + Tmp.v1.x, e.y + Tmp.v1.y, e.foutpow() * 40f, e.fout() * 30f * lenRand + 6f, angle + 90f + s * 90f);
}
}
}),
scatheLight = new Effect(60f, 160f, e -> {
float circleRad = 6f + e.finpow() * 60f;
color(e.color, e.foutpow());
Fill.circle(e.x, e.y, circleRad);
}).layer(Layer.bullet + 2f),
scatheSlash = new Effect(40f, 160f, e -> {
Draw.color(e.color);
for(int s : Mathf.signs){
Drawf.tri(e.x, e.y, e.fout() * 25f, e.foutpow() * 66f + 6f, e.rotation + s * 90f);
}
}),
dynamicSpikes = new Effect(40f, 100f, e -> {
color(e.color);
stroke(e.fout() * 2f);
@ -1559,6 +1611,18 @@ public class Fx{
}
}),
shootSmokeMissile = new Effect(130f, 300f, e -> {
color(Pal.redLight);
alpha(0.5f);
rand.setSeed(e.id);
for(int i = 0; i < 35; i++){
v.trns(e.rotation + rand.range(21f), rand.random(e.finpow() * 90f)).add(rand.range(3f), rand.range(3f));
e.scaled(e.lifetime * rand.random(0.2f, 1f), b -> {
Fill.circle(e.x + v.x, e.y + v.y, b.fout() * 9f + 0.3f);
});
}
}),
regenParticle = new Effect(100f, e -> {
color(Pal.regen);

View file

@ -9,7 +9,7 @@ import mindustry.gen.*;
public class MoveEffectAbility extends Ability{
public float minVelocity = 0.08f;
public float interval = 3f;
public float x, y;
public float x, y, rotation;
public boolean rotateEffect = false;
public float effectParam = 3f;
public boolean teamColor = false;
@ -37,7 +37,7 @@ public class MoveEffectAbility extends Ability{
if(unit.vel.len2() >= minVelocity * minVelocity && (counter >= interval)){
Tmp.v1.trns(unit.rotation - 90f, x, y);
counter %= interval;
effect.at(Tmp.v1.x + unit.x, Tmp.v1.y + unit.y, rotateEffect ? unit.rotation : effectParam, teamColor ? unit.team.color : color, parentizeEffects ? unit : null);
effect.at(Tmp.v1.x + unit.x, Tmp.v1.y + unit.y, (rotateEffect ? unit.rotation : effectParam) + rotation, teamColor ? unit.team.color : color, parentizeEffects ? unit : null);
}
}
}

View file

@ -654,10 +654,19 @@ public class BulletType extends Content implements Cloneable{
spawned.set(x, y);
spawned.rotation = angle;
//immediately spawn at top speed, since it was launched
spawned.vel.trns(angle, spawnUnit.speed);
if(spawnUnit.missileAccelTime <= 0f){
spawned.vel.trns(angle, spawnUnit.speed);
}
//assign unit owner
if(spawned.controller() instanceof MissileAI ai && owner instanceof Unit unit){
ai.shooter = unit;
if(spawned.controller() instanceof MissileAI ai){
if(owner instanceof Unit unit){
ai.shooter = unit;
}
if(owner instanceof ControlBlock control){
ai.shooter = control.unit();
}
}
spawned.add();
}

View file

@ -406,7 +406,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
//make sure trail doesn't just go poof
if(trail != null && trail.size() > 0){
Fx.trailFade.at(x, y, trail.width(), team.color, trail.copy());
Fx.trailFade.at(x, y, trail.width(), type.trailColor == null ? team.color : type.trailColor, trail.copy());
}
}
@ -584,7 +584,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
}
for(WeaponMount mount : mounts){
if(mount.weapon.shootOnDeath && !(mount.weapon.bullet.killShooter && mount.shoot)){
if(mount.weapon.shootOnDeath && !(mount.weapon.bullet.killShooter && mount.totalShots > 0)){
mount.reload = 0f;
mount.shoot = true;
mount.weapon.update(self(), mount);

View file

@ -34,7 +34,7 @@ public class RegionPart extends DrawPart{
public float outlineLayerOffset = -0.001f;
public float x, y, rotation;
public float moveX, moveY, moveRot;
public @Nullable Color color, colorTo;
public @Nullable Color color, colorTo, mixColor, mixColorTo;
public Color heatColor = Pal.turretHeat.cpy();
public Seq<DrawPart> children = new Seq<>();
public Seq<PartMove> moves = new Seq<>();
@ -105,6 +105,13 @@ public class RegionPart extends DrawPart{
}else if(color != null){
Draw.color(color);
}
if(mixColor != null && mixColorTo != null){
Draw.mixcol(mixColor, mixColorTo, prog);
}else if(mixColor != null){
Draw.mixcol(mixColor, mixColor.a);
}
Draw.blend(blending);
Draw.rect(region, rx, ry, rot);
Draw.blend();
@ -118,6 +125,9 @@ public class RegionPart extends DrawPart{
Draw.xscl *= sign;
}
Draw.color();
Draw.mixcol();
Draw.z(z);
//draw child, if applicable - only at the end
@ -162,6 +172,7 @@ public class RegionPart extends DrawPart{
heat = Core.atlas.find(realName + "-heat");
for(var child : children){
child.turretShading = turretShading;
child.load(name);
}
}

View file

@ -73,6 +73,8 @@ public class UnitType extends UnlockableContent{
riseSpeed = 0.08f,
/** how fast this unit falls when not boosting */
fallSpeed = 0.018f,
/** how many ticks it takes this missile to accelerate to full speed */
missileAccelTime = 0f,
/** raw health amount */
health = 200f,
/** incoming damage is reduced by this amount */

View file

@ -520,7 +520,7 @@ public class ModsDialog extends BaseDialog{
ui.showInfo("@mods.browser.noreleases");
}else{
sel.hide();
BaseDialog downloads = new BaseDialog("@mods.browser.releases");
var downloads = new BaseDialog("@mods.browser.releases");
downloads.cont.pane(p -> {
for(int j = 0; j < releases.size; j++){
var release = releases.get(j);
@ -570,14 +570,6 @@ public class ModsDialog extends BaseDialog{
});
}
private String trimText(String text){
if(text == null) return "";
if(text.contains("\n")){
return text.substring(0, text.indexOf("\n"));
}
return text;
}
private void handleMod(String repo, HttpResponse result){
try{
Fi file = tmpDirectory.child(repo.replace("/", "") + ".zip");

View file

@ -208,8 +208,6 @@ public class Turret extends ReloadTurret{
public float curRecoil, heat, logicControlTime = -1;
public float shootWarmup, charge;
public int totalShots;
//turrets need to shoot once for 'visual reload' to be valid, otherwise they seem stuck at reload 0 when placed.
public boolean visualReloadValid;
public boolean logicShooting = false;
public @Nullable Posc target;
public Vec2 targetPos = new Vec2();
@ -503,7 +501,6 @@ public class Turret extends ReloadTurret{
protected void updateShooting(){
if(reloadCounter >= reload && !charging() && shootWarmup >= minWarmup){
visualReloadValid = true;
BulletType type = peekAmmo();
shoot(type);

View file

@ -67,7 +67,7 @@ public class DrawTurret extends DrawBlock{
Draw.z(Layer.turret);
}
float progress = tb.visualReloadValid ? tb.progress() : 1f;
float progress = tb.progress();
//TODO no smooth reload
var params = DrawPart.params.set(build.warmup(), 1f - progress, 1f - progress, tb.heat, tb.curRecoil, tb.charge, tb.x + tb.recoilOffset.x, tb.y + tb.recoilOffset.y, tb.rotation);