机关门绑定

This commit is contained in:
strawberry 2025-07-29 15:01:34 +08:00
parent 4bc212f292
commit a709ceb77b
4 changed files with 94 additions and 4 deletions

View File

@ -867,6 +867,7 @@ action
| battle_s
| battle_1_s
| openDoor_s
| specialDoor_s
| closeDoor_s
| changebg_s
| changeFloor_s
@ -2193,6 +2194,23 @@ var code = '{"type": "openDoor"'+floorstr+IdString_0+Bool_0+Bool_1+'},\n';
return code;
*/;
specialDoor_s
: '怪物坐标 x' EvalString? ',y' EvalString? ',' '门坐标x'EvalString? 'y'EvalString? '战后开启机关门' Newline
/* specialDoor_s
tooltip : specialDoor: 战后开启机关门,需在每个机关怪物使用该战后事件,
helpUrl : /_docs/#/instruction
default : ["","","",""]
selectPoint : ["EvalString_2", "EvalString_3"]
colour : this.mapColor
var enemy =MotaActionFunctions.processMultiLoc(EvalString_0, EvalString_1)
var doors=MotaActionFunctions.processMultiDoors(EvalString_2, EvalString_3);
var code = '{"type": "specialDoor"'+enemy+doors+'},\n';
return code;
*/;
closeDoor_s
: '关门' 'x' PosString? ',' 'y' PosString? 'ID' IdString '不等待执行完毕' Bool Newline

View File

@ -1508,6 +1508,32 @@ MotaActionParser = function () {
this.next,
]);
break;
case "specialDoor": // 机关门
data.loc = data.loc || [];
data.doors = data.doors || [];
if (!(data.loc[0] instanceof Array)) data.loc = [data.loc];
if (!(data.doors[0] instanceof Array)) data.doors = [data.doors];
var x_str = [],
y_str = [],
door_x=[],
door_y=[];
data.loc.forEach(function (t) {
x_str.push(t[0]);
y_str.push(t[1]);
});
data.doors.forEach(function (t) {
door_x.push(t[0]);
door_y.push(t[1]);
});
this.next = MotaActionBlocks["specialDoor_s"].xmlText([
x_str.join(","),
y_str.join(","),
door_x.join(","),
door_y.join(","),
this.next,
]);
break;
case "closeDoor": // 关一个门,需要该点无事件
data.loc = data.loc || ["", ""];
this.next = MotaActionBlocks["closeDoor_s"].xmlText([
@ -3074,6 +3100,30 @@ MotaActionParser = function () {
return floorstr;
};
MotaActionFunctions.processMultiDoors = function (EvalString_0, EvalString_1) {
var floorstr = "";
if (EvalString_0 && EvalString_1) {
var x = EvalString_0,
y = EvalString_1;
var pattern = /^([+-]?\d+)(, ?[+-]?\d+)*$/;
if (
pattern.test(x) &&
pattern.test(y) &&
x.split(",").length == y.split(",").length
) {
x = x.split(",");
y = y.split(",");
for (var ii = 0; ii < x.length; ii++)
x[ii] = "[" + x[ii].trim() + "," + y[ii].trim() + "]";
floorstr = ', "doors": [' + x.join(",") + "]";
}
if (floorstr == "") {
floorstr = ', "doors": ["' + x + '","' + y + '"]';
}
}
return floorstr;
};
MotaActionFunctions.StepString_pre = function (StepString) {
//StepString='上右3下2左上左2'
var route = StepString.replace(/上/g, "U")

View File

@ -653,7 +653,7 @@ editor_mappanel_wrapper = function (editor) {
}
if (bindSpecialDoor.loc == null || bindSpecialDoor.enemys.length != bindSpecialDoor.n) return;
// 添加机关门自动事件
var doorFlag = "flag:door_" + editor.currentFloorId + "_" + bindSpecialDoor.loc.replace(',', '_');
/*var doorFlag = "flag:door_" + editor.currentFloorId + "_" + bindSpecialDoor.loc.replace(',', '_');
editor.currentFloorData.autoEvent[bindSpecialDoor.loc] = {
'0': {
"condition": doorFlag + "==" + bindSpecialDoor.n,
@ -666,11 +666,14 @@ editor_mappanel_wrapper = function (editor) {
{ "type": "setValue", "name": doorFlag, "operator": "=", "value": "null" },
]
}
};
bindSpecialDoor.enemys.forEach(function (loc) {
};*/
var enemys=bindSpecialDoor.enemys.map(function (loc) {
return loc.split(",")
})
bindSpecialDoor.enemys.forEach(function (loc,_i,arr){
if (!editor.currentFloorData.afterBattle[loc])
editor.currentFloorData.afterBattle[loc] = [];
editor.currentFloorData.afterBattle[loc].push({ "type": "setValue", "name": doorFlag, "operator": "+=", "value": "1" });
editor.currentFloorData.afterBattle[loc].push({"type": "specialDoor", "loc": enemys, "doors": [bindSpecialDoor.loc.split(",")]},);
});
editor.file.saveFloorFile(function (err) {
if (err) {

View File

@ -79,6 +79,24 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.removeMouse(data.div);
core.doAction();
});
core.registerEvent("specialDoor", function (data) {
let bool = true;
let loc_arr = data.loc[0] instanceof Array ? data.loc : [data.loc]
loc_arr.forEach(loc => {
if (core.getBlockCls(loc[0], loc[1]) && core.getBlockCls(loc[0], loc[1]).startsWith("enemys")) {
bool = false;
}
});
if (bool) {
let doors = data.doors[0] instanceof Array ? data.doors : [data.doors]
let action = []
doors.forEach(v => action.push({ "type": "openDoor", "loc": [v[0], v[1]], "async": true }))
action.push({ "type": "waitAsync" })
core.insertAction(action)
}
core.doAction();
});
core.registerEvent("animationDrawable", function (data) {
if (!main.replayChecking && !core.isReplaying()) {
core.animationDrawable(
@ -12248,6 +12266,7 @@ let time=0
地图处理: [
MotaActionBlocks["battle_1_s"].xmlText(),
MotaActionBlocks["openDoor_s"].xmlText(),
MotaActionBlocks["specialDoor_s"].xmlText(),
MotaActionBlocks["closeDoor_s"].xmlText(),
MotaActionBlocks["show_s"].xmlText(),
MotaActionBlocks["hide_s"].xmlText(),