diff --git a/libs/control.js b/libs/control.js index 699bc34d..b88921fd 100644 --- a/libs/control.js +++ b/libs/control.js @@ -803,7 +803,7 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off }); } -// ------ 画布、位置、阻激夹域等 ------ // +// ------ 画布、位置、阻激夹域,显伤 ------ // ////// 设置画布偏移 control.prototype.setGameCanvasTranslate = function(canvas,x,y){ @@ -845,20 +845,6 @@ control.prototype.updateViewport = function() { core.relocateCanvas('route', core.status.automaticRoute.offsetX - core.bigmap.offsetX, core.status.automaticRoute.offsetY - core.bigmap.offsetY); } -////// 设置勇士的位置 ////// -control.prototype.setHeroLoc = function (itemName, itemVal, noGather) { - core.status.hero.loc[itemName] = itemVal; - if ((itemName=='x' || itemName=='y') && !noGather) { - this.gatherFollowers(); - } -} - -////// 获得勇士的位置 ////// -control.prototype.getHeroLoc = function (itemName) { - if (itemName == null) return core.status.hero.loc; - return core.status.hero.loc[itemName]; -} - ////// 获得勇士面对位置的x坐标 ////// control.prototype.nextX = function(n) { return core.getHeroLoc('x')+core.utils.scan[core.getHeroLoc('direction')].x*(n||1); @@ -964,137 +950,6 @@ control.prototype._checkBlock_ambush = function (ambush) { core.insertAction(actions); } -////// 更改天气效果 ////// -control.prototype.setWeather = function (type, level) { - - // 非雨雪 - if (type!='rain' && type!='snow' && type!='fog') { - // core.clearMap('weather'); - core.deleteCanvas('weather') - core.animateFrame.weather.type = null; - core.animateFrame.weather.level = 0; - core.animateFrame.weather.nodes = []; - return; - } - - level = parseInt(level); - - // 当前天气:则忽略 - if (type==core.animateFrame.weather.type && !core.isset(level)) { - return; - } - - if (!core.isset(level)) level=5; - if (level<1) level=1; if (level>10) level=10; - level *= parseInt(20*core.bigmap.width*core.bigmap.height/(core.__SIZE__*core.__SIZE__)); - // 计算当前的宽高 - - core.createCanvas('weather', 0, 0, core.__PIXELS__, core.__PIXELS__, 80); - core.animateFrame.weather.type = type; - core.animateFrame.weather.level = level; - core.animateFrame.weather.nodes = []; - - if (type == 'rain') { - for (var a=0;a 1) - core.screenFlash(color, time * 3, times - 1, callback); - else { - if (core.isset(callback)) callback(); - } - }); - }); -} - ////// 更新全地图显伤 ////// control.prototype.updateDamage = function (floorId, canvas) { floorId = floorId || core.status.floorId; @@ -1191,12 +1046,6 @@ control.prototype.doEffect = function (effect, need, times) { }); } -////// 开启debug模式 ////// -control.prototype.debug = function() { - core.setFlag('debug', true); - core.drawText("\t[调试模式开启]此模式下按住Ctrl键(或Ctrl+Shift键)可以穿墙并忽略一切事件。\n同时,录像将失效,也无法上传成绩。"); -} - ////// 选择录像文件 ////// control.prototype.chooseReplayFile = function () { core.readFile(function (obj) { @@ -2197,77 +2046,116 @@ control.prototype.hasSave = function (index) { return core.saves.ids[index]||false; } +// ------ 属性,状态,位置,buff,变量,锁定控制等 ------ // + ////// 设置勇士属性 ////// -control.prototype.setStatus = function (statusName, statusVal) { - if (!core.isset(core.status.hero)) return; - if (statusName == 'exp') statusName = 'experience'; - if (core.isset(core.status.hero.loc[statusName])) - core.status.hero.loc[statusName] = statusVal; +control.prototype.setStatus = function (name, value) { + if (!core.status.hero) return; + if (name == 'exp') name = 'experience'; + if (name == 'x' || name == 'y' || name == 'direction') + this.setHeroLoc(name, value); else - core.status.hero[statusName] = statusVal; + core.status.hero[name] = value; +} + +////// 增减勇士属性 ////// +control.prototype.addStatus = function (name, value) { + this.setStatus(name, this.getStatus(name) + value); } ////// 获得勇士属性 ////// control.prototype.getStatus = function (name) { - if (!core.isset(core.status.hero)) return null; - // support status:x - if (core.isset(core.status.hero.loc[name])) - return core.status.hero.loc[name]; + if (!core.status.hero) return null; + if (name == 'x' || name == 'y' || name == 'direction') + return this.getHeroLoc('x'); if (name == 'exp') name = 'experience'; return core.status.hero[name]; } +////// 从status中获得属性,如果不存在则从勇士属性中获取 ////// control.prototype.getStatusOrDefault = function (status, name) { - if (core.isset(status) && name in status) + if (status && name in status) return status[name]; return this.getStatus(name); } +////// 获得勇士实际属性(增幅后的) ////// control.prototype.getRealStatus = function (name) { return this.getRealStatusOrDefault(null, name); } +////// 从status中获得实际属性(增幅后的),如果不存在则从勇士属性中获取 ////// control.prototype.getRealStatusOrDefault = function (status, name) { - return this.getStatusOrDefault(status, name) * core.getFlag('__'+name+'_buff__', 1); + return this.getStatusOrDefault(status, name) * this.getBuff(name); +} + +////// 设置某个属性的增幅值 ////// +control.prototype.setBuff = function (name, value) { + this.setFlag('flag:__'+name+'_buff__', value); +} + +////// 加减某个属性的增幅值 ////// +control.prototype.addBuff = function (name, value) { + this.setFlag('flag:__'+name+'_buff__', this.getBuff(name) + value); +} + +////// 获得某个属性的增幅值 ////// +control.prototype.getBuff = function (name) { + return core.getFlag('__'+name+'_buff__', 1); +} + +////// 设置勇士的位置 ////// +control.prototype.setHeroLoc = function (name, value, noGather) { + if (!core.status.hero) return; + core.status.hero.loc[name] = value; + if ((name=='x' || name=='y') && !noGather) { + this.gatherFollowers(); + } +} + +////// 获得勇士的位置 ////// +control.prototype.getHeroLoc = function (name) { + if (!core.status.hero) return; + if (name == null) return core.status.hero.loc; + return core.status.hero.loc[name]; } ////// 获得某个等级的名称 ////// -control.prototype.getLvName = function () { - if (!core.isset(core.status.hero)) return null; - return ((core.firstData.levelUp||[])[core.status.hero.lv-1]||{}).title || core.status.hero.lv; +control.prototype.getLvName = function (lv) { + if (!core.status.hero) return null; + if (lv == null) lv = core.status.hero.lv; + return ((core.firstData.levelUp||[])[lv-1]||{}).title || lv; } ////// 设置某个自定义变量或flag ////// -control.prototype.setFlag = function(flag, value) { - if (!core.isset(value)) return this.removeFlag(flag); - if (!core.isset(core.status.hero)) return; - core.status.hero.flags[flag]=value; -} - -////// 获得某个自定义变量或flag ////// -control.prototype.getFlag = function(flag, defaultValue) { - if (!core.isset(core.status.hero)) return defaultValue; - var value = core.status.hero.flags[flag]; - if (core.isset(value)) return value; - return defaultValue; -} - -////// 是否存在某个自定义变量或flag,且值为true ////// -control.prototype.hasFlag = function(flag) { - if (core.getFlag(flag)) return true; - return false; -} - -////// 删除某个自定义变量或flag ////// -control.prototype.removeFlag = function(flag) { - if (!core.isset(core.status.hero)) return; - delete core.status.hero.flags[flag]; +control.prototype.setFlag = function(name, value) { + if (value == null) return this.removeFlag(name); + if (!core.status.hero) return; + core.status.hero.flags[name]=value; } ////// 增加某个flag数值 ////// -control.prototype.addFlag = function(flag, delta) { - if (!core.isset(core.status.hero)) return; - core.setFlag(flag, core.getFlag(flag, 0) + delta); +control.prototype.addFlag = function(name, value) { + if (!core.status.hero) return; + core.setFlag(name, core.getFlag(name, 0) + value); +} + +////// 获得某个自定义变量或flag ////// +control.prototype.getFlag = function(name, defaultValue) { + if (!core.status.hero) return defaultValue; + var value = core.status.hero.flags[name]; + return value != null ? value : defaultValue; +} + +////// 是否存在某个自定义变量或flag,且值为true ////// +control.prototype.hasFlag = function(name) { + return !!core.getFlag(name); +} + +////// 删除某个自定义变量或flag ////// +control.prototype.removeFlag = function(name) { + if (!core.status.hero) return; + delete core.status.hero.flags[name]; } ////// 锁定状态栏,常常用于事件处理 ////// @@ -2280,6 +2168,145 @@ control.prototype.unLockControl = function () { core.status.lockControl = false; } +////// 开启debug模式 ////// +control.prototype.debug = function() { + core.setFlag('debug', true); + core.drawText("\t[调试模式开启]此模式下按住Ctrl键(或Ctrl+Shift键)可以穿墙并忽略一切事件。\n同时,录像将失效,也无法上传成绩。"); +} + +// ------ 天气,色调,BGM ------ // + +////// 更改天气效果 ////// +control.prototype.setWeather = function (type, level) { + + // 非雨雪 + if (type!='rain' && type!='snow' && type!='fog') { + // core.clearMap('weather'); + core.deleteCanvas('weather') + core.animateFrame.weather.type = null; + core.animateFrame.weather.level = 0; + core.animateFrame.weather.nodes = []; + return; + } + + level = parseInt(level); + + // 当前天气:则忽略 + if (type==core.animateFrame.weather.type && !core.isset(level)) { + return; + } + + if (!core.isset(level)) level=5; + if (level<1) level=1; if (level>10) level=10; + level *= parseInt(20*core.bigmap.width*core.bigmap.height/(core.__SIZE__*core.__SIZE__)); + // 计算当前的宽高 + + core.createCanvas('weather', 0, 0, core.__PIXELS__, core.__PIXELS__, 80); + core.animateFrame.weather.type = type; + core.animateFrame.weather.level = level; + core.animateFrame.weather.nodes = []; + + if (type == 'rain') { + for (var a=0;a 1) + core.screenFlash(color, time * 3, times - 1, callback); + else { + if (core.isset(callback)) callback(); + } + }); + }); +} + ////// 播放背景音乐 ////// control.prototype.playBgm = function (bgm, startTime) { if (main.mode!='play')return; diff --git a/libs/enemys.js b/libs/enemys.js index 02554f28..75f64ede 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -245,7 +245,7 @@ enemys.prototype._nextCriticals_useTurn = function (enemy, info, number, x, y, f for (var t = turn - 1; t >= 1; t--) { var nextAtk = Math.ceil(mon_hp / t) + mon_def; // 装备提升比例的计算临界 - nextAtk = Math.ceil(nextAtk / core.getFlag('__atk_buff__', 1)); + nextAtk = Math.ceil(nextAtk / core.getBuff('atk')); if (nextAtk <= hero_atk) break; if (nextAtk != pre) { var nextInfo = this.getDamageInfo(enemy, {"atk": nextAtk}, x, y, floorId); diff --git a/libs/items.js b/libs/items.js index e61c23f9..58faca5c 100644 --- a/libs/items.js +++ b/libs/items.js @@ -333,12 +333,12 @@ items.prototype._loadEquipEffect = function (equipId, unloadEquipId, isPercentag var result = core.compareEquipment(equipId, unloadEquipId); if (isPercentage) { - for (var v in result) - core.addFlag('__' + v + '_buff__', result[v] / 100); + for (var name in result) + core.addBuff(name, result[name] / 100); } else { - for (var v in result) - core.status.hero[v] += result[v]; + for (var name in result) + core.status.hero[name] += result[name]; } } diff --git a/libs/ui.js b/libs/ui.js index f7c437f8..76ad2603 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2059,7 +2059,7 @@ ui.prototype.drawEquipbox = function(index) { if (compare[name]<0) color = '#FF0000'; var nowValue = core.getStatus(name), newValue = nowValue + compare[name]; if (equip.equip.percentage) { - var nowBuff = core.getFlag('__'+name+"_buff__", 1), newBuff = nowBuff+compare[name]/100; + var nowBuff = core.getBuff(name), newBuff = nowBuff+compare[name]/100; nowValue = Math.floor(nowBuff*core.getStatus(name)); newValue = Math.floor(newBuff*core.getStatus(name)); } diff --git a/project/events.js b/project/events.js index 92458391..f9b4d108 100644 --- a/project/events.js +++ b/project/events.js @@ -118,14 +118,12 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 = "text": "<1:扣比例" }, { - "type": "setValue2", - "name": "flag:__atk_buff__", - "value": "-core.values.weakValue" + "type": "function", + "function": "function(){\ncore.addBuff('atk', -core.values.weakValue);\n}" }, { - "type": "setValue2", - "name": "flag:__def_buff__", - "value": "-core.values.weakValue" + "type": "function", + "function": "function(){\ncore.addBuff('def', -core.values.weakValue);\n}" } ] } diff --git a/project/functions.js b/project/functions.js index ea77402d..4ff799de 100644 --- a/project/functions.js +++ b/project/functions.js @@ -60,10 +60,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setFlag('hard', 4); // 可以用flag:hard来获得当前难度 } - // 设置三围的初始增幅属性(均为1) - ["atk", "def", "mdef"].forEach(function (name) { - core.setFlag("__" + name + "_buff__", 1); - }); // 设置已经到过的楼层 core.setFlag("__visited__", {}); diff --git a/project/items.js b/project/items.js index 1c464161..83b236c7 100644 --- a/project/items.js +++ b/project/items.js @@ -372,9 +372,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "upFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.ui.x, 'y': core.status.event.ui.y};\nif (core.status.event.id == 'action') {\n\tcore.insertAction([\n\t\t{\"type\": \"changeFloor\", \"loc\": [loc.x, loc.y], \"direction\": loc.direction, \"floorId\": core.status.event.ui.id},\n\t\t{\"type\": \"tip\", \"text\": core.material.items[itemId].name + '使用成功'}\n\t]);\n}\nelse {\n\tcore.changeFloor(core.status.event.ui.id, null, loc, null, function (){\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t\tcore.replay();\n\t});\n}", "downFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.ui.x, 'y': core.status.event.ui.y};\nif (core.status.event.id == 'action') {\n\tcore.insertAction([\n\t\t{\"type\": \"changeFloor\", \"loc\": [loc.x, loc.y], \"direction\": loc.direction, \"floorId\": core.status.event.ui.id},\n\t\t{\"type\": \"tip\", \"text\": core.material.items[itemId].name + '使用成功'}\n\t]);\n}\nelse {\n\tcore.changeFloor(core.status.event.ui.id, null, loc, null, function (){\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t\tcore.replay();\n\t});\n}\n", "poisonWine": "core.removeFlag('poison');", - "weakWine": "core.removeFlag('weak');\nif (core.values.weakValue>=1) { // >=1:直接扣数值\n\tcore.status.hero.atk += core.values.weakValue;\n\tcore.status.hero.def += core.values.weakValue;\n}\nelse { // <1:扣比例\n\tcore.addFlag(\"__atk_buff__\", core.values.weakValue);\n\tcore.addFlag(\"__def_buff__\", core.values.weakValue);\n}", + "weakWine": "core.removeFlag('weak');\nif (core.values.weakValue>=1) { // >=1:直接扣数值\n\tcore.status.hero.atk += core.values.weakValue;\n\tcore.status.hero.def += core.values.weakValue;\n}\nelse { // <1:扣比例\n\tcore.addBuff(\"atk\", core.values.weakValue);\n\tcore.addBuff(\"def\", core.values.weakValue);\n}", "curseWine": "core.removeFlag('curse');", - "superWine": "core.removeFlag('poison');\nif (core.hasFlag('weak')) {\n\tcore.removeFlag('weak');\n\tif (core.values.weakValue>=1) { // >=1:直接扣数值\n\t\tcore.status.hero.atk += core.values.weakValue;\n\t\tcore.status.hero.def += core.values.weakValue;\n\t}\n\telse { // <1:扣比例\n\t\tcore.addFlag(\"__atk_buff__\", core.values.weakValue);\n\t\tcore.addFlag(\"__def_buff__\", core.values.weakValue);\n\t}\n}\ncore.removeFlag('curse');", + "superWine": "core.removeFlag('poison');\nif (core.hasFlag('weak')) {\n\tcore.removeFlag('weak');\n\tif (core.values.weakValue>=1) { // >=1:直接扣数值\n\t\tcore.status.hero.atk += core.values.weakValue;\n\t\tcore.status.hero.def += core.values.weakValue;\n\t}\n\telse { // <1:扣比例\n\t\tcore.addBuff(\"atk\", core.values.weakValue);\n\t\tcore.addBuff(\"def\", core.values.weakValue);\n\t}\n}\ncore.removeFlag('curse');", "lifeWand": "core.insertAction([\n\t{\"type\": \"input\", \"text\": \"请输入生命魔杖使用次数:(0-${item:lifeWand})\"},\n\t{\"type\": \"if\", \"condition\": \"flag:input<=item:lifeWand\",\n\t\t\"true\": [\n\t\t\t{\"type\": \"setValue\", \"name\": \"item:lifeWand\", \"value\": \"item:lifeWand-flag:input\"},\n\t\t\t{\"type\": \"setValue\", \"name\": \"status:hp\", \"value\": \"status:hp+flag:input*100\"},\n\t\t\t\"成功使用${flag:input}次生命魔杖,恢复${flag:input*100}点生命。\"\n\t\t],\n\t\t\"false\": [\"输入不合法!\"]\n\t},\n]);\ncore.addItem('lifeWand', 1);", "jumpShoes": "core.insertAction({\"type\":\"jumpHero\",\"loc\":[core.nextX(2),core.nextY(2)]});", "redPotion": "core.status.hero.hp += core.values.redPotion",