feat:调整checkBlock
This commit is contained in:
parent
8197b4c4d0
commit
b1a0e1fb37
@ -2499,9 +2499,13 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
|||||||
"!doc": "锁定用户控制,常常用于事件处理",
|
"!doc": "锁定用户控制,常常用于事件处理",
|
||||||
"!type": "fn()"
|
"!type": "fn()"
|
||||||
},
|
},
|
||||||
|
"getCheckBlock": {
|
||||||
|
"!doc": "获取某层的阻激夹域伤害信息",
|
||||||
|
"!type": "fn(floorId?: string)"
|
||||||
|
},
|
||||||
"updateCheckBlock": {
|
"updateCheckBlock": {
|
||||||
"!doc": "更新领域、夹击、阻击的伤害地图",
|
"!doc": "更新领域、夹击、阻击的伤害地图",
|
||||||
"!type": "fn(floorId?: string)"
|
"!type": "fn(floorId?: string) -> bool"
|
||||||
},
|
},
|
||||||
"checkBlock": {
|
"checkBlock": {
|
||||||
"!doc": "检查并执行领域、夹击、阻击事件",
|
"!doc": "检查并执行领域、夹击、阻击事件",
|
||||||
|
|||||||
@ -153,7 +153,7 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_lint": true,
|
"_lint": true,
|
||||||
"_data": "更新状态栏"
|
"_data": "更新状态栏"
|
||||||
},
|
},
|
||||||
"updateCheckBlock": {
|
"getCheckBlock": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_lint": true,
|
"_lint": true,
|
||||||
|
|||||||
@ -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) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 检查并执行领域、夹击、阻击事件 //////
|
////// 检查并执行领域、夹击、阻击事件 //////
|
||||||
|
|||||||
55
libs/maps.js
55
libs/maps.js
@ -766,11 +766,20 @@ maps.prototype.canMoveDirectly = function (destX, destY) {
|
|||||||
return this.canMoveDirectlyArray([[destX, destY]])[0];
|
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 ans = [], number = locs.length;
|
||||||
|
|
||||||
var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y');
|
let fromX, fromY, floorId;
|
||||||
if (!this._canMoveDirectly_checkGlobal()) {
|
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);
|
for (var i = 0; i < number; ++i) ans.push(-1);
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
@ -788,30 +797,32 @@ maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) {
|
|||||||
if (number == 0) return ans;
|
if (number == 0) return ans;
|
||||||
|
|
||||||
// 检查起点事件
|
// 检查起点事件
|
||||||
if (!this._canMoveDirectly_checkStartPoint(fromX, fromY)) {
|
if (!this._canMoveDirectly_checkStartPoint(fromX, fromY, floorId)) {
|
||||||
for (var i in ans) {
|
for (var i in ans) {
|
||||||
if (ans[i] == null) ans[i] = -1;
|
if (ans[i] == null) ans[i] = -1;
|
||||||
}
|
}
|
||||||
return ans;
|
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.flags.enableMoveDirectly) return false;
|
||||||
// 检查该楼层是否不可瞬间移动
|
// 检查该楼层是否不可瞬间移动
|
||||||
if (core.status.thisMap.cannotMoveDirectly) return false;
|
if (core.status.maps[floorId].cannotMoveDirectly) return false;
|
||||||
// flag:cannotMoveDirectly为true:不能
|
// flag:cannotMoveDirectly为true:不能
|
||||||
if (core.hasFlag('cannotMoveDirectly')) return false;
|
if (core.hasFlag('cannotMoveDirectly')) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) {
|
maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy, floorId) {
|
||||||
if (core.status.checkBlock.damage[sx + "," + sy]) return false;
|
let checkBlockInfo = core.getCheckBlock(floorId);
|
||||||
var block = core.getBlock(sx, sy);
|
if (checkBlockInfo && checkBlockInfo.damage[sx + "," + sy]) return false;
|
||||||
|
var block = core.getBlock(sx, sy, floorId);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
// 只有起点是传送点才是能无视
|
// 只有起点是传送点才是能无视
|
||||||
return block.event.trigger == 'changeFloor';
|
return block.event.trigger == 'changeFloor';
|
||||||
@ -819,11 +830,11 @@ maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMoveArray) {
|
maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMoveArray, floorId) {
|
||||||
canMoveArray = canMoveArray || this.generateMovableArray();
|
canMoveArray = canMoveArray || this.generateMovableArray(floorId);
|
||||||
var blocksObj = this.getMapBlocksObj();
|
var blocksObj = this.getMapBlocksObj(floorId);
|
||||||
// 滑冰
|
// 滑冰
|
||||||
var bgMap = this.getBgMapArray();
|
var bgMap = this.getBgMapArray(floorId);
|
||||||
|
|
||||||
var visited = [], queue = [];
|
var visited = [], queue = [];
|
||||||
visited[sx + "," + sy] = 0;
|
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;
|
var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y, nindex = nx + "," + ny;
|
||||||
if (visited[nindex]) continue;
|
if (visited[nindex]) continue;
|
||||||
if (core.onSki(bgMap[ny][nx])) 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;
|
visited[nindex] = visited[now] + 1;
|
||||||
// if (nx == ex && ny == ey) return visited[nindex];
|
// if (nx == ex && ny == ey) return visited[nindex];
|
||||||
for (var i in ans) {
|
for (var i in ans) {
|
||||||
@ -862,7 +873,7 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMo
|
|||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) {
|
maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y, floorId) {
|
||||||
var index = x + "," + y;
|
var index = x + "," + y;
|
||||||
var block = blocksObj[index];
|
var block = blocksObj[index];
|
||||||
// 该点是否不可通行或有脚本
|
// 该点是否不可通行或有脚本
|
||||||
@ -876,13 +887,17 @@ maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) {
|
|||||||
ignore = block.event.data.ignoreChangeFloor;
|
ignore = block.event.data.ignoreChangeFloor;
|
||||||
if (!ignore) return false;
|
if (!ignore) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkBlockInfo = core.control.getCheckBlock(floorId);
|
||||||
// 是否存在阻激夹域伤害
|
// 是否存在阻激夹域伤害
|
||||||
if (core.status.checkBlock.damage[index]) return false;
|
if (checkBlockInfo) {
|
||||||
if (core.status.checkBlock.repulse[index]) return false;
|
if (checkBlockInfo.damage[index]) return false;
|
||||||
|
if (checkBlockInfo.repulse[index]) return false;
|
||||||
// 是否存在捕捉
|
// 是否存在捕捉
|
||||||
if (core.status.checkBlock.ambush[index]) return false;
|
if (checkBlockInfo.ambush[index]) return false;
|
||||||
// 是否在追猎的视野中
|
// 是否在追猎的视野中
|
||||||
if (core.status.checkBlock.chase[index]) return false;
|
if (checkBlockInfo.chase[index]) return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -805,7 +805,7 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 判断某对象是否不为null也不为NaN //////
|
////// 判断某对象是否不为undefined, 不为null也不为NaN //////
|
||||||
utils.prototype.isset = function (val) {
|
utils.prototype.isset = function (val) {
|
||||||
return val != null && !(typeof val == 'number' && isNaN(val));
|
return val != null && !(typeof val == 'number' && isNaN(val));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1292,7 +1292,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
// updateDamage只能在此处执行!!更新全地图显伤
|
// updateDamage只能在此处执行!!更新全地图显伤
|
||||||
core.updateDamage();
|
core.updateDamage();
|
||||||
},
|
},
|
||||||
"updateCheckBlock": function (floorId) {
|
"getCheckBlock": function (floorId) {
|
||||||
// 领域、夹击、阻击等的伤害值计算
|
// 领域、夹击、阻击等的伤害值计算
|
||||||
floorId = floorId || core.status.floorId;
|
floorId = floorId || core.status.floorId;
|
||||||
if (!floorId || !core.status.maps) return;
|
if (!floorId || !core.status.maps) return;
|
||||||
@ -1522,7 +1522,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
core.flags.canGoDeadZone = canGoDeadZone;
|
core.flags.canGoDeadZone = canGoDeadZone;
|
||||||
core.status.checkBlock = {
|
return {
|
||||||
damage: damage,
|
damage: damage,
|
||||||
type: type,
|
type: type,
|
||||||
repulse: repulse,
|
repulse: repulse,
|
||||||
|
|||||||
6
runtime.d.ts
vendored
6
runtime.d.ts
vendored
@ -202,6 +202,7 @@ type gameStatus = {
|
|||||||
checkBlock: {
|
checkBlock: {
|
||||||
ambush: { [x: string]: [number, number, string, direction] }
|
ambush: { [x: string]: [number, number, string, direction] }
|
||||||
repulse: { [x: string]: [number, number, string, direction] }
|
repulse: { [x: string]: [number, number, string, direction] }
|
||||||
|
chase: { [x: string]: [number, number, string, direction] }
|
||||||
damage: { [x: string]: number }
|
damage: { [x: string]: number }
|
||||||
needCache: boolean
|
needCache: boolean
|
||||||
type: { [x: string]: { [x: string]: boolean } }
|
type: { [x: string]: { [x: string]: boolean } }
|
||||||
@ -716,8 +717,11 @@ interface control {
|
|||||||
/** 更新跟随者坐标 */
|
/** 更新跟随者坐标 */
|
||||||
updateFollowers(): void
|
updateFollowers(): void
|
||||||
|
|
||||||
|
/** 获取某一层的checkBlock信息 */
|
||||||
|
getCheckBlock(floorId?: string): gameStatus['checkBlock'] | undefined;
|
||||||
|
|
||||||
/** 更新领域、夹击、阻击的伤害地图 */
|
/** 更新领域、夹击、阻击的伤害地图 */
|
||||||
updateCheckBlock(floorId?: string): void
|
updateCheckBlock(floorId?: string): boolean
|
||||||
|
|
||||||
/** 检查并执行领域、夹击、阻击事件 */
|
/** 检查并执行领域、夹击、阻击事件 */
|
||||||
checkBlock(): void
|
checkBlock(): void
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user