diff --git a/src/core/main/action/move.ts b/src/core/main/action/move.ts index 8fac7cc..6ef385a 100644 --- a/src/core/main/action/move.ts +++ b/src/core/main/action/move.ts @@ -111,7 +111,7 @@ export class HeroKeyMover { if (this.moving || core.status.lockControl) return false; this.mover.oneStep(this.moveDir); - const controller = this.mover.startMove(); + const controller = this.mover.startMove(false, false, false, true); if (!controller) return; this.controller = controller; diff --git a/src/game/state/move.ts b/src/game/state/move.ts index 0ea5d32..1fd410b 100644 --- a/src/game/state/move.ts +++ b/src/game/state/move.ts @@ -400,6 +400,8 @@ export class HeroMover extends ObjectMoverBase { private noRoute: boolean = false; /** 当前移动是否是在lockControl条件下开始的 */ private inLockControl: boolean = false; + /** 是否会在特殊时刻进行自动存档 */ + private autoSave: boolean = false; /** 这一步的传送门信息 */ private portalData?: BluePalace.PortalTo; @@ -407,14 +409,27 @@ export class HeroMover extends ObjectMoverBase { override startMove( ignoreTerrain: boolean = false, noRoute: boolean = false, - inLockControl: boolean = false + inLockControl: boolean = false, + autoSave: boolean = false ): IMoveController | null { this.ignoreTerrain = ignoreTerrain; this.noRoute = noRoute; this.inLockControl = inLockControl; + this.autoSave = autoSave; return super.startMove(); } + private checkAutoSave(x: number, y: number) { + const index = `${x},${y}`; + const map = core.status.thisMap.enemy.mapDamage; + const dam = map[index]; + if (!dam) return false; + if (dam.mockery || dam.hunt) { + core.autosave(); + return true; + } + } + protected async onMoveStart(controller: IMoveController): Promise { const adapter = HeroMover.adapter; if (!adapter) return; @@ -441,6 +456,8 @@ 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.inLockControl && core.status.lockControl) { controller.stop(); return HeroMoveCode.Stop; diff --git a/src/plugin/game/fallback.ts b/src/plugin/game/fallback.ts index 51a4913..d79e987 100644 --- a/src/plugin/game/fallback.ts +++ b/src/plugin/game/fallback.ts @@ -168,6 +168,7 @@ export function init() { } if (name === 'direction') { adapters['hero-adapter']?.sync('turn', value); + adapters['hero-adapter']?.sync('setAnimateDir', value); setHeroDirection(value as Dir); } else if (name === 'x') { adapters['hero-adapter']?.sync('setHeroLoc', value); @@ -181,9 +182,13 @@ export function init() { core.stopAutomaticRoute(); core.clearContinueAutomaticRoute(); - heroMover.controller?.stop().then(() => { + if (heroMover.controller) { + heroMover.controller.stop().then(() => { + callback?.(); + }); + } else { callback?.(); - }); + } }; control.prototype.moveHero = async function ( @@ -191,11 +196,6 @@ export function init() { callback?: () => void ) { if (heroMover.moving) return; - // const nx = core.nextX(); - // const ny = core.nextY(); - // if (core.status.thisMap.enemy.mapDamage[`${nx},${ny}`]?.mockery) { - // core.autosave(); - // } heroMover.clearMoveQueue(); heroMover.oneStep(direction ?? 'forward'); const lock = core.status.lockControl; diff --git a/src/types/control.d.ts b/src/types/control.d.ts index bb9a10b..1a703c0 100644 --- a/src/types/control.d.ts +++ b/src/types/control.d.ts @@ -772,6 +772,9 @@ interface Control { * @param noGather 是否聚集跟随者 */ setHeroLoc(name: 'x' | 'y', value: number, noGather?: boolean): void; + /** + * @deprecated + */ setHeroLoc(name: 'direction', value: Dir, noGather?: boolean): void; /** @@ -781,6 +784,10 @@ interface Control { * @param name 要读取横坐标还是纵坐标还是朝向还是都读取 */ getHeroLoc(): DiredLoc; + /** + * @deprecated + * @param name 要读取横坐标还是纵坐标还是朝向还是都读取 + */ getHeroLoc(name: K): DiredLoc[K]; /**