mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-13 13:44:36 +00:00
fix: Make bots not attack teammates (#368)
Bug report: https://discord.com/channels/1284581928254701718/1355194642592694412 ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [X] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: PilkeySEK
This commit is contained in:
@@ -98,6 +98,7 @@ export class BotExecution implements Execution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendAttack(toAttack: Player | TerraNullius) {
|
sendAttack(toAttack: Player | TerraNullius) {
|
||||||
|
if (toAttack.isPlayer() && this.bot.isOnSameTeam(toAttack)) return;
|
||||||
this.mg.addExecution(
|
this.mg.addExecution(
|
||||||
new AttackExecution(
|
new AttackExecution(
|
||||||
this.bot.troops() / 20,
|
this.bot.troops() / 20,
|
||||||
|
|||||||
@@ -192,6 +192,9 @@ export class FakeHumanExecution implements Execution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private shouldAttack(other: Player): boolean {
|
private shouldAttack(other: Player): boolean {
|
||||||
|
if (this.player.isOnSameTeam(other)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (this.player.isFriendly(other)) {
|
if (this.player.isFriendly(other)) {
|
||||||
if (this.shouldDiscourageAttack(other)) {
|
if (this.shouldDiscourageAttack(other)) {
|
||||||
return this.random.chance(200);
|
return this.random.chance(200);
|
||||||
@@ -290,7 +293,8 @@ export class FakeHumanExecution implements Execution {
|
|||||||
if (
|
if (
|
||||||
this.player.units(UnitType.MissileSilo).length == 0 ||
|
this.player.units(UnitType.MissileSilo).length == 0 ||
|
||||||
this.player.gold() <
|
this.player.gold() <
|
||||||
this.mg.config().unitInfo(UnitType.AtomBomb).cost(this.player)
|
this.mg.config().unitInfo(UnitType.AtomBomb).cost(this.player) ||
|
||||||
|
this.player.isOnSameTeam(other)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -315,6 +319,7 @@ export class FakeHumanExecution implements Execution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private maybeSendBoatAttack(other: Player) {
|
private maybeSendBoatAttack(other: Player) {
|
||||||
|
if (this.player.isOnSameTeam(other)) return;
|
||||||
const closest = closestTwoTiles(
|
const closest = closestTwoTiles(
|
||||||
this.mg,
|
this.mg,
|
||||||
Array.from(this.player.borderTiles()).filter((t) =>
|
Array.from(this.player.borderTiles()).filter((t) =>
|
||||||
@@ -580,6 +585,7 @@ export class FakeHumanExecution implements Execution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendAttack(toAttack: Player | TerraNullius) {
|
sendAttack(toAttack: Player | TerraNullius) {
|
||||||
|
if (toAttack.isPlayer() && this.player.isOnSameTeam(toAttack)) return;
|
||||||
this.mg.addExecution(
|
this.mg.addExecution(
|
||||||
new AttackExecution(
|
new AttackExecution(
|
||||||
this.player.troops() / 5,
|
this.player.troops() / 5,
|
||||||
|
|||||||
Reference in New Issue
Block a user