Bullet cleanup
This commit is contained in:
@@ -3,10 +3,7 @@ package mindustry.content;
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -1426,7 +1423,6 @@ public class Blocks implements ContentList{
|
||||
chargeTime = 50f;
|
||||
chargeMaxDelay = 30f;
|
||||
chargeEffects = 7;
|
||||
shootType = Bullets.lancerLaser;
|
||||
recoilAmount = 2f;
|
||||
reloadTime = 90f;
|
||||
cooldown = 0.03f;
|
||||
@@ -1441,11 +1437,23 @@ public class Blocks implements ContentList{
|
||||
health = 280 * size * size;
|
||||
targetAir = false;
|
||||
shootSound = Sounds.laser;
|
||||
|
||||
shootType = new LaserBulletType(140){{
|
||||
colors = new Color[]{Pal.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Pal.lancerLaser, Color.white};
|
||||
hitEffect = Fx.hitLancer;
|
||||
despawnEffect = Fx.none;
|
||||
hitSize = 4;
|
||||
lifetime = 16f;
|
||||
drawSize = 400f;
|
||||
}};
|
||||
}};
|
||||
|
||||
arc = new PowerTurret("arc"){{
|
||||
requirements(Category.turret, with(Items.copper, 35, Items.lead, 50));
|
||||
shootType = Bullets.arc;
|
||||
shootType = new LightningBulletType(){{
|
||||
damage = 21;
|
||||
lightningLength = 25;
|
||||
}};
|
||||
reloadTime = 35f;
|
||||
shootCone = 40f;
|
||||
rotatespeed = 8f;
|
||||
@@ -1519,42 +1527,11 @@ public class Blocks implements ContentList{
|
||||
health = 220 * size * size;
|
||||
shootSound = Sounds.shotgun;
|
||||
|
||||
ammo(Items.thorium, new BulletType(0.01f, 105){
|
||||
int rays = 1;
|
||||
float rayLength = range + 10f;
|
||||
|
||||
{
|
||||
hitEffect = Fx.hitLancer;
|
||||
shootEffect = smokeEffect = Fx.lightningShoot;
|
||||
lifetime = 10f;
|
||||
despawnEffect = Fx.none;
|
||||
ammoMultiplier = 6f;
|
||||
pierce = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Bullet b){
|
||||
for(int i = 0; i < rays; i++){
|
||||
Damage.collideLine(b, b.team, hitEffect, b.x, b.y, b.rotation(), rayLength - Math.abs(i - (rays / 2)) * 20f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
super.draw(b);
|
||||
Draw.color(Color.white, Pal.lancerLaser, b.fin());
|
||||
//Draw.alpha(b.fout());
|
||||
for(int i = 0; i < 7; i++){
|
||||
Tmp.v1.trns(b.rotation(), i * 8f);
|
||||
float sl = Mathf.clamp(b.fout() - 0.5f) * (80f - i * 10);
|
||||
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rotation() + 90);
|
||||
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rotation() - 90);
|
||||
}
|
||||
Drawf.tri(b.x, b.y, 20f * b.fout(), (rayLength + 50), b.rotation());
|
||||
Drawf.tri(b.x, b.y, 20f * b.fout(), 10f, b.rotation() + 180f);
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
ammo(Items.thorium, new ShrapnelBulletType(){{
|
||||
length = range + 10f;
|
||||
damage = 105f;
|
||||
ammoMultiplier = 6f;
|
||||
}});
|
||||
}};
|
||||
|
||||
ripple = new ItemTurret("ripple"){{
|
||||
@@ -1635,7 +1612,6 @@ public class Blocks implements ContentList{
|
||||
|
||||
meltdown = new LaserTurret("meltdown"){{
|
||||
requirements(Category.turret, with(Items.copper, 250, Items.lead, 350, Items.graphite, 300, Items.surgealloy, 325, Items.silicon, 325));
|
||||
shootType = Bullets.meltdownLaser;
|
||||
shootEffect = Fx.shootBigSmoke2;
|
||||
shootCone = 40f;
|
||||
recoilAmount = 4f;
|
||||
@@ -1650,6 +1626,16 @@ public class Blocks implements ContentList{
|
||||
activeSound = Sounds.beam;
|
||||
activeSoundVolume = 2f;
|
||||
|
||||
shootType = new ContinuousLaserBulletType(70){{
|
||||
length = 220f;
|
||||
hitEffect = Fx.hitMeltdown;
|
||||
drawSize = 420f;
|
||||
|
||||
incendChance = 0.4f;
|
||||
incendSpread = 5f;
|
||||
incendAmount = 1;
|
||||
}};
|
||||
|
||||
health = 200 * size * size;
|
||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.5f)).update(false);
|
||||
}};
|
||||
@@ -1728,7 +1714,7 @@ public class Blocks implements ContentList{
|
||||
upgrades = new UnitType[][]{
|
||||
{UnitTypes.nova, UnitTypes.quasar},
|
||||
{UnitTypes.dagger, UnitTypes.mace},
|
||||
{UnitTypes.crawler, UnitTypes.eruptor},
|
||||
{UnitTypes.crawler, UnitTypes.atrax},
|
||||
{UnitTypes.flare, UnitTypes.horizon},
|
||||
{UnitTypes.mono, UnitTypes.poly},
|
||||
{UnitTypes.risse, UnitTypes.minke},
|
||||
|
||||
@@ -9,6 +9,7 @@ import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@@ -26,20 +27,17 @@ public class Bullets implements ContentList{
|
||||
fragGlass, fragExplosive, fragPlastic, fragSurge, fragGlassFrag, fragPlasticFrag,
|
||||
|
||||
//missiles
|
||||
missileExplosive, missileIncendiary, missileSurge, missileJavelin, missileSwarm,
|
||||
missileExplosive, missileIncendiary, missileSurge, missileSwarm,
|
||||
|
||||
//standard
|
||||
standardCopper, standardDense, standardThorium, standardHoming, standardIncendiary, standardMechSmall,
|
||||
standardGlaive, standardDenseBig, standardThoriumBig, standardIncendiaryBig,
|
||||
|
||||
//electric
|
||||
lancerLaser, meltdownLaser, arc, damageLightning,
|
||||
|
||||
//liquid
|
||||
waterShot, cryoShot, slagShot, oilShot,
|
||||
|
||||
//environment, misc.
|
||||
fireball, basicFlame, pyraFlame, driverBolt, healBullet, healBulletBig, frag,
|
||||
damageLightning, damageLightningGround, fireball, basicFlame, pyraFlame, driverBolt, healBullet, healBulletBig, frag,
|
||||
|
||||
//bombs
|
||||
bombExplosive, bombIncendiary, bombOil;
|
||||
@@ -400,6 +398,12 @@ public class Bullets implements ContentList{
|
||||
hittable = false;
|
||||
}};
|
||||
|
||||
//this is just a copy of the damage lightning bullet that doesn't damage air units
|
||||
damageLightningGround = new BulletType(0.0001f, 0f){{
|
||||
collidesAir = false;
|
||||
}};
|
||||
JsonIO.copy(damageLightning, damageLightningGround);
|
||||
|
||||
healBullet = new HealBulletType(5.2f, 13){{
|
||||
healPercent = 3f;
|
||||
}};
|
||||
@@ -494,25 +498,6 @@ public class Bullets implements ContentList{
|
||||
}
|
||||
};
|
||||
|
||||
lancerLaser = new LaserBulletType(140){{
|
||||
colors = new Color[]{Pal.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Pal.lancerLaser, Color.white};
|
||||
hitEffect = Fx.hitLancer;
|
||||
despawnEffect = Fx.none;
|
||||
hitSize = 4;
|
||||
lifetime = 16f;
|
||||
drawSize = 400f;
|
||||
}};
|
||||
|
||||
meltdownLaser = new ContinuousLaserBulletType(70){{
|
||||
length = 220f;
|
||||
hitEffect = Fx.hitMeltdown;
|
||||
drawSize = 420f;
|
||||
|
||||
incendChance = 0.4f;
|
||||
incendSpread = 5f;
|
||||
incendAmount = 1;
|
||||
}};
|
||||
|
||||
waterShot = new LiquidBulletType(Liquids.water){{
|
||||
knockback = 0.7f;
|
||||
}};
|
||||
@@ -530,11 +515,6 @@ public class Bullets implements ContentList{
|
||||
drag = 0.03f;
|
||||
}};
|
||||
|
||||
arc = new LightningBulletType(){{
|
||||
damage = 21;
|
||||
lightningLength = 25;
|
||||
}};
|
||||
|
||||
driverBolt = new MassDriverBolt();
|
||||
|
||||
frag = new BasicBulletType(5f, 8, "bullet"){{
|
||||
|
||||
@@ -24,7 +24,7 @@ public class UnitTypes implements ContentList{
|
||||
public static @EntityDef({Unitc.class, Mechc.class, Builderc.class, Minerc.class, Commanderc.class}) UnitType pulsar, quasar;
|
||||
|
||||
//legs
|
||||
public static @EntityDef({Unitc.class, Legsc.class}) UnitType cix, eruptor;
|
||||
public static @EntityDef({Unitc.class, Legsc.class}) UnitType arkyid, atrax, spiroct;
|
||||
|
||||
//air (no special traits)
|
||||
public static @EntityDef({Unitc.class}) UnitType flare, eclipse, horizon, zenith, antumbra;
|
||||
@@ -254,7 +254,7 @@ public class UnitTypes implements ContentList{
|
||||
}});
|
||||
}};
|
||||
|
||||
eruptor = new UnitType("eruptor"){{
|
||||
atrax = new UnitType("atrax"){{
|
||||
speed = 0.4f;
|
||||
drag = 0.4f;
|
||||
hitsize = 10f;
|
||||
@@ -284,7 +284,38 @@ public class UnitTypes implements ContentList{
|
||||
}});
|
||||
}};
|
||||
|
||||
cix = new UnitType("cix"){{
|
||||
//TODO this is just a clone
|
||||
spiroct = new UnitType("spiroct"){{
|
||||
speed = 0.4f;
|
||||
drag = 0.4f;
|
||||
hitsize = 10f;
|
||||
rotateSpeed = 3f;
|
||||
targetAir = false;
|
||||
health = 600;
|
||||
immunities = ObjectSet.with(StatusEffects.burning, StatusEffects.melting);
|
||||
legCount = 4;
|
||||
legLength = 9f;
|
||||
legTrns = 0.6f;
|
||||
legMoveSpace = 1.4f;
|
||||
|
||||
weapons.add(new Weapon("eruption"){{
|
||||
shootY = 3f;
|
||||
reload = 10f;
|
||||
ejectEffect = Fx.none;
|
||||
recoil = 1f;
|
||||
x = 7f;
|
||||
shootSound = Sounds.flame;
|
||||
|
||||
bullet = new LiquidBulletType(Liquids.slag){{
|
||||
damage = 11;
|
||||
speed = 2.3f;
|
||||
drag = 0.02f;
|
||||
shootEffect = Fx.shootSmall;
|
||||
}};
|
||||
}});
|
||||
}};
|
||||
|
||||
arkyid = new UnitType("arkyid"){{
|
||||
drag = 0.1f;
|
||||
speed = 0.5f;
|
||||
hitsize = 9f;
|
||||
|
||||
@@ -92,15 +92,17 @@ public class Damage{
|
||||
}
|
||||
};
|
||||
|
||||
world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> {
|
||||
collider.get(cx, cy);
|
||||
if(large){
|
||||
for(Point2 p : Geometry.d4){
|
||||
collider.get(cx + p.x, cy + p.y);
|
||||
if(hitter.type.collidesGround){
|
||||
world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> {
|
||||
collider.get(cx, cy);
|
||||
if(large){
|
||||
for(Point2 p : Geometry.d4){
|
||||
collider.get(cx + p.x, cy + p.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
rect.setPosition(x, y).setSize(tr.x, tr.y);
|
||||
float x2 = tr.x + x, y2 = tr.y + y;
|
||||
@@ -123,6 +125,8 @@ public class Damage{
|
||||
rect.height += expand * 2;
|
||||
|
||||
Cons<Unit> cons = e -> {
|
||||
if(!e.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround)) return;
|
||||
|
||||
e.hitbox(hitrect);
|
||||
Rect other = hitrect;
|
||||
other.y -= expand;
|
||||
|
||||
@@ -5,6 +5,7 @@ import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -21,22 +22,28 @@ public class Lightning{
|
||||
private static boolean bhit = false;
|
||||
private static int lastSeed = 0;
|
||||
|
||||
/** Create a lighting branch at a location. Use Team.none to damage everyone. */
|
||||
/** Create a lighting branch at a location. Use Team.derelict to damage everyone. */
|
||||
public static void create(Team team, Color color, float damage, float x, float y, float targetAngle, int length){
|
||||
createLightingInternal(lastSeed++, team, color, damage, x, y, targetAngle, length);
|
||||
createLightingInternal(null, lastSeed++, team, color, damage, x, y, targetAngle, length);
|
||||
}
|
||||
|
||||
/** Create a lighting branch at a location. Uses bullet parameters. */
|
||||
public static void create(Bullet bullet, Color color, float damage, float x, float y, float targetAngle, int length){
|
||||
createLightingInternal(bullet, lastSeed++, bullet.team, color, damage, x, y, targetAngle, length);
|
||||
}
|
||||
|
||||
//TODO remote method
|
||||
//@Remote(called = Loc.server, unreliable = true)
|
||||
private static void createLightingInternal(int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){
|
||||
private static void createLightingInternal(Bullet hitter, int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){
|
||||
random.setSeed(seed);
|
||||
hit.clear();
|
||||
|
||||
BulletType bulletType = hitter != null && !hitter.type.collidesAir ? Bullets.damageLightningGround : Bullets.damageLightning;
|
||||
Seq<Vec2> lines = new Seq<>();
|
||||
bhit = false;
|
||||
|
||||
for(int i = 0; i < length / 2; i++){
|
||||
Bullets.damageLightning.create(null, team, x, y, 0f, damage, 1f, 1f, null);
|
||||
bulletType.create(null, team, x, y, 0f, damage, 1f, 1f, hitter);
|
||||
lines.add(new Vec2(x + Mathf.range(3f), y + Mathf.range(3f)));
|
||||
|
||||
if(lines.size > 1){
|
||||
@@ -61,7 +68,7 @@ public class Lightning{
|
||||
entities.clear();
|
||||
if(hit.size < maxChain){
|
||||
Units.nearbyEnemies(team, rect, u -> {
|
||||
if(!hit.contains(u.id())){
|
||||
if(!hit.contains(u.id()) && (hitter == null || u.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround))){
|
||||
entities.add(u);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -109,6 +109,10 @@ public abstract class BulletType extends Content{
|
||||
despawnEffect = Fx.hitBulletSmall;
|
||||
}
|
||||
|
||||
public BulletType(){
|
||||
this(1f, 1f);
|
||||
}
|
||||
|
||||
/** Returns maximum distance the bullet this bullet type has can travel. */
|
||||
public float range(){
|
||||
return speed * lifetime * (1f - drag);
|
||||
@@ -153,7 +157,7 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
|
||||
for(int i = 0; i < lightning; i++){
|
||||
Lightning.create(b.team, Pal.surge, lightningDamage < 0 ? damage : lightningDamage, b.x, b.y, Mathf.random(360f), lightningLength);
|
||||
Lightning.create(b, Pal.surge, lightningDamage < 0 ? damage : lightningDamage, b.x, b.y, Mathf.random(360f), lightningLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ public class LightningBulletType extends BulletType{
|
||||
|
||||
@Override
|
||||
public void init(Bullet b){
|
||||
Lightning.create(b.team, lightningColor, damage, b.x, b.y, b.rotation(), lightningLength + Mathf.random(lightningLengthRand));
|
||||
Lightning.create(b, lightningColor, damage, b.x, b.y, b.rotation(), lightningLength + Mathf.random(lightningLengthRand));
|
||||
}
|
||||
}
|
||||
|
||||
47
core/src/mindustry/entities/bullet/ShrapnelBulletType.java
Normal file
47
core/src/mindustry/entities/bullet/ShrapnelBulletType.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class ShrapnelBulletType extends BulletType{
|
||||
public float length = 100f;
|
||||
public float width = 20f;
|
||||
public Color fromColor = Color.white, toColor = Pal.lancerLaser;
|
||||
|
||||
public int serrations = 7;
|
||||
public float serrationLenScl = 10f, serrationWidth = 4f, serrationSpacing = 8f, serrationSpaceOffset = 80f;
|
||||
|
||||
public ShrapnelBulletType(){
|
||||
speed = 0.01f;
|
||||
hitEffect = Fx.hitLancer;
|
||||
shootEffect = smokeEffect = Fx.lightningShoot;
|
||||
lifetime = 10f;
|
||||
despawnEffect = Fx.none;
|
||||
pierce = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Bullet b){
|
||||
Damage.collideLine(b, b.team, hitEffect, b.x, b.y, b.rotation(), length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
Draw.color(fromColor, toColor, b.fin());
|
||||
for(int i = 0; i < serrations; i++){
|
||||
Tmp.v1.trns(b.rotation(), i * serrationSpacing);
|
||||
float sl = Mathf.clamp(b.fout() - 0.5f) * (serrationSpaceOffset - i * serrationLenScl);
|
||||
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, serrationWidth, sl, b.rotation() + 90);
|
||||
Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, serrationWidth, sl, b.rotation() - 90);
|
||||
}
|
||||
Drawf.tri(b.x, b.y, width * b.fout(), (length + 50), b.rotation());
|
||||
Drawf.tri(b.x, b.y, width * b.fout(), 10f, b.rotation() + 180f);
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class DefaultWaves{
|
||||
spacing = 4;
|
||||
}},
|
||||
|
||||
new SpawnGroup(UnitTypes.eruptor){{
|
||||
new SpawnGroup(UnitTypes.atrax){{
|
||||
begin = 31;
|
||||
unitAmount = 4;
|
||||
unitScaling = 1;
|
||||
|
||||
@@ -47,6 +47,11 @@ public class JsonIO{
|
||||
return json.toJson(object, object.getClass());
|
||||
}
|
||||
|
||||
public static <T> T copy(T object, T dest){
|
||||
json.copyFields(object, dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static <T> T copy(T object){
|
||||
return read((Class<T>)object.getClass(), write(object));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user