From 4813d6c8ffdfa3b71743d35d00bd5a5b222ba6d1 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 21 Mar 2020 14:29:00 -0400 Subject: [PATCH] More reasonable AI behavior --- .../src/main/resources/classids.properties | 3 ++- core/src/mindustry/ai/types/FlyingAI.java | 4 ++-- core/src/mindustry/content/UnitTypes.java | 24 +++++++++++++++++-- .../mindustry/entities/bullet/BulletType.java | 2 +- core/src/mindustry/entities/def/UnitComp.java | 4 ++-- core/src/mindustry/type/UnitType.java | 4 ++-- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/annotations/src/main/resources/classids.properties b/annotations/src/main/resources/classids.properties index 87a75e0f14..ed82e2bef1 100644 --- a/annotations/src/main/resources/classids.properties +++ b/annotations/src/main/resources/classids.properties @@ -13,4 +13,5 @@ mindustry.entities.def.TileComp=8 mindustry.type.Weather.WeatherComp=13 phantom=11 spirit=12 -vanguard=9 \ No newline at end of file +vanguard=9 +wraith=14 \ No newline at end of file diff --git a/core/src/mindustry/ai/types/FlyingAI.java b/core/src/mindustry/ai/types/FlyingAI.java index dd9530254b..e64443bf8d 100644 --- a/core/src/mindustry/ai/types/FlyingAI.java +++ b/core/src/mindustry/ai/types/FlyingAI.java @@ -28,7 +28,7 @@ public class FlyingAI extends AIController{ boolean shoot = false; if(target != null){ - attack(40f); + attack(80f); shoot = unit.inRange(target); @@ -88,7 +88,7 @@ public class FlyingAI extends AIController{ if(diff > 100f && vec.len() < circleLength){ vec.setAngle(unit.vel().angle()); }else{ - vec.setAngle(Mathf.slerpDelta(unit.vel().angle(), vec.angle(), 0.44f)); + vec.setAngle(Mathf.slerpDelta(unit.vel().angle(), vec.angle(), 0.6f)); } vec.setLength(unit.type().speed * Time.delta()); diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 58c82161f1..aa4d912849 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -9,12 +9,13 @@ import mindustry.type.*; public class UnitTypes implements ContentList{ //TODO reimplement public static UnitType - wraith, ghoul, revenant, lich, reaper, + ghoul, revenant, lich, reaper, crawler, titan, fortress, eruptor, chaosArray, eradicator; public static @EntityDef({Unitc.class, Legsc.class}) UnitType dagger; public static @EntityDef({Unitc.class, WaterMovec.class}) UnitType vanguard; public static @EntityDef({Unitc.class, Minerc.class}) UnitType draug; + public static @EntityDef({Unitc.class}) UnitType wraith; public static @EntityDef({Unitc.class}) UnitType spirit; public static @EntityDef({Unitc.class, Builderc.class}) UnitType phantom; @@ -27,7 +28,7 @@ public class UnitTypes implements ContentList{ public void load(){ dagger = new UnitType("dagger"){{ - speed = 1f; + speed = 0.5f; drag = 0.3f; hitsize = 8f; mass = 1.75f; @@ -41,6 +42,25 @@ public class UnitTypes implements ContentList{ }}); }}; + wraith = new UnitType("wraith"){{ + speed = 3f; + accel = 0.08f; + drag = 0f; + mass = 1.5f; + flying = true; + health = 75; + engineOffset = 5.5f; + range = 140f; + weapons.add(new Weapon(){{ + y = 1.5f; + reload = 28f; + alternate = true; + ejectEffect = Fx.shellEjectSmall; + bullet = Bullets.standardCopper; + shootSound = Sounds.shoot; + }}); + }}; + vanguard = new UnitType("vanguard"){{ speed = 1.3f; drag = 0.1f; diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 0f97ff686c..ce73e2c81f 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -211,7 +211,7 @@ public abstract class BulletType extends Content{ bullet.damage(damage < 0 ? this.damage : damage); bullet.add(); - //if(keepVelocity && owner instanceof Velc) bullet.vel().add(((Velc)owner).vel()); + if(keepVelocity && owner instanceof Velc) bullet.vel().add(((Velc)owner).vel()); return bullet; } diff --git a/core/src/mindustry/entities/def/UnitComp.java b/core/src/mindustry/entities/def/UnitComp.java index 39e96c4369..1a8a3d12a4 100644 --- a/core/src/mindustry/entities/def/UnitComp.java +++ b/core/src/mindustry/entities/def/UnitComp.java @@ -79,8 +79,8 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox Vec2 v = Geometry.overlap(Tmp.r1, Tmp.r2, true); float tm = mass() + unit.mass(); float s1 = mass() / tm, s2 = unit.mass() / tm; - move(v.x*s2/scale, v.y*s2/scale); - unit.move(-v.x*s1/scale, -v.y*s1/scale); + impulse(v.x*s2/scale, v.y*s2/scale); + unit.impulse(-v.x*s1/scale, -v.y*s1/scale); } @Override diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index f3c5dcf50b..4cf01c7307 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -28,8 +28,8 @@ public class UnitType extends UnlockableContent{ public boolean flying; public @NonNull Prov constructor; public @NonNull Prov defaultController = () -> !flying ? new GroundAI() : new FlyingAI(); - public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 6f, baseRotateSpeed = 10f; - public float drag = 0.3f, mass = 1f, accel = 0.9f; + public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 5f, baseRotateSpeed = 5f; + public float drag = 0.3f, mass = 1f, accel = 0.5f; public float health = 200f, range = -1; public boolean targetAir = true, targetGround = true; public boolean faceTarget = true, isCounted = true;