From b1a0e1fb3743e6b52b148d734406261f8f34865b Mon Sep 17 00:00:00 2001 From: lizhuoyuan <2820814112@qq.com> Date: Sun, 26 Jan 2025 10:19:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=B0=83=E6=95=B4checkBlock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/CodeMirror/defs.js | 6 ++- _server/table/functions.comment.js | 2 +- libs/control.js | 12 +++++- libs/maps.js | 59 +++++++++++++++++++----------- libs/utils.js | 2 +- project/functions.js | 4 +- runtime.d.ts | 6 ++- 7 files changed, 62 insertions(+), 29 deletions(-) diff --git a/_server/CodeMirror/defs.js b/_server/CodeMirror/defs.js index 1c16b253..7bdbc314 100644 --- a/_server/CodeMirror/defs.js +++ b/_server/CodeMirror/defs.js @@ -2499,9 +2499,13 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [ "!doc": "锁定用户控制,常常用于事件处理", "!type": "fn()" }, + "getCheckBlock": { + "!doc": "获取某层的阻激夹域伤害信息", + "!type": "fn(floorId?: string)" + }, "updateCheckBlock": { "!doc": "更新领域、夹击、阻击的伤害地图", - "!type": "fn(floorId?: string)" + "!type": "fn(floorId?: string) -> bool" }, "checkBlock": { "!doc": "检查并执行领域、夹击、阻击事件", diff --git a/_server/table/functions.comment.js b/_server/table/functions.comment.js index 9326bf12..8dbc5ff0 100644 --- a/_server/table/functions.comment.js +++ b/_server/table/functions.comment.js @@ -153,7 +153,7 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_lint": true, "_data": "更新状态栏" }, - "updateCheckBlock": { + "getCheckBlock": { "_leaf": true, "_type": "textarea", "_lint": true, diff --git a/libs/control.js b/libs/control.js index 18b499d2..94e2ddc4 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1114,9 +1114,19 @@ control.prototype._moveDirectyFollowers = function (x, y) { } } +////// 获取某层的阻激夹域信息 ////// +control.prototype.getCheckBlock = function (floorId){ + return this.controldata.getCheckBlock(floorId); +} + ////// 更新领域、夹击、阻击的伤害地图 ////// control.prototype.updateCheckBlock = function (floorId) { - return this.controldata.updateCheckBlock(floorId); + const checkBlockInfo = this.controldata.getCheckBlock(floorId); + if (checkBlockInfo) { + core.status.checkBlock = checkBlockInfo; + return true; + } + return false; } ////// 检查并执行领域、夹击、阻击事件 ////// diff --git a/libs/maps.js b/libs/maps.js index 6dccbb88..db98c514 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -766,11 +766,20 @@ maps.prototype.canMoveDirectly = function (destX, destY) { return this.canMoveDirectlyArray([[destX, destY]])[0]; } -maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) { +maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray, fromObj) { var ans = [], number = locs.length; - var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y'); - if (!this._canMoveDirectly_checkGlobal()) { + let fromX, fromY, floorId; + if (fromObj) { + if (fromObj.hasOwnProperty('fromX')) fromX = fromObj.fromX; + if (fromObj.hasOwnProperty('fromY')) fromY = fromObj.fromY; + if (fromObj.hasOwnProperty('floorId')) floorId = fromObj.floorId; + } + if (!core.isset(fromX)) fromX = core.getHeroLoc('x'); + if (!core.isset(fromY)) fromY = core.getHeroLoc('y'); + if (!floorId) floorId = core.status.floorId; + + if (!this._canMoveDirectly_checkGlobal(floorId)) { for (var i = 0; i < number; ++i) ans.push(-1); return ans; } @@ -788,30 +797,32 @@ maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) { if (number == 0) return ans; // 检查起点事件 - if (!this._canMoveDirectly_checkStartPoint(fromX, fromY)) { + if (!this._canMoveDirectly_checkStartPoint(fromX, fromY, floorId)) { for (var i in ans) { if (ans[i] == null) ans[i] = -1; } return ans; } - return this._canMoveDirectly_bfs(fromX, fromY, locs, number, ans, canMoveArray); + return this._canMoveDirectly_bfs(fromX, fromY, locs, number, ans, canMoveArray, floorId); } -maps.prototype._canMoveDirectly_checkGlobal = function () { +maps.prototype._canMoveDirectly_checkGlobal = function (floorId) { + if (!floorId) floorId = core.status.floorId; // 检查全塔是否禁止瞬间移动 if (!core.flags.enableMoveDirectly) return false; // 检查该楼层是否不可瞬间移动 - if (core.status.thisMap.cannotMoveDirectly) return false; + if (core.status.maps[floorId].cannotMoveDirectly) return false; // flag:cannotMoveDirectly为true:不能 if (core.hasFlag('cannotMoveDirectly')) return false; return true; } -maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) { - if (core.status.checkBlock.damage[sx + "," + sy]) return false; - var block = core.getBlock(sx, sy); +maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy, floorId) { + let checkBlockInfo = core.getCheckBlock(floorId); + if (checkBlockInfo && checkBlockInfo.damage[sx + "," + sy]) return false; + var block = core.getBlock(sx, sy, floorId); if (block != null) { // 只有起点是传送点才是能无视 return block.event.trigger == 'changeFloor'; @@ -819,11 +830,11 @@ maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) { return true; } -maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMoveArray) { - canMoveArray = canMoveArray || this.generateMovableArray(); - var blocksObj = this.getMapBlocksObj(); +maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMoveArray, floorId) { + canMoveArray = canMoveArray || this.generateMovableArray(floorId); + var blocksObj = this.getMapBlocksObj(floorId); // 滑冰 - var bgMap = this.getBgMapArray(); + var bgMap = this.getBgMapArray(floorId); var visited = [], queue = []; visited[sx + "," + sy] = 0; @@ -836,7 +847,7 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMo var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y, nindex = nx + "," + ny; if (visited[nindex]) continue; if (core.onSki(bgMap[ny][nx])) continue; - if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny)) continue; + if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny, floorId)) continue; visited[nindex] = visited[now] + 1; // if (nx == ex && ny == ey) return visited[nindex]; for (var i in ans) { @@ -862,7 +873,7 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMo return ans; } -maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) { +maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y, floorId) { var index = x + "," + y; var block = blocksObj[index]; // 该点是否不可通行或有脚本 @@ -876,13 +887,17 @@ maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) { ignore = block.event.data.ignoreChangeFloor; if (!ignore) return false; } + + const checkBlockInfo = core.control.getCheckBlock(floorId); // 是否存在阻激夹域伤害 - if (core.status.checkBlock.damage[index]) return false; - if (core.status.checkBlock.repulse[index]) return false; - // 是否存在捕捉 - if (core.status.checkBlock.ambush[index]) return false; - // 是否在追猎的视野中 - if (core.status.checkBlock.chase[index]) return false; + if (checkBlockInfo) { + if (checkBlockInfo.damage[index]) return false; + if (checkBlockInfo.repulse[index]) return false; + // 是否存在捕捉 + if (checkBlockInfo.ambush[index]) return false; + // 是否在追猎的视野中 + if (checkBlockInfo.chase[index]) return false; + } return true; } diff --git a/libs/utils.js b/libs/utils.js index 5ac7ca35..f6221b11 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -805,7 +805,7 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) { } } -////// 判断某对象是否不为null也不为NaN ////// +////// 判断某对象是否不为undefined, 不为null也不为NaN ////// utils.prototype.isset = function (val) { return val != null && !(typeof val == 'number' && isNaN(val)); } diff --git a/project/functions.js b/project/functions.js index 5d8235d1..11decb3c 100644 --- a/project/functions.js +++ b/project/functions.js @@ -1292,7 +1292,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // updateDamage只能在此处执行!!更新全地图显伤 core.updateDamage(); }, - "updateCheckBlock": function (floorId) { + "getCheckBlock": function (floorId) { // 领域、夹击、阻击等的伤害值计算 floorId = floorId || core.status.floorId; if (!floorId || !core.status.maps) return; @@ -1522,7 +1522,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = */ core.flags.canGoDeadZone = canGoDeadZone; - core.status.checkBlock = { + return { damage: damage, type: type, repulse: repulse, diff --git a/runtime.d.ts b/runtime.d.ts index 910283f9..4efc449b 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -202,6 +202,7 @@ type gameStatus = { checkBlock: { ambush: { [x: string]: [number, number, string, direction] } repulse: { [x: string]: [number, number, string, direction] } + chase: { [x: string]: [number, number, string, direction] } damage: { [x: string]: number } needCache: boolean type: { [x: string]: { [x: string]: boolean } } @@ -716,8 +717,11 @@ interface control { /** 更新跟随者坐标 */ updateFollowers(): void + /** 获取某一层的checkBlock信息 */ + getCheckBlock(floorId?: string): gameStatus['checkBlock'] | undefined; + /** 更新领域、夹击、阻击的伤害地图 */ - updateCheckBlock(floorId?: string): void + updateCheckBlock(floorId?: string): boolean /** 检查并执行领域、夹击、阻击事件 */ checkBlock(): void