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.autoHeroMove = true;
core.status.automaticRoute.autoStep = 1; core.status.automaticRoute.autoStep = 1;
core.status.automaticRoute.destStep = steps[0].step; 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) { control.prototype.tryMoveDirectly = function (destX, destY) {
// console.trace();
if (this.nearHero(destX, destY)) return false; if (this.nearHero(destX, destY)) return false;
var canMoveArray = core.maps.generateMovableArray(); var canMoveArray = core.maps.generateMovableArray();
var dirs = [ var dirs = [
@ -1015,37 +1014,6 @@ control.prototype.tryMoveDirectly = function (destX, destY) {
////// 绘制勇士 ////// ////// 绘制勇士 //////
control.prototype.drawHero = function (status, offset = 0, frame) { control.prototype.drawHero = function (status, offset = 0, frame) {
return; 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) { control.prototype._drawHero_updateViewport = function (x, y, offset) {

View File

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

View File

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

View File

@ -23,18 +23,25 @@ main.floors.MT86=
] ]
}, },
"changeFloor": { "changeFloor": {
"0,4": { "7,14": {
"floorId": "MT89",
"loc": [
7,
0
]
},
"0,3": {
"floorId": "MT85", "floorId": "MT85",
"loc": [ "loc": [
14, 14,
3 3
] ]
}, },
"7,14": { "14,7": {
"floorId": "MT89", "floorId": "MT91",
"loc": [ "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,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,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,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,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], [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,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,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], [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, 7,
14 14
] ]
},
"14,11": {
"floorId": "MT90",
"loc": [
0,
11
]
} }
}, },
"beforeBattle": {}, "beforeBattle": {},

View File

@ -31,6 +31,13 @@ main.floors.MT89=
7, 7,
14 14
] ]
},
"7,14": {
"floorId": "MT90",
"loc": [
7,
0
]
} }
}, },
"beforeBattle": {}, "beforeBattle": {},
@ -42,13 +49,13 @@ main.floors.MT89=
"cannotMoveIn": {}, "cannotMoveIn": {},
"map": [ "map": [
[648,648,648,648,648,648,648, 91,648,648,648,648,648,648,648], [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, 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, 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,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,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], [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, 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,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], [648, 0,648,648,657,648, 0,648,494,648,492,648,657,648,648],

View File

@ -1,45 +1,72 @@
main.floors.MT90= main.floors.MT90=
{ {
"floorId": "MT90", "floorId": "MT90",
"title": "苍蓝之殿-右上", "title": "苍蓝之殿-右上",
"name": "90", "name": "90",
"width": 15, "width": 15,
"height": 15, "height": 15,
"canFlyTo": true, "canFlyTo": true,
"canFlyFrom": true, "canFlyFrom": true,
"canUseQuickShop": true, "canUseQuickShop": true,
"cannotViewMap": false, "cannotViewMap": false,
"images": [], "images": [],
"ratio": 8, "ratio": 8,
"defaultGround": "T650", "defaultGround": "T650",
"bgm": "palaceNorth.mp3", "bgm": "palaceNorth.mp3",
"firstArrive": [], "firstArrive": [],
"eachArrive": [], "eachArrive": [],
"parallelDo": "", "parallelDo": "",
"events": {}, "events": {},
"changeFloor": {}, "changeFloor": {
"beforeBattle": {}, "0,11": {
"afterBattle": {}, "floorId": "MT88",
"afterGetItem": {}, "loc": [
"afterOpenDoor": {}, 14,
"autoEvent": {}, 11
"cannotMove": {}, ]
"cannotMoveIn": {}, },
"map": [ "7,0": {
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "floorId": "MT89",
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "loc": [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 7,
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 14
[ 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], "beforeBattle": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "afterBattle": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "afterGetItem": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "afterOpenDoor": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "autoEvent": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "cannotMove": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "cannotMoveIn": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] "map": [
[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

@ -1,45 +1,65 @@
main.floors.MT91= main.floors.MT91=
{ {
"floorId": "MT91", "floorId": "MT91",
"title": "苍蓝之殿-右上", "title": "苍蓝之殿-右上",
"name": "91", "name": "91",
"width": 15, "width": 15,
"height": 15, "height": 15,
"canFlyTo": true, "canFlyTo": true,
"canFlyFrom": true, "canFlyFrom": true,
"canUseQuickShop": true, "canUseQuickShop": true,
"cannotViewMap": false, "cannotViewMap": false,
"images": [], "images": [],
"ratio": 8, "ratio": 8,
"defaultGround": "T650", "defaultGround": "T650",
"bgm": "palaceNorth.mp3", "bgm": "palaceNorth.mp3",
"firstArrive": [], "firstArrive": [],
"eachArrive": [], "eachArrive": [],
"parallelDo": "", "parallelDo": "",
"events": {}, "events": {},
"changeFloor": {}, "changeFloor": {
"beforeBattle": {}, "0,7": {
"afterBattle": {}, "floorId": "MT86",
"afterGetItem": {}, "loc": [
"afterOpenDoor": {}, 14,
"autoEvent": {}, 7
"cannotMove": {}, ]
"cannotMoveIn": {}, }
"map": [ },
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "beforeBattle": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "afterBattle": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "afterGetItem": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "afterOpenDoor": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "autoEvent": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "cannotMove": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "cannotMoveIn": {},
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "map": [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [648,648,648,648,648,648,648,648,648,648,648,648,648,648,648],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,648],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [648, 0, 0, 0, 0, 0, 0, 0, 0, 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(); return super.startMove();
} }
private checkAutoSave(x: number, y: number) { private checkAutoSave(x: number, y: number, nx: number, ny: number) {
const index = `${x},${y}`; const index = `${x},${y}`;
const nIndex = `${nx},${ny}`;
const map = core.status.thisMap.enemy.mapDamage; const map = core.status.thisMap.enemy.mapDamage;
const dam = map[index]; const dam = map[index];
const nextDam = map[nIndex];
if (!dam) return false; if (!dam) return false;
if (dam.mockery || dam.hunt) { if (nextDam.mockery || (!dam.hunt && nextDam.hunt)) {
core.autosave(); core.autosave();
return true; return true;
} }
@ -442,6 +444,8 @@ export class HeroMover extends ObjectMoverBase {
if (!adapter) return; if (!adapter) return;
await adapter.all('endMove'); await adapter.all('endMove');
adapter.sync('endAnimate'); adapter.sync('endAnimate');
core.clearContinueAutomaticRoute();
core.stopAutomaticRoute();
} }
protected async onStepStart( protected async onStepStart(
@ -456,7 +460,7 @@ export class HeroMover extends ObjectMoverBase {
const { x, y } = core.status.hero.loc; const { x, y } = core.status.hero.loc;
const { x: nx, y: ny } = this.nextLoc(x, y, this.moveDir); 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) { if (!this.inLockControl && core.status.lockControl) {
controller.stop(); controller.stop();
@ -515,6 +519,8 @@ export class HeroMover extends ObjectMoverBase {
// 本次移动停止 // 本次移动停止
if (code === HeroMoveCode.Stop) { if (code === HeroMoveCode.Stop) {
core.clearContinueAutomaticRoute();
core.stopAutomaticRoute();
controller.stop(); controller.stop();
return; return;
} }

View File

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

View File

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