From ff52fec663051ef833e042817ae86c33a0f30fbf Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 7 Jan 2019 16:53:04 -0500 Subject: [PATCH] Cleanup: all bullet definitions moved into one class --- .../io/anuke/mindustry/content/Bullets.java | 636 ++++++++++++++++++ .../io/anuke/mindustry/content/Weapons.java | 35 +- .../content/blocks/TurretBlocks.java | 76 +-- .../content/bullets/ArtilleryBullets.java | 107 --- .../mindustry/content/bullets/BulletList.java | 12 - .../content/bullets/FlakBullets.java | 51 -- .../content/bullets/MissileBullets.java | 124 ---- .../content/bullets/StandardBullets.java | 101 --- .../content/bullets/TurretBullets.java | 425 ------------ .../content/bullets/WeaponBullets.java | 99 --- .../anuke/mindustry/core/ContentLoader.java | 12 +- .../io/anuke/mindustry/entities/Damage.java | 4 +- .../entities/bullet/BasicBulletType.java | 8 + .../entities/bullet/LiquidBulletType.java | 2 + .../entities/bullet/MassDriverBolt.java | 109 +++ .../entities/bullet/MissileBulletType.java | 7 + .../anuke/mindustry/entities/effect/Fire.java | 4 +- .../mindustry/entities/effect/Lightning.java | 4 +- .../mindustry/entities/effect/Puddle.java | 4 +- .../blocks/defense/turrets/PowerTurret.java | 1 + .../world/blocks/distribution/MassDriver.java | 5 +- 21 files changed, 831 insertions(+), 995 deletions(-) delete mode 100644 core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java delete mode 100644 core/src/io/anuke/mindustry/content/bullets/BulletList.java delete mode 100644 core/src/io/anuke/mindustry/content/bullets/FlakBullets.java delete mode 100644 core/src/io/anuke/mindustry/content/bullets/MissileBullets.java delete mode 100644 core/src/io/anuke/mindustry/content/bullets/StandardBullets.java delete mode 100644 core/src/io/anuke/mindustry/content/bullets/TurretBullets.java delete mode 100644 core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java create mode 100644 core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java diff --git a/core/src/io/anuke/mindustry/content/Bullets.java b/core/src/io/anuke/mindustry/content/Bullets.java index 6e5137a433..8900001cb6 100644 --- a/core/src/io/anuke/mindustry/content/Bullets.java +++ b/core/src/io/anuke/mindustry/content/Bullets.java @@ -1,13 +1,649 @@ package io.anuke.mindustry.content; +import io.anuke.arc.entities.Effects; +import io.anuke.arc.graphics.Color; +import io.anuke.arc.graphics.g2d.CapStyle; +import io.anuke.arc.graphics.g2d.Draw; +import io.anuke.arc.graphics.g2d.Fill; +import io.anuke.arc.graphics.g2d.Lines; +import io.anuke.arc.math.Mathf; +import io.anuke.arc.util.Time; +import io.anuke.arc.util.Tmp; +import io.anuke.mindustry.content.fx.*; +import io.anuke.mindustry.entities.Damage; +import io.anuke.mindustry.entities.bullet.*; +import io.anuke.mindustry.entities.effect.Fire; +import io.anuke.mindustry.entities.effect.Lightning; +import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.game.ContentList; +import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.graphics.Shapes; import io.anuke.mindustry.type.ContentType; +import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.BuildBlock; + +import static io.anuke.mindustry.Vars.world; public class Bullets implements ContentList{ + public static BulletType + + //artillery + artilleryDense, arilleryPlastic, artilleryPlasticFrag, artilleryHoming, artlleryIncendiary, artilleryExplosive, artilleryUnit, + + //flak + flakPlastic, flakExplosive, flakSurge, + + //missiles + missileExplosive, missileIncendiary, missileSurge, missileJavelin, missileSwarm, + + //standard + standardCopper, standardDense, standardThorium, standardHoming, standardIncendiary, standardMechSmall, + standardGlaive, standardDenseBig, standardThoriumBig, standardIncendiaryBig, + + //electric + lancerLaser, burstLaser, meltdownLaser, lightning, arc, damageLightning, + + //liquid + waterShot, cryoShot, lavaShot, oilShot, + + //environment, misc. + fireball, basicFlame, fuseShot, driverBolt, healBullet, frag, + + //bombs + bombExplosive, bombIncendiary, bombOil; @Override public void load(){ + artilleryDense = new ArtilleryBulletType(3f, 0, "shell"){{ + hitEffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 50f; + bulletWidth = bulletHeight = 11f; + collidesTiles = false; + splashDamageRadius = 25f; + splashDamage = 33f; + }}; + + artilleryPlasticFrag = new BasicBulletType(2.5f, 6, "bullet"){{ + bulletWidth = 10f; + bulletHeight = 12f; + bulletShrink = 1f; + lifetime = 15f; + backColor = Palette.plastaniumBack; + frontColor = Palette.plastaniumFront; + despawnEffect = Fx.none; + }}; + + arilleryPlastic = new ArtilleryBulletType(3.3f, 0, "shell"){{ + hitEffect = BulletFx.plasticExplosion; + knockback = 1f; + lifetime = 55f; + bulletWidth = bulletHeight = 13f; + collidesTiles = false; + splashDamageRadius = 35f; + splashDamage = 35f; + fragBullet = artilleryPlasticFrag; + fragBullets = 9; + backColor = Palette.plastaniumBack; + frontColor = Palette.plastaniumFront; + }}; + + artilleryHoming = new ArtilleryBulletType(3f, 0, "shell"){{ + hitEffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 45f; + bulletWidth = bulletHeight = 11f; + collidesTiles = false; + splashDamageRadius = 25f; + splashDamage = 33f; + homingPower = 2f; + homingRange = 50f; + }}; + + artlleryIncendiary = new ArtilleryBulletType(3f, 0, "shell"){{ + hitEffect = BulletFx.blastExplosion; + knockback = 0.8f; + lifetime = 60f; + bulletWidth = bulletHeight = 13f; + collidesTiles = false; + splashDamageRadius = 25f; + splashDamage = 30f; + incendAmount = 4; + incendSpread = 11f; + frontColor = Palette.lightishOrange; + backColor = Palette.lightOrange; + trailEffect = BulletFx.incendTrail; + }}; + + artilleryExplosive = new ArtilleryBulletType(2f, 0, "shell"){{ + hitEffect = BulletFx.blastExplosion; + knockback = 0.8f; + lifetime = 70f; + bulletWidth = bulletHeight = 14f; + collidesTiles = false; + splashDamageRadius = 45f; + splashDamage = 50f; + backColor = Palette.missileYellowBack; + frontColor = Palette.missileYellow; + }}; + + artilleryUnit = new ArtilleryBulletType(2f, 0, "shell"){{ + hitEffect = BulletFx.blastExplosion; + knockback = 0.8f; + lifetime = 90f; + bulletWidth = bulletHeight = 14f; + collides = true; + collidesTiles = true; + splashDamageRadius = 45f; + splashDamage = 50f; + backColor = Palette.bulletYellowBack; + frontColor = Palette.bulletYellow; + }}; + + flakPlastic = new FlakBulletType(4f, 5){{ + splashDamageRadius = 40f; + fragBullet = artilleryPlasticFrag; + fragBullets = 4; + hitEffect = BulletFx.plasticExplosion; + frontColor = Palette.plastaniumFront; + backColor = Palette.plastaniumBack; + }}; + + flakExplosive = new FlakBulletType(4f, 5){{ + //default bullet type, no changes + }}; + + flakSurge = new FlakBulletType(4f, 7){{ + splashDamage = 33f; + lightining = 2; + lightningLength = 12; + }}; + + missileExplosive = new MissileBulletType(1.8f, 10, "missile"){{ + bulletWidth = 8f; + bulletHeight = 8f; + bulletShrink = 0f; + drag = -0.01f; + splashDamageRadius = 30f; + splashDamage = 30f; + lifetime = 150f; + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; + }}; + + missileIncendiary = new MissileBulletType(2f, 12, "missile"){{ + frontColor = Palette.lightishOrange; + backColor = Palette.lightOrange; + bulletWidth = 7f; + bulletHeight = 8f; + bulletShrink = 0f; + drag = -0.01f; + homingPower = 7f; + splashDamageRadius = 10f; + splashDamage = 10f; + lifetime = 160f; + hitEffect = BulletFx.blastExplosion; + incendSpread = 10f; + incendAmount = 3; + }}; + + missileSurge = new MissileBulletType(3.5f, 15, "bullet"){{ + bulletWidth = 8f; + bulletHeight = 8f; + bulletShrink = 0f; + drag = -0.01f; + splashDamageRadius = 30f; + splashDamage = 22f; + lifetime = 150f; + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; + lightining = 2; + lightningLength = 14; + }}; + + missileJavelin = new MissileBulletType(5f, 10.5f, "missile"){{ + bulletWidth = 8f; + bulletHeight = 8f; + bulletShrink = 0f; + drag = -0.003f; + keepVelocity = false; + splashDamageRadius = 20f; + splashDamage = 1f; + lifetime = 90f; + trailColor = Color.valueOf("b6c6fd"); + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; + backColor = Palette.bulletYellowBack; + frontColor = Palette.bulletYellow; + weaveScale = 8f; + weaveMag = 2f; + }}; + + missileSwarm = new MissileBulletType(2.7f, 12, "missile"){{ + bulletWidth = 8f; + bulletHeight = 8f; + bulletShrink = 0f; + drag = -0.003f; + homingRange = 60f; + keepVelocity = false; + splashDamageRadius = 25f; + splashDamage = 10f; + lifetime = 120f; + trailColor = Color.GRAY; + backColor = Palette.bulletYellowBack; + frontColor = Palette.bulletYellow; + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; + weaveScale = 8f; + weaveMag = 2f; + }}; + + standardCopper = new BasicBulletType(2.5f, 7, "bullet"){{ + bulletWidth = 7f; + bulletHeight = 9f; + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + ammoMultiplier = 5; + }}; + + standardDense = new BasicBulletType(3.5f, 18, "bullet"){{ + bulletWidth = 9f; + bulletHeight = 12f; + armorPierce = 0.2f; + reloadMultiplier = 0.6f; + ammoMultiplier = 2; + }}; + + standardThorium = new BasicBulletType(4f, 29, "bullet"){{ + bulletWidth = 10f; + bulletHeight = 13f; + armorPierce = 0.5f; + shootEffect = ShootFx.shootBig; + smokeEffect = ShootFx.shootBigSmoke; + ammoMultiplier = 2; + }}; + + standardHoming = new BasicBulletType(3f, 9, "bullet"){{ + bulletWidth = 7f; + bulletHeight = 9f; + homingPower = 5f; + reloadMultiplier = 1.4f; + ammoMultiplier = 5; + }}; + + standardIncendiary = new BasicBulletType(3.2f, 11, "bullet"){{ + bulletWidth = 10f; + bulletHeight = 12f; + frontColor = Palette.lightishOrange; + backColor = Palette.lightOrange; + incendSpread = 3f; + incendAmount = 1; + incendChance = 0.3f; + inaccuracy = 3f; + }}; + + standardGlaive = new BasicBulletType(4f, 7.5f, "bullet"){{ + bulletWidth = 10f; + bulletHeight = 12f; + frontColor = Color.valueOf("feb380"); + backColor = Color.valueOf("ea8878"); + incendSpread = 3f; + incendAmount = 1; + incendChance = 0.3f; + }}; + + standardMechSmall = new BasicBulletType(4f, 9, "bullet"){{ + bulletWidth = 11f; + bulletHeight = 14f; + lifetime = 40f; + inaccuracy = 5f; + despawnEffect = BulletFx.hitBulletSmall; + }}; + + standardDenseBig = new BasicBulletType(7f, 42, "bullet"){{ + bulletWidth = 15f; + bulletHeight = 21f; + armorPierce = 0.2f; + }}; + + standardThoriumBig = new BasicBulletType(8f, 65, "bullet"){{ + bulletWidth = 16f; + bulletHeight = 23f; + armorPierce = 0.5f; + }}; + + standardIncendiaryBig = new BasicBulletType(7f, 38, "bullet"){{ + bulletWidth = 16f; + bulletHeight = 21f; + frontColor = Palette.lightishOrange; + backColor = Palette.lightOrange; + incendSpread = 3f; + incendAmount = 2; + incendChance = 0.3f; + }}; + + damageLightning = new BulletType(0.0001f, 0f){ + { + lifetime = Lightning.lifetime; + hitEffect = BulletFx.hitLancer; + despawnEffect = Fx.none; + status = StatusEffects.shocked; + statusIntensity = 1f; + } + }; + + healBullet = new BulletType(5.2f, 13){ + float healPercent = 3f; + + { + hitEffect = BulletFx.hitLaser; + despawnEffect = BulletFx.hitLaser; + collidesTeam = true; + } + + @Override + public boolean collides(Bullet b, Tile tile){ + return tile.getTeam() != b.getTeam() || tile.entity.healthf() < 1f; + } + + @Override + public void draw(Bullet b){ + Draw.color(Palette.heal); + Lines.stroke(2f); + Lines.lineAngleCenter(b.x, b.y, b.rot(), 7f); + Draw.color(Color.WHITE); + Lines.lineAngleCenter(b.x, b.y, b.rot(), 3f); + Draw.reset(); + } + + @Override + public void hitTile(Bullet b, Tile tile){ + super.hit(b); + tile = tile.target(); + + if(tile != null && tile.getTeam() == b.getTeam() && !(tile.block() instanceof BuildBlock)){ + Effects.effect(BlockFx.healBlockFull, Palette.heal, tile.drawx(), tile.drawy(), tile.block().size); + tile.entity.healBy(healPercent / 100f * tile.entity.maxHealth()); + } + } + }; + + fireball = new BulletType(1f, 4){ + { + pierce = true; + hitTiles = false; + collides = false; + collidesTiles = false; + drag = 0.03f; + hitEffect = despawnEffect = Fx.none; + } + + @Override + public void init(Bullet b){ + b.velocity().setLength(0.6f + Mathf.random(2f)); + } + + @Override + public void draw(Bullet b){ + //TODO add color to the bullet depending on the color of the flame it came from + Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, b.fin()); + Fill.circle(b.x, b.y, 3f * b.fout()); + Draw.reset(); + } + + @Override + public void update(Bullet b){ + if(Mathf.chance(0.04 * Time.delta())){ + Tile tile = world.tileWorld(b.x, b.y); + if(tile != null){ + Fire.create(tile); + } + } + + if(Mathf.chance(0.1 * Time.delta())){ + Effects.effect(EnvironmentFx.fireballsmoke, b.x, b.y); + } + + if(Mathf.chance(0.1 * Time.delta())){ + Effects.effect(EnvironmentFx.ballfire, b.x, b.y); + } + } + }; + + basicFlame = new BulletType(2.3f, 5){ + { + hitSize = 7f; + lifetime = 35f; + pierce = true; + drag = 0.05f; + hitEffect = BulletFx.hitFlameSmall; + despawnEffect = Fx.none; + status = StatusEffects.burning; + } + + @Override + public void draw(Bullet b){ + } + }; + + lancerLaser = 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 init(Bullet b){ + Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length); + } + + @Override + public void draw(Bullet b){ + float f = Mathf.curve(b.fin(), 0f, 0.2f); + float baseLen = length * f; + + Lines.lineAngle(b.x, b.y, b.rot(), 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.rot(), baseLen * lenscales[i]); + } + } + Draw.reset(); + } + }; + + meltdownLaser = new BulletType(0.001f, 26){ + Color tmpColor = new Color(); + Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.WHITE}; + float[] tscales = {1f, 0.7f, 0.5f, 0.2f}; + float[] strokes = {2f, 1.5f, 1f, 0.3f}; + float[] lenscales = {1f, 1.12f, 1.15f, 1.17f}; + float length = 200f; + + { + hitEffect = BulletFx.hitMeltdown; + despawnEffect = Fx.none; + hitSize = 4; + drawSize = 420f; + lifetime = 16f; + pierce = true; + } + + @Override + public void update(Bullet b){ + if(b.timer.get(1, 5f)){ + Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length); + } + Effects.shake(1f, 1f, b.x, b.y); + } + + @Override + public void hit(Bullet b, float hitx, float hity){ + Effects.effect(hitEffect, colors[2], hitx, hity); + if(Mathf.chance(0.4)){ + Fire.create(world.tileWorld(hitx+Mathf.range(5f), hity+Mathf.range(5f))); + } + } + + @Override + public void draw(Bullet b){ + float baseLen = (length) * b.fout(); + + Lines.lineAngle(b.x, b.y, b.rot(), baseLen); + for(int s = 0; s < colors.length; s++){ + Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f))); + for(int i = 0; i < tscales.length; i++){ + Tmp.v1.trns(b.rot() + 180f, (lenscales[i] - 1f) * 35f); + Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]); + Lines.lineAngle(b.x + Tmp.v1.x, b.y + Tmp.v1.y, b.rot(), baseLen * lenscales[i], CapStyle.none); + } + } + Draw.reset(); + } + }; + + fuseShot = new BulletType(0.01f, 70){ + int rays = 3; + float raySpace = 2f; + float rayLength = 80f; + { + hitEffect = BulletFx.hitFuse; + lifetime = 13f; + despawnEffect = Fx.none; + pierce = true; + } + + @Override + public void init(Bullet b) { + for (int i = 0; i < rays; i++) { + Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays/2))*20f); + } + } + + @Override + public void draw(Bullet b) { + super.draw(b); + Draw.color(Color.WHITE, Palette.surge, b.fin()); + for(int i = 0; i < 7; i++){ + Tmp.v1.trns(b.rot(), i * 8f); + float sl = Mathf.clamp(b.fout()-0.5f) * (80f - i *10); + Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() + 90); + Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() - 90); + } + Shapes.tri(b.x, b.y, 13f, (rayLength+50) * b.fout(), b.rot()); + Shapes.tri(b.x, b.y, 13f, 10f * b.fout(), b.rot() + 180f); + Draw.reset(); + } + }; + + waterShot = new LiquidBulletType(Liquids.water){{ + knockback = 0.65f; + }}; + + cryoShot = new LiquidBulletType(Liquids.cryofluid){{ + + }}; + + lavaShot = new LiquidBulletType(Liquids.lava){{ + damage = 4; + speed = 1.9f; + drag = 0.03f; + }}; + + oilShot = new LiquidBulletType(Liquids.oil){{ + speed = 2f; + drag = 0.03f; + }}; + + lightning = new BulletType(0.001f, 12f){ + { + lifetime = 1f; + despawnEffect = Fx.none; + hitEffect = BulletFx.hitLancer; + keepVelocity = false; + } + + @Override + public void draw(Bullet b){ + } + + @Override + public void init(Bullet b){ + Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 30); + } + }; + + arc = new BulletType(0.001f, 26){{ + lifetime = 1; + despawnEffect = Fx.none; + hitEffect = BulletFx.hitLancer; + } + + @Override + public void draw(Bullet b){} + + @Override + public void init(Bullet b){ + Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 36); + } + }; + + driverBolt = new MassDriverBolt(); + + frag = new BasicBulletType(5f, 8, "bullet"){{ + bulletWidth = 8f; + bulletHeight = 9f; + bulletShrink = 0.5f; + lifetime = 50f; + drag = 0.04f; + }}; + + bombExplosive = new BombBulletType(10f, 20f, "shell"){{ + bulletWidth = 9f; + bulletHeight = 13f; + hitEffect = BulletFx.flakExplosion; + }}; + + bombIncendiary = new BombBulletType(7f, 10f, "shell"){{ + bulletWidth = 8f; + bulletHeight = 12f; + hitEffect = BulletFx.flakExplosion; + backColor = Palette.lightOrange; + frontColor = Palette.lightishOrange; + incendChance = 1f; + incendAmount = 3; + incendSpread = 10f; + }}; + + bombOil = new BombBulletType(2f, 3f, "shell"){{ + bulletWidth = 8f; + bulletHeight = 12f; + hitEffect = BlockFx.pulverize; + backColor = new Color(0x4f4f4fff); + frontColor = Color.GRAY; + } + + @Override + public void hit(Bullet b, float x, float y){ + super.hit(b, x, y); + + for(int i = 0; i < 3; i++){ + Tile tile = world.tileWorld(x + Mathf.range(8f), y + Mathf.range(8f)); + Puddle.deposit(tile, Liquids.oil, 5f); + } + } + }; } @Override diff --git a/core/src/io/anuke/mindustry/content/Weapons.java b/core/src/io/anuke/mindustry/content/Weapons.java index f979f23cb6..20fa1f5804 100644 --- a/core/src/io/anuke/mindustry/content/Weapons.java +++ b/core/src/io/anuke/mindustry/content/Weapons.java @@ -1,6 +1,5 @@ package io.anuke.mindustry.content; -import io.anuke.mindustry.content.bullets.*; import io.anuke.mindustry.content.fx.Fx; import io.anuke.mindustry.content.fx.ShootFx; import io.anuke.mindustry.game.ContentList; @@ -19,7 +18,7 @@ public class Weapons implements ContentList{ reload = 14f; roundrobin = true; ejectEffect = ShootFx.shellEjectSmall; - ammo = StandardBullets.mechSmall; + ammo = Bullets.standardMechSmall; }}; blasterSmall = new Weapon("blaster"){{ @@ -27,7 +26,7 @@ public class Weapons implements ContentList{ reload = 15f; roundrobin = true; ejectEffect = ShootFx.shellEjectSmall; - ammo = StandardBullets.copper; + ammo = Bullets.standardCopper; }}; glaiveBlaster = new Weapon("bomber"){{ @@ -35,7 +34,7 @@ public class Weapons implements ContentList{ reload = 10f; roundrobin = true; ejectEffect = ShootFx.shellEjectSmall; - ammo = StandardBullets.glaive; + ammo = Bullets.standardGlaive; }}; droneBlaster = new Weapon("blaster"){{ @@ -44,7 +43,7 @@ public class Weapons implements ContentList{ width = 1f; roundrobin = true; ejectEffect = ShootFx.shellEjectSmall; - ammo = StandardBullets.copper; + ammo = Bullets.standardCopper; }}; healBlaster = new Weapon("heal-blaster"){{ @@ -53,7 +52,7 @@ public class Weapons implements ContentList{ roundrobin = false; ejectEffect = Fx.none; recoil = 2f; - ammo = TurretBullets.healBullet; + ammo = Bullets.healBullet; }}; missiles = new Weapon("missiles"){{ @@ -65,7 +64,7 @@ public class Weapons implements ContentList{ ejectEffect = Fx.none; velocityRnd = 0.2f; spacing = 1f; - ammo = MissileBullets.javelin; + ammo = Bullets.missileJavelin; }}; swarmer = new Weapon("swarmer"){{ @@ -78,7 +77,7 @@ public class Weapons implements ContentList{ roundrobin = true; ejectEffect = Fx.none; shake = 3f; - ammo = MissileBullets.swarm; + ammo = Bullets.missileSwarm; }}; chainBlaster = new Weapon("chain-blaster"){{ @@ -86,7 +85,7 @@ public class Weapons implements ContentList{ reload = 28f; roundrobin = true; ejectEffect = ShootFx.shellEjectSmall; - ammo = StandardBullets.copper; + ammo = Bullets.standardCopper; }}; shockgun = new Weapon("shockgun"){{ @@ -97,7 +96,7 @@ public class Weapons implements ContentList{ inaccuracy = 0f; velocityRnd = 0.2f; ejectEffect = Fx.none; - ammo = TurretBullets.lightning; + ammo = Bullets.lightning; }}; flakgun = new Weapon("flakgun"){{ @@ -109,7 +108,7 @@ public class Weapons implements ContentList{ recoil = 3f; velocityRnd = 0.1f; ejectEffect = ShootFx.shellEjectMedium; - ammo = ArtilleryBullets.dense; + ammo = Bullets.artilleryDense; }}; flamethrower = new Weapon("flamethrower"){{ @@ -118,7 +117,7 @@ public class Weapons implements ContentList{ roundrobin = true; recoil = 1f; ejectEffect = Fx.none; - ammo = TurretBullets.basicFlame; + ammo = Bullets.basicFlame; }}; artillery = new Weapon("artillery"){{ @@ -128,7 +127,7 @@ public class Weapons implements ContentList{ recoil = 5f; shake = 2f; ejectEffect = ShootFx.shellEjectMedium; - ammo = ArtilleryBullets.unit; + ammo = Bullets.artilleryUnit; }}; bomber = new Weapon("bomber"){{ @@ -139,7 +138,7 @@ public class Weapons implements ContentList{ ejectEffect = Fx.none; velocityRnd = 1f; inaccuracy = 40f; - ammo = WeaponBullets.bombExplosive; + ammo = Bullets.bombExplosive; }}; bomberTrident = new Weapon("bomber"){{ @@ -151,7 +150,7 @@ public class Weapons implements ContentList{ ejectEffect = Fx.none; velocityRnd = 1f; inaccuracy = 40f; - ammo = WeaponBullets.bombExplosive; + ammo = Bullets.bombExplosive; }}; laserBurster = new Weapon("bomber"){{ @@ -160,7 +159,7 @@ public class Weapons implements ContentList{ width = 0f; roundrobin = true; ejectEffect = Fx.none; - ammo = TurretBullets.lancerLaser; + ammo = Bullets.lancerLaser; }}; healBlasterDrone = new Weapon("heal-blaster"){{ @@ -170,7 +169,7 @@ public class Weapons implements ContentList{ roundrobin = true; ejectEffect = Fx.none; recoil = 2f; - ammo = TurretBullets.healBullet; + ammo = Bullets.healBullet; }}; healBlasterDrone2 = new Weapon("heal-blaster"){{ @@ -180,7 +179,7 @@ public class Weapons implements ContentList{ roundrobin = true; ejectEffect = Fx.none; recoil = 2f; - ammo = TurretBullets.healBullet; + ammo = Bullets.healBullet; }}; } diff --git a/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java b/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java index 813f7624b0..f1a7ac794b 100644 --- a/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java @@ -2,26 +2,26 @@ package io.anuke.mindustry.content.blocks; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; +import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Liquids; -import io.anuke.mindustry.content.bullets.*; import io.anuke.mindustry.content.fx.ShootFx; import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.defense.turrets.*; public class TurretBlocks extends BlockList implements ContentList{ - public static Block duo, /*scatter,*/ - scorch, hail, wave, lancer, arc, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown; + public static Block duo, scorch, hail, wave, lancer, arc, swarmer, salvo, + fuse, ripple, cyclone, spectre, meltdown; @Override public void load(){ duo = new DoubleTurret("duo"){{ ammo( - Items.copper, StandardBullets.copper, - Items.densealloy, StandardBullets.dense, - Items.pyratite, StandardBullets.tracer, - Items.silicon, StandardBullets.homing + Items.copper, Bullets.standardCopper, + Items.densealloy, Bullets.standardDense, + Items.pyratite, Bullets.standardIncendiary, + Items.silicon, Bullets.standardHoming ); reload = 25f; restitution = 0.03f; @@ -35,9 +35,9 @@ public class TurretBlocks extends BlockList implements ContentList{ hail = new ArtilleryTurret("hail"){{ ammo( - Items.densealloy, ArtilleryBullets.dense, - Items.silicon, ArtilleryBullets.homing, - Items.pyratite, ArtilleryBullets.incendiary + Items.densealloy, Bullets.artilleryDense, + Items.silicon, Bullets.artilleryHoming, + Items.pyratite, Bullets.artlleryIncendiary ); reload = 60f; recoil = 2f; @@ -48,7 +48,7 @@ public class TurretBlocks extends BlockList implements ContentList{ }}; scorch = new LiquidTurret("scorch"){{ - ammo(Liquids.oil, TurretBullets.basicFlame); + ammo(Liquids.oil, Bullets.basicFlame); recoil = 0f; reload = 4f; shootCone = 50f; @@ -58,10 +58,10 @@ public class TurretBlocks extends BlockList implements ContentList{ wave = new LiquidTurret("wave"){{ ammo( - Liquids.water, TurretBullets.waterShot, - Liquids.lava, TurretBullets.lavaShot, - Liquids.cryofluid, TurretBullets.cryoShot, - Liquids.oil, TurretBullets.oilShot + Liquids.water, Bullets.waterShot, + Liquids.lava, Bullets.lavaShot, + Liquids.cryofluid, Bullets.cryoShot, + Liquids.oil, Bullets.oilShot ); size = 2; recoil = 0f; @@ -87,7 +87,7 @@ public class TurretBlocks extends BlockList implements ContentList{ chargeTime = 60f; chargeMaxDelay = 30f; chargeEffects = 7; - shootType = TurretBullets.lancerLaser; + shootType = Bullets.lancerLaser; recoil = 2f; reload = 100f; cooldown = 0.03f; @@ -105,7 +105,7 @@ public class TurretBlocks extends BlockList implements ContentList{ }}; arc = new PowerTurret("arc"){{ - shootType = TurretBullets.arc; + shootType = Bullets.arc; reload = 85f; shootShake = 1f; shootCone = 40f; @@ -121,9 +121,9 @@ public class TurretBlocks extends BlockList implements ContentList{ swarmer = new BurstTurret("swarmer"){{ ammo( - Items.blastCompound, MissileBullets.explosive, - Items.pyratite, MissileBullets.incindiary, - Items.surgealloy, MissileBullets.surge + Items.blastCompound, Bullets.missileExplosive, + Items.pyratite, Bullets.missileIncendiary, + Items.surgealloy, Bullets.missileSurge ); reload = 50f; shots = 4; @@ -137,11 +137,11 @@ public class TurretBlocks extends BlockList implements ContentList{ salvo = new BurstTurret("salvo"){{ ammo( - Items.copper, StandardBullets.copper, - Items.densealloy, StandardBullets.dense, - Items.pyratite, StandardBullets.tracer, - Items.silicon, StandardBullets.homing, - Items.thorium, StandardBullets.thorium + Items.copper, Bullets.standardCopper, + Items.densealloy, Bullets.standardDense, + Items.pyratite, Bullets.standardIncendiary, + Items.silicon, Bullets.standardHoming, + Items.thorium, Bullets.standardThorium ); size = 2; @@ -160,11 +160,11 @@ public class TurretBlocks extends BlockList implements ContentList{ ripple = new ArtilleryTurret("ripple"){{ ammo( - Items.densealloy, ArtilleryBullets.dense, - Items.silicon, ArtilleryBullets.homing, - Items.pyratite, ArtilleryBullets.incendiary, - Items.blastCompound, ArtilleryBullets.explosive, - Items.plastanium, ArtilleryBullets.plastic + Items.densealloy, Bullets.artilleryDense, + Items.silicon, Bullets.artilleryHoming, + Items.pyratite, Bullets.artlleryIncendiary, + Items.blastCompound, Bullets.artilleryExplosive, + Items.plastanium, Bullets.arilleryPlastic ); size = 3; shots = 4; @@ -184,9 +184,9 @@ public class TurretBlocks extends BlockList implements ContentList{ cyclone = new ItemTurret("cyclone"){{ ammo( - Items.blastCompound, FlakBullets.explosive, - Items.plastanium, FlakBullets.plastic, - Items.surgealloy, FlakBullets.surge + Items.blastCompound, Bullets.flakExplosive, + Items.plastanium, Bullets.flakPlastic, + Items.surgealloy, Bullets.flakSurge ); xRand = 4f; reload = 8f; @@ -201,7 +201,7 @@ public class TurretBlocks extends BlockList implements ContentList{ }}; fuse = new ItemTurret("fuse"){{ - ammo(Items.densealloy, TurretBullets.fuseShot); + ammo(Items.densealloy, Bullets.fuseShot); reload = 50f; shootShake = 4f; range = 80f; @@ -214,9 +214,9 @@ public class TurretBlocks extends BlockList implements ContentList{ spectre = new DoubleTurret("spectre"){{ ammo( - Items.densealloy, StandardBullets.denseBig, - Items.pyratite, StandardBullets.tracerBig, - Items.thorium, StandardBullets.thoriumBig + Items.densealloy, Bullets.standardDenseBig, + Items.pyratite, Bullets.standardIncendiaryBig, + Items.thorium, Bullets.standardThoriumBig ); reload = 6f; coolantMultiplier = 0.5f; @@ -237,7 +237,7 @@ public class TurretBlocks extends BlockList implements ContentList{ }}; meltdown = new LaserTurret("meltdown"){{ - shootType = TurretBullets.meltdownLaser; + shootType = Bullets.meltdownLaser; shootEffect = ShootFx.shootBigSmoke2; shootCone = 40f; recoil = 4f; diff --git a/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java b/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java deleted file mode 100644 index 25169fca0f..0000000000 --- a/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java +++ /dev/null @@ -1,107 +0,0 @@ -package io.anuke.mindustry.content.bullets; - -import io.anuke.mindustry.content.fx.BulletFx; -import io.anuke.mindustry.content.fx.Fx; -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.graphics.Palette; -import io.anuke.mindustry.game.ContentList; - -public class ArtilleryBullets extends BulletList implements ContentList{ - public static BulletType dense, plastic, plasticFrag, homing, incendiary, explosive, surge, unit; - - @Override - public void load(){ - - dense = new ArtilleryBulletType(3f, 0, "shell"){{ - hitEffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 50f; - bulletWidth = bulletHeight = 11f; - collidesTiles = false; - splashDamageRadius = 25f; - splashDamage = 33f; - }}; - - plasticFrag = new BasicBulletType(2.5f, 6, "bullet"){{ - bulletWidth = 10f; - bulletHeight = 12f; - bulletShrink = 1f; - lifetime = 15f; - backColor = Palette.plastaniumBack; - frontColor = Palette.plastaniumFront; - despawnEffect = Fx.none; - }}; - - plastic = new ArtilleryBulletType(3.3f, 0, "shell"){{ - hitEffect = BulletFx.plasticExplosion; - knockback = 1f; - lifetime = 55f; - bulletWidth = bulletHeight = 13f; - collidesTiles = false; - splashDamageRadius = 35f; - splashDamage = 35f; - fragBullet = plasticFrag; - fragBullets = 9; - backColor = Palette.plastaniumBack; - frontColor = Palette.plastaniumFront; - }}; - - homing = new ArtilleryBulletType(3f, 0, "shell"){{ - hitEffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 45f; - bulletWidth = bulletHeight = 11f; - collidesTiles = false; - splashDamageRadius = 25f; - splashDamage = 33f; - homingPower = 2f; - homingRange = 50f; - }}; - - incendiary = new ArtilleryBulletType(3f, 0, "shell"){{ - hitEffect = BulletFx.blastExplosion; - knockback = 0.8f; - lifetime = 60f; - bulletWidth = bulletHeight = 13f; - collidesTiles = false; - splashDamageRadius = 25f; - splashDamage = 30f; - incendAmount = 4; - incendSpread = 11f; - frontColor = Palette.lightishOrange; - backColor = Palette.lightOrange; - trailEffect = BulletFx.incendTrail; - }}; - - explosive = new ArtilleryBulletType(2f, 0, "shell"){{ - hitEffect = BulletFx.blastExplosion; - knockback = 0.8f; - lifetime = 70f; - bulletWidth = bulletHeight = 14f; - collidesTiles = false; - splashDamageRadius = 45f; - splashDamage = 50f; - backColor = Palette.missileYellowBack; - frontColor = Palette.missileYellow; - }}; - - unit = new ArtilleryBulletType(2f, 0, "shell"){{ - hitEffect = BulletFx.blastExplosion; - knockback = 0.8f; - lifetime = 90f; - bulletWidth = bulletHeight = 14f; - collides = true; - collidesTiles = true; - splashDamageRadius = 45f; - splashDamage = 50f; - backColor = Palette.bulletYellowBack; - frontColor = Palette.bulletYellow; - }}; - - surge = new ArtilleryBulletType(3f, 0, "shell"){{ - //TODO - }}; - } -} diff --git a/core/src/io/anuke/mindustry/content/bullets/BulletList.java b/core/src/io/anuke/mindustry/content/bullets/BulletList.java deleted file mode 100644 index cfe4921b93..0000000000 --- a/core/src/io/anuke/mindustry/content/bullets/BulletList.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.anuke.mindustry.content.bullets; - -import io.anuke.mindustry.game.ContentList; -import io.anuke.mindustry.type.ContentType; - -public abstract class BulletList implements ContentList{ - - @Override - public ContentType type(){ - return ContentType.bullet; - } -} diff --git a/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java b/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java deleted file mode 100644 index d312640e35..0000000000 --- a/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.anuke.mindustry.content.bullets; - -import io.anuke.mindustry.content.fx.BulletFx; -import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.entities.bullet.BulletType; -import io.anuke.mindustry.entities.bullet.FlakBulletType; -import io.anuke.mindustry.entities.effect.Lightning; -import io.anuke.mindustry.graphics.Palette; -import io.anuke.mindustry.game.ContentList; -import io.anuke.arc.math.Mathf; - -public class FlakBullets extends BulletList implements ContentList{ - public static BulletType plastic, explosive, surge; - - @Override - public void load(){ - - - plastic = new FlakBulletType(4f, 5){ - { - splashDamageRadius = 40f; - fragBullet = ArtilleryBullets.plasticFrag; - fragBullets = 4; - hitEffect = BulletFx.plasticExplosion; - frontColor = Palette.plastaniumFront; - backColor = Palette.plastaniumBack; - } - }; - - explosive = new FlakBulletType(4f, 5){ - { - //default bullet type, no changes - } - }; - - surge = new FlakBulletType(4f, 7){ - { - splashDamage = 33f; - } - - @Override - public void despawned(Bullet b) { - super.despawned(b); - - for (int i = 0; i < 2; i++) { - Lightning.create(b.getTeam(), Palette.surge, damage, b.x, b.y, Mathf.random(360f), 12); - } - } - }; - } -} diff --git a/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java b/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java deleted file mode 100644 index f3a3d9092c..0000000000 --- a/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java +++ /dev/null @@ -1,124 +0,0 @@ -package io.anuke.mindustry.content.bullets; - -import io.anuke.arc.graphics.Color; -import io.anuke.mindustry.content.fx.BulletFx; -import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.entities.bullet.BulletType; -import io.anuke.mindustry.entities.bullet.MissileBulletType; -import io.anuke.mindustry.entities.effect.Lightning; -import io.anuke.mindustry.graphics.Palette; -import io.anuke.mindustry.game.ContentList; -import io.anuke.arc.util.Time; -import io.anuke.arc.math.Mathf; - -public class MissileBullets extends BulletList implements ContentList{ - public static BulletType explosive, incindiary, surge, javelin, swarm; - - @Override - public void load(){ - - explosive = new MissileBulletType(1.8f, 10, "missile"){ - { - bulletWidth = 8f; - bulletHeight = 8f; - bulletShrink = 0f; - drag = -0.01f; - splashDamageRadius = 30f; - splashDamage = 30f; - lifetime = 150f; - hitEffect = BulletFx.blastExplosion; - despawnEffect = BulletFx.blastExplosion; - } - }; - - incindiary = new MissileBulletType(2f, 12, "missile"){ - { - frontColor = Palette.lightishOrange; - backColor = Palette.lightOrange; - bulletWidth = 7f; - bulletHeight = 8f; - bulletShrink = 0f; - drag = -0.01f; - homingPower = 7f; - splashDamageRadius = 10f; - splashDamage = 10f; - lifetime = 160f; - hitEffect = BulletFx.blastExplosion; - incendSpread = 10f; - incendAmount = 3; - } - }; - - surge = new MissileBulletType(3.5f, 15, "bullet"){ - { - bulletWidth = 8f; - bulletHeight = 8f; - bulletShrink = 0f; - drag = -0.01f; - splashDamageRadius = 30f; - splashDamage = 22f; - lifetime = 150f; - hitEffect = BulletFx.blastExplosion; - despawnEffect = BulletFx.blastExplosion; - } - - @Override - public void hit(Bullet b) { - super.hit(b); - - for (int i = 0; i < 2; i++) { - Lightning.create(b.getTeam(), Palette.surge, damage, b.x, b.y, Mathf.random(360f), 14); - } - } - }; - - javelin = new MissileBulletType(5f, 10.5f, "missile"){ - { - bulletWidth = 8f; - bulletHeight = 8f; - bulletShrink = 0f; - drag = -0.003f; - keepVelocity = false; - splashDamageRadius = 20f; - splashDamage = 1f; - lifetime = 90f; - trailColor = Color.valueOf("b6c6fd"); - hitEffect = BulletFx.blastExplosion; - despawnEffect = BulletFx.blastExplosion; - backColor = Palette.bulletYellowBack; - frontColor = Palette.bulletYellow; - } - - @Override - public void update(Bullet b){ - super.update(b); - b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f)); - } - }; - - swarm = new MissileBulletType(2.7f, 12, "missile"){ - { - bulletWidth = 8f; - bulletHeight = 8f; - bulletShrink = 0f; - drag = -0.003f; - homingRange = 60f; - keepVelocity = false; - splashDamageRadius = 25f; - splashDamage = 10f; - lifetime = 120f; - trailColor = Color.GRAY; - backColor = Palette.bulletYellowBack; - frontColor = Palette.bulletYellow; - hitEffect = BulletFx.blastExplosion; - despawnEffect = BulletFx.blastExplosion; - } - - @Override - public void update(Bullet b){ - super.update(b); - b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f)); - } - }; - } -} diff --git a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java b/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java deleted file mode 100644 index 54670e3484..0000000000 --- a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java +++ /dev/null @@ -1,101 +0,0 @@ -package io.anuke.mindustry.content.bullets; - -import io.anuke.arc.graphics.Color; -import io.anuke.mindustry.content.fx.BulletFx; -import io.anuke.mindustry.content.fx.ShootFx; -import io.anuke.mindustry.entities.bullet.BasicBulletType; -import io.anuke.mindustry.entities.bullet.BulletType; -import io.anuke.mindustry.game.ContentList; -import io.anuke.mindustry.graphics.Palette; - -public class StandardBullets extends BulletList implements ContentList{ - public static BulletType copper, dense, thorium, homing, tracer, mechSmall, glaive, denseBig, thoriumBig, tracerBig; - - @Override - public void load(){ - - copper = new BasicBulletType(2.5f, 7, "bullet"){{ - bulletWidth = 7f; - bulletHeight = 9f; - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - ammoMultiplier = 5; - }}; - - dense = new BasicBulletType(3.5f, 18, "bullet"){{ - bulletWidth = 9f; - bulletHeight = 12f; - armorPierce = 0.2f; - reloadMultiplier = 0.6f; - ammoMultiplier = 2; - }}; - - thorium = new BasicBulletType(4f, 29, "bullet"){{ - bulletWidth = 10f; - bulletHeight = 13f; - armorPierce = 0.5f; - shootEffect = ShootFx.shootBig; - smokeEffect = ShootFx.shootBigSmoke; - ammoMultiplier = 2; - }}; - - homing = new BasicBulletType(3f, 9, "bullet"){{ - bulletWidth = 7f; - bulletHeight = 9f; - homingPower = 5f; - reloadMultiplier = 1.4f; - ammoMultiplier = 5; - }}; - - tracer = new BasicBulletType(3.2f, 11, "bullet"){{ - bulletWidth = 10f; - bulletHeight = 12f; - frontColor = Palette.lightishOrange; - backColor = Palette.lightOrange; - incendSpread = 3f; - incendAmount = 1; - incendChance = 0.3f; - inaccuracy = 3f; - }}; - - glaive = new BasicBulletType(4f, 7.5f, "bullet"){{ - bulletWidth = 10f; - bulletHeight = 12f; - frontColor = Color.valueOf("feb380"); - backColor = Color.valueOf("ea8878"); - incendSpread = 3f; - incendAmount = 1; - incendChance = 0.3f; - }}; - - mechSmall = new BasicBulletType(4f, 9, "bullet"){{ - bulletWidth = 11f; - bulletHeight = 14f; - lifetime = 40f; - inaccuracy = 5f; - despawnEffect = BulletFx.hitBulletSmall; - }}; - - denseBig = new BasicBulletType(7f, 42, "bullet"){{ - bulletWidth = 15f; - bulletHeight = 21f; - armorPierce = 0.2f; - }}; - - thoriumBig = new BasicBulletType(8f, 65, "bullet"){{ - bulletWidth = 16f; - bulletHeight = 23f; - armorPierce = 0.5f; - }}; - - tracerBig = new BasicBulletType(7f, 38, "bullet"){{ - bulletWidth = 16f; - bulletHeight = 21f; - frontColor = Palette.lightishOrange; - backColor = Palette.lightOrange; - incendSpread = 3f; - incendAmount = 2; - incendChance = 0.3f; - }}; - } -} diff --git a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java deleted file mode 100644 index bbc3d6336d..0000000000 --- a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java +++ /dev/null @@ -1,425 +0,0 @@ -package io.anuke.mindustry.content.bullets; - -import io.anuke.arc.entities.Effects; -import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.CapStyle; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.math.Angles; -import io.anuke.arc.math.Mathf; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; -import io.anuke.mindustry.content.Liquids; -import io.anuke.mindustry.content.StatusEffects; -import io.anuke.mindustry.content.fx.BlockFx; -import io.anuke.mindustry.content.fx.BulletFx; -import io.anuke.mindustry.content.fx.EnvironmentFx; -import io.anuke.mindustry.content.fx.Fx; -import io.anuke.mindustry.entities.Damage; -import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.entities.bullet.BulletType; -import io.anuke.mindustry.entities.bullet.LiquidBulletType; -import io.anuke.mindustry.entities.effect.Fire; -import io.anuke.mindustry.entities.effect.Lightning; -import io.anuke.mindustry.game.ContentList; -import io.anuke.mindustry.graphics.Palette; -import io.anuke.mindustry.graphics.Shapes; -import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.blocks.BuildBlock; -import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData; - -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, burstLaser, meltdownLaser, - fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning, driverBolt, healBullet, arc, damageLightning; - - @Override - public void load(){ - - damageLightning = new BulletType(0.0001f, 0f){ - { - lifetime = Lightning.lifetime; - hitEffect = BulletFx.hitLancer; - despawnEffect = Fx.none; - status = StatusEffects.shocked; - statusIntensity = 1f; - } - }; - - healBullet = new BulletType(5.2f, 13){ - float healPercent = 3f; - - { - hitEffect = BulletFx.hitLaser; - despawnEffect = BulletFx.hitLaser; - collidesTeam = true; - } - - @Override - public boolean collides(Bullet b, Tile tile){ - return tile.getTeam() != b.getTeam() || tile.entity.healthf() < 1f; - } - - @Override - public void draw(Bullet b){ - Draw.color(Palette.heal); - Lines.stroke(2f); - Lines.lineAngleCenter(b.x, b.y, b.rot(), 7f); - Draw.color(Color.WHITE); - Lines.lineAngleCenter(b.x, b.y, b.rot(), 3f); - Draw.reset(); - } - - @Override - public void hitTile(Bullet b, Tile tile){ - super.hit(b); - tile = tile.target(); - - if(tile != null && tile.getTeam() == b.getTeam() && !(tile.block() instanceof BuildBlock)){ - Effects.effect(BlockFx.healBlockFull, Palette.heal, tile.drawx(), tile.drawy(), tile.block().size); - tile.entity.healBy(healPercent / 100f * tile.entity.maxHealth()); - } - } - }; - - fireball = new BulletType(1f, 4){ - { - pierce = true; - hitTiles = false; - collides = false; - collidesTiles = false; - drag = 0.03f; - hitEffect = despawnEffect = Fx.none; - } - - @Override - public void init(Bullet b){ - b.velocity().setLength(0.6f + Mathf.random(2f)); - } - - @Override - public void draw(Bullet b){ - //TODO add color to the bullet depending on the color of the flame it came from - Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, b.fin()); - Fill.circle(b.x, b.y, 3f * b.fout()); - Draw.reset(); - } - - @Override - public void update(Bullet b){ - if(Mathf.chance(0.04 * Time.delta())){ - Tile tile = world.tileWorld(b.x, b.y); - if(tile != null){ - Fire.create(tile); - } - } - - if(Mathf.chance(0.1 * Time.delta())){ - Effects.effect(EnvironmentFx.fireballsmoke, b.x, b.y); - } - - if(Mathf.chance(0.1 * Time.delta())){ - Effects.effect(EnvironmentFx.ballfire, b.x, b.y); - } - } - }; - - basicFlame = new BulletType(2.3f, 5){ - { - hitSize = 7f; - lifetime = 35f; - pierce = true; - drag = 0.05f; - hitEffect = BulletFx.hitFlameSmall; - despawnEffect = Fx.none; - status = StatusEffects.burning; - } - - @Override - public void draw(Bullet b){ - } - }; - - lancerLaser = 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 init(Bullet b){ - Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length); - } - - @Override - public void draw(Bullet b){ - float f = Mathf.curve(b.fin(), 0f, 0.2f); - float baseLen = length * f; - - Lines.lineAngle(b.x, b.y, b.rot(), 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.rot(), baseLen * lenscales[i]); - } - } - Draw.reset(); - } - }; - - meltdownLaser = new BulletType(0.001f, 26){ - Color tmpColor = new Color(); - Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.WHITE}; - float[] tscales = {1f, 0.7f, 0.5f, 0.2f}; - float[] strokes = {2f, 1.5f, 1f, 0.3f}; - float[] lenscales = {1f, 1.12f, 1.15f, 1.17f}; - float length = 200f; - - { - hitEffect = BulletFx.hitMeltdown; - despawnEffect = Fx.none; - hitSize = 4; - drawSize = 420f; - lifetime = 16f; - pierce = true; - } - - @Override - public void update(Bullet b){ - if(b.timer.get(1, 5f)){ - Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length); - } - Effects.shake(1f, 1f, b.x, b.y); - } - - @Override - public void hit(Bullet b, float hitx, float hity){ - Effects.effect(hitEffect, colors[2], hitx, hity); - if(Mathf.chance(0.4)){ - Fire.create(world.tileWorld(hitx+Mathf.range(5f), hity+Mathf.range(5f))); - } - } - - @Override - public void draw(Bullet b){ - float baseLen = (length) * b.fout(); - - Lines.lineAngle(b.x, b.y, b.rot(), baseLen); - for(int s = 0; s < colors.length; s++){ - Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f))); - for(int i = 0; i < tscales.length; i++){ - Tmp.v1.trns(b.rot() + 180f, (lenscales[i] - 1f) * 35f); - Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]); - Lines.lineAngle(b.x + Tmp.v1.x, b.y + Tmp.v1.y, b.rot(), baseLen * lenscales[i], CapStyle.none); - } - } - Draw.reset(); - } - }; - - fuseShot = new BulletType(0.01f, 70){ - int rays = 3; - float raySpace = 2f; - float rayLength = 80f; - { - hitEffect = BulletFx.hitFuse; - lifetime = 13f; - despawnEffect = Fx.none; - pierce = true; - } - - @Override - public void init(Bullet b) { - for (int i = 0; i < rays; i++) { - Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays/2))*20f); - } - } - - @Override - public void draw(Bullet b) { - super.draw(b); - Draw.color(Color.WHITE, Palette.surge, b.fin()); - for(int i = 0; i < 7; i++){ - Tmp.v1.trns(b.rot(), i * 8f); - float sl = Mathf.clamp(b.fout()-0.5f) * (80f - i *10); - Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() + 90); - Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() - 90); - } - Shapes.tri(b.x, b.y, 13f, (rayLength+50) * b.fout(), b.rot()); - Shapes.tri(b.x, b.y, 13f, 10f * b.fout(), b.rot() + 180f); - Draw.reset(); - } - }; - - waterShot = new LiquidBulletType(Liquids.water){ - { - status = StatusEffects.wet; - statusIntensity = 0.5f; - knockback = 0.65f; - } - }; - cryoShot = new LiquidBulletType(Liquids.cryofluid){ - { - status = StatusEffects.freezing; - statusIntensity = 0.5f; - } - }; - lavaShot = new LiquidBulletType(Liquids.lava){ - { - damage = 4; - speed = 1.9f; - drag = 0.03f; - status = StatusEffects.melting; - statusIntensity = 0.5f; - } - }; - oilShot = new LiquidBulletType(Liquids.oil){ - { - speed = 2f; - drag = 0.03f; - status = StatusEffects.tarred; - statusIntensity = 0.5f; - } - }; - - lightning = new BulletType(0.001f, 12f){ - { - lifetime = 1f; - despawnEffect = Fx.none; - hitEffect = BulletFx.hitLancer; - keepVelocity = false; - } - - @Override - public void draw(Bullet b){ - } - - @Override - public void init(Bullet b){ - Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 30); - } - }; - - arc = new BulletType(0.001f, 26){ - { - lifetime = 1; - despawnEffect = Fx.none; - hitEffect = BulletFx.hitLancer; - } - - @Override - public void draw(Bullet b){ - } - - @Override - public void init(Bullet b){ - Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 36); - } - }; - - driverBolt = new BulletType(5.3f, 50){ - { - collidesTiles = false; - lifetime = 200f; - despawnEffect = BlockFx.smeltsmoke; - hitEffect = BulletFx.hitBulletBig; - drag = 0.005f; - } - - @Override - public void draw(Bullet b){ - float w = 11f, h = 13f; - - Draw.color(Palette.bulletYellowBack); - Draw.rect("shell-back", b.x, b.y, w, h, b.rot() + 90); - - Draw.color(Palette.bulletYellow); - Draw.rect("shell", b.x, b.y, w, h, b.rot() + 90); - - Draw.reset(); - } - - @Override - public void update(Bullet b){ - //data MUST be an instance of DriverBulletData - if(!(b.getData() instanceof DriverBulletData)){ - hit(b); - return; - } - - float hitDst = 7f; - - DriverBulletData data = (DriverBulletData) b.getData(); - - //if the target is dead, just keep flying until the bullet explodes - if(data.to.isDead()){ - return; - } - - float baseDst = data.from.dst(data.to); - float dst1 = b.dst(data.from); - float dst2 = b.dst(data.to); - - boolean intersect = false; - - //bullet has gone past the destination point: but did it intersect it? - if(dst1 > baseDst){ - float angleTo = b.angleTo(data.to); - float baseAngle = data.to.angleTo(data.from); - - //if angles are nearby, then yes, it did - if(Angles.near(angleTo, baseAngle, 2f)){ - intersect = true; - //snap bullet position back; this is used for low-FPS situations - b.set(data.to.x + Angles.trnsx(baseAngle, hitDst), data.to.y + Angles.trnsy(baseAngle, hitDst)); - } - } - - //if on course and it's in range of the target - if(Math.abs(dst1 + dst2 - baseDst) < 4f && dst2 <= hitDst){ - intersect = true; - } //else, bullet has gone off course, does not get recieved. - - if(intersect){ - data.to.handlePayload(b, data); - } - } - - @Override - public void despawned(Bullet b){ - super.despawned(b); - - if(!(b.getData() instanceof DriverBulletData)) return; - - DriverBulletData data = (DriverBulletData) b.getData(); - data.to.isRecieving = false; - - for(int i = 0; i < data.items.length; i++){ - int amountDropped = Mathf.random(0, data.items[i]); - if(amountDropped > 0){ - float angle = b.rot() + Mathf.range(100f); - Effects.effect(EnvironmentFx.dropItem, Color.WHITE, b.x, b.y, angle, content.item(i)); - } - } - } - - @Override - public void hit(Bullet b, float hitx, float hity){ - super.hit(b, hitx, hity); - despawned(b); - } - }; - } -} diff --git a/core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java b/core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java deleted file mode 100644 index 6052ee1b6b..0000000000 --- a/core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java +++ /dev/null @@ -1,99 +0,0 @@ -package io.anuke.mindustry.content.bullets; - -import io.anuke.arc.graphics.Color; -import io.anuke.mindustry.content.Liquids; -import io.anuke.mindustry.content.fx.BlockFx; -import io.anuke.mindustry.content.fx.BulletFx; -import io.anuke.mindustry.entities.bullet.BasicBulletType; -import io.anuke.mindustry.entities.bullet.BombBulletType; -import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.entities.bullet.BulletType; -import io.anuke.mindustry.entities.effect.Fire; -import io.anuke.mindustry.entities.effect.Puddle; -import io.anuke.mindustry.graphics.Palette; -import io.anuke.mindustry.world.Tile; -import io.anuke.arc.math.Mathf; - -import static io.anuke.mindustry.Vars.world; - -public class WeaponBullets extends BulletList{ - public static BulletType tungstenShotgun, bombExplosive, bombIncendiary, bombOil, shellCarbide; - - @Override - public void load(){ - tungstenShotgun = new BasicBulletType(5f, 8, "bullet"){ - { - bulletWidth = 8f; - bulletHeight = 9f; - bulletShrink = 0.5f; - lifetime = 50f; - drag = 0.04f; - } - }; - - bombExplosive = new BombBulletType(10f, 20f, "shell"){ - { - bulletWidth = 9f; - bulletHeight = 13f; - hitEffect = BulletFx.flakExplosion; - } - }; - - bombIncendiary = new BombBulletType(7f, 10f, "shell"){ - { - bulletWidth = 8f; - bulletHeight = 12f; - hitEffect = BulletFx.flakExplosion; - backColor = Palette.lightOrange; - frontColor = Palette.lightishOrange; - } - - @Override - public void hit(Bullet b, float x, float y){ - super.hit(b, x, y); - - for(int i = 0; i < 3; i++){ - float cx = x + Mathf.range(10f); - float cy = y + Mathf.range(10f); - Tile tile = world.tileWorld(cx, cy); - if(tile != null){ - Fire.create(tile); - } - } - } - }; - - bombOil = new BombBulletType(2f, 3f, "shell"){ - { - bulletWidth = 8f; - bulletHeight = 12f; - hitEffect = BlockFx.pulverize; - backColor = new Color(0x4f4f4fff); - frontColor = Color.GRAY; - } - - @Override - public void hit(Bullet b, float x, float y){ - super.hit(b, x, y); - - for(int i = 0; i < 3; i++){ - Tile tile = world.tileWorld(x + Mathf.range(8f), y + Mathf.range(8f)); - Puddle.deposit(tile, Liquids.oil, 5f); - } - } - }; - - shellCarbide = new BasicBulletType(3.4f, 20, "bullet"){ - { - bulletWidth = 10f; - bulletHeight = 12f; - bulletShrink = 0.4f; - lifetime = 40f; - drag = 0.025f; - fragBullets = 5; - hitEffect = BulletFx.flakExplosion; - fragBullet = tungstenShotgun; - } - }; - } -} diff --git a/core/src/io/anuke/mindustry/core/ContentLoader.java b/core/src/io/anuke/mindustry/core/ContentLoader.java index 8cbb87673c..e425e33e21 100644 --- a/core/src/io/anuke/mindustry/core/ContentLoader.java +++ b/core/src/io/anuke/mindustry/core/ContentLoader.java @@ -7,7 +7,6 @@ import io.anuke.arc.function.Consumer; import io.anuke.arc.util.Log; import io.anuke.mindustry.content.*; import io.anuke.mindustry.content.blocks.*; -import io.anuke.mindustry.content.bullets.*; import io.anuke.mindustry.content.fx.*; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.bullet.Bullet; @@ -60,12 +59,7 @@ public class ContentLoader{ new Liquids(), //bullets - new ArtilleryBullets(), - new FlakBullets(), - new MissileBullets(), - new StandardBullets(), - new TurretBullets(), - new WeaponBullets(), + new Bullets(), //weapons new Weapons(), @@ -275,7 +269,5 @@ public class ContentLoader{ TypeTrait.registerType(Lightning.class, Lightning::new); } - private class ImpendingDoomException extends RuntimeException{ - public ImpendingDoomException(String s){ super(s); } - } + private class ImpendingDoomException extends RuntimeException{ ImpendingDoomException(String s){ super(s); }} } diff --git a/core/src/io/anuke/mindustry/entities/Damage.java b/core/src/io/anuke/mindustry/entities/Damage.java index 27713c81ea..49ad873375 100644 --- a/core/src/io/anuke/mindustry/entities/Damage.java +++ b/core/src/io/anuke/mindustry/entities/Damage.java @@ -10,7 +10,7 @@ import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.util.Time; -import io.anuke.mindustry.content.bullets.TurretBullets; +import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.content.fx.ExplosionFx; import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.effect.Fire; @@ -37,7 +37,7 @@ public class Damage{ } for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i++){ - Time.run(i / 2f, () -> Call.createBullet(TurretBullets.fireball, x, y, Mathf.random(360f))); + Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f))); } int waves = Mathf.clamp((int) (explosiveness / 4), 0, 30); diff --git a/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java index 7f044fbcd5..6152de43fa 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java @@ -10,6 +10,7 @@ import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.mindustry.entities.Damage; import io.anuke.mindustry.entities.Units; +import io.anuke.mindustry.entities.effect.Lightning; import io.anuke.mindustry.entities.traits.TargetTrait; import io.anuke.mindustry.graphics.Palette; @@ -34,6 +35,9 @@ public class BasicBulletType extends BulletType{ public float homingPower = 0f; public float homingRange = 50f; + public int lightining; + public int lightningLength = 5; + public TextureRegion backRegion; public TextureRegion frontRegion; @@ -102,5 +106,9 @@ public class BasicBulletType extends BulletType{ if(fragBullet != null || splashDamageRadius > 0){ hit(b); } + + for (int i = 0; i < lightining; i++) { + Lightning.create(b.getTeam(), Palette.surge, damage, b.x, b.y, Mathf.random(360f), lightningLength); + } } } diff --git a/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java index b3877c26de..90a396839d 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java @@ -25,6 +25,8 @@ public class LiquidBulletType extends BulletType{ this.liquid = liquid; lifetime = 70f; + status = liquid.effect; + statusIntensity = 0.5f; despawnEffect = Fx.none; hitEffect = BulletFx.hitLiquid; drag = 0.01f; diff --git a/core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java b/core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java new file mode 100644 index 0000000000..b263b81ab6 --- /dev/null +++ b/core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java @@ -0,0 +1,109 @@ +package io.anuke.mindustry.entities.bullet; + +import io.anuke.arc.entities.Effects; +import io.anuke.arc.graphics.Color; +import io.anuke.arc.graphics.g2d.Draw; +import io.anuke.arc.math.Angles; +import io.anuke.arc.math.Mathf; +import io.anuke.mindustry.content.fx.BlockFx; +import io.anuke.mindustry.content.fx.BulletFx; +import io.anuke.mindustry.content.fx.EnvironmentFx; +import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData; + +import static io.anuke.mindustry.Vars.content; + +public class MassDriverBolt extends BulletType{ + + public MassDriverBolt(){ + super(5.3f, 50); + collidesTiles = false; + lifetime = 200f; + despawnEffect = BlockFx.smeltsmoke; + hitEffect = BulletFx.hitBulletBig; + drag = 0.005f; + } + + @Override + public void draw(Bullet b){ + float w = 11f, h = 13f; + + Draw.color(Palette.bulletYellowBack); + Draw.rect("shell-back", b.x, b.y, w, h, b.rot() + 90); + + Draw.color(Palette.bulletYellow); + Draw.rect("shell", b.x, b.y, w, h, b.rot() + 90); + + Draw.reset(); + } + + @Override + public void update(Bullet b){ + //data MUST be an instance of DriverBulletData + if(!(b.getData() instanceof DriverBulletData)){ + hit(b); + return; + } + + float hitDst = 7f; + + DriverBulletData data = (DriverBulletData) b.getData(); + + //if the target is dead, just keep flying until the bullet explodes + if(data.to.isDead()){ + return; + } + + float baseDst = data.from.dst(data.to); + float dst1 = b.dst(data.from); + float dst2 = b.dst(data.to); + + boolean intersect = false; + + //bullet has gone past the destination point: but did it intersect it? + if(dst1 > baseDst){ + float angleTo = b.angleTo(data.to); + float baseAngle = data.to.angleTo(data.from); + + //if angles are nearby, then yes, it did + if(Angles.near(angleTo, baseAngle, 2f)){ + intersect = true; + //snap bullet position back; this is used for low-FPS situations + b.set(data.to.x + Angles.trnsx(baseAngle, hitDst), data.to.y + Angles.trnsy(baseAngle, hitDst)); + } + } + + //if on course and it's in range of the target + if(Math.abs(dst1 + dst2 - baseDst) < 4f && dst2 <= hitDst){ + intersect = true; + } //else, bullet has gone off course, does not get recieved. + + if(intersect){ + data.to.handlePayload(b, data); + } + } + + @Override + public void despawned(Bullet b){ + super.despawned(b); + + if(!(b.getData() instanceof DriverBulletData)) return; + + DriverBulletData data = (DriverBulletData) b.getData(); + data.to.isRecieving = false; + + for(int i = 0; i < data.items.length; i++){ + int amountDropped = Mathf.random(0, data.items[i]); + if(amountDropped > 0){ + float angle = b.rot() + Mathf.range(100f); + Effects.effect(EnvironmentFx.dropItem, Color.WHITE, b.x, b.y, angle, content.item(i)); + } + } + } + + @Override + public void hit(Bullet b, float hitx, float hity){ + super.hit(b, hitx, hity); + despawned(b); + } +} diff --git a/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java index d27e2f222f..b62b83787a 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java @@ -10,6 +10,9 @@ import io.anuke.arc.math.Mathf; public class MissileBulletType extends BasicBulletType{ protected Color trailColor = Palette.missileYellowBack; + protected float weaveScale = 0f; + protected float weaveMag = -1f; + public MissileBulletType(float speed, float damage, String bulletSprite){ super(speed, damage, bulletSprite); backColor = Palette.missileYellowBack; @@ -24,5 +27,9 @@ public class MissileBulletType extends BasicBulletType{ if(Mathf.chance(Time.delta() * 0.2)){ Effects.effect(BulletFx.missileTrail, trailColor, b.x, b.y, 2f); } + + if(weaveMag > 0){ + b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, weaveScale, weaveMag)); + } } } diff --git a/core/src/io/anuke/mindustry/entities/effect/Fire.java b/core/src/io/anuke/mindustry/entities/effect/Fire.java index 36e2f03ac5..359a0b1d09 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Fire.java +++ b/core/src/io/anuke/mindustry/entities/effect/Fire.java @@ -13,8 +13,8 @@ import io.anuke.arc.util.Structs; import io.anuke.arc.util.Time; import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; +import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.content.StatusEffects; -import io.anuke.mindustry.content.bullets.TurretBullets; import io.anuke.mindustry.content.fx.EnvironmentFx; import io.anuke.mindustry.entities.Damage; import io.anuke.mindustry.entities.TileEntity; @@ -136,7 +136,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{ create(other); if(Mathf.chance(fireballChance * Time.delta() * Mathf.clamp(flammability / 10f))){ - Call.createBullet(TurretBullets.fireball, x, y, Mathf.random(360f)); + Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f)); } } diff --git a/core/src/io/anuke/mindustry/entities/effect/Lightning.java b/core/src/io/anuke/mindustry/entities/effect/Lightning.java index a26ce41eea..7ee5e771af 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Lightning.java +++ b/core/src/io/anuke/mindustry/entities/effect/Lightning.java @@ -19,7 +19,7 @@ import io.anuke.arc.math.geom.Position; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.util.pooling.Pools; -import io.anuke.mindustry.content.bullets.TurretBullets; +import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.bullet.Bullet; @@ -72,7 +72,7 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time hit.clear(); for (int i = 0; i < length/2; i++) { - Bullet.create(TurretBullets.damageLightning, l, team, x, y, 0f, 1f, 1f, dmg); + Bullet.create(Bullets.damageLightning, l, team, x, y, 0f, 1f, 1f, dmg); l.lines.add(new Vector2(x + Mathf.range(3f), y + Mathf.range(3f))); rect.setSize(hitRange).setCenter(x, y); diff --git a/core/src/io/anuke/mindustry/entities/effect/Puddle.java b/core/src/io/anuke/mindustry/entities/effect/Puddle.java index d88fd53e9f..e134b9a069 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Puddle.java +++ b/core/src/io/anuke/mindustry/entities/effect/Puddle.java @@ -20,7 +20,7 @@ import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.content.Liquids; import io.anuke.mindustry.content.blocks.Blocks; -import io.anuke.mindustry.content.bullets.TurretBullets; +import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.content.fx.BlockFx; import io.anuke.mindustry.content.fx.EnvironmentFx; import io.anuke.mindustry.entities.Units; @@ -130,7 +130,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai (liquid.flammability > 0.3f && dest.temperature > 0.7f)){ //flammable liquid + hot liquid Fire.create(tile); if(Mathf.chance(0.006 * amount)){ - Call.createBullet(TurretBullets.fireball, x, y, Mathf.random(360f)); + Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f)); } }else if(dest.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle if(Mathf.chance(0.5f * amount)){ diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java index f702e0a5b3..7b806c0150 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/PowerTurret.java @@ -6,6 +6,7 @@ import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; public abstract class PowerTurret extends CooledTurret{ + //TODO recode this class, satisfaction must be 100%! /** The percentage of power which will be used per shot. */ protected float powerUsed = 0.5f; protected BulletType shootType; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java index 13a15f3cad..8339a7c1bd 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java @@ -15,7 +15,8 @@ import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; -import io.anuke.mindustry.content.bullets.TurretBullets; +import io.anuke.mindustry.content.Bullets; +import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.content.fx.BlockFx; import io.anuke.mindustry.content.fx.EnvironmentFx; import io.anuke.mindustry.content.fx.ShootFx; @@ -98,7 +99,7 @@ public class MassDriver extends Block{ float angle = tile.angleTo(target); other.isRecieving = true; - Bullet.create(TurretBullets.driverBolt, entity, entity.getTeam(), + Bullet.create(Bullets.driverBolt, entity, entity.getTeam(), tile.drawx() + Angles.trnsx(angle, driver.translation), tile.drawy() + Angles.trnsy(angle, driver.translation), angle, 1f, 1f, data);