feat:追猎相关适配
This commit is contained in:
parent
3501f2e6c6
commit
dccd0711a3
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
@ -1164,16 +1165,18 @@ control.prototype.checkBlock = function () {
|
|||||||
const ambushAction = this._checkBlock_ambush(core.status.checkBlock.ambush[loc]);
|
const ambushAction = this._checkBlock_ambush(core.status.checkBlock.ambush[loc]);
|
||||||
if (ambushAction.length > 0) core.push(actions, ambushAction);
|
if (ambushAction.length > 0) core.push(actions, ambushAction);
|
||||||
|
|
||||||
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,34 +1223,39 @@ 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);
|
|
||||||
// 可与敌人,物品换位
|
// 可与敌人,物品换位
|
||||||
actions.push({
|
if (!(aimx === hx && aimy === hy)) {
|
||||||
"type": "if", "condition": "!core.getBlock(" + aimx + "," + aimy + ")",
|
actions.push({
|
||||||
"true": [
|
"type": "if", "condition": "!core.getBlock(" + aimx + "," + aimy + ")",
|
||||||
{ "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] },
|
"true": [
|
||||||
{ "type": "waitAsync", "excludeAnimates": true },
|
{ "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] },
|
||||||
],
|
],
|
||||||
"false": [
|
"false": [
|
||||||
{
|
{
|
||||||
"type": "if", "condition": "[\"items\",\"enemys\",\"enemy48\"].includes(core.getBlockCls("+ aimx + "," + aimy + "))",
|
"type": "if", "condition": "[\"items\",\"enemys\",\"enemy48\"].includes(core.getBlockCls(" + 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": "move", "loc": [aimx, aimy], "time": 100, "keep": true, "async": true, "steps": [reverseDir[dir] + ":1"] },
|
{ "type": "move", "loc": [aimx, aimy], "time": 100, "keep": true, "async": true, "steps": [reverseDir[dir] + ":1"] },
|
||||||
{ "type": "waitAsync", "excludeAnimates": true },
|
{ "type": "waitAsync", "excludeAnimates": true },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if (actions.length > 0) actions.push({ "type": "waitAsync" });
|
if (actions.length > 0) actions.push({ "type": "waitAsync" });
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user