diff --git a/public/libs/control.js b/public/libs/control.js index aaf6793..d139dd1 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -1030,7 +1030,10 @@ control.prototype.tryMoveDirectly = function (destX, destY) { if (dir && !core.inArray(canMoveArray[dx][dy], dir)) continue; if (canMoveDirectlyArray[i] < 0) continue; if (core.control.moveDirectly(dx, dy, canMoveDirectlyArray[i])) { - if (dir) core.moveHero(dir, function () {}); + if (dir) { + console.log(dir); + core.moveHero(dir, function () {}); + } return true; } } @@ -4288,19 +4291,12 @@ control.prototype._resize_canvas = function (obj) { // resize bigmap core.bigmap.canvas.forEach(function (cn) { var ratio = core.canvas[cn].canvas.hasAttribute('isHD') - ? core.domStyle.ratio + ? core.domStyle.scale * devicePixelRatio : 1; core.canvas[cn].canvas.style.width = - (core.canvas[cn].canvas.width / - devicePixelRatio / - core.domStyle.ratio) * - core.domStyle.scale + - 'px'; + (core.canvas[cn].canvas.width / ratio) * core.domStyle.scale + 'px'; core.canvas[cn].canvas.style.height = - (core.canvas[cn].canvas.height / - devicePixelRatio / - core.domStyle.ratio) * - core.domStyle.scale + + (core.canvas[cn].canvas.height / ratio) * core.domStyle.scale + 'px'; }); // resize dynamic canvas diff --git a/public/libs/core.js b/public/libs/core.js index b88388c..6713c0a 100644 --- a/public/libs/core.js +++ b/public/libs/core.js @@ -108,7 +108,8 @@ function core() { availableScale: [], isVertical: false, showStatusBar: true, - toolbarBtn: false + toolbarBtn: false, + hdCanvas: ['damage', 'ui', 'data'] }; this.bigmap = { canvas: ['bg', 'event', 'event2', 'fg', 'damage'], @@ -294,11 +295,16 @@ core.prototype.init = function (coreData, callback) { var b = main.mode == 'editor'; // 初始化画布 for (var name in core.canvas) { - core.maps._setHDCanvasSize( - core.canvas[name], - b ? core.__PIXELS__ : core._PX_, - b ? core.__PIXELS__ : core._PY_ - ); + if (core.domStyle.hdCanvas.includes(name)) + core.maps._setHDCanvasSize( + core.canvas[name], + b ? core.__PIXELS__ : core._PX_, + b ? core.__PIXELS__ : core._PY_ + ); + else { + core.canvas[name].canvas.width = b ? core.__PIXELS__ : core._PX_; + core.canvas[name].canvas.height = b ? core.__PIXELS__ : core._PY_; + } } core.loader._load(function () { diff --git a/public/libs/enemys.js b/public/libs/enemys.js index 24737c9..5f543ef 100644 --- a/public/libs/enemys.js +++ b/public/libs/enemys.js @@ -208,9 +208,9 @@ enemys.prototype.canBattle = function (enemy, x, y, floorId) { return damage != null && damage < core.status.hero.hp; }; -enemys.prototype.getDamageString = function (enemy, x, y, floorId) { +enemys.prototype.getDamageString = function (enemy, x, y, floorId, hero) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - var damage = this.getDamage(enemy, x, y, floorId); + var damage = this.getDamage(enemy, x, y, floorId, hero); var color = '#000000'; @@ -234,7 +234,7 @@ enemys.prototype.getDamageString = function (enemy, x, y, floorId) { }; ////// 接下来N个临界值和临界减伤计算 ////// -enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { +enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId, hero) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; number = number || 1; @@ -246,7 +246,7 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { floorId ); if (specialCriticals != null) return specialCriticals; - var info = this.getDamageInfo(enemy, null, x, y, floorId); + var info = this.getDamageInfo(enemy, hero, x, y, floorId); if (info == null) { // 如果未破防... var overAtk = this._nextCriticals_overAtk(enemy, x, y, floorId); @@ -268,12 +268,19 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { number, x, y, - floorId + floorId, + hero ); }; /// 未破防临界采用二分计算 -enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) { +enemys.prototype._nextCriticals_overAtk = function ( + enemy, + x, + y, + floorId, + hero +) { var calNext = function (currAtk, maxAtk) { var start = currAtk, end = maxAtk; @@ -284,7 +291,7 @@ enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) { if (mid - start > end - mid) mid--; var nextInfo = core.enemys.getDamageInfo( enemy, - { atk: mid }, + { atk: mid, x: hero?.x, y: hero?.y }, x, y, floorId @@ -294,17 +301,17 @@ enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) { } var nextInfo = core.enemys.getDamageInfo( enemy, - { atk: start }, + { atk: start, x: hero?.x, y: hero?.y }, x, y, floorId ); return nextInfo == null ? null - : [start - core.getStatus('atk'), nextInfo]; + : [start - core.getStatusOrDefault(hero, 'atk'), nextInfo]; }; return calNext( - core.getStatus('atk') + 1, + core.getStatusOrDefault(hero, 'atk') + 1, core.getEnemyValue(enemy, 'hp', x, y, floorId) + core.getEnemyValue(enemy, 'def', x, y, floorId) ); @@ -322,48 +329,17 @@ enemys.prototype._nextCriticals_special = function ( return null; }; -enemys.prototype._nextCriticals_useLoop = function ( - enemy, - info, - number, - x, - y, - floorId -) { - var mon_hp = info.mon_hp, - hero_atk = core.getStatus('atk'), - mon_def = info.mon_def, - pre = info.damage; - var list = []; - var start_atk = hero_atk; - if (info.__over__) { - 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: atk }, x, y, floorId); - if (nextInfo == null || typeof nextInfo == 'number') 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; - } - } - if (list.length == 0) list.push([0, 0]); - return list; -}; - enemys.prototype._nextCriticals_useBinarySearch = function ( enemy, info, number, x, y, - floorId + floorId, + hero ) { var mon_hp = info.mon_hp, - hero_atk = core.getStatus('atk'), + hero_atk = core.getStatusOrDefault(hero, 'atk'), mon_def = info.mon_def, pre = info.damage; var list = []; @@ -382,7 +358,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function ( if (mid - start > end - mid) mid--; var nextInfo = core.enemys.getDamageInfo( enemy, - { atk: mid }, + { atk: mid, x: hero?.x, y: hero?.y }, x, y, floorId @@ -393,7 +369,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function ( } var nextInfo = core.enemys.getDamageInfo( enemy, - { atk: start }, + { atk: start, x: hero?.x, y: hero?.y }, x, y, floorId @@ -418,73 +394,14 @@ enemys.prototype._nextCriticals_useBinarySearch = function ( return list; }; -enemys.prototype._nextCriticals_useTurn = function ( - enemy, - info, - number, - x, - y, - floorId -) { - var mon_hp = info.mon_hp, - hero_atk = core.getStatus('atk'), - mon_def = info.mon_def, - turn = info.turn; - // ------ 超大回合数强制使用二分算临界 - // 以避免1攻10e回合,2攻5e回合导致下述循环卡死问题 - if (turn >= 1e6) { - // 100w回合以上强制二分计算临界 - return this._nextCriticals_useBinarySearch( - enemy, - info, - number, - x, - y, - floorId - ); - } - var list = [], - pre = null; - var start_atk = hero_atk; - if (info.__over__) { - start_atk += info.__overAtk__; - list.push([info.__overAtk__, -info.damage]); - } - for (var t = turn - 1; t >= 1; t--) { - var nextAtk = Math.ceil(mon_hp / t) + mon_def; - // 装备提升比例的计算临界 - nextAtk = Math.ceil(nextAtk / core.getBuff('atk')); - if (nextAtk <= start_atk) break; - if (nextAtk != pre) { - var nextInfo = this.getDamageInfo( - enemy, - { atk: nextAtk }, - x, - y, - floorId - ); - if (nextInfo == null || typeof nextInfo == 'number') break; - list.push([ - nextAtk - hero_atk, - Math.floor(info.damage - nextInfo.damage) - ]); - if (nextInfo.damage <= 0 && !core.flags.enableNegativeDamage) break; - pre = nextAtk; - } - if (list.length >= number) break; - } - if (list.length == 0) list.push([0, 0]); - return list; -}; - ////// N防减伤计算 ////// -enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) { +enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId, hero) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; k = k || 1; - var nowDamage = this._getDamage(enemy, null, x, y, floorId); + var nowDamage = this._getDamage(enemy, hero, x, y, floorId); var nextDamage = this._getDamage( enemy, - { def: core.getStatus('def') + k }, + Object.assign({}, hero ?? {}, { def: core.getStatus('def') + k }), x, y, floorId @@ -508,8 +425,8 @@ enemys.prototype.getDamageInfo = function (enemy, hero, x, y, floorId) { }; ////// 获得在某个勇士属性下怪物伤害 ////// -enemys.prototype.getDamage = function (enemy, x, y, floorId) { - return this._getDamage(enemy, null, x, y, floorId); +enemys.prototype.getDamage = function (enemy, x, y, floorId, hero) { + return this._getDamage(enemy, hero, x, y, floorId); }; enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) { @@ -517,7 +434,6 @@ enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; if (enemy == null) return null; - if (x === 9 && y === 3) debugger; var info = this.getDamageInfo(enemy, hero, x, y, floorId); if (info == null) return null; if (typeof info == 'number') return info; diff --git a/public/libs/maps.js b/public/libs/maps.js index d51f369..6e1e8a8 100644 --- a/public/libs/maps.js +++ b/public/libs/maps.js @@ -634,7 +634,12 @@ maps.prototype.resizeMap = function (floorId) { var height = core.bigmap.v2 ? core._PY_ + 64 : core.bigmap.height * 32; core.bigmap.canvas.forEach(function (cn) { - core.maps._setHDCanvasSize(core.canvas[cn], width, height); + if (core.domStyle.hdCanvas.includes(cn)) + core.maps._setHDCanvasSize(core.canvas[cn], width, height); + else { + core.canvas[cn].canvas.width = width; + core.canvas[cn].canvas.height = height; + } core.canvas[cn].canvas.style.width = width * core.domStyle.scale + 'px'; core.canvas[cn].canvas.style.height = @@ -2581,7 +2586,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function ( tempCanvas.canvas.height = height * 32; tempCanvas.canvas.removeAttribute('isHD'); } else { - core.resizeCanvas(tempCanvas, width * 32, height * 32, false, true); + core.maps._setHDCanvasSize(tempCanvas, width * 32, height * 32); } } else if (width * height > core.bigmap.threshold) { options.v2 = true; @@ -2589,7 +2594,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function ( tempCanvas.canvas.width = core._PX_; tempCanvas.canvas.height = core._PY_; tempCanvas.canvas.removeAttribute('isHD'); - } else core.resizeCanvas(tempCanvas, core._PX_, core._PY_); + } else core.maps._setHDCanvasSize(tempCanvas, width * 32, height * 32); var centerX = options.centerX, centerY = options.centerY; if (centerX == null) centerX = Math.floor(width / 2); @@ -2611,8 +2616,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function ( tempCanvas.canvas.width = width * 32; tempCanvas.canvas.height = height * 32; tempCanvas.canvas.removeAttribute('isHD'); - } else - core.resizeCanvas(tempCanvas, width * 32, height * 32, false, true); + } else core.maps._setHDCanvasSize(tempCanvas, width * 32, height * 32); } options.ctx = tempCanvas; @@ -2695,6 +2699,10 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { if (centerY == null) centerY = Math.floor(height / 2); var tempCanvas = core.bigmap.tempCanvas; + if (!core.getLocalStorage('antiAliasing')) { + ctx.imageSmoothingEnabled = false; + } + if (options.inFlyMap) { ctx.drawImage( tempCanvas.canvas, @@ -2707,6 +2715,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { options.w, options.h ); + ctx.imageSmoothingEnabled = true; return; } @@ -2752,6 +2761,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { realHeight ); } + ctx.imageSmoothingEnabled = true; } else { // 只绘制可见窗口 var pw = core._PX_, @@ -2793,6 +2803,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { h ); } + ctx.imageSmoothingEnabled = true; } else { var offsetX = core.clamp(centerX - hw, 0, width - W), offsetY = core.clamp(centerY - hh, 0, height - H); @@ -2809,6 +2820,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { w, h ); + ctx.imageSmoothingEnabled = true; return; } core.drawImage( @@ -2823,6 +2835,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { w, h ); + ctx.imageSmoothingEnabled = true; } } }; diff --git a/public/libs/ui.js b/public/libs/ui.js index 3c071a4..4f3b72a 100644 --- a/public/libs/ui.js +++ b/public/libs/ui.js @@ -4203,12 +4203,12 @@ ui.prototype.resizeCanvas = function ( var ctx = core.getContextByName(name); if (!ctx) return null; if (width != null) { - if (!styleOnly) + if (!styleOnly && ctx.canvas.hasAttribute('isHD')) core.maps._setHDCanvasSize(ctx, width, null, isTempCanvas); ctx.canvas.style.width = width * core.domStyle.scale + 'px'; } if (height != null) { - if (!styleOnly) + if (!styleOnly && ctx.canvas.hasAttribute('isHD')) core.maps._setHDCanvasSize(ctx, null, height, isTempCanvas); ctx.canvas.style.height = height * core.domStyle.scale + 'px'; } diff --git a/public/main.js b/public/main.js index f46cc84..dc54216 100644 --- a/public/main.js +++ b/public/main.js @@ -220,6 +220,15 @@ function main() { } main.prototype.init = function (mode, callback) { + try { + var a = {}; + var b = {}; + new Proxy(a, b); + } catch (e) { + alert('浏览器版本过低,无法游玩本塔!'); + return; + } + for (var i = 0; i < main.dom.gameCanvas.length; i++) { main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d'); diff --git a/public/project/floors/MT35.js b/public/project/floors/MT35.js index 5c675a3..e1423af 100644 --- a/public/project/floors/MT35.js +++ b/public/project/floors/MT35.js @@ -34,7 +34,7 @@ main.floors.MT35= "你来这干什么", { "type": "if", - "condition": "core.getBlock(10,1)", + "condition": "(core.getBlockId(10,1)!=='none')", "true": [ "把怪踢到这了,想打?", "没门!", @@ -60,7 +60,7 @@ main.floors.MT35= "你来这干什么", { "type": "if", - "condition": "core.getBlock(4,1)", + "condition": "(core.getBlockId(4,1)!=='none')", "true": [ "把怪踢到这了,想打?", "没门!", @@ -82,7 +82,7 @@ main.floors.MT35= "7,0": [ { "type": "if", - "condition": "flag:inWinter2===true", + "condition": "(flag:inWinter2===true)", "true": [ { "type": "changeFloor", diff --git a/public/project/floors/MT36.js b/public/project/floors/MT36.js index 7476eaf..3a42368 100644 --- a/public/project/floors/MT36.js +++ b/public/project/floors/MT36.js @@ -1,37 +1,85 @@ main.floors.MT36= { -"floorId": "MT36", -"title": "冰封雪原", -"name": "冰封雪原", -"width": 15, -"height": 15, -"canFlyTo": true, -"canFlyFrom": true, -"canUseQuickShop": true, -"cannotViewMap": false, -"images": [], -"ratio": 8, -"defaultGround": "T580", -"bgm": "winter.mp3", -"firstArrive": [], -"eachArrive": [], -"parallelDo": "", -"events": {}, -"changeFloor": {}, -"beforeBattle": {}, -"afterBattle": {}, -"afterGetItem": {}, -"afterOpenDoor": {}, -"autoEvent": {}, -"cannotMove": {}, -"cannotMoveIn": {}, -"map": [ + "floorId": "MT36", + "title": "冰封雪原", + "name": "冰封雪原", + "width": 15, + "height": 15, + "canFlyTo": true, + "canFlyFrom": true, + "canUseQuickShop": true, + "cannotViewMap": false, + "images": [], + "ratio": 8, + "defaultGround": "T580", + "bgm": "winter.mp3", + "firstArrive": [], + "eachArrive": [], + "parallelDo": "", + "events": { + "7,14": [ + { + "type": "changeFloor", + "floorId": "MT35", + "loc": [ + 7, + 0 + ] + } + ], + "6,14": [ + "在本地图的右方,会看到一个棕色的线,这是由于抗锯齿出现的像素错误。这里关闭抗锯齿即可解决(默认是关闭的)。" + ] + }, + "changeFloor": {}, + "beforeBattle": {}, + "afterBattle": {}, + "afterGetItem": {}, + "afterOpenDoor": {}, + "autoEvent": {}, + "cannotMove": {}, + "cannotMoveIn": {}, + "map": [ + [ 0, 0, 0,604,604,604,604,604,604, 91,604, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,604, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70176,70177,70177,70177,70177], + [604, 0, 0, 0, 0, 0, 0, 0, 0, 0,70184,70185,70185,70185, 94], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70208,70209,70209,70209,70209], + [604, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [587, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [587, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [584,584,584,584,584,584,584,584,584,584,584, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [70056, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [585,585,585,585,585,585,129, 0,585,585,585,585,585,585,585] +], + "bgmap": [ + [70073,70073,70073,70056, 0, 0, 0, 0, 0, 0,70058,70086,70086,70086,70086], + [70073,70073,70073,70056, 0, 0, 0, 0, 0, 0,70058,70094,70094,70094,70094], + [70081,70081,70081,70056, 0, 0, 0, 0, 0, 0,70058,70102,70102,70102,70102], + [ 0, 0, 0,70056, 0, 0, 0, 0, 0, 0, 0,70110,70110,70110,70110], + [ 0, 0, 0,70056, 0, 0, 0, 0, 0, 0,70058,70118,70118,70118,70118], + [ 0, 0, 0,70056, 0, 0, 0, 0, 0, 0,70058,70067,70067,70067,70067], + [70049,70049,70049,70051, 0, 0, 0, 0, 0, 0,70058,70067,70067,70067,70067], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70052,70067,70067,70067,70067], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70058], + [70065,70065,70065,70065,70065,70065,70065,70065,70065,70065,70065,70059, 0, 0,70058], + [70070,70070,70070,70070,70070,70070,70070,70070,70070,70070,70070,70056, 0, 0,70058], + [70081,70081,70081,70081,70081,70081,70081,70081,70081,70081,70081,70056, 0, 0,70058], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70051, 0, 0,70058], + [70056, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70058], + [70056, 0, 0, 0, 0, 0, 0, 93, 0, 0, 0, 0, 0, 0,70058] +], + "fgmap": [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70200,70201,70201,70201,70201], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], @@ -42,4 +90,24 @@ main.floors.MT36= [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ], + "bg2map": [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70184,70185,70185,70185,70185], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70192,70193,70193,70193,70193], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70049,70049,70049,70050], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [70048,70049,70049,70049,70049,70049,70049,70049,70049,70049,70049, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] +], + "fg2map": [ + +] } \ No newline at end of file diff --git a/public/project/functions.js b/public/project/functions.js index 3f07167..91004e5 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -336,8 +336,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { var equipId = core.getEquip(0); if (equipId && (core.material.items[equipId].equip || {}).animate) animate = core.material.items[equipId].equip.animate; - // 你也可以在这里根据自己的需要,比如enemyId或special或flag来修改播放的动画效果 - // if (enemyId == '...') animate = '...'; // 检查该动画是否存在SE,如果不存在则使用默认音效 if (!(core.material.animates[animate] || {}).se) @@ -348,11 +346,16 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { else core.drawHeroAnimate(animate); // 获得战斗伤害信息 - var damageInfo = core.getDamageInfo(enemyId, null, x, y) || {}; + // 注意这里勇士坐标要传入当前勇士坐标,不然会默认取伤害最低的地方打怪 + const damageInfo = + core.getDamageInfo( + enemyId, + { x: core.status.hero.loc.x, y: core.status.hero.loc.y }, + x, + y + ) ?? {}; // 战斗伤害 - var damage = damageInfo.damage; - // 当前战斗回合数,可用于战后所需的判定 - var turn = damageInfo.turn; + const damage = damageInfo.damage; // 判定是否致死 if (damage == null || damage >= core.status.hero.hp) { core.status.hero.hp = 0; @@ -367,7 +370,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { core.status.hero.statistics.battle++; // 智慧之源 - if (core.hasSpecial(special, 14) && flags.hard == 2) { + if (core.hasSpecial(special, 14) && flags.hard === 2) { core.addFlag( 'inte_' + floorId, Math.ceil((core.status.hero.mdef / 10) * 0.3) * 10 @@ -390,32 +393,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { core.declineStudiedSkill(); } - // 计算当前怪物的支援怪物 - var guards = []; - if (x != null && y != null) { - guards = core.getFlag('__guards__' + x + '_' + y, []); - core.removeFlag('__guards__' + x + '_' + y); - } - // 获得金币 - var money = guards.reduce(function (curr, g) { - return curr + core.material.enemys[g[2]].money; - }, enemy.money); + const money = enemy.money; core.status.hero.money += money; core.status.hero.statistics.money += money; // 获得经验 - var exp = guards.reduce(function (curr, g) { - return curr + core.material.enemys[g[2]].exp; - }, enemy.exp); + const exp = enemy.exp; core.status.hero.exp += exp; core.status.hero.statistics.exp += exp; - var hint = '打败 ' + enemy.name; - if (core.flags.statusBarItems.indexOf('enableMoney') >= 0) - hint += ',金币+' + money; - if (core.flags.statusBarItems.indexOf('enableExp') >= 0) - hint += ',经验+' + exp; + const hint = + '打败 ' + enemy.name + ',金币+' + money + ',经验+' + exp; core.drawTip(hint, enemy.id); if (core.getFlag('bladeOn') && core.getFlag('blade')) { @@ -940,6 +929,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { x !== void 0 && y !== null && y !== void 0 && + (hero?.x === null || hero?.x === void 0) && + (hero?.y === null || hero?.y === void 0) && floorId !== null && floorId !== void 0 && flags.autoLocate && @@ -950,7 +941,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { for (const [dir, { x: dx, y: dy }] of Object.entries( core.utils.scan )) { - // 只有攻击和防御和特殊光环需要注意,其他的一般都不会随楼层与坐标变化 + // 只有攻击和防御和特殊光环需要注意,其他的都不会随楼层与坐标变化 const nx = x + dx; const ny = y + dy; if ( @@ -971,8 +962,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { const status = core.getHeroStatusOf( hero, toGet, - x, - y, + nx, + ny, floorId ); if ( @@ -982,20 +973,28 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { ) { continue; } - toMap.push([dir, Object.assign({}, status, { x, y })]); + toMap.push([ + dir, + Object.assign({}, status, { x: nx, y: ny }) + ]); } } else { - toMap = [['none', core.getHeroStatusOf(hero, ['atk', 'def'])]]; + // 指定了勇士坐标或者没有怪物坐标时 + toMap = [ + [ + 'none', + core.getHeroStatusOf( + hero, + ['atk', 'def'], + hero?.x, + hero?.y + ) + ] + ]; } function getDamage(h) { - const enemyInfo = core.enemys.getEnemyInfo( - enemy, - hero, - x, - y, - floorId - ); + const enemyInfo = core.getEnemyInfo(enemy, hero, x, y, floorId); let { hp: mon_hp, @@ -1033,12 +1032,15 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { // 每回合怪物对勇士造成的战斗伤害 var per_damage = mon_atk - hero_def; + // 魔攻:战斗伤害就是怪物攻击力 if ( core.hasSpecial(mon_special, 2) || core.hasSpecial(mon_special, 13) - ) + ) { per_damage = mon_atk; + } + // 战斗伤害不能为负值 if (per_damage < 0) per_damage = 0; @@ -1121,20 +1123,21 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { ]; function autoSkillOf(h) { + damageInfo = getDamage(h); + damage = damageInfo?.damage ?? Infinity; if (flags.autoSkill) { for (const [unlock, condition] of skills) { - if (flags[unlock]) { - flags[condition] = true; - const info = getDamage(h); - const d = info?.damage; - if (d !== null && d !== void 0) { - if (d < damage) { - damage = d; - damageInfo = info; - } + if (!flags[unlock]) continue; + flags[condition] = true; + const info = getDamage(h); + const d = info?.damage; + if (d !== null && d !== void 0) { + if (d < damage) { + damage = d; + damageInfo = info; } - flags[condition] = false; } + flags[condition] = false; } } else { damageInfo = getDamage(h); @@ -1142,6 +1145,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { } } + let dirDamageInfo = null; + let dirMinDamage = Infinity; let damageInfo = null; let damage = Infinity; @@ -1150,18 +1155,29 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { return damageInfo; } - if (toMap.length === 1) { + if (toMap.length <= 1) { // 单个与多个分开计算,有助于提高性能表现 - const h = toMap[0][1]; + const h = + toMap[0]?.[1] ?? core.getHeroStatusOf(hero, ['atk', 'def']); autoSkillOf(h); if (damageInfo) { - return Object.assign(damageInfo, { dir: toMap[0][0] }); + return Object.assign(damageInfo, { + dir: [toMap[0]?.[0] ?? 'none', damage] + }); } else return null; } else { + const dirDamage = []; for (const [dir, h] of toMap) { + damage = Infinity; + damageInfo = null; autoSkillOf(h); - if (damageInfo) { - return Object.assign(damageInfo, { dir }); + dirDamage.push([dir, damage]); + if (damage < dirMinDamage) { + dirMinDamage = damage; + dirDamageInfo = damageInfo; + } + if (dirDamageInfo) { + return Object.assign(dirDamageInfo, { dir: dirDamage }); } else return null; } } @@ -1501,7 +1517,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { repulse = {}, // 每个点的阻击怪信息 mockery = {}, // 电摇嘲讽 halo = {}; // 光环 - var betweenAttackLocs = {}; // 所有可能的夹击点 var needCache = false; var canGoDeadZone = core.flags.canGoDeadZone; var haveHunt = false; @@ -1702,23 +1717,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { } } - // 夹击;在这里提前计算所有可能的夹击点,具体计算逻辑在下面 - // 如果要防止夹击伤害,可以简单的将 flag:no_betweenAttack 设为true - if ( - enemy && - core.enemys.hasSpecial(enemy.special, 16) && - !core.hasFlag('no_betweenAttack') - ) { - for (var dir in core.utils.scan) { - var nx = x + core.utils.scan[dir].x, - ny = y + core.utils.scan[dir].y, - currloc = nx + ',' + ny; - if (nx < 0 || nx >= width || ny < 0 || ny >= height) - continue; - betweenAttackLocs[currloc] = true; - } - } - // 检查地图范围类技能 var specialFlag = core.getSpecialFlag(enemy); if (specialFlag & 1) needCache = true; @@ -1743,74 +1741,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { } } - // 对每个可能的夹击点计算夹击伤害 - for (var loc in betweenAttackLocs) { - var xy = loc.split(','), - x = parseInt(xy[0]), - y = parseInt(xy[1]); - // 夹击怪物的ID - var enemyId1 = null, - enemyId2 = null; - // 检查左右夹击 - var leftBlock = blocks[x - 1 + ',' + y], - rightBlock = blocks[x + 1 + ',' + y]; - if ( - leftBlock && - !leftBlock.disable && - rightBlock && - !rightBlock.disable && - leftBlock.id == rightBlock.id - ) { - if (core.hasSpecial(leftBlock.event.id, 16)) - enemyId1 = leftBlock.event.id; - } - // 检查上下夹击 - var topBlock = blocks[x + ',' + (y - 1)], - bottomBlock = blocks[x + ',' + (y + 1)]; - if ( - topBlock && - !topBlock.disable && - bottomBlock && - !bottomBlock.disable && - topBlock.id == bottomBlock.id - ) { - if (core.hasSpecial(topBlock.event.id, 16)) - enemyId2 = topBlock.event.id; - } - - if (enemyId1 != null || enemyId2 != null) { - var leftHp = core.status.hero.hp - (damage[loc] || 0); - if (leftHp > 1) { - // 夹击伤害值 - var value = Math.floor(leftHp / 2); - // 是否不超过怪物伤害值 - if (core.flags.betweenAttackMax) { - var enemyDamage1 = core.getDamage( - enemyId1, - x, - y, - floorId - ); - if (enemyDamage1 != null && enemyDamage1 < value) - value = enemyDamage1; - var enemyDamage2 = core.getDamage( - enemyId2, - x, - y, - floorId - ); - if (enemyDamage2 != null && enemyDamage2 < value) - value = enemyDamage2; - } - if (value > 0) { - damage[loc] = (damage[loc] || 0) + value; - type[loc] = type[loc] || {}; - type[loc]['夹击伤害'] = true; - } - } - } - } - core.flags.canGoDeadZone = canGoDeadZone; core.status.checkBlock = { damage: damage, diff --git a/public/project/icons.js b/public/project/icons.js index b2eeac3..24bb91b 100644 --- a/public/project/icons.js +++ b/public/project/icons.js @@ -121,7 +121,8 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "T585": 61, "T586": 62, "T587": 63, - "T588": 64 + "T588": 64, + "T604": 65 }, "animates": { "star": 0, diff --git a/public/project/maps.js b/public/project/maps.js index 75ed89f..4c7da55 100644 --- a/public/project/maps.js +++ b/public/project/maps.js @@ -531,6 +531,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "601": {"cls":"enemys","id":"E601"}, "602": {"cls":"enemys","id":"E602"}, "603": {"cls":"enemys","id":"E603"}, + "604": {"cls":"terrains","id":"T604"}, "20037": {"cls":"tileset","id":"X20037","cannotOut":["up","left"],"cannotIn":["up","left"]}, "20038": {"cls":"tileset","id":"X20038","cannotOut":["up"],"cannotIn":["up"]}, "20039": {"cls":"tileset","id":"X20039","cannotOut":["up","right"],"cannotIn":["up","right"]}, @@ -562,11 +563,24 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "30121": {"cls":"tileset","id":"X30121","canPass":true}, "30196": {"cls":"tileset","id":"X30196","canPass":true}, "30204": {"cls":"tileset","id":"X30204","canPass":true}, - "70065": {"cls":"tileset","id":"X70065","cannotIn":["down"],"cannotOut":["down"]}, + "70048": {"cls":"tileset","id":"X70048","cannotOut":["up","left"],"cannotIn":["up","left"]}, + "70049": {"cls":"tileset","id":"X70049","cannotOut":["up"],"cannotIn":["up"]}, + "70050": {"cls":"tileset","id":"X70050","cannotOut":["up","right"],"cannotIn":["up","right"]}, + "70056": {"cls":"tileset","id":"X70056","cannotOut":["left"],"cannotIn":["left"]}, + "70058": {"cls":"tileset","id":"X70058","cannotOut":["right"],"cannotIn":["right"]}, + "70064": {"cls":"tileset","id":"X70064","cannotOut":["down","left"],"cannotIn":["down","left"]}, + "70065": {"cls":"tileset","id":"X70065","cannotIn":["up","down","left","right"],"cannotOut":["up","down","left","right"]}, + "70066": {"cls":"tileset","id":"X70066","cannotOut":["down","right"],"cannotIn":["down","right"]}, "70112": {"cls":"tileset","id":"X70112","cannotIn":["down"],"cannotOut":["down"]}, "70114": {"cls":"tileset","id":"X70114","cannotIn":["down"],"cannotOut":["down"]}, "70120": {"cls":"tileset","id":"X70120","cannotIn":["up","down","left","right"]}, "70122": {"cls":"tileset","id":"X70122","cannotIn":["up","down","left","right"]}, "70128": {"cls":"tileset","id":"X70128","cannotIn":["up","down","left","right"]}, - "70130": {"cls":"tileset","id":"X70130","cannotIn":["up","down","left","right"]} + "70130": {"cls":"tileset","id":"X70130","cannotIn":["up","down","left","right"]}, + "70184": {"cls":"tileset","id":"X70184","canPass":true}, + "70185": {"cls":"tileset","id":"X70185","canPass":true}, + "70186": {"cls":"tileset","id":"X70186","canPass":true}, + "70200": {"cls":"tileset","id":"X70200","canPass":true}, + "70201": {"cls":"tileset","id":"X70201","canPass":true}, + "70202": {"cls":"tileset","id":"X70202","canPass":true} } \ No newline at end of file diff --git a/public/project/materials/terrains.png b/public/project/materials/terrains.png index dec89e9..b00c8f3 100644 Binary files a/public/project/materials/terrains.png and b/public/project/materials/terrains.png differ diff --git a/public/project/plugins.js b/public/project/plugins.js index 902db9a..01c3b04 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -659,7 +659,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { document.getElementById('gameDraw').appendChild(canvas); var ctx = canvas.getContext('2d'); core.canvas[name] = ctx; - core.maps._setHDCanvasSize(ctx, core.__PIXELS__, core.__PIXELS__); return canvas; } diff --git a/public/styles.css b/public/styles.css index 36a4f79..08701b5 100644 --- a/public/styles.css +++ b/public/styles.css @@ -435,6 +435,10 @@ p#name { z-index: 170; } +.no-anti-aliasing { + image-rendering: pixelated; +} + #inputDiv { display: none; width: 100%; diff --git a/src/data/settings.json b/src/data/settings.json index e5e9625..68a61b2 100644 --- a/src/data/settings.json +++ b/src/data/settings.json @@ -47,7 +47,19 @@ "text": "自动勇士定位", "desc": [ "此项会在进入第二章后会起作用。开启后,当勇士处于不同位置打同一个怪物伤害不同时,在地图上使用绿色箭头标出伤害最低的位置,", - "使用红色箭头标出伤害较高的位置,在自动寻路中选择伤害最低的位置。" + "其余方向,伤害越高,箭头颜色越红,同时在自动寻路中选择可以到达的伤害最低的位置。", + "
", + "
", + "注:如果出现明显卡顿现象可以考虑关闭本设置或自动切换技能设置。" + ] + }, + "antiAliasing": { + "text": "抗锯齿", + "desc": [ + "是否开启抗锯齿。开启后,画面会变得不那么锐利,观感更加舒适;关闭后,可以更好地展现出像素感。", + "
", + "
", + "此项只对游戏画面起作用,对浏览地图和楼传均不起作用。" ] }, "showStudied": { diff --git a/src/plugin/settings.ts b/src/plugin/settings.ts index 0dba7ec..4e778f8 100644 --- a/src/plugin/settings.ts +++ b/src/plugin/settings.ts @@ -40,6 +40,11 @@ export const useFixed = ref(true); */ export const autoLocate = ref(true); +/** + * 是否开启抗锯齿 + */ +export const antiAliasing = ref(true); + watch(transition, n => { core.plugin.transition.value = n; core.setLocalStorage('transition', n); @@ -78,6 +83,17 @@ watch(autoSkill, n => { core.status.route.push(`set:autoLocate:${n}`); }); +watch(antiAliasing, n => { + core.setLocalStorage('antiAliasing', n); + for (const canvas of core.dom.gameCanvas) { + if (n) { + canvas.classList.remove('no-anti-aliasing'); + } else { + canvas.classList.add('no-anti-aliasing'); + } + } +}); + /** * 重置设置信息,从localStorage读取即可 */ @@ -88,6 +104,7 @@ function reset() { autoScale.value = core.getLocalStorage('autoScale', true); showStudied.value = core.getLocalStorage('showStudied', true); showHalo.value = core.getLocalStorage('showHalo', true); + antiAliasing.value = core.getLocalStorage('antiAliasing', false); } function resetFlag() { diff --git a/src/plugin/ui/fixed.ts b/src/plugin/ui/fixed.ts index 85be6c5..25e4ad7 100644 --- a/src/plugin/ui/fixed.ts +++ b/src/plugin/ui/fixed.ts @@ -75,8 +75,8 @@ export function getDetailedEnemy( } const damageColor = getDamageColor(enemyInfo.damage); const detail: DetailedEnemy = Object.assign(enemyInfo, { - critical: critical[0][0], - criticalDamage: critical[0][1], + critical: critical[0]?.[0] ?? '???', + criticalDamage: critical[0]?.[1] ?? '???', defDamage, specialColor, specialText, diff --git a/src/source/cls.d.ts b/src/source/cls.d.ts index 4624b31..0830efe 100644 --- a/src/source/cls.d.ts +++ b/src/source/cls.d.ts @@ -530,6 +530,7 @@ interface IdToCls { E601: 'enemys'; E602: 'enemys'; E603: 'enemys'; + T604: 'terrains'; X20037: 'tileset'; X20038: 'tileset'; X20039: 'tileset'; @@ -561,11 +562,24 @@ interface IdToCls { X30121: 'tileset'; X30196: 'tileset'; X30204: 'tileset'; + X70048: 'tileset'; + X70049: 'tileset'; + X70050: 'tileset'; + X70056: 'tileset'; + X70058: 'tileset'; + X70064: 'tileset'; X70065: 'tileset'; + X70066: 'tileset'; X70112: 'tileset'; X70114: 'tileset'; X70120: 'tileset'; X70122: 'tileset'; X70128: 'tileset'; X70130: 'tileset'; + X70184: 'tileset'; + X70185: 'tileset'; + X70186: 'tileset'; + X70200: 'tileset'; + X70201: 'tileset'; + X70202: 'tileset'; } \ No newline at end of file diff --git a/src/source/maps.d.ts b/src/source/maps.d.ts index f2a4699..55fde03 100644 --- a/src/source/maps.d.ts +++ b/src/source/maps.d.ts @@ -530,6 +530,7 @@ interface IdToNumber { E601: 601; E602: 602; E603: 603; + T604: 604; X20037: 20037; X20038: 20038; X20039: 20039; @@ -561,13 +562,26 @@ interface IdToNumber { X30121: 30121; X30196: 30196; X30204: 30204; + X70048: 70048; + X70049: 70049; + X70050: 70050; + X70056: 70056; + X70058: 70058; + X70064: 70064; X70065: 70065; + X70066: 70066; X70112: 70112; X70114: 70114; X70120: 70120; X70122: 70122; X70128: 70128; X70130: 70130; + X70184: 70184; + X70185: 70185; + X70186: 70186; + X70200: 70200; + X70201: 70201; + X70202: 70202; } interface NumberToId { 1: 'yellowWall'; @@ -1101,6 +1115,7 @@ interface NumberToId { 601: 'E601'; 602: 'E602'; 603: 'E603'; + 604: 'T604'; 20037: 'X20037'; 20038: 'X20038'; 20039: 'X20039'; @@ -1132,11 +1147,24 @@ interface NumberToId { 30121: 'X30121'; 30196: 'X30196'; 30204: 'X30204'; + 70048: 'X70048'; + 70049: 'X70049'; + 70050: 'X70050'; + 70056: 'X70056'; + 70058: 'X70058'; + 70064: 'X70064'; 70065: 'X70065'; + 70066: 'X70066'; 70112: 'X70112'; 70114: 'X70114'; 70120: 'X70120'; 70122: 'X70122'; 70128: 'X70128'; 70130: 'X70130'; + 70184: 'X70184'; + 70185: 'X70185'; + 70186: 'X70186'; + 70200: 'X70200'; + 70201: 'X70201'; + 70202: 'X70202'; } \ No newline at end of file diff --git a/src/ui/fixed.vue b/src/ui/fixed.vue index 4306fab..6eb2cb7 100644 --- a/src/ui/fixed.vue +++ b/src/ui/fixed.vue @@ -98,7 +98,7 @@ async function calHeight() { function getLabel(attr: keyof DetailedEnemy) { if (attr === 'critical') return '临界'; if (attr === 'criticalDamage') return '临界减伤'; - if (attr === 'defDamage') return `${core.status.thisMap.ratio}防`; + if (attr === 'defDamage') return `${core.status?.thisMap?.ratio ?? 1}防`; return core.getStatusLabel(attr); } diff --git a/src/ui/fly.vue b/src/ui/fly.vue index 8ed384e..5d41f76 100644 --- a/src/ui/fly.vue +++ b/src/ui/fly.vue @@ -546,6 +546,8 @@ onMounted(async () => { thumb = document.getElementById('fly-thumbnail') as HTMLCanvasElement; thumbCtx = thumb.getContext('2d')!; + const antiAliasing = core.getLocalStorage('antiAliasing', true); + const mapStyle = getComputedStyle(map); const thumbStyle = getComputedStyle(thumb); map.width = parseFloat(mapStyle.width) * devicePixelRatio; @@ -553,6 +555,13 @@ onMounted(async () => { thumb.width = parseFloat(thumbStyle.width) * devicePixelRatio; thumb.height = parseFloat(thumbStyle.width) * devicePixelRatio; + if (!antiAliasing) { + requestAnimationFrame(() => { + thumb.classList.add('no-anti-aliasing'); + thumbCtx.imageSmoothingEnabled = false; + }); + } + Array.from(document.getElementsByClassName('fly-settings')).forEach(v => { v.addEventListener('click', e => (v as HTMLElement).blur()); }); diff --git a/src/ui/settings.vue b/src/ui/settings.vue index 19a2ac5..ad893e2 100644 --- a/src/ui/settings.vue +++ b/src/ui/settings.vue @@ -58,6 +58,14 @@ autoLocate ? 'ON' : 'OFF' }} + 抗锯齿:   {{ + antiAliasing ? 'ON' : 'OFF' + }}