Fix cannotMove with getNext
This commit is contained in:
commit
5f947bb588
@ -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) {
|
||||
|
||||
@ -885,7 +885,7 @@ core.prototype.addItem = function (itemId, itemNum) {
|
||||
|
||||
////// 获得面前的物品(轻按) //////
|
||||
core.prototype.getNextItem = function() {
|
||||
core.events.getNextItem();
|
||||
return core.events.getNextItem();
|
||||
}
|
||||
|
||||
////// 获得某个物品 //////
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
////// 获得某个物品 //////
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user