mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 16:36:36 +00:00
bufix: NPC is targeted at the same time it allies with targeter, causing it to try to attack itself
This commit is contained in:
@@ -55,6 +55,10 @@ export class AttackExecution implements Execution {
|
||||
this._owner = mg.player(this._ownerID)
|
||||
this.target = this._targetID == this.mg.terraNullius().id() ? mg.terraNullius() : mg.player(this._targetID)
|
||||
|
||||
if (this._owner == this.target) {
|
||||
throw new Error(`Player ${this._owner} cannot attack itself`)
|
||||
}
|
||||
|
||||
if (this.troops == null) {
|
||||
this.troops = this.mg.config().attackAmount(this._owner, this.target)
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ export class FakeHumanExecution implements Execution {
|
||||
.filter(ally => ally.targets().length > 0)
|
||||
.map(ally => ({ ally: ally, t: ally.targets()[0] }))[0] ?? null
|
||||
|
||||
if (target != null && !this.player.isAlliedWith(target.t)) {
|
||||
if (target != null && target.t != this.player && !this.player.isAlliedWith(target.t)) {
|
||||
this.player.updateRelation(target.ally, -20)
|
||||
this.enemy = target.t
|
||||
this.lastEnemyUpdateTick = this.mg.ticks()
|
||||
|
||||
Reference in New Issue
Block a user