diff --git a/_server/data.comment.js b/_server/data.comment.js index fc527ef8..ba4af04e 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -555,13 +555,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": true, "_type": "checkbox", "_bool": "bool", - "_data": "是否循环计算临界;如果此项为true则使用循环法(而不是回合数计算法)来算临界" - }, - "loopStep": { - "_leaf": true, - "_type": "textbox", - "_range": "thiseval==null || thiseval>0", - "_data": "循环计算临界时,每次攻击增加量为原始攻击的多少分之一。\n例如,5000就代表循环中每次攻击增加量是原始攻击的1/5000(向上取整)。\n默认值5000。" + "_data": "是否循环计算临界;如果此项为true则使用循环法(而不是回合数计算法)来算临界\n从V2.5.3开始,对于大数据的循环法将改为使用二分法进行计算" }, "startUsingCanvas": { "_leaf": true, diff --git a/libs/enemys.js b/libs/enemys.js index cc3ca193..e7e26535 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -210,16 +210,45 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { } } else { // 暴力for循环法 + + // V2.5.3以后,大数据改为二分法进行计算 + var LOOP_MAX_VALUE = 1; pre = info.damage; - var per_add = Math.ceil(hero_atk / (core.flags.loopStep||5000)); - if (per_add<0) per_add = 1; - for (var atk=hero_atk+per_add;atk<=mon_hp+mon_def;atk+=per_add) { - 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; - list.push([atk-hero_atk, Math.floor(info.damage-nextInfo.damage)]); - if (nextInfo.damage<=0 && !core.flags.enableNegativeDamage) break; + if (hero_atk <= LOOP_MAX_VALUE) { // 循环法 + 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, x, y, floorId); + if (nextInfo==null) break; + if (pre>nextInfo.damage) { + pre = nextInfo.damage; + list.push([atk-hero_atk, info.damage-nextInfo.damage]); + if (nextInfo.damage<=0 && !core.flags.enableNegativeDamage) break; + if (list.length>=number) break; + } + } + } + else { // 二分法算临界 + var calNext = function (currAtk, maxAtk) { + var start = Math.floor(currAtk), end = Math.floor(maxAtk); + if (start>end) return null; + + while (startnextInfo.damage) end = mid; + else start = mid+1; + } + var nextInfo = core.enemys.getDamageInfo(enemy, core.status.hero.hp, start, core.status.hero.def, core.status.hero.mdef, x, y, floorId); + return nextInfo==null||nextInfo.damage>=pre?null:[start,nextInfo.damage]; + } + var currAtk = hero_atk; + while (true) { + var next = calNext(currAtk+1, mon_hp+mon_def, pre); + if (next == null) break; + currAtk = next[0]; + pre = next[1]; + list.push([currAtk-hero_atk, info.damage-pre]); + if (pre<=0 && !core.flags.enableNegativeDamage) break; if (list.length>=number) break; } } diff --git a/project/data.js b/project/data.js index 080a41f7..969c0da9 100644 --- a/project/data.js +++ b/project/data.js @@ -382,7 +382,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "hatredDecrease": true, "betweenAttackCeil": false, "useLoop": false, - "loopStep": 5000, "startUsingCanvas": false, "startDirectly": false, "statusCanvas": false, diff --git a/project/functions.js b/project/functions.js index 13f525d0..373900ea 100644 --- a/project/functions.js +++ b/project/functions.js @@ -632,14 +632,14 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = damage=Math.max(0, damage); return { - "mon_hp": mon_hp, - "mon_atk": mon_atk, - "mon_def": mon_def, - "init_damage": init_damage, - "per_damage": per_damage, - "hero_per_damage": hero_per_damage, - "turn": turn, - "damage": damage + "mon_hp": Math.floor(mon_hp), + "mon_atk": Math.floor(mon_atk), + "mon_def": Math.floor(mon_def), + "init_damage": Math.floor(init_damage), + "per_damage": Math.floor(per_damage), + "hero_per_damage": Math.floor(hero_per_damage), + "turn": Math.floor(turn), + "damage": Math.floor(damage) }; }, "updateEnemys": function () {