diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index e870f95b..50d1db34 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -236,7 +236,8 @@ action | show_s | hide_s | trigger_s - | insert_s + | insert_1_s + | insert_2_s | revisit_s | exit_s | setBlock_s @@ -599,13 +600,26 @@ var code = '{"type": "trigger", "loc": ['+PosString_0+','+PosString_1+']},\n'; return code; */; -insert_s +insert_1_s + : '插入公共事件' EvalString Newline + + +/* insert_1_s +tooltip : insert: 插入公共事件并执行 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%85%ac%e5%85%b1%e4%ba%8b%e4%bb%b6%e6%88%96%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6%e5%b9%b6%e6%89%a7%e8%a1%8c +default : ["加点事件"] +colour : this.eventColor +var code = '{"type": "insert", "name": "'+EvalString_0+'"},\n'; +return code; +*/; + +insert_2_s : '插入事件' 'x' PosString ',' 'y' PosString '楼层' IdString? Newline -/* insert_s +/* insert_2_s tooltip : insert: 立即插入另一个地点的事件执行,当前事件不会中断,事件坐标不会改变 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%85%ac%e5%85%b1%e4%ba%8b%e4%bb%b6%e6%88%96%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6%e5%b9%b6%e6%89%a7%e8%a1%8c default : ["0","0",""] colour : this.eventColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); @@ -2279,8 +2293,14 @@ ActionParser.prototype.parseAction = function() { data.loc[0],data.loc[1],this.next]); break; case "insert": // 强制插入另一个点的事件在当前事件列表执行,当前坐标和楼层不会改变 - this.next = MotaActionBlocks['insert_s'].xmlText([ - data.loc[0],data.loc[1],data.floorId||'',this.next]); + if (this.isset(data.name)) { + this.next = MotaActionBlocks['insert_1_s'].xmlText([ + data.name, this.next]); + } + else { + this.next = MotaActionBlocks['insert_2_s'].xmlText([ + data.loc[0],data.loc[1],data.floorId||'',this.next]); + } break; case "playSound": this.next = MotaActionBlocks['playSound_s'].xmlText([ diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 910e6188..f002293a 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -117,7 +117,8 @@ editor_blockly = function () { MotaActionBlocks['hideBgFgMap_s'].xmlText(), MotaActionBlocks['setBgFgBlock_s'].xmlText(), MotaActionBlocks['trigger_s'].xmlText(), - MotaActionBlocks['insert_s'].xmlText(), + MotaActionBlocks['insert_1_s'].xmlText(), + MotaActionBlocks['insert_2_s'].xmlText(), MotaActionBlocks['move_s'].xmlText(), MotaActionBlocks['jump_s'].xmlText(), MotaActionBlocks['disableShop_s'].xmlText(), @@ -597,7 +598,8 @@ function omitedcheckUpdateFunction(event) { 'exit_s', 'revisit_s', 'sleep_s', - 'setBlock_s' + 'setBlock_s', + 'insert_1_s' ]; // 最常用的15个图块 editor_blockly.lastUsedTypeNum=15; diff --git a/_server/editor_mode.js b/_server/editor_mode.js index b4813d4f..c97db93f 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -225,21 +225,29 @@ editor_mode = function (editor) { editor_mode.addAction(['delete', field, undefined]); editor_mode.onmode('save');//自动保存 删掉此行的话点保存按钮才会保存 } else { - printe(field + ' : 该值不允许为null,无法删除'); + printe(field + ' : 该值不允许为null,无法删除'); } } var addfunc=function(){ editor_mode.onmode(editor_mode._ids[modeNode.getAttribute('id')]); + + var mode = document.getElementById('editModeSelect').value; + // 1.输入id - var newid=prompt('请输入新项的id'); + var newid=prompt('请输入新项的ID(仅公共事件支持中文ID)'); if (newid == null || newid.length==0) { return; } - // 2.检查id是否符合规范或与已有id重复 - if (!/^[a-zA-Z0-9_]+$/.test(newid)){ - printe('id不符合规范, 请使用大小写字母数字下划线来构成'); - return; + + // 检查commentEvents + if (mode !== 'commonevent') { + // 2.检查id是否符合规范或与已有id重复 + if (!/^[a-zA-Z0-9_]+$/.test(newid)){ + printe('id不符合规范, 请使用大小写字母数字下划线来构成'); + return; + } } + var conflict=true; var basefield=field.replace(/\[[^\[]*\]$/,''); if (basefield==="['main']"){ @@ -1188,11 +1196,11 @@ editor_mode = function (editor) { editor_mode.changeDoubleClickModeByButton=function(mode){ ({ delete:function(){ - printf('下一次双击表格的项删除, 编辑后刷新浏览器生效 (正常模式下双击是用事件或文本编辑器编辑);切换下拉菜单可取消。'); + printf('下一次双击表格的项删除,切换下拉菜单可取消;编辑后需刷新浏览器生效。'); editor_mode.doubleClickMode=mode; }, add:function(){ - printf('下一次双击表格的项, 在同级添加新项, 编辑后刷新浏览器生效 (正常模式下双击是用事件或文本编辑器编辑);切换下拉菜单可取消。'); + printf('下一次双击表格的项则在同级添加新项,切换下拉菜单可取消;编辑后需刷新浏览器生效。'); editor_mode.doubleClickMode=mode; } }[mode])(); diff --git a/_server/events.comment.js b/_server/events.comment.js index 157becee..62fdbfef 100644 --- a/_server/events.comment.js +++ b/_server/events.comment.js @@ -8,19 +8,19 @@ var events_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "object", "_data": function (key) { var obj = { - "addPoint": { + "加点事件": { "_leaf": true, "_type": "event", "_range": "thiseval instanceof Array", "_event": "commonEvent", - "_data": "加点事件,可以双击进入事件编辑器" + "_data": "打败怪物后进行加点" }, - "test": { + "毒衰咒处理": { "_leaf": true, "_type": "event", "_range": "thiseval instanceof Array", "_event": "commonEvent", - "_data": "测试事件, events.comment.js中标记了_range不能为null, 所以应该无法删除" + "_data": "对毒衰咒效果进行的处理" }, } if (obj[key]) return obj[key]; diff --git a/docs/api.md b/docs/api.md index 283e0720..62fcc252 100644 --- a/docs/api.md +++ b/docs/api.md @@ -124,6 +124,9 @@ core.insertAction(list, x, y, callback) x和y如果设置则覆盖"当前事件点"的坐标,callback如果设置则覆盖事件执行完毕后的回调函数。 例如: core.insertAction(["楼层切换", {"type":"changeFloor", "floorId": "MT3"}]) 将依次显示剧情文本,并执行一个楼层切换的自定义事件。 +-------- +从V2.5.4开始提出了“公共事件”的说法,这里也可以插入一个公共事件名。 +例如:core.insertAction("毒衰咒处理") 将插入公共事件“毒衰咒处理”。 core.changeFloor(floorId, stair, heroLoc, time, callback) [异步] @@ -430,6 +433,10 @@ core.events.doAction() 执行下一个事件。此函数中将对所有自定义事件类型分别处理。 +core.events.getCommonEvent(name) +根据名称获得一个公共事件;如果不存在对应的公共事件则返回null。 + + core.events.openShop(shopId, needVisited) [异步] 打开一个全局商店。needVisited表示是否需要该商店已被打开过。 @@ -610,6 +617,10 @@ core.utils.cropImage(image, size) 纵向对图片进行切分(裁剪)。 +core.utils.push(a,b) +向某个数组后插入另一个数组或元素 + + core.utils.unshift(a, b) 向某个数组前插入另一个数组或元素 diff --git a/docs/event.md b/docs/event.md index 4259f2c5..5ebc9ad7 100644 --- a/docs/event.md +++ b/docs/event.md @@ -573,23 +573,29 @@ NPC对话事件结束后如果需要NPC消失也需要调用 `{"type": "hide"}` 例如上面这个例子,下面的文字将不会再被显示,而是直接跳转到`"3,6"`对应的事件列表从头执行。 -### insert:插入另一个地点的事件 +### insert:插入公共事件或另一个地点的事件并执行 -`{"type":"insert"}` 会插入另一个地点的事件执行。 +`{"type":"insert"}` 会插入公共事件或另一个地点的事件并执行。 其基本写法如下: ``` js "x,y": [ // 实际执行的事件列表 + {"type": "insert", "name": "加点事件"}, // 插入公共事件:加点事件 + {"type": "insert", "name": "毒衰咒处理"}, // 插入公共事件:毒衰咒处理 {"type": "insert", "loc": [3,6]}, // 插入[3,6]点的事件并执行 {"type": "insert", "loc": [10,10], "floorId": "MT1"}, // 插入MT1层[10,10]点的事件并执行 "上面的插入事件执行完毕后会接着继续执行后面的事件" ] ``` -loc是必须的,代表另一个地点的坐标。 +`insert`的写法有两种,可以写`name`,或者`loc`。 -floorId可选,代表另一个地点所在的楼层;如果不写则默认为当前层。 +- 如果写了`"name": "xxx"`,则会去公共事件列表中找寻对应的事件,并执行。 + - name为公共事件的名称,如果对应公共事件不存在则跳过。 +- 否则,如果写了`"loc": [x,y]`,则会插入另一个地点的事件 + - loc为另一个地点的坐标 + - floorId可选,代表另一个地点所在的楼层;如果不写则默认为当前层。 和`type:trigger`不同的是,**`type:trigger`是立刻将当前事件结束(剩下所有内容都忽略),然后重新启动另一个地点的action事件。** @@ -597,8 +603,6 @@ floorId可选,代表另一个地点所在的楼层;如果不写则默认为 **这个过程中,当前事件不会被结束,当前的楼层和事件坐标不会发生改变。** 插入的事件执行完毕后,会继续执行接下来的内容。 -我们某个事件写在某个角落的墙上然后远程调用,从而达到“公共事件”的效果。 - ### revisit:立即重启当前事件 revisit和trigger完全相同,只不过是立刻触发的还是本地点的事件 diff --git a/docs/img/commonEvent.png b/docs/img/commonEvent.png new file mode 100644 index 00000000..d6358b89 Binary files /dev/null and b/docs/img/commonEvent.png differ diff --git a/docs/img/plugin.png b/docs/img/plugin.png index 4e87fa84..5c65cd4d 100644 Binary files a/docs/img/plugin.png and b/docs/img/plugin.png differ diff --git a/docs/personalization.md b/docs/personalization.md index 7a4859df..cf2709a0 100644 --- a/docs/personalization.md +++ b/docs/personalization.md @@ -543,18 +543,17 @@ case 89: // 使用该按键的keyCode,比如Y键就是89 ## 公共事件 -从2.5.1开始,H5提供了`{"type":"insert"}`事件,完美支持了公共事件的写法。 +从V2.5.4开始,样板提供了“公共事件”下拉框,我们可以在里面用事件编辑器进行编辑,并通过`{"type":"insert"}`进行调用。 -我们只需要将需要的公共事件放在某个角落的墙上(或者甚至单独弄一层专门摆放公共事件),并使用“插入事件”,即可进行调用。 +![公共事件](./img/commonEvent.png) -具体详见[插入另一个地点的事件](event#insert:插入另一个地点的事件)。 +具体详见[插入公共事件或另一个地点的事件并执行](event#insert:插入公共事件或另一个地点的事件并执行)。 -当然,继续使用**插件**的写法也是可以的。具体参见“脚本编辑 - 插件编写”。 +当然,继续使用**插件**的写法也是可以的。 - +网站上也提供了一个[插件库](https://h5mota.com/plugins/),欢迎大家把自己写的插件进行共享。 ## 标题界面事件化 diff --git a/libs/control.js b/libs/control.js index b0c76fd2..3df0d0ac 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1416,6 +1416,7 @@ control.prototype.screenFlash = function (color, time, times, callback) { control.prototype.updateDamage = function (floorId, canvas) { floorId = floorId || core.status.floorId; if (!core.isset(floorId)) return; + if (core.status.gameOver) return; if (!core.isset(canvas)) { canvas = core.canvas.damage; core.clearMap('damage'); diff --git a/libs/core.js b/libs/core.js index 8e7a03ec..54f01b97 100644 --- a/libs/core.js +++ b/libs/core.js @@ -1071,6 +1071,11 @@ core.prototype.unshift = function (a,b) { return core.utils.unshift(a,b); } +////// 向某个数组后插入另一个数组或元素 ////// +core.prototype.push = function (a,b) { + return core.utils.push(a,b); +} + ////// 设置本地存储 ////// core.prototype.setLocalStorage = function(key, value) { return core.utils.setLocalStorage(key, value); @@ -1388,6 +1393,11 @@ core.prototype.insertAction = function (list, x, y, callback) { core.events.insertAction(list, x, y, callback); } +////// 获得一个公共事件内容 ////// +core.prototype.getCommonEvent = function (name) { + return core.events.getCommonEvent(name); +} + ////// 锁定状态栏,常常用于事件处理 ////// core.prototype.lockControl = function () { core.control.lockControl(); diff --git a/libs/events.js b/libs/events.js index 6dd7c25b..0100662b 100644 --- a/libs/events.js +++ b/libs/events.js @@ -7,6 +7,7 @@ function events() { ////// 初始化 ////// events.prototype.init = function () { this.eventdata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.events; + this.commonEvent = events_c12a15a8_c380_4b28_8144_256cba95f760.commonEvent; this.events = { 'battle': function (data, core, callback) { // 正在执行自定义事件:不允许战斗 @@ -911,7 +912,14 @@ events.prototype.doAction = function() { break; } case "insert": - { + if (core.isset(data.name)) { + // ----- 公共事件 + var commonEvent = this.getCommonEvent(data.name); + if (core.isset(commonEvent)) { + core.insertAction(commonEvent); + } + } + else { var toX=core.calValue(data.loc[0], prefix), toY=core.calValue(data.loc[1], prefix); var floorId = data.floorId || core.status.floorId; var event = core.floors[floorId].events[toX+","+toY]; @@ -920,9 +928,9 @@ events.prototype.doAction = function() { if (typeof event == 'string' || event instanceof Array || core.isset(event.type)) core.insertAction(event); } - this.doAction(); - break; } + this.doAction(); + break; case "playSound": if (!core.isReplaying()) core.playSound(data.name); @@ -1313,6 +1321,13 @@ events.prototype.doAction = function() { events.prototype.insertAction = function (action, x, y, callback) { if (core.hasFlag("__statistics__")) return; + // ------ 判定commonEvent + var commonEvent = this.getCommonEvent(action); + if (core.isset(commonEvent) && commonEvent instanceof Array) { + action = commonEvent; + } + if (!core.isset(action)) return; + if (core.status.event.id != 'action') { this.doEvents(action, x, y, callback); } @@ -1339,6 +1354,12 @@ events.prototype.recoverEvents = function (data) { return false; } +////// 获得一个公共事件 ////// +events.prototype.getCommonEvent = function (name) { + if (!core.isset(name) || !(typeof name === 'string')) return null; + return this.commonEvent[name] || null; +} + ////// 获得面前的物品(轻按) ////// events.prototype.getNextItem = function() { if (!core.status.heroStop || !core.flags.enableGentleClick) return false; @@ -2041,24 +2062,16 @@ events.prototype.passNet = function (data) { // core.drawTip('经过血网,生命-'+core.values.lavaDamage); } if (data.event.id=='poisonNet') { // 毒网 - if (core.hasFlag('poison')) return; - core.setFlag('poison', true); + core.setFlag('debuff', 'poison'); + core.insertAction('毒衰咒处理'); } - if (data.event.id=='weakNet') { // 衰网 - if (core.hasFlag('weak')) return; - core.setFlag('weak', true); - if (core.values.weakValue>=1) { // >=1:直接扣数值 - core.status.hero.atk -= core.values.weakValue; - core.status.hero.def -= core.values.weakValue; - } - else { // <1:扣比例 - core.setFlag("equip_atk_buff", core.getFlag("equip_atk_buff", 1) - core.values.weakValue); - core.setFlag("equip_def_buff", core.getFlag("equip_def_buff", 1) - core.values.weakValue); - } + else if (data.event.id=='weakNet') { // 衰网 + core.setFlag('debuff', 'weak'); + core.insertAction('毒衰咒处理'); } - if (data.event.id=='curseNet') { // 咒网 - if (core.hasFlag('curse')) return; - core.setFlag('curse', true); + else if (data.event.id=='curseNet') { // 咒网 + core.setFlag('debuff', 'curse'); + core.insertAction('毒衰咒处理'); } core.updateStatusBar(); } diff --git a/libs/ui.js b/libs/ui.js index 09eac7cc..a589431e 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -563,6 +563,9 @@ ui.prototype.drawTextBox = function(content, showAll) { py=core.getHeroLoc('y'); ydelta = core.material.icons.hero.height-32; } + else if (ss[1] == 'null') { + px = py = null; + } else if (ss.length>=3) { px=parseInt(ss[1]); py=parseInt(ss[2]); diff --git a/libs/utils.js b/libs/utils.js index 3c65d624..a8751ef4 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -62,17 +62,17 @@ utils.prototype.replaceText = function (text, need, times) { ////// 计算表达式的值 ////// utils.prototype.calValue = function (value, prefix, need, times) { if (!core.isset(value)) return value; - if (typeof value == 'number') { - return value; + if (typeof value === 'string') { + value=value.replace(/status:([\w\d_]+)/g, "core.getStatus('$1')"); + value=value.replace(/item:([\w\d_]+)/g, "core.itemCount('$1')"); + value=value.replace(/flag:([\w\d_]+)/g, "core.getFlag('$1', 0)"); + value=value.replace(/switch:([\w\d_]+)/g, "core.getFlag('"+(prefix||"global")+"@$1', 0)"); + return eval(value); } if (value instanceof Function) { return value(); } - value=value.replace(/status:([\w\d_]+)/g, "core.getStatus('$1')"); - value=value.replace(/item:([\w\d_]+)/g, "core.itemCount('$1')"); - value=value.replace(/flag:([\w\d_]+)/g, "core.getFlag('$1', 0)"); - value=value.replace(/switch:([\w\d_]+)/g, "core.getFlag('"+(prefix||"global")+"@$1', 0)"); - return eval(value); + return value; } ////// 字符串自动换行的分割 ////// @@ -116,6 +116,18 @@ utils.prototype.unshift = function (a,b) { return a; } +////// 向某个数组后插入另一个数组或元素 ////// +utils.prototype.push = function (a,b) { + if (!(a instanceof Array) || !core.isset(b)) return; + if (b instanceof Array) { + core.clone(b).forEach(function (e) { + a.push(e); + }); + } + else a.push(b); + return a; +} + ////// 设置本地存储 ////// utils.prototype.setLocalStorage = function(key, value) { try { diff --git a/project/events.js b/project/events.js index 8b4db61d..0e82a912 100644 --- a/project/events.js +++ b/project/events.js @@ -1,14 +1,167 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 = { "commonEvent": { - "addPoint": [ - "" + "加点事件": [ + { + "type": "comment", + "text": "flag:point表示当前应该的加点数值" + }, + { + "type": "choices", + "choices": [ + { + "text": "攻击+${1*flag:point}", + "action": [ + { + "type": "setValue", + "name": "status:atk", + "value": "status:atk+1*flag:point" + } + ] + }, + { + "text": "防御+${2*flag:point}", + "action": [ + { + "type": "setValue", + "name": "status:def", + "value": "status:def+2*flag:point" + } + ] + }, + { + "text": "生命+${200*flag:point}", + "action": [ + { + "type": "setValue", + "name": "status:hp", + "value": "status:hp+200*flag:point" + } + ] + } + ] + }, + { + "type": "setValue", + "name": "flag:point", + "value": "null" + } ], - "test": [ - "应该无法删除" - ], - "test2": [ - "应该可以删除" + "毒衰咒处理": [ + { + "type": "comment", + "text": "获得毒衰咒效果,flag:debuff为要获得的类型" + }, + { + "type": "switch", + "condition": "flag:debuff", + "caseList": [ + { + "case": "'poison'", + "action": [ + { + "type": "comment", + "text": "获得毒效果" + }, + { + "type": "if", + "condition": "!flag:poison", + "true": [ + { + "type": "setValue", + "name": "flag:poison", + "value": "true" + } + ], + "false": [] + } + ] + }, + { + "case": "'weak'", + "action": [ + { + "type": "comment", + "text": "获得衰效果" + }, + { + "type": "if", + "condition": "!flag:weak", + "true": [ + { + "type": "setValue", + "name": "flag:weak", + "value": "true" + }, + { + "type": "if", + "condition": "core.values.weakValue>=1", + "true": [ + { + "type": "comment", + "text": ">=1:直接扣数值" + }, + { + "type": "setValue", + "name": "status:atk", + "value": "status:atk-core.values.weakValue" + }, + { + "type": "setValue", + "name": "status:def", + "value": "status:def-core.values.weakValue" + } + ], + "false": [ + { + "type": "comment", + "text": "<1:扣比例" + }, + { + "type": "setValue", + "name": "flag:equip_atk_buff", + "value": "core.getFlag('equip_atk_buff',1)-core.values.weakValue" + }, + { + "type": "setValue", + "name": "flag:equip_def_buff", + "value": "core.getFlag('equip_def_buff',1)-core.values.weakValue" + } + ] + } + ], + "false": [] + } + ] + }, + { + "case": "'curse'", + "action": [ + { + "type": "comment", + "text": "获得咒效果" + }, + { + "type": "if", + "condition": "!flag:curse", + "true": [ + { + "type": "setValue", + "name": "flag:curse", + "value": "true" + } + ], + "false": [] + } + ] + } + ] + }, + { + "type": "setValue", + "name": "flag:debuff", + "value": "null" + } ] } } \ No newline at end of file diff --git a/project/functions.js b/project/functions.js index b625a2c6..e55d3f73 100644 --- a/project/functions.js +++ b/project/functions.js @@ -168,21 +168,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (!core.flags.enableAddPoint || !core.isset(point) || point<=0) return []; // 加点,返回一个choices事件 - return [ - {"type": "choices", - "choices": [ - {"text": "攻击+"+(1*point), "action": [ - {"type": "setValue", "name": "status:atk", "value": "status:atk+"+(1*point)} - ]}, - {"text": "防御+"+(2*point), "action": [ - {"type": "setValue", "name": "status:def", "value": "status:def+"+(2*point)} - ]}, - {"text": "生命+"+(200*point), "action": [ - {"type": "setValue", "name": "status:hp", "value": "status:hp+"+(200*point)} - ]}, - ] - } - ]; + // ----- 从V2.5.4开始,移动到“公共事件-加点事件”中 + core.setFlag('point', point); // 设置flag:point + return core.getCommonEvent('加点事件'); }, "afterBattle": function(enemyId,x,y,callback) { // 战斗结束后触发的事件 @@ -236,27 +224,24 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.removeBlock(x, y); } - // 毒衰咒的处理 + // 事件的处理 + var todo = []; + var special = enemy.special; // 中毒 - if (core.enemys.hasSpecial(special, 12) && !core.hasFlag('poison')) { - core.setFlag('poison', true); + if (core.enemys.hasSpecial(special, 12)) { + core.push(todo, [{"type": "setValue", "name": "flag:debuff", "value": "'poison'"}]); + core.push(todo, [{"type": "insert", "name": "毒衰咒处理"}]); } // 衰弱 - if (core.enemys.hasSpecial(special, 13) && !core.hasFlag('weak')) { - core.setFlag('weak', true); - if (core.values.weakValue>=1) { // >=1:直接扣数值 - core.status.hero.atk -= core.values.weakValue; - core.status.hero.def -= core.values.weakValue; - } - else { // <1:扣比例 - core.setFlag("equip_atk_buff", core.getFlag("equip_atk_buff", 1) - core.values.weakValue); - core.setFlag("equip_def_buff", core.getFlag("equip_def_buff", 1) - core.values.weakValue); - } + if (core.enemys.hasSpecial(special, 13)) { + core.push(todo, [{"type": "setValue", "name": "flag:debuff", "value": "'weak'"}]); + core.push(todo, [{"type": "insert", "name": "毒衰咒处理"}]); } // 诅咒 - if (core.enemys.hasSpecial(special, 14) && !core.hasFlag('curse')) { - core.setFlag('curse', true); + if (core.enemys.hasSpecial(special, 14)) { + core.push(todo, [{"type": "setValue", "name": "flag:debuff", "value": "'curse'"}]); + core.push(todo, [{"type": "insert", "name": "毒衰咒处理"}]); } // 仇恨属性:减半 if (core.flags.hatredDecrease && core.enemys.hasSpecial(special, 17)) { @@ -287,30 +272,24 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setFlag('skill', 0); core.setFlag('skillName', '无'); } - core.updateStatusBar(); - - // 事件的处理 - var todo = []; - // 如果该点存在,且有事件 -- V2.5.4 以后阻击怪也可以有战后事件了 - if (core.isset(x) && core.isset(y)) { - var event = core.floors[core.status.floorId].afterBattle[x+","+y]; - if (core.isset(event)) { - // 插入事件 - core.unshift(todo, event); - } - } // 如果有加点 var point = core.material.enemys[enemyId].point; - if (core.isset(point) && point>0) { - core.unshift(todo, core.events.addPoint(core.material.enemys[enemyId])); + if (core.flags.enableAddPoint && core.isset(point) && point>0) { + core.push(todo, [{"type": "setValue", "name": "flag:point", "value": point}]); + core.push(todo, [{"type": "insert", "name": "加点事件"}]); + } + + // 如果该点存在,且有事件 -- V2.5.4 以后阻击怪也可以有战后事件了 + if (core.isset(x) && core.isset(y)) { + core.push(todo, core.floors[core.status.floorId].afterBattle[x+","+y]); } // 在这里增加其他的自定义事件需求 /* if (enemyId=='xxx') { - core.unshift(todo, [ + core.push(todo, [ {"type": "...", ...}, ]); } @@ -1182,7 +1161,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = 'redJewel', 'blueJewel', 'greenJewel', 'yellowJewel', 'redPotion', 'bluePotion', 'greenPotion', 'yellowPotion', 'superPotion', 'pickaxe', 'bomb', 'centerFly', 'icePickaxe', 'snow', - 'earthquake', 'upFly', 'downFly', 'jumpShoes', 'lifeWand', + 'earthquake', 'upFly', 'downFly', 'jumpShoes', 'lifeWand', 'poisonWine', 'weakWine', 'curseWine', 'superWine', 'sword1', 'sword2', 'sword3', 'sword4', 'sword5', 'shield1', 'shield2', 'shield3', 'shield4', 'shield5',