diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 57ff4cb0..07105cb2 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -4060,8 +4060,8 @@ Direction_List /*Direction_List ['up','down','left','right']*/; DirectionEx_List - : '不变'|'朝上'|'朝下'|'朝左'|'朝右'|'左转'|'右转'|'背对' - /*DirectionEx_List ['null','up','down','left','right',':left',':right',':back']*/; + : '不变'|'朝上'|'朝下'|'朝左'|'朝右'|'左转'|'右转'|'背对'|'面对角色'|'背对角色' + /*DirectionEx_List ['null','up','down','left','right',':left',':right',':back',':hero',':backhero']*/; StepString : (Direction_List Int?)+ diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index c1945512..8ee847dd 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -361,23 +361,7 @@ editor_blocklyconfig=(function(){ } ] } - ], 'event'), - '', - MotaActionFunctions.actionParser.parse({ - "trigger": "action", - "displayDamage": true, - "data": [ - ' ... 战前剧情', - {"type": "battle", "id": "greenSlime"}, - ' ... 战后剧情;请注意上面的强制战斗不会使怪物消失', - '需要下一句来调用{"type": "hide"}来隐藏事件', - {"type": "hide"}, - ] - },'event'), - '', - MotaActionFunctions.actionParser.parse([ - {"type": "function", "function": "function(){var x=core.status.event.data.x,y=core.status.event.data.y;if(core.isset(x)&&core.isset(y)){core.insertAction([{type:'hide',loc:[[x-1,y-2],[x,y-2],[x+1,y-2],[x-1,y-1],[x,y-1],[x+1,y-1],[x-1,y],[x+1,y]]}]);}}"}, - ],'afterBattle'), + ], 'event'), '', MotaActionFunctions.actionParser.parse([ { diff --git a/libs/utils.js b/libs/utils.js index b85395b9..89428532 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -864,6 +864,8 @@ utils.prototype.turnDirection = function (turn, direction) { direction = direction || core.getHeroLoc('direction'); var directionList = ["left", "leftup", "up", "rightup", "right", "rightdown", "down", "leftdown"]; if (directionList.indexOf(turn) >= 0) return turn; + if (turn == ':hero') return this.turnDirection(':back', core.getHeroLoc('direction')); + if (turn == ':backhero') return core.getHeroLoc('direction'); if (typeof turn === 'number' && turn % 45 == 0) turn /= 45; else { switch (turn) { diff --git a/project/items.js b/project/items.js index 6c2b4665..d7ba487a 100644 --- a/project/items.js +++ b/project/items.js @@ -382,7 +382,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "cls": "tools", "name": "炸弹", "text": "可以炸掉勇士面前的怪物", - "useItemEffect": "(function () {\n\tvar bombList = []; // 炸掉的怪物坐标列表\n\tvar todo = []; // 炸弹后事件\n\tvar money = 0,\n\t\texp = 0; // 炸弹获得的金币和经验\n\n\tvar canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable || block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.material.enemys[block.event.id];\n\t\treturn enemy && !enemy.notBomb;\n\t};\n\n\tvar bomb = function (x, y) {\n\t\tif (!canBomb(x, y)) return;\n\t\tbombList.push([x, y]);\n\t\tvar id = core.getBlockId(x, y),\n\t\t\tenemy = core.material.enemys[id];\n\t\tmoney += core.getEnemyValue(enemy, 'money', x, y) || 0;\n\t\texp += core.getEnemyValue(enemy, 'exp', x, y) || 0;\n\t\tcore.push(todo, core.floors[core.status.floorId].afterBattle[x + \",\" + y]);\n\t\tcore.push(todo, enemy.afterBattle);\n\t\tcore.removeBlock(x, y);\n\t}\n\n\t// 如果要多方向可炸,把这里的false改成true\n\tif (false) {\n\t\tvar scan = core.utils.scan; // 多方向炸时默认四方向,如果要改成八方向炸可以改成 core.utils.scan2\n\t\tfor (var direction in scan) {\n\t\t\tvar delta = scan[direction];\n\t\t\tbomb(core.getHeroLoc('x') + delta.x, core.getHeroLoc('y') + delta.y);\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tbomb(core.nextX(), core.nextY());\n\t}\n\n\tif (bomb.length == 0) {\n\t\tcore.playSound('操作失败');\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name, itemId);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\tcore.playSound('炸弹');\n\tcore.drawTip(core.material.items[itemId].name + '使用成功', itemId);\n\n\t// 取消这里的注释可以炸弹后获得金币和经验\n\t// core.status.hero.money += money;\n\t// core.status.hero.exp += exp;\n\n\t// 取消这里的注释可以炸弹引发战后事件\n\t// if (todo.length > 0) core.insertAction(todo);\n\n})();", + "useItemEffect": "(function () {\n\tvar bombList = []; // 炸掉的怪物坐标列表\n\tvar todo = []; // 炸弹后事件\n\tvar money = 0,\n\t\texp = 0; // 炸弹获得的金币和经验\n\n\tvar canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable || block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.material.enemys[block.event.id];\n\t\treturn enemy && !enemy.notBomb;\n\t};\n\n\tvar bomb = function (x, y) {\n\t\tif (!canBomb(x, y)) return;\n\t\tbombList.push([x, y]);\n\t\tvar id = core.getBlockId(x, y),\n\t\t\tenemy = core.material.enemys[id];\n\t\tmoney += core.getEnemyValue(enemy, 'money', x, y) || 0;\n\t\texp += core.getEnemyValue(enemy, 'exp', x, y) || 0;\n\t\tcore.push(todo, core.floors[core.status.floorId].afterBattle[x + \",\" + y]);\n\t\tcore.push(todo, enemy.afterBattle);\n\t\tcore.removeBlock(x, y);\n\t}\n\n\t// 如果要多方向可炸,把这里的false改成true\n\tif (false) {\n\t\tvar scan = core.utils.scan; // 多方向炸时默认四方向,如果要改成八方向炸可以改成 core.utils.scan2\n\t\tfor (var direction in scan) {\n\t\t\tvar delta = scan[direction];\n\t\t\tbomb(core.getHeroLoc('x') + delta.x, core.getHeroLoc('y') + delta.y);\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tbomb(core.nextX(), core.nextY());\n\t}\n\n\tif (bombList.length == 0) {\n\t\tcore.playSound('操作失败');\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name, itemId);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\tcore.playSound('炸弹');\n\tcore.drawTip(core.material.items[itemId].name + '使用成功', itemId);\n\n\t// 取消这里的注释可以炸弹后获得金币和经验\n\t// core.status.hero.money += money;\n\t// core.status.hero.exp += exp;\n\n\t// 取消这里的注释可以炸弹引发战后事件\n\t// if (todo.length > 0) core.insertAction(todo);\n\n})();", "canUseItemEffect": "true" }, "centerFly": {