quickCommonEvents
This commit is contained in:
parent
f7056d699f
commit
16980c527a
@ -682,6 +682,12 @@ revisit常常使用在一些商人之类的地方,当用户购买物品后不
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### addToList:将本公共事件插入到快捷列表中
|
||||||
|
|
||||||
|
使用 `{"type": "addToList"}` 可以将当前公共事件插入到快捷商店列表中。
|
||||||
|
|
||||||
|
此项只能在公共事件中被执行。详见[公共事件](personalization#公共事件)。
|
||||||
|
|
||||||
### setBlock:设置某个图块
|
### setBlock:设置某个图块
|
||||||
|
|
||||||
我们可以采用 `{"type": "setBlock"}` 来改变某个地图块。
|
我们可以采用 `{"type": "setBlock"}` 来改变某个地图块。
|
||||||
|
|||||||
@ -240,6 +240,7 @@ action
|
|||||||
| insert_2_s
|
| insert_2_s
|
||||||
| revisit_s
|
| revisit_s
|
||||||
| exit_s
|
| exit_s
|
||||||
|
| addToList_s
|
||||||
| setBlock_s
|
| setBlock_s
|
||||||
| showFloorImg_s
|
| showFloorImg_s
|
||||||
| hideFloorImg_s
|
| hideFloorImg_s
|
||||||
@ -693,6 +694,18 @@ var code = '{"type": "exit"},\n';
|
|||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
|
addToList_s
|
||||||
|
: '将本公共事件插入到快捷列表中' Newline
|
||||||
|
|
||||||
|
|
||||||
|
/* addToList_s
|
||||||
|
tooltip : addToList: 将本公共事件插入到快捷列表中
|
||||||
|
helpUrl : https://h5mota.com/games/template/docs/#/event?id=exit%EF%BC%9A%E7%AB%8B%E5%88%BB%E7%BB%93%E6%9D%9F%E5%BD%93%E5%89%8D%E4%BA%8B%E4%BB%B6
|
||||||
|
colour : this.eventColor
|
||||||
|
var code = '{"type": "addToList"},\n';
|
||||||
|
return code;
|
||||||
|
*/;
|
||||||
|
|
||||||
setBlock_s
|
setBlock_s
|
||||||
: '转变图块为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
|
: '转变图块为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
|
||||||
|
|
||||||
@ -2604,6 +2617,10 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
this.next = MotaActionBlocks['exit_s'].xmlText([
|
this.next = MotaActionBlocks['exit_s'].xmlText([
|
||||||
this.next]);
|
this.next]);
|
||||||
break;
|
break;
|
||||||
|
case "addToList": // 立刻结束事件
|
||||||
|
this.next = MotaActionBlocks['addToList_s'].xmlText([
|
||||||
|
this.next]);
|
||||||
|
break;
|
||||||
case "animateImage": // 兼容 animateImage
|
case "animateImage": // 兼容 animateImage
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -660,6 +660,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
|||||||
"_bool": "bool",
|
"_bool": "bool",
|
||||||
"_data": "是否在经过领域/夹击/路障等伤害后禁用快捷商店。"
|
"_data": "是否在经过领域/夹击/路障等伤害后禁用快捷商店。"
|
||||||
},
|
},
|
||||||
|
"quickCommonEvents": {
|
||||||
|
"_leaf": true,
|
||||||
|
"_type": "checkbox",
|
||||||
|
"_bool": "bool",
|
||||||
|
"_data": "是否使用自定义的公共事件列表来代替快捷商店列表。\n如果此项开启,则快捷商店列表中将会显示加入的公共事件。"
|
||||||
|
},
|
||||||
"checkConsole": {
|
"checkConsole": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "checkbox",
|
"_type": "checkbox",
|
||||||
|
|||||||
@ -123,6 +123,7 @@ editor_blockly = function () {
|
|||||||
MotaActionBlocks['hideBgFgMap_s'].xmlText(),
|
MotaActionBlocks['hideBgFgMap_s'].xmlText(),
|
||||||
MotaActionBlocks['trigger_s'].xmlText(),
|
MotaActionBlocks['trigger_s'].xmlText(),
|
||||||
MotaActionBlocks['insert_1_s'].xmlText(),
|
MotaActionBlocks['insert_1_s'].xmlText(),
|
||||||
|
MotaActionBlocks['addToList_s'].xmlText(),
|
||||||
MotaActionBlocks['insert_2_s'].xmlText(),
|
MotaActionBlocks['insert_2_s'].xmlText(),
|
||||||
MotaActionBlocks['move_s'].xmlText(),
|
MotaActionBlocks['move_s'].xmlText(),
|
||||||
MotaActionBlocks['jump_s'].xmlText(),
|
MotaActionBlocks['jump_s'].xmlText(),
|
||||||
|
|||||||
@ -1198,20 +1198,35 @@ actions.prototype._keyUpShop = function (keycode) {
|
|||||||
|
|
||||||
////// 快捷商店界面时的点击操作 //////
|
////// 快捷商店界面时的点击操作 //////
|
||||||
actions.prototype._clickQuickShop = function (x, y) {
|
actions.prototype._clickQuickShop = function (x, y) {
|
||||||
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
|
var keys = [];
|
||||||
return shopList[shopId].visited || !shopList[shopId].mustEnable
|
if (core.flags.quickCommonEvents) {
|
||||||
});
|
keys = core.getFlag("__commonEventList__", []);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keys = Object.keys(core.status.shops).filter(function (shopId) {
|
||||||
|
return core.status.shops[shopId].visited || !core.status.shops[shopId].mustEnable
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) {
|
if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) {
|
||||||
var topIndex = this.HSIZE - parseInt(keys.length / 2);
|
var topIndex = this.HSIZE - parseInt(keys.length / 2);
|
||||||
if (y >= topIndex && y < topIndex + keys.length) {
|
if (y >= topIndex && y < topIndex + keys.length) {
|
||||||
var reason = core.events.canUseQuickShop(keys[y - topIndex]);
|
if (core.flags.quickCommonEvents) {
|
||||||
if (!core.flags.enableDisabledShop && reason) {
|
var name = keys[y - topIndex];
|
||||||
core.drawText(reason);
|
core.ui.closePanel();
|
||||||
return;
|
core.status.route.push("common:" + core.encodeBase64(name));
|
||||||
|
core.insertAction(name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var reason = core.events.canUseQuickShop(keys[y - topIndex]);
|
||||||
|
if (!core.flags.enableDisabledShop && reason) {
|
||||||
|
core.drawText(reason);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.events.openShop(keys[y - topIndex], true);
|
||||||
|
if (core.status.event.id == 'shop')
|
||||||
|
core.status.event.data.fromList = true;
|
||||||
}
|
}
|
||||||
core.events.openShop(keys[y - topIndex], true);
|
|
||||||
if (core.status.event.id == 'shop')
|
|
||||||
core.status.event.data.fromList = true;
|
|
||||||
}
|
}
|
||||||
// 离开
|
// 离开
|
||||||
else if (y == topIndex + keys.length)
|
else if (y == topIndex + keys.length)
|
||||||
@ -1225,10 +1240,17 @@ actions.prototype._keyUpQuickShop = function (keycode) {
|
|||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
|
var length = 0;
|
||||||
return shopList[shopId].visited || !shopList[shopId].mustEnable
|
if (core.flags.quickCommonEvents) {
|
||||||
});
|
length = core.getFlag("__commonEventList__", []).length;
|
||||||
this._selectChoices(keys.length + 1, keycode, this._clickQuickShop);
|
}
|
||||||
|
else {
|
||||||
|
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
|
||||||
|
return shopList[shopId].visited || !shopList[shopId].mustEnable
|
||||||
|
});
|
||||||
|
length = keys.length;
|
||||||
|
}
|
||||||
|
this._selectChoices(length + 1, keycode, this._clickQuickShop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,7 @@ control.prototype._init = function () {
|
|||||||
this.registerReplayAction("fly", this._replayAction_fly);
|
this.registerReplayAction("fly", this._replayAction_fly);
|
||||||
this.registerReplayAction("shop", this._replayAction_shop);
|
this.registerReplayAction("shop", this._replayAction_shop);
|
||||||
this.registerReplayAction("turn", this._replayAction_turn);
|
this.registerReplayAction("turn", this._replayAction_turn);
|
||||||
|
this.registerReplayAction("common", this._replayAction_common);
|
||||||
this.registerReplayAction("getNext", this._replayAction_getNext);
|
this.registerReplayAction("getNext", this._replayAction_getNext);
|
||||||
this.registerReplayAction("moveDirectly", this._replayAction_moveDirectly);
|
this.registerReplayAction("moveDirectly", this._replayAction_moveDirectly);
|
||||||
this.registerReplayAction("key", this._replayAction_key);
|
this.registerReplayAction("key", this._replayAction_key);
|
||||||
@ -1441,6 +1442,16 @@ control.prototype._replayAction_turn = function (action) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
control.prototype._replayAction_common = function (action) {
|
||||||
|
if (action.indexOf("common:") != 0) return false;
|
||||||
|
var name = core.decodeBase64(action.substring(7));
|
||||||
|
if (core.getFlag("__commonEventList__").indexOf(name) == -1) return false;
|
||||||
|
core.status.route.push(action);
|
||||||
|
core.insertAction(name);
|
||||||
|
setTimeout(core.replay);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
control.prototype._replayAction_getNext = function (action) {
|
control.prototype._replayAction_getNext = function (action) {
|
||||||
if (action != "getNext") return false;
|
if (action != "getNext") return false;
|
||||||
if (!core.getNextItem()) return false;
|
if (!core.getNextItem()) return false;
|
||||||
|
|||||||
@ -806,7 +806,10 @@ events.prototype.insertAction = function (action, x, y, callback, addToLast) {
|
|||||||
|
|
||||||
// ------ 判定commonEvent
|
// ------ 判定commonEvent
|
||||||
var commonEvent = this.getCommonEvent(action);
|
var commonEvent = this.getCommonEvent(action);
|
||||||
if (commonEvent instanceof Array) action = commonEvent;
|
if (commonEvent instanceof Array) {
|
||||||
|
this._addCommentEventToList(action, commonEvent);
|
||||||
|
action = commonEvent;
|
||||||
|
}
|
||||||
if (!action) return;
|
if (!action) return;
|
||||||
|
|
||||||
if (core.status.event.id != 'action') {
|
if (core.status.event.id != 'action') {
|
||||||
@ -827,6 +830,22 @@ events.prototype.getCommonEvent = function (name) {
|
|||||||
return this.commonEvent[name] || null;
|
return this.commonEvent[name] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events.prototype._addCommentEventToList = function (name, list) {
|
||||||
|
if (list == null) list = this.getCommonEvent(name);
|
||||||
|
if (!list || !core.flags.quickCommonEvents) return;
|
||||||
|
var addToList = false;
|
||||||
|
for (var x in list) {
|
||||||
|
if (list[x].type == 'addToList') {
|
||||||
|
addToList = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!addToList) return;
|
||||||
|
var obj = core.getFlag("__commonEventList__", []);
|
||||||
|
if (obj.indexOf(name) == -1) obj.push(name);
|
||||||
|
core.setFlag("__commonEventList__", obj);
|
||||||
|
}
|
||||||
|
|
||||||
////// 恢复一个事件 //////
|
////// 恢复一个事件 //////
|
||||||
events.prototype.recoverEvents = function (data) {
|
events.prototype.recoverEvents = function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -1175,7 +1194,7 @@ events.prototype._action_insert = function (data, x, y, prefix) {
|
|||||||
}
|
}
|
||||||
if (data.name) { // 公共事件
|
if (data.name) { // 公共事件
|
||||||
core.setFlag('arg0', data.name);
|
core.setFlag('arg0', data.name);
|
||||||
core.insertAction(this.getCommonEvent(data.name));
|
core.insertAction(data.name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||||
@ -1188,6 +1207,10 @@ events.prototype._action_insert = function (data, x, y, prefix) {
|
|||||||
core.doAction();
|
core.doAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events.prototype._action_addToList = function (data, x, y, prefix) {
|
||||||
|
core.doAction();
|
||||||
|
}
|
||||||
|
|
||||||
events.prototype._action_playBgm = function (data, x, y, prefix) {
|
events.prototype._action_playBgm = function (data, x, y, prefix) {
|
||||||
core.playBgm(data.name);
|
core.playBgm(data.name);
|
||||||
core.doAction();
|
core.doAction();
|
||||||
|
|||||||
18
libs/ui.js
18
libs/ui.js
@ -1118,12 +1118,18 @@ ui.prototype.drawSettings = function () {
|
|||||||
////// 绘制快捷商店选择栏 //////
|
////// 绘制快捷商店选择栏 //////
|
||||||
ui.prototype.drawQuickShop = function () {
|
ui.prototype.drawQuickShop = function () {
|
||||||
core.status.event.id = 'selectShop';
|
core.status.event.id = 'selectShop';
|
||||||
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
|
var choices;
|
||||||
return shopList[shopId].visited || !shopList[shopId].mustEnable
|
if (core.flags.quickCommonEvents) {
|
||||||
});
|
choices = core.clone(core.getFlag("__commonEventList__", []));
|
||||||
var choices = keys.map(function (shopId) {
|
}
|
||||||
return {"text": shopList[shopId].textInList, "color": shopList[shopId].visited?null:"#999999"};
|
else {
|
||||||
});
|
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
|
||||||
|
return shopList[shopId].visited || !shopList[shopId].mustEnable
|
||||||
|
});
|
||||||
|
choices = keys.map(function (shopId) {
|
||||||
|
return {"text": shopList[shopId].textInList, "color": shopList[shopId].visited?null:"#999999"};
|
||||||
|
});
|
||||||
|
}
|
||||||
choices.push("返回游戏");
|
choices.push("返回游戏");
|
||||||
this.drawChoices(null, choices);
|
this.drawChoices(null, choices);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -467,6 +467,8 @@ utils.prototype._encodeRoute_encodeOne = function (t) {
|
|||||||
return "P" + t.substring(6);
|
return "P" + t.substring(6);
|
||||||
else if (t.indexOf('input2:') == 0)
|
else if (t.indexOf('input2:') == 0)
|
||||||
return "Q" + t.substring(7) + ":";
|
return "Q" + t.substring(7) + ":";
|
||||||
|
else if (t.indexOf('common:') == 0)
|
||||||
|
return "c" + t.substring(7) + ":";
|
||||||
else if (t == 'no')
|
else if (t == 'no')
|
||||||
return 'N';
|
return 'N';
|
||||||
else if (t.indexOf('move:') == 0)
|
else if (t.indexOf('move:') == 0)
|
||||||
@ -525,7 +527,7 @@ utils.prototype._decodeRoute_number2id = function (number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
|
utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
|
||||||
var nxt = (c == 'I' || c == 'e' || c == 'F' || c == 'S' || c == 'Q' || c == 't') ?
|
var nxt = (c == 'I' || c == 'e' || c == 'F' || c == 'S' || c == 'Q' || c == 't' || c == 'c') ?
|
||||||
this._decodeRoute_getString(decodeObj) : this._decodeRoute_getNumber(decodeObj);
|
this._decodeRoute_getString(decodeObj) : this._decodeRoute_getNumber(decodeObj);
|
||||||
|
|
||||||
var mp = {"U": "up", "D": "down", "L": "left", "R": "right"};
|
var mp = {"U": "up", "D": "down", "L": "left", "R": "right"};
|
||||||
@ -570,6 +572,9 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
|
|||||||
case "Q":
|
case "Q":
|
||||||
decodeObj.ans.push("input2:" + nxt);
|
decodeObj.ans.push("input2:" + nxt);
|
||||||
break;
|
break;
|
||||||
|
case "c":
|
||||||
|
decodeObj.ans.push("common:" + nxt);
|
||||||
|
break;
|
||||||
case "N":
|
case "N":
|
||||||
decodeObj.ans.push("no");
|
decodeObj.ans.push("no");
|
||||||
break;
|
break;
|
||||||
|
|||||||
2
main.js
2
main.js
@ -675,7 +675,7 @@ window.onblur = function () {
|
|||||||
if (main.core && main.core.control) {
|
if (main.core && main.core.control) {
|
||||||
try {
|
try {
|
||||||
main.core.control.checkAutosave();
|
main.core.control.checkAutosave();
|
||||||
} catch (e) {main.log(e);}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -397,6 +397,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
|||||||
"enableMoveDirectly": true,
|
"enableMoveDirectly": true,
|
||||||
"enableDisabledShop": true,
|
"enableDisabledShop": true,
|
||||||
"disableShopOnDamage": false,
|
"disableShopOnDamage": false,
|
||||||
|
"quickCommonEvents": false,
|
||||||
"checkConsole": false
|
"checkConsole": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,6 +237,83 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
|
|||||||
],
|
],
|
||||||
"false": []
|
"false": []
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"回收钥匙商店": [
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "公共事件:回收钥匙商店"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "addToList"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "使用上述事件并在全塔属性打开quickCommonEvent开关"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"text": "就可以在快捷列表(V键)中使用本公共事件"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "while",
|
||||||
|
"condition": "1",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"type": "choices",
|
||||||
|
"text": "\t[商人,woman]你有多余的钥匙想要出售吗?",
|
||||||
|
"choices": [
|
||||||
|
{
|
||||||
|
"text": "黄钥匙(10金币)",
|
||||||
|
"color": [
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"action": [
|
||||||
|
{
|
||||||
|
"type": "if",
|
||||||
|
"condition": "item:yellowKey >= 1",
|
||||||
|
"true": [
|
||||||
|
{
|
||||||
|
"type": "addValue",
|
||||||
|
"name": "item:yellowKey",
|
||||||
|
"value": "-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "addValue",
|
||||||
|
"name": "status:money",
|
||||||
|
"value": "10"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"false": [
|
||||||
|
"\t[商人,woman]你没有黄钥匙!"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "蓝钥匙(50金币)",
|
||||||
|
"color": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
255,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"action": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "离开",
|
||||||
|
"action": [
|
||||||
|
{
|
||||||
|
"type": "exit"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -699,7 +699,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
gid = guards[i][2];
|
gid = guards[i][2];
|
||||||
// 递归计算支援怪伤害信息,这里不传x,y保证不会重复调用
|
// 递归计算支援怪伤害信息,这里不传x,y保证不会重复调用
|
||||||
// 这里的mdef传0,因为护盾应该只会被计算一次
|
// 这里的mdef传0,因为护盾应该只会被计算一次
|
||||||
var info = core.enemys.getDamageInfo(core.material.enemys[gid], origin_hero_hp, origin_hero_atk, origin_hero_def, 0);
|
var info = core.enemys.getDamageInfo(core.material.enemys[gid], { hp: origin_hero_hp, atk: origin_hero_atk, def: origin_hero_def, mdef: 0 });
|
||||||
if (info == null) { // 小队中任何一个怪物不可战斗,直接返回null
|
if (info == null) { // 小队中任何一个怪物不可战斗,直接返回null
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user