From c6e0573496220fb9ec6904f3ff72208d44282a94 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 28 Sep 2024 15:32:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E5=8A=A8=E5=AF=BB=E8=B7=AF?= =?UTF-8?q?=E6=97=B6=E6=97=A0=E6=B3=95=E8=A7=A6=E5=8F=91=E6=A5=BC=E5=B1=82?= =?UTF-8?q?=E4=BC=A0=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/libs/control.js | 34 +---------- public/libs/core.js | 2 +- public/project/floors/MT85.js | 2 +- public/project/floors/MT86.js | 21 ++++--- public/project/floors/MT88.js | 7 +++ public/project/floors/MT89.js | 11 +++- public/project/floors/MT90.js | 109 +++++++++++++++++++++------------- public/project/floors/MT91.js | 102 ++++++++++++++++++------------- src/game/state/move.ts | 12 +++- src/plugin/game/fallback.ts | 8 ++- src/plugin/game/loopMap.ts | 2 +- 11 files changed, 178 insertions(+), 132 deletions(-) diff --git a/public/libs/control.js b/public/libs/control.js index 2c47656..d18d468 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -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) { diff --git a/public/libs/core.js b/public/libs/core.js index 0963388..682bb05 100644 --- a/public/libs/core.js +++ b/public/libs/core.js @@ -133,7 +133,7 @@ function core() { time: 0, updated: false, storage: true, // 是否把自动存档写入文件a - max: 20, // 自动存档最大回退数 + max: 50, // 自动存档最大回退数 now: 0 }, favorite: [], diff --git a/public/project/floors/MT85.js b/public/project/floors/MT85.js index 2a8c97d..71d7eb2 100644 --- a/public/project/floors/MT85.js +++ b/public/project/floors/MT85.js @@ -29,7 +29,7 @@ main.floors.MT85= "floorId": "MT86", "loc": [ 0, - 4 + 3 ] }, "10,14": { diff --git a/public/project/floors/MT86.js b/public/project/floors/MT86.js index 8d16a35..9f0be85 100644 --- a/public/project/floors/MT86.js +++ b/public/project/floors/MT86.js @@ -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], diff --git a/public/project/floors/MT88.js b/public/project/floors/MT88.js index de39ef1..7ebf34c 100644 --- a/public/project/floors/MT88.js +++ b/public/project/floors/MT88.js @@ -31,6 +31,13 @@ main.floors.MT88= 7, 14 ] + }, + "14,11": { + "floorId": "MT90", + "loc": [ + 0, + 11 + ] } }, "beforeBattle": {}, diff --git a/public/project/floors/MT89.js b/public/project/floors/MT89.js index 6c138e8..20edea3 100644 --- a/public/project/floors/MT89.js +++ b/public/project/floors/MT89.js @@ -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], diff --git a/public/project/floors/MT90.js b/public/project/floors/MT90.js index 86f0c04..131198b 100644 --- a/public/project/floors/MT90.js +++ b/public/project/floors/MT90.js @@ -1,45 +1,72 @@ main.floors.MT90= { -"floorId": "MT90", -"title": "苍蓝之殿-右上", -"name": "90", -"width": 15, -"height": 15, -"canFlyTo": true, -"canFlyFrom": true, -"canUseQuickShop": true, -"cannotViewMap": false, -"images": [], -"ratio": 8, -"defaultGround": "T650", -"bgm": "palaceNorth.mp3", -"firstArrive": [], -"eachArrive": [], -"parallelDo": "", -"events": {}, -"changeFloor": {}, -"beforeBattle": {}, -"afterBattle": {}, -"afterGetItem": {}, -"afterOpenDoor": {}, -"autoEvent": {}, -"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] + "floorId": "MT90", + "title": "苍蓝之殿-右上", + "name": "90", + "width": 15, + "height": 15, + "canFlyTo": true, + "canFlyFrom": true, + "canUseQuickShop": true, + "cannotViewMap": false, + "images": [], + "ratio": 8, + "defaultGround": "T650", + "bgm": "palaceNorth.mp3", + "firstArrive": [], + "eachArrive": [], + "parallelDo": "", + "events": {}, + "changeFloor": { + "0,11": { + "floorId": "MT88", + "loc": [ + 14, + 11 + ] + }, + "7,0": { + "floorId": "MT89", + "loc": [ + 7, + 14 + ] + } + }, + "beforeBattle": {}, + "afterBattle": {}, + "afterGetItem": {}, + "afterOpenDoor": {}, + "autoEvent": {}, + "cannotMove": {}, + "cannotMoveIn": {}, + "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": [ + +] } \ No newline at end of file diff --git a/public/project/floors/MT91.js b/public/project/floors/MT91.js index 9c86bf6..b60f3b1 100644 --- a/public/project/floors/MT91.js +++ b/public/project/floors/MT91.js @@ -1,45 +1,65 @@ main.floors.MT91= { -"floorId": "MT91", -"title": "苍蓝之殿-右上", -"name": "91", -"width": 15, -"height": 15, -"canFlyTo": true, -"canFlyFrom": true, -"canUseQuickShop": true, -"cannotViewMap": false, -"images": [], -"ratio": 8, -"defaultGround": "T650", -"bgm": "palaceNorth.mp3", -"firstArrive": [], -"eachArrive": [], -"parallelDo": "", -"events": {}, -"changeFloor": {}, -"beforeBattle": {}, -"afterBattle": {}, -"afterGetItem": {}, -"afterOpenDoor": {}, -"autoEvent": {}, -"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] + "floorId": "MT91", + "title": "苍蓝之殿-右上", + "name": "91", + "width": 15, + "height": 15, + "canFlyTo": true, + "canFlyFrom": true, + "canUseQuickShop": true, + "cannotViewMap": false, + "images": [], + "ratio": 8, + "defaultGround": "T650", + "bgm": "palaceNorth.mp3", + "firstArrive": [], + "eachArrive": [], + "parallelDo": "", + "events": {}, + "changeFloor": { + "0,7": { + "floorId": "MT86", + "loc": [ + 14, + 7 + ] + } + }, + "beforeBattle": {}, + "afterBattle": {}, + "afterGetItem": {}, + "afterOpenDoor": {}, + "autoEvent": {}, + "cannotMove": {}, + "cannotMoveIn": {}, + "map": [ + [648,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,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], + [ 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": [ + +] } \ No newline at end of file diff --git a/src/game/state/move.ts b/src/game/state/move.ts index 1fd410b..5d0cd7d 100644 --- a/src/game/state/move.ts +++ b/src/game/state/move.ts @@ -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; } diff --git a/src/plugin/game/fallback.ts b/src/plugin/game/fallback.ts index d79e987..6f367b1 100644 --- a/src/plugin/game/fallback.ts +++ b/src/plugin/game/fallback.ts @@ -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 }; diff --git a/src/plugin/game/loopMap.ts b/src/plugin/game/loopMap.ts index 2023fb8..dea4bd9 100644 --- a/src/plugin/game/loopMap.ts +++ b/src/plugin/game/loopMap.ts @@ -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(); };