openDoor event needKey

This commit is contained in:
oc 2019-02-04 00:24:49 +08:00
parent 7e8db1edad
commit 7436c54c67
3 changed files with 12 additions and 5 deletions

View File

@ -905,20 +905,21 @@ return code;
*/;
openDoor_s
: '开门' 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
: '开门' 'x' PosString? ',' 'y' PosString? '楼层' IdString? '需要钥匙' Bool? Newline
/* openDoor_s
tooltip : openDoor: 开门,楼层可不填表示当前层
helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8
default : ["","",""]
default : ["","","",false]
colour : this.dataColor
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var floorstr = '';
if (PosString_0 && PosString_1) {
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
}
var code = '{"type": "openDoor"'+floorstr+IdString_0+'},\n';
Bool_0 = Bool_0 ? ', "needKey": true' : '';
var code = '{"type": "openDoor"'+floorstr+IdString_0+Bool_0+'},\n';
return code;
*/;
@ -2283,7 +2284,7 @@ ActionParser.prototype.parseAction = function() {
case "openDoor": // 开一个门, 包括暗墙
data.loc=data.loc||['','']
this.next = MotaActionBlocks['openDoor_s'].xmlText([
data.loc[0],data.loc[1],data.floorId||'',this.next]);
data.loc[0],data.loc[1],data.floorId||'',data.needKey||false,this.next]);
break;
case "useItem": // 使用道具
this.next = MotaActionBlocks['useItem_s'].xmlText([

View File

@ -842,6 +842,7 @@ name是可选的代表目标行走图的文件名。
"x,y": [ // 实际执行的事件列表
{"type": "openDoor", "loc": [3,6], "floorId": "MT1"}, // 打开MT1层的[3,6]位置的门
{"type": "openDoor", "loc": [3,6]}, // 如果是本层则可省略floorId
{"type": "openDoor", "loc": [3,6], "needKey": true} // 打开此门需要钥匙
]
```
@ -851,6 +852,10 @@ loc指定门的坐标floorId指定门所在的楼层ID。如果是当前层
如果loc所在的点既不是门也不是墙壁则忽略本事件。
needKey是可选的如果设置为true则需要钥匙才能打开此门。如果没有钥匙则跳过此事件。
!> needKey仅对当前楼层开门有效跨楼层的门仍然不需要钥匙即可打开如有需求请自行判定。
### changeFloor楼层切换
在事件中也可以对楼层进行切换。一个比较典型的例子就是TSW中勇士在三楼的陷阱被扔到了二楼就是一个楼层切换事件。

View File

@ -853,7 +853,7 @@ events.prototype.doAction = function() {
}
var floorId=data.floorId || core.status.floorId;
if (floorId==core.status.floorId)
core.openDoor(null, x, y, false, function() {
core.openDoor(null, x, y, data.needKey, function() {
core.lockControl();
core.events.doAction();
})
@ -1459,6 +1459,7 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) {
core.drawTip("你没有" + ((core.material.items[key]||{}).name||"钥匙"));
else core.drawTip("无法开启此门");
core.clearContinueAutomaticRoute();
if (core.isset(callback)) callback();
return;
}
core.autosave(true);