Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // Practice using modulo to loop over an array
  2.  
  3. // Choisis la combinaison et l'ordre des unités idéale
  4. var summonTypes = ["archer"];
  5.  
  6. function summonTroops() {
  7. // Use % to wrap around the summonTypes array based on hero.built.length
  8. var type = summonTypes[0];
  9. hero.summon(type);
  10.  
  11.  
  12.  
  13. }
  14. while(true) {
  15.  
  16. var item = hero.findNearestItem();
  17. hero.move(item.pos);
  18. while(hero.gold>hero.costOf(summonTypes[0])) {
  19. summonTroops();
  20. }
  21. var friends = hero.findFriends();
  22. for(var i = 0;i<friends.length;i++){
  23. var enemy = friends[i].findNearestEnemy();
  24. if(enemy ){
  25. hero.command(friends[i], "attack", enemy);
  26. }
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement