From 41d9c5a2985e4fcb7ffcfd20f314ec22d231a3db Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 11 Oct 2018 16:53:39 +0800 Subject: [PATCH 1/6] getEnemyInfo & Aura --- _server/functions.comment.js | 6 +++ docs/api.md | 14 ++--- docs/personalization.md | 2 +- libs/actions.js | 12 +++-- libs/control.js | 4 +- libs/core.js | 28 +++++----- libs/enemys.js | 58 ++++++++++---------- libs/events.js | 2 +- libs/ui.js | 31 ++++++----- project/functions.js | 102 +++++++++++++++++++++++++++++------ 更新说明.txt | 14 ++++- 11 files changed, 186 insertions(+), 87 deletions(-) diff --git a/_server/functions.comment.js b/_server/functions.comment.js index ecc6ac0f..acceed2f 100644 --- a/_server/functions.comment.js +++ b/_server/functions.comment.js @@ -103,6 +103,12 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_lint": true, "_data": "怪物特殊属性的定义(获得怪物的特殊属性)" }, + "getEnemyInfo": { + "_leaf": true, + "_type": "textarea", + "_lint": true, + "_data": "获得某个怪物的当前属性数据\n该函数主要是会被伤害计算和怪物手册等使用" + }, "getDamageInfo": { "_leaf": true, "_type": "textarea", diff --git a/docs/api.md b/docs/api.md index 14cde546..0388bd22 100644 --- a/docs/api.md +++ b/docs/api.md @@ -349,34 +349,36 @@ core.enemys.getSpecialHint(enemy, special) 获得怪物某个(或全部)特殊属性的文字说明。 -core.enemys.canBattle(enemyId) +core.enemys.canBattle(enemyId, x, y, floorId) 返回当前能否战胜某个怪物。 +后面三个参数是怪物坐标和楼层。 -core.enemys.getDamage(enemyId) +core.enemys.getDamage(enemyId, x, y, floorId) 返回当前对某个怪物的战斗伤害。如果无法战斗,返回null。 +后面三个参数是怪物坐标和楼层。 core.enemys.getExtraDamage(enemyId) 返回某个怪物会对勇士造成的额外伤害(不可被魔防抵消),例如仇恨、固伤等等。 -core.enemys.nextCriticals(enemyId, number) +core.enemys.nextCriticals(enemyId, number, x, y, floorId) 返回一个列表,为接下来number(可忽略,默认为1)个该怪物的临界值和临界减伤。 列表每一项类似 [x,y] 表示临界值为x,且临界减伤为y。 如果无临界值,则返回空列表。 -core.enemys.getDefDamage(enemyId, k) +core.enemys.getDefDamage(enemyId, k, x, y, floorId) 获得k(可忽略,默认为1)防减伤值。 -core.enemys.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef) +core.enemys.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) 获得实际战斗信息,比如伤害,回合数,每回合伤害等等。 此函数是实际战斗过程的计算。 -core.enemys.calDamage(enemy, hero_hp, hero_atk, hero_def, hero_mdef) +core.enemys.calDamage(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) 获得在某个勇士属性下怪物伤害;实际返回的是上面getDamageInfo中伤害的数值。 diff --git a/docs/personalization.md b/docs/personalization.md index f7d4422b..43b2987e 100644 --- a/docs/personalization.md +++ b/docs/personalization.md @@ -320,7 +320,7 @@ core.setFlag("shield5", true); // 增加一个自定义Flag:已经拿到神圣 ``` 2. 免疫吸血效果:在脚本编辑的getDamageInfo中,编辑成如果存在神圣盾标记,吸血伤害为0。 ``` js -function (enemy, hero_hp, hero_atk, hero_def, hero_mdef) { +function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { // ... 上略 // 吸血 if (this.hasSpecial(mon_special, 11)) { diff --git a/libs/actions.js b/libs/actions.js index 706eac89..a42ea53c 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1030,14 +1030,14 @@ actions.prototype.clickViewMaps = function (x,y) { return; } - if(x>=2 && x<=10 && y<=4) { + if(y<=4 && (mh==13 || (x>=2 && x<=10))) { index++; while (index=2 && x<=10 && y>=8) { + else if (y>=8 && (mh==13 || (x>=2 && x<=10))) { index--; while (index>=0 && index!=now && core.floors[core.floorIds[index]].cannotViewMap) index--; @@ -2067,6 +2067,10 @@ actions.prototype.clickSyncSave = function (x,y) { }); break; case 4: + core.status.event.selection=0; + core.ui.drawReplay(); + break; + case 5: if (core.hasFlag('debug')) { core.drawText("\t[系统提示]调试模式下无法下载录像"); break; @@ -2078,11 +2082,11 @@ actions.prototype.clickSyncSave = function (x,y) { 'route': core.encodeRoute(core.status.route) })); break; - case 5: + case 6: core.status.event.selection=0; core.ui.drawStorageRemove(); break; - case 6: + case 7: core.status.event.selection=3; core.ui.drawSettings(); break; diff --git a/libs/control.js b/libs/control.js index a910c9a5..d9233d8f 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1280,7 +1280,7 @@ control.prototype.snipe = function (snipes) { snipe.blockImage = core.material.images[cls]; snipe.height = height; - var damage = core.enemys.getDamage(block.event.id); + var damage = core.enemys.getDamage(block.event.id, x, y); var color = '#000000'; if (damage == null) { @@ -1514,7 +1514,7 @@ control.prototype.updateDamage = function () { var id = mapBlocks[b].event.id; if (core.flags.displayEnemyDamage) { - var damage = core.enemys.getDamage(id); + var damage = core.enemys.getDamage(id, x, y); var color = '#000000'; if (damage == null) { diff --git a/libs/core.js b/libs/core.js index a4157709..9033a221 100644 --- a/libs/core.js +++ b/libs/core.js @@ -232,19 +232,23 @@ core.prototype.init = function (coreData, callback) { core.platform.isQQ = /QQ/i.test(navigator.userAgent); core.platform.isWeChat = /MicroMessenger/i.test(navigator.userAgent); core.platform.useLocalForage = core.getLocalStorage('useLocalForage', true); + if (core.platform.isIOS) core.platform.useLocalForage=false; if (core.platform.useLocalForage) { try { - core.setLocalForage("__test__", "__test__", function() { + core.setLocalForage("__test__", LZString.compress("__test__"), function() { try { core.getLocalForage("__test__", null, function(data) { - if (data!="__test__") { - console.log("localForage unsupported!"); - core.platform.useLocalForage=false; - } - else { - console.log("localForage supported!") - core.removeLocalForage("__test__"); + try { + if (LZString.decompress(data)!="__test__") { + console.log("localForage unsupported!"); + core.platform.useLocalForage=false; + } + else { + console.log("localForage supported!") + core.removeLocalForage("__test__"); + } } + catch (e) {console.log(e); core.platform.useLocalForage=false;} }, function(e) {console.log(e); core.platform.useLocalForage=false;}) } catch (e) {console.log(e); core.platform.useLocalForage=false;} @@ -821,13 +825,13 @@ core.prototype.hasSpecial = function (special, test) { } ////// 判断能否战斗 ////// -core.prototype.canBattle = function(enemyId) { - return core.enemys.canBattle(enemyId); +core.prototype.canBattle = function(enemyId, x, y, floorId) { + return core.enemys.canBattle(enemyId, x, y, floorId); } ////// 获得伤害数值 ////// -core.prototype.getDamage = function(enemy) { - return core.enemys.getDamage(enemy); +core.prototype.getDamage = function(enemy, x, y, floorId) { + return core.enemys.getDamage(enemy, x, y, floorId); } ////// 获得某个物品的个数 ////// diff --git a/libs/enemys.js b/libs/enemys.js index c2f7d3ee..efae6beb 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -99,15 +99,15 @@ enemys.prototype.getSpecialHint = function (enemy, special) { } ////// 能否获胜 ////// -enemys.prototype.canBattle = function (enemyId) { - var damage = this.getDamage(enemyId); +enemys.prototype.canBattle = function (enemyId, x, y, floorId) { + var damage = this.getDamage(enemyId, x, y, floorId); return damage != null && damage < core.status.hero.hp; } ////// 获得某个怪物的伤害 ////// -enemys.prototype.getDamage = function (enemy) { +enemys.prototype.getDamage = function (enemy, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - var damage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef); + var damage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); if (damage == null) return null; return damage + this.getExtraDamage(enemy); } @@ -126,7 +126,7 @@ enemys.prototype.getExtraDamage = function (enemy) { } ////// 接下来N个临界值和临界减伤计算 ////// -enemys.prototype.nextCriticals = function (enemy, number) { +enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; var useTurn = !core.flags.useLoop; @@ -142,7 +142,7 @@ enemys.prototype.nextCriticals = function (enemy, number) { // 坚固、模仿怪物没有临界! if (this.hasSpecial(enemy.special, 10)) return []; - var info = this.getDamageInfo(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef); + var info = this.getDamageInfo(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); if (info == null) { if (core.status.hero.atk<=enemy.def) { @@ -167,7 +167,7 @@ enemys.prototype.nextCriticals = function (enemy, number) { } if (nextAtk<=hero_atk) break; if (nextAtk!=pre) { - var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, nextAtk, core.status.hero.def, core.status.hero.mdef); + var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, nextAtk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); if (nextInfo==null) break; list.push([nextAtk-hero_atk,info.damage-nextInfo.damage]); if (nextInfo.damage<=0 && !core.flags.enableNegativeDamage) break; @@ -180,7 +180,7 @@ enemys.prototype.nextCriticals = function (enemy, number) { else { // 暴力for循环法 pre = info.damage; for (var atk=hero_atk+1;atk<=mon_hp+mon_def;atk++) { - var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef); + var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); if (nextInfo==null) break; if (pre>nextInfo.damage) { pre = nextInfo.damage; @@ -195,27 +195,32 @@ enemys.prototype.nextCriticals = function (enemy, number) { } ////// N防减伤计算 ////// -enemys.prototype.getDefDamage = function (enemy, k) { +enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; k = k || 1; - var nowDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef); - var nextDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + k, core.status.hero.mdef); + var nowDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); + var nextDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + k, core.status.hero.mdef, x, y, floorId); if (nowDamage == null || nextDamage ==null) return "???"; return nowDamage - nextDamage; } +enemys.prototype.getEnemyInfo = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { + if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; + return this.enemydata.getEnemyInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) +} + ////// 获得战斗伤害信息(实际伤害计算函数) ////// -enemys.prototype.getDamageInfo = function(enemy, hero_hp, hero_atk, hero_def, hero_mdef) { +enemys.prototype.getDamageInfo = function(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { // 移动到了脚本编辑 - getDamageInfo中 if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - return this.enemydata.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef); + return this.enemydata.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId); } ////// 获得在某个勇士属性下怪物伤害 ////// -enemys.prototype.calDamage = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef) { +enemys.prototype.calDamage = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - var info = this.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef); + var info = this.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId); if (info == null) return null; return info.damage; } @@ -246,12 +251,7 @@ enemys.prototype.getCurrentEnemys = function (floorId) { hero_def = Math.floor(core.getFlag('equip_def_buff',1)*hero_def); hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef); } - if (this.hasSpecial(enemy.special, 10)) { - mon_atk=hero_atk; - mon_def=hero_def; - } - if (this.hasSpecial(enemy.special, 3) && mon_def < hero_atk - 1) - mon_def = hero_atk - 1; + var enemyInfo = this.getEnemyInfo(enemy, core.status.hero.hp, hero_atk, hero_def, hero_mdef, null, null, floorId); var specialText = core.enemys.getSpecialText(enemyId); if (specialText.length>=3) specialText = "多属性..."; @@ -263,17 +263,17 @@ enemys.prototype.getCurrentEnemys = function (floorId) { enemys.push({ 'id': enemyId, 'name': enemy.name, - 'hp': mon_hp, - 'atk': mon_atk, - 'def': mon_def, - 'money': enemy.money, - 'experience': enemy.experience, - 'point': enemy.point||0, // 加点 + 'hp': enemyInfo.hp, + 'atk': enemyInfo.atk, + 'def': enemyInfo.def, + 'money': enemyInfo.money||0, + 'experience': enemyInfo.experience||0, + 'point': enemyInfo.point||0, // 加点 'special': specialText, - 'damage': this.getDamage(enemyId), + 'damage': this.getDamage(enemyId,null,null,floorId), 'critical': critical[0], 'criticalDamage': critical[1], - 'defDamage': this.getDefDamage(enemyId) + 'defDamage': this.getDefDamage(enemyId,1,null,null,floorId) }); used[enemyId] = true; diff --git a/libs/events.js b/libs/events.js index aab2a7d1..7c043b97 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1120,7 +1120,7 @@ events.prototype.battle = function (id, x, y, force, callback) { core.stopAutomaticRoute(); // 非强制战斗 - if (!core.enemys.canBattle(id) && !force && !core.isset(core.status.event.id)) { + if (!core.enemys.canBattle(id, x, y) && !force && !core.isset(core.status.event.id)) { core.drawTip("你打不过此怪物!"); core.clearContinueAutomaticRoute(); return; diff --git a/libs/ui.js b/libs/ui.js index 47cd026e..7fada304 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -862,8 +862,11 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) { var hero_hp = core.getStatus('hp'), hero_atk = core.getStatus('atk'), hero_def = core.getStatus('def'), hero_mdef = core.getStatus('mdef'); - var monster = core.material.enemys[monsterId]; - var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_money=monster.money, mon_exp = monster.experience, mon_special=monster.special; + + hero_hp=Math.max(0, hero_hp); + hero_atk=Math.max(0, hero_atk); + hero_def=Math.max(0, hero_def); + hero_mdef=Math.max(0, hero_mdef); if (core.flags.equipPercentage) { hero_atk = Math.floor(core.getFlag('equip_atk_buff',1)*hero_atk); @@ -871,30 +874,30 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) { hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef); } + var enemy = core.material.enemys[monsterId]; + var enemyInfo = core.enemys.getEnemyInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef); + var mon_hp = enemyInfo.hp, mon_atk = enemyInfo.atk, mon_def = enemyInfo.def, mon_money=enemyInfo.money, + mon_exp = enemyInfo.experience, mon_special=enemyInfo.special; + var initDamage = 0; // 战前伤害 // 吸血 if (core.enemys.hasSpecial(mon_special, 11)) { - var vampireDamage = hero_hp * monster.value; + var vampireDamage = hero_hp * enemy.value; // 如果有神圣盾免疫吸血等可以在这里写 - vampireDamage = Math.floor(vampireDamage); + vampireDamage = Math.floor(vampireDamage) || 0; // 加到自身 - if (monster.add) // 如果加到自身 + if (enemy.add) // 如果加到自身 mon_hp += vampireDamage; initDamage += vampireDamage; } - hero_hp -= core.enemys.getExtraDamage(monster); + hero_hp -= core.enemys.getExtraDamage(enemy); - if (core.enemys.hasSpecial(mon_special, 10)) { // 模仿 - mon_atk=hero_atk; - mon_def=hero_def; - } if (core.enemys.hasSpecial(mon_special, 2)) hero_def=0; // 魔攻 - if (core.enemys.hasSpecial(mon_special, 3) && mon_def0 && x Date: Thu, 11 Oct 2018 17:28:03 +0800 Subject: [PATCH 2/6] drawStatistics & flyTo --- _server/functions.comment.js | 12 +++++++++++ libs/actions.js | 13 ++---------- libs/control.js | 16 +++++++-------- libs/ui.js | 18 ++++++---------- project/functions.js | 40 ++++++++++++++++++++++++++++++++++++ 更新说明.txt | 5 +++-- 6 files changed, 71 insertions(+), 33 deletions(-) diff --git a/_server/functions.comment.js b/_server/functions.comment.js index acceed2f..f49f51d1 100644 --- a/_server/functions.comment.js +++ b/_server/functions.comment.js @@ -127,6 +127,12 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": false, "_type": "object", "_data": { + "flyTo": { + "_leaf": true, + "_type": "textarea", + "_lint": true, + "_data": "使用楼层传送器飞到某层" + }, "updateStatusBar": { "_leaf": true, "_type": "textarea", @@ -145,6 +151,12 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": false, "_type": "object", "_data": { + "drawStatistics": { + "_leaf": true, + "_type": "textarea", + "_lint": true, + "_data": "地图数据统计项的注册" + }, "drawAbout": { "_leaf": true, "_type": "textarea", diff --git a/libs/actions.js b/libs/actions.js index a42ea53c..46640f2f 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -969,17 +969,8 @@ actions.prototype.clickFly = function(x,y) { if ((x==10 || x==11) && y==10) core.ui.drawFly(core.status.event.data-10); if ((x==10 || x==11) && y==4) core.ui.drawFly(core.status.event.data+10); if (x>=5 && x<=7 && y==12) core.ui.closePanel(); - if (x>=0 && x<=9 && y>=3 && y<=11) { - var index=core.status.hero.flyRange.indexOf(core.status.floorId); - var stair=core.status.event.data=0 && x<=9 && y>=3 && y<=11) + core.control.flyTo(core.status.hero.flyRange[core.status.event.data]); return; } diff --git a/libs/control.js b/libs/control.js index d9233d8f..80a4e03e 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1901,14 +1901,10 @@ control.prototype.replay = function () { if (core.hasItem('fly') && toIndex>=0 && nowIndex>=0) { core.ui.drawFly(toIndex); setTimeout(function () { - core.ui.closePanel(); - var stair=toIndex0) { - var name=""; + var name=null; if (key=='yellowDoor') name="黄门"; else if (key=='blueDoor') name="蓝门"; else if (key=='redDoor') name="红门"; else if (key=='greenDoor') name="绿门"; else if (key=='steelDoor') name="铁门"; - else name=core.material.items[key].name; + else name=(core.material.items[key]||{}).name; if (core.isset(name)) { text+=name+value+"个;"; } diff --git a/project/functions.js b/project/functions.js index 384daad0..30d29e48 100644 --- a/project/functions.js +++ b/project/functions.js @@ -554,6 +554,31 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } }, "control": { + "flyTo": function (toId, callback) { + // 楼层传送器的使用,从当前楼层飞往toId + // 如果不能飞行请返回false + + var fromId = core.status.floorId; + + // 检查能否飞行 + if (!core.floors[fromId].canFlyTo || !core.floors[toId].canFlyTo) { + core.drawTip("无法飞往" + core.floors[toId].title +"!"); + return false; + } + + // 获得两个楼层的索引,以决定是上楼梯还是下楼梯 + var fromIndex = core.floorIds.indexOf(fromId), toIndex = core.floorIds.indexOf(toId); + var stair = fromIndex<=toIndex?"downFloor":"upFloor"; + // 地下层:同层传送至上楼梯 + if (fromIndex == toIndex && core.floorIds[fromId].underGround) stair = "upFloor"; + // 记录录像 + core.status.route.push("fly:"+toId); + // 传送 + core.ui.closePanel(); + core.changeFloor(toId, stair, null, null, callback); + + return true; +}, "updateStatusBar": function () { // 更新状态栏 @@ -759,6 +784,21 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } }, "ui": { + "drawStatistics": function () { + // 浏览地图时参与的统计项目 + + return [ + 'yellowDoor', 'blueDoor', 'redDoor', 'greenDoor', 'steelDoor', + 'yellowKey', 'blueKey', 'redKey', 'greenKey', 'steelKey', + 'redJewel', 'blueJewel', 'greenJewel', 'yellowJewel', + 'redPotion', 'bluePotion', 'greenPotion', 'yellowPotion', 'superPotion', + 'pickaxe', 'bomb', 'centerFly', + 'poisonWine', 'weakWine', 'curseWine', 'superWine', + 'sword1', 'sword2', 'sword3', 'sword4', 'sword5', + 'shield1', 'shield2', 'shield3', 'shield4', 'shield5', + // 在这里可以增加新的ID来进行统计个数,只能增加道具ID + ]; +}, "drawAbout": function() { // 绘制“关于”界面 if (!core.isPlaying()) { diff --git a/更新说明.txt b/更新说明.txt index e25cb82f..64c7c121 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,8 +1,9 @@ HTML5魔塔样板V2.4.1 增加光环属性 -怪物属性获取独立到脚本编辑中 -楼层传送代码独立到脚本编辑中 +怪物属性获取移动到脚本编辑中 +楼层传送代码移动到脚本编辑中 +地图数据统计移动到脚本编辑中 状态栏可以显示角色名字 修复大地图的夹击Bug iOS设备默认关闭新版存档 From 806449381b69914cb291272bcf5ee6c1adaf707b Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 11 Oct 2018 17:44:17 +0800 Subject: [PATCH 3/6] Double Click Toolbox --- libs/actions.js | 4 ++-- libs/ui.js | 4 ++-- main.js | 16 +++++++++++++++- project/functions.js | 2 +- 更新说明.txt | 4 +++- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 46640f2f..7dd56cad 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -977,7 +977,7 @@ actions.prototype.clickFly = function(x,y) { ////// 楼层传送器界面时,按下某个键的操作 ////// actions.prototype.keyDownFly = function (keycode) { if (keycode==37) core.ui.drawFly(core.status.event.data-10); - else if ( keycode==38) core.ui.drawFly(core.status.event.data+1); + else if (keycode==38) core.ui.drawFly(core.status.event.data+1); else if (keycode==39) core.ui.drawFly(core.status.event.data+10); else if (keycode==40) core.ui.drawFly(core.status.event.data-1); return; @@ -1222,7 +1222,7 @@ actions.prototype.keyUpQuickShop = function (keycode) { ////// 工具栏界面时的点击操作 ////// actions.prototype.clickToolbox = function(x,y) { // 装备栏 - if (x>=10 && x<=12 && y==0 && core.flags.equipment) { + if (x>=10 && x<=12 && y==0) { core.ui.closePanel(); core.openEquipbox(); return; diff --git a/libs/ui.js b/libs/ui.js index 67608838..f7984067 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1747,8 +1747,8 @@ ui.prototype.drawToolbox = function(index) { core.canvas.ui.textAlign = 'center'; // 装备栏 - if (core.flags.equipment) - core.fillText('ui', '[装备栏]', 370, 25,'#DDDDDD', 'bold 15px Verdana'); + // if (core.flags.equipment) + core.fillText('ui', '[装备栏]', 370, 25,'#DDDDDD', 'bold 15px Verdana'); // core.fillText('ui', '删除道具', 370, 32,'#DDDDDD', 'bold 15px Verdana'); // 退出 core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana'); diff --git a/main.js b/main.js index 130a77b3..f966596c 100644 --- a/main.js +++ b/main.js @@ -413,8 +413,22 @@ main.statusBar.image.toolbox.onclick = function () { return; } + if (main.core.isPlaying()) { + main.core.openToolbox(core.status.event.id != 'equipbox'); + } +} + +////// 双击状态栏中的工具箱时 ////// +main.statusBar.image.toolbox.ondblclick = function () { + + if (core.isset(core.status.replay) && core.status.replay.replaying) { + core.rewindReplay(); + return; + } + if (main.core.isPlaying()) - main.core.openToolbox(true); + main.core.openEquipbox(true); + } ////// 点击状态栏中的快捷商店时 ////// diff --git a/project/functions.js b/project/functions.js index 30d29e48..f128df95 100644 --- a/project/functions.js +++ b/project/functions.js @@ -677,7 +677,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // Step2: 更新领域、阻击伤害 - core.status.checkBlock.damage = []; // 记录(x,y)点的伤害;(x,y)对应的值是 x+y*core.bigmap + core.status.checkBlock.damage = []; // 记录(x,y)点的伤害;(x,y)对应的值是 x+core.bigmap.width*y for (var x=0;x Date: Thu, 11 Oct 2018 21:51:41 +0800 Subject: [PATCH 4/6] Name on statusBar --- _server/data.comment.js | 6 ++++ editor-mobile.html | 4 +++ editor.html | 4 +++ index.html | 4 +++ libs/control.js | 78 ++++++++++++++++++++++++++++++----------- libs/core.js | 6 ++-- libs/events.js | 9 +++-- main.js | 4 +++ project/data.js | 1 + project/functions.js | 5 ++- styles.css | 4 +++ 11 files changed, 98 insertions(+), 27 deletions(-) diff --git a/_server/data.comment.js b/_server/data.comment.js index 94a6fcbb..a149b17b 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -351,6 +351,12 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_bool": "bool", "_data": "是否在状态栏显示当前楼层" }, + "enableName": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "是否在状态栏显示勇士名字" + }, "enableLv": { "_leaf": true, "_type": "checkbox", diff --git a/editor-mobile.html b/editor-mobile.html index 3f656e78..b04d75ae 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -333,6 +333,10 @@

+
+ +

+

diff --git a/editor.html b/editor.html index f3d9b16f..1a37ee1b 100644 --- a/editor.html +++ b/editor.html @@ -319,6 +319,10 @@

+
+ +

+

diff --git a/index.html b/index.html index 7710ce4e..f84ce4e1 100644 --- a/index.html +++ b/index.html @@ -46,6 +46,10 @@

+
+ +

+

diff --git a/libs/control.js b/libs/control.js index 80a4e03e..505ab2d4 100644 --- a/libs/control.js +++ b/libs/control.js @@ -250,6 +250,8 @@ control.prototype.clearStatus = function() { } core.status = {}; core.clearStatusBar(); + core.status.played = false; + core.events.setHeroIcon('hero.png', true); } ////// 重置游戏状态和初始数据 ////// @@ -266,7 +268,6 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value // 初始化status core.status = core.clone(core.initStatus); - core.status.played = true; // 初始化maps core.status.floorId = floorId; core.status.maps = core.clone(maps); @@ -275,6 +276,8 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value core.material.items = core.clone(core.items.getItems()); // 初始化人物属性 core.status.hero = core.clone(hero); + // 初始化人物图标 + core.events.setHeroIcon(core.getFlag('heroIcon', 'hero.png'), true); // 统计数据 if (!core.isset(core.status.hero.statistics)) core.status.hero.statistics = { @@ -302,6 +305,7 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value else core.values = core.clone(core.data.values); core.events.initGame(); + core.status.played = true; } ////// 开始游戏 ////// @@ -1022,6 +1026,8 @@ control.prototype.updateViewport = function() { ////// 绘制勇士 ////// control.prototype.drawHero = function (direction, x, y, status, offset) { + if (!core.isPlaying()) return; + var scan = { 'up': {'x': 0, 'y': -1}, 'left': {'x': -1, 'y': 0}, @@ -1197,20 +1203,22 @@ control.prototype.checkBlock = function () { // 检查阻击事件 var snipe = []; - var scan = { - 'up': {'x': 0, 'y': -1}, - 'left': {'x': -1, 'y': 0}, - 'down': {'x': 0, 'y': 1}, - 'right': {'x': 1, 'y': 0} - } - for (var direction in scan) { - var nx = x+scan[direction].x, ny=y+scan[direction].y; - if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue; - var id=core.status.checkBlock.map[nx+core.bigmap.width*ny]; - if (core.isset(id)) { - var enemy = core.material.enemys[id]; - if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) { - snipe.push({'direction': direction, 'x': nx, 'y': ny}); + if (!core.hasFlag("no_snipe")) { + var scan = { + 'up': {'x': 0, 'y': -1}, + 'left': {'x': -1, 'y': 0}, + 'down': {'x': 0, 'y': 1}, + 'right': {'x': 1, 'y': 0} + } + for (var direction in scan) { + var nx = x+scan[direction].x, ny=y+scan[direction].y; + if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue; + var id=core.status.checkBlock.map[nx+core.bigmap.width*ny]; + if (core.isset(id)) { + var enemy = core.material.enemys[id]; + if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) { + snipe.push({'direction': direction, 'x': nx, 'y': ny}); + } } } } @@ -2585,11 +2593,11 @@ control.prototype.playSound = function (sound) { ////// 清空状态栏 ////// control.prototype.clearStatusBar = function() { - var statusList = ['floor', 'lv', 'hpmax', 'hp', 'atk', 'def', 'mdef', 'money', 'experience', - 'up', 'yellowKey', 'blueKey', 'redKey', 'poison', 'weak', 'curse', 'hard']; - statusList.forEach(function (e) { - core.statusBar[e].innerHTML = " "; - }); + + Object.keys(core.statusBar).forEach(function (e) { + if (core.isset(core.statusBar[e].innerHTML)) + core.statusBar[e].innerHTML = " "; + }) core.statusBar.image.book.style.opacity = 0.3; if (!core.flags.equipboxButton) { core.statusBar.image.fly.style.opacity = 0.3; @@ -2645,6 +2653,27 @@ control.prototype.updateStatusBar = function () { } } +control.prototype.updateHeroIcon = function (name) { + name = name || "hero.png"; + if (core.statusBar.icons.name == name) return; + core.statusBar.icons.name = name; + + var image = core.material.images.hero; + + var canvas = document.createElement("canvas"); + var context = canvas.getContext("2d"); + canvas.width = 32; + canvas.height = 32; + context.drawImage(image, 0, 0, 32, 32, 0, 0, 32, 32); + if (core.material.icons.hero.height>=48) { + context.lineWidth = 5; + context.strokeStyle = '#FFFFFF'; + context.strokeRect(0, 0, 32, 32); + } + core.statusBar.image.name.src = canvas.toDataURL("image/png"); + +} + ////// 屏幕分辨率改变后重新自适应 ////// control.prototype.resize = function(clientWidth, clientHeight) { if (main.mode=='editor')return; @@ -2685,8 +2714,9 @@ control.prototype.resize = function(clientWidth, clientHeight) { if (!core.flags.enableExperience) count--; if (!core.flags.enableLevelUp) count--; if (!core.flags.enableDebuff) count--; - if (core.isset(core.flags.enableKeys) && !core.flags.enableKeys) count--; + if (!core.flags.enableKeys) count--; if (!core.flags.enablePZF) count--; + if (!core.flags.enableName) count--; var statusLineHeight = BASE_LINEHEIGHT * 9 / count; var statusLineFontSize = DEFAULT_FONT_SIZE; @@ -2940,6 +2970,12 @@ control.prototype.resize = function(clientWidth, clientHeight) { display: core.flags.enableFloor ? 'block': 'none' } }, + { + id: 'nameCol', + rules: { + display: core.flags.enableName ? 'block': 'none' + } + }, { id: 'lvCol', rules: { diff --git a/libs/core.js b/libs/core.js index 9033a221..b155f6e5 100644 --- a/libs/core.js +++ b/libs/core.js @@ -292,8 +292,7 @@ core.prototype.init = function (coreData, callback) { core.flags.displayEnemyDamage = core.getLocalStorage('enemyDamage', core.flags.displayEnemyDamage); core.flags.displayCritical = core.getLocalStorage('critical', core.flags.displayCritical); core.flags.displayExtraDamage = core.getLocalStorage('extraDamage', core.flags.displayExtraDamage); - core.flags.clickMoveDirectly = core.getLocalStorage('clickMoveDirectly', - !(core.isset(core.flags.clickMoveDirectly) && !core.flags.clickMoveDirectly)); + core.flags.clickMoveDirectly = core.getLocalStorage('clickMoveDirectly', core.flags.clickMoveDirectly); core.material.ground = new Image(); core.material.ground.src = "project/images/ground.png"; @@ -304,6 +303,9 @@ core.prototype.init = function (coreData, callback) { console.log(core.material); // 设置勇士高度 core.material.icons.hero.height = core.material.images.hero.height/4; + // 行走图 + core.control.updateHeroIcon(); + core.initStatus.maps = core.maps.initMaps(core.floorIds); core.setRequestAnimationFrame(); core.showStartAnimate(); diff --git a/libs/events.js b/libs/events.js index 7c043b97..39950751 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1568,12 +1568,15 @@ events.prototype.canUseQuickShop = function(shopId) { } ////// 设置角色行走图 ////// -events.prototype.setHeroIcon = function (name) { +events.prototype.setHeroIcon = function (name, noDraw) { if (core.isset(core.material.images.images[name]) && core.material.images.images[name].width==128) { core.setFlag("heroIcon", name); + core.material.images.hero.onload = function () { + core.material.icons.hero.height = core.material.images.images[name].height/4; + core.control.updateHeroIcon(name); + if (!noDraw) core.drawHero(); + } core.material.images.hero.src = core.material.images.images[name].src; - core.material.icons.hero.height = core.material.images.images[name].height/4; - core.drawHero(); } } diff --git a/main.js b/main.js index f966596c..54442633 100644 --- a/main.js +++ b/main.js @@ -51,6 +51,7 @@ function main() { 'data': document.getElementById('data'), 'statusLabels': document.getElementsByClassName('statusLabel'), 'floorCol': document.getElementById('floorCol'), + 'nameCol': document.getElementById('nameCol'), 'lvCol': document.getElementById('lvCol'), 'hpmaxCol': document.getElementById('hpmaxCol'), 'mdefCol': document.getElementById('mdefCol'), @@ -76,6 +77,7 @@ function main() { this.statusBar = { 'image': { 'floor': document.getElementById('img-floor'), + 'name': document.getElementById('img-name'), 'lv': document.getElementById('img-lv'), 'hpmax': document.getElementById('img-hpmax'), 'hp': document.getElementById("img-hp"), @@ -95,6 +97,7 @@ function main() { }, 'icons': { 'floor': 0, + 'name': null, 'lv': 1, 'hpmax': 2, 'hp': 3, @@ -120,6 +123,7 @@ function main() { 'equipbox': 23, }, 'floor': document.getElementById('floor'), + 'name': document.getElementById('name'), 'lv': document.getElementById('lv'), 'hpmax': document.getElementById('hpmax'), 'hp': document.getElementById('hp'), diff --git a/project/data.js b/project/data.js index d708e48a..e035a504 100644 --- a/project/data.js +++ b/project/data.js @@ -187,6 +187,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, "flags": { "enableFloor": true, + "enableName": false, "enableLv": false, "enableHPMax": false, "enableMDef": true, diff --git a/project/functions.js b/project/functions.js index f128df95..8c35d32a 100644 --- a/project/functions.js +++ b/project/functions.js @@ -590,7 +590,10 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setStatus('hp', Math.min(core.getStatus('hpmax'), core.getStatus('hp'))); } - // 设置等级奴名称 + // 设置勇士名字和图标 + core.statusBar.name.innerHTML = core.getStatus('name'); + + // 设置等级名称 var lvName = core.getLvName(); core.statusBar.lv.innerHTML = lvName; // 检测是不是纯数字;如果带中文等需要取消斜体(不然很难看的!) diff --git a/styles.css b/styles.css index 6b45773f..19d1048e 100644 --- a/styles.css +++ b/styles.css @@ -227,6 +227,10 @@ span#poison, span#weak, span#curse, span#pickaxe, span#bomb, span#fly { font-size: 1em; } +p#name { + font-style: normal; +} + .gameCanvas { position: absolute; box-sizing: border-box; From 6aed9a63d38be55cf3c04d9164c76a0d69751d6a Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 11 Oct 2018 22:15:05 +0800 Subject: [PATCH 5/6] canUseQuickShop in functions --- _server/functions.comment.js | 8 +++++++- docs/personalization.md | 13 +++++++------ libs/events.js | 5 +---- project/functions.js | 12 ++++++++++++ 更新说明.txt | 6 +++--- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/_server/functions.comment.js b/_server/functions.comment.js index f49f51d1..2e5f1735 100644 --- a/_server/functions.comment.js +++ b/_server/functions.comment.js @@ -90,6 +90,12 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_lint": true, "_data": "读档事件后,载入事件前,可以执行的操作" + }, + "canUseQuickShop": { + "_leaf": true, + "_type": "textarea", + "_lint": true, + "_data": "当前能否使用快捷商店" } } }, @@ -144,7 +150,7 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_lint": true, "_data": "阻激夹域的伤害值计算" - }, + } } }, "ui": { diff --git a/docs/personalization.md b/docs/personalization.md index 5eb8c866..78ab906f 100644 --- a/docs/personalization.md +++ b/docs/personalization.md @@ -501,7 +501,7 @@ case 87: // W // 请使用同步脚本,请勿执行任何异步代码,否则可能导致游戏过程或录像出现问题。 core.insertAction([...]) // 例如,插入一段自定义事件并执行。 - core.status.route.push("key:"+keyCode); // 录像的支持!这句话必须要加,不然录像回放会出错! + // core.status.route.push("key:"+keyCode); // 录像的支持,这句话加不加最好仔细进行测试 } break; ``` @@ -509,7 +509,9 @@ case 87: // W 在勇士处于停止的条件下,按下W键时,将执行你写的脚本代码。请只使用同步脚本而不要使用异步代码,不然可能导致游戏出现问题。 -`core.status.route.push("key:"+keyCode);` 这句话是对录像的支持,一定要加(这样录像播放时也会模拟该按键)。 +`core.status.route.push("key:"+keyCode);` 这句话是对录像的支持。 + +**录像的支持可能比较诡异,在不同条件下都是不同的;因此加不加最好分开独立进行测试。** !> H5不支持组合快捷键,所以不存在`W+1`这种组合快捷键的说法! @@ -560,8 +562,8 @@ this.myfunc = function(x) {

``` -3. 在editor.html中的statusBar(305行起),仿照第二点同样添加;这一项如果不进行则会地图编辑器报错。 -4. 使用便捷PS工具,打开icons.png,新增一行并将魔力的图标P上去;记下其索引比如23(减速播放图标的下方)。 +3. 在editor.html中的statusBar(317行起),仿照第二点同样添加;这一项如果不进行则会地图编辑器报错。editor-mobile.html同理。 +4. 使用便捷PS工具,打开icons.png,新增一行并将魔力的图标P上去;记下其索引比如24(从0开始数)。 5. 在main.js的this.statusBar中增加图片、图标和内容的定义。 ``` js this.statusBar = { @@ -571,7 +573,7 @@ this.statusBar = { }, 'icons': { // ...其他略 - 'mana': 23, // 图标的定义,这里对应的是icons.png中的索引 + 'mana': 24, // 图标的定义,这里对应的是icons.png中的索引 }, // ...其他略 'mana': document.getElementById('mana'), // 显示内容(数据)的定义 @@ -583,7 +585,6 @@ core.statusBar.mana.innerHTML = core.getFlag('mana', 0); // 设置其显示内 core.statusBar.mana.innerHTML = core.getFlag('mana', 0) + '/' + core.getFlag('manaMax', 0); // 显示内容将类似 "32/60" 这样。 core.statusBar.mana.style.fontStyle = 'normal'; // 这一行会取消斜体。如果是汉字(比如技能名)的话,斜体起来会非常难看,可以通过这一句取消。 ``` -7. 在control.js的clearStatusBar函数,`statusList`里面也要增加mana项,这样清空状态栏时也会对其清空。 ## 技能塔的支持 diff --git a/libs/events.js b/libs/events.js index 39950751..23786921 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1561,10 +1561,7 @@ events.prototype.disableQuickShop = function (shopId) { ////// 能否使用快捷商店 ////// events.prototype.canUseQuickShop = function(shopId) { - if (core.isset(core.floors[core.status.floorId].canUseQuickShop) && !core.floors[core.status.floorId].canUseQuickShop) - return '当前不能使用快捷商店。'; - - return null; + return this.eventdata.canUseQuickShop(shopId); } ////// 设置角色行走图 ////// diff --git a/project/functions.js b/project/functions.js index 8c35d32a..d34b5b6c 100644 --- a/project/functions.js +++ b/project/functions.js @@ -336,6 +336,18 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 怪物数据的动态修改迁移到了“脚本编辑 - updateEnemys”中,详见文档说明 core.enemys.updateEnemys(); +}, + "canUseQuickShop": function(shopId) { + // 当前能否使用某个快捷商店 + // shopId:快捷商店ID + // 如果返回一个字符串,表示不能,字符串为不能使用的提示 + // 返回null代表可以使用 + + // 检查当前楼层的canUseQuickShop选项是否为false + if (core.isset(core.floors[core.status.floorId].canUseQuickShop) && !core.floors[core.status.floorId].canUseQuickShop) + return '当前楼层不能使用快捷商店。'; + + return null; } }, "enemys": { diff --git a/更新说明.txt b/更新说明.txt index eeda8b50..d5daaf2b 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,9 +1,9 @@ HTML5魔塔样板V2.4.3 增加光环属性 -怪物属性获取移动到脚本编辑中 -楼层传送代码移动到脚本编辑中 -地图数据统计移动到脚本编辑中 +将部分代码移动到脚本编辑中 +(怪物属性获取、楼层传送、数据统计等) +事件改变天气或画面色调,读档后仍有效 Autotile注册优化 状态栏可以显示角色名字 双击道具栏图标直接进入装备栏 From 76a84c5f8fc67680fdf1eceae8ec377f516069f5 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 11 Oct 2018 23:48:54 +0800 Subject: [PATCH 6/6] setFg & setWeather --- libs/control.js | 6 ++---- libs/events.js | 50 +++++++++++++++++++++++++------------------- project/functions.js | 2 +- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/libs/control.js b/libs/control.js index 505ab2d4..69ce1ce8 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1514,7 +1514,7 @@ control.prototype.updateDamage = function () { // 判断显伤 var event = core.floors[core.status.floorId].events[x+","+y]; if (core.isset(event) && !(event instanceof Array)) { - if (core.isset(event.displayDamage) && !event.displayDamage) + if (event.displayDamage === false) continue; } } @@ -2441,9 +2441,7 @@ control.prototype.getStatus = function (statusName) { ////// 获得某个等级的名称 ////// control.prototype.getLvName = function () { - if (!core.isset(core.firstData.levelUp) || core.status.hero.lv<=0 - || core.status.hero.lv>core.firstData.levelUp.length) return core.status.hero.lv; - return core.firstData.levelUp[core.status.hero.lv-1].name || core.status.hero.lv; + return ((core.firstData.levelUp||[])[core.status.hero.lv-1]||{}).name || core.status.hero.lv; } ////// 设置某个自定义变量或flag ////// diff --git a/libs/events.js b/libs/events.js index 23786921..5ea87222 100644 --- a/libs/events.js +++ b/libs/events.js @@ -657,16 +657,21 @@ events.prototype.doAction = function() { case "setFg": // 颜色渐变 if (data.async) { core.setFg(data.color, data.time); + core.setFlag('color', data.color||null); this.doAction(); } else { core.setFg(data.color, data.time, function() { + core.setFlag('color', data.color||null); core.events.doAction(); }); } break; case "setWeather": // 更改天气 core.setWeather(data.name, data.level); + if (core.isset(data.name)) + core.setFlag('weather', [data.name, data.level]); + else core.setFlag('weather', null); this.doAction(); break; case "openDoor": // 开一个门,包括暗墙 @@ -1272,29 +1277,32 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback } // 不存在事件时,更改画面色调 - if (core.status.event.id == null) { - // 默认画面色调 - if (core.isset(core.floors[floorId].color)) { - var color = core.floors[floorId].color; - - // 直接变色 - core.clearMap('curtain'); - if (core.isset(color[3])) - core.setAlpha('curtain', color[3]); - else - core.setAlpha('curtain', 1); - core.fillRect('curtain', 0, 0, 416, 416, core.arrayToRGB(color)); - core.status.curtainColor = color; - } - else { - core.clearMap('curtain'); - core.setAlpha('curtain', 0); - } + var color = core.getFlag('color', null); + if (!core.isset(color) && core.isset(core.floors[floorId].color)) { + color = core.floors[floorId].color; + } + if (core.isset(color)) { + // 直接变色 + core.clearMap('curtain'); + if (core.isset(color[3])) + core.setAlpha('curtain', color[3]); + else + core.setAlpha('curtain', 1); + core.fillRect('curtain', 0, 0, 416, 416, core.arrayToRGB(color)); + core.status.curtainColor = color; + } + else { + core.clearMap('curtain'); + core.setAlpha('curtain', 0); } // 更改天气 - if (core.isset(core.floors[floorId].weather)) { - core.setWeather(core.floors[floorId].weather[0], core.floors[floorId].weather[1]) + var weather = core.getFlag('weather', null); + if (!core.isset(weather) && core.isset(core.floors[floorId].weather)) { + weather = core.floors[floorId].weather; + } + if (core.isset(weather)) { + core.setWeather(weather[0], weather[1]) } else core.setWeather(); @@ -1582,7 +1590,7 @@ events.prototype.checkLvUp = function () { if (!core.flags.enableLevelUp || !core.isset(core.firstData.levelUp) || core.status.hero.lv>=core.firstData.levelUp.length) return; // 计算下一个所需要的数值 - var need=core.firstData.levelUp[core.status.hero.lv].need; + var need=(core.firstData.levelUp[core.status.hero.lv]||{}).need; if (!core.isset(need)) return; if (core.status.hero.experience>=need) { // 升级 diff --git a/project/functions.js b/project/functions.js index d34b5b6c..fc0ea1af 100644 --- a/project/functions.js +++ b/project/functions.js @@ -344,7 +344,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 返回null代表可以使用 // 检查当前楼层的canUseQuickShop选项是否为false - if (core.isset(core.floors[core.status.floorId].canUseQuickShop) && !core.floors[core.status.floorId].canUseQuickShop) + if (core.floors[core.status.floorId].canUseQuickShop === false) return '当前楼层不能使用快捷商店。'; return null;