Skip to content

Commit

Permalink
Support version Beta 2.16b. Autoattack should now attack enemy planet…
Browse files Browse the repository at this point in the history
…s even if they are not scouted.
  • Loading branch information
coder111111 committed Mar 12, 2021
1 parent af0ceac commit a387218
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.rayfowler</groupId>

<version>2.16.2</version>
<version>2.16.3</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>8</java.version>
Expand Down
2 changes: 1 addition & 1 deletion src/rotp/RotpGovernor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* to get more memory it uses the right jar file name.
*/
public class RotpGovernor {
static String expectedROTPVersion = "Beta 2.16a";
static String expectedROTPVersion = "Beta 2.16b";

private static String governorVersion = null;

Expand Down
70 changes: 33 additions & 37 deletions src/rotp/model/empires/Empire.java
Original file line number Diff line number Diff line change
Expand Up @@ -1651,50 +1651,46 @@ public void autoattack() {
}
int sendCount = Math.max(1, GameSession.instance().getGovernorOptions().getAutoAttackShipCount());
List<Integer> targets = filterTargets(i -> {
// only consider scouted systems
if (sv.view(i).scouted()) {
boolean inRange;
if (extendedRange) {
inRange = sv.inScoutRange(i);
} else {
inRange = sv.inShipRange(i);
}
if (!inRange) {
return false;
}
List<ShipFleet> fleets = sv.orbitingFleets(i);
if (fleets != null) {
for (ShipFleet sf: fleets) {
if (sf.empire() == this && sf.isArmed()) {
// don't target planets which already have own armed fleets in orbit
return false;
}
// consider both scouted and unscouted systems if they belong to the enemy
boolean inRange;
if (extendedRange) {
inRange = sv.inScoutRange(i);
} else {
inRange = sv.inShipRange(i);
}
if (!inRange) {
return false;
}
List<ShipFleet> fleets = sv.orbitingFleets(i);
if (fleets != null) {
for (ShipFleet sf: fleets) {
if (sf.empire() == this && sf.isArmed()) {
// don't target planets which already have own armed fleets in orbit
return false;
}
}
// armed ships already on route- no need to send more
for (ShipFleet sf: this.ownFleetsTargetingSystem(sv.system(i))) {
for (ShipDesign sd: designs) {
// attack fleet already on its way, don't send more
if (sf.num(sd.id()) >= sendCount) {
return false;
}
}
// armed ships already on route- no need to send more
for (ShipFleet sf: this.ownFleetsTargetingSystem(sv.system(i))) {
for (ShipDesign sd: designs) {
// attack fleet already on its way, don't send more
if (sf.num(sd.id()) >= sendCount) {
return false;
}
}
if (sv.empire(i) != null && hostileEmpires.contains(sv.empire(i).id)) {
System.out.println("System "+sv.name(i)+" belongs to enemy empire, targeting");
}
if (sv.empire(i) != null && hostileEmpires.contains(sv.empire(i).id)) {
System.out.println("System "+sv.name(i)+" belongs to enemy empire, targeting");
return true;
}
// This will send ships to own colonies that have enemy ships in orbit. I guess that's OK
for (ShipFleet f: fleets) {
if (hostileEmpires.contains(f.empId) && !f.retreating()) {
System.out.println("System "+sv.name(i)+" has enemy ships, targeting");
return true;
}
// This will send ships to own colonies that have enemy ships in order. I guess that's OK
for (ShipFleet f: fleets) {
if (hostileEmpires.contains(f.empId) && !f.retreating()) {
System.out.println("System "+sv.name(i)+" has enemy ships, targeting");
return true;
}
}
return false;
} else {
return false;
}
return false;
});

// No systems to colonize
Expand Down

0 comments on commit a387218

Please sign in to comment.