feat: 怪物及地图伤害系统

This commit is contained in:
AncTe committed 2026-04-14 18:10:21 +08:00
1 parent fe67939a05
commit 057d5ab813
28 files changed
+3638 -264

No files matched your search

+4 -1
View File
@@ -1,12 +1,14 @@
import { ICoreState, IStateSaveData } from './types';
import { ICoreState, IGameDataState, IStateSaveData } from './types';
import { IHeroState, HeroState } from './hero';
import { ILayerState, LayerState } from './map';
import { IRoleFaceBinder, RoleFaceBinder } from './common';
import { GameDataState } from './data';
export class CoreState implements ICoreState {
readonly layer: ILayerState;
readonly hero: IHeroState;
readonly roleFace: IRoleFaceBinder;
readonly data: IGameDataState;
readonly idNumberMap: Map<string, number>;
readonly numberIdMap: Map<number, string>;
@@ -16,6 +18,7 @@ export class CoreState implements ICoreState {
this.roleFace = new RoleFaceBinder();
this.idNumberMap = new Map();
this.numberIdMap = new Map();
this.data = new GameDataState();
}
saveState(): IStateSaveData {
+12
View File
@@ -0,0 +1,12 @@
import { EnemyManager, IEnemyManager } from '@user/data-base';
import { IGameDataState } from './types';
import { registerSpecials } from './enemy';
export class GameDataState implements IGameDataState {
readonly enemyManager: IEnemyManager;
constructor() {
this.enemyManager = new EnemyManager();
registerSpecials(this.enemyManager);
}
}
+121
View File
@@ -0,0 +1,121 @@
import {
FullRange,
IManhattanRangeParam,
IRange,
IRectRangeParam,
ManhattanRange,
RectRange
} from '@motajs/common';
import {
IAuraConverter,
IEnemyAuraView,
IEnemySpecialModifier,
IReadonlyEnemy,
ISpecial,
IEnemy
} from '@user/data-base';
import { IHaloValue } from './special';
import { ITileLocator } from '@user/types';
const FULL_RANGE = new FullRange();
const RECT_RANGE = new RectRange();
const MANHATTAN_RANGE = new ManhattanRange();
//#region 25-光环
export class CommonAuraConverter implements IAuraConverter {
shouldConvert(special: ISpecial<any>): boolean {
return special.code === 25;
}
convert(
special: ISpecial<any>,
enemy: IReadonlyEnemy,
locator: ITileLocator
): IEnemyAuraView<any, any> {
return new CommonAura(enemy, special as ISpecial<IHaloValue>, locator);
}
}
export class CommonAura implements IEnemyAuraView<
IRectRangeParam | IManhattanRangeParam | void,
IHaloValue
> {
readonly priority: number = 25;
readonly couldApplyBase: boolean = true;
readonly couldApplySpecial: boolean = false;
readonly range: IRange<IRectRangeParam | IManhattanRangeParam | void>;
constructor(
readonly enemy: IReadonlyEnemy,
readonly special: ISpecial<IHaloValue>,
readonly locator: ITileLocator
) {
this.range = this.createRange();
}
private createRange(): IRange<
IRectRangeParam | IManhattanRangeParam | void
> {
const { haloRange, haloSquare } = this.special.value;
if (haloRange <= 0) {
return FULL_RANGE;
}
return haloSquare ? RECT_RANGE : MANHATTAN_RANGE;
}
getRangeParam(): IRectRangeParam | IManhattanRangeParam | void {
const { haloRange, haloSquare } = this.special.value;
if (haloRange <= 0) {
return undefined;
}
if (haloSquare) {
return {
x: this.locator.x - haloRange,
y: this.locator.y - haloRange,
w: haloRange * 2 + 1,
h: haloRange * 2 + 1
};
}
return {
cx: this.locator.x,
cy: this.locator.y,
radius: haloRange
};
}
apply(enemy: IEnemy, baseEnemy: IReadonlyEnemy): void {
const { hpBuff, atkBuff, defBuff } = this.special.value;
if (hpBuff !== 0) {
enemy.setAttribute(
'hp',
enemy.getAttribute('hp') +
Math.floor((baseEnemy.getAttribute('hp') * hpBuff) / 100)
);
}
if (atkBuff !== 0) {
enemy.setAttribute(
'atk',
enemy.getAttribute('atk') +
Math.floor((baseEnemy.getAttribute('atk') * atkBuff) / 100)
);
}
if (defBuff !== 0) {
enemy.setAttribute(
'def',
enemy.getAttribute('def') +
Math.floor((baseEnemy.getAttribute('def') * defBuff) / 100)
);
}
}
applySpecial(): IEnemySpecialModifier | null {
return null;
}
}
//#endregion
@@ -1,2 +1,4 @@
export * from './aura';
export * from './damage';
export * from './mapSpecials';
export * from './special';
@@ -0,0 +1,358 @@
import {
DirectionMapper,
IDirectionDescriptor,
InternalDirectionGroup,
IManhattanRangeParam,
IRange,
IRayRangeParam,
IRectRangeParam,
ManhattanRange,
RayRange,
RectRange
} from '@motajs/common';
import { ITileLocator } from '@user/types';
import { IReadonlyEnemy, ISpecial } from '@user/data-base';
import {
IEnemyContext,
IMapDamageConverter,
IMapDamageInfo,
IMapDamageInfoExtra,
IMapDamageReducer,
IMapDamageView
} from '@user/data-base';
import { IZoneValue } from './special';
import { MapDamageType } from './types';
const RECT_RANGE = new RectRange();
const MANHATTAN_RANGE = new ManhattanRange();
const RAY_RANGE = new RayRange();
const DIRECTION_MAPPER = new DirectionMapper();
const DIR4 = [...DIRECTION_MAPPER.map(InternalDirectionGroup.Dir4)];
//#region 地图伤害
abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
constructor(protected readonly context: IEnemyContext) {}
abstract getRange(): IRange<T>;
abstract getRangeParam(): T;
getDamageAt(locator: ITileLocator): Readonly<IMapDamageInfo> | null {
const range = this.getRange();
const param = this.getRangeParam();
range.bindHost(this.context);
if (!range.inRange(locator.x, locator.y, param)) {
return null;
}
return this.getDamageWithoutCheck(locator);
}
abstract getDamageWithoutCheck(
locator: ITileLocator
): Readonly<IMapDamageInfo> | null;
/**
* 创建伤害信息
* @param damage 伤害值
* @param type 伤害类型
* @param extra 额外信息
*/
protected createInfo(
damage: number,
type: number,
extra?: Partial<IMapDamageInfoExtra>
): IMapDamageInfo {
return {
damage,
type,
extra: {
catch: extra?.catch ?? new Set(),
repulse: extra?.repulse ?? new Set()
}
};
}
/**
* 判断一个点是否在上下文范围内
* @param x 横坐标
* @param y 纵坐标
*/
protected isInBounds(x: number, y: number): boolean {
return (
x >= 0 &&
y >= 0 &&
x < this.context.width &&
y < this.context.height
);
}
}
export class ZoneDamageView extends BaseMapDamageView<
IRectRangeParam | IManhattanRangeParam
> {
constructor(
context: IEnemyContext,
private readonly locator: Readonly<ITileLocator>,
private readonly special: Readonly<ISpecial<IZoneValue>>
) {
super(context);
}
getRange(): IRange<IRectRangeParam | IManhattanRangeParam> {
return this.special.value.zoneSquare ? RECT_RANGE : MANHATTAN_RANGE;
}
getRangeParam(): IRectRangeParam | IManhattanRangeParam {
if (this.special.value.zoneSquare) {
return {
h: this.special.value.range * 2 + 1,
w: this.special.value.range * 2 + 1,
x: this.locator.x - this.special.value.range,
y: this.locator.y - this.special.value.range
};
}
return {
cx: this.locator.x,
cy: this.locator.y,
radius: this.special.value.range
};
}
getDamageWithoutCheck(
_locator: ITileLocator
): Readonly<IMapDamageInfo> | null {
return this.createInfo(this.special.value.zone, MapDamageType.Zone);
}
}
export class RepulseDamageView extends BaseMapDamageView<IManhattanRangeParam> {
constructor(
context: IEnemyContext,
private readonly locator: Readonly<ITileLocator>,
private readonly special: Readonly<ISpecial<number>>
) {
super(context);
}
getRange(): IRange<IManhattanRangeParam> {
return MANHATTAN_RANGE;
}
getRangeParam(): IManhattanRangeParam {
return {
cx: this.locator.x,
cy: this.locator.y,
radius: 1
};
}
getDamageWithoutCheck(
locator: ITileLocator
): Readonly<IMapDamageInfo> | null {
if (locator.x === this.locator.x && locator.y === this.locator.y) {
return null;
}
return this.createInfo(this.special.value, MapDamageType.Repulse, {
repulse: new Set([this.locator])
});
}
}
export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
constructor(
context: IEnemyContext,
private readonly locator: Readonly<ITileLocator>,
private readonly special: Readonly<ISpecial<number>>,
private readonly dir: IDirectionDescriptor[] = DIR4
) {
super(context);
}
getRange(): IRange<IRayRangeParam> {
return RAY_RANGE;
}
getRangeParam(): IRayRangeParam {
return {
cx: this.locator.x,
cy: this.locator.y,
dir: this.dir
};
}
getDamageWithoutCheck(
locator: ITileLocator
): Readonly<IMapDamageInfo> | null {
if (locator.x === this.locator.x && locator.y === this.locator.y) {
return null;
}
return this.createInfo(this.special.value, MapDamageType.Layer);
}
}
export class BetweenDamageView extends BaseMapDamageView<IManhattanRangeParam> {
private static readonly DAMAGE = 1;
constructor(
context: IEnemyContext,
private readonly locator: Readonly<ITileLocator>
) {
super(context);
}
getRange(): IRange<IManhattanRangeParam> {
return MANHATTAN_RANGE;
}
getRangeParam(): IManhattanRangeParam {
return {
cx: this.locator.x,
cy: this.locator.y,
radius: 1
};
}
getDamageWithoutCheck(
locator: ITileLocator
): Readonly<IMapDamageInfo> | null {
const deltaX = locator.x - this.locator.x;
const deltaY = locator.y - this.locator.y;
if (Math.abs(deltaX) + Math.abs(deltaY) !== 1) {
return null;
}
if (deltaX <= 0 && deltaY <= 0) {
return null;
}
const otherX = locator.x + deltaX;
const otherY = locator.y + deltaY;
if (!this.isInBounds(otherX, otherY)) {
return null;
}
const other = this.context.getEnemyByLoc(otherX, otherY);
if (!other) {
return null;
}
if (!other.getComputedEnemy().hasSpecial(16)) {
return null;
}
return this.createInfo(BetweenDamageView.DAMAGE, MapDamageType.Between);
}
}
export class AmbushDamageView extends BaseMapDamageView<IManhattanRangeParam> {
constructor(
context: IEnemyContext,
private readonly locator: Readonly<ITileLocator>
) {
super(context);
}
getRange(): IRange<IManhattanRangeParam> {
return MANHATTAN_RANGE;
}
getRangeParam(): IManhattanRangeParam {
return {
cx: this.locator.x,
cy: this.locator.y,
radius: 1
};
}
getDamageWithoutCheck(
locator: ITileLocator
): Readonly<IMapDamageInfo> | null {
if (locator.x === this.locator.x && locator.y === this.locator.y) {
return null;
}
return this.createInfo(0, MapDamageType.Unknown, {
catch: new Set([this.locator])
});
}
}
//#endregion
//#region 转换器
export class MainMapDamageConverter implements IMapDamageConverter {
convert(
enemy: IReadonlyEnemy,
locator: ITileLocator,
context: IEnemyContext
): IMapDamageView<any>[] {
const views: IMapDamageView<any>[] = [];
const zone = enemy.getSpecial<IZoneValue>(15);
if (zone) {
views.push(new ZoneDamageView(context, locator, zone));
}
if (enemy.hasSpecial(16)) {
views.push(new BetweenDamageView(context, locator));
}
const repulse = enemy.getSpecial<number>(18);
if (repulse) {
views.push(new RepulseDamageView(context, locator, repulse));
}
const laser = enemy.getSpecial<number>(24);
if (laser) {
views.push(new LaserDamageView(context, locator, laser));
}
if (enemy.hasSpecial(27)) {
views.push(new AmbushDamageView(context, locator));
}
return views;
}
}
//#endregion
//#region 合并器
export class MainMapDamageReducer implements IMapDamageReducer {
reduce(
info: Iterable<Readonly<IMapDamageInfo>>,
_locator: ITileLocator
): Readonly<IMapDamageInfo> {
let damage = 0;
let type = MapDamageType.Unknown;
let maxDamage = -Infinity;
const extra = {
catch: new Set<ITileLocator>(),
repulse: new Set<ITileLocator>()
};
for (const item of info) {
damage += item.damage;
if (item.damage > maxDamage) {
maxDamage = item.damage;
type = item.type;
}
item.extra.catch.forEach(v => extra.catch.add(v));
item.extra.repulse.forEach(v => extra.repulse.add(v));
}
return {
damage,
extra,
type
};
}
}
//#endregion
+409 -227
View File
@@ -1,243 +1,425 @@
import { EnemyInfo } from '@motajs/types';
import {
defineCommonSerializableSpecial,
defineNonePropertySpecial,
IEnemyManager
} from '@user/data-base';
import { getHeroStatusOn } from '../legacy/hero';
export interface SpecialDeclaration {
code: number;
name: string | ((enemy: EnemyInfo) => string);
desc: string | ((enemy: EnemyInfo) => string);
color: string;
//#region 复合属性值类型
export interface IVampireValue {
vampire: number;
add: boolean;
}
export interface IZoneValue {
zone: number;
zoneSquare: boolean;
range: number;
}
export interface IDegradationValue {
atkValue: number;
defValue: number;
}
export interface IHaloValue {
haloRange: number;
haloSquare: boolean;
hpBuff: number;
atkBuff: number;
defBuff: number;
}
//#endregion
/**
* 怪物特殊属性列表,当前版本中 code 最好与索引保持一致,不然可能会出现问题
* 注册所有怪物特殊属性到 enemyManager
*
* 属性实现位置一览('./'表示当前文件夹 '../'表示上一级文件夹):
* 1. 调参类属性 / 仅影响战斗过程的属性:./damage.ts calDamageWithTurn 函数
* 2. 地图伤害:./damage.ts DamageEnemy.calMapDamage 方法,搜索 calMapDamage 即可搜到
* 3. 光环属性:./damage.ts DamageEnemy.provideHalo 方法,搜索 provideHalo 即可搜到
* 4. 仇恨 / 退化 等战后效果:packages-user/data-fallback/src/battle.ts 中的 afterBattle
* 5. 中毒的每步效果:../state/move.ts HeroMover.onStepEnd 方法,在约 590 行
* 1. 调参类属性 | 仅影响战斗过程的属性:./damage.ts calDamageWithTurn 函数
* 2. 地图伤害:./damage.ts DamageEnemy.calMapDamage 方法
* 3. 光环属性:./damage.ts DamageEnemy.provideHalo 方法
* 4. 仇恨 | 退化 等战后效果:packages-user/data-fallback/src/battle.ts 中的 afterBattle
* 5. 中毒的每步效果:../state/move.ts HeroMover.onStepEnd 方法
* 6. 中毒的瞬移效果:还在脚本编辑的 moveDirectly
* 7. 衰弱效果:../state/hero.ts getHeroStatusOf 方法
* 8. 重生属性:还在脚本编辑的 changingFloor
* 9. 阻击 / 捕捉 的每步效果:packages-user/legacy-plugin-data/src/enemy/checkblock.ts
* 9. 阻击 | 捕捉 的每步效果:packages-user/legacy-plugin-data/src/enemy/checkblock.ts
*/
export const specials: SpecialDeclaration[] = [
{
code: 0,
name: '空',
desc: '空',
color: '#fff'
},
{
code: 1,
name: '先攻',
desc: `怪物首先攻击。`,
color: '#fc3'
},
{
code: 2,
name: '魔攻',
desc: '怪物攻击无视勇士的防御。',
color: '#bbb0ff'
},
{
code: 3,
name: '坚固',
desc: '怪物防御不小于勇士攻击-1。',
color: '#c0b088'
},
{
code: 4,
name: '2连击',
desc: '怪物每回合攻击2次。',
color: '#fe7'
},
{
code: 5,
name: '3连击',
desc: '怪物每回合攻击3次。',
color: '#fe7'
},
{
code: 6,
name: enemy => `${enemy.n ?? 4}连击`,
desc: enemy => `怪物每回合攻击${enemy.n ?? 4}次。`,
color: '#fe7'
},
{
code: 7,
name: '破甲',
desc: enemy =>
`战斗前,附加角色防御的${enemy.breakArmor ?? core.values.breakArmor}%作为伤害。`,
color: '#fe7'
},
{
code: 8,
name: '反击',
desc: enemy =>
`战斗时,怪物每回合附加角色攻击的${enemy.counterAttack ?? core.values.counterAttack}%作为伤害,无视角色防御。`,
color: '#fa4'
},
{
code: 9,
name: '净化',
desc: enemy =>
`战斗前,怪物附加角色护盾的${enemy.purify ?? core.values.purify}倍作为伤害。`,
color: '#80eed6'
},
{
code: 10,
name: '模仿',
desc: `怪物的攻防与勇士相同。`,
color: '#b0c0dd'
},
{
code: 11,
name: '吸血',
desc: enemy => {
const vampire = enemy.vampire ?? 0;
return (
`战斗前,怪物首先吸取角色的${vampire}%生命` +
`(约${Math.floor((vampire / 100) * getHeroStatusOn('hp'))}点)作为伤害` +
(enemy.add ? `,并把伤害数值加到自身生命上。` : `。`)
);
},
color: '#ff00d2'
},
{
code: 12,
name: '中毒',
desc: () =>
`战斗后,角色陷入中毒状态,每一步损失生命${core.values.poisonDamage}点。`,
color: '#9e8'
},
{
code: 13,
name: '衰弱',
desc: () => {
const weak = core.values.weakValue;
if (weak < 1) {
return `战斗后,角色陷入衰弱状态,攻防暂时下降${Math.floor(weak * 100)}%`;
} else {
return `战斗后,角色陷入衰弱状态,攻防暂时下降${weak}点`;
export function registerSpecials(manager: IEnemyManager): void {
// 0 - 空
manager.registerSpecial(
0,
defineNonePropertySpecial(0, {
getSpecialName: () => '空',
getDescription: () => '空',
fromLegacyEnemy: () => {}
})
);
// 1 - 先攻
manager.registerSpecial(
1,
defineNonePropertySpecial(1, {
getSpecialName: () => '先攻',
getDescription: () => '怪物首先攻击。',
fromLegacyEnemy: () => {}
})
);
// 2 - 魔攻
manager.registerSpecial(
2,
defineNonePropertySpecial(2, {
getSpecialName: () => '魔攻',
getDescription: () => '怪物攻击无视勇士的防御。',
fromLegacyEnemy: () => {}
})
);
// 3 - 坚固
manager.registerSpecial(
3,
defineNonePropertySpecial(3, {
getSpecialName: () => '坚固',
getDescription: () => '怪物防御不小于勇士攻击-1。',
fromLegacyEnemy: () => {}
})
);
// 4 - 2连击
manager.registerSpecial(
4,
defineNonePropertySpecial(4, {
getSpecialName: () => '2连击',
getDescription: () => '怪物每回合攻击2次。',
fromLegacyEnemy: () => {}
})
);
// 5 - 3连击
manager.registerSpecial(
5,
defineNonePropertySpecial(5, {
getSpecialName: () => '3连击',
getDescription: () => '怪物每回合攻击3次。',
fromLegacyEnemy: () => {}
})
);
// 6 - n连击
manager.registerSpecial(
6,
defineCommonSerializableSpecial(6, 4, {
getSpecialName: special => `${special.value}连击`,
getDescription: special => `怪物每回合攻击${special.value}次。`,
fromLegacyEnemy: enemy => enemy.n ?? 4
})
);
// 7 - 破甲
manager.registerSpecial(
7,
defineCommonSerializableSpecial(7, 0, {
getSpecialName: () => '破甲',
getDescription: special =>
`战斗前,附加角色防御的${special.value || core.values.breakArmor}%作为伤害。`,
fromLegacyEnemy: enemy => enemy.breakArmor ?? 0
})
);
// 8 - 反击
manager.registerSpecial(
8,
defineCommonSerializableSpecial(8, 0, {
getSpecialName: () => '反击',
getDescription: special =>
`战斗时,怪物每回合附加角色攻击的${special.value || core.values.counterAttack}%作为伤害,无视角色防御。`,
fromLegacyEnemy: enemy => enemy.counterAttack ?? 0
})
);
// 9 - 净化
manager.registerSpecial(
9,
defineCommonSerializableSpecial(9, 0, {
getSpecialName: () => '净化',
getDescription: special =>
`战斗前,怪物附加角色护盾的${special.value || core.values.purify}倍作为伤害。`,
fromLegacyEnemy: enemy => enemy.purify ?? 0
})
);
// 10 - 模仿
manager.registerSpecial(
10,
defineNonePropertySpecial(10, {
getSpecialName: () => '模仿',
getDescription: () => '怪物的攻防与勇士相同。',
fromLegacyEnemy: () => {}
})
);
// 11 - 吸血
manager.registerSpecial(
11,
defineCommonSerializableSpecial<IVampireValue>(
11,
{ vampire: 0, add: false },
{
getSpecialName: () => '吸血',
getDescription: special => {
const { vampire, add } = special.value;
return (
`战斗前,怪物首先吸取角色的${vampire}%生命` +
`(约${Math.floor((vampire / 100) * getHeroStatusOn('hp'))}点)作为伤害` +
(add ? `,并把伤害数值加到自身生命上。` : `。`)
);
},
fromLegacyEnemy: enemy => ({
vampire: enemy.vampire ?? 0,
add: enemy.add ?? false
})
}
},
color: '#f0bbcc'
},
{
code: 14,
name: '诅咒',
desc: '战斗后,角色陷入诅咒状态,战斗无法获得金币和经验。',
color: '#bbeef0'
},
{
code: 15,
name: '领域',
desc: enemy =>
`经过怪物周围${enemy.zoneSquare ? '九宫格' : '十字'}范围内${enemy.range ?? 1}格时自动减生命${enemy.zone ?? 0}点。`,
color: '#c677dd'
},
{
code: 16,
name: '夹击',
desc: '经过两只相同的怪物中间,角色生命值变成一半。',
color: '#b9e'
},
{
code: 17,
name: '仇恨',
desc: () =>
`战斗前,怪物附加之前积累的仇恨值作为伤害;战斗后,释放一半的仇恨值。(每杀死一个怪物获得${core.values.hatred}点仇恨值)。`,
color: '#b0b666'
},
{
code: 18,
name: '阻击',
desc: enemy =>
`经过怪物十字范围内时怪物后退一格,同时对勇士造成${enemy.repulse ?? 0}点伤害。`,
color: '#8888e6'
},
{
code: 19,
name: '自爆',
desc: '战斗后角色的生命值变成1。',
color: '#ff6666'
},
{
code: 20,
name: '无敌',
desc: `角色无法打败怪物,除非拥有十字架。`,
color: '#aaa'
},
{
code: 21,
name: '退化',
desc: enemy =>
`战斗后角色永久下降${enemy.atkValue ?? 0}点攻击和${enemy.defValue ?? 0}点防御。`,
color: 'cyan'
},
{
code: 22,
name: '固伤',
desc: enemy =>
`战斗前,怪物对角色造成${enemy.damage ?? 0}点固定伤害,未开启负伤时无视角色护盾。`,
color: '#f97'
},
{
code: 23,
name: '重生',
desc: `怪物被击败后,角色转换楼层则怪物将再次出现。`,
color: '#dda0dd'
},
{
code: 24,
name: '激光',
desc: enemy => `经过怪物同行或同列时自动减生命${enemy.laser ?? 0}点。`,
color: '#dda0dd'
},
{
code: 25,
name: '光环',
desc: enemy => {
let str = '';
if (enemy.haloRange) {
if (enemy.haloSquare) {
str += '对于该怪物九宫格';
)
);
// 12 - 中毒
manager.registerSpecial(
12,
defineNonePropertySpecial(12, {
getSpecialName: () => '中毒',
getDescription: () =>
`战斗后,角色陷入中毒状态,每一步损失生命${core.values.poisonDamage}点。`,
fromLegacyEnemy: () => {}
})
);
// 13 - 衰弱
manager.registerSpecial(
13,
defineNonePropertySpecial(13, {
getSpecialName: () => '衰弱',
getDescription: () => {
const weak = core.values.weakValue;
if (weak < 1) {
return `战斗后,角色陷入衰弱状态,攻防暂时下降${Math.floor(weak * 100)}%`;
} else {
str += '对于该怪物十字';
return `战斗后,角色陷入衰弱状态,攻防暂时下降${weak}点`;
}
str += `${enemy.haloRange ?? 1}格范围内所有怪物`;
} else {
str += `同楼层所有怪物`;
},
fromLegacyEnemy: () => {}
})
);
// 14 - 诅咒
manager.registerSpecial(
14,
defineNonePropertySpecial(14, {
getSpecialName: () => '诅咒',
getDescription: () =>
'战斗后,角色陷入诅咒状态,战斗无法获得金币和经验。',
fromLegacyEnemy: () => {}
})
);
// 15 - 领域
manager.registerSpecial(
15,
defineCommonSerializableSpecial<IZoneValue>(
15,
{ zone: 0, zoneSquare: false, range: 1 },
{
getSpecialName: () => '领域',
getDescription: special => {
const { zone, zoneSquare, range } = special.value;
return `经过怪物周围${zoneSquare ? '九宫格' : '十字'}范围内${range}格时自动减生命${zone}点。`;
},
fromLegacyEnemy: enemy => ({
zone: enemy.zone ?? 0,
zoneSquare: enemy.zoneSquare ?? false,
range: enemy.range ?? 1
})
}
if (enemy.hpBuff) {
str += `,生命提升${enemy.hpBuff}%`;
)
);
// 16 - 夹击
manager.registerSpecial(
16,
defineNonePropertySpecial(16, {
getSpecialName: () => '夹击',
getDescription: () =>
'经过两只相同的怪物中间,角色生命值变成一半。',
fromLegacyEnemy: () => {}
})
);
// 17 - 仇恨
manager.registerSpecial(
17,
defineNonePropertySpecial(17, {
getSpecialName: () => '仇恨',
getDescription: () =>
`战斗前,怪物附加之前积累的仇恨值作为伤害;战斗后,释放一半的仇恨值。(每杀死一个怪物获得${core.values.hatred}点仇恨值)。`,
fromLegacyEnemy: () => {}
})
);
// 18 - 阻击
manager.registerSpecial(
18,
defineCommonSerializableSpecial(18, 0, {
getSpecialName: () => '阻击',
getDescription: special =>
`经过怪物十字范围内时怪物后退一格,同时对勇士造成${special.value}点伤害。`,
fromLegacyEnemy: enemy => enemy.repulse ?? 0
})
);
// 19 - 自爆
manager.registerSpecial(
19,
defineNonePropertySpecial(19, {
getSpecialName: () => '自爆',
getDescription: () => '战斗后角色的生命值变成1。',
fromLegacyEnemy: () => {}
})
);
// 20 - 无敌
manager.registerSpecial(
20,
defineNonePropertySpecial(20, {
getSpecialName: () => '无敌',
getDescription: () => '角色无法打败怪物,除非拥有十字架。',
fromLegacyEnemy: () => {}
})
);
// 21 - 退化
manager.registerSpecial(
21,
defineCommonSerializableSpecial<IDegradationValue>(
21,
{ atkValue: 0, defValue: 0 },
{
getSpecialName: () => '退化',
getDescription: special => {
const { atkValue, defValue } = special.value;
return `战斗后角色永久下降${atkValue}点攻击和${defValue}点防御。`;
},
fromLegacyEnemy: enemy => ({
atkValue: enemy.atkValue ?? 0,
defValue: enemy.defValue ?? 0
})
}
if (enemy.atkBuff) {
str += `,攻击提升${enemy.atkBuff}%`;
)
);
// 22 - 固伤
manager.registerSpecial(
22,
defineCommonSerializableSpecial(22, 0, {
getSpecialName: () => '固伤',
getDescription: special =>
`战斗前,怪物对角色造成${special.value}点固定伤害,未开启负伤时无视角色护盾。`,
fromLegacyEnemy: enemy => enemy.damage ?? 0
})
);
// 23 - 重生
manager.registerSpecial(
23,
defineNonePropertySpecial(23, {
getSpecialName: () => '重生',
getDescription: () =>
'怪物被击败后,角色转换楼层则怪物将再次出现。',
fromLegacyEnemy: () => {}
})
);
// 24 - 激光
manager.registerSpecial(
24,
defineCommonSerializableSpecial(24, 0, {
getSpecialName: () => '激光',
getDescription: special =>
`经过怪物同行或同列时自动减生命${special.value}点。`,
fromLegacyEnemy: enemy => enemy.laser ?? 0
})
);
// 25 - 光环
manager.registerSpecial(
25,
defineCommonSerializableSpecial<IHaloValue>(
25,
{
haloRange: 0,
haloSquare: false,
hpBuff: 0,
atkBuff: 0,
defBuff: 0
},
{
getSpecialName: () => '光环',
getDescription: special => {
const { haloRange, haloSquare, hpBuff, atkBuff, defBuff } =
special.value;
let str = '';
if (haloRange > 0) {
if (haloSquare) {
str += '对于该怪物九宫格';
} else {
str += '对于该怪物十字';
}
str += `${haloRange}格范围内所有怪物`;
} else {
str += '同楼层所有怪物';
}
if (hpBuff) {
str += `,生命提升${hpBuff}%`;
}
if (atkBuff) {
str += `,攻击提升${atkBuff}%`;
}
if (defBuff) {
str += `,防御提升${defBuff}%`;
}
str += `,线性叠加。`;
return str;
},
fromLegacyEnemy: enemy => ({
haloRange: enemy.haloRange ?? 0,
haloSquare: enemy.haloSquare ?? false,
hpBuff: enemy.hpBuff ?? 0,
atkBuff: enemy.atkBuff ?? 0,
defBuff: enemy.defBuff ?? 0
})
}
if (enemy.defBuff) {
str += `,防御提升${enemy.defBuff}%`;
}
if (enemy.haloAdd) {
str += `,线性叠加。`;
} else {
str += `,不可叠加。`;
}
return str;
},
color: '#e6e099'
},
{
code: 26,
name: '支援',
desc: `当周围一圈的怪物受到攻击时将上前支援,并组成小队战斗。`,
color: '#77c0b6'
},
{
code: 27,
name: '捕捉',
desc: `当走到怪物十字范围内时会进行强制战斗。`,
color: '#ff6f0a'
}
];
)
);
// 26 - 支援
manager.registerSpecial(
26,
defineNonePropertySpecial(26, {
getSpecialName: () => '支援',
getDescription: () =>
'当周围一圈的怪物受到攻击时将上前支援,并组成小队战斗。',
fromLegacyEnemy: () => {}
})
);
// 27 - 捕捉
manager.registerSpecial(
27,
defineNonePropertySpecial(27, {
getSpecialName: () => '捕捉',
getDescription: () => '当走到怪物十字范围内时会进行强制战斗。',
fromLegacyEnemy: () => {}
})
);
}
@@ -0,0 +1,12 @@
export const enum MapDamageType {
/** 未知伤害 */
Unknown,
/** 领域伤害 */
Zone,
/** 激光伤害 */
Layer,
/** 阻击伤害 */
Repulse,
/** 夹击伤害 */
Between
}
+8
View File
@@ -1,6 +1,12 @@
import { ILayerState } from './map';
import { IHeroFollower, IHeroState } from './hero';
import { IRoleFaceBinder } from './common';
import { IEnemyManager } from '@user/data-base';
export interface IGameDataState {
/** 怪物管理器 */
readonly enemyManager: IEnemyManager;
}
export interface IStateSaveData {
/** 跟随者列表 */
@@ -14,6 +20,8 @@ export interface ICoreState {
readonly hero: IHeroState;
/** 朝向绑定 */
readonly roleFace: IRoleFaceBinder;
/** 游戏数据状态 */
readonly data: IGameDataState;
/** id 到图块数字的映射 */
readonly idNumberMap: Map<string, number>;
/** 图块数字到 id 的映射 */