feat:调整checkBlock

This commit is contained in:
lizhuoyuan 2025-01-26 10:19:25 +08:00
parent 8197b4c4d0
commit b1a0e1fb37
7 changed files with 62 additions and 29 deletions

View File

@ -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": "检查并执行领域、夹击、阻击事件",

View File

@ -153,7 +153,7 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_lint": true,
"_data": "更新状态栏"
},
"updateCheckBlock": {
"getCheckBlock": {
"_leaf": true,
"_type": "textarea",
"_lint": true,

View File

@ -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;
}
////// 检查并执行领域、夹击、阻击事件 //////

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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,

6
runtime.d.ts vendored
View File

@ -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