feat:追猎穿怪
This commit is contained in:
parent
d46baf63b1
commit
c41dde17a3
@ -600,6 +600,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_docs": "开启负伤",
|
||||
"_data": "是否支持负伤害(回血)"
|
||||
},
|
||||
"chaseThroughEnemy": {
|
||||
"_leaf": true,
|
||||
"_type": "checkbox",
|
||||
"_docs": "追猎穿怪",
|
||||
"_data": "追猎的视野和行动能否穿越其它怪物"
|
||||
},
|
||||
"betweenAttackMax": {
|
||||
"_leaf": true,
|
||||
"_type": "checkbox",
|
||||
|
||||
@ -1245,6 +1245,13 @@ control.prototype._checkBlock_ambush = function (ambush) {
|
||||
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) {
|
||||
if (!chase || chase.length === 0) return [];
|
||||
@ -1259,7 +1266,6 @@ control.prototype._checkBlock_chase = function (chase) {
|
||||
chase.forEach((currChaseInfo) => {
|
||||
const { x, y, dir } = currChaseInfo;
|
||||
const [aimx, aimy] = [x + core.utils.scan[dir].x, y + core.utils.scan[dir].y];
|
||||
// 可与敌人,物品换位
|
||||
if (!(aimx === hx && aimy === hy)) {
|
||||
actions.push({
|
||||
"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"] },
|
||||
],
|
||||
"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": [
|
||||
{ "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": "setValue", "name": "flag:chaseCls", "value": null },
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
57
libs/maps.js
57
libs/maps.js
@ -2664,7 +2664,7 @@ maps.prototype._getAndRemoveBlock = function (x, y) {
|
||||
}
|
||||
|
||||
////// 显示移动某块的动画,达到{“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;
|
||||
time = time || 500;
|
||||
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,
|
||||
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;
|
||||
// 强制npc48行走时使用四帧动画
|
||||
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) {
|
||||
core.setBlock(blockInfo.number, 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();
|
||||
}
|
||||
@ -2730,6 +2730,55 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call
|
||||
}
|
||||
_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) {
|
||||
if (moveInfo.step == 0 && moveInfo.moveSteps[0][0] == 'speed' && moveInfo.moveSteps[0][1] >= 16) {
|
||||
|
||||
18
mynote.md
18
mynote.md
@ -67,4 +67,20 @@ core.drawToolboxRightbar(ctx, info1);
|
||||
|
||||
!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:疑似是通过该函数不断移动实现移动效果
|
||||
|
||||
模板字符串居然不能随意填字符串,逆天
|
||||
@ -141,7 +141,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"constants": {
|
||||
"book": 1,
|
||||
"setting": 1,
|
||||
"postman": 1,
|
||||
"postman": 1
|
||||
},
|
||||
"tools": {},
|
||||
"equips": {}
|
||||
@ -728,6 +728,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"enableMoveDirectly": true,
|
||||
"enableRouteFolding": true,
|
||||
"disableShopOnDamage": false,
|
||||
"blurFg": false
|
||||
"blurFg": false,
|
||||
"chaseThroughEnemy": true
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 =
|
||||
{
|
||||
"greenSlime": {"name":"绿头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0},
|
||||
"redSlime": {"name":"红头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[26]},
|
||||
"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":[]},
|
||||
"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":[]},
|
||||
"bat": {"name":"小蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]},
|
||||
|
||||
@ -11,11 +11,11 @@ main.floors.MT0=
|
||||
"images": [],
|
||||
"ratio": 2,
|
||||
"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, 0, 0, 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,201, 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],
|
||||
@ -35,6 +35,28 @@ main.floors.MT0=
|
||||
"type": "setValue",
|
||||
"name": "item:silverCoin",
|
||||
"value": "99"
|
||||
},
|
||||
{
|
||||
"type": "setEnemyOnPoint",
|
||||
"loc": [
|
||||
[
|
||||
5,
|
||||
2
|
||||
]
|
||||
],
|
||||
"name": "hp",
|
||||
"value": "123"
|
||||
},
|
||||
{
|
||||
"type": "setEnemyOnPoint",
|
||||
"loc": [
|
||||
[
|
||||
5,
|
||||
4
|
||||
]
|
||||
],
|
||||
"name": "hp",
|
||||
"value": "1234"
|
||||
}
|
||||
],
|
||||
"parallelDo": "",
|
||||
|
||||
@ -439,11 +439,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
const { aimx, aimy, aimId } = failMoveInfo;
|
||||
if (core.getBlockId(x, y) === enemyId && failMoveInfo
|
||||
&& core.getBlockId(aimx, aimy) === aimId) {
|
||||
const doFailMove =
|
||||
[{ "type": "setBlock", "number": enemyId, "loc": [[aimx, aimy]], "time": 50 },
|
||||
const doFailMove = [
|
||||
{ "type": "setBlock", "number": enemyId, "loc": [[aimx, aimy]], "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);
|
||||
}
|
||||
}
|
||||
@ -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],
|
||||
[26, "支援", "当周围一圈的怪物受到攻击时将上前支援,并组成小队战斗。", "#77c0b6", 1],
|
||||
[27, "捕捉", function (enemy) { return "当走到怪物周围" + (enemy.zoneSquare ? "九宫格" : "十字") + "时会强制进行战斗。"; }, "#c0ddbb"],
|
||||
[28, "追猎", "角色行走一步后若处在怪物视线内,怪物向角色移动一步。怪物走入角色十字1格以内时主动与角色开战。", "#800020"],
|
||||
[28, "追猎", "角色行走一步后若处在怪物视线内,怪物向角色移动一步。怪物走入角色十字1格以内时主动与角色开战。", "#DC143C"],
|
||||
[29, "败移", "战后若角色面对的行/列有其它怪物,该怪物不会被击败,而是与其中最近的怪物交换位置。", "#c0ddbb"],
|
||||
];
|
||||
},
|
||||
@ -1439,9 +1441,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
*/
|
||||
function canSeeThrough(x, y) {
|
||||
const block = core.getBlock(x, y);
|
||||
// 空地和道具,敌人(不含普通事件)可被穿过
|
||||
// 空地默认一定可被穿过,有事件不允许穿过
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user