fix:败移追猎小调整

This commit is contained in:
ShakeFlower 2025-02-14 19:52:54 +08:00
parent c41dde17a3
commit b209a114f4
3 changed files with 7 additions and 39 deletions

View File

@ -3090,7 +3090,7 @@ events.prototype.moveEnemyOnPoint = function (fromX, fromY, toX, toY, floorId, n
}
////// 将两个点的怪物属性交换 //////
events.prototype.switchEnemyOnPoint = function (fromX, fromY, toX, toY, floorId, norefresh) {
events.prototype.exchangeEnemyOnPoint = function (fromX, fromY, toX, toY, floorId, norefresh) {
floorId = floorId || core.status.floorId;
const spos = fromX + "," + fromY,
aimpos = toX + "," + toY;

View File

@ -2730,54 +2730,22 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call
}
_run();
}
//core.setEnemyOnPoint(5,2,null,'hp',1000,'=') core.exchangeBlock(5, 2, 5, 3, 'down', 100, null)
maps.prototype.exchangeBlock = function (x1, y1, x2, y2, dir, time, callback) {
console.log([x1, y1, x2, y2, dir, time, callback])
let [block1, block2] = [this.getBlock(x1, y1), this.getBlock(x2, y2)];
let [blockInfo1, blockInfo2] = [this.getBlockInfo(block1), this.getBlockInfo(block2)];
const [pos1, pos2] = [`${x1},${y1}`, `${x2},${y2}`];
let fromInfo, toInfo, enemyOnFloor;
const floorId = core.status.floorId;
if (flags.enemyOnPoint && flags.enemyOnPoint.hasOwnProperty(floorId)) {
enemyOnFloor = flags.enemyOnPoint[floorId];
if (enemyOnFloor.hasOwnProperty(pos1)) fromInfo = core.clone(enemyOnFloor[pos1]);
if (enemyOnFloor.hasOwnProperty(pos2)) toInfo = core.clone(enemyOnFloor[pos2]);
}
let callbackCount = 0;
function myCallback() {
callbackCount++;
if (callbackCount === 2) {
// 删除旧位置信息
if (fromInfo) delete enemyOnFloor[pos1];
if (toInfo) delete enemyOnFloor[pos2];
// 设置新位置信息
if (fromInfo) enemyOnFloor[pos2] = fromInfo;
if (toInfo) enemyOnFloor[pos1] = toInfo;
core.exchangeEnemyOnPoint(x1, y1, x2, y2, floorId);
if (callback) callback();
}
}
switch (dir) {
case 'left':
this.moveBlock(x1, y1, ['left'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['right'], time, true, myCallback, true);
break;
case 'right':
this.moveBlock(x1, y1, ['right'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['left'], time, true, myCallback, true);
break;
case 'up':
this.moveBlock(x1, y1, ['up'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['down'], time, true, myCallback, true);
break;
case 'down':
this.moveBlock(x1, y1, ['down'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['up'], time, true, myCallback, true);
break;
}
const reverseDir = { 'up': 'down', 'down': 'up', 'left': 'right', 'right': 'left' };
this.moveBlock(x1, y1, [dir], time, true, myCallback, true);
this.moveBlock(x2, y2, [reverseDir[dir]], time, true, myCallback, true);
}
maps.prototype._moveBlock_updateSpeed = function (moveInfo) {

View File

@ -443,7 +443,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
{ "type": "setBlock", "number": enemyId, "loc": [[aimx, aimy]], "time": 50 },
{ "type": "setBlock", "number": aimId, "loc": [[x, y]], "time": 50 },
{
"type": "function", "function": `function () { core.switchEnemyOnPoint(${x},${y},${aimx},${aimy}) }`
"type": "function", "function": `function () { core.exchangeEnemyOnPoint(${x},${y},${aimx},${aimy}) }`
},
];
core.insertAction(doFailMove);