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