Implemented artillery turret, carbide artillery shells
This commit is contained in:
@@ -37,10 +37,12 @@ public class TurretBlocks extends BlockList implements ContentList {
|
|||||||
ammoUseEffect = ShootFx.shellEjectSmall;
|
ammoUseEffect = ShootFx.shellEjectSmall;
|
||||||
}};*/
|
}};*/
|
||||||
|
|
||||||
hail = new ItemTurret("hail") {{
|
hail = new ArtilleryTurret("hail") {{
|
||||||
ammoTypes = new AmmoType[]{AmmoTypes.artilleryCarbide, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary};
|
ammoTypes = new AmmoType[]{AmmoTypes.artilleryCarbide, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary};
|
||||||
reload = 40f;
|
reload = 100f;
|
||||||
|
recoil = 2f;
|
||||||
range = 200f;
|
range = 200f;
|
||||||
|
inaccuracy = 5f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
scorch = new LiquidTurret("scorch") {{
|
scorch = new LiquidTurret("scorch") {{
|
||||||
@@ -136,7 +138,7 @@ public class TurretBlocks extends BlockList implements ContentList {
|
|||||||
};
|
};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
ripple = new ItemTurret("ripple") {{
|
ripple = new ArtilleryTurret("ripple") {{
|
||||||
ammoTypes = new AmmoType[]{AmmoTypes.artilleryCarbide, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary, AmmoTypes.artilleryPlastic, AmmoTypes.artilleryThorium};
|
ammoTypes = new AmmoType[]{AmmoTypes.artilleryCarbide, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary, AmmoTypes.artilleryPlastic, AmmoTypes.artilleryThorium};
|
||||||
size = 3;
|
size = 3;
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.content.bullets;
|
package io.anuke.mindustry.content.bullets;
|
||||||
|
|
||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
|
import io.anuke.mindustry.entities.bullet.ArtilleryBulletType;
|
||||||
import io.anuke.mindustry.entities.bullet.BasicBulletType;
|
import io.anuke.mindustry.entities.bullet.BasicBulletType;
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||||
import io.anuke.mindustry.type.ContentList;
|
import io.anuke.mindustry.type.ContentList;
|
||||||
@@ -11,14 +12,15 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
|
|
||||||
carbide = new BasicBulletType(3f, 0, "shell") {
|
carbide = new ArtilleryBulletType(3f, 4, "shell") {
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.flakExplosion;
|
hiteffect = BulletFx.flakExplosion;
|
||||||
knockback = 0.8f;
|
knockback = 0.8f;
|
||||||
lifetime = 90f;
|
lifetime = 50f;
|
||||||
drag = 0.01f;
|
bulletWidth = bulletHeight = 11f;
|
||||||
bulletWidth = bulletHeight = 9f;
|
collidesTiles = false;
|
||||||
bulletShrink = 0.1f;
|
splashDamageRadius = 25f;
|
||||||
|
splashDamage = 33f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import io.anuke.ucore.util.Angles;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class BulletFx extends FxList implements ContentList {
|
public class BulletFx extends FxList implements ContentList {
|
||||||
public static Effect hitBulletSmall, hitBulletBig, hitFlameSmall, hitLiquid, hitLancer, despawn, flakExplosion;
|
public static Effect hitBulletSmall, hitBulletBig, hitFlameSmall, hitLiquid, hitLancer, despawn, flakExplosion, artilleryTrail;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
@@ -109,6 +109,12 @@ public class BulletFx extends FxList implements ContentList {
|
|||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
artilleryTrail = new Effect(50, e -> {
|
||||||
|
Draw.color(Palette.bulletYellowBack);
|
||||||
|
Fill.circle(e.x, e.y, e.rotation * e.fout());
|
||||||
|
Draw.reset();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getViewDistance(){
|
public float getViewDistance(){
|
||||||
return 130f;
|
return 135f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract TextureRegion getIconRegion();
|
public abstract TextureRegion getIconRegion();
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package io.anuke.mindustry.entities.bullet;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
|
||||||
|
//TODO scale velocity depending on fslope()
|
||||||
|
public class ArtilleryBulletType extends BasicBulletType {
|
||||||
|
|
||||||
|
public ArtilleryBulletType(float speed, float damage, String bulletSprite) {
|
||||||
|
super(speed, damage, bulletSprite);
|
||||||
|
collidesTiles = false;
|
||||||
|
collides = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Bullet b) {
|
||||||
|
if(b.timer.get(0, 3 + b.fslope()*2f)){
|
||||||
|
Effects.effect(BulletFx.artilleryTrail, b.x, b.y, b.fslope() * 4f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Bullet b) {
|
||||||
|
float baseScale = 0.7f;
|
||||||
|
float scale = (baseScale + b.fslope()*(1f-baseScale));
|
||||||
|
|
||||||
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
|
Draw.color(backColor);
|
||||||
|
Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
|
||||||
|
Draw.color(frontColor);
|
||||||
|
Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.bullet;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.mindustry.entities.Damage;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
@@ -18,6 +19,10 @@ public class BasicBulletType extends BulletType {
|
|||||||
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
|
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
|
||||||
public BulletType fragBullet = null;
|
public BulletType fragBullet = null;
|
||||||
|
|
||||||
|
/**Use a negative value to disable splash damage.*/
|
||||||
|
public float splashDamageRadius = -1f;
|
||||||
|
public float splashDamage = 6f;
|
||||||
|
|
||||||
public TextureRegion backRegion;
|
public TextureRegion backRegion;
|
||||||
public TextureRegion frontRegion;
|
public TextureRegion frontRegion;
|
||||||
|
|
||||||
@@ -54,11 +59,15 @@ public class BasicBulletType extends BulletType {
|
|||||||
Bullet.create(fragBullet, b, x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a, Mathf.random(fragVelocityMin, fragVelocityMax));
|
Bullet.create(fragBullet, b, x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a, Mathf.random(fragVelocityMin, fragVelocityMax));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(splashDamageRadius > 0){
|
||||||
|
Damage.damage(x, y, splashDamageRadius, splashDamage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void despawned(Bullet b) {
|
public void despawned(Bullet b) {
|
||||||
if(fragBullet != null){
|
if(fragBullet != null || splashDamageRadius > 0){
|
||||||
hit(b);
|
hit(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean collides(SolidTrait other){
|
public boolean collides(SolidTrait other){
|
||||||
return super.collides(other);
|
return type.collides && super.collides(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
|
|||||||
public boolean syncable;
|
public boolean syncable;
|
||||||
/**Whether this bullet type collides with tiles.*/
|
/**Whether this bullet type collides with tiles.*/
|
||||||
public boolean collidesTiles = true;
|
public boolean collidesTiles = true;
|
||||||
|
/**Whether this bullet types collides with anything at all.*/
|
||||||
|
public boolean collides = true;
|
||||||
|
|
||||||
public BulletType(float speed, float damage){
|
public BulletType(float speed, float damage){
|
||||||
this.id = lastid ++;
|
this.id = lastid ++;
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public abstract class GroundUnit extends BaseUnit {
|
|||||||
TileEntity core = getClosestEnemyCore();
|
TileEntity core = getClosestEnemyCore();
|
||||||
float dst = core == null ? 0 :distanceTo(core);
|
float dst = core == null ? 0 :distanceTo(core);
|
||||||
|
|
||||||
if(core != null && dst < inventory.getAmmo().getRange()){
|
if(core != null && inventory.hasAmmo() && dst < inventory.getAmmo().getRange()){
|
||||||
target = core;
|
target = core;
|
||||||
}else {
|
}else {
|
||||||
retarget(() -> targetClosest());
|
retarget(() -> targetClosest());
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.defense.turrets;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import io.anuke.mindustry.entities.Predict;
|
||||||
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
/**Artillery turrets have special shooting calculations done to hit targets.*/
|
||||||
|
public class ArtilleryTurret extends ItemTurret {
|
||||||
|
|
||||||
|
public ArtilleryTurret(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shoot(Tile tile, AmmoType ammo){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
entity.recoil = recoil;
|
||||||
|
entity.heat = 1f;
|
||||||
|
|
||||||
|
AmmoType type = peekAmmo(tile);
|
||||||
|
useAmmo(tile);
|
||||||
|
|
||||||
|
tr.trns(entity.rotation, size * tilesize / 2);
|
||||||
|
|
||||||
|
Vector2 predict = Predict.intercept(tile, entity.target, type.bullet.speed);
|
||||||
|
|
||||||
|
float dst = entity.distanceTo(predict.x, predict.y);
|
||||||
|
float maxTraveled = type.bullet.lifetime * type.bullet.speed;
|
||||||
|
|
||||||
|
Bullet.create(ammo.bullet, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y,
|
||||||
|
entity.rotation + Mathf.range(inaccuracy + type.inaccuracy), dst/maxTraveled);
|
||||||
|
|
||||||
|
effects(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,7 @@ public abstract class Turret extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
|
super.init();
|
||||||
viewRange = range;
|
viewRange = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user