优化默认系统事件

This commit is contained in:
ckcz123 2020-05-13 19:34:54 +08:00
parent 50a0eda71f
commit 1faad822fb
8 changed files with 27 additions and 75 deletions

View File

@ -278,9 +278,8 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"values": [ "values": [
"null", "null",
"openDoor", "openDoor",
"passNet",
"changeLight",
"pushBox", "pushBox",
"ski",
"custom" "custom"
] ]
}, },

View File

@ -70,23 +70,11 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_lint": true, "_lint": true,
"_data": "道具后脚本" "_data": "道具后脚本"
}, },
"afterChangeLight": {
"_leaf": true,
"_type": "textarea",
"_lint": true,
"_data": "改变亮灯后"
},
"afterPushBox": { "afterPushBox": {
"_leaf": true, "_leaf": true,
"_type": "textarea", "_type": "textarea",
"_lint": true, "_lint": true,
"_data": "推箱子后" "_data": "推箱子后"
},
"afterPassNet": {
"_leaf": true,
"_type": "textarea",
"_lint": true,
"_data": "特殊地形后"
} }
} }
}, },

View File

@ -658,7 +658,7 @@ control.prototype._moveAction_moving = function (callback) {
core.events._trigger(nowx, nowy); core.events._trigger(nowx, nowy);
// 检查该点是否是滑冰 // 检查该点是否是滑冰
if (core.getBgNumber() == 167) { if (core.onSki()) {
core.insertAction("滑冰事件", null, null, null, true); core.insertAction("滑冰事件", null, null, null, true);
} }

View File

@ -317,7 +317,7 @@ events.prototype._trigger = function (x, y) {
eval(block.event.script); eval(block.event.script);
} catch (e) { main.log(e); } } catch (e) { main.log(e); }
if (block.event.trigger) { if (block.event.trigger && block.event.trigger != 'null') {
var noPass = block.event.noPass, trigger = block.event.trigger; var noPass = block.event.noPass, trigger = block.event.trigger;
if (noPass) core.clearAutomaticRouteNode(x, y); if (noPass) core.clearAutomaticRouteNode(x, y);
@ -708,33 +708,6 @@ events.prototype.visitFloor = function (floorId) {
core.getFlag("__visited__")[floorId] = true; core.getFlag("__visited__")[floorId] = true;
} }
events.prototype._sys_passNet = function (data, callback) {
this.passNet(data);
if (callback) callback();
}
////// 经过一个路障 //////
events.prototype.passNet = function (data) {
if (!core.hasItem('shoes')) {
// 血网 lavaNet 移动到 checkBlock 中处理
if (data.event.id == 'poisonNet') { // 毒网
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[0]});
}
else if (data.event.id == 'weakNet') { // 衰网
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[1]});
}
else if (data.event.id == 'curseNet') { // 咒网
core.insertAction({"type":"insert","name":"毒衰咒处理","args":[2]});
}
}
this.afterPassNet(data.x, data.y, data.event.id);
core.updateStatusBar();
}
events.prototype.afterPassNet = function (x, y, id) {
if (this.eventdata.afterPassNet) this.eventdata.afterPassNet(x, y, id);
}
events.prototype._sys_pushBox = function (data, callback) { events.prototype._sys_pushBox = function (data, callback) {
this.pushBox(data); this.pushBox(data);
if (callback) callback(); if (callback) callback();
@ -749,7 +722,15 @@ events.prototype.pushBox = function (data) {
nx = data.x + core.utils.scan[direction].x, ny = data.y + core.utils.scan[direction].y; nx = data.x + core.utils.scan[direction].x, ny = data.y + core.utils.scan[direction].y;
// 检测能否推上去 // 检测能否推上去
if (!core.canMoveHero() || !core.canMoveHero(data.x, data.y, direction)) return; if (!core.canMoveHero()) return;
var canGoDeadZone = core.flags.canGoDeadZone;
core.flags.canGoDeadZone = false;
if (!core.canMoveHero(data.x, data.y, direction)) {
core.flags.canGoDeadZone = canGoDeadZone;
return;
}
core.flags.canGoDeadZone = canGoDeadZone;
var nextId = core.getBlockId(nx, ny); var nextId = core.getBlockId(nx, ny);
if (nextId != null && nextId != 'flower') return; if (nextId != null && nextId != 'flower') return;
@ -784,22 +765,17 @@ events.prototype.afterPushBox = function () {
return this.eventdata.afterPushBox(); return this.eventdata.afterPushBox();
} }
events.prototype._sys_changeLight = function (data, callback) {
core.events.changeLight(data.event.id, data.x, data.y);
if (callback) callback();
}
////// 改变亮灯(感叹号)的事件 //////
events.prototype.changeLight = function (id, x, y) {
if (id != null && id != 'light') return;
core.setBlock(core.getNumberById('darkLight'), x, y);
return this.eventdata.afterChangeLight(x, y);
}
events.prototype._sys_ski = function (data, callback) { events.prototype._sys_ski = function (data, callback) {
core.insertAction(["V2.6后,请将滑冰放在背景层!"], data.x, data.y, callback); core.insertAction(["V2.6后,请将滑冰放在背景层!"], data.x, data.y, callback);
} }
/// 当前是否在冰上
events.prototype.onSki = function (number) {
if (number == null) number = core.getBgNumber();
var block = core.getBlockByNumber(number);
return block && block.event && block.event.trigger == 'ski';
}
events.prototype._sys_action = function (data, callback) { events.prototype._sys_action = function (data, callback) {
var ev = core.clone(data.event.data), ex = data.x, ey = data.y; var ev = core.clone(data.event.data), ex = data.x, ey = data.y;
// 检查是否需要改变朝向 // 检查是否需要改变朝向

View File

@ -596,7 +596,7 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans) {
if (!core.inArray(canMoveArray[x][y], direction)) continue; if (!core.inArray(canMoveArray[x][y], direction)) continue;
var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y, nindex = nx + "," + ny; var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y, nindex = nx + "," + ny;
if (visited[nindex]) continue; if (visited[nindex]) continue;
if (bgMap[ny][nx] == 167) continue; if (core.onSki(bgMap[ny][nx])) continue;
if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny)) continue; if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny)) continue;
visited[nindex] = visited[now] + 1; visited[nindex] = visited[now] + 1;
// if (nx == ex && ny == ey) return visited[nindex]; // if (nx == ex && ny == ey) return visited[nindex];

View File

@ -163,7 +163,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
}, },
{ {
"type": "if", "type": "if",
"condition": "core.getBgNumber() == 167", "condition": "core.onSki()",
"true": [ "true": [
{ {
"type": "if", "type": "if",

View File

@ -404,10 +404,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (todo.length > 0) core.insertAction(todo, x, y); if (todo.length > 0) core.insertAction(todo, x, y);
if (callback) callback(); if (callback) callback();
},
"afterChangeLight": function(x,y) {
// 改变亮灯之后,可以触发的事件
}, },
"afterPushBox": function () { "afterPushBox": function () {
// 推箱子后的事件 // 推箱子后的事件
@ -421,13 +417,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
} }
*/ */
} }
},
"afterPassNet": function (x, y, id) {
// 经过特殊地形后的事件x和y为当前坐标id为当前的图块id
// 这是个一次性血网的例子
// if (id == 'lavaNet') core.removeBlock(x, y);
}, },
}, },
"enemys": { "enemys": {
@ -1077,7 +1066,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
enemy = core.material.enemys[id]; enemy = core.material.enemys[id];
// 血网 // 血网
if (id == 'lavaNet' && block.event.trigger == 'passNet' && !core.hasItem('shoes')) { if (id == 'lavaNet' && !core.hasItem('shoes')) {
damage[loc] = (damage[loc] || 0) + core.values.lavaDamage; damage[loc] = (damage[loc] || 0) + core.values.lavaDamage;
type[loc] = "血网伤害"; type[loc] = "血网伤害";
} }

View File

@ -10,10 +10,10 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e =
"8": {"cls":"terrains","id":"blueShopRight"}, "8": {"cls":"terrains","id":"blueShopRight"},
"9": {"cls":"terrains","id":"pinkShopLeft"}, "9": {"cls":"terrains","id":"pinkShopLeft"},
"10": {"cls":"terrains","id":"pinkShopRight"}, "10": {"cls":"terrains","id":"pinkShopRight"},
"11": {"cls":"animates","id":"lavaNet","canPass":true,"trigger":"passNet"}, "11": {"cls":"animates","id":"lavaNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 血网的伤害效果移动到 checkBlock 中处理\n\n\t// 如果要做一次性血网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})();"},
"12": {"cls":"animates","id":"poisonNet","canPass":true,"trigger":"passNet"}, "12": {"cls":"animates","id":"poisonNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行毒处理\n\tif (!core.hasItem('shoes')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [0] });\n\t}\n\n\t// 如果要做一次性毒网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()"},
"13": {"cls":"animates","id":"weakNet","canPass":true,"trigger":"passNet"}, "13": {"cls":"animates","id":"weakNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行衰处理\n\tif (!core.hasItem('shoes')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [1] });\n\t}\n\n\t// 如果要做一次性衰网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()"},
"14": {"cls":"animates","id":"curseNet","canPass":true,"trigger":"passNet"}, "14": {"cls":"animates","id":"curseNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行咒处理\n\tif (!core.hasItem('shoes')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [2] });\n\t}\n\n\t// 如果要做一次性咒网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()"},
"15": {"cls":"animates","id":"blueWater"}, "15": {"cls":"animates","id":"blueWater"},
"16": {"cls":"animates","id":"water"}, "16": {"cls":"animates","id":"water"},
"20": {"cls":"autotile","id":"autotile"}, "20": {"cls":"autotile","id":"autotile"},
@ -109,7 +109,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e =
"162": {"cls":"terrains","id":"arrowDown","canPass":true,"cannotOut":["left","right","up"],"cannotIn":["down"]}, "162": {"cls":"terrains","id":"arrowDown","canPass":true,"cannotOut":["left","right","up"],"cannotIn":["down"]},
"163": {"cls":"terrains","id":"arrowLeft","canPass":true,"cannotOut":["up","down","right"],"cannotIn":["left"]}, "163": {"cls":"terrains","id":"arrowLeft","canPass":true,"cannotOut":["up","down","right"],"cannotIn":["left"]},
"164": {"cls":"terrains","id":"arrowRight","canPass":true,"cannotOut":["up","down","left"],"cannotIn":["right"]}, "164": {"cls":"terrains","id":"arrowRight","canPass":true,"cannotOut":["up","down","left"],"cannotIn":["right"]},
"165": {"cls":"terrains","id":"light","trigger":"changeLight","canPass":true}, "165": {"cls":"terrains","id":"light","trigger":"null","canPass":true,"script":"(function () {\n\tcore.setBlock(core.getNumberById('darkLight'), core.getHeroLoc('x'), core.getHeroLoc('y'));\n})();"},
"166": {"cls":"terrains","id":"darkLight"}, "166": {"cls":"terrains","id":"darkLight"},
"167": {"cls":"terrains","id":"ski","trigger":"ski","canPass":true}, "167": {"cls":"terrains","id":"ski","trigger":"ski","canPass":true},
"168": {"cls":"terrains","id":"flower","canPass":true}, "168": {"cls":"terrains","id":"flower","canPass":true},