Floor ParallelDo
This commit is contained in:
parent
cd530d62b4
commit
69e44861aa
@ -359,6 +359,13 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
|||||||
"_event": "firstArrive",
|
"_event": "firstArrive",
|
||||||
"_data": "第一次到该楼层触发的事件,可以双击进入事件编辑器。"
|
"_data": "第一次到该楼层触发的事件,可以双击进入事件编辑器。"
|
||||||
},
|
},
|
||||||
|
"parallelDo": {
|
||||||
|
"_leaf": true,
|
||||||
|
"_type": "textarea",
|
||||||
|
"_string": true,
|
||||||
|
"_lint": true,
|
||||||
|
"_data": "在该层楼时执行的并行事件处理。\n可以在这里写上任意需要自动执行的脚本,比如打怪自动开门等。\n详见文档-个性化-并行事件处理。"
|
||||||
|
},
|
||||||
"underGround": {
|
"underGround": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "checkbox",
|
"_type": "checkbox",
|
||||||
|
|||||||
@ -157,6 +157,7 @@ editor_file = function (editor, callback) {
|
|||||||
color: saveStatus?currData.color:null,
|
color: saveStatus?currData.color:null,
|
||||||
weather: saveStatus?currData.weather:null,
|
weather: saveStatus?currData.weather:null,
|
||||||
firstArrive: [],
|
firstArrive: [],
|
||||||
|
parallelDo: null,
|
||||||
events: {},
|
events: {},
|
||||||
changeFloor: {},
|
changeFloor: {},
|
||||||
afterBattle: {},
|
afterBattle: {},
|
||||||
|
|||||||
@ -1611,6 +1611,8 @@ core.insertAction([
|
|||||||
|
|
||||||
在脚本编辑里面提供了一个parallelDo函数,这个函数可以用来做并行处理内容。
|
在脚本编辑里面提供了一个parallelDo函数,这个函数可以用来做并行处理内容。
|
||||||
|
|
||||||
|
从V2.5.2开始,每层楼的楼层属性中也增加了一个parallelDo选项,可以在里面写任何脚本代码。该部分代码仅在人物在该楼层时才会被反复执行。
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
"parallelDo": function (timestamp) {
|
"parallelDo": function (timestamp) {
|
||||||
// 并行事件处理,可以在这里写任何需要并行处理的脚本或事件
|
// 并行事件处理,可以在这里写任何需要并行处理的脚本或事件
|
||||||
@ -1619,6 +1621,15 @@ core.insertAction([
|
|||||||
|
|
||||||
// 检查当前是否处于游戏开始状态
|
// 检查当前是否处于游戏开始状态
|
||||||
if (!core.isPlaying()) return;
|
if (!core.isPlaying()) return;
|
||||||
|
|
||||||
|
// 执行当前楼层的并行事件处理
|
||||||
|
if (core.isset(core.status.floorId)) {
|
||||||
|
try {
|
||||||
|
eval(core.floors[core.status.floorId].parallelDo);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 下面是一个并行事件开门的样例
|
// 下面是一个并行事件开门的样例
|
||||||
/*
|
/*
|
||||||
@ -1644,6 +1655,22 @@ core.insertAction([
|
|||||||
|
|
||||||
!> 判定flag后千万别忘了将该flag清空!否则下次仍然会执行这段代码。
|
!> 判定flag后千万别忘了将该flag清空!否则下次仍然会执行这段代码。
|
||||||
|
|
||||||
|
每层楼的并行事件处理类似,只有角色在当前楼层时才会反复执行当前楼层中parallelDo部分的代码。
|
||||||
|
|
||||||
|
下面是一个打怪开门的样例:(假设每打一个怪的战后事件把`flag:door`+1)
|
||||||
|
|
||||||
|
``` js
|
||||||
|
// 每层楼的并行事件处理代码样例
|
||||||
|
if (core.getFlag("door",0)==2) {
|
||||||
|
// 将该flag清空
|
||||||
|
core.setFlag("door", 0);
|
||||||
|
// 开门,如果是当前层则无需写floorId
|
||||||
|
core.insertAction([
|
||||||
|
{"type":"openDoor", "loc":[0,0]}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 加点事件
|
## 加点事件
|
||||||
|
|
||||||
打败怪物后可以进行加点。
|
打败怪物后可以进行加点。
|
||||||
|
|||||||
@ -28,7 +28,14 @@ items.prototype.getItemEffect = function(itemId, itemNum) {
|
|||||||
if (itemCls === 'items') {
|
if (itemCls === 'items') {
|
||||||
var ratio = parseInt(core.status.thisMap.item_ratio) || 1;
|
var ratio = parseInt(core.status.thisMap.item_ratio) || 1;
|
||||||
var curr_hp = core.status.hero.hp;
|
var curr_hp = core.status.hero.hp;
|
||||||
if (itemId in this.itemEffect)eval(this.itemEffect[itemId]);
|
if (itemId in this.itemEffect) {
|
||||||
|
try {
|
||||||
|
eval(this.itemEffect[itemId]);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
|
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -42,7 +49,14 @@ items.prototype.getItemEffectTip = function(itemId) {
|
|||||||
// 消耗品
|
// 消耗品
|
||||||
if (itemCls === 'items') {
|
if (itemCls === 'items') {
|
||||||
var ratio = parseInt(core.status.thisMap.item_ratio) || 1;
|
var ratio = parseInt(core.status.thisMap.item_ratio) || 1;
|
||||||
if (itemId in this.itemEffectTip) return eval(this.itemEffectTip[itemId])||"";
|
if (itemId in this.itemEffectTip) {
|
||||||
|
try {
|
||||||
|
return eval(this.itemEffectTip[itemId])||"";
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2311,7 +2311,10 @@ ui.prototype.drawStatistics = function () {
|
|||||||
if (cls[id]=='items' && id!='superPotion') {
|
if (cls[id]=='items' && id!='superPotion') {
|
||||||
var ratio = floor.item_ratio||1;
|
var ratio = floor.item_ratio||1;
|
||||||
if (core.isset(core.items.itemEffect[id])) {
|
if (core.isset(core.items.itemEffect[id])) {
|
||||||
eval(core.items.itemEffect[id]);
|
try {
|
||||||
|
eval(core.items.itemEffect[id]);
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
}
|
}
|
||||||
hp = core.status.hero.hp - temp.hp;
|
hp = core.status.hero.hp - temp.hp;
|
||||||
atk = core.status.hero.atk - temp.atk;
|
atk = core.status.hero.atk - temp.atk;
|
||||||
|
|||||||
@ -87,9 +87,11 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
"afterChangeFloor": function (floorId, fromLoad) {
|
"afterChangeFloor": function (floorId, fromLoad) {
|
||||||
// 转换楼层结束的事件
|
// 转换楼层结束的事件
|
||||||
// floorId是切换到的楼层;fromLoad若为true则代表是从读档行为造成的楼层切换
|
// floorId是切换到的楼层;fromLoad若为true则代表是从读档行为造成的楼层切换
|
||||||
if (!core.hasFlag("visited_"+floorId)) {
|
var visited = core.getFlag("__visited__", []);
|
||||||
|
if (visited.indexOf(floorId)===-1) {
|
||||||
core.insertAction(core.floors[floorId].firstArrive);
|
core.insertAction(core.floors[floorId].firstArrive);
|
||||||
core.setFlag("visited_"+floorId, true);
|
visited.push(floorId);
|
||||||
|
core.setFlag("__visited__", visited);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"addPoint": function (enemy) {
|
"addPoint": function (enemy) {
|
||||||
@ -1034,7 +1036,16 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
|
|
||||||
// 检查当前是否处于游戏开始状态
|
// 检查当前是否处于游戏开始状态
|
||||||
if (!core.isPlaying()) return;
|
if (!core.isPlaying()) return;
|
||||||
|
|
||||||
|
// 执行当前楼层的并行事件处理
|
||||||
|
if (core.isset(core.status.floorId)) {
|
||||||
|
try {
|
||||||
|
eval(core.floors[core.status.floorId].parallelDo);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 下面是一个并行事件开门的样例
|
// 下面是一个并行事件开门的样例
|
||||||
/*
|
/*
|
||||||
// 如果某个flag为真
|
// 如果某个flag为真
|
||||||
@ -1048,7 +1059,8 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
// 也可以写任意其他的脚本代码
|
// 也可以写任意其他的脚本代码
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
"plugin": function () {
|
"plugin": function () {
|
||||||
////// 插件编写,可以在这里写自己额外需要执行的脚本 //////
|
////// 插件编写,可以在这里写自己额外需要执行的脚本 //////
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user