diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index 4509ef94b4..4364ad831d 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -78,11 +78,15 @@ public class CommandAI extends AIController{ float engageRange = unit.type.range - 10f; if(move){ - moveTo(vecOut, - attackTarget != null && unit.within(attackTarget, engageRange) ? engageRange : - unit.isGrounded() ? 0f : - attackTarget != null ? engageRange : - 0f, unit.isFlying() ? 40f : 100f, false, null); + if(unit.type.circleTarget && attackTarget != null){ + circleAttack(80f); + }else{ + moveTo(vecOut, + attackTarget != null && unit.within(attackTarget, engageRange) ? engageRange : + unit.isGrounded() ? 0f : + attackTarget != null ? engageRange : + 0f, unit.isFlying() ? 40f : 100f, false, null); + } //calculateFlock().limit(unit.speed() * flockMult) } diff --git a/core/src/mindustry/ai/types/FlyingAI.java b/core/src/mindustry/ai/types/FlyingAI.java index bb4f3de78d..a938b5d3b6 100644 --- a/core/src/mindustry/ai/types/FlyingAI.java +++ b/core/src/mindustry/ai/types/FlyingAI.java @@ -15,11 +15,11 @@ public class FlyingAI extends AIController{ unloadPayloads(); if(target != null && unit.hasWeapons()){ - if(!unit.type.circleTarget){ + if(unit.type.circleTarget){ + circleAttack(120f); + }else{ moveTo(target, unit.type.range * 0.8f); unit.lookAt(target); - }else{ - attack(120f); } } @@ -56,21 +56,4 @@ public class FlyingAI extends AIController{ return core; } - - protected void attack(float circleLength){ - vec.set(target).sub(unit); - - float ang = unit.angleTo(target); - float diff = Angles.angleDist(ang, unit.rotation()); - - if(diff > 70f && vec.len() < circleLength){ - vec.setAngle(unit.vel().angle()); - }else{ - vec.setAngle(Angles.moveToward(unit.vel().angle(), vec.angle(), 6f)); - } - - vec.setLength(unit.speed()); - - unit.moveAt(vec); - } } diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 64cf213316..7f01da776b 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -4190,22 +4190,23 @@ public class Blocks{ consumePower(2f); }}; - mechFabricator = new UnitFactory("mech-fabricator"){{ + shipFabricator = new UnitFactory("ship-fabricator"){{ requirements(Category.units, with(Items.silicon, 250, Items.beryllium, 200)); + size = 3; configurable = false; - plans.add(new UnitPlan(UnitTypes.merui, 60f * 45f, with(Items.beryllium, 50f, Items.silicon, 70f))); + plans.add(new UnitPlan(UnitTypes.elude, 60f * 45f, with(Items.beryllium, 50f, Items.silicon, 70f))); regionSuffix = "-dark"; fogRadius = 3; researchCostMultiplier = 0.5f; consumePower(2f); }}; - shipFabricator = new UnitFactory("ship-fabricator"){{ + mechFabricator = new UnitFactory("mech-fabricator"){{ requirements(Category.units, with(Items.silicon, 200, Items.graphite, 300, Items.tungsten, 60)); size = 3; configurable = false; - plans.add(new UnitPlan(UnitTypes.elude, 60f * 40f, with(Items.graphite, 40f, Items.silicon, 70f))); + plans.add(new UnitPlan(UnitTypes.merui, 60f * 40f, with(Items.graphite, 40f, Items.silicon, 70f))); regionSuffix = "-dark"; fogRadius = 3; researchCostMultiplier = 0.65f; diff --git a/core/src/mindustry/content/ErekirTechTree.java b/core/src/mindustry/content/ErekirTechTree.java index c1978ebd3d..61aea6da74 100644 --- a/core/src/mindustry/content/ErekirTechTree.java +++ b/core/src/mindustry/content/ErekirTechTree.java @@ -283,13 +283,13 @@ public class ErekirTechTree{ }); - node(mechFabricator, Seq.with(new OnSector(two)), () -> { - node(UnitTypes.merui, () -> { + node(shipFabricator, Seq.with(new OnSector(two)), () -> { + node(UnitTypes.elude, () -> { }); - node(shipFabricator, Seq.with(new OnSector(three)), () -> { - node(UnitTypes.elude, () -> { + node(mechFabricator, Seq.with(new OnSector(three)), () -> { + node(UnitTypes.merui, () -> { }); diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index 6966f9c17e..c450ea6e27 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -234,6 +234,23 @@ public class AIController implements UnitController{ } } + public void circleAttack(float circleLength){ + vec.set(target).sub(unit); + + float ang = unit.angleTo(target); + float diff = Angles.angleDist(ang, unit.rotation()); + + if(diff > 70f && vec.len() < circleLength){ + vec.setAngle(unit.vel().angle()); + }else{ + vec.setAngle(Angles.moveToward(unit.vel().angle(), vec.angle(), 6f)); + } + + vec.setLength(unit.speed()); + + unit.moveAt(vec); + } + public void circle(Position target, float circleLength){ circle(target, circleLength, unit.speed()); } diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index 93790fbeee..286b7880fa 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -57,7 +57,7 @@ public class Weather extends UnlockableContent{ public WeatherState create(float intensity, float duration){ WeatherState entity = type.get(); - entity.intensity(intensity); + entity.intensity(Mathf.clamp(intensity)); entity.init(this); entity.life(duration); entity.add();