feat:阻击加速(待测试bug)

This commit is contained in:
ShakeFlower 2026-02-22 10:59:34 +08:00
parent 9aa040ecf5
commit ad23687274
2 changed files with 37 additions and 31 deletions

View File

@ -1242,7 +1242,7 @@ control.prototype._checkBlock_repulse = function (repulse) {
if (!repulse || repulse.length == 0) return []; if (!repulse || repulse.length == 0) return [];
var actions = []; var actions = [];
repulse.forEach(function (t) { repulse.forEach(function (t) {
actions.push({ "type": "move", "loc": [t[0], t[1]], "steps": [t[3]], "time": 100, "keep": true, "async": true }); actions.push({ "type": "move", "loc": [t[0], t[1]], "steps": [t[3]], "time": 80, "keep": true, "async": true });
}); });
if (actions.length > 0) actions.push({ "type": "waitAsync" }); if (actions.length > 0) actions.push({ "type": "waitAsync" });
return actions; return actions;
@ -1293,7 +1293,7 @@ control.prototype._checkBlock_chase = function (chase) {
actions.push({ actions.push({
"type": "if", "condition": "!core.getBlock(" + aimx + "," + aimy + ")", "type": "if", "condition": "!core.getBlock(" + aimx + "," + aimy + ")",
"true": [ "true": [
{ "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] }, { "type": "move", "loc": [x, y], "time": 80, "keep": true, "async": true, "steps": [dir + ":1"] },
], ],
"false": [ "false": [
{ "type": "setValue", "name": "flag:chaseAimCls", "value": `core.getBlockCls(${aimx},${aimy})` }, { "type": "setValue", "name": "flag:chaseAimCls", "value": `core.getBlockCls(${aimx},${aimy})` },
@ -1309,8 +1309,8 @@ control.prototype._checkBlock_chase = function (chase) {
}, },
], ],
"false": [ "false": [
{ "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] }, { "type": "move", "loc": [x, y], "time": 80, "keep": true, "async": true, "steps": [dir + ":1"] },
{ "type": "move", "loc": [aimx, aimy], "time": 100, "keep": true, "async": true, "steps": [reverseDir[dir] + ":1"] }, { "type": "move", "loc": [aimx, aimy], "time": 80, "keep": true, "async": true, "steps": [reverseDir[dir] + ":1"] },
] ]
}, },
{ "type": "waitAsync", "excludeAnimates": true }, { "type": "waitAsync", "excludeAnimates": true },

View File

@ -2706,25 +2706,30 @@ maps.prototype._getAndRemoveBlock = function (x, y) {
maps.prototype.moveBlock = function (x, y, steps, time, keep, callback, noMoveEInfo) { maps.prototype.moveBlock = function (x, y, steps, time, keep, callback, noMoveEInfo) {
if (core.status.replay.speed == 24) time = 1; if (core.status.replay.speed == 24) time = 1;
time = time || 500; time = time || 500;
var blockArr = this._getAndRemoveBlock(x, y); const blockArr = this._getAndRemoveBlock(x, y);
if (blockArr == null) { if (blockArr == null) {
if (callback) callback(); if (callback) callback();
return; return;
} }
var block = blockArr[0], blockInfo = blockArr[1]; const block = blockArr[0], blockInfo = blockArr[1];
var moveSteps = (steps || []).map(function (t) { const moveSteps = (steps || []).map(function (t) {
return [t.split(':')[0], parseInt(t.split(':')[1] || "1")]; return [t.split(':')[0], parseInt(t.split(':')[1] || "1")];
}).filter(function (t) { }).filter(function (t) {
return ['up', 'down', 'left', 'right', 'forward', 'backward', 'leftup', 'leftdown', 'rightup', 'rightdown', 'speed'].indexOf(t[0]) >= 0 return ['up', 'down', 'left', 'right', 'forward', 'backward', 'leftup', 'leftdown', 'rightup', 'rightdown', 'speed'].indexOf(t[0]) >= 0
&& !(t[0] == 'speed' && t[1] < 16) && !(t[0] == 'speed' && t[1] < 16)
}); });
var canvases = this._initDetachedBlock(blockInfo, x, y, block.event.animate !== false); const canvases = this._initDetachedBlock(blockInfo, x, y, block.event.animate !== false);
this._moveDetachedBlock(blockInfo, 32 * x, 32 * y, 1, canvases); this._moveDetachedBlock(blockInfo, 32 * x, 32 * y, 1, canvases);
var moveInfo = { const per_time = time / 16 / core.status.replay.speed;
let oneStepLength = 2;
if (time / core.status.replay.speed < 50) oneStepLength = 8; // 当time较小时增大步长
else if (time / core.status.replay.speed < 100) oneStepLength = 4;
const moveInfo = {
sx: x, sy: y, x: x, y: y, px: 32 * x, py: 32 * y, opacity: 1, keep: keep, lastDirection: null, offset: 1, sx: x, sy: y, x: x, y: y, px: 32 * x, py: 32 * y, opacity: 1, keep: keep, lastDirection: null, offset: 1,
moveSteps: moveSteps, step: 0, per_time: time / 16 / core.status.replay.speed moveSteps: moveSteps, step: 0, per_time, oneStepLength,
} };
this._moveBlock_doMove(blockInfo, canvases, moveInfo, callback, noMoveEInfo); this._moveBlock_doMove(blockInfo, canvases, moveInfo, callback, noMoveEInfo);
} }
@ -2770,23 +2775,6 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call
_run(); _run();
} }
maps.prototype.exchangeBlock = function (x1, y1, x2, y2, dir, time, callback) {
const floorId = core.status.floorId;
let callbackCount = 0;
function myCallback() {
callbackCount++;
if (callbackCount === 2) {
core.exchangeEnemyOnPoint(x1, y1, x2, y2, floorId);
if (callback) callback();
}
}
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) { maps.prototype._moveBlock_updateSpeed = function (moveInfo) {
if (moveInfo.step == 0 && moveInfo.moveSteps[0][0] == 'speed' && moveInfo.moveSteps[0][1] >= 16) { if (moveInfo.step == 0 && moveInfo.moveSteps[0][0] == 'speed' && moveInfo.moveSteps[0][1] >= 16) {
moveInfo.per_time = moveInfo.moveSteps[0][1] / 16 / core.status.replay.speed; moveInfo.per_time = moveInfo.moveSteps[0][1] / 16 / core.status.replay.speed;
@ -2856,10 +2844,10 @@ maps.prototype._moveBlock_moving = function (blockInfo, canvases, moveInfo) {
} }
var curr = moveInfo.moveSteps[0]; var curr = moveInfo.moveSteps[0];
moveInfo.step++; moveInfo.step++;
moveInfo.px += core.utils.scan2[curr[0]].x * 2 * moveInfo.offset; moveInfo.px += core.utils.scan2[curr[0]].x * moveInfo.offset * moveInfo.oneStepLength;
moveInfo.py += core.utils.scan2[curr[0]].y * 2 * moveInfo.offset; moveInfo.py += core.utils.scan2[curr[0]].y * moveInfo.offset * moveInfo.oneStepLength;
this._moveDetachedBlock(blockInfo, moveInfo.px, moveInfo.py, moveInfo.opacity, canvases); this._moveDetachedBlock(blockInfo, moveInfo.px, moveInfo.py, moveInfo.opacity, canvases);
if (moveInfo.step == Math.round(32 / (moveInfo.offset * 2))) { if (moveInfo.step == Math.abs(Math.round(32 / (moveInfo.offset * moveInfo.oneStepLength)))) {
moveInfo.step = 0; moveInfo.step = 0;
moveInfo.moveSteps[0][1]--; moveInfo.moveSteps[0][1]--;
if (moveInfo.moveSteps[0][1] <= 0) { if (moveInfo.moveSteps[0][1] <= 0) {
@ -2868,6 +2856,24 @@ maps.prototype._moveBlock_moving = function (blockInfo, canvases, moveInfo) {
} }
} }
maps.prototype.exchangeBlock = function (x1, y1, x2, y2, dir, time, callback) {
const floorId = core.status.floorId;
let callbackCount = 0;
function myCallback() {
callbackCount++;
if (callbackCount === 2) {
core.exchangeEnemyOnPoint(x1, y1, x2, y2, floorId);
if (callback) callback();
}
}
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);
}
////// 显示跳跃某块的动画,达到{"type":"jump"}的效果 ////// ////// 显示跳跃某块的动画,达到{"type":"jump"}的效果 //////
maps.prototype.jumpBlock = function (sx, sy, ex, ey, time, keep, callback) { maps.prototype.jumpBlock = function (sx, sy, ex, ey, time, keep, callback) {
time = time || 500; time = time || 500;