Guest User

Untitled

a guest
Jan 23rd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.31 KB | None | 0 0
  1. diff --git a/military.js b/military.js
  2. index 6f9b69a..8215ad8 100644
  3. --- a/military.js
  4. +++ b/military.js
  5. @@ -200,6 +200,14 @@ MilitaryAttackManager.prototype.defence = function(gameStat
  6.  };
  7.  
  8.  // return n available units and makes these units unavailable
  9. +MilitaryAttackManager.prototype.getEnemyBuildings = function(gameState,cls) {
  10. +       var targets = gameState.entities.filter(function(ent) {
  11. +       return (gameState.isEntityEnemy(ent) && ent.hasClass(cls) && ent.owner()
  12. +       });
  13. +       return targets;
  14. +}
  15. +
  16. +// return n available units and makes these units unavailable
  17.  MilitaryAttackManager.prototype.getAvailableUnits = function(n) {
  18.         var ret = [];
  19.         var count = 0;
  20. diff --git a/walkToCC.js b/walkToCC.js
  21. index f064368..2a43d59 100644
  22. --- a/walkToCC.js
  23. +++ b/walkToCC.js
  24. @@ -24,16 +24,15 @@ WalkToCC.prototype.execute = function(gameState, militaryMan
  25.                 var idList = militaryManager.getAvailableUnits(availableCount);
  26.                 var pending = EntityCollectionFromIds(gameState, idList);
  27.                
  28. -               // Find the enemy CCs we could attack
  29. -               var targets = gameState.entities.filter(function(ent) {
  30. -                       return (gameState.isEntityEnemy(ent) && ent.hasClass("Ci
  31. -               });
  32. +               // Find the enemy critical buildings we could attack
  33. +               var targets = militaryManager.getEnemyBuildings(gamestate,"Conqu
  34.  
  35. -               // If there's no CCs, attack anything else that's critical
  36. +               // If there's nothing, attack anything else that's less critical
  37.                 if (targets.length == 0) {
  38. -                       targets = gameState.entities.filter(function(ent) {
  39. -                               return (gameState.isEntityEnemy(ent) && ent.hasC
  40. -                       });
  41. +                       targets = militaryManager.getEnemyBuildings(gamestate,"T
  42. +               }
  43. +               if (targets.length == 0) {
  44. +                       targets = militaryManager.getEnemyBuildings(gamestate,"V
  45.                 }
  46.  
  47.                 // If we have a target, move to it
  48. @@ -52,4 +51,4 @@ WalkToCC.prototype.execute = function(gameState, militaryManag
  49.                         gameState.ai.gameFinished = true;
  50.                 }
  51.         }
  52. -};
  53. \ No newline at end of file
  54. +};
Add Comment
Please, Sign In to add comment