diff --git a/libs/control.js b/libs/control.js index 04066db4..6029ea0e 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1954,15 +1954,9 @@ control.prototype.replay = function () { return; } else if (action=='getNext') { - if (core.flags.enableGentleClick && core.getBlock(core.nextX(), core.nextY())!=null) { - var nextX = core.nextX(), nextY = core.nextY(); - var block = core.getBlock(nextX, nextY); - if (block!=null && block.block.event.trigger=='getItem') { - core.getItem(block.block.event.id, 1, nextX, nextY); - core.status.route.push("getNext"); - core.replay(); - return; - } + if (core.getNextItem()) { + core.replay(); + return; } } else if (action.indexOf('move:')==0) { diff --git a/libs/core.js b/libs/core.js index f3155dd9..f3bab34c 100644 --- a/libs/core.js +++ b/libs/core.js @@ -885,7 +885,7 @@ core.prototype.addItem = function (itemId, itemNum) { ////// 获得面前的物品(轻按) ////// core.prototype.getNextItem = function() { - core.events.getNextItem(); + return core.events.getNextItem(); } ////// 获得某个物品 ////// diff --git a/libs/events.js b/libs/events.js index 0eca9ad7..357bb26a 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1002,14 +1002,24 @@ events.prototype.insertAction = function (action, x, y, callback) { ////// 获得面前的物品(轻按) ////// events.prototype.getNextItem = function() { - if (!core.status.heroStop || !core.flags.enableGentleClick) return; + if (!core.status.heroStop || !core.flags.enableGentleClick) return false; + // 检查cannotMove + var x = core.getHeroLoc('x'), y=core.getHeroLoc('y'), direction=core.getHeroLoc('direction'); + if (core.isset(core.floors[core.status.floorId].cannotMove)) { + var cannotMove = core.floors[core.status.floorId].cannotMove[x+","+y]; + if (core.isset(cannotMove) && cannotMove instanceof Array && cannotMove.indexOf(direction)>=0) + return false; + } + var nextX = core.nextX(), nextY = core.nextY(); var block = core.getBlock(nextX, nextY); - if (block==null) return; + if (block==null) return false; if (block.block.event.trigger=='getItem') { core.getItem(block.block.event.id, 1, nextX, nextY); core.status.route.push("getNext"); + return true; } + return false; } ////// 获得某个物品 ////// diff --git a/libs/maps.js b/libs/maps.js index 69c138d7..f2490d4a 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -310,11 +310,17 @@ maps.prototype.canMoveDirectly = function (destX,destY) { visited[fromX+core.bigmap.width*fromY]=0; queue.push(fromX+core.bigmap.width*fromY); - var directions = [[-1,0],[1,0],[0,1],[0,-1]]; + var directions = { + "left": [-1,0], + "up": [0,-1], + "right": [1,0], + "down": [0,1] + } while (queue.length>0) { var now=queue.shift(), nowX=parseInt(now%core.bigmap.width), nowY=parseInt(now/core.bigmap.width); for (var dir in directions) { + if (!core.canMoveHero(nowX, nowY, dir)) continue; var nx=nowX+directions[dir][0], ny=nowY+directions[dir][1]; if (nx<0||nx>=core.bigmap.width||ny<0||ny>=core.bigmap.height||visited[nx+core.bigmap.width*ny]||core.getBlock(nx,ny)!=null||core.status.checkBlock.damage[nx+core.bigmap.width*ny]>0) continue; visited[nx+core.bigmap.width*ny]=visited[nowX+core.bigmap.width*nowY]+1;