diff --git a/libs/enemys.js b/libs/enemys.js index 722e6287..5ab31a09 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -228,13 +228,12 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { if (specialCriticals != null) return specialCriticals; var info = this.getDamageInfo(enemy, null, x, y, floorId); if (info == null) { // 如果未破防... - var enemyInfo = this.getEnemyInfo(enemy, null, x, y, floorId); - if (enemyInfo.def == null || enemyInfo.def < core.status.hero.atk) return []; - // 再次尝试获得破防后伤害 - info = this.getDamageInfo(enemy, {atk: enemyInfo.def + 1}, x, y, floorId); - if (info == null || info.mon_def != enemyInfo.def) return []; + var overAtk = this._nextCriticals_overAtk(enemy, x, y, floorId); + if (overAtk == null) return []; + if (typeof overAtk[1] == 'number') return [[overAtk[0], -overAtk[1]]]; + info = overAtk[1]; info.__over__ = true; - info.__overAtk__ = info.mon_def + 1 - core.status.hero.atk; + info.__overAtk__ = overAtk[0]; } if (typeof info == 'number') return [[0,0]]; @@ -255,6 +254,26 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { } } +/// 未破防临界采用二分计算 +enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) { + var calNext = function (currAtk, maxAtk) { + var start = currAtk, end = maxAtk; + if (start > end) return null; + + while (start < end) { + var mid = Math.floor((start + end) / 2); + if (mid - start > end - mid) mid--; + var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": mid}, x, y, floorId); + if (nextInfo != null) end = mid; + else start = mid + 1; + } + var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": start}, x, y, floorId); + return nextInfo == null ? null : [start - core.status.hero.atk, nextInfo]; + } + return calNext(core.status.hero.atk + 1, + core.getEnemyValue(enemy, 'hp', x, y, floorId) + core.getEnemyValue(enemy, 'def', x, y, floorId)); +} + enemys.prototype._nextCriticals_special = function (enemy, number, x, y, floorId) { if (this.hasSpecial(enemy.special, 10) || this.hasSpecial(enemy.special, 3)) return []; // 模仿or坚固临界 @@ -266,15 +285,15 @@ enemys.prototype._nextCriticals_useLoop = function (enemy, info, number, x, y, f var list = []; var start_atk = hero_atk; if (info.__over__) { - start_atk = mon_def + 1; + start_atk += info.__overAtk__; list.push([info.__overAtk__, -info.damage]); } for (var atk = start_atk + 1; atk <= mon_hp + mon_def; atk++) { - var nextInfo = this.getDamageInfo(enemy, {"atk": Math.ceil(atk / core.getBuff('atk'))}, x, y, floorId); + var nextInfo = this.getDamageInfo(enemy, {"atk": atk}, x, y, floorId); if (nextInfo == null || (typeof nextInfo == 'number')) break; if (pre > nextInfo.damage) { pre = nextInfo.damage; - list.push([Math.ceil(atk / core.getBuff('atk')) - hero_atk, info.damage - nextInfo.damage]); + list.push([atk - hero_atk, info.damage - nextInfo.damage]); if (nextInfo.damage <= 0 && !core.flags.enableNegativeDamage) break; if (list.length >= number) break; } @@ -288,7 +307,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number, var list = []; var start_atk = hero_atk; if (info.__over__) { - start_atk = mon_def + 1; + start_atk += info.__overAtk__; list.push([info.__overAtk__, -info.damage]); } var calNext = function (currAtk, maxAtk) { @@ -298,12 +317,12 @@ enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number, while (start < end) { var mid = Math.floor((start + end) / 2); if (mid - start > end - mid) mid--; - var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": Math.ceil(mid / core.getBuff('atk'))}, x, y, floorId); + var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": mid}, x, y, floorId); if (nextInfo == null || (typeof nextInfo == 'number')) return null; if (pre > nextInfo.damage) end = mid; else start = mid + 1; } - var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": Math.ceil(start / core.getBuff('atk'))}, x, y, floorId); + var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": start}, x, y, floorId); return nextInfo == null || (typeof nextInfo == 'number') || nextInfo.damage >= pre ? null : [start, nextInfo.damage]; } var currAtk = start_atk; @@ -312,7 +331,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number, if (next == null) break; currAtk = next[0]; pre = next[1]; - list.push([Math.ceil(currAtk / core.getBuff('atk')) - hero_atk, info.damage - pre]); + list.push([currAtk - hero_atk, info.damage - pre]); if (pre <= 0 && !core.flags.enableNegativeDamage) break; if (list.length >= number) break; } @@ -330,7 +349,7 @@ enemys.prototype._nextCriticals_useTurn = function (enemy, info, number, x, y, f var list = [], pre = null; var start_atk = hero_atk; if (info.__over__) { - start_atk = mon_def + 1; + start_atk += info.__overAtk__; list.push([info.__overAtk__, -info.damage]); } for (var t = turn - 1; t >= 1; t--) { diff --git a/libs/maps.js b/libs/maps.js index eaa0ddc8..e292dec2 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -1696,8 +1696,10 @@ maps.prototype._makeAutotileEdges = function () { }); for (var n in first) { + n = parseInt(n); core.material.autotileEdges[n] = [n]; for (var n2 in second) { + n2 = parseInt(n2); if (n == n2) continue; if (first[n] == second[n2]) { core.material.autotileEdges[n].push(n2); diff --git a/libs/ui.js b/libs/ui.js index 279a580f..403fbc14 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2482,14 +2482,6 @@ ui.prototype._drawBookDetail_turnAndCriticals = function (enemy, floorId, texts) }); while (criticals[0]=='0:0') criticals.shift(); texts.push("\r[#FF6A6A]\\d临界表:\\d\r[]"+JSON.stringify(criticals)); - var prevInfo = core.getDamageInfo(enemy.id, {atk: core.status.hero.atk-1}, null, null, floorId); - if (prevInfo != null && damageInfo != null) { - if (damageInfo.damage != null) damageInfo = damageInfo.damage; - if (prevInfo.damage != null) prevInfo = prevInfo.damage; - if (prevInfo > damageInfo) { - texts.push("(当前攻击力正位于临界点上)") - } - } } ui.prototype._drawBookDetail_drawContent = function (enemy, content, pos) {