type:insert

This commit is contained in:
oc 2019-03-19 23:57:43 +08:00
parent 833164e206
commit bb8182d589
8 changed files with 96 additions and 52 deletions

View File

@ -616,10 +616,11 @@ NPC对话事件结束后如果需要NPC消失也需要调用 `{"type": "hide"}`
``` js ``` js
"x,y": [ // 实际执行的事件列表 "x,y": [ // 实际执行的事件列表
{"type": "insert", "name": "加点事件"}, // 插入公共事件:加点事件 {"type": "insert", "name": "加点事件", "args": [10] }, // 插入公共事件:加点事件传入参数10
{"type": "insert", "name": "毒衰咒处理"}, // 插入公共事件:毒衰咒处理 {"type": "insert", "name": "毒衰咒处理", "args": [0]}, // 插入公共事件:毒衰咒处理传入参数0
{"type": "insert", "loc": [3,6]}, // 插入[3,6]点的事件并执行 {"type": "insert", "loc": [3,6]}, // 插入[3,6]点的事件并执行
{"type": "insert", "loc": [10,10], "floorId": "MT1"}, // 插入MT1层[10,10]点的事件并执行 {"type": "insert", "loc": [10,10], "floorId": "MT1"}, // 插入MT1层[10,10]点的事件并执行
{"type": "insert", "loc": [2,2], "args": [1,"flag:abc","status:atk+status:def"]}, // 传入三个参数
"上面的插入事件执行完毕后会接着继续执行后面的事件" "上面的插入事件执行完毕后会接着继续执行后面的事件"
] ]
``` ```
@ -631,6 +632,7 @@ NPC对话事件结束后如果需要NPC消失也需要调用 `{"type": "hide"}`
- 否则,如果写了`"loc": [x,y]`,则会插入另一个地点的事件 - 否则,如果写了`"loc": [x,y]`,则会插入另一个地点的事件
- loc为另一个地点的坐标 - loc为另一个地点的坐标
- floorId可选代表另一个地点所在的楼层如果不写则默认为当前层。 - floorId可选代表另一个地点所在的楼层如果不写则默认为当前层。
- 从V2.6开始还可以传可选的which可以为`afterBattle`/`afterGetItem`/`afterOpenDoor`,代表插入该点的战后/获得道具后/开门后事件。
和`type:trigger`不同的是,**`type:trigger`是立刻将当前事件结束剩下所有内容都忽略然后重新启动另一个地点的action事件。** 和`type:trigger`不同的是,**`type:trigger`是立刻将当前事件结束剩下所有内容都忽略然后重新启动另一个地点的action事件。**
@ -638,6 +640,16 @@ NPC对话事件结束后如果需要NPC消失也需要调用 `{"type": "hide"}`
**这个过程中,当前事件不会被结束,当前的楼层和事件坐标不会发生改变。** 插入的事件执行完毕后,会继续执行接下来的内容。 **这个过程中,当前事件不会被结束,当前的楼层和事件坐标不会发生改变。** 插入的事件执行完毕后,会继续执行接下来的内容。
从V2.6开始,插入事件允许传参。如果需要传参,则需要增加一个`args`数组。
例如: `"args": [1,"flag:abc","status:atk+status:def"]` 传入了三个参数。
系统会自动把`flag:arg1`设置为第一个参数数值,`flag:arg2`设置为第二个参数数值,等等。
`flag:arg0`则会被置为公共事件名称,或者插入的点的坐标)
即可在事件中直接取用`flag:arg1`等等来获得各项参数值!。
### revisit立即重启当前事件 ### revisit立即重启当前事件
revisit和trigger完全相同只不过是立刻触发的还是本地点的事件 revisit和trigger完全相同只不过是立刻触发的还是本地点的事件

View File

@ -614,29 +614,55 @@ return code;
*/; */;
insert_1_s insert_1_s
: '插入公共事件' EvalString Newline : '插入公共事件' EvalString '参数列表' EvalString? Newline
/* insert_1_s /* insert_1_s
tooltip : insert: 插入公共事件并执行 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 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 : ["加点事件"] default : ["加点事件", ""]
colour : this.eventColor colour : this.eventColor
var code = '{"type": "insert", "name": "'+EvalString_0+'"},\n'; if (EvalString_1) {
if (EvalString_1.indexOf('"')>=0)
throw new Error('请勿在此处使用双引号!尝试使用单引号吧~');
// 检查是不是数组
try {
if (!(JSON.parse(EvalString_1.replace(/'/g, '"')) instanceof Array)) throw new Error();
}
catch (e) {
throw new Error('参数列表必须是个有效的数组!');
}
EvalString_1 = ', "args": ' +EvalString_1;
}
var code = '{"type": "insert", "name": "'+EvalString_0+'"'+EvalString_1+'},\n';
return code; return code;
*/; */;
insert_2_s insert_2_s
: '插入事件' 'x' PosString ',' 'y' PosString '楼层' IdString? Newline : '插入事件' 'x' PosString ',' 'y' PosString Event_List? '楼层' IdString? '参数列表' EvalString? ENewline
/* insert_2_s /* insert_2_s
tooltip : insert: 立即插入另一个地点的事件执行,当前事件不会中断,事件坐标不会改变 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 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",""] default : ["0","0",null,"",""]
colour : this.eventColor colour : this.eventColor
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var code = '{"type": "insert", "loc": ['+PosString_0+','+PosString_1+']'+IdString_0+'},\n'; if (EvalString_0) {
if (EvalString_0.indexOf('"')>=0)
throw new Error('请勿在此处使用双引号!尝试使用单引号吧~');
try {
if (!(JSON.parse(EvalString_0.replace(/'/g, '"')) instanceof Array)) throw new Error();
}
catch (e) {
throw new Error('参数列表必须是个有效的数组!');
}
EvalString_0 = ', "args": ' +EvalString_0;
}
if (Event_List_0 && Event_List_0 !=='null')
Event_List_0 = ', "which": "'+Event_List_0+'"';
else Event_List_0 = '';
var code = '{"type": "insert", "loc": ['+PosString_0+','+PosString_1+']'+Event_List_0+IdString_0+EvalString_0+'},\n';
return code; return code;
*/; */;
@ -1852,6 +1878,10 @@ Bg_Fg_List
: '背景层'|'前景层' : '背景层'|'前景层'
/*Bg_Fg_List ['bg','fg']*/; /*Bg_Fg_List ['bg','fg']*/;
Event_List
: '事件'|'战后事件'|'道具后事件'|'开门后事件'
/*Event_List ['null','afterBattle','afterGetItem','afterOpenDoor']*/;
Floor_Meta_List Floor_Meta_List
: '楼层中文名'|'状态栏名称'|'能否使用楼传'|'能否打开快捷商店'|'是否不可浏览地图'|'是否不可瞬间移动'|'默认地面ID'|'楼层贴图'|'宝石血瓶效果'|'上楼点坐标'|'下楼点坐标'|'背景音乐'|'画面色调'|'天气和强度'|'是否地下层' : '楼层中文名'|'状态栏名称'|'能否使用楼传'|'能否打开快捷商店'|'是否不可浏览地图'|'是否不可瞬间移动'|'默认地面ID'|'楼层贴图'|'宝石血瓶效果'|'上楼点坐标'|'下楼点坐标'|'背景音乐'|'画面色调'|'天气和强度'|'是否地下层'
/*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'item_ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/; /*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'item_ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/;
@ -2329,13 +2359,18 @@ ActionParser.prototype.parseAction = function() {
data.loc[0],data.loc[1],this.next]); data.loc[0],data.loc[1],this.next]);
break; break;
case "insert": // 强制插入另一个点的事件在当前事件列表执行,当前坐标和楼层不会改变 case "insert": // 强制插入另一个点的事件在当前事件列表执行,当前坐标和楼层不会改变
if (data.args instanceof Array) {
try { data.args = JSON.stringify(data.args).replace(/"/g, "'"); }
catch (e) {data.args = '';}
}
else data.args = null;
if (this.isset(data.name)) { if (this.isset(data.name)) {
this.next = MotaActionBlocks['insert_1_s'].xmlText([ this.next = MotaActionBlocks['insert_1_s'].xmlText([
data.name, this.next]); data.name, data.args||"", this.next]);
} }
else { else {
this.next = MotaActionBlocks['insert_2_s'].xmlText([ this.next = MotaActionBlocks['insert_2_s'].xmlText([
data.loc[0],data.loc[1],data.floorId||'',this.next]); data.loc[0],data.loc[1],data.which,data.floorId||'',data.args||"",this.next]);
} }
break; break;
case "playSound": case "playSound":

View File

@ -2141,8 +2141,8 @@ control.prototype.clearStatusBar = function() {
////// 更新状态栏 ////// ////// 更新状态栏 //////
control.prototype.updateStatusBar = function () { control.prototype.updateStatusBar = function () {
if (core.isPlaying()) if (!core.isPlaying()) return;
this.controldata.updateStatusBar(); this.controldata.updateStatusBar();
this._updateStatusBar_setToolboxIcon(); this._updateStatusBar_setToolboxIcon();
} }

View File

@ -579,16 +579,13 @@ events.prototype.passNet = function (data) {
if (core.hasItem('shoes')) return; if (core.hasItem('shoes')) return;
// 血网 lavaNet 移动到 checkBlock 中处理 // 血网 lavaNet 移动到 checkBlock 中处理
if (data.event.id == 'poisonNet') { // 毒网 if (data.event.id == 'poisonNet') { // 毒网
core.setFlag('debuff', 'poison'); core.insertAction({"type":"insert","name":"毒衰咒处理","args":[0]});
core.insertAction('毒衰咒处理');
} }
else if (data.event.id == 'weakNet') { // 衰网 else if (data.event.id == 'weakNet') { // 衰网
core.setFlag('debuff', 'weak'); core.insertAction({"type":"insert","name":"毒衰咒处理","args":[1]});
core.insertAction('毒衰咒处理');
} }
else if (data.event.id == 'curseNet') { // 咒网 else if (data.event.id == 'curseNet') { // 咒网
core.setFlag('debuff', 'curse'); core.insertAction({"type":"insert","name":"毒衰咒处理","args":[2]});
core.insertAction('毒衰咒处理');
} }
core.updateStatusBar(); core.updateStatusBar();
} }
@ -1166,13 +1163,24 @@ events.prototype._action_trigger = function (data, x, y, prefix) {
} }
events.prototype._action_insert = function (data, x, y, prefix) { events.prototype._action_insert = function (data, x, y, prefix) {
// 设置参数
if (data.args instanceof Array) {
for (var i = 0; i < data.args.length; ++i) {
try {
core.setFlag('arg'+(i+1), core.calValue(data.args[i], prefix));
} catch (e) { main.log(e); }
}
}
if (data.name) { // 公共事件 if (data.name) { // 公共事件
core.setFlag('arg0', data.name);
core.insertAction(this.getCommonEvent(data.name)); core.insertAction(this.getCommonEvent(data.name));
} }
else { else {
var loc = this.__action_getLoc(data.loc, x, y, prefix); var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setFlag('arg0', loc);
var floorId = data.floorId || core.status.floorId; var floorId = data.floorId || core.status.floorId;
var event = core.floors[floorId].events[loc[0] + "," + loc[1]]; var which = data.which || "events";
var event = (core.floors[floorId][which]||[])[loc[0] + "," + loc[1]];
if (event) this.insertAction(event.data || event); if (event) this.insertAction(event.data || event);
} }
core.doAction(); core.doAction();

View File

@ -1483,6 +1483,7 @@ ui.prototype.drawBookDetail = function (index) {
var enemy = enemys[index], enemyId = enemy.id; var enemy = enemys[index], enemyId = enemy.id;
var hints=core.enemys.getSpecialHint(enemyId); var hints=core.enemys.getSpecialHint(enemyId);
var damageInfo = core.enemys.getDamageInfo(enemy, null, null, null, floorId);
if (hints.length==0) if (hints.length==0)
hints.push("该怪物无特殊属性。"); hints.push("该怪物无特殊属性。");
@ -1553,6 +1554,7 @@ ui.prototype.drawBookDetail = function (index) {
} }
hints.push(""); hints.push("");
hints.push("战斗回合数:"+((damageInfo||{}).turn||0));
var criticals = core.enemys.nextCriticals(enemyId, 10, null, null, floorId).map(function (v) { var criticals = core.enemys.nextCriticals(enemyId, 10, null, null, floorId).map(function (v) {
return core.formatBigNumber(v[0])+":"+core.formatBigNumber(v[1]); return core.formatBigNumber(v[0])+":"+core.formatBigNumber(v[1]);
}); });

View File

@ -69,6 +69,7 @@ function main() {
'skillCol': document.getElementById('skillCol'), 'skillCol': document.getElementById('skillCol'),
'hard': document.getElementById('hard'), 'hard': document.getElementById('hard'),
'statusCanvas': document.getElementById('statusCanvas'), 'statusCanvas': document.getElementById('statusCanvas'),
'statusCanvasCtx': document.getElementById('statusCanvas').getContext('2d')
}; };
this.mode = 'play'; this.mode = 'play';
this.loadList = [ this.loadList = [

View File

@ -4,60 +4,55 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
"加点事件": [ "加点事件": [
{ {
"type": "comment", "type": "comment",
"text": "flag:point表示当前应该的加点数值" "text": "通过传参flag:arg1表示当前应该的加点数值"
}, },
{ {
"type": "choices", "type": "choices",
"choices": [ "choices": [
{ {
"text": "攻击+${1*flag:point}", "text": "攻击+${1*flag:arg1}",
"action": [ "action": [
{ {
"type": "setValue", "type": "setValue",
"name": "status:atk", "name": "status:atk",
"value": "status:atk+1*flag:point" "value": "status:atk+1*flag:arg1"
} }
] ]
}, },
{ {
"text": "防御+${2*flag:point}", "text": "防御+${2*flag:arg1}",
"action": [ "action": [
{ {
"type": "setValue", "type": "setValue",
"name": "status:def", "name": "status:def",
"value": "status:def+2*flag:point" "value": "status:def+2*flag:arg1"
} }
] ]
}, },
{ {
"text": "生命+${200*flag:point}", "text": "生命+${200*flag:arg1}",
"action": [ "action": [
{ {
"type": "setValue", "type": "setValue",
"name": "status:hp", "name": "status:hp",
"value": "status:hp+200*flag:point" "value": "status:hp+200*flag:arg1"
} }
] ]
} }
] ]
},
{
"type": "setValue",
"name": "flag:point",
"value": "null"
} }
], ],
"毒衰咒处理": [ "毒衰咒处理": [
{ {
"type": "comment", "type": "comment",
"text": "获得毒衰咒效果flag:debuff为要获得的类型" "text": "获得毒衰咒效果flag:arg1为要获得的类型"
}, },
{ {
"type": "switch", "type": "switch",
"condition": "flag:debuff", "condition": "flag:arg1",
"caseList": [ "caseList": [
{ {
"case": "'poison'", "case": "0",
"action": [ "action": [
{ {
"type": "comment", "type": "comment",
@ -78,7 +73,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
] ]
}, },
{ {
"case": "'weak'", "case": "1",
"action": [ "action": [
{ {
"type": "comment", "type": "comment",
@ -133,7 +128,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
] ]
}, },
{ {
"case": "'curse'", "case": "2",
"action": [ "action": [
{ {
"type": "comment", "type": "comment",
@ -154,11 +149,6 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
] ]
} }
] ]
},
{
"type": "setValue",
"name": "flag:debuff",
"value": "null"
} }
] ]
} }

View File

@ -271,18 +271,15 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var special = enemy.special; var special = enemy.special;
// 中毒 // 中毒
if (core.enemys.hasSpecial(special, 12)) { if (core.enemys.hasSpecial(special, 12)) {
core.push(todo, [{ "type": "setValue", "name": "flag:debuff", "value": "'poison'" }]); core.push(todo, [{ "type": "insert", "name": "毒衰咒处理", "args": [0] }]);
core.push(todo, [{ "type": "insert", "name": "毒衰咒处理" }]);
} }
// 衰弱 // 衰弱
if (core.enemys.hasSpecial(special, 13)) { if (core.enemys.hasSpecial(special, 13)) {
core.push(todo, [{ "type": "setValue", "name": "flag:debuff", "value": "'weak'" }]); core.push(todo, [{ "type": "insert", "name": "毒衰咒处理", "args": [1] }]);
core.push(todo, [{ "type": "insert", "name": "毒衰咒处理" }]);
} }
// 诅咒 // 诅咒
if (core.enemys.hasSpecial(special, 14)) { if (core.enemys.hasSpecial(special, 14)) {
core.push(todo, [{ "type": "setValue", "name": "flag:debuff", "value": "'curse'" }]); core.push(todo, [{ "type": "insert", "name": "毒衰咒处理", "args": [2] }]);
core.push(todo, [{ "type": "insert", "name": "毒衰咒处理" }]);
} }
// 仇恨属性:减半 // 仇恨属性:减半
if (core.flags.hatredDecrease && core.enemys.hasSpecial(special, 17)) { if (core.flags.hatredDecrease && core.enemys.hasSpecial(special, 17)) {
@ -318,8 +315,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 如果有加点 // 如果有加点
var point = core.material.enemys[enemyId].point; var point = core.material.enemys[enemyId].point;
if (core.flags.enableAddPoint && point > 0) { if (core.flags.enableAddPoint && point > 0) {
core.push(todo, [{ "type": "setValue", "name": "flag:point", "value": point }]); core.push(todo, [{ "type": "insert", "name": "加点事件", "args": [point] }]);
core.push(todo, [{ "type": "insert", "name": "加点事件" }]);
} }
// 如果该点存在事件 -- V2.5.4 以后阻击怪也可以有战后事件了 // 如果该点存在事件 -- V2.5.4 以后阻击怪也可以有战后事件了
@ -1289,7 +1285,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 如果是非状态栏canvas化直接返回 // 如果是非状态栏canvas化直接返回
if (!core.flags.statusCanvas) return; if (!core.flags.statusCanvas) return;
var canvas = core.dom.statusCanvas, var canvas = core.dom.statusCanvas,
ctx = canvas.getContext('2d'); ctx = core.dom.statusCanvasCtx;
// 清空状态栏 // 清空状态栏
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
// 如果是隐藏状态栏模式,直接返回 // 如果是隐藏状态栏模式,直接返回
@ -1372,7 +1368,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.lockControl(); core.lockControl();
core.status.event.id = 'about'; core.status.event.id = 'about';
var left = 48, top = 36, right = 416 - 2 * left, bottom = 416 - 2 * top; var left = 48, top = 36, right = core.__PIXELS__ - 2 * left, bottom = core.__PIXELS__ - 2 * top;
core.setAlpha('ui', 0.85); core.setAlpha('ui', 0.85);
core.fillRect('ui', left, top, right, bottom, '#000000'); core.fillRect('ui', left, top, right, bottom, '#000000');
@ -1459,7 +1455,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var ctx = core.getContextByName(name); var ctx = core.getContextByName(name);
if (ctx == null) { if (ctx == null) {
if (typeof name == 'string') if (typeof name == 'string')
ctx = core.createCanvas(name, 0, 0, 416, 416, 98); ctx = core.createCanvas(name, 0, 0, core.__PIXELS__, core.__PIXELS__, 98);
else return; else return;
} }