0.2.5-dev: merge claude/036-sim
# Conflicts: # CHANGELOG.md # docs/history/0.2.5.md # test/golden/matches.json
This commit is contained in:
commit
3dd2213e47
42 files changed
+2335
-961
No files matched your search
+21
-8
@@ -138,16 +138,26 @@ const DEFAULT_MELEE_RANGE = [[0, 0], [0, 1]];
|
||||
* preferred). Alone, a band that withholds the first rounds' funds (老鲤 "资金暂存": no operator in R1–R2, every enemy
|
||||
* leaks) is avoided — only 联防 teammates cover that. A band whose mechanic rides on a bond the mode switches off
|
||||
* (gd.bandBondIds ∩ gd.modeInactiveBonds — 标准: 潘格尼尼 <拉特兰>, 克莱门莎 <阿戈尔>, 玛恩纳 <卡西米尔>) weighs 0, never taken
|
||||
* (DESIGN §21.26); with every band excluded, the default band. One rng draw per call (deterministic per seed); modes
|
||||
* without inactive bonds keep exactly the earlier picks.
|
||||
* (DESIGN §21.26). [ASSUMED] A living teammate's opening strategy soft-reserves those bonds before anyone is deployed:
|
||||
* the weight stays positive, at a quarter of the unreserved weight, so the strategy can still be drawn, and the
|
||||
* reservation ends when that teammate is eliminated (alivePlayers). With every band excluded, the default band. One
|
||||
* rng draw per call (deterministic per seed); a solo match has no teammate to reserve against.
|
||||
*/
|
||||
const SOFT_BAND_RESERVE = 0.25;
|
||||
export function botPickBand(m, ps) {
|
||||
const gd = ps?.gd || m.gd;
|
||||
const ids = gd.bandIds();
|
||||
if (!ids.length) return gd.defaultBandId;
|
||||
const lateFunds = (id) => /暂存/.test(String(gd.band(id)?.desc || ''));
|
||||
const offBond = (id) => gd.bandBondIds(id).some((b) => gd.modeInactiveBonds.has(b));
|
||||
const pairs = ids.map((id) => [id, offBond(id) ? 0 : Math.max(1, (gd.startLp(id) - 18) ** 2) * (m.isSolo && lateFunds(id) ? 0.02 : 1)]);
|
||||
const reserved = new Set(ps && typeof m.alivePlayers === 'function'
|
||||
? m.alivePlayers().filter((p) => p !== ps).flatMap((p) => gd.bandBondIds(p.bandId))
|
||||
: []);
|
||||
const inactive = (id) => gd.bandBondIds(id).some((b) => gd.modeInactiveBonds.has(b));
|
||||
const pairs = ids.map((id) => {
|
||||
if (inactive(id)) return [id, 0];
|
||||
const w = Math.max(1, (gd.startLp(id) - 18) ** 2) * (m.isSolo && lateFunds(id) ? 0.02 : 1);
|
||||
return [id, gd.bandBondIds(id).some((b) => reserved.has(b)) ? w * SOFT_BAND_RESERVE : w];
|
||||
});
|
||||
let total = 0;
|
||||
for (const [, w] of pairs) total += w;
|
||||
let r = m.rngBots() * total;
|
||||
@@ -348,12 +358,14 @@ function mainCoreBond(m, p) {
|
||||
* The bonds the bot builds around (cached per round and owned set): `focus` = the core bond with the best
|
||||
* owned members × 10 + reachable members (bondPoolStats, ≤ 4) + layers already banked (≤ 6) + 6 for last round's focus
|
||||
* (commit instead of flip-flopping between equal bonds) − 6 when a teammate already builds it (its main core bond on
|
||||
* its public bond strip, mainCoreBond — the shop pool is shared); `second` = the other live bond (core or add-on) with
|
||||
* the most owned members whose next threshold is within reach (≥ 1 owned member). `ps._botFocusId` keeps the focus
|
||||
* across rounds.
|
||||
* its public bond strip, mainCoreBond — the shop pool is shared) or has selected that bond's opening strategy, even
|
||||
* before anyone is deployed. The strategy reservation ends when that teammate is eliminated. `second` = the other live
|
||||
* bond (core or add-on) with the most owned members whose next threshold is within reach (≥ 1 owned member).
|
||||
* `ps._botFocusId` keeps the focus across rounds.
|
||||
*/
|
||||
export function bondPlan(m, ps, owned = ownedBonds(m, ps)) {
|
||||
const key = `${m.round}|${ps.shop.level}|${[...owned.counts.entries()].map(([k, v]) => k + v).join()}`;
|
||||
const livingBands = m.alivePlayers().filter((p) => p !== ps).flatMap((p) => m.gd.bandBondIds(p.bandId)).sort().join();
|
||||
const key = `${m.round}|${ps.shop.level}|${[...owned.counts.entries()].map(([k, v]) => k + v).join()}|${livingBands}`;
|
||||
if (ps._botFocus && ps._botFocus.key === key) return ps._botFocus;
|
||||
const prev = ps._botFocusId ?? null;
|
||||
const mates = new Set();
|
||||
@@ -361,6 +373,7 @@ export function bondPlan(m, ps, owned = ownedBonds(m, ps)) {
|
||||
if (p === ps) continue;
|
||||
const b = mainCoreBond(m, p);
|
||||
if (b) mates.add(b);
|
||||
for (const id of m.gd.bandBondIds(p.bandId)) mates.add(id);
|
||||
}
|
||||
let focus = null;
|
||||
let bestS = 0;
|
||||
|
||||
+17
-1
@@ -318,13 +318,29 @@ export function resolveHit(b, u, prof, target, info, x, y) {
|
||||
if (target && target.alive) {
|
||||
let mulT = skillMul;
|
||||
if (prof.dmgMul) { const m = typeof prof.dmgMul === 'function' ? prof.dmgMul(b, u, target) : prof.dmgMul; if (Number.isFinite(m)) mulT *= m; }
|
||||
const funnelMul = prof.funnelMul ? prof.funnelMul(b, u, target) : 1;
|
||||
// Unreleased drones are additional damage on the caster's attack (PRTS 驭械术师), including a skill that only
|
||||
// buffs or retargets that attack. `info.isSkill` is set for every attack or targeting override, so it must not
|
||||
// decide this. `funnelBodyHits === 0` is the drone-only opt-out (the ramp stays inside the hits, no body).
|
||||
// A volley shares one talent roll and attackId; extra drones never duplicate the body.
|
||||
// [ASSUMED] Body instances precede additions at the existing projectile impact; a multi-hit volley keeps one ramp.
|
||||
const attachedFunnel = !!prof.funnelMul && prof.funnelBodyHits !== 0;
|
||||
if (!attachedFunnel) mulT *= funnelMul;
|
||||
const hits = prof.hitsFn ? prof.hitsFn(b, u, info) : Math.max(1, prof.hits || 1);
|
||||
// `hitDmgMul` (professions.js header): each instance's 伤害倍率 — the DamageInfo `mul`, after DEF / RES — and only the
|
||||
// first instance may give 受击回复 (砾's two 50 % hits, PRTS 砾 特性备注)
|
||||
const split = Number.isFinite(prof.hitDmgMul) && prof.hitDmgMul > 0 ? prof.hitDmgMul : null;
|
||||
let dealtMain = 0;
|
||||
if (attachedFunnel && info.index === 0) {
|
||||
const bodyHits = Math.max(1, prof.funnelBodyHits > 0 ? prof.funnelBodyHits : 1);
|
||||
for (let h = 0; h < bodyHits && target.alive; h++) {
|
||||
dealtMain += b.dealDamage(u, target, { amount: atk * scale * mulT, type: baseType,
|
||||
isAttack: true, isSkill: info.isSkill, tags: prof.tags || [], attackId });
|
||||
}
|
||||
}
|
||||
for (let h = 0; h < hits && target.alive; h++) {
|
||||
const d = { amount: atk * scale * mulT, type: baseType, isAttack: true, isSkill: info.isSkill, tags: prof.tags || [], attackId };
|
||||
const d = { amount: atk * scale * mulT * (attachedFunnel ? funnelMul : 1), type: baseType,
|
||||
isAttack: !attachedFunnel, isSkill: info.isSkill, tags: attachedFunnel ? [...(prof.tags || []), 'addition', 'funnel'] : (prof.tags || []), attackId };
|
||||
if (split != null) { d.mul = split; if (h > 0) d.noSp = true; }
|
||||
dealtMain += b.dealDamage(u, target, d);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { ROWS, COLS } from '../constants.js';
|
||||
import { absoluteRangeKeys, canTargetEnemy, extendedGrid, enemyStealthed } from '../targeting.js';
|
||||
import { bodyKeys, bodyInKeys, bodyInRadius } from '../body.js';
|
||||
import { roundHalfEven } from '../detmath.js';
|
||||
|
||||
export class BattleQueries {
|
||||
/**
|
||||
@@ -21,7 +22,7 @@ export class BattleQueries {
|
||||
for (const k of bodyKeys(e)) { const b = this._eb[k]; if (!b.length) this._ebUsed.push(k); b.push(e); }
|
||||
continue;
|
||||
}
|
||||
const r = Math.round(e.y), c = Math.round(e.x);
|
||||
const r = roundHalfEven(e.y), c = roundHalfEven(e.x); // the tile body.js gives a point enemy
|
||||
if (r < 0 || r >= ROWS || c < 0 || c >= COLS) continue;
|
||||
const k = r * COLS + c;
|
||||
const b = this._eb[k];
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// and the list compaction.
|
||||
// Installed on Battle.prototype by server/sim/Battle.js (a method container: never instantiated; `this` is the battle).
|
||||
|
||||
import { MAX_ALIVE_ENEMIES } from '../constants.js';
|
||||
import { MAX_ALIVE_ENEMIES, FIELD_EDGE_INSET } from '../constants.js';
|
||||
import { Unit } from '../units.js';
|
||||
import { compileRoute } from '../ai.js';
|
||||
import { unitInfo } from '../snapshot.js';
|
||||
@@ -201,11 +201,11 @@ export class BattleSpawns {
|
||||
}
|
||||
|
||||
_clampPos(e) {
|
||||
const R = this.rect;
|
||||
if (e.x < R.c0 - 0.5) e.x = R.c0 - 0.5;
|
||||
if (e.x > R.c1 + 0.5) e.x = R.c1 + 0.5;
|
||||
if (e.y < R.r0 - 0.5) e.y = R.r0 - 0.5;
|
||||
if (e.y > R.r1 + 0.5) e.y = R.r1 + 0.5;
|
||||
const R = this.rect, m = 0.5 - FIELD_EDGE_INSET; // inside the edge: on the edge tile, never halfway (body.js)
|
||||
if (e.x < R.c0 - m) e.x = R.c0 - m;
|
||||
if (e.x > R.c1 + m) e.x = R.c1 + m;
|
||||
if (e.y < R.r0 - m) e.y = R.r0 - m;
|
||||
if (e.y > R.r1 + m) e.y = R.r1 + m;
|
||||
}
|
||||
|
||||
_compactEnemies() {
|
||||
|
||||
+7
-6
@@ -1,8 +1,9 @@
|
||||
// server/sim/body.js — where a unit can be hit: the ONE helper behind every range test that targets enemies (user
|
||||
// playtest #5 item 10: "大体型的关底boss实际受击判定范围很小…原版是很大的一片区域").
|
||||
//
|
||||
// Regular units are a point: in a grid range when the tile containing their position (round(y), round(x)) is a range
|
||||
// tile, in a radius when their position is (DESIGN §3). Huge units (巨型单位 — enemy data `hitArea`, tools/build-data.mjs
|
||||
// Regular units are a point: in a grid range when the tile containing their position is a range tile — the position
|
||||
// rounded half to even (detmath roundHalfEven; PRTS 作战机制 "受击方坐标经round函数取整(四舍六入五成双)得到其所属格
|
||||
// 坐标") —, in a radius when their position is (DESIGN §3). Huge units (巨型单位 — enemy data `hitArea`, tools/build-data.mjs
|
||||
// HIT_AREAS, from PRTS "巨型单位:受击判定区域为长4.95、宽2.95的长方形,向上偏移1.0") are hit anywhere on a rectangle
|
||||
// `w` tiles along the columns × `h` along the rows, centred on their position moved `dx` columns right and `dy` rows
|
||||
// up:
|
||||
@@ -24,7 +25,7 @@
|
||||
// `hitRect`).
|
||||
|
||||
import { ROWS, COLS } from './constants.js';
|
||||
import { hypot } from './detmath.js';
|
||||
import { hypot, roundHalfEven } from './detmath.js';
|
||||
|
||||
/**
|
||||
* Validated hit area of a data record (`{ w, h, dx, dy }`, tiles) or null for a regular (point) unit.
|
||||
@@ -47,7 +48,7 @@ export function hitRect(u) {
|
||||
|
||||
/** Tile key of a unit's position (-1 off the grid). */
|
||||
function posKey(u) {
|
||||
const r = Math.round(u.y), c = Math.round(u.x);
|
||||
const r = roundHalfEven(u.y), c = roundHalfEven(u.x);
|
||||
return r < 0 || r >= ROWS || c < 0 || c >= COLS ? -1 : r * COLS + c;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ export function bodyKeys(u) {
|
||||
/** Does the unit occupy tile (r, c)? */
|
||||
export function bodyOnTile(u, r, c) {
|
||||
const R = hitRect(u);
|
||||
if (!R) return Math.round(u.y) === r && Math.round(u.x) === c;
|
||||
if (!R) return roundHalfEven(u.y) === r && roundHalfEven(u.x) === c;
|
||||
return c + 0.5 > R.x0 + 1e-9 && c - 0.5 < R.x1 - 1e-9 && r + 0.5 > R.y0 + 1e-9 && r - 0.5 < R.y1 - 1e-9;
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ export function bodyInRadius(u, x, y, r) {
|
||||
* around it; …): "周围八格"-style square areas centred on a tile.
|
||||
*/
|
||||
export function bodyTileReach(u, r, c) {
|
||||
if (!u.hitArea) return Math.max(Math.abs(Math.round(u.y) - r), Math.abs(Math.round(u.x) - c));
|
||||
if (!u.hitArea) return Math.max(Math.abs(roundHalfEven(u.y) - r), Math.abs(roundHalfEven(u.x) - c));
|
||||
let best = Infinity;
|
||||
for (const k of bodyKeys(u)) {
|
||||
const kr = Math.floor(k / COLS), kc = k % COLS;
|
||||
|
||||
@@ -220,6 +220,15 @@ export const MAX_ALIVE_ENEMIES = 600;
|
||||
/** Heal-over-time / regen events are aggregated and only emitted when they reach this amount. */
|
||||
export const REGEN_EVENT_MIN = 1;
|
||||
|
||||
/**
|
||||
* How far inside the field rectangle an enemy is held (tiles; Battle._clampPos). [ASSUMED] The rectangle's edge lies
|
||||
* exactly halfway between two tiles, where the tile of a position — rounded half to even (body.js; PRTS 作战机制
|
||||
* 四舍六入五成双) — would depend on whether the row or column number is even. Held this little inside, an enemy at the
|
||||
* edge stays on the edge tile. 2^-20 is exact in binary and too small to move a slide of 0.1-tile steps; a 1/1024 inset
|
||||
* did move those steps.
|
||||
*/
|
||||
export const FIELD_EDGE_INSET = 1 / 1048576;
|
||||
|
||||
/** Row offset mapping board rows (9..12) onto boss-field rows (2..5). */
|
||||
export const BOSS_ROW_OFFSET = -7;
|
||||
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
// server/sim/content/kits/ops/chess_char_2_10-rockr.js — 洛洛 (char_4040_rockr) kit, tier 2.
|
||||
// Conventions of the tier-2 kits: ../shared/tier2.js; kit contract and rules: ../README.md.
|
||||
|
||||
import { canTargetEnemy } from '../../../targeting.js';
|
||||
import { bodyInKeys } from '../../../body.js';
|
||||
import { canTargetEnemy, sortEnemyTargets } from '../../../targeting.js';
|
||||
import { num, talentBb, up } from '../shared/tier1.js';
|
||||
import { onDefaultSkill } from '../shared/tier2.js';
|
||||
|
||||
export const DRONE_TAG = 'rockr:drone';
|
||||
|
||||
const firstTarget = (battle, unit) => {
|
||||
const prof = unit.profile;
|
||||
const candidates = battle.enemiesInKeys(unit.rangeKeys, unit, prof);
|
||||
for (const e of battle.blockedTargets(unit, prof)) if (!candidates.includes(e)) candidates.push(e);
|
||||
sortEnemyTargets(battle, unit, candidates, prof.priority);
|
||||
return candidates[0] ?? null;
|
||||
};
|
||||
|
||||
export default {
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// 2_10 洛洛 自负此轭: ASPD +attack_speed; the drones lock on their target until it dies or the skill ends.
|
||||
// 2_10 洛洛 自负此轭: ASPD +attack_speed. The skill releases its drone, which keeps the lock after the target leaves
|
||||
// her range and returns only when that enemy dies or the skill ends (docs/research/03-operators.md, skchr_rockr_2).
|
||||
// While it is out, the unreleased drone's additional damage is off and the drone's own hits are skill damage.
|
||||
// 过载 (term ba.overdrive "技能进行到一半时触发额外效果"): the second half of the duration — ATK +atk and the funnel cap
|
||||
// ×scale; when the skill ends she is stunned as long as the overload lasted. 立于磐石: ATK +atk per `interval` s on the
|
||||
// field, up to max_stack_cnt stacks.
|
||||
// S1 战术咏唱·γ型 (alt): ASPD +attack_speed; the target lock belongs to 自负此轭 only.
|
||||
chess_char_2_10_a: (bb, chess) => {
|
||||
const t = talentBb(chess, 0);
|
||||
const s2 = onDefaultSkill(chess);
|
||||
const endOverload = (battle, unit) => {
|
||||
if (unit.mem.rockFunnel) { unit.profile.funnel = unit.mem.rockFunnel; unit.mem.rockFunnel = null; }
|
||||
battle.removeBuff(unit, 'rockr:overload');
|
||||
@@ -26,19 +35,53 @@ export default {
|
||||
onStart({ battle, unit, skill }) {
|
||||
unit.mem.rockOverAt = battle.time + skill.duration / 2;
|
||||
unit.mem.rockOver = false;
|
||||
unit.mem.rockLock = null;
|
||||
// The released drone inherits the trait's ramp; the body still attacks only inside its own range.
|
||||
// `funnelMul` separates the addition; older profiles fold it into `dmgMul`. Keep launched shots unchanged.
|
||||
const key = typeof unit.profile.funnelMul === 'function' ? 'funnelMul' : 'dmgMul';
|
||||
const mul = unit.profile[key];
|
||||
unit.profile = { ...unit.profile, [key]: null };
|
||||
const lock = firstTarget(battle, unit);
|
||||
unit.mem.rockDrone = { lock, cd: 0, key, mul,
|
||||
target: unit.trait.funnelTarget, scale: unit.trait.funnelScale };
|
||||
unit.mem.rockLock = lock;
|
||||
},
|
||||
onTick({ battle, unit }) {
|
||||
if (unit.mem.rockOver || battle.time + 1e-9 < unit.mem.rockOverAt) return;
|
||||
unit.mem.rockOver = true;
|
||||
onTick({ battle, unit, dt }) {
|
||||
if (!unit.mem.rockOver && battle.time + 1e-9 >= unit.mem.rockOverAt) {
|
||||
unit.mem.rockOver = true;
|
||||
const f = unit.profile.funnel;
|
||||
if (f) { unit.mem.rockFunnel = f; unit.profile.funnel = { ...f, max: f.max * num(bb.scale, 1) }; }
|
||||
battle.addBuff(unit, { key: 'rockr:overload', mods: { atkPct: num(bb.atk) }, visible: true, tags: ['skill'] });
|
||||
battle.fx('overload', { x: unit.x, y: unit.y, id: unit.id });
|
||||
}
|
||||
const d = unit.mem.rockDrone;
|
||||
if (!d || !unit.alive || !unit.skill.active) return;
|
||||
d.cd = Math.max(0, d.cd - dt);
|
||||
// [ASSUMED] A newly unselectable lock is dropped and the drone retargets. No flight delay, and body control
|
||||
// (stun and the like) does not pause the released drone — same as the other independent skill drones.
|
||||
if (d.lock && !canTargetEnemy(unit, d.lock, unit.profile)) d.lock = null;
|
||||
if (!d.lock) d.lock = firstTarget(battle, unit);
|
||||
unit.mem.rockLock = d.lock;
|
||||
if (!d.lock || d.cd > 1e-9) return;
|
||||
d.cd = unit.s.interval;
|
||||
// Official S2 releases one drone (1 + attack@cnt = 1 at both ranks). The ramp lives on the drone, so a
|
||||
// pre-skill projectile that lands later cannot change it.
|
||||
const f = unit.profile.funnel;
|
||||
if (f) { unit.mem.rockFunnel = f; unit.profile.funnel = { ...f, max: f.max * num(bb.scale, 1) }; }
|
||||
battle.addBuff(unit, { key: 'rockr:overload', mods: { atkPct: num(bb.atk) }, visible: true, tags: ['skill'] });
|
||||
battle.fx('overload', { x: unit.x, y: unit.y, id: unit.id });
|
||||
d.scale = d.target === d.lock.id ? Math.min(f.max, (d.scale ?? f.init) + f.delta) : f.init;
|
||||
d.target = d.lock.id;
|
||||
battle.fx('drone', { x: d.lock.x, y: d.lock.y, id: unit.id });
|
||||
battle.dealDamage(unit, d.lock, { amount: unit.s.atk * unit.s.atkScaleMul * d.scale,
|
||||
type: 'arts', isSkill: true, isAttack: false, tags: ['skill', 'drone', DRONE_TAG] });
|
||||
},
|
||||
onEnd({ battle, unit, reason }) {
|
||||
const over = unit.mem.rockOver ? battle.time - unit.mem.rockOverAt : 0;
|
||||
const d = unit.mem.rockDrone;
|
||||
unit.mem.rockDrone = null;
|
||||
endOverload(battle, unit);
|
||||
if (d) {
|
||||
unit.trait.funnelTarget = d.target;
|
||||
unit.trait.funnelScale = d.scale;
|
||||
unit.profile = { ...unit.profile, [d.key]: d.mul };
|
||||
}
|
||||
unit.mem.rockOver = false;
|
||||
unit.mem.rockLock = null;
|
||||
if (over > 0 && reason !== 'death' && unit.alive) battle.applyStatus(unit, 'stun', { duration: over, source: unit });
|
||||
@@ -46,12 +89,6 @@ export default {
|
||||
},
|
||||
skills: { 'skcom_magic_rage[3]': { kind: 'duration', mods: { aspd: num(bb.attack_speed) } } },
|
||||
talents: [{ install(battle, unit) {
|
||||
if (s2) battle.on('beforeAttack', (ctx) => {
|
||||
if (ctx.attacker !== unit || !unit.skill?.active) return;
|
||||
const L = unit.mem.rockLock;
|
||||
if (L && L.alive && bodyInKeys(L, unit.rangeKeySet) && canTargetEnemy(unit, L, ctx.profile || unit.profile)) ctx.targets = [L];
|
||||
else unit.mem.rockLock = ctx.targets[0] ?? null;
|
||||
}, { owner: unit });
|
||||
const iv = num(t.interval), max = Math.floor(num(t.max_stack_cnt)), v = num(t.atk);
|
||||
if (!(iv > 0) || !(max > 0) || !v) return;
|
||||
battle.on('tick', () => {
|
||||
|
||||
@@ -12,10 +12,10 @@ export default {
|
||||
const hits = textNum(d.skill?.description, /连续攻击(\d+|[一二两三四五])次/, 2);
|
||||
const insight = (battle) => (battle.rng.chance(num(t0.prob, 0)) ? num(t0.atk_scale, 1) : 1);
|
||||
return {
|
||||
trait: { dmgMul: (battle, unit, target) => funnelMap(battle, unit, target) * insight(battle) },
|
||||
trait: { funnelMul: funnelMap, dmgMul: insight },
|
||||
skill: {
|
||||
kind: charges > 1 ? 'charges' : 'instant',
|
||||
attack: { atkScale: num(bb.atk_scale, 1), hits, dmgType: 'arts', dmgMul: (battle) => insight(battle) },
|
||||
attack: { atkScale: num(bb.atk_scale, 1), hits, funnelBodyHits: hits, dmgType: 'arts', dmgMul: insight },
|
||||
},
|
||||
// S1 迅捷打击·γ型: ATK / ASPD + (the drones' ramp and 忽有所悟 stay on every attack through the trait)
|
||||
skills: altSkills(chess, d, bb, { 'skcom_quickattack[3]': statSkill }),
|
||||
|
||||
@@ -2,42 +2,136 @@
|
||||
// Conventions of the tier-3 kits: ../shared/tier3.js; kit contract and rules: ../README.md.
|
||||
|
||||
import { COLS } from '../../../constants.js';
|
||||
import { canTargetEnemy, sortEnemyTargets } from '../../../targeting.js';
|
||||
import { num, defOf, talentBb, altSkills, statSkill, funnelMap, installFunnelPrune } from '../shared/tier3.js';
|
||||
|
||||
export const DRONE_TAG = 'kjera:drone';
|
||||
|
||||
// One step of the per-target ramp. Two drones that hit the same enemy in the same tick share the step (funnelMap).
|
||||
function stepMap(ramp, id, time, f) {
|
||||
const prev = ramp.get(id);
|
||||
if (prev && prev.t === time) return prev.s;
|
||||
const s = prev == null ? f.init : Math.min(f.max, prev.s + f.delta);
|
||||
ramp.set(id, { s, t: time });
|
||||
return s;
|
||||
}
|
||||
|
||||
function acquire(battle, unit, rel) {
|
||||
const prof = unit.profile;
|
||||
const ok = (e) => !!e && e.alive && canTargetEnemy(unit, e, prof);
|
||||
const cands = battle.enemiesInKeys(unit.rangeKeys, unit, prof);
|
||||
for (const e of battle.blockedTargets(unit, prof)) if (!cands.includes(e)) cands.push(e);
|
||||
sortEnemyTargets(battle, unit, cands, prof.priority);
|
||||
const usable = cands.filter(ok);
|
||||
const held = new Set();
|
||||
for (const d of rel.drones) {
|
||||
if (d.lock && ok(d.lock)) held.add(d.lock);
|
||||
else { d.lock = null; d.scale = null; }
|
||||
}
|
||||
for (const d of rel.drones) {
|
||||
if (d.lock) continue;
|
||||
const e = usable.find((x) => !held.has(x)) ?? usable[0] ?? rel.drones.find((x) => x.lock)?.lock ?? null;
|
||||
if (!e) continue;
|
||||
held.add(e);
|
||||
d.lock = e;
|
||||
d.scale = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 心随意动 (skchr_kjera_2, docs/research/03-operators.md): release `1 + attack@cnt` drones that stay locked until the
|
||||
* enemy dies or the skill ends, ATK +, and a cold roll on her own attack and on each drone hit. The body keeps its
|
||||
* ordinary attack inside her range; the unreleased addition is off while the drones are out.
|
||||
* `restart` (hidden form): each drone begins at the trait's initial scale and is not written back.
|
||||
* Otherwise the drones continue the per-target ramp and that map is restored when the skill ends.
|
||||
* [ASSUMED] The released drones use the trait ramp (init / +delta / cap). Her blackboard has no drone scale.
|
||||
* [ASSUMED] No flight delay. A lock that can no longer be targeted is dropped and the drone retargets. Stun and
|
||||
* disarm do not pause the released drones (the skill tick still runs).
|
||||
*/
|
||||
export function kjeraRelease(bb, { restart = false, announce = false } = {}) {
|
||||
const n = 1 + Math.max(0, Math.floor(num(bb['attack@cnt'], 0)));
|
||||
const prob = num(bb['attack@prob'], 0), cold = num(bb['attack@cold'], 0);
|
||||
return {
|
||||
skill: {
|
||||
kind: 'duration',
|
||||
mods: { atkPct: num(bb.atk) },
|
||||
onStart({ battle, unit }) {
|
||||
const key = typeof unit.profile.funnelMul === 'function' ? 'funnelMul' : 'dmgMul';
|
||||
const mul = unit.profile[key];
|
||||
unit.profile = { ...unit.profile, [key]: null };
|
||||
const ramp = restart ? null : new Map();
|
||||
if (ramp && unit.trait.funnelMap) {
|
||||
for (const [id, v] of unit.trait.funnelMap) ramp.set(id, { s: v.s, t: v.t });
|
||||
}
|
||||
unit.mem.kjeraRel = {
|
||||
key, mul, restart, ramp, cd: 0,
|
||||
target: unit.trait.funnelTarget ?? null,
|
||||
scale: unit.trait.funnelScale,
|
||||
drones: Array.from({ length: n }, () => ({ lock: null, scale: null })),
|
||||
};
|
||||
if (announce) battle.fx('drones', { x: unit.x, y: unit.y, id: unit.id, n });
|
||||
},
|
||||
onTick({ battle, unit, dt }) {
|
||||
const rel = unit.mem.kjeraRel;
|
||||
if (!rel || !unit.alive || !unit.skill?.active) return;
|
||||
rel.cd = Math.max(0, rel.cd - dt);
|
||||
acquire(battle, unit, rel);
|
||||
if (!rel.drones.some((d) => d.lock) || rel.cd > 1e-9) return;
|
||||
rel.cd = unit.s.interval;
|
||||
const f = unit.profile.funnel || { init: 0.2, delta: 0.15, max: 1.1 };
|
||||
for (const d of rel.drones) {
|
||||
if (!d.lock || !d.lock.alive) continue;
|
||||
const scale = rel.restart
|
||||
? (d.scale = d.scale == null ? f.init : Math.min(f.max, d.scale + f.delta))
|
||||
: stepMap(rel.ramp, d.lock.id, battle.time, f);
|
||||
battle.fx('drone', { x: d.lock.x, y: d.lock.y, id: unit.id });
|
||||
battle.dealDamage(unit, d.lock, {
|
||||
amount: unit.s.atk * unit.s.atkScaleMul * scale, type: 'arts',
|
||||
isSkill: true, isAttack: false, tags: ['skill', 'drone', DRONE_TAG],
|
||||
});
|
||||
if (d.lock.alive && cold > 0 && battle.rng.chance(prob)) {
|
||||
battle.applyStatus(d.lock, 'cold', { duration: cold, source: unit });
|
||||
}
|
||||
}
|
||||
},
|
||||
onEnd({ unit }) {
|
||||
const rel = unit.mem.kjeraRel;
|
||||
unit.mem.kjeraRel = null;
|
||||
if (!rel) return;
|
||||
unit.trait.funnelTarget = rel.target;
|
||||
unit.trait.funnelScale = rel.scale;
|
||||
if (rel.ramp) unit.trait.funnelMap = rel.ramp;
|
||||
if (unit.profile && rel.key) unit.profile = { ...unit.profile, [rel.key]: rel.mul };
|
||||
},
|
||||
},
|
||||
install(battle, unit) {
|
||||
// 自身攻击: one cold roll on the ordinary body hit. Drone hits roll in onTick, so they are not rolled again.
|
||||
battle.on('damaged', (ctx) => {
|
||||
if (!unit.mem.kjeraRel || ctx.source !== unit || !ctx.target?.alive || !ctx.dmg) return;
|
||||
if (!ctx.dmg.isAttack || ctx.dmg.isSkill) return;
|
||||
const tags = ctx.dmg.tags || [];
|
||||
if (tags.includes('addition') || tags.includes('funnel') || tags.includes(DRONE_TAG)) return;
|
||||
if (!(cold > 0) || !battle.rng.chance(prob)) return;
|
||||
battle.applyStatus(ctx.target, 'cold', { duration: cold, source: unit });
|
||||
}, { owner: unit });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
// ---- 3_20 耶拉 · 驭械术师 — S2 心随意动: +1 drone (2 locks; a lone enemy gets both), ATK +, cold procs; 低眉: ATK +
|
||||
// (more with ≥cnt ground tiles in range)
|
||||
// (more with ≥cnt ground tiles in range). S1 攻击力强化·γ型: ATK + only (one unreleased drone, the trait ramp).
|
||||
chess_char_3_20_a: (bb, chess, def) => {
|
||||
const d = defOf(chess, def);
|
||||
const t0 = talentBb(d, 0);
|
||||
const extra = Math.floor(num(bb['attack@cnt'], 0));
|
||||
const prob = num(bb['attack@prob'], 0), cold = num(bb['attack@cold'], 0);
|
||||
const kit = {
|
||||
trait: { dmgMul: funnelMap },
|
||||
skill: {
|
||||
kind: 'duration',
|
||||
mods: { atkPct: num(bb.atk) },
|
||||
attack: { onHit({ battle, unit, target }) {
|
||||
if (target && target.alive && cold > 0 && battle.rng.chance(prob)) battle.applyStatus(target, 'cold', { duration: cold, source: unit });
|
||||
} },
|
||||
},
|
||||
// S1 攻击力强化·γ型: ATK + (one drone, the trait ramp as usual)
|
||||
const rel = kjeraRelease(bb, { restart: false });
|
||||
return {
|
||||
trait: { funnelMul: funnelMap },
|
||||
skill: rel.skill,
|
||||
skills: altSkills(chess, d, bb, { 'skcom_atk_up[3]': statSkill }),
|
||||
install(battle, unit) {
|
||||
installFunnelPrune(battle, unit);
|
||||
// "浮游单元+1": every drone locks an enemy — with fewer enemies in range than drones, the spare drone joins a
|
||||
// lock (both attack it, each hit rolls the cold proc; they ramp in parallel, see funnelMap)
|
||||
if (extra > 0) {
|
||||
battle.on('beforeAttack', (ctx) => {
|
||||
if (ctx.attacker !== unit || !unit.skill?.active || !ctx.targets.length) return;
|
||||
const n = 1 + extra;
|
||||
if (ctx.targets.length >= n) return;
|
||||
const base = ctx.targets.slice();
|
||||
const out = base.slice();
|
||||
for (let i = 0; out.length < n; i++) out.push(base[i % base.length]);
|
||||
ctx.targets = out;
|
||||
}, { owner: unit, priority: -50 });
|
||||
}
|
||||
rel.install(battle, unit);
|
||||
},
|
||||
talents: [{ install(battle, unit) {
|
||||
battle.on('deploy', (ctx) => {
|
||||
@@ -52,7 +146,5 @@ export default {
|
||||
}, { owner: unit });
|
||||
} }],
|
||||
};
|
||||
if (extra > 0) kit.skill.targeting = { maxTargets: 1 + extra };
|
||||
return kit;
|
||||
},
|
||||
};
|
||||
@@ -2,35 +2,18 @@
|
||||
// Conventions of the tier-4 kits: ../shared/tier4.js; kit contract and rules: ../README.md.
|
||||
|
||||
import { COLS } from '../../../constants.js';
|
||||
import { canTargetEnemy } from '../../../targeting.js';
|
||||
import { num, tbb, skillActive, withDefaults } from '../shared/tier4.js';
|
||||
import { num, tbb, withDefaults } from '../shared/tier4.js';
|
||||
import { kjeraRelease } from './chess_char_3_20-kjera.js';
|
||||
|
||||
export default withDefaults({
|
||||
// ===== 耶拉 (funnel, hidden) S2 心随意动 — +1 drone locking targets, ATK up, chance to chill; talent 低眉
|
||||
// ===== 耶拉 (funnel, hidden) S2 心随意动 — +1 drone locking targets, ATK up, chance to chill; talent 低眉.
|
||||
// Each released drone restarts at the trait's initial scale (it does not continue the pre-skill ramp) and those
|
||||
// scales are not written back onto the single trait ramp. The body stays an ordinary in-range attack.
|
||||
chess_char_4_03_a: (bb, chess, def) => {
|
||||
const t0 = tbb(def, 0);
|
||||
const n = 1 + Math.max(0, Math.floor(num(bb['attack@cnt'], 1)));
|
||||
const prob = num(bb['attack@prob'], 0), cold = num(bb['attack@cold'], 0);
|
||||
const funnel = (unit) => unit.profile.funnel || { init: 0.2, delta: 0.15, max: 1.1 };
|
||||
const rel = kjeraRelease(bb, { restart: true, announce: true });
|
||||
return {
|
||||
skill: {
|
||||
kind: 'duration',
|
||||
mods: { atkPct: num(bb.atk) },
|
||||
targeting: { maxTargets: n },
|
||||
attack: {
|
||||
// every drone ramps on its own locked target (trait init/delta/max): the multipliers are queued per target
|
||||
// by the beforeAttack hook below (two drones on the same enemy ramp independently)
|
||||
dmgMul: (battle, unit, target) => {
|
||||
const q = unit.mem.kjeraQueue && unit.mem.kjeraQueue.get(target.id);
|
||||
return q && q.length ? q.shift() : funnel(unit).init;
|
||||
},
|
||||
onHit({ battle, unit, target }) {
|
||||
if (target && target.alive && cold > 0 && battle.rng.chance(prob)) battle.applyStatus(target, 'cold', { duration: cold, source: unit });
|
||||
},
|
||||
},
|
||||
onStart({ battle, unit }) { unit.mem.kjeraDrones = []; unit.mem.kjeraQueue = new Map(); battle.fx('drones', { x: unit.x, y: unit.y, id: unit.id, n }); },
|
||||
onEnd({ unit }) { unit.mem.kjeraDrones = []; unit.mem.kjeraQueue = null; },
|
||||
},
|
||||
skill: rel.skill,
|
||||
talents: [{ install(battle, unit) { // 低眉: ATK +10 %, +16 % with ≥ 2 ground tiles in range
|
||||
battle.on('deploy', (c) => {
|
||||
if (c.unit !== unit) return;
|
||||
@@ -40,38 +23,7 @@ export default withDefaults({
|
||||
battle.addBuff(unit, { key: 'kjera:t1', mods: { atkPct: v } });
|
||||
}, { owner: unit });
|
||||
} }],
|
||||
install(battle, unit) {
|
||||
// n drones, each locked on its enemy until that enemy dies (while at least one enemy is in her range). A free
|
||||
// drone takes an enemy no other drone holds, else doubles up on the best target (a lone enemy/boss gets both).
|
||||
battle.on('beforeAttack', (c) => {
|
||||
if (c.attacker !== unit || !skillActive(unit)) return;
|
||||
const ok = (e) => !!e && e.alive && canTargetEnemy(unit, e, { canHitFly: true });
|
||||
const cands = c.targets.filter(ok);
|
||||
const drones = unit.mem.kjeraDrones || (unit.mem.kjeraDrones = []);
|
||||
const held = new Set();
|
||||
for (let i = 0; i < n; i++) { if (drones[i] && ok(drones[i].e)) held.add(drones[i].e); else drones[i] = null; }
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (drones[i]) continue;
|
||||
const e = cands.find((x) => !held.has(x)) ?? cands[0] ?? drones.find((d) => d)?.e;
|
||||
if (!e) continue;
|
||||
held.add(e);
|
||||
drones[i] = { e, scale: null };
|
||||
}
|
||||
const f = funnel(unit);
|
||||
const q = unit.mem.kjeraQueue || (unit.mem.kjeraQueue = new Map());
|
||||
const out = [];
|
||||
for (const d of drones) {
|
||||
if (!d) continue;
|
||||
d.scale = d.scale == null ? f.init : Math.min(f.max, d.scale + f.delta);
|
||||
out.push(d.e);
|
||||
const l = q.get(d.e.id);
|
||||
if (l) l.push(d.scale); else q.set(d.e.id, [d.scale]);
|
||||
}
|
||||
if (out.length) c.targets = out;
|
||||
}, { owner: unit, priority: 10 });
|
||||
// queued multipliers of shots that never landed (target died mid-flight) are dropped with the target
|
||||
battle.on('death', (c) => { if (c.unit.side === 'enemy' && unit.mem.kjeraQueue) unit.mem.kjeraQueue.delete(c.unit.id); }, { owner: unit });
|
||||
},
|
||||
install(battle, unit) { rel.install(battle, unit); },
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -124,8 +124,10 @@ function whitw2(bb, chess, def) {
|
||||
|
||||
const skills = {
|
||||
// S1 慵怠者悲鸣: passive 浮游单元+1 (trait: one more hit per attack); toggled on: ATK +atk and the drones lock a random
|
||||
// non-moving enemy anywhere on the field (re-locking when it moves or falls; install), else her range. The whole-field
|
||||
// grid only selects those targets — no rangeId, no 攻击范围 in the text — so the card keeps her 3-1 (showOwnRange)
|
||||
// non-moving enemy anywhere on the field (re-locking when it moves or falls; install), else her range. The toggle
|
||||
// retargets her attack; the text does not say she stops attacking, so the body and both unreleased additions stay.
|
||||
// The whole-field grid only selects those targets — no rangeId, no 攻击范围 in the text — so the card keeps her 3-1
|
||||
// (showOwnRange)
|
||||
skchr_whitw2_1: {
|
||||
kind: 'toggle',
|
||||
// [ASSUMED] her drones lock enemies only (install): 白铁's 铁钳号 alone does not open S1 / S2 (skills.js allyTargetsOk)
|
||||
@@ -143,7 +145,9 @@ function whitw2(bb, chess, def) {
|
||||
...(skillGridW ? { targeting: { rangeGrid: skillGridW } } : {}),
|
||||
attack: {
|
||||
hits: 1,
|
||||
dmgMul(battle, unit, target) {
|
||||
// The skill names the released drones, not a second hit from her. 0 keeps the ramp inside these hits.
|
||||
funnelBodyHits: 0,
|
||||
funnelMul(battle, unit, target) {
|
||||
const f = unit.profile?.funnel || { init: 0.2, delta: 0.15, max: 1.1 };
|
||||
const m = unit.mem.hunt;
|
||||
if (!m) return f.init;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// projectile_chr_gdglow_funnel_s1_1 … s3_3 (`_lifeTimeType` 2: until stopped, `_stopWhenSourceInvalid`, its crash
|
||||
// AdvancedApplyDamage MAGICAL at atk_scale_2) and their s12 / s3 blast projectiles.
|
||||
// - Trait (驭械术师) "操作浮游单元造成法术伤害;单元攻击同一敌人伤害提升(最高造成干员110%攻击力的伤害)" (trait bb init / delta /
|
||||
// max_atk_scale): the engine's funnel profile (professions.js: her normal attack = one drone hit at init → +delta per hit on
|
||||
// max_atk_scale): the engine's funnel profile (professions.js: her normal attack = a body hit plus one drone addition at init → +delta per hit on
|
||||
// the same target → max). FUN-X: init 0.35 ("单元初始伤害提高"); FUN-Y: max 1.2. Ranged arts, 3-1, hits air (PRTS "可对空"),
|
||||
// blocks 1, ground enemies target her.
|
||||
// - Skill drones (the three skills "浮游单元+N,释放浮游单元锁定敌人攻击 … 锁敌后直至敌人被击杀、自爆或技能结束后返回干员身边"): while a
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// test/sim/detmath.test.js scans server/sim/).
|
||||
//
|
||||
// hypot(x, y) √(x² + y²) as Math.sqrt(x*x + y*y), rescaled by exact powers of two outside 2^±500
|
||||
// roundHalfEven(x) nearest integer, ties to even (四舍六入五成双); Math.round and Math.floor, never −0
|
||||
// powi(x, n) xⁿ for an integer n: square-and-multiply in double-double, one final rounding
|
||||
// sin(x), cos(x) fdlibm 5.3 (__kernel_sin / __kernel_cos / __ieee754_rem_pio2)
|
||||
// atan2(y, x) fdlibm (FreeBSD msun e_atan2.c / s_atan.c)
|
||||
@@ -46,6 +47,17 @@ export function hypot(x, y) {
|
||||
return Math.sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
/**
|
||||
* x rounded to an integer, ties to even (2.5 → 2, 3.5 → 4, −2.5 → −2): the rule PRTS 作战机制 gives for the tile of a
|
||||
* target — 受击方坐标经round函数取整(四舍六入五成双)得到其所属格坐标. Math.round rounds ties up (2.5 → 3). Exact; never −0.
|
||||
* @param {number} x
|
||||
*/
|
||||
export function roundHalfEven(x) {
|
||||
const f = Math.floor(x);
|
||||
if (x - f !== 0.5) return Math.round(x) + 0;
|
||||
return (f % 2 === 0 ? f : f + 1) + 0;
|
||||
}
|
||||
|
||||
// ---- integer powers ----------------------------------------------------------------------------------------------
|
||||
|
||||
const SPLIT = 134217729; // 2^27 + 1 (Dekker)
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
// noAttack bool (never attacks) noAttackUnlessSkill bool (attacks only while its skill is active)
|
||||
// noHeal bool (cannot be healed by others) blockFly bool onHitStatus {key, duration, value}
|
||||
// dmgMul(battle, unit, target) → number afterHit(battle, unit, target, {dealt,x,y})
|
||||
// funnelMul(battle, unit, target) → number (drone ramp, separate from the caster's attack multiplier)
|
||||
// funnelBodyHits n (body hits kept beside that ramp. Omit it for one. 0: drone-only, ramp folded into the hits,
|
||||
// no body — 荒芜拉普兰德 S2. >0: that many body hits — 至简 S2. Not keyed off the skill flag)
|
||||
// canAttack(battle, unit) → bool afterAttack(battle, unit, targets)
|
||||
// skipEnemy(enemy) → bool (an enemy the unit never selects — targeting.js canTargetEnemy; 嵯峨 "不攻击重伤单位")
|
||||
// healThrough(healer, ally) → bool (a healer that selects and heals that ally through its 禁疗 — Battle
|
||||
@@ -385,8 +388,17 @@ const installTactician = (battle, unit) => {
|
||||
};
|
||||
|
||||
const installFunnel = (battle, unit) => {
|
||||
unit.trait.funnelTarget = null;
|
||||
unit.trait.funnelScale = unit.profile.funnel?.init ?? 0.2;
|
||||
// PRTS 分支特性信息 驭械术师: changing the target, or redeploying, resets the drone ramp at once, even against the
|
||||
// same living enemy. The per-target map (耶拉 / 至简) resets with it. A free move (moveRedeploy, the same carry as a
|
||||
// 秘术师's stored energy and 乌尔比安 S3) keeps the ramp. An in-flight drone still applies the ramp it computes on
|
||||
// impact, so a shot launched before the reset can step the new ramp.
|
||||
const reset = () => {
|
||||
unit.trait.funnelTarget = null;
|
||||
unit.trait.funnelScale = unit.profile.funnel?.init ?? 0.2;
|
||||
unit.trait.funnelMap?.clear();
|
||||
};
|
||||
reset();
|
||||
battle.on('deploy', (ctx) => { if (ctx.unit === unit && !ctx.move) reset(); }, { owner: unit });
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -508,7 +520,7 @@ export const SUB = Object.freeze({
|
||||
blastcaster: P({ rangeAoe: true }),
|
||||
chain: P({ chain: { count: 3, falloff: 0.15, radius: CHAIN_RADIUS, sluggish: 0.5 } }),
|
||||
funnel: P({ projectile: 'drone', install: installFunnel,
|
||||
dmgMul: (battle, unit, target) => {
|
||||
funnelMul: (battle, unit, target) => {
|
||||
const f = unit.profile.funnel || { init: 0.2, delta: 0.15, max: 1.1 };
|
||||
if (unit.trait.funnelTarget === target.id) unit.trait.funnelScale = Math.min(f.max, (unit.trait.funnelScale ?? f.init) + f.delta);
|
||||
else { unit.trait.funnelTarget = target.id; unit.trait.funnelScale = f.init; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Grid ranges: `[dRow, dCol]` offsets relative to facing RIGHT, rotated by the unit's direction (sim/dir.js: RIGHT
|
||||
// (dr,dc), UP (dc,−dr), LEFT (−dr,−dc), DOWN (−dc,dr); row 0 = bottom). An enemy is in range when the tile containing
|
||||
// it (round(y), round(x)) is one of the absolute range tiles — a huge enemy (巨型单位) when any tile its hit rectangle
|
||||
// it (rounded half to even, detmath roundHalfEven; PRTS 作战机制 四舍六入五成双) is one of the absolute range tiles — a huge enemy (巨型单位) when any tile its hit rectangle
|
||||
// occupies is (body.js; user playtest #5 item 10). `rangeExtend` (ability_range_forward_extend) adds N tiles
|
||||
// past the furthest cell of every row, along +dCol BEFORE rotating (DESIGN §3).
|
||||
// Operator priority: (1) enemies it blocks (every blocker, ranged ones on melee tiles included — user playtest #6
|
||||
@@ -17,6 +17,7 @@
|
||||
import { COLS, ROWS } from './constants.js';
|
||||
import { normDir, rotateOffset } from './dir.js';
|
||||
import { bodyDist } from './body.js';
|
||||
import { roundHalfEven } from './detmath.js';
|
||||
|
||||
/**
|
||||
* Build the absolute tile-key list of a grid for a unit standing at (r,c) facing `dir` ('UP'|'RIGHT'|'DOWN'|'LEFT';
|
||||
@@ -50,9 +51,9 @@ export function absoluteRangeKeys(grid, r, c, dir, extend = 0) {
|
||||
// record range (shared/loadoutRecord.js attackRangeGrid), re-exported here for the battle (Battle._refreshRange).
|
||||
export { extendedGrid } from '../../shared/loadoutRecord.js';
|
||||
|
||||
/** Tile key of a unit's current position. */
|
||||
/** Tile key of a unit's current position (rounded half to even, as body.js). */
|
||||
export function tileKeyOf(u) {
|
||||
const r = Math.round(u.y), c = Math.round(u.x);
|
||||
const r = roundHalfEven(u.y), c = roundHalfEven(u.x);
|
||||
if (r < 0 || r >= ROWS || c < 0 || c >= COLS) return -1;
|
||||
return r * COLS + c;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user