feat:追猎相关适配

This commit is contained in:
ShakeFlower 2025-01-05 09:49:03 +08:00
parent 3501f2e6c6
commit dccd0711a3
2 changed files with 3618 additions and 3610 deletions

View File

@ -8,7 +8,7 @@
(function () { (function () {
// 将这一行改成 false 可以禁用本拓展 // 将这一行改成 false 可以禁用本拓展
var __enabled = true; var __enabled = false;
if (window.jsinterface || !window.fs || !__enabled) return; if (window.jsinterface || !window.fs || !__enabled) return;

View File

@ -1122,9 +1122,10 @@ control.prototype.updateCheckBlock = function (floorId) {
////// 检查并执行领域、夹击、阻击事件 ////// ////// 检查并执行领域、夹击、阻击事件 //////
control.prototype.battleWithChase = function () { control.prototype.battleWithChase = function () {
const [hx, hy] = [core.getHeroLoc('x'), core.getHeroLoc('y')]; const { x: hx, y: hy } = core.status.hero.loc;
const scan = core.utils.scan; const scan = core.utils.scan;
const actions = []; const actions = [];
for (const dir in scan) { for (const dir in scan) {
const [nx, ny] = [hx + scan[dir].x, hy + scan[dir].y]; const [nx, ny] = [hx + scan[dir].x, hy + scan[dir].y];
const blockId = core.getBlockId(nx, ny); const blockId = core.getBlockId(nx, ny);
@ -1167,13 +1168,15 @@ control.prototype.checkBlock = function () {
const repulseAction = this._checkBlock_repulse(core.status.checkBlock.repulse[loc]); const repulseAction = this._checkBlock_repulse(core.status.checkBlock.repulse[loc]);
if (repulseAction.length > 0) core.push(actions, repulseAction); if (repulseAction.length > 0) core.push(actions, repulseAction);
// 追猎需要等待阻击完成,避免发生碰撞导致怪物消失 // 追猎需要等待阻击完成,避免发生碰撞导致怪物消失 先清理四周追猎,追猎移动,再清理一轮四周的追猎
const chaseAction = this._checkBlock_chase(core.status.checkBlock.chase[loc]); const currChase = core.status.checkBlock.chase[loc];
if (chaseAction.length > 0) { if (currChase && currChase.length > 0) {
core.push(actions, chaseAction); core.push(actions, { "type": "function", "async": true, "function": "function(){\ncore.battleWithChase();\n}" });
core.push(actions, }
{ "type": "function", "async": true, "function": "function(){\ncore.battleWithChase();\n}" } const chaseAction = this._checkBlock_chase(currChase);
); if (chaseAction.length > 0) core.push(actions, chaseAction);
if (currChase && currChase.length > 0) {
core.push(actions, { "type": "function", "async": true, "function": "function(){\ncore.battleWithChase();\n}" });
} }
if (actions.length > 0) core.insertAction(actions); if (actions.length > 0) core.insertAction(actions);
} }
@ -1220,21 +1223,24 @@ control.prototype._checkBlock_ambush = function (ambush) {
////// 追猎 ////// ////// 追猎 //////
control.prototype._checkBlock_chase = function (chase) { control.prototype._checkBlock_chase = function (chase) {
if (!chase || chase.length == 0) return []; if (!chase || chase.length === 0) return [];
var actions = []; var actions = [];
const { x: hx, y: hy } = core.status.hero.loc;
const reverseDir = { 'up': 'down', 'down': 'up', 'left': 'right', 'right': 'left' }; const reverseDir = { 'up': 'down', 'down': 'up', 'left': 'right', 'right': 'left' };
console.log(chase); chase = chase.sort((a, b) => {
const { x: ax, y: ay } = a;
chase.forEach(function (info) { const { x: bx, y: by } = b;
const { x, y, dir } = info; return Math.abs(ax - hx) + Math.abs(ay - hy) - Math.abs(bx - hx) - Math.abs(by - hy);
})
chase.forEach((currChaseInfo) => {
const { x, y, dir } = currChaseInfo;
const [aimx, aimy] = [x + core.utils.scan[dir].x, y + core.utils.scan[dir].y]; const [aimx, aimy] = [x + core.utils.scan[dir].x, y + core.utils.scan[dir].y];
console.log(aimx,aimy);
// 可与敌人,物品换位 // 可与敌人,物品换位
if (!(aimx === hx && aimy === hy)) {
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": 100, "keep": true, "async": true, "steps": [dir + ":1"] },
{ "type": "waitAsync", "excludeAnimates": true },
], ],
"false": [ "false": [
{ {
@ -1247,7 +1253,9 @@ control.prototype._checkBlock_chase = function (chase) {
}, },
] ]
}); });
}); }
})
if (actions.length > 0) actions.push({ "type": "waitAsync" }); if (actions.length > 0) actions.push({ "type": "waitAsync" });
return actions; return actions;
} }