diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index bc8dceaa..20f65ae5 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -617,7 +617,7 @@ return code; faceIds_m - : '行走图朝向:' BGNL? Newline '向上ID' IdString? '向下ID' IdString? '向左ID' IdString? '向右ID' IdString? BEND + : '行走图朝向:' BGNL? Newline '向下ID' IdString? '向左ID' IdString? '向右ID' IdString? '向上ID' IdString? BEND /* faceIds_m @@ -626,10 +626,10 @@ default : ["","","",""] allIds : ['IdString_0','IdString_1','IdString_2','IdString_3'] helpUrl : /_docs/#/instruction return '{' + [ - IdString_0 && ('"up": "' + IdString_0 +'"'), - IdString_1 && ('"down": "' + IdString_1 +'"'), - IdString_2 && ('"left": "' + IdString_2 +'"'), - IdString_3 && ('"right": "' + IdString_3 +'"'), + IdString_0 && ('"down": "' + IdString_0 +'"'), + IdString_1 && ('"left": "' + IdString_1 +'"'), + IdString_2 && ('"right": "' + IdString_2 +'"'), + IdString_3 && ('"up": "' + IdString_3 +'"'), ].filter(function (x) { return x; }).join(', ') + '}\n'; */; diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index 9b40faba..2fb804b4 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -115,7 +115,7 @@ ActionParser.prototype.parse = function (obj,type) { case 'faceIds': if(!obj) obj={}; - return MotaActionBlocks['faceIds_m'].xmlText([obj.up||"", obj.down||"", obj.left||"", obj.right||""]); + return MotaActionBlocks['faceIds_m'].xmlText([obj.down||"", obj.left||"", obj.right||"", obj.up||""]); case 'mainStyle': if(!obj) obj={}; diff --git a/_server/editor_file.js b/_server/editor_file.js index 8ce57667..ec0cbb20 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -306,7 +306,8 @@ editor_file = function (editor, callback) { callback('不能对自动元件进行自动注册!'); return; } - if (image=='npc48' && confirm("你想绑定npc48的朝向么?\n如果是,则会将最后四个npc48的faceIds进行自动绑定。")) { + if ((image=='npcs' || image=='npc48' || image == 'enemys' || image == 'enemy48') + && confirm("你想绑定图块的朝向么?\n如果是,则会将最后四个注册图块的faceIds进行自动绑定。")) { bindFaceIds = true; } var c=image.toUpperCase().charAt(0); @@ -353,10 +354,17 @@ editor_file = function (editor, callback) { var i = faceIds.length - 4; var down = faceIds[i], left = faceIds[i+1], right = faceIds[i+2], up = faceIds[i+3]; var obj = {down: down.id, left: left.id, right: right.id, up: up.id}; - mapActions.push(["add", "['" + down.idnum + "']['faceIds']", obj]); - mapActions.push(["add", "['" + left.idnum + "']['faceIds']", obj]); - mapActions.push(["add", "['" + right.idnum + "']['faceIds']", obj]); - mapActions.push(["add", "['" + up.idnum + "']['faceIds']", obj]); + if (image.indexOf('enemy')==0) { + templateActions.push(["add", "['" + down.id + "']['faceIds']", obj]); + templateActions.push(["add", "['" + left.id + "']['faceIds']", obj]); + templateActions.push(["add", "['" + right.id + "']['faceIds']", obj]); + templateActions.push(["add", "['" + up.id + "']['faceIds']", obj]); + } else { + mapActions.push(["add", "['" + down.idnum + "']['faceIds']", obj]); + mapActions.push(["add", "['" + left.idnum + "']['faceIds']", obj]); + mapActions.push(["add", "['" + right.idnum + "']['faceIds']", obj]); + mapActions.push(["add", "['" + up.idnum + "']['faceIds']", obj]); + } } } diff --git a/_server/table/comment.js b/_server/table/comment.js index 72d68466..33ed27ac 100644 --- a/_server/table/comment.js +++ b/_server/table/comment.js @@ -135,6 +135,13 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "手册ID", "_data": "在怪物手册中映射到的怪物ID。如果此项不为null,则在怪物手册中,将用目标ID来替换该怪物原本的ID。常被运用在同一个怪物的多朝向上。" }, + "faceIds": { + "_leaf": true, + "_type": "event", + "_event": "faceIds", + "_docs": "行走图朝向", + "_data": "行走图朝向。在勇士撞上图块时,或图块在移动时,会自动选择最合适的朝向图块(如果存在定义)来进行绘制。" + }, "hp": { "_leaf": true, "_type": "textarea", @@ -374,7 +381,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_type": "event", "_event": "faceIds", "_docs": "行走图朝向", - "_data": "行走图朝向,仅对npc48有效。在勇士撞上NPC时,或NPC在移动时,会自动选择最合适的朝向图块(如果存在定义)来进行绘制。" + "_data": "行走图朝向。在勇士撞上图块时,或图块在移动时,会自动选择最合适的朝向图块(如果存在定义)来进行绘制。" } } }, diff --git a/libs/enemys.js b/libs/enemys.js index 46a1d93f..bc0eb169 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -30,6 +30,16 @@ enemys.prototype.getEnemys = function () { } } } + // 将所有怪物的各项属性映射到朝下的 + for (var id in enemys) { + if (enemys[id].faceIds) { + var downId = enemys[id].faceIds.down; + if (downId != null && downId != id && enemys[downId]) { + enemys[id] = core.clone(enemys[downId]); + enemys[id].id = id; + } + } + } return enemys; } @@ -365,8 +375,8 @@ enemys.prototype._getCurrentEnemys_getEnemy = function (enemyId) { var enemy = core.material.enemys[enemyId]; if (!enemy) return null; - // 检查displayIdInBook - return core.material.enemys[enemy.displayIdInBook] || enemy; + // 检查朝向;displayIdInBook + return core.material.enemys[(enemy.faceIds || {}).down] || core.material.enemys[enemy.displayIdInBook] || enemy; } enemys.prototype._getCurrentEnemys_addEnemy = function (enemyId, enemys, used, x, y, floorId) { diff --git a/libs/events.js b/libs/events.js index 38695075..ba9b29f5 100644 --- a/libs/events.js +++ b/libs/events.js @@ -419,6 +419,17 @@ events.prototype._trigger_ignoreChangeFloor = function (block) { } events.prototype._sys_battle = function (data, callback) { + // 检查是否需要改变朝向 + if (data.x == core.nextX() && data.y == core.nextY()) { + var dir = core.turnDirection(":back"); + var id = data.event.id, toId = (data.event.faceIds || {})[dir]; + if (toId && id != toId) { + var number = core.getNumberById(toId); + if (number > 0) + core.setBlock(number, data.x, data.y); + } + } + // 检查战前事件 var beforeBattle = []; core.push(beforeBattle, core.floors[core.status.floorId].beforeBattle[data.x + "," + data.y]); diff --git a/libs/maps.js b/libs/maps.js index c2eb38de..9f3c8525 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -218,6 +218,14 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { } delete block.event.canPass; + // 增加怪物的faceIds + if (block.event.cls.indexOf("enemy") ==0 ) { + var enemy = core.material.enemys[block.event.id]; + if (enemy && enemy.faceIds) { + block.event.faceIds = enemy.faceIds; + } + } + if (addInfo) this._addInfo(block); if (eventFloor) { this._addEvent(block, x, y, (eventFloor.events || {})[x + "," + y]); @@ -1883,6 +1891,12 @@ maps.prototype.searchBlockWithFilter = function (blockFilter, floorId, showDisab return result; } +////// 获得某个图块,其行走图朝向朝下的图块ID ////// +maps.prototype.getFaceDownId = function (block) { + if (block == null || !block.event) return null; + return (block.event.faceIds || {}).down || block.event.id; +} + // -------- 启用/禁用图块,楼层贴图 -------- // ////// 将某个块从禁用变成启用状态 //////