Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/drone-remaster' into drone-remaster
Browse files Browse the repository at this point in the history
  • Loading branch information
stabu-dev committed Oct 20, 2024
2 parents a5b22b2 + a8b11b4 commit 68bc1e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/omaloon/ai/drone/AttackDroneAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public void updateMovement() {
float distanceToOwner = unit.dst(owner);

if (distanceToOwner < owner.range()) {
moveTo(posTeam, unit.type().range * 0.75f);
moveTo(posTeam, unit.type().range * 0.75f, 30f);
} else {
moveTo(owner, owner.range() * 0.95f);
moveTo(owner, owner.range() * 0.95f, 30f);
if (distanceToTarget > unit.type().range) {
unit.lookAt(posTeam);
unit.controlWeapons(true, true);
Expand Down
29 changes: 18 additions & 11 deletions src/omaloon/ai/drone/UtilityDroneAI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package omaloon.ai.drone;

import arc.util.*;
import mindustry.content.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.world.*;
import omaloon.ai.*;

public class UtilityDroneAI extends DroneAI {
Expand All @@ -15,15 +18,17 @@ public UtilityDroneAI(Unit owner) {
@Override
public void updateMovement() {
if (owner.activelyBuilding()) {
Tmp.v1.set(owner.buildPlan().drawx(), owner.buildPlan().drawy());
moveTo(Tmp.v1, unit.type.buildRange * buildRangeScl);
if (unit.dst(Tmp.v1) <= unit.type.buildRange && !unit.plans.contains(owner.buildPlan())) unit.plans.add(owner.buildPlan());
BuildPlan plan = owner.buildPlan();
Tile tile = plan.tile();
Tmp.v1.set(plan.drawx(), plan.drawy());
moveTo(Tmp.v1, unit.type.buildRange * buildRangeScl, 30f);
if (unit.dst(Tmp.v1) <= unit.type.buildRange && !unit.plans.contains(plan)) unit.plans.add(plan);
if (
unit.dst(Tmp.v1) <= unit.type.buildRange && (
(!owner.buildPlan().breaking && owner.buildPlan().progress >= 1f) ||
(owner.buildPlan().breaking && owner.buildPlan().progress <= 0f)
)
) owner.plans.removeFirst();
!(tile != null && (!plan.breaking || tile.block() != Blocks.air) && (plan.breaking || (tile.build == null || tile.build.rotation != plan.rotation) && plan.block.rotate || tile.block() != plan.block && (plan.block == null || (!plan.block.isOverlay() || plan.block != tile.overlay()) && (!plan.block.isFloor() || plan.block != tile.floor()))))
) {
owner.plans.remove(plan);
unit.plans.remove(plan);
}
} else {
unit.plans.clear();
if (
Expand All @@ -34,20 +39,22 @@ public void updateMovement() {
) {
Tmp.v1.set(owner.mineTile.worldx(), owner.mineTile.worldy());
if (unit.dst(Tmp.v1) <= unit.type.mineRange) unit.mineTile = owner.mineTile;
moveTo(Tmp.v1, unit.type.mineRange * mineRangeScl);
moveTo(Tmp.v1, unit.type.mineRange * mineRangeScl, 30f);
} else {
unit.mineTile = null;
rally();
}
}

if (unit.stack.amount > 0) {
if (!unit.within(unit.closestCore(), unit.type.range)) {
if (!unit.within(unit.closestCore(), owner.type.range)) {
for(int i = 0; i < unit.stack.amount; i++) {
Call.transferItemToUnit(unit.stack.item, unit.x, unit.y, owner);
}
unit.clearItem();
} else {
Call.transferItemTo(unit, unit.stack.item, unit.stack.amount, unit.x, unit.y, unit.closestCore());
}
unit.clearItem();
}
}
}

0 comments on commit 68bc1e7

Please sign in to comment.