diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 4004f8a..e08294e 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -39,6 +39,23 @@ var code = '[\n'+action_0+']\n'; return code; */; +//taskEvent 事件编辑器入口之一 +taskEvent_m + : '任务描述' EvalString_Multi? BGNL? Newline + '需完成的最低子任务数' Int BGNL? Newline + tasksList+ Newline + '完成奖励' BGNL? Newline action+ + + +/* taskEvent_m +colour : this.tasksColor +default :["任务描述",1] +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var code = '{"type":"taskEvent"'+EvalString_Multi_0+',"n":'+Int_0+',"info":['+tasksList_0+'\n]'+', "action": [\n' + action_0 + ']}\n' +return code; +*/; + + //事件 事件编辑器入口之一 event_m @@ -977,6 +994,15 @@ action | over_s | overlist_s | cgtextList_s + | setTask_s + | removeTask_s + | removeTaskByName_s + | successTask_s + | successTaskByName_s + | clearTask_s + | submitTask_s + | trymitTask_s + | trymitTaskByName_s | pass_s ; @@ -4289,6 +4315,298 @@ var code = ' \n'; return code; */; +setTask_s + : '接取任务 任务名' EvalString Newline + +/* setTask_s +tooltip :接取任务 +colour : this.tasksColor +default :["mission name"] + +var code = '{"type":"setTask","name":"'+EvalString_0+'"},\n' +return code; +*/; + +tasksList + : checkItem + | checkStatus + | checkFlag + | checkBlock + | kill + | killLocs + | killSpecial + | killAll + | specialBlock + | gosthFloor + | arrival + | empty; + +checkItem + : '道具ID' IdString TaskOperator_List '数量' Int '子任务描述' EvalString_Multi? BGNL? Newline +/* checkItem +tooltip : 检查道具数量 +default : ["yellowKey",">=",0,""] +colour : this.childColor +allItems : ['IdString_0'] +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var code = '{"type":"checkItem","checkItem":"'+IdString_0+'","operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_0+'},'; +return code; + */; + +checkStatus + :'检查' Status_List '属性' TaskOperator_List Int '子任务描述' EvalString_Multi? BGNL? Newline +/* checkStatus +tooltip : 检查属性数值 +default : ["atk",">=",10,""] +colour : this.childColor +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var code = '{"type":"checkStatus","checkStatus":"'+Status_List_0+'","operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_0+'},'; +return code; + */; + +checkFlag + :'检查Flag变量' EvalString TaskOperator_List expression '子任务描述'EvalString_Multi? BGNL? Newline +/* checkFlag +tooltip : 检查Flag变量 +default : ["flag1","=","",""] +colour : this.childColor +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var code = '{"type":"checkFlag","checkFlag":"'+EvalString_0+'","operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":"'+expression_0+'"},'; +return code; +*/; + +checkBlock + :'检查地面图块数量' EvalString '楼层' EvalString TaskOperator_List Int '子任务描述' EvalString_Multi? BGNL? Newline +/* checkBlock +tooltip : 检查地面图块数量 +default : ["ju87b","MT1,MT2","<=",0,""] +colour : this.childColor +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var thisFloorId=EvalString_1.split(",") +thisFloorId=thisFloorId.map(function(v){return '"'+v.trim()+'"'}) +var floorstr=',"floorId":['+thisFloorId.join(",")+']' +var code = '{"type":"checkBlock","checkBlock":"'+EvalString_0+'"'+floorstr+',"operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_0+'},'; +return code; +*/; + + +kill + :'击杀' IdString? '敌人楼层' EvalString? TaskOperator_List Int'子任务描述' EvalString_Multi? BGNL? Newline +/* kill +tooltip : 击杀一定数量的敌人 +default : ["","",">",0,""] +colour : this.childColor +allEnemys : ['IdString_0'] +IdString_0=IdString_0?(',"kill": "'+IdString_0+'"'):''; +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +if(EvalString_0){ +var thisFloorId=EvalString_0.split(",") +thisFloorId=thisFloorId.map(function(v){return '"'+v.trim()+'"'}) +var floorstr=',"floorId":['+thisFloorId.join(",")+']' +}else { +var floorstr="" +} +var code = '{"type":"kill"'+IdString_0+floorstr+',"operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_0+'},'; +return code; +*/; + +killLocs + :'击杀x' EvalString 'y' EvalString '楼层' IdString '位置的敌人' TaskOperator_List Int'子任务描述' EvalString_Multi? BGNL? Newline +/* killLocs +tooltip : 击杀某些位置的敌人 +default : ["1","1","MT1",">=",1,""] +colour : this.childColor +allFloorIds : ['IdString_0'] +selectPoint : ["EvalString_0","EvalString_1","IdString_0"] +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var floorstr = MotaActionFunctions.processMultiLoc(EvalString_0,EvalString_1); +var code = '{"type":"killLocs"'+floorstr+',"floorId":"'+IdString_0+'","operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_0+'},'; +return code; +*/; + +killSpecial + :'击杀拥有' Int '技能的敌人楼层' EvalString? TaskOperator_List Int '子任务描述' EvalString_Multi? BGNL? Newline +/* killSpecial +tooltip : 击杀一定数量的某种敌人 +default : [61,"MT1,MT2",">=",1,""] +colour : this.childColor +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +if(EvalString_0){ +var thisFloorId=EvalString_0.split(",") +thisFloorId=thisFloorId.map(function(v){return '"'+v.trim()+'"'}) +var floorstr=',"floorId":['+thisFloorId.join(",")+']' +}else { +var floorstr="" +} +var code = '{"type":"killSpecial","killSpecial":"'+Int_0+'"'+floorstr+',"operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_1+'},'; +return code; +*/; + +killAll + :'击杀楼层' EvalString '所有敌人' '子任务描述' EvalString_Multi? BGNL? Newline +/* killAll +tooltip : 击杀某些楼层所有敌人 +default : ["MT1",""] +colour : this.childColor +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var thisFloorId=EvalString_0.split(",") +thisFloorId=thisFloorId.map(function(v){return '"'+v.trim()+'"'}) +var floorstr=',"floorId":['+thisFloorId.join(",")+']' +var code = '{"type":"killAll"'+floorstr+EvalString_Multi_0+'},'; +return code; +*/; + +specialBlock + :'在楼层' EvalString? '受到' MapDamage_List '地图伤害次数' TaskOperator_List Int '子任务描述' EvalString_Multi? BGNL? Newline +/* specialBlock +tooltip : 在某些楼层受到一定次数的地图伤害 +default : ["MT1","血网伤害","<",1,""] +colour : this.childColor +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +if(EvalString_0){ +var thisFloorId=EvalString_0.split(",") +thisFloorId=thisFloorId.map(function(v){return '"'+v.trim()+'"'}) +var floorstr=',"floorId":['+thisFloorId.join(",")+']' +}else { +var floorstr="" +} +var code = '{"type":"specialBlock"'+floorstr+',"specialBlock":"'+MapDamage_List_0+'"'+',"operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_0+'},' +return code; +*/; + +gosthFloor + :'切换至楼层' EvalString? '次数' TaskOperator_List Int '子任务描述' EvalString_Multi? BGNL? Newline +/* gosthFloor +tooltip : 切换/到达某楼层不超过一定次数 +default : ["MT1","<",1,""] +colour : this.childColor +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +if(EvalString_0){ +var thisFloorId=EvalString_0.split(",") +thisFloorId=thisFloorId.map(function(v){return '"'+v.trim()+'"'}) +var floorstr=',"floorId":['+thisFloorId.join(",")+']' +}else { +var floorstr="" +} +var code = '{"type":"gosthFloor"'+floorstr+',"operator":"'+TaskOperator_List_0+'"'+EvalString_Multi_0+',"count":'+Int_0+'},' +return code; +*/; + +arrival + :'抵达' IdString '子任务描述' EvalString_Multi? BGNL? Newline +/* arrival +tooltip : 抵达某楼层 +default : ["MT1",""] +colour : this.childColor +allFloorIds : ['IdString_0'] +EvalString_Multi_0=EvalString_Multi_0?(',"text": "'+EvalString_Multi_0+'"'): ''; +var code = '{"type":"arrival","floorId":"'+IdString_0+'"'+EvalString_Multi_0+'},' +return code; +*/; + +empty + : Newline + + +/* empty +var code = ' \n'; +return code; +*/; + + + +removeTask_s + : '移除第' Int '项任务' + + +/* removeTask_s +tooltip : 移除第n项任务。 +colour : this.tasksColor +default :[0] +var code = '{"type":"removeTask","index":'+Int_0+'},\n'; +return code; +*/; + +removeTaskByName_s + : '移除名为' EvalString '的任务' + + +/* removeTaskByName_s +tooltip : 移除某一任务。 +colour : this.tasksColor +default :["mission's name"] +var code = '{"type":"removeTaskByName","name":"'+EvalString_0+'"},\n'; +return code; +*/; + +successTask_s + : '完成第' Int '项任务' + + +/* successTask_s +tooltip : 强制完成第n项任务时。 +colour : this.tasksColor +default :[0] +var code = '{"type":"successTask","index":'+Int_0+'},\n'; +return code; +*/; + +successTaskByName_s + : '完成名为' EvalString '的任务' + + +/* successTaskByName_s +tooltip : 强制完成某一任务时。 +colour : this.tasksColor +default :["mission's name"] +var code = '{"type":"successTaskByName","name":"'+EvalString_0+'"},\n'; +return code; +*/; + +clearTask_s + : '删除所有任务' + + +/* clearTask_s +tooltip : 删除所有任务。 +colour : this.tasksColor +var code = '{"type":"clearTask"},\n'; +return code; +*/; + +submitTask_s + : '提交并清空任务' + + +/* submitTask_s +tooltip : 关卡结束时清空任务并提交。 +colour : this.tasksColor +var code = '{"type":"submitTask"},\n'; +return code; +*/; +trymitTask_s + : '尝试提交第' Int '项任务' + + +/* trymitTask_s +tooltip : 尝试提交第n项任务时(未完成时无效果)。 +colour : this.tasksColor +default :[0] +var code = '{"type":"trymitTask","index":'+Int_0+'},\n'; +return code; +*/; + +trymitTaskByName_s + : '尝试提交名为' EvalString '的任务' + + +/* trymitTaskByName_s +tooltip : 尝试提交某一任务时(未完成时无效果)。 +colour : this.tasksColor +default :["mission's name"] +var code = '{"type":"trymitTaskByName","name":"'+EvalString_0+'"},\n'; +return code; +*/; statExprSplit : '=== statement ^ === expression v ===' ; //===blockly表达式=== @@ -4830,6 +5148,15 @@ EnemyId_List EnemyPoint_List : '生命'|'攻击'|'防御'|'金币'|'经验'|'加点'|'名称' /*EnemyPoint_List ['hp','atk','def','money','exp','point','name']*/; +TaskOperator_List + : '等于'|'小于'|'小于等于'|'大于'|'大于等于' + /*TaskOperator_List ['=','<','<=','>','>=']*/; +Status_List + : '生命'|'攻击'|'防御'|'法强'|'速度'|'金币' + /*Status_List ['hp','atk','def','spell','speed','money']*/; +MapDamage_List + : '血网伤害'|'领域伤害'|'阻击伤害'|'激光伤害'|'夹击伤害' + /*MapDamage_List ['血网伤害','领域伤害','阻击伤害','激光伤害','夹击伤害']*/; Equip_List : '生命'|'生命上限'|'攻击'|'防御'|'法强'|'魔攻比例'|'护盾比例'|'法抗百分比'|'魔力'|'魔力上限'|'速度' @@ -4908,7 +5235,8 @@ LineComment this.evisitor.valueColor=330; this.evisitor.statementColor=70; this.evisitor.entryColor=250; - +this.evisitor.tasksColor=210 +this.evisitor.childColor=35 this.evisitor.idstring_eColor=310; this.evisitor.subColor=250; this.evisitor.dataColor=130; diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index 02a6d3c..dee390d 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -3,6 +3,125 @@ MotaActionParser = function () { ActionParser.prototype.parse = function (obj, type) { switch (type) { + case "taskEvent": // 设置任务 + if (!obj) obj = {"type":"taskEvent","text": "任务描述","n":1,"info":[ + {"type":"checkItem","checkItem":"yellowKey","operator":">=","count":0}, + {"type":"checkStatus","checkStatus":"atk","operator":">=","count":10}, + {"type":"checkFlag","checkFlag":"flag1","operator":"=","count":"\"value\""}, + {"type":"checkBlock","checkBlock":"bat","floorId":["MT1","MT2"],"operator":"<=","count":0}, + {"type":"kill","operator":">=","count":0}, + {"type":"killLocs", "loc": [[1,1]],"floorId":"MT1","operator":">=","count":1}, + {"type":"killSpecial","killSpecial":"61","floorId":["61"],"operator":">=","count":1}, + {"type":"killAll","floorId":["MT1"]}, + {"type":"specialBlock","floorId":["MT1"],"specialBlock":"血网伤害","operator":"<","count":1}, + {"type":"gosthFloor","floorId":["MT1"],"operator":"<","count":1}, + {"type":"arrival","floorId":"MT1"}, + ], "action": [ + ]}; + var that=this + var bulidTaskList = function (obj) { + var res = null; + for (var ii = obj.length - 1, one; (one = obj[ii]); ii--) { + if(one.type==="checkItem"){ + res = MotaActionBlocks["checkItem"].xmlText([ + one.checkItem, + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="checkStatus"){ + res = MotaActionBlocks["checkStatus"].xmlText([ + one.checkStatus, + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="checkFlag"){ + res = MotaActionBlocks["checkFlag"].xmlText([ + one.checkFlag, + one.operator, + that.expandEvalBlock([one.count]), + one.text||"", + res, + ]); + }else if(one.type==="checkBlock"){ + res = MotaActionBlocks["checkBlock"].xmlText([ + one.checkBlock, + one.floorId.join(","), + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="kill"){ + res = MotaActionBlocks["kill"].xmlText([ + one.kill||"", + one.floorId?one.floorId.join(","):"", + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="killLocs"){ + var x_str = [], + y_str = []; + one.loc.forEach(function(t){ + x_str.push(t[0]); + y_str.push(t[1]); + }); + res = MotaActionBlocks["killLocs"].xmlText([ + x_str.join(","), + y_str.join(","), + one.floorId, + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="killSpecial"){ + res = MotaActionBlocks["killSpecial"].xmlText([ + one.floorId.join(","), + one.killSpecial, + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="killAll"){ + res = MotaActionBlocks["killAll"].xmlText([ + one.floorId.join(","), + one.text||"", + res, + ]); + }else if(one.type==="specialBlock"){ + res = MotaActionBlocks["specialBlock"].xmlText([ + one.floorId.join(","), + one.specialBlock, + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="gosthFloor"){ + res = MotaActionBlocks["gosthFloor"].xmlText([ + one.floorId.join(","), + one.operator, + one.count, + one.text||"", + res, + ]); + }else if(one.type==="empty"){ + res = MotaActionBlocks["empty"].xmlText([ + res, + ]); + } + + } + return res; + }; + return MotaActionBlocks['taskEvent_m'].xmlText([obj.text||"",obj.n,bulidTaskList(obj.info),this.insertActionList(obj.action)]); case "event": if (!obj) obj = {}; if (typeof obj === typeof "") obj = { data: [obj] }; @@ -2572,6 +2691,34 @@ MotaActionParser = function () { } case "animateImage": // 兼容 animateImage break; + case "setTask": // 设置任务 + this.next = MotaActionBlocks['setTask_s'].xmlText([data.name,this.next ]); + break; + + case "removeTask": // 移除第n项任务 + this.next = MotaActionBlocks['removeTask_s'].xmlText([data.index,this.next ]); + break; + case "removeTaskByName": // 移除某一任务 + this.next = MotaActionBlocks['removeTaskByName_s'].xmlText([data.name,this.next ]); + break; + case "successTask": // 强制完成第n项任务 + this.next = MotaActionBlocks['successTask_s'].xmlText([data.index,this.next ]); + break; + case "successTaskByName": // 强制完成某一任务 + this.next = MotaActionBlocks['successTaskByName_s'].xmlText([data.name,this.next ]); + break; + case "trymitTask": // 尝试提交第n项任务 + this.next = MotaActionBlocks['trymitTask_s'].xmlText([data.index,this.next ]); + break; + case "trymitTaskTaskByName": // 尝试提交某一任务 + this.next = MotaActionBlocks['trymitTaskByName_s'].xmlText([data.name,this.next ]); + break; + case "clearTask": // 删除所有任务 + this.next = MotaActionBlocks['clearTask_s'].xmlText([this.next ]); + break; + case "submitTask": // 清除并提交任务 + this.next = MotaActionBlocks['submitTask_s'].xmlText([this.next ]); + break; default: this.next = MotaActionBlocks["unknown_s"].xmlText([ JSON.stringify(data), diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index b0f038c..b3fd551 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -692,6 +692,7 @@ editor_blocklyconfig = function () { "eachArrive", "commonEvent", "item", + "taskEvent" ]; return commonEntries.indexOf(editor_blockly.entryType) >= 0; }; diff --git a/_server/editor_file.js b/_server/editor_file.js index 1b4a200..9a14a4c 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -941,6 +941,7 @@ editor_file = function (editor, callback) { } var saveSetting = function (file, actionList, callback) { + var _update = function (name, value) { if (value[2] === undefined) { eval("delete " + name + value[1]); @@ -1089,6 +1090,7 @@ editor_file = function (editor, callback) { }); return; } + if (file == 'plugins') { actionList.forEach(function (value) { if(value[0]==='add'){ diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 151a3b8..afcfa6a 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -79,6 +79,7 @@ editor_mode = function (editor) { if (callback) callback(); } switch (mode) { + case 'loc': editor.file.editLoc(editor_mode.pos.x, editor_mode.pos.y, actionList, function (objs_) { cb(objs_); @@ -106,9 +107,14 @@ editor_mode = function (editor) { case 'commonevent': editor.file.editCommonEvent(actionList, cb); break; + case 'CommonEventTemplate': + editor.file.editCommonEventTemplate(actionList, cb) case 'plugins': editor.file.editPlugins(actionList, cb); break; + case 'task': + editor.file.editTask(actionList, cb); + break; default: break; } diff --git a/libs/control.js b/libs/control.js index 543527a..8998ca2 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1440,7 +1440,7 @@ control.prototype.checkBlock = function () { if (damage) { core.status.hero.hp -= damage; core.taskSystem.tasksInfo.forEach(v => v.tasks.forEach(a => { - if (a.type==="specialBlock"&&(!a.floorIds||a.floorIds.includes(core.status.floorId)) &&(core.status.checkBlock.type[loc]|| {})[a.specialType])a.has++ + if (a.type==="specialBlock"&&(!a.floorId||a.floorId.includes(core.status.floorId)) &&(core.status.checkBlock.type[loc]|| {})[a.specialType])a.has++ })) var text = Object.keys(core.status.checkBlock.type[loc] || {}).join(",") || "伤害"; @@ -2428,7 +2428,8 @@ control.prototype._replayAction_ignoreInput = function (action) { action.indexOf("input:") == 0 || action.indexOf("input2:") == 0 || action.indexOf("choices:") == 0 || - action.indexOf("random:") == 0 + action.indexOf("random:") == 0|| + action.indexOf("menu:") ) { console.warn("警告!录像播放中出现了未知的 " + action + "!"); core.replay(); diff --git a/libs/events.js b/libs/events.js index 3aabd20..3ed63fe 100644 --- a/libs/events.js +++ b/libs/events.js @@ -8,6 +8,7 @@ function events() { events.prototype._init = function () { this.eventdata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.events; this.commonEvent = events_c12a15a8_c380_4b28_8144_256cba95f760.commonEvent; + this.task = events_c12a15a8_c380_4b28_8144_256cba95f760.task; this.systemEvents = {}; this.actions = {}; }; diff --git a/project/events.js b/project/events.js index d366549..13ec7e3 100644 --- a/project/events.js +++ b/project/events.js @@ -11681,5 +11681,92 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 = "speed": 1 } ] + }, + "task": { + "新手任务": { + "type": "taskEvent", + "text": "任务描述", + "n": 1, + "info": [ + { + "type": "checkItem", + "checkItem": "yellowKey", + "operator": ">=", + "count": 0 + }, + { + "type": "checkStatus", + "checkStatus": "atk", + "operator": ">=", + "count": 10 + }, + { + "type": "checkFlag", + "checkFlag": "flag1", + "operator": "=", + "count": "\"value\"" + }, + { + "type": "checkBlock", + "checkBlock": "bat", + "floorId": [ + "MT1", + "MT2" + ], + "operator": "<=", + "count": 0 + }, + { + "type": "kill", + "operator": ">=", + "count": 0 + }, + { + "type": "killLocs", + "loc": [ + [ + 1, + 1 + ] + ], + "floorId": "MT1", + "operator": ">=", + "count": 1 + }, + { + "type": "killSpecial", + "killSpecial": "61", + "floorId": [ + "61" + ], + "operator": ">=", + "count": 1 + }, + { + "type": "killAll", + "floorId": [ + "MT1" + ] + }, + { + "type": "specialBlock", + "floorId": [ + "MT1" + ], + "specialBlock": "血网伤害", + "operator": "<", + "count": 1 + }, + { + "type": "gosthFloor", + "floorId": [ + "MT1" + ], + "operator": "<", + "count": 1 + } + ], + "action": [] + } } } \ No newline at end of file diff --git a/project/floors/yiqu4.js b/project/floors/yiqu4.js index 78d37a0..d7ac2b0 100644 --- a/project/floors/yiqu4.js +++ b/project/floors/yiqu4.js @@ -47,7 +47,7 @@ main.floors.yiqu4= [120178,120179,120180,120010,120018, 81,120010,120010,120010,120010,120028, 0, 31], [244, 0, 0, 31,421,205,421, 31, 81, 81, 0,205, 0], [ 0,110004,425,201021,220013,201021,220013,201021,220013,201021,216,201021,220013], - [ 0, 81, 0,201029,401,201029,402,201029, 22,201037, 32,201037,403], + [ 0, 81, 0,401,201029,201029,402,201029, 22,201037, 32,201037,403], [ 31,200199, 21,201029, 0,201029, 0,201029,244, 81, 0, 81, 0], [ 0,216, 0,201037, 82,201037, 82,201037,220013,130006,216,130006,220013], [403,201021,421, 0, 21, 0, 32, 0,240, 21, 0,425, 94], diff --git a/project/functions.js b/project/functions.js index 6be4614..f7bb7ef 100644 --- a/project/functions.js +++ b/project/functions.js @@ -190,15 +190,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 每次抵达楼层执行的事件 core.insertAction(core.floors[floorId].eachArrive); core.taskSystem.tasksInfo.forEach(v => v.tasks.forEach(a => { - switch (a.type) { - case "changeFloor": - if (!a.floorIds || a.floorId.includes(floorId)) a.has++ - break; - case "arrival": - if (a.floorId === floorId) a.has = 1 - break; + if (a.type === "arrival" && a.floorId === floorId) { + a.has = 1; + } else if (a.type === "gosthFloor" && (!a.floorId || a.floorId.includes(core.status.floorId))) { + a.has++; } - })) + + })); // 首次抵达楼层时执行的事件(后插入,先执行) if (!core.hasVisitedFloor(floorId)) { core.insertAction(core.floors[floorId].firstArrive); @@ -342,7 +340,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 当前战斗回合数,可用于战后所需的判定 var turn = damageInfo.turn; // 判定是否致死 - if (damage == null || damage >= core.status.hero.hp) { + if (damage == null || damage >= core.status.hero.hp || damageInfo.致死) { core.status.hero.hp = 0; core.updateStatusBar(false, true); core.events.lose('战斗失败'); @@ -430,8 +428,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = switch (a.type) { case "kill": - if (a.kill === enemyId && (!a.floorIds || a.floorIds.includes(core.status.floorId))) a.has++ - else if (!a.kill && (!a.floorIds || a.floorIds.includes(core.status.floorId))) a.has++ + if (a.kill === enemyId && (!a.floorId || a.floorId.includes(core.status.floorId))) a.has++ + else if (!a.kill && (!a.floorId || a.floorId.includes(core.status.floorId))) a.has++ break case "killLocs": if (core.status.floorId === a.floorId) { @@ -442,7 +440,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = break case "killSpecial": - if (!a.floorIds || a.floorIds.includes(core.status.floorId)) { + if (!a.floorId || a.floorId.includes(core.status.floorId)) { if (core.hasSpecial(special, a.killSpecial)) a.has++ } @@ -799,7 +797,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } }) - const heroinfo = { hp: hero_hp, atk: hero_atk, def: hero_def, mdef: (!hero?.mdef || hero?.mdef === 100) ? hero_mdef : hero.mdef, spell: hero_spell, mhp: Math.floor(hero_spell * hero_mhp / 100), matk: Math.floor(hero_spell * hero_matk / 100), speed: hero_speed, now: 0, isAttack: false } //勇士属性 + const heroinfo = { hp: hero_hp, atk: hero_atk, def: hero_def, mdef: (!hero?.mdef || hero?.mdef === 100) ? hero_mdef : hero.mdef, spell: hero_spell, mhp: Math.floor(hero_spell * hero_mhp / 100), matk: Math.floor(hero_spell * hero_matk / 100), speed: hero_speed, now: 0, isAttack: false, 致死: false } //勇士属性 const enemyinfo = { hp: mon_hp, atk: mon_atk, def: mon_def, mhp: 0, mdef: mon_mdef, spell: mon_spell, speed: mon_speed, special: mon_special, now: 0, isAttack: false } //怪物属性 //先攻,先攻为怪物50%行动条 if (core.hasSpecial(mon_special, 1)) { @@ -811,7 +809,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } let Exspeed = hero_speed const start = [core.clone(heroinfo), core.clone(enemyinfo), core.clone(equipInfo), Exspeed] //记录开始战斗时的属性并转发 - //---第三部分:递归开始--- + //---第三部分:循环开始--- let poison = 0 const heroDiffList = [], enemyDiffList = [], @@ -820,7 +818,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = let beforehp = enemyinfo.hp - + let 致死 = false while ( enemyinfo.hp > 0 ) { @@ -981,6 +979,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }) if (onattack) { + if (damage > hero_hp) 致死 = true //处理完毕后的数据处理 heroDiffList.push(hero_diff) enemyDiffList.push(enemy_diff) @@ -1007,6 +1006,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return { + 致死, start: start, mon_hp: Math.floor(mon_hp), mon_atk: Math.floor(mon_atk), @@ -1307,7 +1307,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = cg: cg, animateObjs: core.status.animateObjs.filter(v => v.loop), playing: [...core.plugin.playing].filter(v => v.loop), - task: core.taskSystem.save() + task: core.taskSystem.save(), + 可接取任务: [...core.plugin.可接取任务], + 已提交任务: [...core.plugin.已提交任务] }; return data; }, @@ -1365,6 +1367,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } core.drawbackground(core.ui.cgText.image, core.ui.cgText.memory) } + core.plugin.可接取任务 = [...data.可接取任务] + core.plugin.已提交任务 = [...data.已提交任务] // 切换到对应的楼层 core.changeFloor(data.floorId, null, data.hero.loc, 0, function () { // TODO:可以在这里设置读档后播放BGM diff --git a/project/plugins.js b/project/plugins.js index 2ed62de..cc86f15 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -11820,30 +11820,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; //定義表格操作行為 - editor_mode.OriginDoActionList = editor_mode.doActionList; - editor_mode.doActionList = function (mode, actionList, callback) { - if (editor_mode.mode == "CommonEventTemplate") { - if (actionList.length == 0) return; - printf("修改中..."); - var cb = function (objs_) { - if (objs_.slice(-1)[0] != null) { - printe(objs_.slice(-1)[0]); - throw objs_.slice(-1)[0]; - } - var str = "修改成功!"; - if ( - data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.name == - "template" - ) - str += "
请注意:全塔属性的name尚未修改,请及时予以设置。"; - printf(str); - if (callback) callback(); - }; - editor.file.editCommonEventTemplate(actionList, cb); - } else { - editor_mode.OriginDoActionList(mode, actionList, callback); - } - }; + //添加表格列 editor.table.CommonEventTemplateAddFunc = function () { let obj = events_c12a15a8_c380_4b28_8144_256cba95f760; @@ -11932,6 +11909,22 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = ], "event" ), + MotaActionFunctions.actionParser.parse({"type":"taskEvent","text": "任务描述","n":1,"info":[ + {"type":"checkItem","checkItem":"yellowKey","operator":">=","count":0}, + {"type":"checkStatus","checkStatus":"atk","operator":">=","count":10}, + {"type":"checkFlag","checkFlag":"flag1","operator":"=","count":"\"value\""}, + {"type":"checkBlock","checkBlock":"bat","floorId":["MT1","MT2"],"operator":"<=","count":0}, + {"type":"kill","operator":">=","count":0}, + {"type":"killLocs", "loc": [[1,1]],"floorId":"MT1","operator":">=","count":1}, + {"type":"killSpecial","killSpecial":"61","floorId":["61"],"operator":">=","count":1}, + {"type":"killAll","floorId":["MT1"]}, + {"type":"specialBlock","floorId":["MT1"],"specialBlock":"血网伤害","operator":"<","count":1}, + {"type":"gosthFloor","floorId":["MT1"],"operator":"<","count":1}, + {"type":"arrival","floorId":"MT1"}, + ], "action": [ + ]}, + "taskEvent" + ), MotaActionFunctions.actionParser.parse({ condition: "flag:__door__===2", currentFloor: true, @@ -12333,6 +12326,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = MotaActionBlocks["setVolume_s"].xmlText(), MotaActionBlocks["setBgmSpeed_s"].xmlText(), ], + 任务相关: [ + MotaActionBlocks['setTask_s'].xmlText(), + MotaActionBlocks['removeTask_s'].xmlText(), + MotaActionBlocks['removeTaskByName_s'].xmlText(), + MotaActionBlocks['successTask_s'].xmlText(), + MotaActionBlocks['successTaskByName_s'].xmlText(), + MotaActionBlocks['trymitTask_s'].xmlText(), + MotaActionBlocks['trymitTaskByName_s'].xmlText(), + MotaActionBlocks['submitTask_s'].xmlText(), + MotaActionBlocks['clearTask_s'].xmlText(), + ], UI绘制: [ MotaActionBlocks["previewUI_s"].xmlText(), MotaActionBlocks["clearMap_s"].xmlText(), @@ -12479,7 +12483,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = "firstArrive", "eachArrive", "commonEvent", - "item", + "item" ]; return commonEntries.indexOf(editor_blockly.entryType) >= 0; }; @@ -21939,55 +21943,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (list.length == 0) list.push([0, 0]); return list; } -}, - "手册(临时)": function () { - // 在此增加新插件 - ui.prototype._drawBook_drawContent = function (index, enemy, top, left) { - var width = core._PX_ - left; // 9 : 8 : 8 划分三列 - this._drawBook_drawRow1(index, enemy, top, left, width, top + 20); - this._drawBook_drawRow4(index, enemy, top, left, width, top + 38); - this._drawBook_drawRow2(index, enemy, top, left, width, top + 56); - this._drawBook_drawRow3(index, enemy, top, left, width, top + 74); - this._drawBook_drawRow5(index, enemy, top, left, width, top + 90); - } - - ui.prototype._drawBook_drawRow4 = function (index, enemy, top, left, width, position) { - // 绘制第一行 - core.setTextAlign('ui', 'left'); - var b13 = this._buildFont(13, true), - f13 = this._buildFont(13, false); - var col1 = left, - col2 = left + width * 9 / 25, - col3 = left + width * 17 / 25; - core.fillText('ui', core.getStatusLabel('speed'), col1, position, '#DDDDDD', f13); - core.fillText('ui', core.formatBigNumber(enemy.speed || 0), col1 + 30, position, null, b13); - core.fillText('ui', core.getStatusLabel('spell'), col2, position, null, f13); - core.fillText('ui', core.formatBigNumber(enemy.spell || 0), col2 + 30, position, null, b13); - core.fillText('ui', core.getStatusLabel('mdef'), col3, position, null, f13); - core.fillText('ui', core.formatBigNumber(enemy.mdef || 0) + "%", col3 + 30, position, null, b13); - } - ui.prototype._drawBook_drawRow5 = function (index, enemy, top, left, width, position) { - // 绘制第一行 - core.setTextAlign('ui', 'left'); - var b13 = this._buildFont(13, true), - f13 = this._buildFont(13, false); - var col1 = left, - col2 = left + width * 13 / 25; - core.fillText('ui', '速度临界', col1 - 120, position, '#DDDDDD', f13); - core.fillText('ui', `[${core.formatBigNumber(enemy.criticalSpeed?.[0] || 0)},${core.formatBigNumber(enemy.criticalSpeed?.[1] || 0)}]`, col1 - 60, position, null, b13); - - core.fillText('ui', "勇士出手次数", col1, position, '#DDDDDD', f13); - core.fillText('ui', core.getDamageInfo(enemy, null) ? core.getDamageInfo(enemy, null).hero_turn : '???', col1 + 80, position, null, b13); - core.fillText('ui', "怪物出手次数", col2, position, null, f13); - core.fillText('ui', core.getDamageInfo(enemy, null) ? core.getDamageInfo(enemy, null).mon_turn : '???', col2 + 80, position, null, b13); - - } - ui.prototype._drawBook_pageinfo = function () { - var per_page = 4; - var padding_top = 12; // 距离顶端像素 - var per_height = (core._PY_ - 32 - padding_top) / per_page; - return { per_page: per_page, padding_top: padding_top, per_height: per_height }; - } }, "新怪物手册": function () { // 在此增加新插件 @@ -28254,13 +28209,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }, "任务系统": function () { // 在此增加新插件 + //详细的任务信息及要求存放在core.events.task,供TaskSystem使用 + //以下均为任务名构成的数组,在任务接取或提交时转换 + this.可接取任务 = [] + this.已提交任务 = [] + //当前任务及任务状态在TaskSystem内部,无需数组 class TaskSystem { constructor() { this.tasksInfo = [] } - setTask(name, text, info, n) { - this.tasksInfo.push({ name, text, n, tasks: info.map(v => new Task(v)) }) - this.tasksInfo[this.tasksInfo.length - 1].complter = this.checkTask(this.tasksInfo.length - 1) + setTask(name) { + let task = core.enents.task[name] + if (task && core.plugin.可接取任务.includes(name)) { + this.tasksInfo.push({ name, text: task.text, n: task.n, action: task.action, tasks: task.info.map(v => new Task(v)) }) + this.tasksInfo[this.tasksInfo.length - 1].complter = this.checkTask(this.tasksInfo.length - 1) + } } checkTask(index) { if (this.tasksInfo[index].success) return true @@ -28282,12 +28245,29 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = } } submitTask() { - if (!flags.score) flags.score = 0 for (let i = 0; i < this.tasksInfo.length; i++) { - flags.score += Number(this.tasksInfo[i].complter) + this.trymitTask(i) } this.clearTesk() } + trymitTask(index) { + + if (this.checkTask(index)) { + if (this.tasksInfo[i].action) core.insertAction(this.tasksInfo[i].action) + core.plugin.已提交任务.push(this.tasksInfo[i].name) + this.removeTask(index) + } + + } + trymitTaskByName(name) { + const index = this.tasksInfo.findIndex(v => v.name === name) + if (this.checkTask(index)) { + if (this.tasksInfo[i].action) core.insertAction(this.tasksInfo[i].action) + core.plugin.已提交任务.push(name) + this.removeTask(index) + } + + } successTesk(index) { this.tasksInfo[index].success = true this.tasksInfo[index].complter = true @@ -28328,58 +28308,52 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = this.checkStatus = info.checkStatus this.count = info.count this.operator = info.operator - this.has = core.getRealStatus(this.checkStatus) + this.has = info.has ?? core.getRealStatus(this.checkStatus) } else if (info.type === "checkFlag") { this.checkFlag = info.checkFlag this.count = info.count this.operator = info.operator this.has = info.has ?? core.getFlag(this.checkFlag) - } else if (info.type === "checkBlock") { + } else if (info.type === "checkBlock") { //剩余图块 this.checkBlock = info.checkBlock this.count = info.count this.operator = info.operator - this.floorIds = info.floorIds - this.has = info.has ?? core.searchBlock(this.checkBlock, this.floorIds).length - } else if (info.type === "checkEnemyType") { - this.checkEnemyType = info.checkEnemyType - this.count = info.count - this.operator = info.operator - this.floorIds = info.floorIds - this.has = info.has ?? core.searchBlockWithFilter(block => block.event.cls.startsWith("enemy") && block.event.type === this.checkEnemyType, this.floorIds).length + this.floorId = info.floorId //楼层数组 + this.has = info.has ?? core.searchBlock(this.checkBlock, this.floorId).length } else if (info.type === "kill") { - this.floorIds = info.floorIds - this.kill = info.kill + this.floorId = info.floorId //楼层数组,不填为任意楼层 + this.kill = info.kill //空为任意怪物 this.count = info.count this.has = info.has ?? 0 this.operator = info.operator } else if (info.type === "killLocs") { - this.killLocs = info.killLocs - this.floorId = info.floorId + this.floorId = info.floorId //楼层名 + this.loc = info.loc this.count = info.count this.has = info.has ?? 0 this.operator = info.operator } else if (info.type === "killSpecial") { - this.floorIds = info.floorIds - this.killSpecial = info.killSpecial + this.floorId = info.floorId //楼层数组,不填为任意楼层 + this.killSpecial = info.killSpecial //特技数字 this.count = info.count this.has = info.has ?? 0 this.operator = info.operator } else if (info.type === "killAll") { - this.floorIds = info.floorIds - this.has = info.has ?? core.searchBlockWithFilter(block => block.event.cls.startsWith("enemy"), this.floorIds).length - } else if (info.type === "specialBlock") { - this.floorIds = info.floorIds - this.specialType = info.specialType + this.floorId = info.floorId //楼层数组 + this.has = info.has ?? core.searchBlockWithFilter(block => block.event.cls.startsWith("enemy"), this.floorId).length + } else if (info.type === "specialBlock") { //踩雷 + this.floorId = info.floorId //楼层数组,不填为任意楼层 + this.specialType = info.specialType //地形伤害名,如血网伤害 this.count = info.count this.has = info.has ?? 0 this.operator = info.operator - } else if (info.type === "changeFloor") { - this.floorIds = info.floorIds + } else if (info.type === "gosthFloor") { //进行楼层切换次数 + this.floorId = info.floorId //楼层数组 this.count = info.count this.has = info.has ?? 0 this.operator = info.operator - } else if (info.type === "arrival") { - this.floorId = info.floorId + } else if (info.type === "arrival") { //抵达某楼层 + this.floorId = info.floorId //楼层名 this.has = info.has ?? 0 } @@ -28389,10 +28363,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (this.type === "checkItem") return this.checkInfo(this.count, this.has = core.itemCount(this.checkItem)) else if (this.type === "checkStatus") return this.checkInfo(this.count, this.has = core.getRealStatus(this.checkStatus)) else if (this.type === "checkFlag") return this.checkInfo(this.count, this.has = core.getFlag(this.checkFlag)) - else if (this.type === "checkBlock") return this.checkInfo(this.count, this.has = core.searchBlock(this.checkBlock, this.floorIds).length) - else if (this.type === "checkEnemyType") return this.checkInfo(this.count, this.has = core.searchBlockWithFilter(block => block.event.cls.startsWith("enemy") && block.event.type === this.checkEnemyType, this.floorIds).length) - else if (this.type === "killAll") return this.has = core.searchBlockWithFilter(block => block.event.cls.startsWith("enemy"), this.floorIds).length, this.has === 0 - else if (this.type === "specialBlock" || this.type === "changeFloor" || this.type === "kill" || this.type === "killSpecial" || this.type === "killLocs") return this.checkInfo(this.count, this.has) + else if (this.type === "checkBlock") return this.checkInfo(this.count, this.has = core.searchBlock(this.checkBlock, this.floorId).length) + else if (this.type === "killAll") return this.has = core.searchBlockWithFilter(block => block.event.cls.startsWith("enemy"), this.floorId).length, this.has === 0 + else if (this.type === "specialBlock" || this.type === "gosthFloor" || this.type === "kill" || this.type === "killSpecial" || this.type === "killLocs") return this.checkInfo(this.count, this.has) else if (this.type === "arrival") return Boolean(this.has) else if (this.type === "outer") return false @@ -28400,15 +28373,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = checkInfo(check, has) { switch (this.operator) { case "=": - return has === check + return check === has case "<": - return has < check + return check > has case "<=": - return has <= check + return check >= has case ">": - return has > check + return check < has case ">=": - return has >= check + return check <= has } } save() { @@ -28432,44 +28405,38 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = info.checkBlock = this.checkBlock info.count = this.count info.operator = this.operator - info.floorIds = this.floorIds - info.has = this.has - } else if (info.type === "checkEnemyType") { - info.checkEnemyType = this.checkEnemyType - info.count = this.count - info.operator = this.operator - info.floorIds = this.floorIds + info.floorId = this.floorId info.has = this.has } else if (info.type === "kill") { - info.floorIds = this.floorIds + info.floorId = this.floorId info.kill = this.kill info.count = this.count info.has = this.has info.operator = this.operator } else if (info.type === "killLocs") { - info.killLocs = this.killLocs info.floorId = this.floorId - info.count = this.locs.length + info.loc = this.loc + info.count = this.count info.has = this.has info.operator = this.operator } else if (info.type === "killSpecial") { - info.floorIds = this.floorIds + info.floorId = this.floorId info.killSpecial = this.killSpecial info.count = this.count info.has = this.has info.operator = this.operator } else if (info.type === "killAll") { - info.floorIds = this.floorIds + info.floorId = this.floorId info.has = this.has } else if (info.type === "specialBlock") { + info.floorId = this.floorId info.specialType = this.specialType - info.floorIds = this.floorIds info.count = this.count info.has = this.has info.operator = this.operator - } else if (info.type === "changeFloor") { + } else if (info.type === "gosthFloor") { + info.floorId = this.floorId info.count = this.count - info.floorIds = this.floorIds info.has = this.has info.operator = this.operator } else if (info.type === "arrival") { @@ -28483,7 +28450,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.taskSystem = new TaskSystem() core.registerEvent("setTask", (data) => { - core.taskSystem.setTask(data.name, data.text, data.info, data.n) + core.taskSystem.setTask(data.name) core.doAction() }) core.registerEvent("removeTask", (data) => { @@ -28506,10 +28473,554 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.taskSystem.clearTask() core.doAction() }) - + core.registerEvent("trymitTask", (data) => { + core.taskSystem.trymitTask(data.index) + core.doAction() + }) + core.registerEvent("trymitTaskByName", (data) => { + core.taskSystem.trymitTaskByName(data.name) + core.doAction() + }) core.registerEvent("submitTask", () => { core.taskSystem.submitTask() core.doAction() }) +}, + "NPC菜单": function () { + // 在此增加新插件 + + const menu = { + + setcanvas(list, x, y) { + let textmax = "" + list.forEach(v => textmax = v.length > textmax.length ? v : textmax) + if (!this.canvas) { + this.canvas = core.createCanvas("menu", x * 32 + 16, y * 32 + 16, 30, 30, 70) + core.setFont(this.canvas, "18px cjx") + } + let length = this.canvas.measureText(textmax).width + let px = x * 32 + 16 + let py = y * 32 + 16 + if (px + length + 32 > 416) px -= length + 32 + if (py + list.length * 32 > 416) py -= list.length * 32 + this.canvas = core.createCanvas("menu", px, py, length + 32, list.length * 32, 70) + core.setFont(this.canvas, "18px cjx") + this.x = px + this.y = py + this.w = length + 32 + this.h = list.length * 32 + core.clearMap(this.canvas) + core.fillRect(this.canvas, 0, 0, this.w, this.h, "rgba(0,0,0,0.7)") + core.fillRect(this.canvas, 0, 0, this.w, 32, "rgba(0,0,0,0.7)") + core.setTextAlign(this.canvas, "center") + let dy = 0 + list.forEach(v => { + core.fillText(this.canvas, v, this.w / 2, 22 + dy, "#FFFFFF") + dy += 32 + }) + this.selection = 0 + core.strokeRoundRect(this.canvas, 2, 34 + this.selection * 32, this.w - 4, 28, 4, "#FFFF00", 2) + } + } + + function action_menu(data, x, y, prefix) { + data.choices = data.choices.filter(function (x) { + if (x._disabled) return false; + if (x.condition == null || x.condition == "") return true; + try { + return core.calValue(x.condition, prefix); + } catch (e) { + return true; + } + }); + if (data.choices.length == 0) return core.doAction() + if (core.isReplaying()) { + var action = core.status.replay.toReplay.shift(); + if ( + action.indexOf("menu:") == 0) { + var index = action.substring(5); + if (!menu_replaying(data, index)) { + core.control._replay_error(action); + return; + } + } else { + `` + // 容错录像 + if (main.replayChecking) { + // 录像验证系统中选返回 + if (action != "menu:none") + core.status.replay.toReplay.unshift(action); // 首先归还刚才读出的下一步操作 + menu_replaying(data, "none"); + } else { + // 正常游戏中弹窗选择 + core.myprompt( + "录像回放出错!当前需要执行选择项但录像中未记录。\n如需修复请输入您要选的项(从0起),点击取消将不会修复。", + 0, + function (value) { + if (value == null) { + core.control._replay_error(action); + return; + } + if (action != "menu:none") + core.status.replay.toReplay.unshift(action); // 首先归还刚才读出的下一步操作 + menu_replaying( + data, + ((parseInt(value) || 0) + data.choices.length) % + data.choices.length + ); + } + ); + } + } + } + let list = [] + list.push(core.replaceText(data.text, prefix)) + for (var i = 0; i < data.choices.length; i++) { + if (typeof data.choices[i] === "string") + data.choices[i] = { text: data.choices[i] }; + data.choices[i].text = core.replaceText(data.choices[i].text, prefix); + list.push(data.choices[i].text) + } + menu.setcanvas(list, x, y) + } + + function menu_replaying(data, index) { + var selection = index; + if (index != "none") { + selection = parseInt(index); + if (Number.isNaN(selection)) return false; + if (selection < 0) selection += data.choices.length; + if (selection < 0) return false; + if (selection % 100 > data.choices.length) return false; + } + core.status.event.selection = selection; + setTimeout( + function () { + core.status.route.push("choices:" + index); + if (selection != "none") { + // 检查 + var choice = data.choices[selection]; + if ( + choice.need != null && + choice.need != "" && + !core.calValue(choice.need) + ) { + // 无法选择此项 + core.control._replay_error("无法选择项:" + index); + return; + } else { + core.insertAction(choice.action); + } + } else core.clearMap(menu.canvas) + core.doAction(); + }, + core.status.replay.speed == 24 ? + 1 : + 750 / Math.max(1, core.status.replay.speed) + ); + return true; + }; +}, + "任务栏": function () { + // 在此增加新插件 + if (main.mode == "editor") { + //#region 配置表格初始化 + let TableFileName = "project/table/task_comment.js"; + let TableRow = ` + var task_comment = {"_type": "object", + "_data": { + "task": { + "_type": "object", + "_data": function (key) { + var obj = { + "检测音乐如果没有开启则系统提示开启": { + "_leaf": true, + "_type": "object", + "_data": "检测音乐如果没有开启则系统提示开启" + }, + + } + if (obj[key]) return obj[key]; + return { + "_leaf": true, + "_type": "object", + "_data": "任务栏" + } + } + } + }} + `; + if (!events_c12a15a8_c380_4b28_8144_256cba95f760.task) { + /** + * @type {{[EvnetName:actionParserJson]}} + */ + events_c12a15a8_c380_4b28_8144_256cba95f760.task = { + 检测音乐如果没有开启则系统提示开启: [{ + type: "if", + condition: "!core.musicStatus.bgmStatus", + true: [ + "\t[系统提示]你当前音乐处于关闭状态,本塔开音乐游戏效果更佳", + ], + false: [], + }, ], + 仿新新魔塔一次性商人: [{ + type: "if", + condition: "switch:A", + true: [ + "\t[行商,trader]\b[this]这是购买我的道具后我给玩家的提示。", + { + type: "comment", + text: "下一条指令可视情况使用或不使用", + }, + { + type: "hide", + remove: true, + time: 250, + }, + ], + false: [{ + type: "confirm", + text: "我有3把黄钥匙,\n你出50金币就卖给你。", + yes: [{ + type: "if", + condition: "status:money>=50", + true: [{ + type: "setValue", + name: "status:money", + operator: "-=", + value: "50", + }, + { + type: "setValue", + name: "item:yellowKey", + operator: "+=", + value: "3", + }, + { + type: "playSound", + name: "确定", + stop: true, + }, + { + type: "setValue", + name: "switch:A", + value: "true", + }, + ], + false: [{ + type: "playSound", + name: "操作失败", + }, + "\t[行商,trader]\b[this]你的金币不足!", + ], + }, ], + no: [], + }, ], + }, ], + 全地图选中一个点: [{ + type: "comment", + text: "全地图选中一个点,需要用鼠标或触屏操作", + }, + { + type: "setValue", + name: "temp:X", + value: "status:x", + }, + { + type: "setValue", + name: "temp:Y", + value: "status:y", + }, + { + type: "tip", + text: "再次点击闪烁位置确认", + }, + { + type: "while", + condition: "true", + data: [{ + type: "drawSelector", + image: "winskin.webp", + code: 1, + x: "32*temp:X", + y: "32*temp:Y", + width: 32, + height: 32, + }, + { + type: "wait", + }, + { + type: "if", + condition: "(flag:type === 1)", + true: [{ + type: "if", + condition: "((temp:X===flag:x)&&(temp:Y===flag:y))", + true: [{ + type: "break", + n: 1, + }, ], + }, + { + type: "setValue", + name: "temp:X", + value: "flag:x", + }, + { + type: "setValue", + name: "temp:Y", + value: "flag:y", + }, + ], + }, + ], + }, + { + type: "drawSelector", + code: 1, + }, + { + type: "comment", + text: "流程进行到这里可以对[X,Y]点进行处理,比如", + }, + { + type: "closeDoor", + id: "yellowDoor", + loc: ["temp:X", "temp:Y"], + }, + ], + 多阶段Boss战斗: [{ + type: "comment", + text: "多阶段boss,请直接作为战后事件使用", + }, + { + type: "setValue", + name: "switch:A", + operator: "+=", + value: "1", + }, + { + type: "switch", + condition: "switch:A", + caseList: [{ + case: "1", + action: [{ + type: "setBlock", + number: "redSlime", + }, + "\t[2阶段boss,redSlime]\b[this]你以为你已经打败我了吗?没听说过史莱姆有九条命吗?", + ], + }, + { + case: "2", + action: [{ + type: "setBlock", + number: "blackSlime", + }, + "\t[3阶段boss,blackSlime]\b[this]不能消灭我的,只会让我更强大!", + ], + }, + { + case: "3", + action: [{ + type: "setBlock", + number: "slimelord", + }, + "\t[4阶段boss,slimelord]\b[this]我还能打!", + ], + }, + { + case: "4", + action: ["\t[4阶段boss,slimelord]我一定会回来的!"], + }, + ], + }, + ], + }; + } + // 新增模板選項 + let editModeSelect = document.getElementById("editModeSelect"); + let newEditModeOption = document.createElement("option"); + newEditModeOption.value = "task"; + newEditModeOption.text = "任务表"; + editModeSelect.add(newEditModeOption); + + //檢查可用的編輯模板ID + let leftIDNumber = 11 - 1; + let ExistLeftElement = document.querySelector(".main"); + while (ExistLeftElement) { + leftIDNumber++; + ExistLeftElement = document.getElementById(`left${leftIDNumber}`); + } + + //新增編輯模板 + let MainDiv = document.querySelector(".main"); + + let CommonEventTemplateMainDiv = document.createElement("div"); + CommonEventTemplateMainDiv.id = `left${leftIDNumber}`; + CommonEventTemplateMainDiv.className = "leftTab"; + CommonEventTemplateMainDiv.style.zIndex = "-1"; + CommonEventTemplateMainDiv.style.opacity = "0"; + + CommonEventTemplateMainDiv.innerHTML = ` +

+ 任务栏   +    +    +    + +

+
+
+ + + + + + + + +
条目注释
+
+
+ `; + MainDiv.appendChild(CommonEventTemplateMainDiv); + + (async function () { + //等待編輯器初始化 + while (!editor_mode.ids) { + await Sleep(100); + } + //新增編輯模板ID + editor_mode.ids.task = `left${leftIDNumber}`; + editor_mode.init_dom_ids(); + //切換至任务栏 + editor_mode.task = function (callback) { + var objs = []; + editor.file.editTask([], function (objs_) { + objs = objs_; + //console.log(objs_) + }); + //只查询不修改时,内部实现不是异步的,所以可以这么写 + var tableinfo = editor.table.objToTable(objs[0], objs[1]); + document.getElementById( + "table_298572d8-93dd-4c6e-a278-6a7d49831e3b" + ).innerHTML = tableinfo.HTML; + tableinfo.listen(tableinfo.guids); + if (Boolean(callback)) callback(); + }; + + //檢查配置表格存在 + let TableRowExist = null; + fs.readFile(TableFileName, "base64", function (err, data) { + if (err) { + console.log(`察覺常見事件模板配置表格不存在,原因:${err}`); + console.log("新建一個常見事件模板配置表格。"); + TableRowExist = false; + } else { + TableRowExist = true; + } + }); + //等待配置表格載入完畢(最多0.3秒,超過則視為失敗) + for (let i = 0; i < 3; i++) { + if (TableRowExist == null) { + await Sleep(100); + } + } + //配置表格初始化 + if (TableRowExist != true) { + fs.mkdir("project/table", function (err, data) { + if (err) throw `任务栏配置表格目錄初始化失敗,原因:${err}`; + }); + fs.writeFile( + TableFileName, + editor.util.encode64(TableRow || ""), + "base64", + function (err, data) { + if (err) throw `任务栏板配置表格文件初始化失敗,原因:${err}`; + } + ); + } + //載入配置表格 + //editor.file.loadCommentjs(callback); + (function () { + var key = "task_comment"; + var script = document.createElement("script"); + script.src = "project/table/" + key + ".js"; + document.body.appendChild(script); + script.onload = function () { + editor.file[key] = eval(key.replace(".", "_")); + var loaded = Boolean(editor.file[key]); + }; + })(); + //按下配置表格 + editor_multi.taskEditCommentJs = function (mod) { + editor_multi.lintAutocomplete = true; + editor_multi.setLint(); + editor_multi.importFile(TableFileName); + }; + + + //添加表格列 + editor.table.taskAddFunc = function () { + let obj = events_c12a15a8_c380_4b28_8144_256cba95f760; + + // 1.输入id + let newid = prompt("请输入新项的ID(支持中文)"); + if (newid == null || newid.length == 0) { + return; + } + + // 2.检查id是否符合规范或与已有id重复 + var conflict = true; + var basefield = "".replace(/\[[^\[]*\]$/, ""); + + try { + var baseobj = eval("obj" + basefield); + conflict = newid in baseobj; + } catch (ee) { + // 理论上这里不会发生错误 + printe(ee); + throw ee; + } + + if (conflict) { + printe("id已存在, 请直接修改该项的值"); + return; + } + + // 3.添加 + editor_mode.addAction(["add", basefield + "['" + newid + "']", null]); + editor_mode.onmode("save", function () { + printf("添加成功,刷新后生效;也可以继续新增其他项目。"); + }); //自动保存 删掉此行的话点保存按钮才会保存 + }; + //對表格的存讀 + editor.file.editTask = function (actionList, callback) { + /*actionList:[ + ["change","['test']",['123']], + ] + 为[]时只查询不修改 + */ + var data_obj = + events_c12a15a8_c380_4b28_8144_256cba95f760.task; + checkCallback(callback); + if (isset(actionList) && actionList.length > 0) { + actionList.forEach(function (value) { + value[1] = "['task']" + value[1]; + }); + editor.file.saveSetting("events", actionList, function (err) { + callback([err]); + }); + } else { + callback([ + Object.assign({}, data_obj), + editor.file.task_comment._data.task, + null, + ]); + } + }; + })(); + } } } \ No newline at end of file diff --git a/project/table/CommonEventTemplate_comment.js b/project/table/CommonEventTemplate_comment.js index f805344..0df90bd 100644 --- a/project/table/CommonEventTemplate_comment.js +++ b/project/table/CommonEventTemplate_comment.js @@ -1,43 +1,43 @@ - - var CommonEventTemplate_comment = {"_type": "object", - "_data": { - "CommonEventTemplate": { - "_type": "object", - "_data": function (key) { - var obj = { - "检测音乐如果没有开启则系统提示开启": { - "_leaf": true, - "_type": "event", - "_event": "commonEvent", - "_data": "检测音乐如果没有开启则系统提示开启" - }, - "仿新新魔塔一次性商人": { - "_leaf": true, - "_type": "event", - "_event": "commonEvent", - "_data": "仿新新魔塔一次性商人" - }, - "全地图选中一个点": { - "_leaf": true, - "_type": "event", - "_event": "commonEvent", - "_data": "全地图选中一个点" - }, - "多阶段Boss战斗": { - "_leaf": true, - "_type": "event", - "_event": "commonEvent", - "_data": "多阶段Boss战斗" - }, - } - if (obj[key]) return obj[key]; - return { - "_leaf": true, - "_type": "event", - "_event": "commonEvent", - "_data": "常見事件模板" - } - } - } - }} - \ No newline at end of file +var CommonEventTemplate_comment = { + "_type": "object", + "_data": { + "CommonEventTemplate": { + "_type": "object", + "_data": function (key) { + var obj = { + "检测音乐如果没有开启则系统提示开启": { + "_leaf": true, + "_type": "event", + "_event": "commonEvent", + "_data": "检测音乐如果没有开启则系统提示开启" + }, + "仿新新魔塔一次性商人": { + "_leaf": true, + "_type": "event", + "_event": "commonEvent", + "_data": "仿新新魔塔一次性商人" + }, + "全地图选中一个点": { + "_leaf": true, + "_type": "event", + "_event": "commonEvent", + "_data": "全地图选中一个点" + }, + "多阶段Boss战斗": { + "_leaf": true, + "_type": "event", + "_event": "commonEvent", + "_data": "多阶段Boss战斗" + }, + } + if (obj[key]) return obj[key]; + return { + "_leaf": true, + "_type": "event", + "_event": "commonEvent", + "_data": "常見事件模板" + } + } + } + } +} \ No newline at end of file diff --git a/project/table/task_comment.js b/project/table/task_comment.js new file mode 100644 index 0000000..41d6aca --- /dev/null +++ b/project/table/task_comment.js @@ -0,0 +1,115 @@ +var task_comment = { + "_type": "object", + "_data": { + "task": { + "_type": "object", + "_data": function (key) { + var obj = { + "新手任务": { + "_leaf": true, + "_type": "event", + "_event": "taskEvent", + "_data": "开局就有" + }, + } + if (obj[key]) return obj[key]; + return { + "_leaf": true, + "_type": "event", + "_event": "taskEvent", + "_template": `{ + "type": "taskEvent", + "name": "mission name", + "n": 1, + "text": "任务描述", + "info": [ + { + "type": "checkItem", + "checkItem": "yellowKey", + "operator": ">=", + "count": 0 + }, + { + "type": "checkStatus", + "checkStatus": "atk", + "operator": ">=", + "count": 10 + }, + { + "type": "checkFlag", + "checkFlag": "flag1", + "operator": "=", + "count": "\"value\"" + }, + { + "type": "checkBlock", + "checkBlock": "bat", + "floorId": [ + "MT1", + "MT2" + ], + "operator": "<=", + "count": 0 + }, + { + "type": "kill", + "operator": ">=", + "count": 0 + }, + { + "type": "killLocs", + "loc": [ + [ + 1, + 1 + ] + ], + "floorId": "MT1", + "operator": ">=", + "count": 1 + }, + { + "type": "killSpecial", + "killSpecial": "61", + "floorId": [ + "61" + ], + "operator": ">=", + "count": 1 + }, + { + "type": "killAll", + "floorId": [ + "MT1" + ] + }, + { + "type": "specialBlock", + "floorId": [ + "MT1" + ], + "specialBlock": "血网伤害", + "operator": "<", + "count": 1 + }, + { + "type": "gosthFloor", + "floorId": [ + "MT1" + ], + "operator": "<", + "count": 1 + } + ], + "action": [ + { + "type": "setmusics" + } + ] + }`, + "_data": "..." + } + } + } + } +} \ No newline at end of file