From 10c972dc0b691da7359fb6014863c63cc87e0981 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 22 May 2020 21:17:42 +0800 Subject: [PATCH] =?UTF-8?q?ID:this=E4=BB=A3=E8=A1=A8=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 4 ++-- _server/editor_blockly.js | 2 +- _server/editor_datapanel.js | 4 ++++ libs/control.js | 10 ++++++---- libs/events.js | 2 +- libs/icons.js | 3 ++- libs/maps.js | 10 ++++++++-- libs/ui.js | 11 +++++++---- project/functions.js | 11 +++++++++++ v2.x-final更新.txt | 2 +- 10 files changed, 43 insertions(+), 16 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 6bb5db27..e46ef20f 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -682,7 +682,7 @@ if (EvalString_0==''){ if (EvalString_1=='')title='\\t['+EvalString_0+']'; else title='\\t['+EvalString_0+','+EvalString_1+']'; } -if(EvalString_2 && !(/^(up|center|down|hero|null)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) { +if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) { throw new Error('对话框效果的用法请右键点击帮助'); } EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']'); @@ -719,7 +719,7 @@ if (EvalString_0==''){ if (EvalString_1=='')title='\\t['+EvalString_0+']'; else title='\\t['+EvalString_0+','+EvalString_1+']'; } -if(EvalString_2 && !(/^(up|down)(,hero)?(,([+-]?\d+),([+-]?\d+))?$/.test(EvalString_2))) { +if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) { throw new Error('对话框效果的用法请右键点击帮助'); } EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']'); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 6ed9762f..65b4b156 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -536,7 +536,7 @@ editor_blockly = function () { }).sort(); } - var allIds = core.getAllIconIds(); + var allIds = ["this"].concat(core.getAllIconIds()); var allIconIds = allIds.concat(Object.keys(core.statusBar.icons).filter(function (x) { return core.statusBar.icons[x] instanceof Image; })); diff --git a/_server/editor_datapanel.js b/_server/editor_datapanel.js index b0f6a9bd..52ba9422 100644 --- a/_server/editor_datapanel.js +++ b/_server/editor_datapanel.js @@ -388,6 +388,10 @@ editor_datapanel_wrapper = function (editor) { printe('不合法的id,请使用字母、数字或下划线,且不能以数字开头') return; } + if (id == 'hero' || id == 'this' || id == 'none' || id == 'airwall') { + printe('不得使用保留关键字作为id!'); + return; + } editor.file.changeIdAndIdnum(id, null, editor_mode.info, function (err) { if (err) { printe(err); diff --git a/libs/control.js b/libs/control.js index 95940fcc..46aa0a08 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1579,10 +1579,12 @@ control.prototype._replayAction_getNext = function (action) { control.prototype._replayAction_moveDirectly = function (action) { if (action.indexOf("move:")!=0) return false; // 忽略连续的瞬移事件 - while (core.status.replay.toReplay.length>0 && - core.status.replay.toReplay[0].indexOf('move:')==0) { - core.status.route.push(action); - action = core.status.replay.toReplay.shift(); + if (!core.hasFlag('poison')) { + while (core.status.replay.toReplay.length>0 && + core.status.replay.toReplay[0].indexOf('move:')==0) { + core.status.route.push(action); + action = core.status.replay.toReplay.shift(); + } } var pos=action.substring(5).split(":"); diff --git a/libs/events.js b/libs/events.js index 412f20b3..eeec3713 100644 --- a/libs/events.js +++ b/libs/events.js @@ -988,7 +988,7 @@ events.prototype.insertCommonEvent = function (name, x, y, callback, addToLast) if (callback) callback(); return; } - this.insertAction(commonEvent, x, y, callback, addToLast); + this.insertAction({"type": "dowhile", "condition": "false", "data": commonEvent}, x, y, callback, addToLast); } ////// 获得一个公共事件 ////// diff --git a/libs/icons.js b/libs/icons.js index a21780f3..de28a897 100644 --- a/libs/icons.js +++ b/libs/icons.js @@ -53,6 +53,7 @@ icons.prototype._getAnimateFrames = function (cls, useOriginValue) { icons.prototype.getTilesetOffset = function (id) { if (typeof id == 'string') { + id = core.getIdOfThis(id); // Tileset的ID必须是 X+数字 的形式 if (!/^X\d+$/.test(id)) return null; id = parseInt(id.substring(1)); @@ -74,4 +75,4 @@ icons.prototype.getTilesetOffset = function (id) { startOffset += this.tilesetStartOffset; } return null; -} \ No newline at end of file +} diff --git a/libs/maps.js b/libs/maps.js index b95d77b6..367f0e25 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -79,6 +79,7 @@ maps.prototype._mapIntoBlocks = function (map, floor, floorId) { ////// 从ID获得数字 ////// maps.prototype.getNumberById = function (id) { + id = this.getIdOfThis(id); core.status.id2number = core.status.id2number || {}; if (core.status.id2number[id] != null) return core.status.id2number[id]; return core.status.id2number[id] = this._getNumberById(id); @@ -109,6 +110,13 @@ maps.prototype.getBlockById = function (id) { return this.getBlockByNumber(this.getNumberById(id)); } +maps.prototype.getIdOfThis = function (id) { + if (id != 'this') return id; + if (core.status.event.id != 'action') return id; + if (!core.status.event.data || core.status.event.data.x == null || core.status.event.data.y == null) return id; + return core.getBlockId(core.status.event.data.x, core.status.event.data.y) || id; +} + ////// 数字和ID的对应关系 ////// maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { var disable = null; @@ -562,8 +570,6 @@ maps.prototype._canMoveDirectly_checkGlobal = function () { if (core.status.thisMap.cannotMoveDirectly) return false; // flag:cannotMoveDirectly为true:不能 if (core.hasFlag('cannotMoveDirectly')) return false; - // 中毒状态:不能 - if (core.hasFlag('poison')) return false; return true; } diff --git a/libs/ui.js b/libs/ui.js index 014e16ee..03fc941e 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -596,7 +596,7 @@ ui.prototype.closePanel = function () { if (core.status.hero && core.status.hero.flags) { // 清除全部临时变量 Object.keys(core.status.hero.flags).forEach(function (name) { - if (name.startsWith("@temp@")) { + if (name.startsWith("@temp@") || /^arg\d+$/.test(name)) { delete core.status.hero.flags[name]; } }); @@ -752,7 +752,7 @@ ui.prototype._getPosition = function (content) { py = core.status.event.data.y; } content = content.replace("\b", "\\b") - .replace(/\\b\[(up|center|down|hero|null)(,(hero|null|\d+,\d+|\d+))?]/g, function (s0, s1, s2, s3) { + .replace(/\\b\[(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?]/g, function (s0, s1, s2, s3) { pos = s1; if (s3 == 'hero' || s1=='hero' && !s3) { px = core.status.hero.loc.x; @@ -776,7 +776,7 @@ ui.prototype._getPosition = function (content) { noPeak = core.getBlockId(px, py) == null; } } - if(pos=='hero' || pos=='null'){ + if(pos=='hero' || pos=='this'){ pos = py==null?'center':(py>=core.__HALF_SIZE__? 'up':'down'); } return ""; @@ -974,6 +974,7 @@ ui.prototype._getDrawableIconInfo = function (id) { if (id && id.indexOf('flag:') === 0) { id = core.getFlag(id.substring(5), id); } + id = core.getIdOfThis(id); var image = null, icon = null; ["terrains","animates","items","npcs","enemys"].forEach(function (v) { if (core.material.icons[v][id] != null) { @@ -1401,10 +1402,12 @@ ui.prototype._drawTextBox_drawTitleAndIcon = function (titleInfo, hPos, vPos, al // --- 勇士 if (titleInfo.image == core.material.images.hero) { if (core.status.hero.animate) { + var direction = core.getHeroLoc('direction'); + if (direction == 'up') direction = 'down'; core.status.boxAnimateObjs.push({ 'bgx': hPos.left + 15, 'bgy': image_top, 'bgWidth': 32, 'bgHeight': titleInfo.height, 'x': hPos.left + 15, 'y': image_top, 'height': titleInfo.height, 'animate': 4, - 'image': titleInfo.image, 'pos': core.material.icons.hero[core.getHeroLoc('direction')].loc * titleInfo.height + 'image': titleInfo.image, 'pos': core.material.icons.hero[direction].loc * titleInfo.height }) } else { core.clearMap('ui', hPos.left + 15, image_top, 32, titleInfo.height); diff --git a/project/functions.js b/project/functions.js index 2ba7ca99..db296e5a 100644 --- a/project/functions.js +++ b/project/functions.js @@ -1287,6 +1287,14 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 判定能否瞬移到该点 if (ignoreSteps == null) ignoreSteps = core.canMoveDirectly(x, y); if (ignoreSteps >= 0) { + // 中毒也允许瞬移 + if (core.hasFlag('poison')) { + var damage = ignoreSteps * core.values.poisonDamage; + if (damage >= core.status.hero.hp) return false; + core.status.hero.statistics.poisonDamage += damage; + core.status.hero.hp -= damage; + } + core.clearMap('hero'); // 获得勇士最后的朝向 var lastDirection = core.status.route[core.status.route.length - 1]; @@ -1301,6 +1309,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 统计信息 core.status.hero.statistics.moveDirectly++; core.status.hero.statistics.ignoreSteps += ignoreSteps; + if (core.hasFlag('poison')) { + core.updateStatusBar(); + } return true; } return false; diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 1c49d733..4883e99d 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -67,7 +67,7 @@ (已完成!) 勇士帧动画 (不处理;现在静止状态可以有帧动画了,所以不考虑行走过程动画) 行走动画 合并main中一些设置内容 -\t[this], 勇士朝下,flag:arg清理,瞬移扣血 +(已完成!) \t[this], 勇士朝下,flag:arg清理,瞬移扣血 -------------