From dea560b6872ab2405168dc30b5780bd697783ad7 Mon Sep 17 00:00:00 2001 From: pierretienne Date: Mon, 8 Dec 2014 23:24:05 +0100 Subject: [PATCH] differenciation entre usage retreat et attack (ignore leeks ou pas) --- src/IA_Exemple__4393.lks | 4 ++-- src/include_shoot__86113.lks | 27 +++++++++++++++++++++++++++ src/test__5639.lks | 4 ++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/IA_Exemple__4393.lks b/src/IA_Exemple__4393.lks index 9985641..2fccaf8 100644 --- a/src/IA_Exemple__4393.lks +++ b/src/IA_Exemple__4393.lks @@ -541,7 +541,7 @@ function retreat(){ var outEdge_l = getDistantBorder(retreatCells_l, distance_l); for(var hurtableCellMe_l : var cellsProducingIt_l in outEdge_l[distance_l - 1]){ for(var reachableCellEnemy_l : var pathEnemy_l in cellsReachablebleEnemy_l){ - if(canShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, hurtableCellMe_l, ME_G)){ + if(mightShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, hurtableCellMe_l, ME_G)){ var cellsToRemove_l = []; push(cellsToRemove_l, hurtableCellMe_l); for(var itDist_l = 0; itDist_l < distance_l; itDist_l++){ @@ -567,7 +567,7 @@ function retreat(){ }else{ for(var reachableCellMe_l : var pathMe_l in retreatCells_l){ for(var reachableCellEnemy_l : var pathEnemy_l in cellsReachablebleEnemy_l){ - if(canShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, reachableCellMe_l, ME_G)){ + if(mightShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, reachableCellMe_l, ME_G)){ removeKey(currentRetreatCells, reachableCellMe_l); break; } diff --git a/src/include_shoot__86113.lks b/src/include_shoot__86113.lks index e21d5f6..55f0019 100644 --- a/src/include_shoot__86113.lks +++ b/src/include_shoot__86113.lks @@ -108,6 +108,33 @@ function canShootCellToCell(shootingCell_p, shootingLeek_p, item_p, targetCell_p return 0; } + if(!lineOfSight(shootingCell_p, targetCell_p) && item_p != CHIP_SPARK){ + return 0; + } + + if(STUFFS_G[item_p][STUFF_SCOPE_G][STUFF_SCOPE_INLINE_G] && + (shootingCell_p - targetCell_p) % 18 != 0 && + (shootingCell_p - targetCell_p) % 17 != 0){ + return 0; + } + return 1; + }else if(shootingLeek_p === ME_G){ + return closeToShoot(item_p, targetLeek_p); + } + return -1; +} + + + +function mightShootCellToCell(shootingCell_p, shootingLeek_p, item_p, targetCell_p, targetLeek_p){ + if(targetCell_p !== -1 && targetCell_p !== null && + shootingCell_p !== -1 && shootingCell_p !== null){ + if(LEVEL_G >= 5 && + (getCellDistance(targetCell_p, shootingCell_p) > STUFFS_G[item_p][STUFF_SCOPE_G][STUFF_SCOPE_MAX_G] || + getCellDistance(targetCell_p, shootingCell_p) < STUFFS_G[item_p][STUFF_SCOPE_G][STUFF_SCOPE_MIN_G])){ + return 0; + } + if(!lineOfSight(shootingCell_p, targetCell_p, ALL_LEEKS) && item_p != CHIP_SPARK){ return 0; } diff --git a/src/test__5639.lks b/src/test__5639.lks index e1f6612..c965413 100644 --- a/src/test__5639.lks +++ b/src/test__5639.lks @@ -230,7 +230,7 @@ function retreat(){ var outEdge_l = getDistantBorder(retreatCells_l, distance_l); for(var hurtableCellMe_l : var cellsProducingIt_l in outEdge_l[distance_l - 1]){ for(var reachableCellEnemy_l : var pathEnemy_l in cellsReachablebleEnemy_l){ - if(canShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, hurtableCellMe_l, ME_G)){ + if(mightShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, hurtableCellMe_l, ME_G)){ var cellsToRemove_l = []; push(cellsToRemove_l, hurtableCellMe_l); for(var itDist_l = 0; itDist_l < distance_l; itDist_l++){ @@ -256,7 +256,7 @@ function retreat(){ }else{ for(var reachableCellMe_l : var pathMe_l in retreatCells_l){ for(var reachableCellEnemy_l : var pathEnemy_l in cellsReachablebleEnemy_l){ - if(canShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, reachableCellMe_l, ME_G)){ + if(mightShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, reachableCellMe_l, ME_G)){ removeKey(currentRetreatCells, reachableCellMe_l); break; } -- 2.11.4.GIT