action loadEquip

This commit is contained in:
ckcz123 2019-11-29 14:37:06 +08:00
parent 257a14248e
commit f8163c5fbf
7 changed files with 109 additions and 6 deletions

View File

@ -315,6 +315,8 @@
从V2.6开始,也可以使用`global:xxx`代表全局存储(和存档无关的存储)。
从V2.6.5开始,也可以使用`enemy:id:atk`来获得某个怪物的属性,`blockId:x,y`来获得某个点的图块ID`equip:x`来获得某个装备孔的装备ID。
``` js
[
"你当前的攻击力是${status:atk}, 防御是${status:def},坐标是(${status:x},${status:y})",
@ -322,15 +324,21 @@
"你的红黄蓝钥匙总数为${item:yellowKey+item:blueKey+item:redKey}",
"你访问某个老人的次数为${flag:man_times}",
"当前的存档编号是${global:saveIndex}",
"绿色史莱姆的攻击力是${enemy:greenSlime:atk}",
"(2,3)点的图块ID是${blockId:2,3},图块类型是${blockCls:2,3}",
"装备孔0的当前装备ID是${equip:0}",
]
```
![](img/events/7.jpg)
![](img/events/7.png)
- `status:xxx` 获取勇士属性时只能使用如下几个hp生命值atk攻击力def防御力mdef魔防值money金币experience经验x勇士的横坐标y勇士的纵坐标direction勇士的方向
- `item:xxx` 中的xxx为道具ID。所有道具的ID定义在items.js中请自行查看。例如`item:centerFly` 代表中心对称飞行器的个数。
- `flag:xxx` 中的xxx为一个自定义的变量/Flag支持中文如果没有对其进行赋值则默认值为0。
- `global:xxx` 中的xxx为一个全局存储的名称支持中文如果没有对其进行赋值则默认值为0。
- `enemy:xxx:yyy` 中的xxx为怪物IDyyy为要获得的项比如hp, atk, def等等
- `blockId:x,y``blockCls:x,y` 中的x,y为坐标值
- `equip:x` 中的x为装备孔编号从0开始。
### autoText自动剧情文本
@ -1063,9 +1071,9 @@ time为可选的指定的话将作为楼层切换动画的时间。
``` js
[
{"type": "changePos", "id": "pickaxe"}, // 尝试使用破
{"type": "changePos", "id": "bomb"}, // 尝试使用炸
{"type": "changePos", "id": "centerFly"} // 尝试使用飞
{"type": "useItem", "id": "pickaxe"}, // 尝试使用破
{"type": "useItem", "id": "bomb"}, // 尝试使用炸
{"type": "useItem", "id": "centerFly"} // 尝试使用飞
]
```
@ -1077,6 +1085,32 @@ time为可选的指定的话将作为楼层切换动画的时间。
不可使用“怪物手册”(请使用【呼出怪物手册】事件)或楼层传送器(如果[覆盖楼传事件](personalization#覆盖楼传事件)则可忽视本项)。
### loadEquip装上装备
使用`{"type": "loadEquip"}`可以装上一个装备。
``` js
[
{"type": "loadEquip", "id": "sword1"}, // 尝试装上铁剑
]
```
id必填为需要装备的ID。
使用装备时仍会检查条件(比如装备是否存在,能否装备等等)。
### unloadEquip卸下装备
使用`{"type": "unloadEquip"}`卸下某个装备孔的装备。
``` js
[
{"type": "unloadEquip", "pos": 0}, // 卸下装备孔0的装备
]
```
pos必填为要卸下的装备孔编号从0开始。
### openShop打开一个全局商店
使用openShop可以打开一个全局商店。有关全局商店的说明可参见[全局商店](#全局商店)。

BIN
_docs/img/events/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

View File

@ -359,6 +359,8 @@ action
| setViewport_s
| moveViewport_s
| useItem_s
| loadEquip_s
| unloadEquip_s
| openShop_s
| disableShop_s
| follow_s
@ -1244,6 +1246,32 @@ var code = '{"type": "useItem", "id": "'+IdString_0+'"},\n';
return code;
*/;
loadEquip_s
: '装上装备' IdString Newline
/* loadEquip_s
tooltip : loadEquip: 装上装备
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=useItem%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%81%93%e5%85%b7
colour : this.dataColor
default : ["sword1"]
var code = '{"type": "loadEquip", "id": "'+IdString_0+'"},\n';
return code;
*/;
unloadEquip_s
: '卸下装备孔' Int '的装备' Newline
/* unloadEquip_s
tooltip : unloadEquip: 卸下装备
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=useItem%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%81%93%e5%85%b7
colour : this.dataColor
default : [0]
var code = '{"type": "unloadEquip", "pos": '+Int_0+'},\n';
return code;
*/;
openShop_s
: '打开全局商店' IdString Newline
@ -2636,6 +2664,19 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC];
*/;
//这一条不会被antlr识别,总是会被归到idString_e
idString_6_e
: '装备孔:' Int
/* idString_6_e
colour : this.idstring_eColor
default : [0]
var code = 'equip:'+Int_0;
return [code, Blockly.JavaScript.ORDER_ATOMIC];
*/;
evFlag_e
: '独立开关' Letter_List
@ -2854,6 +2895,7 @@ this.block('idString_2_e').output='idString_e';
this.block('idString_3_e').output='idString_e';
this.block('idString_4_e').output='idString_e';
this.block('idString_5_e').output='idString_e';
this.block('idString_6_e').output='idString_e';
this.block('evFlag_e').output='idString_e';
*/
@ -3272,6 +3314,14 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['useItem_s'].xmlText([
data.id,this.next]);
break;
case "loadEquip": // 装上装备
this.next = MotaActionBlocks['loadEquip_s'].xmlText([
data.id,this.next]);
break;
case "unloadEquip": // 卸下装备
this.next = MotaActionBlocks['unloadEquip_s'].xmlText([
data.pos,this.next]);
break;
case "openShop": // 打开一个全局商店
this.next = MotaActionBlocks['openShop_s'].xmlText([
data.id,this.next]);
@ -3922,7 +3972,7 @@ MotaActionFunctions.replaceToName = function (str) {
return map[c] ? ("怪物:" + b + "" + map[c]) : c;
}).replace(/enemy:/g, "怪物:");
str = str.replace(/blockId:/g, "图块ID").replace(/blockCls:/g, "图块类别:");
str = str.replace(/blockId:/g, "图块ID").replace(/blockCls:/g, "图块类别:").replace(/equip:/g, "装备孔:");
return str;
}
@ -3952,7 +4002,7 @@ MotaActionFunctions.replaceFromName = function (str) {
return map[d] ? ("enemy:" + c + ":" + map[d]) : d;
}).replace(/怪物[:]/g, "enemy:");
str = str.replace(/图块I[dD][:]/g, "blockId:").replace(/图块类别[:]/g, "blockCls:");
str = str.replace(/图块I[dD][:]/g, "blockId:").replace(/图块类别[:]/g, "blockCls:").replace(/装备孔[:]/g, "equip:");
return str;
}

View File

@ -120,6 +120,8 @@ editor_blockly = function () {
MotaActionBlocks['changePos_1_s'].xmlText(),
MotaActionBlocks['battle_s'].xmlText(),
MotaActionBlocks['useItem_s'].xmlText(),
MotaActionBlocks['loadEquip_s'].xmlText(),
MotaActionBlocks['unloadEquip_s'].xmlText(),
MotaActionBlocks['openShop_s'].xmlText(),
MotaActionBlocks['disableShop_s'].xmlText(),
MotaActionBlocks['setHeroIcon_s'].xmlText(),
@ -232,6 +234,7 @@ editor_blockly = function () {
MotaActionBlocks['idString_3_e'].xmlText(),
MotaActionBlocks['idString_4_e'].xmlText(),
MotaActionBlocks['idString_5_e'].xmlText(),
MotaActionBlocks['idString_6_e'].xmlText(),
MotaActionBlocks['evalString_e'].xmlText(),
],
'常见事件模板':[

View File

@ -1465,6 +1465,10 @@ control.prototype._replayAction_equip = function (action) {
var index = ownEquipment.indexOf(equipId), per = core.__SIZE__-1;
if (index<0) return false;
core.status.route.push(action);
if (core.material.items[equipId].hideInReplay) {
core.loadEquip(equipId, core.replay);
return true;
}
core.status.event.data = {"page":Math.floor(index/per)+1, "selectId":null};
index = index%per+per;
core.ui.drawEquipbox(index);

View File

@ -1339,6 +1339,16 @@ events.prototype._action_useItem = function (data, x, y, prefix) {
}
}
events.prototype._action_loadEquip = function (data, x, y, prefix) {
core.loadEquip(data.id);
core.doAction();
}
events.prototype._action_unloadEquip = function (data, x, y, prefix) {
core.unloadEquip(data.pos);
core.doAction();
}
events.prototype._action_openShop = function (data, x, y, prefix) {
core.status.shops[data.id].visited = true;
this.setEvents([]);

View File

@ -87,6 +87,8 @@ utils.prototype.calValue = function (value, prefix, need, times) {
value = value.replace(/blockId:(\d+),(\d+)/g, "core.getBlockId($1, $2)");
if (value.indexOf('blockCls:')>=0)
value = value.replace(/blockCls:(\d+),(\d+)/g, "core.getBlockCls($1, $2)");
if (value.indexOf('equip:')>=0)
value = value.replace(/equip:(\d)/g, "core.getEquip($1)");
}
return eval(value);
}