fix:调整core.getEnemyValue逻辑,不填name返回该点完整metadata

This commit is contained in:
lizhuoyuan 2025-02-13 14:58:13 +08:00
parent a7ac6c2ae7
commit 6b5615fd4e
4 changed files with 45 additions and 13 deletions

View File

@ -167,17 +167,30 @@ enemys.prototype._calSpecialContent = function (enemy, content) {
////// 获得某个点上某个怪物的某项属性 //////
enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) {
floorId = floorId || core.status.floorId;
if ((((flags.enemyOnPoint || {})[floorId] || {})[x + "," + y] || {})[name] != null) {
return flags.enemyOnPoint[floorId][x + "," + y][name];
const pointInfo = (((flags.enemyOnPoint || {})[floorId] || {})[x + "," + y] || {});
if (core.isset(name) && pointInfo[name] != null) {
return pointInfo[name];
}
if (enemy == null) {
var block = core.getBlock(x, y, floorId);
if (block == null) return null;
if (block == null) return null; // 无enemy且无x,y时返回null无enemy有x,y将读取该点信息
enemy = core.material.enemys[block.event.id];
}
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
if (enemy == null) return null;
return enemy[name];
else if (typeof enemy == 'string') {
enemy = core.material.enemys[enemy];
if (enemy == null) return null;
}
if (!core.isset(name)) { // 仅name不填时返回该enemy的完整数据有x,y将用该点信息覆盖core.material.enemys相应属性
enemy = core.clone(enemy);
for (let status in pointInfo) {
if (pointInfo.hasOwnProperty(status)) enemy[status] = pointInfo[status];
}
return enemy;
}
else return enemy[name];
}
////// 能否获胜 //////

View File

@ -14,12 +14,12 @@ main.floors.MT0=
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 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,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,201, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 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, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@ -56,7 +56,19 @@ main.floors.MT0=
"afterOpenDoor": {},
"cannotMove": {},
"bgmap": [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[167,167,167,167,167,167,167,167,167,167,167,167,167],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
],
"fgmap": [

View File

@ -1967,7 +1967,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
function canBattle(enemy, x, y) {
const loc = `${x},${y}`;
const floor = core.floors[core.status.floorId];
const e = core.material.enemys[enemy];
const e = core.getEnemyValue(enemy, null, x, y);
const hasEvent =
has(floor.afterBattle[loc]) || has(floor.beforeBattle[loc])
|| has(e.beforeBattle) || has(e.afterBattle)

11
runtime.d.ts vendored
View File

@ -1426,8 +1426,15 @@ interface enemys {
*/
getSpecialHint(enemy: string | Enemy, special: number): string
/** 获得某个敌人的某项属性值 */
getEnemyValue(enemy: string | Enemy, name: string, x?: number, y?: number, floorId?: string): any
/**
*
* @param enemy id或敌人对象
* @param name
* @param x core.material.enemys中相应属性
* @param y
* @param floorId
*/
getEnemyValue(enemy: string | Enemy, name?: string, x?: number, y?: number, floorId?: string): any
/**
*