Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. include("puny_bulb");
  2.  
  3. //variables globales
  4. global chip = getChips();
  5. global lowest = 0;
  6. var nameChip = [];
  7. global closest;
  8. global melee = 0;
  9. global weapons = getWeapons();
  10. for (var i = 0; i < count(chip)-1; i++) {
  11. nameChip[i] = getChipName(chip[i]);
  12. }
  13. debug(nameChip);
  14.  
  15. if (getTurn() <2) {
  16. var weaponsName = [getWeaponName(weapons[0]),getWeaponName(weapons[1])];
  17. debug("Weapons : "+weaponsName);
  18. debug(getFightType());
  19. debug(getFightContext());
  20. }
  21. //fonctions :
  22.  
  23. // sélection du poireau ennemi avec le moins de vie
  24. function bestEnemy() {
  25. var best = getNearestEnemy();
  26. var distance = [];
  27. var alive = getAliveEnemies();
  28. for (var enemy in alive) {
  29. push(distance, getPathLength(getCell(), getCell(enemy)));
  30. }
  31. best = alive[search(distance, arrayMin(distance))];
  32. debug(getName(best));
  33. return best;
  34. }
  35.  
  36. //tirer sur l'ennemi
  37.  
  38. function shoot() {
  39. if (not getAliveEnemiesCount()) {
  40. say("My job is done here");
  41. }
  42. var enemy = bestEnemy();
  43. var counter = 0;
  44. selectWeapon(enemy);
  45. var weapon = getWeapon();
  46. var cost = getWeaponCost(weapon);
  47. if (not inArray(getCellsToUseWeapon(enemy), getCell()) and getTP() >= cost) {
  48. moveTowardCell(closest,1);
  49. useWeapon(enemy);
  50. } else {
  51. useWeapon(enemy);
  52. }
  53. while (getTP() > 0 and getTP() > cost and counter < 10) {
  54. useWeapon(enemy);
  55. counter++;
  56. }
  57. if (getTP() < cost and inArray(getCellsToUseWeapon(enemy), getCell()) and weapon != melee ) {
  58. moveAwayFrom(enemy, 1);
  59. }
  60. // On utilise le sort sinon
  61. spell(enemy);
  62. }
  63.  
  64. function selectWeapon(leek) {
  65. var usable = [];
  66. var closestCell = [];
  67. var uCells = [];
  68. var change = true;
  69. melee = 0;
  70. var equiped = getWeapon();
  71. for (var weapon in weapons) {
  72. push(usable, getCellsToUseWeapon(weapon, leek));
  73. if (getWeaponMaxRange(weapon) == 1){
  74. melee = weapon;
  75. }
  76. }
  77. for (var cells in usable[0]) {
  78. push(uCells, getPathLength(getCell(), cells));
  79. }
  80. push(closestCell, usable[0][search(uCells, arrayMin(uCells))]);
  81. uCells = [];
  82. for (var cells in usable[1]) {
  83. push(uCells, getPathLength(getCell(), cells));
  84. }
  85. push(closestCell, usable[1][search(uCells, arrayMin(uCells))]);
  86. if (getPathLength(getCell(), leek) <= getMP() and equiped != melee) {
  87. setWeapon(melee);
  88. change = false;
  89. }
  90. if (getPathLength(getCell(), closestCell[0]) < getPathLength(getCell(), closestCell[1]) and change){
  91. if (equiped != weapons[0]) {
  92. setWeapon(weapons[0]);
  93. }
  94. closest = closestCell[0];
  95. } else {
  96. if (equiped != weapons[1]) {
  97. setWeapon(weapons[1]);
  98. }
  99. closest = closestCell[1];
  100. }
  101. }
  102.  
  103. function spell(enemy){
  104. var equipedChip = getChips();
  105. if ( inArray(getCellsToUseChip(CHIP_STALACTITE, enemy), getCell())) {
  106. for (var i = 0; i < 6; i++) {
  107. useChip(CHIP_STALACTITE, enemy);
  108. }
  109. }
  110. if ( inArray(getCellsToUseChip(CHIP_SPARK, enemy), getCell())) {
  111. for (var i = 0; i < 6; i++) {
  112. useChip(CHIP_SPARK, enemy);
  113. }
  114. }
  115. if (getLife(enemy) >= 0.5*getTotalLife(enemy) and getTurn() >=50) {
  116. moveAwayFrom(enemy);
  117. }
  118. }
  119.  
  120. function heal(ally){
  121. if (getLife(ally)<=0.93*getTotalLife(ally)) {
  122. debug("envoi message heal");
  123. sendAll(MESSAGE_HEAL, ally);
  124. useChip(CHIP_VACCINE, ally);
  125. if (getLife(ally)<getTotalLife(ally)) {
  126. if (getChipEffectiveArea(CHIP_BANDAGE, getCell(ally))) {
  127. useChip(CHIP_BANDAGE, ally);
  128. useChip(CHIP_BANDAGE, ally);
  129. useChip(CHIP_BANDAGE, ally);
  130. }
  131. }
  132. }
  133. }
  134.  
  135. function protect() {
  136. if (getTurn() > 1) {
  137. var proche = true;
  138. var distanceD = getCellDistance(getCell(), getCell(getNearestEnemy()));
  139.  
  140. if (distanceD <= 2){
  141. proche = false;
  142. }
  143. var invocBulb = true;
  144. if (getCooldown(CHIP_PUNY_BULB) == 0 ) {
  145. for (var entity in getAliveAllies()) {
  146. if ( isSummon(entity)) {
  147. invocBulb = false;
  148. break;
  149. }
  150. }
  151. if (invocBulb) {
  152. var cell = getCell();
  153. var X = getCellX(cell);
  154. var Y = getCellY(cell);
  155. for (var i = -1; i <= 1 ; i++) {
  156. for (var j = -1; j <= 1 ; j++) {
  157. summon(CHIP_PUNY_BULB, getCellFromXY( X+i, Y+j ), AI_puny_bulb );
  158. }
  159. }
  160. }
  161. }
  162.  
  163. //casque
  164. if (getCooldown(CHIP_HELMET) == 0 and getTP()>= getChipCost(CHIP_HELMET) and proche) {
  165. useChip(CHIP_HELMET, getLeek());
  166. }
  167.  
  168. //bouclier
  169. if (getCooldown(CHIP_SHIELD) == 0 and getTP()>= getChipCost(CHIP_SHIELD)) {
  170. useChip(CHIP_SHIELD, getLeek());
  171. }
  172.  
  173. //force +50
  174. //if (getCooldown(CHIP_PROTEIN) == 0 and getTP()>= getChipCost(CHIP_PROTEIN) and proche) {
  175. //useChip(CHIP_PROTEIN, getLeek());
  176. //}
  177.  
  178.  
  179. //agilité
  180. if (getCooldown(CHIP_STRETCHING) == 0 and getTP()>= getChipCost(CHIP_STRETCHING) and proche) {
  181. useChip(CHIP_STRETCHING, getLeek());
  182. }
  183.  
  184. }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement