mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-17 14:51:15 -08:00
Implemented artillery turret, carbide artillery shells
This commit is contained in:
parent
c7fb517e6c
commit
6e5aec080a
11 changed files with 112 additions and 13 deletions
|
|
@ -37,10 +37,12 @@ public class TurretBlocks extends BlockList implements ContentList {
|
|||
ammoUseEffect = ShootFx.shellEjectSmall;
|
||||
}};*/
|
||||
|
||||
hail = new ItemTurret("hail") {{
|
||||
hail = new ArtilleryTurret("hail") {{
|
||||
ammoTypes = new AmmoType[]{AmmoTypes.artilleryCarbide, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary};
|
||||
reload = 40f;
|
||||
reload = 100f;
|
||||
recoil = 2f;
|
||||
range = 200f;
|
||||
inaccuracy = 5f;
|
||||
}};
|
||||
|
||||
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};
|
||||
size = 3;
|
||||
}};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package io.anuke.mindustry.content.bullets;
|
||||
|
||||
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.BulletType;
|
||||
import io.anuke.mindustry.type.ContentList;
|
||||
|
|
@ -11,14 +12,15 @@ public class ArtilleryBullets extends BulletList implements ContentList{
|
|||
@Override
|
||||
public void load() {
|
||||
|
||||
carbide = new BasicBulletType(3f, 0, "shell") {
|
||||
carbide = new ArtilleryBulletType(3f, 4, "shell") {
|
||||
{
|
||||
hiteffect = BulletFx.flakExplosion;
|
||||
knockback = 0.8f;
|
||||
lifetime = 90f;
|
||||
drag = 0.01f;
|
||||
bulletWidth = bulletHeight = 9f;
|
||||
bulletShrink = 0.1f;
|
||||
lifetime = 50f;
|
||||
bulletWidth = bulletHeight = 11f;
|
||||
collidesTiles = false;
|
||||
splashDamageRadius = 25f;
|
||||
splashDamage = 33f;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import io.anuke.ucore.util.Angles;
|
|||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
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
|
||||
public void load() {
|
||||
|
|
@ -109,6 +109,12 @@ public class BulletFx extends FxList implements ContentList {
|
|||
|
||||
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(){
|
||||
return 130f;
|
||||
return 135f;
|
||||
}
|
||||
|
||||
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.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.entities.Damage;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
|
@ -18,6 +19,10 @@ public class BasicBulletType extends BulletType {
|
|||
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
|
||||
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 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));
|
||||
}
|
||||
}
|
||||
|
||||
if(splashDamageRadius > 0){
|
||||
Damage.damage(x, y, splashDamageRadius, splashDamage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void despawned(Bullet b) {
|
||||
if(fragBullet != null){
|
||||
if(fragBullet != null || splashDamageRadius > 0){
|
||||
hit(b);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||
|
||||
@Override
|
||||
public boolean collides(SolidTrait other){
|
||||
return super.collides(other);
|
||||
return type.collides && super.collides(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
|
|||
public boolean syncable;
|
||||
/**Whether this bullet type collides with tiles.*/
|
||||
public boolean collidesTiles = true;
|
||||
/**Whether this bullet types collides with anything at all.*/
|
||||
public boolean collides = true;
|
||||
|
||||
public BulletType(float speed, float damage){
|
||||
this.id = lastid ++;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ public abstract class GroundUnit extends BaseUnit {
|
|||
TileEntity core = getClosestEnemyCore();
|
||||
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;
|
||||
}else {
|
||||
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
|
||||
public void init() {
|
||||
super.init();
|
||||
viewRange = range;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue