事件中的强制战斗

This commit is contained in:
AncTe committed 2023-07-30 17:04:52 +08:00
1 parent 351e136775
commit fbe81fedd2
10 files changed
+549 -477

No files matched your search

@@ -1,5 +1,10 @@
import { DamageDir, DamageEnemy, getNeedCalDir } from './damage';
import { findDir, has } from './utils';
import {
DamageDir,
DamageEnemy,
getNeedCalDir,
getSingleEnemy
} from './damage';
import { findDir, has } from '../utils';
export function getEnemy(
x: number,
@@ -205,6 +210,24 @@ core.events._sys_battle = function (data: Block, callback?: () => void) {
}
};
core.events._action_battle = function (data, x, y, prefix) {
if (data.id) {
const enemy = getSingleEnemy(data.id as EnemyIds);
// todo: 与不在地图上的怪物战斗
} else {
if (data.floorId != core.status.floorId) {
core.doAction();
return;
}
const [ex, ey] = this.__action_getLoc(data.loc, x, y, prefix) as LocArr;
const dir = findDir(core.status.hero.loc, {
x: ex,
y: ey
}) as DamageDir;
this.battle(ex, ey, dir, true, core.doAction);
}
};
declare global {
interface Events {
/**
@@ -1,6 +1,6 @@
import { equal } from './utils';
import { getHeroStatusOf, getHeroStatusOn } from './hero';
import { Range, RangeCollection } from './range';
import { equal } from '../utils';
import { getHeroStatusOf, getHeroStatusOn } from '../hero';
import { Range, RangeCollection } from '../range';
import {
backDir,
checkV2,
@@ -9,7 +9,7 @@ import {
has,
manhattan,
ofDir
} from './utils';
} from '../utils';
interface HaloType {
square: {
@@ -968,11 +968,11 @@ const skills: [unlock: string, condition: string][] = [
export function getNeedCalDir(
x?: number,
y?: number,
floorId: FloorIds = core.status.floorId,
floorId?: FloorIds,
hero: Partial<HeroStatus> = core.status.hero
): (Dir | 'none')[] {
// 第一章或序章,或者没有指定怪物位置,或者没开自动定位,用不到这个函数
if (flags.chapter < 2 || !has(x) || !has(y)) {
if (flags.chapter < 2 || !has(x) || !has(y) || !floorId) {
return ['none'];
}
@@ -1105,6 +1105,15 @@ export function ensureFloorDamage(floorId: FloorIds) {
floor.enemy ??= new EnemyCollection(floorId);
}
export function getSingleEnemy(id: EnemyIds) {
const e = core.material.enemys[id];
const enemy = new DamageEnemy(e);
enemy.calAttribute();
enemy.getRealInfo();
enemy.calDamage(core.status.hero, false)[0];
return enemy;
}
declare global {
interface PluginDeclaration {
damage: {
+2 -2
View File
@@ -17,8 +17,8 @@ import * as study from './study';
import * as towerBoss from './towerBoss';
import * as utils from './utils';
import * as chase from './chase';
import * as damage from './damage';
import * as battle from './battle';
import * as damage from './enemy/damage';
import * as battle from './enemy/battle';
export {
halo,
+1 -1
View File
@@ -1,4 +1,4 @@
import { ensureFloorDamage } from './damage';
import { ensureFloorDamage } from './enemy/damage';
core.control.updateDamage = function (floorId = core.status.floorId, ctx) {
if (!floorId || core.status.gameOver || main.mode !== 'play') return;