diff --git a/libs/control.js b/libs/control.js index d79d2cd5..5a8ae715 100644 --- a/libs/control.js +++ b/libs/control.js @@ -656,16 +656,29 @@ control.prototype.moveOneStep = function (callback) { ////// 实际每一步的行走过程 ////// control.prototype.moveAction = function (callback) { if (core.status.heroMoving > 0) return; - var noPass = core.noPass(core.nextX(), core.nextY()), canMove = core.canMoveHero(); - // 下一个点如果不能走 + const nextX = core.nextX(), nextY = core.nextY(); + const noPass = core.noPass(nextX, nextY); + const canMove = core.canMoveHero(); + // 下一个点如果不可通行 if (noPass || !canMove) return this._moveAction_noPass(canMove, callback); - if (core.getLocalStorage("autoSaveBeforeUseItem")) { // 即将进入滑冰前触发自动存档 - const nextbgNumber = core.maps.getBgNumber(core.nextX(), core.nextY(), core.status.floorId); - if (core.onSki(nextbgNumber)) { + // 下一个点如果可通行 + // 满足条件时触发一次自动存档 + if (!core.isReplaying()) { + const dir = core.getHeroLoc('direction'); + let needAutoSave = false; + if (core.getLocalStorage("autoSaveBeforeUseItem") && + core.onSki(core.maps.getBgNumber(nextX, nextY))) { + needAutoSave = true; + } + else if (core.getLocalStorage('autoSaveBeforePickItem') && + core.getBlockCls(nextX, nextY) === 'items') { + needAutoSave = true; + } + if (needAutoSave) { + core.status.route.push(`turn:${dir}`); // 保存触发转向后的方向 core.control.autosave(); } } - this._moveAction_moving(callback); } @@ -723,8 +736,12 @@ control.prototype._moveAction_popAutomaticRoute = function () { control.prototype.moveHero = function (direction, callback) { // 如果正在移动,直接return if (core.status.heroMoving != 0) return; - if (core.isset(direction)) + if (core.isset(direction)) { + if (core.status.hero.loc.direction != direction) { + core.status.dirBeforeMove = core.status.hero.loc.direction; // 记录转向前的方向,如果下一步自动保存要还原到这个方向 + } core.setHeroLoc('direction', direction); + } if (callback) return this.moveAction(callback); this._moveHero_moving(); diff --git a/project/plugins.js b/project/plugins.js index df5f86b9..598a4e78 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -4921,6 +4921,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = ['1,5', 'comment', new SettingButton(40, 330, 150, 25)], ['2,5', 'autoHideFloor', new SettingButton(220, 330, 150, 25)], ['1,6', 'autoSaveBeforeUseItem', new SettingButton(40, 355, 150, 25)], + ['2,6', 'autoSaveBeforePickItem', new SettingButton(220, 355, 150, 25)], ]); return gamePlayMenu; } @@ -5934,8 +5935,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.fillRoundRect(ctx, 21, 71, core.__PIXELS__ - 42, 68, 3, " #555555"); // 绘制设置的框体 - core.strokeRoundRect(ctx, 20, 150, core.__PIXELS__ - 40, 240, 3, "white"); - core.fillRoundRect(ctx, 21, 151, core.__PIXELS__ - 42, 238, 3, " #999999"); + core.strokeRoundRect(ctx, 20, 150, core.__PIXELS__ - 40, 256, 3, "white"); + core.fillRoundRect(ctx, 21, 151, core.__PIXELS__ - 42, 254, 3, " #999999"); core.setTextAlign(ctx, 'center'); core.ui.fillText(ctx, "设置", core.__PIXELS__ / 2, 25, 'white', '20px Verdana');