Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/military.js b/military.js
- index 6f9b69a..8215ad8 100644
- --- a/military.js
- +++ b/military.js
- @@ -200,6 +200,14 @@ MilitaryAttackManager.prototype.defence = function(gameStat
- };
- // return n available units and makes these units unavailable
- +MilitaryAttackManager.prototype.getEnemyBuildings = function(gameState,cls) {
- + var targets = gameState.entities.filter(function(ent) {
- + return (gameState.isEntityEnemy(ent) && ent.hasClass(cls) && ent.owner()
- + });
- + return targets;
- +}
- +
- +// return n available units and makes these units unavailable
- MilitaryAttackManager.prototype.getAvailableUnits = function(n) {
- var ret = [];
- var count = 0;
- diff --git a/walkToCC.js b/walkToCC.js
- index f064368..2a43d59 100644
- --- a/walkToCC.js
- +++ b/walkToCC.js
- @@ -24,16 +24,15 @@ WalkToCC.prototype.execute = function(gameState, militaryMan
- var idList = militaryManager.getAvailableUnits(availableCount);
- var pending = EntityCollectionFromIds(gameState, idList);
- - // Find the enemy CCs we could attack
- - var targets = gameState.entities.filter(function(ent) {
- - return (gameState.isEntityEnemy(ent) && ent.hasClass("Ci
- - });
- + // Find the enemy critical buildings we could attack
- + var targets = militaryManager.getEnemyBuildings(gamestate,"Conqu
- - // If there's no CCs, attack anything else that's critical
- + // If there's nothing, attack anything else that's less critical
- if (targets.length == 0) {
- - targets = gameState.entities.filter(function(ent) {
- - return (gameState.isEntityEnemy(ent) && ent.hasC
- - });
- + targets = militaryManager.getEnemyBuildings(gamestate,"T
- + }
- + if (targets.length == 0) {
- + targets = militaryManager.getEnemyBuildings(gamestate,"V
- }
- // If we have a target, move to it
- @@ -52,4 +51,4 @@ WalkToCC.prototype.execute = function(gameState, militaryManag
- gameState.ai.gameFinished = true;
- }
- }
- -};
- \ No newline at end of file
- +};
Add Comment
Please, Sign In to add comment