From 6740b60af2de11067b1509c101cf8613e63444cb Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 6 May 2022 23:33:22 -0400 Subject: [PATCH] Misc bugfixes, AI hit retaliation --- core/src/mindustry/ai/types/CommandAI.java | 7 +++++++ core/src/mindustry/content/UnitTypes.java | 8 +------- core/src/mindustry/entities/comp/UnitComp.java | 7 +++++++ core/src/mindustry/entities/units/UnitController.java | 4 ++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index 216370ae82..4509ef94b4 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -122,6 +122,13 @@ public class CommandAI extends AIController{ } } + @Override + public void hit(Bullet bullet){ + if(unit.team.isAI() && bullet.owner instanceof Teamc teamc && teamc.team() != unit.team && attackTarget == null){ + commandTarget(teamc, true); + } + } + public static float cohesionScl = 0.3f; public static float cohesionRad = 3f, separationRad = 1.1f, separationScl = 1f, flockMult = 0.5f; diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 5f3b05e762..f2b381ef7c 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -39,7 +39,7 @@ public class UnitTypes{ //legs public static @EntityDef({Unitc.class, Legsc.class}) UnitType corvus, atrax, merui, cleroi, anthicus, - tecta, collaris; //TODO horrid name here + tecta, collaris; //legs, legacy public static @EntityDef(value = {Unitc.class, Legsc.class}, legacy = true) UnitType spiroct, arkyid, toxopid; @@ -2523,7 +2523,6 @@ public class UnitTypes{ spread = 3.5f; }}; - //TODO make this look nicer bullet = new RailBulletType(){{ length = 160f; damage = 48f; @@ -2699,7 +2698,6 @@ public class UnitTypes{ fragBullets = 5; fragVelocityMin = 1f; - //TODO fragBullet = new BasicBulletType(8f, 25){{ sprite = "missile-large"; width = 8f; @@ -3324,7 +3322,6 @@ public class UnitTypes{ weaveMag = 4; weaveScale = 4; lifetime = 55f; - //TODO better shootEffect = Fx.shootBig2; smokeEffect = Fx.shootSmokeTitan; splashDamage = 60f; @@ -3454,7 +3451,6 @@ public class UnitTypes{ despawnEffect = Fx.none; - //TODO diff effect hitEffect = despawnEffect = new ExplosionEffect(){{ lifetime = 30f; waveStroke = 2f; @@ -3571,7 +3567,6 @@ public class UnitTypes{ mirror = false; shoot = new ShootHelix(); - //TODO cooler + balancing bullet = new BasicBulletType(5f, 34){{ width = 7f; height = 12f; @@ -3946,7 +3941,6 @@ public class UnitTypes{ float coreFleeRange = 500f; - //TODO bad name evoke = new ErekirUnitType("evoke"){{ coreUnitDock = true; controller = u -> new BuilderAI(true, coreFleeRange); diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index f8709e2749..485cb5ea10 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -263,6 +263,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I return hittable(); } + @Override + public void collision(Hitboxc other, float x, float y){ + if(other instanceof Bullet bullet){ + controller.hit(bullet); + } + } + @Override public int itemCapacity(){ return type.itemCapacity; diff --git a/core/src/mindustry/entities/units/UnitController.java b/core/src/mindustry/entities/units/UnitController.java index 7df6e0f02d..bbba6122b9 100644 --- a/core/src/mindustry/entities/units/UnitController.java +++ b/core/src/mindustry/entities/units/UnitController.java @@ -6,6 +6,10 @@ public interface UnitController{ void unit(Unit unit); Unit unit(); + default void hit(Bullet bullet){ + + } + default boolean isValidController(){ return true; }