mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-31 15:09:26 +08:00
refactor: 永夜/极昼
This commit is contained in:
parent
849e121b77
commit
3baee32c51
@ -269,7 +269,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
version: core.firstData.version,
|
||||
guid: core.getGuid(),
|
||||
time: new Date().getTime(),
|
||||
skills: Mota.Plugin.require('skillTree_g').saveSkillTree()
|
||||
skills: Mota.Plugin.require('skillTree_g').saveSkillTree(),
|
||||
night: [
|
||||
...Mota.require(
|
||||
'module',
|
||||
'Mechanism'
|
||||
).NightSpecial.saveNight()
|
||||
]
|
||||
};
|
||||
|
||||
return data;
|
||||
@ -318,6 +324,19 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
core.setFlag('__fromLoad__', true);
|
||||
|
||||
Mota.Plugin.require('skillTree_g').loadSkillTree(data.skills);
|
||||
const Night = Mota.require('module', 'Mechanism').NightSpecial;
|
||||
|
||||
if (!data.night) {
|
||||
// 兼容旧版
|
||||
Night.loadNight([]);
|
||||
for (const [key, value] of Object.entries(data.hero.flags)) {
|
||||
if (key.startsWith('night_')) {
|
||||
const [, floorId] = key.split('_');
|
||||
Night.addNight(floorId, value);
|
||||
delete data.hero.flags[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 切换到对应的楼层
|
||||
core.changeFloor(data.floorId, null, data.hero.loc, 0, function () {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { DamageEnemy, ensureFloorDamage, getSingleEnemy } from './damage';
|
||||
import { findDir, has } from '../../plugin/game/utils';
|
||||
import { hook, loading } from '../game';
|
||||
import { NightSpecial } from '../mechanism/misc';
|
||||
|
||||
export interface CurrentEnemy {
|
||||
enemy: DamageEnemy;
|
||||
@ -198,18 +199,12 @@ function init() {
|
||||
|
||||
// 极昼永夜
|
||||
if (special.has(22)) {
|
||||
flags[`night_${floorId}`] ??= 0;
|
||||
flags[`night_${floorId}`] -= enemy.info.night!;
|
||||
NightSpecial.addNight(floorId, -enemy.info.night!);
|
||||
}
|
||||
if (special.has(23)) {
|
||||
flags[`night_${floorId}`] ??= 0;
|
||||
flags[`night_${floorId}`] += enemy.info.day;
|
||||
NightSpecial.addNight(floorId, enemy.info.day!);
|
||||
}
|
||||
|
||||
// if (core.plugin.skillTree.getSkillLevel(11) > 0) {
|
||||
// core.plugin.study.declineStudiedSkill();
|
||||
// }
|
||||
|
||||
// 如果是融化怪,需要特殊标记一下
|
||||
if (special.has(25) && has(x) && has(y)) {
|
||||
flags[`melt_${floorId}`] ??= {};
|
||||
|
@ -3,6 +3,7 @@ import { Range } from '../util/range';
|
||||
import { ensureArray, has, manhattan } from '@/plugin/game/utils';
|
||||
import EventEmitter from 'eventemitter3';
|
||||
import { hook } from '../game';
|
||||
import { NightSpecial } from '../mechanism/misc';
|
||||
|
||||
// todo: 光环划分优先级,从而可以实现光环的多级运算
|
||||
|
||||
@ -335,12 +336,14 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
}
|
||||
|
||||
// 极昼永夜
|
||||
info.atk -= flags[`night_${floorId}`] ?? 0;
|
||||
info.def -= flags[`night_${floorId}`] ?? 0;
|
||||
const night = NightSpecial.getNight(floorId);
|
||||
info.atk -= night;
|
||||
info.def -= night;
|
||||
|
||||
// 融化,融化不属于怪物光环,因此不能用provide和inject计算,需要在这里计算
|
||||
if (has(flags[`melt_${floorId}`]) && has(this.x) && has(this.y)) {
|
||||
for (const [loc, per] of Object.entries(flags[`melt_${floorId}`])) {
|
||||
const melt = flags[`melt_${floorId}`];
|
||||
if (has(melt) && has(this.x) && has(this.y)) {
|
||||
for (const [loc, per] of Object.entries(melt)) {
|
||||
const [mx, my] = loc.split(',').map(v => parseInt(v));
|
||||
if (
|
||||
Math.abs(mx + dx - this.x) <= 1 &&
|
||||
|
@ -33,7 +33,8 @@ Mota.register('var', 'gameListener', gameListener);
|
||||
Mota.register('var', 'loading', loading);
|
||||
// ----- 模块注册
|
||||
Mota.register('module', 'Mechanism', {
|
||||
BluePalace: miscMechanism.BluePalace
|
||||
BluePalace: miscMechanism.BluePalace,
|
||||
NightSpecial: miscMechanism.NightSpecial
|
||||
});
|
||||
Mota.register('module', 'State', {
|
||||
ItemState,
|
||||
|
@ -2,6 +2,34 @@ import { backDir, has } from '@/plugin/game/utils';
|
||||
import { loading } from '../game';
|
||||
import type { LayerDoorAnimate } from '@/core/render/preset/floor';
|
||||
|
||||
/**
|
||||
* 永夜/极昼
|
||||
*/
|
||||
export namespace NightSpecial {
|
||||
let nightMap = new Map<FloorIds, number>();
|
||||
|
||||
export function getNight(floor: FloorIds) {
|
||||
return nightMap.get(floor) ?? 0;
|
||||
}
|
||||
|
||||
export function addNight(floor: FloorIds, value: number) {
|
||||
const num = nightMap.get(floor) ?? 0;
|
||||
nightMap.set(floor, num + value);
|
||||
}
|
||||
|
||||
export function saveNight() {
|
||||
return nightMap.entries();
|
||||
}
|
||||
|
||||
export function loadNight(night: IterableIterator<[FloorIds, number]>) {
|
||||
nightMap = new Map(night);
|
||||
}
|
||||
|
||||
export function getAll() {
|
||||
return nightMap;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace BluePalace {
|
||||
type DoorConvertInfo = [id: AllIds, x: number, y: number];
|
||||
|
||||
|
@ -2,6 +2,7 @@ import { logger } from '@/core/common/logger';
|
||||
import { EventEmitter } from 'eventemitter3';
|
||||
import { cloneDeep, isNil } from 'lodash-es';
|
||||
import { ItemState } from './item';
|
||||
import { NightSpecial } from '../mechanism/misc';
|
||||
|
||||
/**
|
||||
* 获取勇士在某一点的属性
|
||||
@ -85,7 +86,7 @@ function getRealStatus(
|
||||
|
||||
// 永夜、极昼
|
||||
if (name === 'atk' || name === 'def') {
|
||||
s += window.flags?.[`night_${floorId}`] ?? 0;
|
||||
s += NightSpecial.getNight(floorId);
|
||||
}
|
||||
|
||||
// 技能
|
||||
@ -93,8 +94,7 @@ function getRealStatus(
|
||||
const level = getSkillLevel(2);
|
||||
if (name === 'atk') {
|
||||
s *= 1 + 0.1 * level;
|
||||
}
|
||||
if (name === 'def') {
|
||||
} else if (name === 'def') {
|
||||
s *= 1 - 0.1 * level;
|
||||
}
|
||||
}
|
||||
@ -102,18 +102,17 @@ function getRealStatus(
|
||||
const level = getSkillLevel(10);
|
||||
if (name === 'atk') {
|
||||
s *= 1 - 0.1 * level;
|
||||
}
|
||||
if (name === 'def') {
|
||||
} else if (name === 'def') {
|
||||
s *= 1 + 0.1 * level;
|
||||
}
|
||||
}
|
||||
|
||||
// buff
|
||||
if (typeof s === 'number')
|
||||
if (typeof s === 'number') {
|
||||
s *= core.getBuff(name as keyof NumbericHeroStatus);
|
||||
s = Math.floor(s);
|
||||
}
|
||||
|
||||
// 取整
|
||||
if (typeof s === 'number') s = Math.floor(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,7 @@ interface VariableInterface {
|
||||
interface ModuleInterface {
|
||||
Mechanism: {
|
||||
BluePalace: typeof misc.BluePalace;
|
||||
NightSpecial: typeof misc.NightSpecial;
|
||||
};
|
||||
Effect: {
|
||||
Portal: typeof portal;
|
||||
|
Loading…
Reference in New Issue
Block a user