Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/danubius_triggers.js
Show First 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | Trigger.prototype.SpawnInitialCCDefenders = function(gaiaEnts) | ||||
} | } | ||||
}; | }; | ||||
Trigger.prototype.SpawnCCAttackers = function() | Trigger.prototype.SpawnCCAttackers = function() | ||||
{ | { | ||||
let time = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetTime() / 60 / 1000; | let time = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetTime() / 60 / 1000; | ||||
let mapSize = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain).GetMapSize(); | let mapSize = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain).GetMapSize(); | ||||
let [spawnLeft, spawnRight] = this.GetActiveRiversides(); | |||||
for (let gaiaCC of this.civicCenters) | 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); | let toSpawn = this.GetAttackerComposition(ccAttackerCount(time), false); | ||||
this.debugLog("Spawning civic center attackers at " + gaiaCC + ": " + uneval(toSpawn)); | this.debugLog("Spawning civic center attackers at " + gaiaCC + ": " + uneval(toSpawn)); | ||||
let ccAttackers = []; | let ccAttackers = []; | ||||
for (let spawn of toSpawn) | for (let spawn of toSpawn) | ||||
{ | { | ||||
let ents = TriggerHelper.SpawnUnits(gaiaCC, "units/" + spawn.template, spawn.count, gaulPlayer); | let ents = TriggerHelper.SpawnUnits(gaiaCC, "units/" + spawn.template, spawn.count, gaulPlayer); | ||||
if (spawn.hero && ents[0]) | if (spawn.hero && ents[0]) | ||||
this.heroes.push({ "template": spawn.template, "ent": ents[0] }); | this.heroes.push({ "template": spawn.template, "ent": ents[0] }); | ||||
ccAttackers = ccAttackers.concat(ents); | ccAttackers = ccAttackers.concat(ents); | ||||
} | } | ||||
let patrolPointRef = Engine.QueryInterface(gaiaCC, IID_Position).GetPosition2D().x < mapSize / 2 ? | let patrolPointRef = isLeft ? | ||||
triggerPointCCAttackerPatrolLeft : | triggerPointCCAttackerPatrolLeft : | ||||
triggerPointCCAttackerPatrolRight; | triggerPointCCAttackerPatrolRight; | ||||
this.AttackAndPatrol(ccAttackers, unitTargetClass, patrolPointRef, "CCAttackers", false); | this.AttackAndPatrol(ccAttackers, unitTargetClass, patrolPointRef, "CCAttackers", false); | ||||
} | } | ||||
if (this.civicCenters.length) | if (this.civicCenters.length) | ||||
this.DoAfterDelay(ccAttackerInterval() * 60 * 1000, "SpawnCCAttackers", {}); | this.DoAfterDelay(ccAttackerInterval() * 60 * 1000, "SpawnCCAttackers", {}); | ||||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | ProcessCommand(gaulPlayer, { | ||||
}, | }, | ||||
"queued": true, | "queued": true, | ||||
"allowCapture": false | "allowCapture": false | ||||
}); | }); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* 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 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()) | for (let ent of Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetNonGaiaEntities()) | ||||
{ | { | ||||
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | ||||
if (!cmpIdentity || !cmpIdentity.HasClass("Structure")) | if (!cmpIdentity || !cmpIdentity.HasClass(siegeTargetClass)) | ||||
continue; | continue; | ||||
if (Engine.QueryInterface(ent, IID_Position).GetPosition2D().x < mapSize / 2) | if (Engine.QueryInterface(ent, IID_Position).GetPosition2D().x < mapSize / 2) | ||||
ungarrisonLeft = true; | left = true; | ||||
else | else | ||||
ungarrisonRight = true; | right = true; | ||||
if (ungarrisonLeft && ungarrisonRight) | if (left && right) | ||||
break; | 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) | if (!ungarrisonLeft && !ungarrisonRight) | ||||
return; | return; | ||||
// Determine which ships should ungarrison on which side of the river | // Determine which ships should ungarrison on which side of the river | ||||
let shipsLeft = []; | let shipsLeft = []; | ||||
let shipsRight = []; | let shipsRight = []; | ||||
if (ungarrisonLeft && ungarrisonRight) | if (ungarrisonLeft && ungarrisonRight) | ||||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator