From b209a114f415fdfd4d4c5b19a8af7cfdf753ac59 Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Fri, 14 Feb 2025 19:52:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B4=A5=E7=A7=BB=E8=BF=BD=E7=8C=8E?= =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/events.js | 2 +- libs/maps.js | 42 +++++------------------------------------- project/functions.js | 2 +- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/libs/events.js b/libs/events.js index 8a729ceb..622151bf 100644 --- a/libs/events.js +++ b/libs/events.js @@ -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; diff --git a/libs/maps.js b/libs/maps.js index 7c748aa1..5b3880e0 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -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) { diff --git a/project/functions.js b/project/functions.js index 356052f5..38473475 100644 --- a/project/functions.js +++ b/project/functions.js @@ -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);