diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 86cfd54e..27af623c 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1009,14 +1009,16 @@ return code; */; update_s - : '更新状态栏和地图显伤' Newline + : '更新状态栏和地图显伤' '不检查自动事件' Bool Newline /* update_s tooltip : update: 立刻更新状态栏和地图显伤 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=update%EF%BC%9A%E7%AB%8B%E5%88%BB%E6%9B%B4%E6%96%B0%E7%8A%B6%E6%80%81%E6%A0%8F%E5%92%8C%E5%9C%B0%E5%9B%BE%E6%98%BE%E4%BC%A4 +default : [false] colour : this.dataColor -var code = '{"type": "update"},\n'; +Bool_0 = Bool_0 ? (', "doNotCheckAutoEvents": true') : '' +var code = '{"type": "update"'+Bool_0+'},\n'; return code; */; @@ -3462,7 +3464,7 @@ ActionParser.prototype.parseAction = function() { break; case "update": this.next = MotaActionBlocks['update_s'].xmlText([ - this.next]); + this.next, this.doNotCheckAutoEvents||false]); break; case "showStatusBar": this.next = MotaActionBlocks['showStatusBar_s'].xmlText([ diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 111e96f4..3a75f8df 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -672,7 +672,7 @@ function omitedcheckUpdateFunction(event) { } } } - if (one.async && one.type != 'animate') hasAsync = true; + if (one.async && one.type != 'animate' && one.type != 'function') hasAsync = true; if (one.type == 'waitAsync') hasAsync = false; } return hasAsync; diff --git a/libs/control.js b/libs/control.js index a0a3d27a..0f3dfe5f 100644 --- a/libs/control.js +++ b/libs/control.js @@ -656,7 +656,6 @@ control.prototype._moveAction_moving = function (callback) { // 执行该点事件 if (!hasTrigger) core.events._trigger(nowx, nowy); - core.updateStatusBar(); // 检查该点是否是滑冰 if (core.getBgNumber() == 167) { @@ -745,7 +744,7 @@ control.prototype.waitHeroToStop = function(callback) { core.setHeroLoc('direction', lastDirection); core.drawHero(); callback(); - }, 30); + }, core.status.replay.speed == 24 ? 0 : 30); } } @@ -1000,6 +999,8 @@ control.prototype.checkBlock = function () { core.updateStatusBar(); core.events.lose(); return; + } else { + core.updateStatusBar(); } } this._checkBlock_snipe(core.status.checkBlock.snipe[loc]); @@ -1020,7 +1021,7 @@ control.prototype._checkBlock_snipe = function (snipe) { if (!snipe || snipe.length == 0) return; var actions = []; snipe.forEach(function (t) { - actions.push({"type": "move", "loc": [t[0],t[1]], "steps": [t[3]], "time": 500, "keep": true, "async": true}); + actions.push({"type": "move", "loc": [t[0],t[1]], "steps": [t[3]], "time": 250, "keep": true, "async": true}); }); actions.push({"type": "waitAsync"}); core.insertAction(actions); @@ -1032,12 +1033,14 @@ control.prototype._checkBlock_ambush = function (ambush) { // 捕捉效果 var actions = []; ambush.forEach(function (t) { - actions.push({"type": "move", "loc": [t[0],t[1]], "steps": [t[3]], "time": 500, "keep": false, "async":true}); + actions.push({"type": "move", "loc": [t[0],t[1]], "steps": [t[3]], "time": 250, "keep": false, "async":true}); }); actions.push({"type": "waitAsync"}); // 强制战斗 ambush.forEach(function (t) { - actions.push({"type": "battle", "id": t[2]}); + actions.push({"type": "function", "function": "function() { "+ + "core.battle('" + t[2] + "', " + t[0]+ "," + t[1] + ", true, core.doAction); "+ + "}", "async": true}); }); core.insertAction(actions); } @@ -1430,7 +1433,7 @@ control.prototype._replayAction_item = function (action) { if (action.indexOf("item:")!=0) return false; var itemId = action.substring(5); if (!core.canUseItem(itemId)) return false; - if (core.material.items[itemId].hideInReplay) { + if (core.material.items[itemId].hideInReplay || core.status.replay.speed == 24) { core.useItem(itemId, false, core.replay); return true; } @@ -1463,7 +1466,7 @@ control.prototype._replayAction_equip = function (action) { var index = ownEquipment.indexOf(equipId), per = core.__SIZE__-1; if (index<0) return false; core.status.route.push(action); - if (core.material.items[equipId].hideInReplay) { + if (core.material.items[equipId].hideInReplay || core.status.replay.speed == 24) { core.loadEquip(equipId, core.replay); return true; } @@ -1483,6 +1486,10 @@ control.prototype._replayAction_unEquip = function (action) { if (!core.isset(equipType)) return false; core.ui.drawEquipbox(equipType); core.status.route.push(action); + if (core.status.replay.speed == 24) { + core.unloadEquip(equipType, core.replay); + return true; + } setTimeout(function () { core.ui.closePanel(); core.unloadEquip(equipType, core.replay); @@ -1496,6 +1503,11 @@ control.prototype._replayAction_fly = function (action) { var toIndex=core.floorIds.indexOf(floorId); if (!core.canUseItem('fly')) return false; core.ui.drawFly(toIndex); + if (core.status.replay.speed == 24) { + if (!core.flyTo(floorId, core.replay)) + core.control._replay_error(action); + return true; + } setTimeout(function () { if (!core.flyTo(floorId, core.replay)) core.control._replay_error(action); @@ -1513,7 +1525,7 @@ control.prototype._replayAction_shop = function (action) { // --- 判定commonEvent或item if (shop.commonEvent || shop.item) { core.openShop(shopId, false); - setTimeout(core.replay); + core.replay(); return true; } var choices = shop.choices; @@ -1542,14 +1554,14 @@ control.prototype._replayAction_turn = function (action) { if (action != 'turn' && action.indexOf('turn:') != 0) return false; if (action == 'turn') core.turnHero(); else core.turnHero(action.substring(5)); - setTimeout(core.replay); + core.replay(); return true; } control.prototype._replayAction_getNext = function (action) { if (action != "getNext") return false; if (!core.getNextItem()) return false; - setTimeout(core.replay); + core.replay(); return true; } @@ -1566,6 +1578,11 @@ control.prototype._replayAction_moveDirectly = function (action) { var x=parseInt(pos[0]), y=parseInt(pos[1]); var nowx=core.getHeroLoc('x'), nowy=core.getHeroLoc('y'); if (!core.moveDirectly(x, y)) return false; + if (core.status.replay.speed == 24) { + core.replay(); + return true; + } + core.ui.drawArrow('ui', 32*nowx+16-core.bigmap.offsetX, 32*nowy+16-core.bigmap.offsetY, 32*x+16-core.bigmap.offsetX, 32*y+16-core.bigmap.offsetY, '#FF0000', 3); setTimeout(function () { @@ -1578,7 +1595,7 @@ control.prototype._replayAction_moveDirectly = function (action) { control.prototype._replayAction_key = function (action) { if (action.indexOf("key:") != 0) return false; core.actions.keyUp(parseInt(action.substring(4)), false, true); - setTimeout(core.replay); + core.replay(); return true; } diff --git a/libs/events.js b/libs/events.js index 7462c7da..450d8146 100644 --- a/libs/events.js +++ b/libs/events.js @@ -402,7 +402,16 @@ events.prototype.openDoor = function (x, y, needKey, callback) { }); return; } - this._openDoor_animate(id, x, y, callback); + if (core.status.replay.speed == 24) { + core.status.replay.animate = true; + core.removeBlock(x, y); + setTimeout(function () { + core.status.replay.animate = false; + core.events.afterOpenDoor(id, x, y, callback); + }); + } else { + this._openDoor_animate(id, x, y, callback); + } } events.prototype._openDoor_check = function (id, x, y, needKey) { @@ -485,8 +494,8 @@ events.prototype.getItem = function (id, num, x, y, callback) { if (num == null) num = 1; num = num || 1; var itemCls = core.material.items[id].cls; - core.items.getItemEffect(id, num); core.removeBlock(x, y); + core.items.getItemEffect(id, num); var text = '获得 ' + core.material.items[id].name; if (num > 1) text += "x" + num; if (itemCls === 'items' && num == 1) text += core.items.getItemEffectTip(id); @@ -510,9 +519,6 @@ events.prototype.getItem = function (id, num, x, y, callback) { itemHint.push(id); } - - core.updateStatusBar(); - this.afterGetItem(id, x, y, callback); } @@ -753,8 +759,6 @@ events.prototype.pushBox = function (data) { core.removeBlock(data.x, data.y); else core.setBlock(168, data.x, data.y); - - core.updateStatusBar(); this._pushBox_moveHero(direction); } @@ -1949,7 +1953,7 @@ events.prototype._action_function = function (data, x, y, prefix) { } events.prototype._action_update = function (data, x, y, prefix) { - core.updateStatusBar(); + core.updateStatusBar(data.doNotCheckAutoEvents); core.doAction(); } diff --git a/libs/items.js b/libs/items.js index 46121db2..7d7073c9 100644 --- a/libs/items.js +++ b/libs/items.js @@ -81,6 +81,7 @@ items.prototype.getItemEffect = function (itemId, itemNum) { main.log(e); } } + core.updateStatusBar(); } else { core.addItem(itemId, itemNum); diff --git a/libs/maps.js b/libs/maps.js index 2d095e38..a448d26a 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -1471,10 +1471,10 @@ maps.prototype.hideBlock = function (x, y, floorId) { ////// 将某个块从启用变成禁用状态 ////// maps.prototype.removeBlock = function (x, y, floorId) { floorId = floorId || core.status.floorId; - if (!floorId) return; + if (!floorId) return false; var block = core.getBlock(x, y, floorId, true); - if (block == null) return; // 不存在 + if (block == null) return false; // 不存在 var index = block.index; @@ -1490,6 +1490,7 @@ maps.prototype.removeBlock = function (x, y, floorId) { // 删除Index core.removeBlockByIndex(index, floorId); core.updateStatusBar(); + return true; } ////// 根据block的索引(尽可能)删除该块 ////// @@ -1778,6 +1779,7 @@ maps.prototype._getAndRemoveBlock = function (x, y) { ////// 显示移动某块的动画,达到{“type”:”move”}的效果 ////// maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) { + if (core.status.replay.speed == 24) time = 1; time = time || 500; var blockArr = this._getAndRemoveBlock(x, y); if (blockArr == null) { @@ -1939,6 +1941,7 @@ maps.prototype._moveJumpBlock_finished = function (blockInfo, canvases, info, an ////// 显示/隐藏某个块时的动画效果 ////// maps.prototype.animateBlock = function (loc, type, time, callback) { + if (core.status.replay.speed == 24) time = 1; var isHide = type == 'hide'; if (typeof loc[0] == 'number' && typeof loc[1] == 'number') loc = [loc]; diff --git a/project/functions.js b/project/functions.js index 244a121a..c63fa1fe 100644 --- a/project/functions.js +++ b/project/functions.js @@ -1269,9 +1269,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.status.hero.hp = 0; core.updateStatusBar(); core.events.lose(); - return; + } else { + core.updateStatusBar(); } } + + // 从v2.7开始,每一步行走不会再刷新状态栏。 + // 如果有特殊要求(如每走一步都加buff之类),可手动取消注释下面这一句: + // core.updateStatusBar(true); + + // 检查自动事件 + core.checkAutoEvents(); + // 如需强行终止行走可以在这里条件判定: // core.stopAutomaticRoute(); },