From 6ec28be541bb4dabd2a77bb1e2862bc5e41bd3e4 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 24 Jun 2018 21:17:48 -0400 Subject: [PATCH] Implemented homing silicon bullets --- .../io/anuke/mindustry/content/AmmoTypes.java | 3 ++- .../mindustry/content/blocks/TurretBlocks.java | 3 ++- .../content/bullets/StandardBullets.java | 18 ++++++++++++++++-- .../io/anuke/mindustry/entities/Player.java | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/src/io/anuke/mindustry/content/AmmoTypes.java b/core/src/io/anuke/mindustry/content/AmmoTypes.java index 2bdc9c1042..fb77362177 100644 --- a/core/src/io/anuke/mindustry/content/AmmoTypes.java +++ b/core/src/io/anuke/mindustry/content/AmmoTypes.java @@ -42,9 +42,10 @@ public class AmmoTypes implements ContentList { smokeEffect = ShootFx.shootSmallSmoke; }}; - bulletSilicon = new AmmoType(Items.silicon, StandardBullets.homing, 4) {{ + bulletSilicon = new AmmoType(Items.silicon, StandardBullets.homing, 5) {{ shootEffect = ShootFx.shootSmall; smokeEffect = ShootFx.shootSmallSmoke; + reloadMultiplier = 1.4f; }}; bulletThermite = new AmmoType(Items.thermite, StandardBullets.tracer, 3) {{ diff --git a/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java b/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java index e5817ebe39..74384e5fe9 100644 --- a/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java @@ -18,10 +18,11 @@ public class TurretBlocks extends BlockList implements ContentList { @Override public void load() { duo = new DoubleTurret("duo") {{ - ammoTypes = new AmmoType[]{AmmoTypes.bulletTungsten, AmmoTypes.bulletLead, AmmoTypes.bulletCarbide, AmmoTypes.bulletThermite}; + ammoTypes = new AmmoType[]{AmmoTypes.bulletTungsten, AmmoTypes.bulletLead, AmmoTypes.bulletCarbide, AmmoTypes.bulletThermite, AmmoTypes.bulletSilicon}; reload = 25f; restitution = 0.03f; range = 80f; + shootCone = 15f; ammoUseEffect = ShootFx.shellEjectSmall; }}; /* diff --git a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java b/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java index 21e8768167..0f58547d3d 100644 --- a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java @@ -1,8 +1,13 @@ package io.anuke.mindustry.content.bullets; +import io.anuke.mindustry.entities.Unit; +import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.bullet.BasicBulletType; +import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.bullet.BulletType; import io.anuke.mindustry.type.ContentList; +import io.anuke.ucore.core.Timers; +import io.anuke.ucore.util.Angles; public class StandardBullets extends BulletList implements ContentList { public static BulletType tungsten, lead, carbide, thorium, homing, tracer; @@ -32,7 +37,7 @@ public class StandardBullets extends BulletList implements ContentList { } }; - thorium = new BasicBulletType(4f, 25, "bullet") { + thorium = new BasicBulletType(4f, 29, "bullet") { { bulletWidth = 10f; bulletHeight = 13f; @@ -40,11 +45,20 @@ public class StandardBullets extends BulletList implements ContentList { } }; - homing = new BasicBulletType(3f, 5, "bullet") { + homing = new BasicBulletType(3f, 9, "bullet") { + float homingPower = 5f; { bulletWidth = 7f; bulletHeight = 9f; } + + @Override + public void update(Bullet b) { + Unit target = Units.getClosestEnemy(b.getTeam(), b.x, b.y, 40f, unit -> true); + if(target != null){ + b.getVelocity().setAngle(Angles.moveToward(b.getVelocity().angle(), b.angleTo(target), homingPower * Timers.delta())); + } + } }; tracer = new BasicBulletType(3f, 5, "bullet") { diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index a2a63a3212..b62d0a3d37 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -418,6 +418,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait { if(isDead()){ isBoosting = false; + boostHeat = 0f; CoreEntity entity = (CoreEntity)getClosestCore(); if (!respawning && entity != null) {