fix: 自动寻路时无法触发楼层传送

This commit is contained in:
unanmed 2024-09-28 15:32:12 +08:00
parent b881cc1d2e
commit c6e0573496
11 changed files with 178 additions and 132 deletions

View File

@ -784,7 +784,7 @@ control.prototype.setAutoHeroMove = function (steps) {
core.status.automaticRoute.autoHeroMove = true;
core.status.automaticRoute.autoStep = 1;
core.status.automaticRoute.destStep = steps[0].step;
core.moveHero(steps[0].direction);
// core.moveHero(steps[0].direction);
};
////// 设置行走的效果动画 //////
@ -977,7 +977,6 @@ control.prototype.moveDirectly = function (destX, destY, ignoreSteps) {
////// 尝试瞬间移动 //////
control.prototype.tryMoveDirectly = function (destX, destY) {
// console.trace();
if (this.nearHero(destX, destY)) return false;
var canMoveArray = core.maps.generateMovableArray();
var dirs = [
@ -1015,37 +1014,6 @@ control.prototype.tryMoveDirectly = function (destX, destY) {
////// 绘制勇士 //////
control.prototype.drawHero = function (status, offset = 0, frame) {
return;
if (!core.isPlaying() || !core.status.floorId || core.status.gameOver)
return;
var x = core.getHeroLoc('x'),
y = core.getHeroLoc('y'),
direction = core.getHeroLoc('direction');
status = status || 'stop';
if (!offset) offset = 0;
var way = core.utils.scan2[direction];
var dx = way.x,
dy = way.y;
var offsetX = typeof offset == 'number' ? dx * offset : offset.x || 0;
var offsetY = typeof offset == 'number' ? dy * offset : offset.y || 0;
offset = { x: offsetX, y: offsetY, offset: offset };
core.clearAutomaticRouteNode(x + dx, y + dy);
core.clearMap('hero');
core.status.heroCenter.px = 32 * x + offsetX + 16;
core.status.heroCenter.py =
32 * y + offsetY + 32 - core.material.icons.hero.height / 2;
// 重置hero层画布
core.setGameCanvasTranslate('hero', 0, 0);
delete core.canvas.hero._px;
delete core.canvas.hero._py;
core.status.preview.enabled = false;
if (!core.hasFlag('__lockViewport__')) {
this._drawHero_updateViewport(x, y, offset);
}
this._drawHero_draw(direction, x, y, status, offset, frame);
};
control.prototype._drawHero_updateViewport = function (x, y, offset) {

View File

@ -133,7 +133,7 @@ function core() {
time: 0,
updated: false,
storage: true, // 是否把自动存档写入文件a
max: 20, // 自动存档最大回退数
max: 50, // 自动存档最大回退数
now: 0
},
favorite: [],

View File

@ -29,7 +29,7 @@ main.floors.MT85=
"floorId": "MT86",
"loc": [
0,
4
3
]
},
"10,14": {

View File

@ -23,18 +23,25 @@ main.floors.MT86=
]
},
"changeFloor": {
"0,4": {
"7,14": {
"floorId": "MT89",
"loc": [
7,
0
]
},
"0,3": {
"floorId": "MT85",
"loc": [
14,
3
]
},
"7,14": {
"floorId": "MT89",
"14,7": {
"floorId": "MT91",
"loc": [
7,
0
0,
7
]
}
},
@ -49,8 +56,8 @@ main.floors.MT86=
[648,648,648,648,648,648,648,648,648,648,648,648,648,648,648],
[648,491,376,491, 0,648, 0, 0,482, 0, 0,482, 0, 0,648],
[648,648,648,648,671,648,676,648,648,648,648,677,648,492,648],
[648, 0, 0,648, 0,648, 0, 0,232,487,648, 0, 27, 0,648],
[ 92, 0, 0,129,484, 0,378, 0,648,487,492,484, 0,484,648],
[ 92, 0, 0,648, 0,648, 0, 0,232,487,648, 0, 27, 0,648],
[648, 0, 0,129,484, 0,378, 0,648,487,492,484, 0,484,648],
[648,249,648,648,648,494,648,648,648,644,648,648,648,249,648],
[648, 0,484,648,376, 21,378,648, 29, 0,648,484, 0,484,648],
[648, 0, 0,648,484,403,484,648, 0,484,578, 0, 28, 0, 94],

View File

@ -31,6 +31,13 @@ main.floors.MT88=
7,
14
]
},
"14,11": {
"floorId": "MT90",
"loc": [
0,
11
]
}
},
"beforeBattle": {},

View File

@ -31,6 +31,13 @@ main.floors.MT89=
7,
14
]
},
"7,14": {
"floorId": "MT90",
"loc": [
7,
0
]
}
},
"beforeBattle": {},
@ -42,13 +49,13 @@ main.floors.MT89=
"cannotMoveIn": {},
"map": [
[648,648,648,648,648,648,648, 91,648,648,648,648,648,648,648],
[648,249, 29, 0,491,578, 0, 0,658, 0,381,648,484,484,648],
[648,249, 29, 0,491,578, 27, 0,658, 0,381,648,484,484,648],
[648, 29,648,648,648,648, 0,648,648,648,648,648,492,648,648],
[648, 0,648,487,378,648,484,648, 0, 0,676,648,378,484,648],
[648,491,648,378, 21,618, 0,648, 0,648, 0,679,484, 27,648],
[648,578,648,648,648,648,679,648, 0,648,491,648,648,648,648],
[648, 0, 0, 0,484, 0, 0,648, 0,648, 0,513, 0, 0,648],
[ 92, 0,648,492,648,648, 0,648,494,648,648,648, 0, 0, 94],
[ 92, 0,648,492,648,648, 0,648,494,648,648,648,484, 0, 94],
[648, 0,682, 0,491,648, 0,644,420,249,482,648,648,682,648],
[648,682,648, 29, 0,648,648,648,578,648,482,648, 0,484,648],
[648, 0,648,648,657,648, 0,648,494,648,492,648,657,648,648],

View File

@ -17,7 +17,22 @@ main.floors.MT90=
"eachArrive": [],
"parallelDo": "",
"events": {},
"changeFloor": {},
"changeFloor": {
"0,11": {
"floorId": "MT88",
"loc": [
14,
11
]
},
"7,0": {
"floorId": "MT89",
"loc": [
7,
14
]
}
},
"beforeBattle": {},
"afterBattle": {},
"afterGetItem": {},
@ -26,20 +41,32 @@ main.floors.MT90=
"cannotMove": {},
"cannotMoveIn": {},
"map": [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[648,648,648,648,648,648,648, 91,648,648,648,648,648,648,648],
[648,376, 0,648,487,232, 0, 0,484, 0,648, 0,494, 0,648],
[648,491,381,671, 0,648,492,648,648,513,648, 0,648,376,648],
[648,648,648,648,648,648, 27, 0,484, 0,538, 0,648,491,648],
[648,491,381,679, 0,648,492,648,648,648,648,677,648,378,648],
[648,378, 0,648,491,232, 27,491,648, 0,658, 0,648,618,648],
[648,648,648,648,648,648,491, 28,648,381,648,484,658, 0,648],
[648, 0,578, 0, 28,648,644,648,648, 0,648,648,648, 0,648],
[648, 0,648,484, 0,682,103,657, 0,484,648,484,657, 0,648],
[648,484,648, 0, 27,648,249,648,648,648,648,492,648,648,648],
[648, 0,648,648,648,648, 0,491, 0,648, 27,484,677, 0,648],
[ 92, 0, 0,484, 0,648,494,648,513,648, 0, 29,648, 0,648],
[648,648,648,648,513,648,491,648, 0,648,648,648,648, 0,648],
[648, 28, 0,484, 0,648,491,648, 28, 0, 29,658, 0,491,648],
[648,648,648,648,648,648,648,648,648,648,648,648,648,648,648]
],
"bgmap": [
],
"fgmap": [
],
"bg2map": [
],
"fg2map": [
]
}

View File

@ -17,7 +17,15 @@ main.floors.MT91=
"eachArrive": [],
"parallelDo": "",
"events": {},
"changeFloor": {},
"changeFloor": {
"0,7": {
"floorId": "MT86",
"loc": [
14,
7
]
}
},
"beforeBattle": {},
"afterBattle": {},
"afterGetItem": {},
@ -26,20 +34,32 @@ main.floors.MT91=
"cannotMove":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, 0, 0, 0, 0, 0,648],
[ 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 94],
[648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[648,648,648,648,648,648,648, 93,648,648,648,648,648,648,648]
],
"bgmap": [
],
"fgmap": [
],
"bg2map": [
],
"fg2map": [
]
}

View File

@ -419,12 +419,14 @@ export class HeroMover extends ObjectMoverBase {
return super.startMove();
}
private checkAutoSave(x: number, y: number) {
private checkAutoSave(x: number, y: number, nx: number, ny: number) {
const index = `${x},${y}`;
const nIndex = `${nx},${ny}`;
const map = core.status.thisMap.enemy.mapDamage;
const dam = map[index];
const nextDam = map[nIndex];
if (!dam) return false;
if (dam.mockery || dam.hunt) {
if (nextDam.mockery || (!dam.hunt && nextDam.hunt)) {
core.autosave();
return true;
}
@ -442,6 +444,8 @@ export class HeroMover extends ObjectMoverBase {
if (!adapter) return;
await adapter.all('endMove');
adapter.sync('endAnimate');
core.clearContinueAutomaticRoute();
core.stopAutomaticRoute();
}
protected async onStepStart(
@ -456,7 +460,7 @@ export class HeroMover extends ObjectMoverBase {
const { x, y } = core.status.hero.loc;
const { x: nx, y: ny } = this.nextLoc(x, y, this.moveDir);
this.checkAutoSave(nx, ny);
if (this.autoSave) this.checkAutoSave(x, y, nx, ny);
if (!this.inLockControl && core.status.lockControl) {
controller.stop();
@ -515,6 +519,8 @@ export class HeroMover extends ObjectMoverBase {
// 本次移动停止
if (code === HeroMoveCode.Stop) {
core.clearContinueAutomaticRoute();
core.stopAutomaticRoute();
controller.stop();
return;
}

View File

@ -193,13 +193,14 @@ export function init() {
control.prototype.moveHero = async function (
direction?: Dir,
callback?: () => void
callback?: () => void,
noRoute: boolean = false
) {
if (heroMover.moving) return;
heroMover.clearMoveQueue();
heroMover.oneStep(direction ?? 'forward');
const lock = core.status.lockControl;
const controller = heroMover.startMove(false, true, lock);
const controller = heroMover.startMove(false, noRoute, lock);
controller?.onEnd.then(() => {
callback?.();
});
@ -251,6 +252,9 @@ export function init() {
this._setAutomaticRoute_drawRoute(moveStep);
this._setAutomaticRoute_setAutoSteps(moveStep);
// ???
core.setAutoHeroMove();
// 执行移动
const steps: MoveStep[] = moveStep.map(v => {
return { type: 'dir', value: v.direction };

View File

@ -184,7 +184,7 @@ export function init() {
return _executeCallback();
// @ts-ignore
core.status.automaticRoute.moveDirectly = false;
this.doSystemEvent(trigger, block, core.doAction);
this.doSystemEvent(trigger, block);
}
return _executeCallback();
};