shoot du plus proche d'abord (coups meilleurs)
[multileek.git] / src / include_getWeakestAliveEnemy__74262.lks
blobb1749d3d0a0f40caba953ee2aa13440032fc9293
1 // NAME : include_getWeakestAliveEnemy
2 // DEFINITIONS :
3 //
4 // function getAliveEnemiesRobust()
5 // function getWeakestAliveEnemy()
7 include("include_basic_global_variables");
8 include("include_ground");
12 function getAliveEnemiesRobust(){
13 //debug(">>> getAliveEnemiesRobust()");
15         var enemies_l = [];
16         for(var enemyIt_l in ENEMIES_G){
17                 if(isAlive(enemyIt_l)){
18                         push(enemies_l, enemyIt_l);
19                 }
20         }
21 //debug("<<< getAliveEnemiesRobust() = " + enemies_l);
22         return enemies_l;
27 function getWeakestAliveEnemy(){
28 //debug(">>> getWeakestAliveEnemy()");
30         var enemies_l = getAliveEnemiesRobust();
31         var warning_l = 0, force_l = 1, life_l = 0, inoffensiveness_l = 0;
32         var enemyToAttack_l = [getNearestEnemy(), -99999999999];
33         for(var itEnemy_l in enemies_l){
34                 life_l = getTotalLife(itEnemy_l); //getLife ou getTotalLife
35                 if(LEVEL_G >= 5){
36                         force_l += getForce(itEnemy_l);
37                 }
38                 inoffensiveness_l = force_l/((1+force_l/100)*life_l*life_l);
39                 //debug("enemy = " + getName(itEnemy_l) + " inoffensiveness_l = " + inoffensiveness_l);
40                 if(enemyToAttack_l[1] < inoffensiveness_l){
41                         enemyToAttack_l = [itEnemy_l, inoffensiveness_l];
42                 }
43         }
44 //debug("<<< getWeakestAliveEnemy() = " + getName(enemyToAttack_l[0]));
45         return enemyToAttack_l[0];