bufix: NPC is targeted at the same time it allies with targeter, causing it to try to attack itself

This commit is contained in:
Evan
2025-01-05 20:04:55 -08:00
parent 81d849dec1
commit 5e0367ae55
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -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)
}
+1 -1
View File
@@ -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()