Index: binaries/data/mods/public/maps/scripts/CaptureTheRelic.js =================================================================== --- binaries/data/mods/public/maps/scripts/CaptureTheRelic.js +++ binaries/data/mods/public/maps/scripts/CaptureTheRelic.js @@ -50,7 +50,7 @@ /** * Check if an individual player or team has acquired all relics. * Also check if the countdown needs to be stopped if a player/team no longer has all relics. - * Reset the countdown if any of the original allies tries to change their diplomacy with one of these allies. + * Reset the countdown if the group of the original allies changes. */ Trigger.prototype.CheckCaptureTheRelicCountdown = function(data) { @@ -58,20 +58,35 @@ for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID) { + if (!this.playerRelicsCount[playerID]) + continue; + + let relicOwners = []; let playerAndAllies = cmpEndGameManager.GetAlliedVictory() ? QueryPlayerIDInterface(playerID).GetMutualAllies() : [playerID]; let teamRelicsOwned = 0; for (let ally of playerAndAllies) + { teamRelicsOwned += this.playerRelicsCount[ally]; + if (this.playerRelicsCount[ally]) + relicOwners.push(ally); + } if (teamRelicsOwned == this.relics.length) { - if (!data || - !this.relicsVictoryCountdownPlayers.length || - this.relicsVictoryCountdownPlayers.indexOf(data.player) != -1 && - this.relicsVictoryCountdownPlayers.indexOf(data.otherPlayer) != -1) + // Filter all players mutually allied to all relicOwners + for (let owner of relicOwners) + playerAndAllies.filter(ally => QueryPlayerIDInterface(owner).GetMutualAllies().indexOf(ally) != -1) + + // All relicOwners should be mutally allied + if (relicOwners.some(owner => playerAndAllies.indexOf(owner) == -1)) + this.DeleteCaptureTheRelicVictoryMessages(); + + // When playerAndAllies isn't the same as this.relicsVictoryCountdownPlayers then reset the timer + else if (playerAndAllies.some(ally => this.relicsVictoryCountdownPlayers.indexOf(ally) == -1) || + this.relicsVictoryCountdownPlayers.some(ally => playerAndAllies.indexOf(ally) == -1)) { this.relicsVictoryCountdownPlayers = playerAndAllies; this.StartCaptureTheRelicCountdown(playerAndAllies);