diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index dc9a423b..217ea594 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -3636,6 +3636,8 @@ expression | isShopVisited_e | hasEquip_e | canBattle_e + | damage_e + | damage_1_e | rand_e | evalString_e @@ -3875,6 +3877,33 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; +damage_e + : '战斗伤害' '怪物ID' IdString + +/* damage_e +default : ['greenSlime'] +allEnemys : ['IdString_0'] +var code = 'core.getDamage(\'' + IdString_0 + '\')'; +return [code, Blockly.JavaScript.ORDER_ATOMIC]; +*/; + + +damage_1_e + : '战斗伤害' '点坐标' 'x' PosString 'y' PosString + +/* damage_1_e +default : [0, 0] +if (PosString_0.startsWith('"')) { + PosString_0 = PosString_0.substring(1, PosString_0.length - 1); +} +if (PosString_1.startsWith('"')) { + PosString_1 = PosString_1.substring(1, PosString_1.length - 1); +} +var code = 'core.getDamage(null, ' + PosString_0 + ',' + PosString_1 + ')'; +return [code, Blockly.JavaScript.ORDER_ATOMIC]; +*/; + + rand_e : '随机数 [0, ' Int ')' diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index 0dc19af8..5d95776b 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -290,6 +290,8 @@ editor_blocklyconfig=(function(){ MotaActionBlocks['hasVisitedFloor_e'].xmlText(), MotaActionBlocks['isShopVisited_e'].xmlText(), MotaActionBlocks['canBattle_e'].xmlText(), + MotaActionBlocks['damage_e'].xmlText(), + MotaActionBlocks['damage_1_e'].xmlText(), MotaActionBlocks['rand_e'].xmlText(), MotaActionBlocks['evalString_e'].xmlText(), ], diff --git a/libs/enemys.js b/libs/enemys.js index 5ab31a09..5cf7659f 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -401,8 +401,9 @@ enemys.prototype.getDamage = function (enemy, x, y, floorId) { } enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) { - if (enemy == null) return null; + if (enemy == null) enemy = core.getBlockId(x, y, floorId); if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; + if (enemy == null) return null; var info = this.getDamageInfo(enemy, hero, x, y, floorId); if (info == null) return null; diff --git a/project/functions.js b/project/functions.js index 796c6327..a05e80b7 100644 --- a/project/functions.js +++ b/project/functions.js @@ -245,6 +245,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }); core.push(actions, [ { "type": "waitAsync" }, // 等待所有异步事件执行完毕 + { "type": "setBlock", "number": enemyId, "loc": [[x, y]]}, // 重新设置怪物自身 { "type": "battle", "loc": [x, y] } // 重要!重新触发本次战斗 ]); core.insertAction(actions);