From fe9cc4a150db112cb81f831750ce49b221d419c4 Mon Sep 17 00:00:00 2001 From: elexis Date: Fri, 11 Aug 2017 17:05:32 +0000 Subject: [PATCH] Don't spawn Danubius attackers (indefinitely) at the Gaia Civic Center if all targeted player buildings on that riverside were destroyed or captured by gaia. Differential Revision: https://code.wildfiregames.com/D777 Fixes #4715 Reviewed By: bb This was SVN commit r19972. --- .../public/maps/random/danubius_triggers.js | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/binaries/data/mods/public/maps/random/danubius_triggers.js b/binaries/data/mods/public/maps/random/danubius_triggers.js index 41c0f5fa57..471d2af6ad 100644 --- a/binaries/data/mods/public/maps/random/danubius_triggers.js +++ b/binaries/data/mods/public/maps/random/danubius_triggers.js @@ -301,8 +301,14 @@ Trigger.prototype.SpawnCCAttackers = function() let time = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetTime() / 60 / 1000; let mapSize = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain).GetMapSize(); + let [spawnLeft, spawnRight] = this.GetActiveRiversides(); + for (let gaiaCC of this.civicCenters) { + let isLeft = Engine.QueryInterface(gaiaCC, IID_Position).GetPosition2D().x < mapSize / 2; + if (isLeft && !spawnLeft || !isLeft && !spawnRight) + continue; + let toSpawn = this.GetAttackerComposition(ccAttackerCount(time), false); this.debugLog("Spawning civic center attackers at " + gaiaCC + ": " + uneval(toSpawn)); @@ -318,7 +324,7 @@ Trigger.prototype.SpawnCCAttackers = function() ccAttackers = ccAttackers.concat(ents); } - let patrolPointRef = Engine.QueryInterface(gaiaCC, IID_Position).GetPosition2D().x < mapSize / 2 ? + let patrolPointRef = isLeft ? triggerPointCCAttackerPatrolLeft : triggerPointCCAttackerPatrolRight; @@ -535,33 +541,41 @@ Trigger.prototype.AttackAndPatrol = function(attackers, targetClass, triggerPoin }; /** - * Order all ships to abort naval warfare and move to the shoreline all few minutes. + * To avoid unloading unlimited amounts of units on empty riversides, + * only add attackers to riversides where player buildings exist that are + * actually targeted. */ -Trigger.prototype.UngarrisonShipsOrder = function() +Trigger.prototype.GetActiveRiversides = function() { - // To avoid unloading unlimited amounts of units on empty riversides, - // only ungarrison on riversides where player buildings exist - - let ungarrisonLeft = false; - let ungarrisonRight = false; - let mapSize = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain).GetMapSize(); + let left = false; + let right = false; + for (let ent of Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetNonGaiaEntities()) { let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); - if (!cmpIdentity || !cmpIdentity.HasClass("Structure")) + if (!cmpIdentity || !cmpIdentity.HasClass(siegeTargetClass)) continue; if (Engine.QueryInterface(ent, IID_Position).GetPosition2D().x < mapSize / 2) - ungarrisonLeft = true; + left = true; else - ungarrisonRight = true; + right = true; - if (ungarrisonLeft && ungarrisonRight) + if (left && right) break; } + return [left, right]; +}; + +/** + * Order all ships to abort naval warfare and move to the shoreline all few minutes. + */ +Trigger.prototype.UngarrisonShipsOrder = function() +{ + let [ungarrisonLeft, ungarrisonRight] = this.GetActiveRiversides(); if (!ungarrisonLeft && !ungarrisonRight) return;