feat:追猎穿怪

This commit is contained in:
ShakeFlower 2025-02-14 19:42:14 +08:00
parent d46baf63b1
commit c41dde17a3
8 changed files with 139 additions and 24 deletions

View File

@ -600,6 +600,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_docs": "开启负伤", "_docs": "开启负伤",
"_data": "是否支持负伤害(回血)" "_data": "是否支持负伤害(回血)"
}, },
"chaseThroughEnemy": {
"_leaf": true,
"_type": "checkbox",
"_docs": "追猎穿怪",
"_data": "追猎的视野和行动能否穿越其它怪物"
},
"betweenAttackMax": { "betweenAttackMax": {
"_leaf": true, "_leaf": true,
"_type": "checkbox", "_type": "checkbox",

View File

@ -1245,6 +1245,13 @@ control.prototype._checkBlock_ambush = function (ambush) {
return actions; return actions;
} }
////// 获取追猎的视野和行动可穿越的图块类型 //////
control.prototype.getChaseType = function () {
let clsList = ['items'];
if (core.flags.chaseThroughEnemy) core.push(clsList, ['enemys', 'enemy48']);
return clsList;
}
////// 追猎 ////// ////// 追猎 //////
control.prototype._checkBlock_chase = function (chase) { control.prototype._checkBlock_chase = function (chase) {
if (!chase || chase.length === 0) return []; if (!chase || chase.length === 0) return [];
@ -1259,7 +1266,6 @@ control.prototype._checkBlock_chase = function (chase) {
chase.forEach((currChaseInfo) => { chase.forEach((currChaseInfo) => {
const { x, y, dir } = currChaseInfo; const { x, y, dir } = currChaseInfo;
const [aimx, aimy] = [x + core.utils.scan[dir].x, y + core.utils.scan[dir].y]; const [aimx, aimy] = [x + core.utils.scan[dir].x, y + core.utils.scan[dir].y];
// 可与敌人,物品换位
if (!(aimx === hx && aimy === hy)) { if (!(aimx === hx && aimy === hy)) {
actions.push({ actions.push({
"type": "if", "condition": "!core.getBlock(" + aimx + "," + aimy + ")", "type": "if", "condition": "!core.getBlock(" + aimx + "," + aimy + ")",
@ -1267,14 +1273,27 @@ control.prototype._checkBlock_chase = function (chase) {
{ "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] }, { "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] },
], ],
"false": [ "false": [
{ "type": "setValue", "name": "flag:chaseAimCls", "value": `core.getBlockCls(${aimx},${aimy})` },
{ {
"type": "if", "condition": "[\"items\",\"enemys\",\"enemy48\"].includes(core.getBlockCls(" + aimx + "," + aimy + "))", "type": "if", "condition": "core.getChaseType().includes(core.getFlag('chaseAimCls'))",
"true": [ "true": [
{ "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] }, {
{ "type": "move", "loc": [aimx, aimy], "time": 100, "keep": true, "async": true, "steps": [reverseDir[dir] + ":1"] }, "type": "if", "condition": "[\"enemys\",\"enemy48\"].includes(core.getFlag('chaseAimCls'))",
"true": [
{
"type": "function", "function": `function () {
core.exchangeBlock(${x}, ${y}, ${aimx}, ${aimy}, '${dir}', 100, null); }`
},
],
"false": [
{ "type": "move", "loc": [x, y], "time": 100, "keep": true, "async": true, "steps": [dir + ":1"] },
{ "type": "move", "loc": [aimx, aimy], "time": 100, "keep": true, "async": true, "steps": [reverseDir[dir] + ":1"] },
]
},
{ "type": "waitAsync", "excludeAnimates": true }, { "type": "waitAsync", "excludeAnimates": true },
] ]
}, },
{ "type": "setValue", "name": "flag:chaseCls", "value": null },
] ]
}); });
} }

View File

@ -2664,7 +2664,7 @@ maps.prototype._getAndRemoveBlock = function (x, y) {
} }
////// 显示移动某块的动画,达到{“type”:”move”}的效果 ////// ////// 显示移动某块的动画,达到{“type”:”move”}的效果 //////
maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) { maps.prototype.moveBlock = function (x, y, steps, time, keep, callback, noMoveInfo) {
if (core.status.replay.speed == 24) time = 1; if (core.status.replay.speed == 24) time = 1;
time = time || 500; time = time || 500;
var blockArr = this._getAndRemoveBlock(x, y); var blockArr = this._getAndRemoveBlock(x, y);
@ -2686,10 +2686,10 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) {
sx: x, sy: y, x: x, y: y, px: 32 * x, py: 32 * y, opacity: 1, keep: keep, lastDirection: null, offset: 1, sx: x, sy: y, x: x, y: y, px: 32 * x, py: 32 * y, opacity: 1, keep: keep, lastDirection: null, offset: 1,
moveSteps: moveSteps, step: 0, per_time: time / 16 / core.status.replay.speed moveSteps: moveSteps, step: 0, per_time: time / 16 / core.status.replay.speed
} }
this._moveBlock_doMove(blockInfo, canvases, moveInfo, callback); this._moveBlock_doMove(blockInfo, canvases, moveInfo, callback, noMoveInfo);
} }
maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, callback) { maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, callback, noMoveInfo) {
var animateTotal = blockInfo.animate, animateTime = 0; var animateTotal = blockInfo.animate, animateTime = 0;
// 强制npc48行走时使用四帧动画 // 强制npc48行走时使用四帧动画
if (!blockInfo.doorInfo && !blockInfo.bigImage && blockInfo.cls == 'npc48') animateTotal = 4; if (!blockInfo.doorInfo && !blockInfo.bigImage && blockInfo.cls == 'npc48') animateTotal = 4;
@ -2700,7 +2700,7 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call
if (moveInfo.keep) { if (moveInfo.keep) {
core.setBlock(blockInfo.number, moveInfo.x, moveInfo.y); core.setBlock(blockInfo.number, moveInfo.x, moveInfo.y);
core.showBlock(moveInfo.x, moveInfo.y); core.showBlock(moveInfo.x, moveInfo.y);
core.moveEnemyOnPoint(moveInfo.sx, moveInfo.sy, moveInfo.x, moveInfo.y); if (!noMoveInfo) core.moveEnemyOnPoint(moveInfo.sx, moveInfo.sy, moveInfo.x, moveInfo.y);
} }
if (callback) callback(); if (callback) callback();
} }
@ -2730,6 +2730,55 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call
} }
_run(); _run();
} }
//core.setEnemyOnPoint(5,2,null,'hp',1000,'=') core.exchangeBlock(5, 2, 5, 3, 'down', 100, null)
maps.prototype.exchangeBlock = function (x1, y1, x2, y2, dir, time, callback) {
console.log([x1, y1, x2, y2, dir, time, callback])
let [block1, block2] = [this.getBlock(x1, y1), this.getBlock(x2, y2)];
let [blockInfo1, blockInfo2] = [this.getBlockInfo(block1), this.getBlockInfo(block2)];
const [pos1, pos2] = [`${x1},${y1}`, `${x2},${y2}`];
let fromInfo, toInfo, enemyOnFloor;
const floorId = core.status.floorId;
if (flags.enemyOnPoint && flags.enemyOnPoint.hasOwnProperty(floorId)) {
enemyOnFloor = flags.enemyOnPoint[floorId];
if (enemyOnFloor.hasOwnProperty(pos1)) fromInfo = core.clone(enemyOnFloor[pos1]);
if (enemyOnFloor.hasOwnProperty(pos2)) toInfo = core.clone(enemyOnFloor[pos2]);
}
let callbackCount = 0;
function myCallback() {
callbackCount++;
if (callbackCount === 2) {
// 删除旧位置信息
if (fromInfo) delete enemyOnFloor[pos1];
if (toInfo) delete enemyOnFloor[pos2];
// 设置新位置信息
if (fromInfo) enemyOnFloor[pos2] = fromInfo;
if (toInfo) enemyOnFloor[pos1] = toInfo;
if (callback) callback();
}
}
switch (dir) {
case 'left':
this.moveBlock(x1, y1, ['left'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['right'], time, true, myCallback, true);
break;
case 'right':
this.moveBlock(x1, y1, ['right'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['left'], time, true, myCallback, true);
break;
case 'up':
this.moveBlock(x1, y1, ['up'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['down'], time, true, myCallback, true);
break;
case 'down':
this.moveBlock(x1, y1, ['down'], time, true, myCallback, true);
this.moveBlock(x2, y2, ['up'], time, true, myCallback, true);
break;
}
}
maps.prototype._moveBlock_updateSpeed = function (moveInfo) { maps.prototype._moveBlock_updateSpeed = function (moveInfo) {
if (moveInfo.step == 0 && moveInfo.moveSteps[0][0] == 'speed' && moveInfo.moveSteps[0][1] >= 16) { if (moveInfo.step == 0 && moveInfo.moveSteps[0][0] == 'speed' && moveInfo.moveSteps[0][1] >= 16) {

View File

@ -68,3 +68,19 @@ core.drawToolboxRightbar(ctx, info1);
!mypromt callback疑似需要改回去 !mypromt callback疑似需要改回去
难绷的bug太多了 自动拾取,自动清怪,追猎等等。 难绷的bug太多了 自动拾取,自动清怪,追猎等等。
moveBlock:
```js
let [x, y, steps, time, keep] = [0,0,['down'],1,false];
let blockArr = core.maps._getAndRemoveBlock(x, y);
let block = blockArr[0], blockInfo = blockArr[1];
let canvases = core.maps._initDetachedBlock(blockInfo, x, y, block.event.animate !== false);
core.maps._moveDetachedBlock(blockInfo, 32 * x, 32 * y, 1, canvases);
```
1.blockArr:[block,blockInfo]组成同时会removeBlock
block,blockInfo有一个什么都没有则blockArr什么都没有则返回
接下来处理moveSteps得到['down',1];
_initDetachedBlock返回三个canvas的对象 {headCanvas,bodyCanvas,damageCanvas}
_moveDetachedBlock疑似是通过该函数不断移动实现移动效果
模板字符串居然不能随意填字符串,逆天

View File

@ -141,7 +141,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"constants": { "constants": {
"book": 1, "book": 1,
"setting": 1, "setting": 1,
"postman": 1, "postman": 1
}, },
"tools": {}, "tools": {},
"equips": {} "equips": {}
@ -728,6 +728,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"enableMoveDirectly": true, "enableMoveDirectly": true,
"enableRouteFolding": true, "enableRouteFolding": true,
"disableShopOnDamage": false, "disableShopOnDamage": false,
"blurFg": false "blurFg": false,
"chaseThroughEnemy": true
} }
} }

View File

@ -1,7 +1,7 @@
var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 =
{ {
"greenSlime": {"name":"绿头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, "greenSlime": {"name":"绿头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[28]},
"redSlime": {"name":"红头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[26]}, "redSlime": {"name":"红头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]},
"blackSlime": {"name":"青头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, "blackSlime": {"name":"青头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0},
"slimelord": {"name":"怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "slimelord": {"name":"怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]},
"bat": {"name":"小蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "bat": {"name":"小蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]},

View File

@ -11,11 +11,11 @@ main.floors.MT0=
"images": [], "images": [],
"ratio": 2, "ratio": 2,
"map": [ "map": [
[201, 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,201, 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,201, 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,202, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@ -35,6 +35,28 @@ main.floors.MT0=
"type": "setValue", "type": "setValue",
"name": "item:silverCoin", "name": "item:silverCoin",
"value": "99" "value": "99"
},
{
"type": "setEnemyOnPoint",
"loc": [
[
5,
2
]
],
"name": "hp",
"value": "123"
},
{
"type": "setEnemyOnPoint",
"loc": [
[
5,
4
]
],
"name": "hp",
"value": "1234"
} }
], ],
"parallelDo": "", "parallelDo": "",

View File

@ -439,11 +439,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
const { aimx, aimy, aimId } = failMoveInfo; const { aimx, aimy, aimId } = failMoveInfo;
if (core.getBlockId(x, y) === enemyId && failMoveInfo if (core.getBlockId(x, y) === enemyId && failMoveInfo
&& core.getBlockId(aimx, aimy) === aimId) { && core.getBlockId(aimx, aimy) === aimId) {
const doFailMove = const doFailMove = [
[{ "type": "setBlock", "number": enemyId, "loc": [[aimx, aimy]], "time": 50 }, { "type": "setBlock", "number": enemyId, "loc": [[aimx, aimy]], "time": 50 },
{ "type": "setBlock", "number": aimId, "loc": [[x, y]], "time": 50 }, { "type": "setBlock", "number": aimId, "loc": [[x, y]], "time": 50 },
{ "type": "function", "function": `function () { core.switchEnemyOnPoint(${x},${y},${aimx},${aimy}) }` }, {
] "type": "function", "function": `function () { core.switchEnemyOnPoint(${x},${y},${aimx},${aimy}) }`
},
];
core.insertAction(doFailMove); core.insertAction(doFailMove);
} }
} }
@ -547,7 +549,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
[25, "光环", function (enemy) { return (enemy.range != null ? ((enemy.haloSquare ? "该怪物九宫格" : "该怪物十字") + enemy.haloRange + "格范围内") : "同楼层所有") + "怪物生命提升" + (enemy.hpBuff || 0) + "%,攻击提升" + (enemy.atkBuff || 0) + "%,防御提升" + (enemy.defBuff || 0) + "%" + (enemy.haloAdd ? "可叠加" : "不可叠加"); }, "#e6e099", 1], [25, "光环", function (enemy) { return (enemy.range != null ? ((enemy.haloSquare ? "该怪物九宫格" : "该怪物十字") + enemy.haloRange + "格范围内") : "同楼层所有") + "怪物生命提升" + (enemy.hpBuff || 0) + "%,攻击提升" + (enemy.atkBuff || 0) + "%,防御提升" + (enemy.defBuff || 0) + "%" + (enemy.haloAdd ? "可叠加" : "不可叠加"); }, "#e6e099", 1],
[26, "支援", "当周围一圈的怪物受到攻击时将上前支援,并组成小队战斗。", "#77c0b6", 1], [26, "支援", "当周围一圈的怪物受到攻击时将上前支援,并组成小队战斗。", "#77c0b6", 1],
[27, "捕捉", function (enemy) { return "当走到怪物周围" + (enemy.zoneSquare ? "九宫格" : "十字") + "时会强制进行战斗。"; }, "#c0ddbb"], [27, "捕捉", function (enemy) { return "当走到怪物周围" + (enemy.zoneSquare ? "九宫格" : "十字") + "时会强制进行战斗。"; }, "#c0ddbb"],
[28, "追猎", "角色行走一步后若处在怪物视线内怪物向角色移动一步。怪物走入角色十字1格以内时主动与角色开战。", "#800020"], [28, "追猎", "角色行走一步后若处在怪物视线内怪物向角色移动一步。怪物走入角色十字1格以内时主动与角色开战。", "#DC143C"],
[29, "败移", "战后若角色面对的行/列有其它怪物,该怪物不会被击败,而是与其中最近的怪物交换位置。", "#c0ddbb"], [29, "败移", "战后若角色面对的行/列有其它怪物,该怪物不会被击败,而是与其中最近的怪物交换位置。", "#c0ddbb"],
]; ];
}, },
@ -1439,9 +1441,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
*/ */
function canSeeThrough(x, y) { function canSeeThrough(x, y) {
const block = core.getBlock(x, y); const block = core.getBlock(x, y);
// 空地和道具,敌人(不含普通事件)可被穿过 // 空地默认一定可被穿过,有事件不允许穿过
if (block === null || if (block === null ||
(['items', 'enemys', 'enemy48'].includes(block.event.cls) && !block.event.data)) return true; (core.control.getChaseType().includes(block.event.cls) && !block.event.data)) return true;
return false; return false;
} }