删除大部分checkblock

This commit is contained in:
unanmed 2023-07-28 11:50:01 +08:00
parent e5f025ec55
commit 9b69639c40
4 changed files with 1 additions and 280 deletions

View File

@ -1440,8 +1440,7 @@ control.prototype._moveDirectyFollowers = function (x, y) {
////// 更新领域、夹击、阻击的伤害地图 //////
control.prototype.updateCheckBlock = function (floorId) {
// throw new Error(`This function has been deprecated.`);
return this.controldata.updateCheckBlock(floorId);
// Deprecated
};
////// 检查并执行领域、夹击、阻击事件 //////

View File

@ -1350,7 +1350,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
);
},
updateStatusBar: function () {
// todo: 删除 updateCheckBlock
// 更新状态栏
// 检查等级
@ -1383,271 +1382,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
core.plugin.showStudiedSkill.value = false;
}
},
updateCheckBlock: function (floorId) {
// 领域、夹击、阻击等的伤害值计算
floorId = floorId || core.status.floorId;
if (!floorId || !core.status.maps) return;
const haloMap = {
21: ['square:7:cyan'],
26: ['square:5:blue'],
27: ['square:5:red']
};
var width = core.floors[floorId].width,
height = core.floors[floorId].height;
var blocks = core.getMapBlocksObj(floorId);
const damage = {}, // 每个点的伤害值
type = {}, // 每个点的伤害类型
repulse = {}, // 每个点的阻击怪信息
mockery = {}, // 电摇嘲讽
halo = {}; // 光环
var needCache = false;
var canGoDeadZone = core.flags.canGoDeadZone;
var haveHunt = false;
core.flags.canGoDeadZone = true;
// 计算血网和领域、阻击、激光的伤害,计算捕捉信息
for (var loc in blocks) {
var block = blocks[loc],
x = block.x,
y = block.y,
id = block.event.id,
enemy = core.material.enemys[id];
if (block.disable) continue;
type[loc] = type[loc] || {};
// 血网
// 如需调用当前楼层的ratio可使用 core.status.maps[floorId].ratio
if (id == 'lavaNet' && !core.hasItem('amulet')) {
damage[loc] = (damage[loc] || 0) + core.values.lavaDamage;
type[loc]['血网伤害'] = true;
}
// 领域
// 如果要防止领域伤害,可以直接简单的将 flag:no_zone 设为true
if (
enemy &&
core.hasSpecial(enemy.special, 15) &&
!core.hasFlag('no_zone')
) {
// 领域范围默认为1
var range = enemy.range || 1;
// 是否是九宫格领域
var zoneSquare = false;
if (enemy.zoneSquare != null) zoneSquare = enemy.zoneSquare;
// 在范围内进行搜索,增加领域伤害值
for (var dx = -range; dx <= range; dx++) {
for (var dy = -range; dy <= range; dy++) {
if (dx == 0 && dy == 0) continue;
var nx = x + dx,
ny = y + dy,
currloc = nx + ',' + ny;
if (nx < 0 || nx >= width || ny < 0 || ny >= height)
continue;
// 如果是十字领域,则还需要满足 |dx|+|dy|<=range
if (
!zoneSquare &&
Math.abs(dx) + Math.abs(dy) > range
)
continue;
damage[currloc] = Math.max(
(damage[currloc] || 0) +
(enemy.value || 0) -
core.getRealStatusOrDefault(null, 'def'),
0
);
type[currloc] = type[currloc] || {};
type[currloc]['领域伤害'] = true;
}
}
}
// 阻击
// 如果要防止阻击伤害,可以直接简单的将 flag:no_repulse 设为true
if (
enemy &&
core.hasSpecial(enemy.special, 18) &&
!core.hasFlag('no_repulse')
) {
for (var dir in core.utils.scan) {
var nx = x + core.utils.scan[dir].x,
ny = y + core.utils.scan[dir].y,
currloc = nx + ',' + ny;
if (nx < 0 || nx >= width || ny < 0 || ny >= height)
continue;
damage[currloc] =
(damage[currloc] || 0) + (enemy.value || 0);
type[currloc] = type[currloc] || {};
type[currloc]['阻击伤害'] = true;
var rdir = core.turnDirection(':back', dir);
// 检查下一个点是否存在事件(从而判定是否移动)
var rnx = x + core.utils.scan[rdir].x,
rny = y + core.utils.scan[rdir].y;
if (
core.canMoveHero(x, y, rdir, floorId) &&
core.getBlock(rnx, rny, floorId) == null
) {
repulse[currloc] = (repulse[currloc] || []).concat([
[x, y, id, rdir]
]);
}
}
}
// 射击
if (enemy && core.hasSpecial(enemy.special, 24)) {
var beyondVisual = false;
for (var nx = 0; nx < width; nx++) {
var currloc = nx + ',' + y;
for (var mx = nx; mx != x; mx > x ? mx-- : mx++) {
if (
core.getBlockCls(mx, y, floorId) == 'enemys' ||
core.getBlockCls(mx, y, floorId) == 'enemy48'
)
continue;
if (
core.noPass(mx, y, floorId) &&
core.getBlockNumber(mx, y, floorId) != 141 &&
core.getBlockNumber(mx, y, floorId) != 151
) {
beyondVisual = true;
break;
}
}
if (beyondVisual) {
beyondVisual = false;
continue;
}
if (
nx != x &&
!(
core.getBlockCls(nx, y, floorId) == 'enemys' ||
core.getBlockCls(nx, y, floorId) == 'enemy48'
)
) {
damage[currloc] =
(damage[currloc] || 0) +
Math.max(
(enemy.atk || 0) -
core.getRealStatusOrDefault(
null,
'def'
),
0
);
type[currloc] = type[currloc] || {};
type[currloc]['射击伤害'] = true;
}
}
for (var ny = 0; ny < height; ny++) {
var currloc = x + ',' + ny;
for (var my = ny; my != y; my > y ? my-- : my++) {
if (
core.getBlockCls(x, my, floorId) == 'enemys' ||
core.getBlockCls(x, my, floorId) == 'enemy48'
)
continue;
if (
core.noPass(x, my, floorId) &&
core.getBlockNumber(x, my, floorId) != 141 &&
core.getBlockNumber(x, my, floorId) != 151
) {
beyondVisual = true;
break;
}
}
if (beyondVisual) {
beyondVisual = false;
continue;
}
if (
ny != y &&
!(
core.getBlockCls(x, ny, floorId) == 'enemys' ||
core.getBlockCls(x, ny, floorId) == 'enemy48'
)
) {
damage[currloc] =
(damage[currloc] || 0) +
Math.max(
(enemy.atk || 0) -
core.getRealStatusOrDefault(
null,
'def'
),
0
);
if (damage < 0) damage = 0;
type[currloc] = type[currloc] || {};
type[currloc]['射击伤害'] = true;
}
}
}
// 电摇嘲讽
if (enemy && core.hasSpecial(enemy.special, 19)) {
for (let nx = 0; nx < width; nx++) {
if (!core.noPass(nx, y, floorId)) {
mockery[`${nx},${y}`] ??= [];
mockery[`${nx},${y}`].push([x, y]);
}
}
for (let ny = 0; ny < height; ny++) {
if (!core.noPass(x, ny, floorId)) {
mockery[`${x},${ny}`] ??= [];
mockery[`${x},${ny}`].push([x, y]);
}
}
}
// 检查地图范围类技能
var specialFlag = core.getSpecialFlag(enemy);
if (specialFlag & 1) needCache = true;
if (core.status.event.id == 'viewMaps') needCache = true;
if (
(core.status.event.id == 'book' ||
core.status.event.id == 'bool-detail') &&
core.status.event.ui
)
needCache = true;
if (specialFlag & 2) haveHunt = true;
// 检查范围光环
if (enemy) {
if (!(enemy.special instanceof Array)) continue;
for (const num of enemy.special) {
if (num in haloMap) {
halo[loc] ??= [];
halo[loc].push(...haloMap[num]);
}
}
}
}
// 融化怪
if (core.has(flags[`melt_${floorId}`])) {
Object.keys(flags[`melt_${floorId}`]).forEach(v => {
needCache = true;
halo[v] ??= [];
halo[v].push('square:3:purple');
});
}
core.flags.canGoDeadZone = canGoDeadZone;
core.status.checkBlock = {
damage: damage,
type: type,
repulse: repulse,
mockery,
needCache: needCache,
cache: {}, // clear cache
haveHunt: haveHunt,
halo
};
},
moveOneStep: function (callback) {
// 勇士每走一步后执行的操作。callback为行走完毕后的回调
// 这个函数执行在“刚走完”的时候,即还没有检查该点的事件和领域伤害等。

View File

@ -467,12 +467,6 @@ interface Control {
*/
updateFollowers(): void;
/**
*
* @param floorId id
*/
updateCheckBlock(floorId?: FloorIds): void;
/**
*
*/

View File

@ -31,12 +31,6 @@ interface ControlData {
*/
updateStatusBar(): void;
/**
*
* @param floorId id
*/
updateCheckBlock(floorId: FloorIds): void;
/**
*
* @param callback