feedback5: merge O20 — 自选 kits for 多萝西 (with her 共振装置), 予愿安洁莉娜 and 黑键; engine: the 缚地 status (groundbind: a flyer that 浮空 can land on, weight halving; 掠海漂移体 / 吉兆飞鳞 drop on it); golden: only diy moved

This commit is contained in:
sganggs committed 2026-10-06 14:13:39 +08:00
commit b4d10ff1b1
16 files changed
+2713 -159

No files matched your search

+7 -6
View File
@@ -135,8 +135,8 @@ export class BattleStatus {
* handlers may cancel it or change `duration` / `value`. Official rules (buffs.js STATUS): 抵抗 (the `resist` status)
* shortens the RESIST_STATUSES by its value (default half; applied after `beforeStatus`; `resistApplied` skips that
* pass — the cold-on-cold 冻结 below already used post-抵抗 lengths). A second 寒冷 while 寒冷 remains applies 冻结 for
* max(remaining, this cold after 抵抗) (PRTS 术语释义 寒冷 「持续时间取双方之中最高」). 浮空 lasts half as long on units heavier
* than LEVITATE_HALF_WEIGHT (current massLevel); 冻结's RES cut hits enemies only; 麻痹 adds stacks; "同名效果取最高"
* max(remaining, this cold after 抵抗) (PRTS 术语释义 寒冷 「持续时间取双方之中最高」). 浮空 and 缚地 last half as long on units
* heavier than LEVITATE_HALF_WEIGHT (current massLevel); 冻结's RES cut hits enemies only; 麻痹 adds stacks; "同名效果取最高"
* statuses (`valued`) keep the strongest value — a weaker application only extends past the stronger one's end (it
* then resumes); `stackAs` = the value such an application competes with instead of its own (its effect stays
* `value`): an effect the game stacks as another strength — Raidian S3's 虚弱, PRTS 备注 "在叠加时视为90%(1级~6级)/80%
@@ -162,9 +162,9 @@ export class BattleStatus {
const immune = target.def && target.def.immune;
if (!opts.force && tpl.immune && immune && immune.has(tpl.immune)) return false;
// 浮空 Buff (PRTS 异常效果: "若单位数据上为飞行单位且不持有缚地异常或是持有浮空异常则Buff取消"; 行动方式 "行动类型(数据)为
// 飞行的单位、以及已持有浮空异常的单位无法被施加浮空Buff"): refused on data flyers (`motion` FLY) and units already
// levitated — a hovering 近地悬浮 enemy is WALK in its data, so it can be levitated (no 缚地 / 浮空强化 in this mode)
if (key === 'levitate' && (target.motion === 'FLY' || target.s.flags.levitate)) return false;
// 飞行的单位、以及已持有浮空异常的单位无法被施加浮空Buff"): refused on data flyers (`motion` FLY) that hold no 缚地 and on
// units already levitated — a hovering 近地悬浮 enemy is WALK in its data, so it can be levitated (no 浮空强化 in this mode)
if (key === 'levitate' && ((target.motion === 'FLY' && !target.s.flags.groundbind) || target.s.flags.levitate)) return false;
if (this._hooks.beforeStatus) {
const c = this.emit('beforeStatus', { source: opts.source ?? null, target, status: key, duration, value, cancel: false });
if (c.cancel || !target.alive) return false;
@@ -177,7 +177,8 @@ export class BattleStatus {
const rv = this.resistOf(target);
if (rv > 0) duration *= 1 - rv;
}
if (key === 'levitate' && target.s.massLevel > LEVITATE_HALF_WEIGHT) duration /= 2;
// 浮空 / 缚地 (ba.levitate, ba.groundbind): "对重量大于3的单位持续时间减半"
if ((key === 'levitate' || key === 'groundbind') && target.s.massLevel > LEVITATE_HALF_WEIGHT) duration /= 2;
if (!(duration > 0)) return false;
if (key === 'cold' && target.findBuff('cold') && !(immune && immune.has('frozen'))) {
// PRTS 术语释义 寒冷: 友方寒冷 pairs into 冻结, 「持续时间取双方之中最高」. `duration` is this cold after 抵抗;
+9 -2
View File
@@ -42,6 +42,8 @@ export const FLAG_KEYS = Object.freeze([
// 自缚 (the unit's own immobility: 守墓石像's 转换模式, the 自缚 leaders) beside its `noMove` — 束缚 sets noMove too, and
// only 自缚 makes a unit "不视为可达目标" for 余 S2's teleport (PRTS 余 S2 备注)
'selfBound', 'healFree', 'stealthOff',
// 缚地 (status `groundbind`): an enemy air unit counts as a ground unit meanwhile (Unit.isFlying)
'groundbind',
]);
/**
@@ -90,6 +92,11 @@ export const STATUS = Object.freeze({
// 浮空: 变为空中单位 (Unit.isFlying),无法移动、攻击及使用技能; 对重量大于3的单位持续时间减半; the state holds 不可阻挡 +
// 失衡免疫 (noDisplace: "不会被位移影响", PRTS 异常效果)
levitate: { flags: { levitate: true, stun: true, unblockable: true, noDisplace: true }, immune: 'levitate' },
// 缚地 (gamedata_const ba.groundbind "目标变为地面单位,无法移动;使部分近地悬浮敌人掉落;对重量大于3的单位持续时间减半"):
// an air unit (data flyer, 近地悬浮) counts as a ground unit (Unit.isFlying: melee operators hit it, ground blockers
// block it) and cannot move; half duration on units with massLevel > 3 (Battle.applyStatus, as 浮空); a 浮空 still
// lands on it (PRTS 异常效果 "若单位数据上为飞行单位且不持有缚地异常…则Buff取消"). 予愿安洁莉娜 S2 (kits/ops/op-aglna2.js)
groundbind: { flags: { groundbind: true, noMove: true }, mods: { moveMul: 0 } },
// 麻痹: value = stacks (default 1, max 3); each stack cancels one enemy normal attack; lasts until consumed; honours
// 麻痹免疫 (enemy_database palsyImmune, e.g. 假想敌:铳 — PRTS 元素: a 神经 burst gives 麻痹 only "若单位不具有麻痹免疫")
palsy: { palsy: true, immune: 'palsy' },
@@ -120,12 +127,12 @@ export const STATUS = Object.freeze({
});
/**
* Control statuses (异常状态) shortened by 抵抗: 晕眩 冻结 寒冷 沉睡 恐惧 战栗 诱导 浮空 束缚 沉默 缴械 停顿 减速. The
* Control statuses (异常状态) shortened by 抵抗: 晕眩 冻结 寒冷 沉睡 恐惧 战栗 诱导 浮空 束缚 沉默 缴械 停顿 减速 缚地. The
* official term lists 晕眩/寒冷/冻结/恐惧/诱导…; the rest follow the operator kits that grant 抵抗 [ASSUMED]. 麻痹 is
* stack-based: it decays instead (RESIST_PALSY_DECAY).
*/
export const RESIST_STATUSES = Object.freeze(new Set(['stun', 'freeze', 'cold', 'sleep', 'fear', 'tremble', 'attract', 'levitate',
'bind', 'silence', 'disarm', 'sluggish', 'slow']));
'bind', 'silence', 'disarm', 'sluggish', 'slow', 'groundbind']));
/** Statuses that should be reported to clients as `['status', id, key, on]`. */
export const VISIBLE_STATUS = new Set(Object.keys(STATUS));
+2 -2
View File
@@ -58,13 +58,13 @@ const SYUFO_CRAWL_STUN = 0.5;
/**
* 掠海漂移体 (PRTS): 初始模式 近地悬浮 + 失衡免疫, 不会攻击飞行单位; 受晕眩/无法行动/沉睡/冻结/缚地影响后进入爬行模式 for
* good and is stunned 0.5 s — a ground unit (blockable, melee operators hit it) that "仅进行阻挡攻击" (only its blocker).
* The engine has 晕眩 / 冻结 / 沉睡 (no operator here applies 无法行动 or 缚地). Erosion on every attack.
* The engine has 晕眩 / 冻结 / 沉睡 / 缚地 (予愿安洁莉娜 S2; no operator here applies 无法行动). Erosion on every attack.
*/
function kitSyufo(ab) {
return [float(), ep('erosion', T(ab, 'EpDamage.attack@ep_damage_ratio') ?? 0), {
spawn(b, e) { e.profile.canTarget = (u) => !u.isFlying; },
status(c, b, e, a) {
if (a.crawl || !(c.status === 'stun' || c.status === 'freeze' || c.status === 'sleep')) return;
if (a.crawl || !(c.status === 'stun' || c.status === 'freeze' || c.status === 'sleep' || c.status === 'groundbind')) return;
a.crawl = true;
setFloat(b, e, false);
e.profile.melee = true;
+3 -3
View File
@@ -103,7 +103,7 @@ function kitParrot(ab) {
},
status(c, b, e, a) {
if (c.status === 'freeze') { a.chill = true; return; }
if (a.down || !(c.status === 'stun' || c.status === 'sleep')) return;
if (a.down || !(c.status === 'stun' || c.status === 'sleep' || c.status === 'groundbind')) return;
a.down = true;
setFloat(b, e, false);
b.removeBuff(e, 'ab:parrotRun');
@@ -114,8 +114,8 @@ function kitParrot(ab) {
tick(b, e, a) {
if (a.chill && !e.s.flags.freeze) { a.chill = false; b.applyStatus(e, 'stun', { duration: PARROT_CHILL_STUN, source: null }); }
// "离开上述异常效果影响后进入初始模式": s.flags.stun also holds while asleep / frozen (units.js), so a sleep that
// outlasts the mode stun keeps it down
if (a.down && !e.s.flags.stun) {
// outlasts the mode stun keeps it down; so does a 缚地 (flag `groundbind`)
if (a.down && !e.s.flags.stun && !e.s.flags.groundbind) {
a.down = false;
b.removeBuff(e, 'ab:parrotDown');
b.removeBuff(e, 'ab:parrotRun');
+3
View File
@@ -136,6 +136,9 @@ export const OPERATOR_KIT_FILES = Object.freeze([
'op-lmlee.js',
'op-weedy.js',
'op-wang.js',
'op-doroth.js',
'op-aglna2.js',
'op-ebnhlz.js',
]);
/**
+378
View File
@@ -0,0 +1,378 @@
// server/sim/content/kits/ops/op-aglna2.js — 予愿安洁莉娜 (char_1015_aglna2) 自选 operator kit: 6★ 巡空者 (特种), an
// owned-6★ pick of the tier-5 and tier-6 自选 slots (no module); every skill, both talents, the trait at every form, and
// the kit of her S3 marker “一会儿见!” (token_10071_aglna2_agairp). Kit contract and the 自选 rules: ../README.md ("How
// to add an operator (自选)").
//
// Forms (data/backups.json units.char_1015_aglna2): normal = E2 Lv1, skills at rank 4; elite = E2 Lv60, rank 7 — the
// owner's decision of 2026-10-05; she has no module. Potential 0 [ASSUMED: no account]. Sources: character_table /
// skill_table / token_table (zh_CN, as built into backups.json), PRTS 予愿安洁莉娜 / “一会儿见!” (备注), 分支特性信息 §巡空者,
// gamedata_const (ba.liftoff / ba.levitate / ba.groundbind / ba.airprotect / ba.weightless), and the client's battle data
// (charpack char_1015_aglna2: modes, MassLossAura, the trait / talent buffs; skills skchr_aglna2_1–3; projectiles
// projectile_chr_aglna2_s2_fly / _s3_fly; buff templates aglna2_tr, aglna2_t_1[self], aglna2_t_1[enemy], aglna2_t_2,
// aglna2_s_2[*], aglna2_s_3[*]).
// - Trait (巡空者) "起飞后能够阻挡2个飞行敌人" (aglna2_tr: block mode WALK in her default mode, FLY in every skill mode):
// melee physical, hits air units (分支特性信息 "攻击可对空"), blocks 2. On the ground she blocks ground enemies only (the
// profession's permanent blockFly is removed, as 蒂比's kit does); airborne (起飞, flags `liftoff` + `blockFly`: every
// skill below while it runs) she blocks flyers only and no ground enemy selects her (对地规避: aglna2_t_1[motion_target]
// MOTION_TARGET_FREE). Taking off releases the ground enemies she blocked, landing the flyers.
// - T1 飘浮大地之上 "攻击额外造成相当于攻击力25%的法术伤害,攻击重量较轻(小于等于3)的敌人时则额外造成相当于攻击力35%的法术伤害;
// 处于起飞状态时使攻击范围内的敌人失重" (bb atk_scale_lo / atk_scale_hi / mass_level): every damage instance she outputs that is
// no additional (ADDITION) or continuous damage (备注 "可于任何来源于予愿安洁莉娜的、附加伤害以外的伤害的输出伤害时触发";
// aglna2_t_1[self] ON_OUTPUT_MODIFIER) adds ATK × atk_scale_hi arts on a target whose current weight (失重 included) is at
// most mass_level, else × atk_scale_lo — also when that hit is dodged or absorbed (an output, [ASSUMED]: the hooks
// `damaged` and `dodge`), never on a target with no HP left. While she is airborne every selectable enemy of her attack
// range (ground and air: MassLossAura targetMotion 3) is 失重 (weight −1 level; 同名效果不可叠加: none of hers while
// another 失重 holds it), gone when it leaves the range or she lands (备注 "此天赋的失重效果仅判断自身是否能够阻挡飞行敌人").
// - T2 天穹间的舞步 "在场时,所有处于起飞状态的友方干员攻击力+13%且阻挡时每秒回复8%的最大生命值" (bb atk,
// hp_recovery_per_sec_by_max_hp_ratio): every 0.2 s (the client ability `_interval`) each allied operator in the air
// block mode (起飞: flag `liftoff`, her included) gets ATK +atk and, while it blocks, 生命回复速度 +ratio × max HP
// (hpRegenRatio — 备注 "生命回复的效果为增加“生命回复速度(百分比)”属性,不受治疗加成和禁疗影响": no heal, 禁疗 does not stop it).
// - S1 极速送达 (被动 ON_DEPLOY, 56 s): a timed deployment skill (activateOnDeploy, trigger NEVER): she takes off at each
// deployment for its duration — range 3-6, ATK +atk, attacks 2 targets (attack@max_target) — and lands when it ends
// (aglna2_s_1[switch_mode] → S1_Landing; the landing clip's length is not modelled).
// - S2 重力自定义 (MANUAL, 22 s, data ACTIVE_RANGE on its 3-10): she takes off at once; for chant_duration (2.5) s she glides
// (吟唱: no attack, 无敌, the control statuses refused — 备注 "持有无敌、不可阻挡、晕眩/冻结/小睡/沉睡免疫,一减状态抵抗率×0")
// while a sweep released from her tile along her direction (备注 "宽3.0×厚1.3、飞行速度6.0的弹道…终点位于前方至多4.0格"; it
// goes through walls) hits each selectable enemy once: an air unit 缚地 buff_duration_ground_bound s, any other 浮空
// buff_duration_levitate s (aglna2_s_2[enemy]: CheckMotionMode FLY; halved on weight > 3 by both terms). The 22 s,
// ATK +atk and the attack interval change (a flat base_attack_time s) run from the cast (the client's
// `_buffsWhenStartChant` carries them); range 3-10, attacks turn arts and hit attack@max_target targets. `mass_level`
// (10) has no text and no node uses it here [unused — open question].
// - S3 酸橙的心事 (MANUAL, 30 / 31 bullets, data ACTIVE_RANGE on its 3-9): she takes off; ATK +atk; 对空庇护
// (damage_resistance: physical / arts damage whose source is an air unit ×(1 − ratio) — aglna2_s_3[damage_reduce]);
// range 3-9 and the 8 tiles around her (attack@attack_range_id x-4); each attack hits at most attack@max_walk_target
// ground enemies and fills up to attack@max_target with flyers (her two selectors: ground ≤ 3, air) for attack@atk_scale
// × ATK physical; every flyer of her range moves ×(1 − move_speed) (备注 "对飞行单位的减速效果无视其可选性"). The move (备注;
// aglna2_s_3[mode], every 0.1 s): blocking nothing, with an unblocked flyer she can block inside the ORIGINAL 3-9 — of
// her deployment tile and direction —, she flies to its tile (not a start / end tile, any deploy type but not
// impassable, empty or holding her marker) at 2 tiles/s ([ASSUMED]: the client's movement `_finalSpeed`), meanwhile
// 无敌, 禁疗, disarmed, blocking nothing and refusing control statuses (aglna2_s_3[fly_passive]), and lands there by a
// 【移动】 (Battle.moveRedeploy: a new deployment, the skill and its bullets kept), re-picking the best target on arrival
// [ASSUMED: the client re-selects every 0.1 s in flight]; her attack range stays the original 3-9 — anchored on her
// deployment tile (extra range keys) — plus the 8 tiles around her (备注 "不影响攻击范围"; the client's located-range
// abilities). Off her deployment tile, “一会儿见!” marks it (备注 "每次移动后若不位于初始位置且初始位置不存在标志物…部署一个").
// When the skill ends she goes back there by a 【移动】 (the marker leaves) unless she is knocked out.
// - “一会儿见!” (its kit below): 无敌, 孤立, 不可选中 by enemies, blocks nothing, no attack (PRTS 备注; token_aglna2_passive).
// It is the skill's placeholder (skchr_aglna2_3 `_placeholderTokenKey`), not a player's summon: the data marks it
// placeable (the prep hands a piece out with S3 — open question), so a placed piece is used as that marker and never
// deploys by itself (`deferDeploy`; its tile stays reserved); without one the skill summons it.
import { num, talentBb, skillRec, batMod, up, installAura, toggleBuff } from '../shared/tier1.js';
import { absoluteRangeKeys, canTargetEnemy, sortEnemyTargets } from '../../../targeting.js';
import { bodyInKeys } from '../../../body.js';
import { hasHp } from '../../../damage.js';
import { RESIST_STATUSES } from '../../../buffs.js';
import { TICK } from '../../../constants.js';
const S1 = 'skchr_aglna2_1';
const S2 = 'skchr_aglna2_2';
const S3 = 'skchr_aglna2_3';
/** “一会儿见!”, the marker of her deployment tile while S3 has moved her off it. */
export const MARKER = 'token_10071_aglna2_agairp';
/** 起飞 (ba.liftoff): air block mode + 对地规避 (as 蒂比's kit). */
const LIFTOFF = Object.freeze({ liftoff: true, blockFly: true });
/** range x-4: her tile and the eight around it (S3 attack@attack_range_id). */
const X4 = Object.freeze([[1, -1], [1, 0], [1, 1], [0, -1], [0, 0], [0, 1], [-1, -1], [-1, 0], [-1, 1]]);
const ANY = Object.freeze({ canHitFly: true });
/** S2's sweep (PRTS 备注; projectile_chr_aglna2_s2_fly `_speed` 6, `_distanceMax` 4). */
const GLIDE_SPEED = 6, GLIDE_DIST = 4, GLIDE_HALF_WIDTH = 1.5, GLIDE_HALF_THICK = 0.65;
/** S3's flight speed (projectile_chr_aglna2_s3_fly `_finalSpeed` 2) [ASSUMED constant]. */
const MOVE_SPEED = 2;
/** S3's move check (aglna2_s_3[mode] / the flight's `_selectorRefreshInterval`). */
const MOVE_CHECK = 0.1;
/** T2's refresh (the client ability `_interval` 0.2). */
const DANCE_IV = 0.2;
const CHANT_KEY = 'aglna2:chant';
const MOVE_KEY = 'aglna2:move';
const TAG_EXTRA = 'aglna2:extra';
const bbOf = (chess, id) => skillRec(chess, id)?.bb ?? {};
const skillOn = (unit, id) => !!(unit.skill && unit.skill.active && unit.skill.id === id);
const keyOf = (r, c) => `${r},${c}`;
function takeOff(battle, unit) {
battle.releaseBlocked(unit); // 起飞 "不阻挡地面敌人": the ground enemies she held walk on
battle.fx('takeoff', { x: unit.x, y: unit.y, id: unit.id });
}
function land(battle, unit) { battle.releaseBlocked(unit); } // the flyers she held
/** “一会儿见!”'s kit: 无敌, 孤立, not selectable by enemies, blocks nothing, no attack, no skill. */
function markerKit() {
return {
skill: null,
trait: { noAttack: true },
install(battle, t) {
battle.addBuff(t, { key: 'trait:aglna2:marker', flags: { invulnerable: true, untargetable: true, isolated: true, noBlock: true, noHeal: true }, persist: true, allowDead: true });
},
};
}
/** S2's sweep from (x0, y0) along `fwd`: each selectable enemy once — an air unit 缚地 `gb` s, any other 浮空 `lev` s. */
function glide(battle, unit, lev, gb) {
const [fr, fc] = unit.fwd;
const x0 = unit.x, y0 = unit.y, t0 = battle.time;
const hit = new Set();
const sweep = () => {
const lead = Math.min(GLIDE_DIST, (battle.time - t0) * GLIDE_SPEED);
for (const e of battle.enemies) {
if (hit.has(e) || !canTargetEnemy(unit, e, ANY)) continue;
const dx = e.x - x0, dy = e.y - y0;
const along = dx * fc + dy * fr, side = Math.abs(dx * fr - dy * fc);
if (side > GLIDE_HALF_WIDTH + 1e-9 || along < -GLIDE_HALF_THICK - 1e-9 || along > lead + GLIDE_HALF_THICK + 1e-9) continue;
hit.add(e);
if (e.isFlying) battle.applyStatus(e, 'groundbind', { duration: gb, source: unit });
else battle.applyStatus(e, 'levitate', { duration: lev, source: unit });
}
return lead >= GLIDE_DIST;
};
battle.fx('dash', { x: x0, y: y0, id: unit.id, tx: x0 + fc * GLIDE_DIST, ty: y0 + fr * GLIDE_DIST, t: GLIDE_DIST / GLIDE_SPEED });
if (sweep()) return;
battle.every(TICK, (b, sched) => { if (sweep()) sched.cancel(); });
}
export default {
char_1015_aglna2: (bb, chess) => {
const t0 = talentBb(chess, 0); // atk_scale_lo / atk_scale_hi / mass_level
const t1 = talentBb(chess, 1); // atk / hp_recovery_per_sec_by_max_hp_ratio
const b1 = bbOf(chess, S1), b2 = bbOf(chess, S2), b3 = bbOf(chess, S3);
const r1 = skillRec(chess, S1), r2 = skillRec(chess, S2), r3 = skillRec(chess, S3);
const g39 = (r3?.rangeGrid ?? []).map((p) => [p[0], p[1]]);
const seen = new Set(g39.map(([r, c]) => keyOf(r, c)));
const g39x4 = [...g39, ...X4.filter(([r, c]) => !seen.has(keyOf(r, c))).map((p) => [p[0], p[1]])];
const maxT3 = Math.max(1, Math.floor(num(b3['attack@max_target'], 4)));
const maxWalk3 = Math.max(0, Math.floor(num(b3['attack@max_walk_target'], maxT3)));
// S3's running range: the original 3-9 with the eight tiles around her; once she has moved, the eight around her and
// the 3-9 of her deployment tile (extra range keys) — a per-unit object Battle._refreshRange reads
const s3Targeting = { rangeGrid: g39x4, maxTargets: maxT3 };
// S3's per-activation state: her deployment tile / direction, the flight under way, the marker
let st = null;
/** The original 3-9 of her deployment tile (S3 "原技能范围"), grown by her permanent rangeExtend. */
const keys39 = (unit) => absoluteRangeKeys(g39, st.r0, st.c0, st.dir0, unit.s.baseRangeExtend || 0);
const atHome = (unit) => !!st && unit.tileR === st.r0 && unit.tileC === st.c0;
/** May she (blocking nothing) block flyer `e` once there: unblocked, no 无法被阻挡 state, room for its weight. */
const blockable = (unit, e) => !e.blockedBy && !e.s.flags.unblockable && !e.s.flags.levitate && !e.s.flags.fear && !e.s.flags.attract
&& (e.blockWeight ?? 1) <= unit.s.blockCnt;
/** A tile her S3 may take: on the field, not impassable, no start / end tile, not hers, empty or her marker's. */
function tileOk(battle, unit, r, c) {
if (!battle.grid.inRect(r, c) || (r === unit.tileR && c === unit.tileC)) return false;
const tile = battle.grid.tile(r, c);
if (tile.pass === 'NONE' || tile.special) return false;
if (battle.downOn(r, c)) return false;
const occ = battle.unitAt(r, c);
return !occ || !occ.alive || (!!st && occ === st.marker);
}
/** The flyer (and its tile) her S3 should fly to now, or null. */
function moveTarget(battle, unit) {
const cands = battle.enemiesInKeys(keys39(unit), unit, ANY).filter((e) => e.isFlying && blockable(unit, e));
sortEnemyTargets(battle, unit, cands, null);
for (const e of cands) {
const r = Math.round(e.y), c = Math.round(e.x);
if (tileOk(battle, unit, r, c)) return { e, r, c };
}
return null;
}
function placeMarker(battle, unit) {
if (!st || (st.marker && st.marker.alive)) return;
const piece = battle.allyUnits.find((t) => t.kind === 'token' && t.defId === MARKER && t.ownerUnit === unit && t.uid != null && !t.alive && !t.removed);
if (piece && battle.redeploy(piece, { free: true, tile: [st.r0, st.c0] })) { st.marker = piece; return; }
st.marker = battle.spawnToken(unit, MARKER, st.r0, st.c0, { kit: markerKit() });
}
function dropMarker(battle) {
const m = st && st.marker;
if (m && m.alive) battle.retreat(m, { reason: 'expired', permanent: m.uid == null });
if (st) st.marker = null;
}
/** Her S3 range for where she stands: the 3-9 ∪ x-4 at home; away, the x-4 here + the anchored 3-9 (extra keys). */
function anchorRange(battle, unit) {
if (!st || atHome(unit)) {
s3Targeting.rangeGrid = g39x4;
battle.setExtraRange(unit, null);
} else {
s3Targeting.rangeGrid = X4;
battle.setExtraRange(unit, keys39(unit));
}
}
/** A 【移动】 of S3 onto (r, c); the marker follows the rules of the 备注. */
function moveTo(battle, unit, r, c) {
const home = r === st.r0 && c === st.c0;
if (home) dropMarker(battle);
const from = { x: unit.x, y: unit.y };
if (!battle.moveRedeploy(unit, r, c)) return false;
battle.fx('blink', { x: unit.x, y: unit.y, id: unit.id, fx: from.x, fy: from.y });
if (!home) placeMarker(battle, unit);
anchorRange(battle, unit);
return true;
}
return {
trait: { blockFly: false }, // the profession's permanent air block: only while airborne here
skills: {
[S1]: {
kind: 'duration', activateOnDeploy: true, spCost: 0, spType: 'none', trigger: 'NEVER',
mods: { atkPct: num(b1.atk) }, flags: LIFTOFF,
targeting: { rangeGrid: r1?.rangeGrid ?? null, maxTargets: Math.max(1, Math.floor(num(b1['attack@max_target'], 1))) },
onStart({ battle, unit }) { takeOff(battle, unit); },
onEnd({ battle, unit }) { land(battle, unit); },
},
[S2]: {
kind: 'duration',
mods: { atkPct: num(b2.atk), batPct: batMod(b2.base_attack_time, chess) }, flags: LIFTOFF,
targeting: { rangeGrid: r2?.rangeGrid ?? null, maxTargets: Math.max(1, Math.floor(num(b2['attack@max_target'], 1))) },
attack: { dmgType: 'arts' },
onStart({ battle, unit }) {
takeOff(battle, unit);
const chant = num(b2.chant_duration);
if (chant > 0) battle.addBuff(unit, { key: CHANT_KEY, duration: chant, flags: { disarm: true, invulnerable: true }, tags: ['skill'] });
glide(battle, unit, num(b2.buff_duration_levitate), num(b2.buff_duration_ground_bound));
},
onEnd({ battle, unit }) { battle.removeBuff(unit, CHANT_KEY); land(battle, unit); },
},
[S3]: {
kind: 'ammo',
ammo: Math.max(1, Math.floor(num(b3['attack@trigger_time'], 1))),
mods: { atkPct: num(b3.atk) }, flags: LIFTOFF,
targeting: s3Targeting,
attack: { atkScale: num(b3['attack@atk_scale'], 1) },
onStart({ battle, unit, skill }) {
takeOff(battle, unit);
st = { r0: unit.tileR, c0: unit.tileC, dir0: unit.dir, act: skill.activations, flight: null, marker: null };
s3Targeting.rangeGrid = g39x4;
},
onEnd({ battle, unit, reason }) {
if (st) st.flight = null;
battle.removeBuff(unit, MOVE_KEY);
dropMarker(battle);
// back to her deployment tile by a 【移动】 (备注 "技能结束时若位于初始位置则降落;否则执行一次以初始位置为目标的返回移动")
if (reason !== 'death' && st && !atHome(unit) && unit.alive && unit.deployed) {
const from = { x: unit.x, y: unit.y };
if (battle.moveRedeploy(unit, st.r0, st.c0)) battle.fx('blink', { x: unit.x, y: unit.y, id: unit.id, fx: from.x, fy: from.y });
}
st = null;
s3Targeting.rangeGrid = g39x4;
battle.setExtraRange(unit, null);
land(battle, unit);
},
},
},
talents: [
{ install(battle, unit) { // 飘浮大地之上: the arts addition on every output of hers; 失重 in her range while airborne
battle.removeBuff(unit, 'trait:skywalker'); // (the profession's permanent blockFly)
const hi = num(t0.atk_scale_hi), lo = num(t0.atk_scale_lo), mass = num(t0.mass_level, 3);
const extra = (target, dmg) => {
if (!up(unit) || !target || target.side !== 'enemy' || !target.alive || !hasHp(target) || !dmg) return;
if (dmg.type === 'element' || dmg.type === 'elemental' || (dmg.tags && (dmg.tags.includes(TAG_EXTRA) || dmg.tags.includes('dot')))) return;
const s = target.weight <= mass ? hi : lo;
if (s > 0) battle.dealDamage(unit, target, { amount: unit.s.atk * s, type: 'arts', tags: ['talent', TAG_EXTRA] });
};
battle.on('damaged', (ctx) => { if (ctx.source === unit && ctx.type !== 'element') extra(ctx.target, ctx.dmg); }, { owner: unit });
battle.on('dodge', (ctx) => { if (ctx.source === unit) extra(ctx.target, ctx.dmg); }, { owner: unit });
// 失重 (同名效果不可叠加) on every selectable enemy of her range while she is airborne
const myKey = `aglna2:weightless:${unit.id}`;
battle.on('tick', () => {
const on = up(unit) && !!unit.s.flags.liftoff;
const inRange = on ? new Set(battle.enemiesInKeys(unit.rangeKeys, unit, ANY)) : null;
for (const e of battle.enemies) {
const mine = e.findBuff(myKey);
const want = on && e.alive && inRange.has(e) && !e.buffs.some((b) => b.status === 'weightless' && b.key !== myKey);
if (want && !mine) battle.addBuff(e, { key: myKey, status: 'weightless', visible: true, mods: { massFlat: -1 }, source: unit });
else if (!want && mine) battle.removeBuff(e, mine);
}
}, { owner: unit });
} },
{ install(battle, unit) { // 天穹间的舞步: airborne allied operators ATK +atk, and 生命回复速度 while they block
const atk = num(t1.atk), regen = num(t1.hp_recovery_per_sec_by_max_hp_ratio);
if (!(atk > 0) && !(regen > 0)) return;
installAura(battle, unit, {
key: 'talent:aglna2:dance', value: atk, interval: DANCE_IV,
select: (a) => a.kind === 'op' && !!a.s.flags.liftoff,
mods: (a) => (regen > 0 && a.blocking.length > 0 ? { atkPct: atk, hpRegenRatio: regen } : { atkPct: atk }),
});
} },
],
install(battle, unit) {
const sid = unit.skill?.id;
// the 吟唱 (S2) and the flight (S3) refuse every control status (一减状态抵抗率×0)
battle.on('beforeStatus', (ctx) => {
if (ctx.target !== unit || !RESIST_STATUSES.has(ctx.status) || (ctx.source && ctx.source.side === 'ally')) return;
if (unit.findBuff(CHANT_KEY) || unit.findBuff(MOVE_KEY)) ctx.cancel = true;
}, { owner: unit });
// a placed “一会儿见!” piece is S3's marker: it never deploys by itself
for (const t of battle.allyUnits) {
if (t.kind !== 'token' || t.defId !== MARKER || t.ownerUnit !== unit || t.alive || t.deployed) continue;
if (t.kit) battle.offOwner(t);
battle._setupUnit(t, markerKit());
if (sid === S3) t.deferDeploy = true;
}
if (sid !== S3) return;
const dr = num(b3.damage_resistance), slow = -num(b3.move_speed);
const aspdB = num(b3['aglna2_s_3[blocked].attack_speed']), aspdU = num(b3['aglna2_s_3[unblocked].attack_speed']);
if (aspdB) toggleBuff(battle, unit, 'skill:aglna2:blocked', () => skillOn(unit, S3) && unit.blocking.length > 0, { aspd: aspdB });
if (aspdU) toggleBuff(battle, unit, 'skill:aglna2:unblocked', () => skillOn(unit, S3) && unit.blocking.length === 0, { aspd: aspdU });
// 对空庇护: physical / arts damage from an air unit ×(1 − damage_resistance)
if (dr > 0) {
battle.on('hit', (ctx) => {
const s = ctx.source, d = ctx.dmg;
if (ctx.target !== unit || !skillOn(unit, S3) || !s || !s.isFlying || !d || (d.type !== 'phys' && d.type !== 'arts')) return;
if (d.tags && d.tags.includes('dot')) return;
d.mul = (d.mul ?? 1) * (1 - dr);
}, { owner: unit });
}
// at most attack@max_walk_target ground targets, flyers up to attack@max_target
battle.on('beforeAttack', (ctx) => {
if (ctx.attacker !== unit || !skillOn(unit, S3)) return;
const prof = ctx.profile || unit.profile;
const cands = battle.enemiesInKeys(unit.rangeKeys, unit, prof);
for (const e of battle.blockedTargets(unit, prof)) if (!cands.includes(e)) cands.push(e);
if (!cands.length) return;
sortEnemyTargets(battle, unit, cands, prof.priority);
let g = 0;
const out = [];
for (const e of cands) {
if (out.length >= maxT3) break;
if (!e.isFlying) { if (g >= maxWalk3) continue; g++; }
out.push(e);
}
if (out.length) ctx.targets = out;
}, { owner: unit });
battle.on('tick', () => {
if (!skillOn(unit, S3) || !up(unit)) return;
// the flyers of her range move ×(1 − move_speed), selectable or not
if (slow > 0) {
const keys = unit.rangeKeySet;
for (const e of battle.enemies) {
if (!e.alive || e.hidden || !e.isFlying || !keys || !bodyInKeys(e, keys)) continue;
battle.applyStrongest(e, 'aglna2:airSlow', { duration: MOVE_CHECK * 2, value: slow, mods: (v) => ({ moveMul: 1 - v }), source: unit });
}
}
}, { owner: unit });
// the move (every MOVE_CHECK s): fly to a blockable flyer of the original 3-9 while she blocks nothing
battle.every(MOVE_CHECK, () => {
if (!st || !skillOn(unit, S3) || !up(unit) || st.flight || !unit.canAct || unit.blocking.length) return;
const tgt = moveTarget(battle, unit);
if (!tgt) return;
const dur = Math.hypot(tgt.r - unit.tileR, tgt.c - unit.tileC) / MOVE_SPEED;
const act = unit.skill.activations;
st.flight = tgt;
battle.releaseBlocked(unit);
battle.addBuff(unit, { key: MOVE_KEY, duration: dur + 1, flags: { disarm: true, invulnerable: true, noHeal: true, noBlock: true }, tags: ['skill'] });
battle.fx('dash', { x: unit.x, y: unit.y, id: unit.id, tx: tgt.c, ty: tgt.r, t: dur });
battle.after(dur, () => {
battle.removeBuff(unit, MOVE_KEY);
if (!st || !skillOn(unit, S3) || unit.skill.activations !== act || !up(unit)) return;
st.flight = null;
const now = moveTarget(battle, unit);
if (now) moveTo(battle, unit, now.r, now.c);
}, { owner: unit });
}, { owner: unit });
// knocked out / withdrawn: the marker leaves and the anchored range is dropped (S3's onEnd runs before the
// removal finishes; this covers a removal with no skill end)
battle.on('death', (ctx) => {
if (ctx.unit !== unit) return;
dropMarker(battle);
battle.setExtraRange(unit, null);
}, { owner: unit });
},
};
},
};
+292
View File
@@ -0,0 +1,292 @@
// server/sim/content/kits/ops/op-doroth.js — 多萝西 (char_4048_doroth) 自选 operator kit: 6★ 陷阱师 (特种), an owned-6★ pick
// of the tier-5 and tier-6 自选 slots; every skill, both talents, the trait, both modules (TRP-Y 童话书, TRP-X 梦中人) at
// every form, and the kit of her trap 共振装置 (token_10025_doroth_recttp). Kit contract and the 自选 rules: ../README.md
// ("How to add an operator (自选)").
//
// Forms (data/backups.json units.char_4048_doroth): normal = E2 Lv1, skills at rank 4, no module; elite = E2 Lv60, rank 7,
// the picked module at stage 1 (tier 5) or 3 (tier 6) — the owner's decision of 2026-10-05. Potential 0 [ASSUMED: no
// account]. Sources: character_table / skill_table / battle_equip_table / token_table (zh_CN, as built into backups.json),
// PRTS 多萝西 / 共振装置 (备注) and 分支特性信息 §陷阱师, and the client's battle data (charpack char_4048_doroth: SpawnTokens,
// KillTokens, the T2 mode switch; skills skchr_doroth_1–3 / sktok_doroth_1–3; equips doroth_equip_1_* / 2_3_p1; buff
// templates doroth_t_2, doroth_token[*], trapper_e_trait[*], doroth_e_003[advanced_spawn_token], charge_token[refresh],
// trigger_charge_token, die_to_kill_token).
// - Trait (陷阱师) "可以使用陷阱来协助作战,但陷阱无法放置于敌人已在的格子中": ranged physical arrows, 3-3, hits air units
// (分支特性信息 "可对空"; the data's canHitFly over the profession table), blocks 1, ground enemies target her. Her traps
// never (re)deploy on a tile a ground enemy stands on (分支特性信息: "适用飞行单位判定的敌人(如浮空、近地悬浮)不影响陷阱的部署")
// and leave when she leaves the field (分支特性信息 "干员离场后,附属的陷阱随之消失"; die_to_kill_token).
// - The traps in this mode: her 共振装置 are hand pieces the player places (data `placeable`; the prep hands out a stack —
// content/tokens.js, server/match/player/diy.js). Placed pieces deploy with the board, free and ignoring her stock (PRTS
// 卫戍协议/帮助 "所有手动部署的召唤物,无视所属干员的持有状态…作战开始时立即部署一次"); a used-up one stays its tile's piece and
// comes back there (PRTS "若召唤物在战斗期间退场,将在满足条件后立即原地再部署1个") once the deployment conditions hold: she is on
// the field, her stock holds a trap, the token card's redeploy time has run since the last trap deployment (data
// respawnTime 5 s: 备注 "…会让共振装置进入再部署CD"), its player has its cost in DP (3; TRP-X 2), fewer of her traps than
// the deploy limit stand (data deployLimit 10; TRP-X 13 — 备注 "陷阱部署上限与最多拥有数量相同") and no ground enemy is on
// the tile; one piece per check (uid order), paying the cost and spending one trap.
// - T1 共振装置 "可以使用8个共振装置(最多拥有10个),踩上去的第一个敌人会触发其效果,部署后立刻在攻击范围内召唤2个共振装置"
// (bb cnt, attack@max_cnt; TRP-X: 13 and stage 3: 3): her stock is refilled to cnt at each deployment (charge_token[refresh])
// and holds at most the deploy limit; at each deployment attack@max_cnt traps appear on free melee tiles of her attack
// range with no ground enemy (the enemies' ground paths first, random among equals — [ASSUMED]: the client's selector
// filter 16 is not decoded), spending no trap but counting toward the limit (备注); the placed pieces off the field keep
// their slots (no summon takes one) [ASSUMED]. 阻回 while the stock is full (备注; `_stopSpWhenTokenIsFull`).
// - 共振装置 (its kit below): 不会受到攻击 (data: untargetable), blocks nothing, no normal attack. The first selectable ground
// enemy standing on its tile (sktok_doroth_* SkillTrigger: targetMotion ground, range 0-1; the earliest spawned of
// several) sets it off — the effect of the token skill of her pick (bySkill), with her current ATK (PRTS "技能伤害始终借用
// 持有者的攻击力计算"), from the trap (its source) —, then it withdraws (doroth_token[withdraw]; the blast fx carries
// `consumed`). S1 危险目标清除: that enemy takes atk_scale × ATK physical and DEF ×(1 + def) for `duration` s (formula
// FINAL_SCALER: the catalogue `defDown`). S2 流沙区域生成: every selectable ground enemy within 1.2 (备注 "陷阱爆炸范围为1.2半径
// 的圆") takes atk_scale × ATK physical and 束缚 `duration` s — `duration_2` s when it hit only one (cnt_2). S3
// 高速共振排障: every selectable ground enemy on the trap's x-6 takes atk_scale × ATK arts and 停顿 `sluggish` s, and every
// other trap of hers on that x-6 goes off `interval` s later (备注 "延迟触发时长为2s"; doroth_token_s3[trigger]: once — a
// trap already waiting keeps its time [ASSUMED]), with no enemy needed, and sets off its own x-6 the same way.
// - T2 梦想家 "陷阱触发后,多萝西获得2%的攻击力,最多叠加10层" (bb atk, max_stack_cnt; TRP-Y stage 3: 4%): every trap that goes
// off gives her one stack (ATK +atk, 直接乘算) until she leaves the field; with S1 / S2 before its damage, with S3 after
// it (备注). Full stacks switch her attack mode (doroth_t_2 SwitchMode: the Attack_2 clip — cosmetic here).
// - TRP-Y 童话书 "有20%概率部署造成2倍伤害的陷阱" (trait bb prob, atk_scale): each trap deployment rolls prob; such a trap deals
// ×atk_scale (trapper_e_trait[token_atk_scale] AtkScaleUp; the red "!" — fx 'mark'). Stage 3: T2 4 %.
// - TRP-X 梦中人: traps cost 1 less and the limit is 13 (the token's module stats), T1 "最多拥有13个"; stage 3: T1 summons 3 and
// "部署共振装置时有50%概率在攻击范围内额外召唤一个共振装置" (hidden talent prob, max_cnt, rangeGrid): on each deployment of a
// placed piece (备注 "仅手动部署的共振装置可触发模组3级效果" — the pieces the player placed [ASSUMED]: the start deployment and
// the redeploys) prob to summon max_cnt more on a tile as T1's, within the limit, spending no trap and ignoring the card's
// redeploy time but restarting it (备注); and when her T2 stacks fill (her attack mode switch) every placed piece standing
// rolls again (备注 "多萝西切换攻击模式时…为所有已手动部署的共振装置重新判定“概率额外召唤”").
// - S1 / S2 / S3 (AUTO, 19 / 16 SP, the data's DEFAULT): 被动效果 = the trap's effect above; 主动效果 "立即获得一个陷阱" (bb cnt):
// +cnt to her stock (trigger_charge_token). The cast acts on herself only, so it fires as soon as its SP is full
// (`trigger: 'SP_FULL'` — the owner's AUTO rule, kits/README.md checklist 5; skchr_doroth_* `_allowNoTarget`).
import { num, talentBb, moduleBb, traitBb, up, toggleBuff, summonTileFree } from '../shared/tier1.js';
import { absoluteRangeKeys, canTargetEnemy } from '../../../targeting.js';
import { bodyOnTile } from '../../../body.js';
import { COLS } from '../../../constants.js';
const S1 = 'skchr_doroth_1';
const S2 = 'skchr_doroth_2';
const S3 = 'skchr_doroth_3';
/** 共振装置, her trap. */
export const RESONATOR = 'token_10025_doroth_recttp';
const TS1 = 'sktok_doroth_1';
const TS2 = 'sktok_doroth_2';
const TS3 = 'sktok_doroth_3';
/** S2's blast (PRTS S2 备注 "陷阱爆炸范围为1.2半径的圆"). */
const S2_RADIUS = 1.2;
/** S3's area when the token skill carries no grid: range x-6 (the cross of radius 2). */
const X6 = Object.freeze([[2, 0], [1, 0], [0, -2], [0, -1], [0, 0], [0, 1], [0, 2], [-1, 0], [-2, 0]]);
/** S3's delayed trigger when the blackboard carries none (PRTS 备注 "延迟触发时长为2s"). */
const S3_DELAY = 2;
/** How often a used-up piece checks its redeploy conditions. */
const WATCH = 0.25;
const GROUND = Object.freeze({ canHitFly: false, groundOnly: true });
const DREAM_KEY = 'talent:doroth:dream';
const tokenOf = (t) => t && t.kind === 'token' && t.defId === RESONATOR;
/** A ground enemy stands on tile (r, c) — a huge one on any tile of its body (body.js); air units never count. */
function groundEnemyOn(battle, r, c) {
for (const e of battle.enemies) {
if (!e.alive || e.hidden || e.isFlying) continue;
if (e.hitArea ? bodyOnTile(e, r, c) : Math.abs(e.x - c) <= 0.5 && Math.abs(e.y - r) <= 0.5) return true;
}
return false;
}
export default {
char_4048_doroth: (bb, chess) => {
const t0 = talentBb(chess, 0); // cnt, attack@max_cnt
const t1 = talentBb(chess, 1); // atk, max_stack_cnt
const tb = traitBb(chess); // TRP-Y: prob, atk_scale
const hidden = moduleBb(chess); // TRP-X stage 3: prob, max_cnt
const hiddenGrid = (chess?.talents ?? []).find((t) => t && t.index === -1 && t.rangeGrid)?.rangeGrid ?? null;
const stockRefill = Math.max(0, Math.floor(num(t0.cnt, 0)));
const onDeploy = Math.max(0, Math.floor(num(t0['attack@max_cnt'], 0)));
const dream = { atk: num(t1.atk), max: Math.max(0, Math.floor(num(t1.max_stack_cnt, 0))) };
const dbl = { prob: num(tb.prob), scale: num(tb.atk_scale, 1) };
const extra = { prob: num(hidden.prob), cnt: Math.max(0, Math.floor(num(hidden.max_cnt, 0))) };
// her trap stock, the card's ready time, whether her T2 has filled this deployment, the deploy limit (per unit: the
// factory runs per unit; also `unit.trait.doroth` for diagnostics and tests)
const D = { stock: 0, readyAt: -Infinity, full: false, limit: Infinity };
const traps = (battle, unit) => battle.allyUnits.filter((t) => tokenOf(t) && t.ownerUnit === unit);
const standing = (battle, unit) => traps(battle, unit).filter((t) => t.alive).length;
/** Placed pieces still to come (not on the field, not gone): the T1 summons leave their slots free. */
const waiting = (battle, unit) => traps(battle, unit).filter((t) => t.uid != null && !t.alive && !t.removed).length;
/** The token's deploy limit for her loadout (variant stats, the module's when it carries one); her max stock too. */
function limitOf(battle, unit) {
const raw = battle.data.rawToken?.(RESONATOR);
const v = raw?.variants?.[unit.def?.tokenOwner];
const mod = unit.def?.loadout?.moduleId;
const n = num(v?.byModule?.[mod]?.stats?.deployLimit, num(v?.stats?.deployLimit, num(raw?.deployLimit, 0)));
if (n > 0) return n;
const m = String(chess?.talents?.find((t) => t && t.index === 0)?.desc ?? '').match(/最多拥有(\d+)个/);
return m ? +m[1] : Infinity;
}
/** Free melee tiles of her range (or of `grid` around her) with no ground enemy: enemy paths first, then random. */
function summonTiles(battle, unit, grid = null) {
const keys = grid ? absoluteRangeKeys(grid, unit.tileR, unit.tileC, unit.dir, unit.s.rangeExtend || 0) : unit.rangeKeys || [];
const path = battle.groundPathTiles();
const out = [];
for (const k of keys) {
const r = Math.floor(k / COLS), c = k % COLS;
if (!summonTileFree(battle, r, c) || !battle.grid.canStand(r, c) || groundEnemyOn(battle, r, c)) continue;
out.push({ r, c, p: path.has(k) ? 0 : 1 });
}
battle.rng.shuffle(out);
return out.sort((a, b) => a.p - b.p);
}
/** Summon up to `n` traps (no stock spent) on summonTiles, within the limit (`room` more at most). */
function summon(battle, unit, n, grid = null, room = Infinity) {
let left = Math.min(n, room, D.limit - standing(battle, unit));
if (!(left > 0)) return 0;
let made = 0;
for (const { r, c } of summonTiles(battle, unit, grid)) {
if (left <= 0) break;
const t = battle.spawnToken(unit, RESONATOR, r, c, { kit: trapKit(unit) });
if (!t) continue;
battle.fx('summon', { x: t.x, y: t.y, id: t.id, token: RESONATOR });
left--; made++;
}
return made;
}
/** TRP-X stage 3 on a placed piece's deployment (and her mode switch): prob to summon max_cnt more. */
function rollExtra(battle, unit) {
if (!(extra.prob > 0) || !(extra.cnt > 0) || !up(unit) || !battle.rng.chance(extra.prob)) return;
summon(battle, unit, extra.cnt, hiddenGrid, D.limit - standing(battle, unit) - waiting(battle, unit));
}
/** 梦想家: one stack (to max_stack_cnt); full stacks are her attack mode switch (TRP-X stage 3 re-rolls). */
function dreamStack(battle, unit) {
if (!up(unit) || !(dream.atk > 0) || !(dream.max > 0)) return;
const b = unit.findBuff(DREAM_KEY);
const n = b ? b.stacks : 0;
if (n >= dream.max) return;
battle.addBuff(unit, { key: DREAM_KEY, refresh: 'stack', stacks: 1, maxStacks: dream.max, mods: { atkPct: dream.atk }, tags: ['talent'] });
if (n + 1 >= dream.max && !D.full) {
D.full = true;
for (const t of traps(battle, unit)) if (t.alive && t.uid != null) rollExtra(battle, unit);
}
}
/** The trap `t` goes off (`e` = the enemy that stepped on it; null for a delayed S3 trigger). */
function fire(battle, unit, t, e) {
if (!t.alive || t.mem.dorFired) return;
t.mem.dorFired = true;
const sk = t.def?.skill ?? null;
const tb2 = sk?.bb ?? {};
const id = sk?.id ?? TS1;
const s3 = id === TS3;
if (!s3) dreamStack(battle, unit); // 备注: with S1 / S2 before the damage
const atk = (unit.s ? unit.s.atk : t.s.atk) * (t.mem.dorDouble ? dbl.scale : 1);
const tags = ['summon', 'trap', 'doroth:trap'];
if (id === TS2) {
const victims = battle.foesInRadius(t.x, t.y, S2_RADIUS, true).filter((x) => canTargetEnemy(t, x, GROUND));
const dur = victims.length === Math.max(1, Math.floor(num(tb2.cnt_2, 1))) ? num(tb2.duration_2, num(tb2.duration)) : num(tb2.duration);
for (const x of victims) {
battle.dealDamage(t, x, { amount: atk * num(tb2.atk_scale), type: 'phys', isSkill: true, tags });
if (x.alive && dur > 0) battle.applyStatus(x, 'bind', { duration: dur, source: t });
}
battle.fx('explode', { x: t.x, y: t.y, r: S2_RADIUS, id: t.id, consumed: true, kind: 'doroth:quicksand' });
} else if (s3) {
const keys = absoluteRangeKeys(sk?.rangeGrid ?? X6, t.tileR, t.tileC, t.dir, 0);
for (const x of battle.enemiesInKeys(keys, t, GROUND)) {
battle.dealDamage(t, x, { amount: atk * num(tb2.atk_scale), type: 'arts', isSkill: true, tags });
if (x.alive && num(tb2.sluggish) > 0) battle.applyStatus(x, 'sluggish', { duration: num(tb2.sluggish), source: t });
}
// 并延迟触发范围内的其他共振装置
const set = new Set(keys);
const delay = num(tb2.interval, S3_DELAY);
for (const o of traps(battle, unit)) {
if (o === t || !o.alive || o.mem.dorFired || o.mem.dorWaiting || !set.has(o.tileR * COLS + o.tileC)) continue;
o.mem.dorWaiting = true;
const seq = o.deploySeq;
battle.after(delay, () => { if (o.alive && o.deploySeq === seq) fire(battle, unit, o, null); }, { owner: o });
}
battle.fx('explode', { x: t.x, y: t.y, r: 2, id: t.id, consumed: true, dmgType: 'arts', kind: 'doroth:resonance' });
dreamStack(battle, unit); // 备注: with S3 after the damage
} else {
if (e && e.alive) {
battle.dealDamage(t, e, { amount: atk * num(tb2.atk_scale), type: 'phys', isSkill: true, tags });
if (e.alive && num(tb2.duration) > 0 && num(tb2.def) < 0) battle.applyStatus(e, 'defDown', { duration: num(tb2.duration), value: -num(tb2.def), source: t });
}
battle.fx('explode', { x: t.x, y: t.y, r: 0.6, id: t.id, consumed: true, kind: 'doroth:clear' });
}
battle.retreat(t, { reason: 'expired', permanent: true });
}
/** 共振装置's kit (`unit` = 多萝西): its rolls at each deployment, the trigger, a placed piece kept for its redeploys. */
function trapKit(unit) {
return {
skill: null,
trait: { noAttack: true },
install(battle, t) {
battle.on('deploy', (ctx) => {
if (ctx.unit !== t) return;
t.mem.dorFired = false;
t.mem.dorWaiting = false;
t.mem.dorDouble = dbl.prob > 0 && dbl.scale !== 1 && battle.rng.chance(dbl.prob);
if (t.mem.dorDouble) battle.fx('mark', { x: t.x, y: t.y, id: t.id, kind: 'doroth:double' });
D.readyAt = battle.time + Math.max(0, num(t.base.respawnTime, 0));
if (t.uid != null) rollExtra(battle, unit);
}, { owner: t });
battle.on('tick', () => {
if (!t.alive || t.mem.dorFired) return;
let hit = null;
for (const e of battle.enemies) {
if (!canTargetEnemy(t, e, GROUND)) continue;
const on = e.hitArea ? bodyOnTile(e, t.tileR, t.tileC) : Math.abs(e.x - t.tileC) <= 0.5 && Math.abs(e.y - t.tileR) <= 0.5;
if (on && (!hit || e.spawnSeq < hit.spawnSeq)) hit = e;
}
if (hit) fire(battle, unit, t, hit);
}, { owner: t });
// a placed piece stays its tile's piece (redeployed by her kit's watch), whatever took it off the field
if (t.uid != null) battle.on('death', (ctx) => { if (ctx.unit === t && !battle.finished) t.removed = false; }, { owner: t, priority: -10 });
},
};
}
const skillSpec = () => ({
kind: 'instant', trigger: 'SP_FULL',
onStart({ skill }) { // 主动效果:立即获得一个陷阱
D.stock = Math.min(D.limit, D.stock + Math.max(1, Math.floor(num(skill.bb?.cnt, 1))));
},
});
return {
skills: { [S1]: skillSpec(), [S2]: skillSpec(), [S3]: skillSpec() },
talents: [
{ install(battle, unit) { // 共振装置: the pieces' kit, the stock, the summons at each deployment, the redeploys
D.limit = limitOf(battle, unit);
unit.trait.doroth = D;
for (const t of battle.allyUnits) {
if (!tokenOf(t) || t.ownerUnit !== unit || t.alive || t.deployed) continue;
if (t.kit) battle.offOwner(t); // a piece set up before her: drop its generic kit's hooks
battle._setupUnit(t, trapKit(unit));
}
battle.on('deploy', (ctx) => {
if (ctx.unit !== unit || ctx.move) return;
D.stock = Math.min(D.limit, stockRefill); // charge_token[refresh]
D.full = false;
if (onDeploy > 0) summon(battle, unit, onDeploy, null, D.limit - standing(battle, unit) - waiting(battle, unit));
}, { owner: unit });
// her traps leave with her (die_to_kill_token); the placed pieces wait for her return
battle.on('death', (ctx) => {
if (ctx.unit !== unit) return;
for (const t of traps(battle, unit)) if (t.alive) battle.retreat(t, { reason: 'expired', permanent: true });
}, { owner: unit });
// a used-up / withdrawn piece comes back on its tile once the deployment conditions hold (see the header)
battle.every(WATCH, () => {
if (!up(unit) || D.stock < 1 || battle.time + 1e-9 < D.readyAt || standing(battle, unit) >= D.limit) return;
const pieces = traps(battle, unit).filter((t) => t.uid != null && !t.alive && !t.removed).sort((a, b) => a.uid - b.uid);
for (const p of pieces) {
if (groundEnemyOn(battle, p.homeR, p.homeC)) continue;
if (battle.redeploy(p, { free: false })) { D.stock--; break; }
}
}, { owner: unit });
// 阻回 while her stock is full (_stopSpWhenTokenIsFull)
toggleBuff(battle, unit, 'talent:doroth:full', () => D.stock >= D.limit, {}, { flags: { noSp: true } });
} },
{ install() {} }, // 梦想家: the stacks come with every trap that goes off (fire → dreamStack)
],
};
},
};
+300
View File
@@ -0,0 +1,300 @@
// server/sim/content/kits/ops/op-ebnhlz.js — 黑键 (char_4046_ebnhlz) 自选 operator kit: 6★ 秘术师 (术师), an owned-6★ pick
// of the tier-5 and tier-6 自选 slots; every skill, both talents, the trait, the three modules (MSC-X 源石骰子收纳盒, MSC-Y
// “乐理阐释者”, MSC-Δ 朽坏传承) at every form, and the kit of his S2 summon 旧日残影 (token_10024_ebnhlz_rcube). Kit contract
// and the 自选 rules: ../README.md ("How to add an operator (自选)").
//
// Forms (data/backups.json units.char_4046_ebnhlz): normal = E2 Lv1, skills at rank 4, no module; elite = E2 Lv60, rank 7,
// the picked module at stage 1 (tier 5) or 3 (tier 6) — the owner's decision of 2026-10-05. Potential 0 [ASSUMED: no
// account]. Sources: character_table / skill_table / battle_equip_table / token_table (zh_CN, as built into backups.json),
// PRTS 黑键 / 旧日残影 (备注) and 分支特性信息 §秘术师, and the client's battle data (charpack char_4046_ebnhlz: the
// ExChargeAttack abilities, the talent config; skills sktok_ebnhlz_token / skchr_ebnhlz_1–3; buff templates ebnhlz_t_2,
// ebnhlz_e_003_*, ebnhlz_e_004_*).
// - Trait (秘术师) "攻击造成法术伤害,在找不到攻击目标时可以将攻击能量储存起来之后一齐发射(最多3个)" (bb times; MSC-X 4):
// ranged arts bolts, hits air units (分支特性信息 "可对空"), blocks 1, ground enemies target him. The store (分支特性信息:
// "能量储存与攻击占用相同的攻击间隔:…若无有效目标且能量储存数未满,则改为储存一份攻击能量(属于攻击行为)"): when his attack is
// ready and he has no valid target he stores one energy and his attack interval starts again — this kit's own store,
// as 维伊's (op-veen.js; the engine's mystic profile stores one interval after the attack is ready). His next attack
// releases them at its target ("一齐发射"), each hitting for ATK × the attack's scale × the energy scale (talent 1) as
// an arts 普通伤害 attack hit ("由储存能量形成的弹道造成攻击力100%的法术普通伤害"); they land with the main bolt (one
// volley to one target [ASSUMED], as 维伊's), the later ones only on a target still alive. [ASSUMED] a redeployment holds
// no energy.
// - T1 强弱法 "储存的攻击能量造成的伤害提升至135%,可额外储存1份只用于攻击精英或领袖敌人的攻击能量" (bb atk_scale, times_2; MSC-X
// stage 3: 1.43): every stored energy ×atk_scale; one more energy (the client's ExChargeAttack `_exProjectileKey`,
// targetValidator enemyLevelMask 6 = ELITE | BOSS) stored once the trait's are full (备注 "通常情况下此“额外攻击能量”将在
// 特性能量全部储存完毕后再尝试储存") and released only by an attack on an elite or leader enemy (kept otherwise).
// - T2 倚音 "若攻击目标周围没有其他敌人,攻击对其额外造成相当于攻击力15%的法术伤害" (bb atk_scale, cnt 0, range_radius 1.1): per
// projectile — the main bolt and every energy (备注 "主攻击与每个攻击能量分别独立触发") — with at most `cnt` other selectable
// enemies within range_radius of the target (中点判定; 备注 "可以攻击的装置类不影响判定"), ATK × atk_scale arts on it.
// MSC-Y stage 3 (atk_scale 0.2, atk_scale_2 0.36): otherwise ATK × atk_scale_2 arts splash on each of those others (备注
// "额外伤害的影响对象不包括主目标"; ebnhlz_e_003_t_2 AOEDamage SPLASH, every motion). MSC-Δ stage 3 (atk_scale 0.3,
// element_atk_scale 0.3): and, on a target in its 凋亡 burst (its `apoptosisBurst` lock — ebnhlz_e_004[t_2_ele]
// IsTargetInEPBreakRecovery DARK), ATK × element_atk_scale 元素伤害 after the arts (备注 "先造成法术伤害,后造成元素伤害").
// - MSC-X 源石骰子收纳盒: trait times 4 (above), attributes in the stats (ATK, ASPD). MSC-Y “乐理阐释者” "拥有已储存的攻击
// 能量时,攻击速度+30" (hidden module talent attack_speed): while any energy is stored (ebnhlz_e_003_trait: charge or ex
// charge > 0). MSC-Δ 朽坏传承 "造成法术伤害时附带相当于8%伤害的凋亡损伤" (hidden ep_damage_ratio): every arts damage he deals
// that removes HP attaches ep_damage_ratio × that damage of 凋亡损伤 (ebnhlz_e_004_tr ON_AFTER_OUTPUT_DAMAGE; the SIM.md
// §7.2 convention "伤害N%的…损伤" = × the HP damage dealt); his 旧日残影 too (PRTS "旧日残影造成的伤害也可以附加相应的凋亡损伤",
// ebnhlz_e_004_tr[token]).
// - S1 渐快急板 (MANUAL, 5 s, data DEFAULT — its 4-1 does not contain his 3-14): range 4-1, attack interval ×base_attack_time
// (PRTS "大幅度缩短(*0.2)": batMod's ratio reading), every attack attack@atk_scale × ATK; the energies released meanwhile
// use that scale too (备注 "该技能的“每次攻击的攻击倍率”会实时应用在特性积攒的“攻击能量”抛射物上") × the energy scale.
// `attack@cnt` (1) has no text [unused].
// - S2 荒芜回响 (AUTO, instant, data DEFAULT — an AUTO skill whose effect acts on enemies keeps the data rule): spends every
// stored energy (elite ones first: 备注 "可以消耗并优先消耗第一天赋储存的额外能量") and places energies + 1 旧日残影 on free
// placeable tiles of his attack range (部署位置 全部位), in the 备注's order: tiles holding a selectable ground enemy (the
// best of them first by his target order — 仇恨值 [ASSUMED: the engine's default operator order]), then the tiles nearest
// another selectable ground enemy, then the rest at random (battle.rng); fewer free tiles than energies + 1 ⇒ fewer
// energies spent; no free tile ⇒ no cast (备注 "攻击范围内不存在可部署位时,技能不会被触发": the charge is given back).
// - 旧日残影 (its kit below): no normal attack; 闪回 — once a selectable ground enemy (备注 "不对空") is within 1.35 of it, after
// 0.93 s (备注 "技能伤害与“拖拽”在激活0.93s后生效"; sktok_ebnhlz_token _preDelay) every selectable ground enemy within 1.35
// then [ASSUMED: re-selected when it lands] takes 黑键's ATK × atk_scale arts from the remnant (备注 "伤害来源为召唤物自身,
// 伤害计算使用持有者的攻击力") and a 中力 (force 1) inward push towards it (备注 "此处的“拖拽”实际为反方向的推开"; template
// mint_s_2[pull], Battle.push inward), then it withdraws (suicide). It leaves after the token talent's 30 s or when 黑键
// leaves the field (备注; die_to_kill_token). Its data carries no 不会受到攻击: enemies may target it [ASSUMED]; no per-owner
// deploy limit applies (several stand at once).
// - S3 寂静之声 (MANUAL, 30 s, data DEFAULT): ASPD +attack_speed, ATK +atk, attacks only elite or leader enemies (S3 mode
// Trigger enemyLevelMask 6; with none in range he stores energy), every energy × talent_scale_multiplier (备注 "天赋伤害
// 加成与第一天赋数值直接做乘法计算"; the config trait_s3.atk_scale = atk_scale × talent_scale_multiplier). 备注 "技能开始时
// 将所有攻击能量转换为精英攻击能量,技能期间只生成精英攻击能量;技能结束时精英攻击能量会保留最多1份,溢出部分转换为普通的攻击能量":
// at its start every energy becomes elite (cap times + times_2: the config trait_s3.times / trait_s3.times_2), it stores
// only elite ones, and at its end at most times_2 stay elite, the rest normal (up to times). "可主动关闭" is a manual
// operation (no automatic stop).
import { num, talentBb, moduleBb, traitBb, skillRec, batMod, up, toggleBuff } from '../shared/tier1.js';
import { canTargetEnemy, sortEnemyTargets } from '../../../targeting.js';
import { acquireTargets, effectiveProfile } from '../../../ai.js';
import { hasHp } from '../../../damage.js';
import { COLS } from '../../../constants.js';
const S1 = 'skchr_ebnhlz_1';
const S2 = 'skchr_ebnhlz_2';
const S3 = 'skchr_ebnhlz_3';
/** 旧日残影, his S2 summon. */
export const REMNANT = 'token_10024_ebnhlz_rcube';
/** 闪回: activation radius = effect radius (PRTS 旧日残影 备注 "激活范围与技能生效的半径为1.35"). */
const REMNANT_RADIUS = 1.35;
/** 闪回: its damage and push land 0.93 s after the activation (PRTS 备注; sktok_ebnhlz_token `_preDelay` 0.93). */
const REMNANT_DELAY = 0.93;
/** The remnant's life when its talent carries none (PRTS "部署30秒后…自身自动撤退"). */
const REMNANT_LIFE = 30;
/** 倚音's radius when the talent carries none (PRTS 备注 "判定范围半径1.1"). */
const T2_RADIUS = 1.1;
const GROUND = Object.freeze({ canHitFly: false, groundOnly: true });
const bbOf = (chess, id) => skillRec(chess, id)?.bb ?? {};
const skillOn = (unit, id) => !!(unit.skill && unit.skill.active && unit.skill.id === id);
/** An elite or leader enemy (the ELITE | BOSS level mask of the client's validators; targeting.js priority 'elite'). */
export const eliteOrLeader = (e) => !!e && (!!e.isBoss || e.def?.rank === 'ELITE' || e.def?.rank === 'BOSS');
/** His stored energies (per deployment): `n` normal, `e` elite, `q` the volleys in flight per target id. */
const stateOf = (unit) => unit.trait.ebn ?? (unit.trait.ebn = { n: 0, e: 0, q: new Map() });
/**
* The tiles 荒芜回响 may place 旧日残影 on (PRTS 备注 order): free deployable tiles of `unit`'s attack range — first those
* holding a selectable ground enemy, by the best of them in his target order; then by the distance to the nearest
* selectable ground enemy; then (no such enemy) at random.
*/
function remnantTiles(battle, unit) {
const tiles = [];
for (const k of unit.rangeKeys || []) {
const r = Math.floor(k / COLS), c = k % COLS;
if (!battle.grid.inRect(r, c) || !battle.grid.canStand(r, c, { ranged: true }) || battle.isReservedTile(r, c)) continue;
tiles.push([r, c]);
}
if (!tiles.length) return tiles;
const foes = battle.enemies.filter((e) => canTargetEnemy(unit, e, GROUND));
sortEnemyTargets(battle, unit, foes, null);
const rank = new Map();
foes.forEach((e, i) => { const k = Math.round(e.y) * COLS + Math.round(e.x); if (!rank.has(k)) rank.set(k, i); });
battle.rng.shuffle(tiles); // the random order of the last group, and of equal distances [ASSUMED]
const dist = (r, c) => { let d = Infinity; for (const e of foes) d = Math.min(d, Math.hypot(e.x - c, e.y - r)); return d; };
const keyed = tiles.map(([r, c], i) => ({ r, c, i, on: rank.get(r * COLS + c) ?? Infinity, d: dist(r, c) }));
keyed.sort((a, b) => a.on - b.on || a.d - b.d || a.i - b.i);
return keyed.map((x) => [x.r, x.c]);
}
/**
* 旧日残影's kit: no normal attack; 闪回 once (a selectable ground enemy within REMNANT_RADIUS ⇒ REMNANT_DELAY s later the
* blast and the inward push, then it withdraws); its life; it leaves with 黑键 (owner kit's death hook).
*/
function remnantKit(owner) {
return {
skill: null,
trait: { noAttack: true },
install(battle, t) {
const bb = t.def?.skill?.bb ?? {};
const scale = num(bb.atk_scale, 1), force = num(bb.force, 1);
const life = num((t.def?.talents ?? []).find((x) => x && x.bb && x.bb.duration != null)?.bb.duration, REMNANT_LIFE);
battle.on('deploy', (ctx) => {
if (ctx.unit !== t) return;
const seq = t.deploySeq;
t.mem.flashback = false;
if (life > 0) battle.after(life, () => { if (t.alive && t.deploySeq === seq) battle.retreat(t, { reason: 'expired', permanent: true }); }, { owner: t });
}, { owner: t });
battle.on('tick', () => {
if (!t.alive || t.mem.flashback) return;
if (!battle.foesInRadius(t.x, t.y, REMNANT_RADIUS, true).some((e) => !e.isFlying && canTargetEnemy(t, e, GROUND))) return;
t.mem.flashback = true;
const seq = t.deploySeq;
battle.fx('aoe', { x: t.x, y: t.y, radius: REMNANT_RADIUS, id: t.id, dmgType: 'arts', skill: 'ebnhlz:flashback', t: REMNANT_DELAY });
battle.after(REMNANT_DELAY, () => {
if (!t.alive || t.deploySeq !== seq) return;
const atk = owner && owner.s ? owner.s.atk : t.s.atk;
for (const e of battle.foesInRadius(t.x, t.y, REMNANT_RADIUS, true)) {
if (e.isFlying || !canTargetEnemy(t, e, GROUND)) continue;
battle.dealDamage(t, e, { amount: atk * scale, type: 'arts', isSkill: true, tags: ['summon', 'ebnhlz:flashback'] });
if (e.alive && battle.push(e, force, { from: t, inward: true }) > 0) battle.fx('pull', { x: e.x, y: e.y, id: e.id, src: t.id });
}
battle.retreat(t, { reason: 'expired', permanent: true });
}, { owner: t });
}, { owner: t });
},
};
}
export default {
char_4046_ebnhlz: (bb, chess) => {
const tb = traitBb(chess);
const t0 = talentBb(chess, 0);
const t1 = talentBb(chess, 1);
const hidden = moduleBb(chess); // MSC-Y attack_speed, MSC-Δ ep_damage_ratio
const b1 = bbOf(chess, S1), b3 = bbOf(chess, S3);
const s1 = skillRec(chess, S1);
const N = Math.max(1, Math.floor(num(tb.times, 3)));
const E = Math.max(0, Math.floor(num(t0.times_2, 0)));
const energyScale = num(t0.atk_scale, 1);
const s3Mult = num(b3.talent_scale_multiplier, 1);
const s1Scale = num(b1['attack@atk_scale'], 1);
const t2 = {
scale: num(t1.atk_scale), cnt: Math.max(0, Math.floor(num(t1.cnt, 0))), radius: num(t1.range_radius, T2_RADIUS),
splash: num(t1.atk_scale_2), elem: num(t1.element_atk_scale),
};
const epRatio = num(hidden.ep_damage_ratio);
/** 倚音 on the target of one projectile (the main bolt or one energy). */
function yiyin(battle, unit, t, attackId) {
if (!t || !t.alive) return;
const others = battle.foesInRadius(t.x, t.y, t2.radius, true).filter((e) => e !== t);
const atk = unit.s.atk;
if (others.length <= t2.cnt) {
if (t2.scale > 0) battle.dealDamage(unit, t, { amount: atk * t2.scale, type: 'arts', attackId, tags: ['talent', 'ebnhlz:yiyin'] });
} else if (t2.splash > 0) {
for (const e of others) battle.dealDamage(unit, e, { amount: atk * t2.splash, type: 'arts', isSplash: true, attackId, tags: ['talent', 'ebnhlz:yiyin'] });
}
if (t2.elem > 0 && t.alive && t.findBuff('apoptosisBurst')) {
battle.dealDamage(unit, t, { amount: atk * t2.elem, type: 'elemental', element: 'apoptosis', attackId, tags: ['talent', 'ebnhlz:yiyin'] });
}
}
/** The main bolt of an attack landed on `victim`: its 倚音, then every energy of its volley (and theirs). */
function land(battle, unit, victim, hc) {
const v = stateOf(unit);
const list = v.q.get(victim.id);
const rec = list ? list.shift() : null;
if (list && !list.length) v.q.delete(victim.id);
yiyin(battle, unit, victim, hc.attackId);
if (!rec) return;
const per = (rec.s1 ? s1Scale : 1) * energyScale * (rec.s3 ? s3Mult : 1);
for (let i = 0; i < rec.n + rec.e && victim.alive; i++) {
battle.dealDamage(unit, victim, { amount: unit.s.atk * per * unit.s.atkScaleMul, type: 'arts', isAttack: true, isSkill: !!hc.isSkill, attackId: hc.attackId, tags: ['ebnhlz:energy'] });
yiyin(battle, unit, victim, hc.attackId);
}
}
return {
trait: {
hitsFn: () => 1, // the engine's main hit only: the stored energies are this kit's (land)
onEachHit(battle, unit, victim, hc) { if (hc.kind === 'main' && victim && victim.side === 'enemy') land(battle, unit, victim, hc); },
install(battle, unit) {
battle.on('deploy', (ctx) => { if (ctx.unit === unit && !ctx.move) unit.trait.ebn = null; }, { owner: unit });
// the store: his attack ready and no valid target ⇒ one energy, an attack action (the interval restarts); the
// attack loop ran first this tick (a valid target was attacked instead)
battle.on('tick', () => {
if (!up(unit) || !unit.canAct || unit.s.flags.disarm || unit.atkCd > 0) return;
const prof = effectiveProfile(unit);
if (prof.noAttack || acquireTargets(battle, unit, prof).length) return;
const v = stateOf(unit);
if (skillOn(unit, S3)) { if (v.n + v.e >= N + E) return; v.e++; }
else if (v.n < N) v.n++;
else if (v.e < E) v.e++;
else return;
unit.atkCd = unit.s.interval;
}, { owner: unit });
battle.on('death', (ctx) => { if (ctx.unit && ctx.unit.side === 'enemy') stateOf(unit).q.delete(ctx.unit.id); }, { owner: unit });
},
},
skills: {
[S1]: {
kind: 'duration',
mods: { batPct: batMod(b1.base_attack_time, chess, s1?.desc ?? '') },
targeting: { rangeGrid: s1?.rangeGrid ?? null },
attack: { atkScale: s1Scale },
},
[S2]: {
kind: 'instant',
onStart({ battle, unit, skill }) {
const tiles = remnantTiles(battle, unit);
if (!tiles.length) { skill.addCharge(1); return; } // "攻击范围内不存在可部署位时,技能不会被触发"
const v = stateOf(unit);
const count = Math.min(v.n + v.e + 1, tiles.length);
let spend = count - 1;
const fromE = Math.min(v.e, spend);
v.e -= fromE; spend -= fromE;
v.n -= Math.min(v.n, spend);
for (const [r, c] of tiles.slice(0, count)) {
const t = battle.spawnToken(unit, REMNANT, r, c, { kit: remnantKit(unit) });
if (t) battle.fx('summon', { x: t.x, y: t.y, id: t.id, token: REMNANT });
}
},
},
[S3]: {
kind: 'duration',
mods: { aspd: num(b3.attack_speed), atkPct: num(b3.atk) },
attack: { skipEnemy: (e) => !eliteOrLeader(e) },
onStart({ unit }) { const v = stateOf(unit); v.e += v.n; v.n = 0; },
onEnd({ unit }) {
const v = stateOf(unit);
const keep = Math.min(v.e, E);
v.n = Math.min(N, v.n + v.e - keep);
v.e = keep;
},
},
},
install(battle, unit) {
// MSC-Y: ASPD while any energy is stored
const aspd = num(hidden.attack_speed);
if (aspd) toggleBuff(battle, unit, 'trait:ebnhlz:stored', () => { const v = stateOf(unit); return v.n + v.e > 0; }, { aspd });
// MSC-Δ: every arts damage of his (and of his 旧日残影) that removes HP attaches ep_damage_ratio × it of 凋亡损伤
if (epRatio > 0) {
battle.on('damaged', (ctx) => {
const s = ctx.source, t = ctx.target;
if (!s || ctx.type !== 'arts' || !(ctx.amount > 0) || !t || t.side !== 'enemy' || !hasHp(t)) return;
if (s !== unit && !(s.kind === 'token' && s.defId === REMNANT && s.ownerUnit === unit)) return;
battle.dealDamage(s, t, { type: 'element', element: 'apoptosis', amount: ctx.amount * epRatio, tags: ['module', 'ebnhlz:decay'] });
}, { owner: unit });
}
// the energies leave with the attack: the normal ones always, the elite ones only at an elite / leader target
battle.on('attack', (ctx) => {
if (ctx.attacker !== unit || !ctx.targets.length) return;
const v = stateOf(unit);
ctx.targets.forEach((tg, i) => {
if (!tg || tg.side !== 'enemy') return;
const rec = { n: 0, e: 0, s1: skillOn(unit, S1), s3: skillOn(unit, S3) };
if (i === 0) {
rec.n = v.n; v.n = 0;
if (eliteOrLeader(tg)) { rec.e = v.e; v.e = 0; }
if (rec.n + rec.e > 0) battle.fx('volley', { x: unit.x, y: unit.y, id: unit.id, target: tg.id, n: rec.n + rec.e });
}
const list = v.q.get(tg.id) ?? [];
list.push(rec);
v.q.set(tg.id, list);
});
}, { owner: unit });
// 旧日残影 leave with him (PRTS 备注 "黑键离场时,自身自动撤退"; die_to_kill_token)
battle.on('death', (ctx) => {
if (ctx.unit !== unit) return;
for (const t of battle.allyUnits) if (t.alive && t.kind === 'token' && t.defId === REMNANT && t.ownerUnit === unit) battle.retreat(t, { reason: 'expired', permanent: true });
}, { owner: unit });
},
};
},
};
+10 -5
View File
@@ -179,13 +179,18 @@ export class Unit {
/**
* Air unit (空中单位) for every targeting / ground-only rule: FLY movers, and enemies that hover (近地悬浮, buff flag
* `float` — PRTS 术语释义 ba.float "算作空中单位"; they keep walking the ground path) or are levitated (浮空, gamedata_const
* ba.levitate "变为空中单位"). Movement and pathing read `motion`, never this.
* ba.levitate "变为空中单位"). A 缚地 enemy (status `groundbind`, ba.groundbind "目标变为地面单位") is a ground unit
* meanwhile — unless a 浮空 lifts it again (浮空 lands on a 缚地 flyer: Battle.applyStatus). Movement and pathing read
* `motion`, never this.
*/
get isFlying() {
if (this.motion === 'FLY') return true;
if (this.side !== 'enemy') return false;
const f = this.s.flags;
return !!(f.float || f.levitate);
if (this.side === 'enemy') {
const f = this.s.flags;
if (f.levitate) return true;
if (f.groundbind) return false;
return this.motion === 'FLY' || !!f.float;
}
return this.motion === 'FLY';
}
get hpRatio() { const mh = this.s.maxHp; return mh > 0 ? this.hp / mh : 0; }