From 9bf3074aee2dc91a25aed5090242e0e3c9b23d7f Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 29 Jul 2020 21:09:58 -0400 Subject: [PATCH] AI bugfixes / Balance --- core/src/mindustry/ai/types/FlyingAI.java | 7 ++- core/src/mindustry/content/Bullets.java | 47 +------------------ core/src/mindustry/content/UnitTypes.java | 12 ++++- .../entities/bullet/BombBulletType.java | 4 ++ .../mindustry/entities/bullet/BulletType.java | 15 ++++++ .../mindustry/entities/comp/WeaponsComp.java | 4 +- core/src/mindustry/type/Weapon.java | 2 + 7 files changed, 42 insertions(+), 49 deletions(-) diff --git a/core/src/mindustry/ai/types/FlyingAI.java b/core/src/mindustry/ai/types/FlyingAI.java index e71de21f7e..80d712573a 100644 --- a/core/src/mindustry/ai/types/FlyingAI.java +++ b/core/src/mindustry/ai/types/FlyingAI.java @@ -33,7 +33,12 @@ public class FlyingAI extends AIController{ boolean shoot = false; if(target != null && unit.hasWeapons()){ - attack(80f); + if(unit.type().weapons.first().rotate){ + moveTo(unit.range() * 0.85f); + unit.lookAt(target); + }else{ + attack(80f); + } shoot = unit.inRange(target); diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index 6a002dd42a..40a8a545de 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -37,10 +37,7 @@ public class Bullets implements ContentList{ waterShot, cryoShot, slagShot, oilShot, //environment, misc. - damageLightning, damageLightningGround, fireball, basicFlame, pyraFlame, driverBolt, healBullet, healBulletBig, frag, - - //bombs - bombExplosive, bombIncendiary, bombOil; + damageLightning, damageLightningGround, fireball, basicFlame, pyraFlame, driverBolt, healBullet, healBulletBig, frag; @Override public void load(){ @@ -495,47 +492,5 @@ public class Bullets implements ContentList{ lifetime = 50f; drag = 0.04f; }}; - - bombExplosive = new BombBulletType(18f, 25f, "shell"){{ - width = 10f; - height = 14f; - hitEffect = Fx.flakExplosion; - shootEffect = Fx.none; - smokeEffect = Fx.none; - - status = StatusEffects.blasted; - statusDuration = 60f; - }}; - - bombIncendiary = new BombBulletType(7f, 10f, "shell"){{ - width = 8f; - height = 12f; - hitEffect = Fx.flakExplosion; - backColor = Pal.lightOrange; - frontColor = Pal.lightishOrange; - incendChance = 1f; - incendAmount = 3; - incendSpread = 10f; - }}; - - bombOil = new BombBulletType(2f, 3f, "shell"){ - { - width = 8f; - height = 12f; - hitEffect = Fx.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)); - Puddles.deposit(tile, Liquids.oil, 5f); - } - } - }; } } diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 1bcec0fdd9..cae6808fd6 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -460,6 +460,7 @@ public class UnitTypes implements ContentList{ armor = 2f; weapons.add(new Weapon(){{ + minShootVelocity = 0.75f; x = 3f; shootY = 0f; reload = 12f; @@ -467,8 +468,17 @@ public class UnitTypes implements ContentList{ ejectEffect = Fx.none; inaccuracy = 15f; ignoreRotation = true; - bullet = Bullets.bombExplosive; shootSound = Sounds.none; + bullet = new BombBulletType(23f, 25f){{ + width = 10f; + height = 14f; + hitEffect = Fx.flakExplosion; + shootEffect = Fx.none; + smokeEffect = Fx.none; + + status = StatusEffects.blasted; + statusDuration = 60f; + }}; }}); }}; diff --git a/core/src/mindustry/entities/bullet/BombBulletType.java b/core/src/mindustry/entities/bullet/BombBulletType.java index 4dd18a7750..acd18a8064 100644 --- a/core/src/mindustry/entities/bullet/BombBulletType.java +++ b/core/src/mindustry/entities/bullet/BombBulletType.java @@ -18,6 +18,10 @@ public class BombBulletType extends BasicBulletType{ hitSound = Sounds.explosion; } + public BombBulletType(float damage, float radius){ + this(damage, radius, "shell"); + } + public BombBulletType(){ this(1f, 1f, "shell"); } diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 5977a9ed22..2d23d9eb4b 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -13,6 +13,9 @@ import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; +import mindustry.world.*; + +import static mindustry.Vars.*; public abstract class BulletType extends Content{ public float lifetime = 40f; @@ -98,6 +101,11 @@ public abstract class BulletType extends Content{ public float weaveMag = -1f; public float hitShake = 0f; + public int puddles; + public float puddleRange; + public float puddleAmount = 5f; + public Liquid puddleLiquid = Liquids.water; + public float lightRadius = 16f; public float lightOpacity = 0.3f; public Color lightColor = Pal.powerLight; @@ -144,6 +152,13 @@ public abstract class BulletType extends Content{ } } + if(puddleLiquid != null && puddles > 0){ + for(int i = 0; i < puddles; i++){ + Tile tile = world.tileWorld(x + Mathf.range(puddleRange), y + Mathf.range(puddleRange)); + Puddles.deposit(tile, puddleLiquid, puddleAmount); + } + } + if(Mathf.chance(incendChance)){ Damage.createIncend(x, y, incendSpread, incendAmount); } diff --git a/core/src/mindustry/entities/comp/WeaponsComp.java b/core/src/mindustry/entities/comp/WeaponsComp.java index b05800d702..661346188f 100644 --- a/core/src/mindustry/entities/comp/WeaponsComp.java +++ b/core/src/mindustry/entities/comp/WeaponsComp.java @@ -13,8 +13,9 @@ import mindustry.type.*; import static mindustry.Vars.*; @Component -abstract class WeaponsComp implements Teamc, Posc, Rotc{ +abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{ @Import float x, y, rotation, reloadMultiplier; + @Import Vec2 vel; /** minimum cursor distance from unit, fixes 'cross-eyed' shooting */ static final float minAimDst = 18f; @@ -111,6 +112,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{ if(mount.shoot && //must be shooting (ammo > 0 || !state.rules.unitAmmo || team().rules().infiniteAmmo) && //check ammo (!weapon.alternate || mount.side == weapon.flipSprite) && + vel.len() >= mount.weapon.minShootVelocity && //check velocity requirements mount.reload <= 0.0001f && //reload has to be 0 Angles.within(weapon.rotate ? mount.rotation : this.rotation, mount.targetRotation, mount.weapon.shootCone) //has to be within the cone ){ diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 744011df74..b83478cd24 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -53,6 +53,8 @@ public class Weapon{ public float shootCone = 5f; /** whether shooter rotation is ignored when shooting. */ public boolean ignoreRotation = false; + /** min velocity required for this weapon to shoot */ + public float minShootVelocity = -1f; /** internal value used for alternation - do not change! */ public int otherSide = -1; /** sound used for shooting */