Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions calc-sidecar/src/backends/rocalc/form-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ <h3><img src="images/magno.gif" alt="(icon)" style="margin:0 19px 0 0; vertical-
<!--<span name="show_ActiveSkillLV"></span>--><select name="A_ActiveSkillLV" onchange="calc()"><option value="-">-</option></select>
<!--<span id="AASkillName"></span><span id="AASkill"></span>-->
</td></tr>
<tr><td colspan="2" class="subheader" style="padding-top:0;"><span id="AASkill" style="float:right;"></span></td></tr>
<tr><td colspan="2" class="subheader" style="padding-top:0;"><span id="AASkill" style="float:right;"><!-- Seeds the SkillSubNum name into form.elements so installFormNameProxies registers a live getter for it. rocalc replaces this via myInnerHtml(AASkill,...) when a sub-parameter skill is selected (Storm Gust hits, etc.); because the stub lives INSIDE AASkill, the inject clears it first, so there is never a duplicate-name collision. --><select id="SkillSubNum" name="SkillSubNum"></select></span></td></tr>

<tr><td id="nm053" class="right">Player's Hit Ratio</td><td><span id="BattleHIT"></span>%</td></tr>
<tr><td id="nm074" class="right">Attack Element</td><td id="A_WeaponElement"></td></tr>
Expand Down Expand Up @@ -927,7 +927,12 @@ <h3><img src="images/magno.gif" alt="(icon)" style="margin:0 19px 0 0; vertical-
<select id="SP_OBJ" name="SP_OBJ"></select>
<select id="S_LV" name="S_LV"></select>
<select id="S_OBJ" name="S_OBJ"></select>
<select id="SkillSubNum" name="SkillSubNum"></select>
<!-- SkillSubNum is intentionally NOT stubbed here. rocalc injects it into the
AASkill container per active skill (Storm Gust hits, Venom Splasher Poison
React lvl, Asura remaining SP, etc.) and guards every other read with
c.contains(c.SkillSubNum). A standalone stub collides with the injected
element (two same-named controls -> RadioNodeList, no .options), which
broke select-type sub-param skills. Matches rocalc's own index.html. -->
<select id="Smug_LV" name="Smug_LV"></select>
<select id="SocketChance" name="SocketChance"></select>
<select id="StartingRefine" name="StartingRefine"></select>
Expand Down
129 changes: 127 additions & 2 deletions calc-sidecar/src/backends/rocalc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,14 @@ export function createShim(): ShimSession {
// ATTACK_SKILL_BINDINGS maps a semantic attack-skill name to its rocalc
// A_ActiveSkill id. This is the only place rocalc's attack-skill ids live;
// the contract stays semantic. uncertainty mirrors the overlay caveat so the
// breakdown entry can carry it. Add a row per skill to onboard a class.
// breakdown entry can carry it. spheres (when set) is the spirit-sphere count
// a sphere-explosion skill needs to deal damage; computeSkillBreakdown drives
// A2_Skill12 to it while that skill is active. Add a row per skill to onboard.
const ATTACK_SKILL_BINDINGS: Record<
string,
{ rocalcId: number; uncertainty?: string }
{ rocalcId: number; uncertainty?: string; spheres?: number }
> = {
// Taekwon Kid
tornado_kick: { rocalcId: 331 },
heel_drop: { rocalcId: 333 },
roundhouse: { rocalcId: 335 },
Expand All @@ -502,6 +505,112 @@ export function createShim(): ShimSession {
uncertainty:
"rocalc cannot model Flying Kick's movement-distance scaling; damage approximated",
},
// Assassin / Assassin Cross. Sonic Blow probed lv10 = 1776 (8 hits) vs
// barehanded auto 222, matching the spec's ~8x baseline.
envenom: { rocalcId: 17 },
sonic_blow: { rocalcId: 83 },
grimtooth: {
rocalcId: 84,
uncertainty:
"rocalc flags Grimtooth damage as approximate (long-range vs melee is distance-dependent)",
},
venom_splasher: {
rocalcId: 88,
uncertainty:
"Venom Splasher's Poison React level sub-parameter defaults to 0",
},
poison_react: { rocalcId: 86 },
soul_breaker: {
rocalcId: 263,
uncertainty:
"rocalc flags Soul Breaker (Soul Destroyer) damage as differing slightly from in-game",
},
meteor_assault: { rocalcId: 264 },
sand_attack: { rocalcId: 19 },
throw_venom_knife: { rocalcId: 306 },
// Knight / Lord Knight (SM_/KN_ skills inherited by Lord Knight's tree too).
bash: { rocalcId: 6 },
magnum_break: { rocalcId: 7 },
pierce: { rocalcId: 70 },
spear_stab: { rocalcId: 71 },
spear_boomerang: { rocalcId: 72 },
brandish_spear: { rocalcId: 73 },
bowling_bash: { rocalcId: 76 },
charge_attack: { rocalcId: 308 },
spiral_pierce: { rocalcId: 259 },
head_crush: { rocalcId: 260 },
joint_beat: { rocalcId: 261 },
// Hunter / Sniper. Ranged skills compute off the equipped bow; barehanded
// probe numbers are a floor, the orchestrator supplies the weapon.
double_strafe: { rocalcId: 40 },
arrow_shower: { rocalcId: 41 },
charge_arrow: { rocalcId: 44 },
phantasmic_arrow: { rocalcId: 307 },
blitz_beat: { rocalcId: 118 },
land_mine: { rocalcId: 106 },
freezing_trap: { rocalcId: 111 },
blast_mine: { rocalcId: 112 },
claymore_trap: { rocalcId: 113 },
sharp_shooting: { rocalcId: 272 },
falcon_assault: { rocalcId: 271 },
// Wizard / High Wizard. Magic flows through A_ActiveSkill: damage scales
// off MATK (probed lv99 INT99: Lightning Bolt 7710, Jupitel 9252, Meteor
// Storm 7700).
fire_bolt: { rocalcId: 51 },
cold_bolt: { rocalcId: 54 },
lightning_bolt: { rocalcId: 56 },
fire_ball: { rocalcId: 52 },
fire_wall: { rocalcId: 53 },
frost_diver: { rocalcId: 55 },
thunder_storm: { rocalcId: 57 },
napalm_beat: { rocalcId: 46 },
soul_strike: { rocalcId: 47 },
fire_pillar: { rocalcId: 122 },
sightrasher: { rocalcId: 124 },
meteor_storm: { rocalcId: 125 },
jupitel_thunder: { rocalcId: 126 },
lord_of_vermilion: { rocalcId: 127 },
water_ball: { rocalcId: 128 },
frost_nova: { rocalcId: 130 },
storm_gust: {
rocalcId: 131,
uncertainty:
"Storm Gust hit count defaults to 3; actual hits depend on how long the target stays in the area",
},
earth_spike: { rocalcId: 132 },
heavens_drive: { rocalcId: 133 },
magic_crasher: { rocalcId: 275 },
napalm_vulcan: { rocalcId: 277 },
gravitation_field: { rocalcId: 325 },
// Monk / Champion (MO_ skills inherited by Champion's tree too). Finger
// Offensive and Ki Explosion explode spirit spheres: they read 0 unless
// A2_Skill12 (# of Spirit Spheres) is driven > 0, so they carry spheres.
holy_light: { rocalcId: 37 },
chain_combo: { rocalcId: 188 },
combo_finish: { rocalcId: 189 },
finger_offensive: {
rocalcId: 192,
spheres: 5,
uncertainty: "Finger Offensive damage assumes a full 5 spirit spheres",
},
excruciating_palm: {
rocalcId: 382,
spheres: 5,
uncertainty: "Ki Explosion damage assumes a full 5 spirit spheres",
},
investigate: {
rocalcId: 193,
uncertainty:
"Investigate/Occult Impaction damage scales with the target's DEF; near-zero against low-DEF mobs",
},
asura_strike: {
rocalcId: 197,
uncertainty:
"Asura Strike damage assumes a near-full SP pool (remaining SP defaults to max - 1)",
},
palm_push_strike: { rocalcId: 288 },
tiger_knuckle_fist: { rocalcId: 289 },
chain_crush_combo: { rocalcId: 290 },
};

type PendingAttackSkill = {
Expand All @@ -510,6 +619,7 @@ export function createShim(): ShimSession {
level: number;
primary: boolean;
uncertainty?: string;
spheres?: number;
};
let pendingAttackSkills: PendingAttackSkill[] = [];
let lastSkillBreakdown: SkillDamage[] | undefined = undefined;
Expand Down Expand Up @@ -1829,6 +1939,7 @@ export function createShim(): ShimSession {
level: sk.level,
primary: sk.primary ?? false,
uncertainty: bind.uncertainty,
spheres: bind.spheres,
});
}
// Exactly one skill drives the top-level CombatResults cells (the primary).
Expand Down Expand Up @@ -1874,6 +1985,18 @@ export function createShim(): ShimSession {
form.A_ActiveSkill.value = String(sk.rocalcId);
win.ClickActiveSkill();
setSelectClamped(form.A_ActiveSkillLV, sk.level);
// Spirit-sphere-explosion skills (Finger Offensive, Ki Explosion) read
// n_A_Buf2[12] and deal 0 without spheres. Drive A2_Skill12 to the
// skill's sphere count and enable the support section so StAllCalc reads
// it; clear it for non-sphere skills so the count doesn't carry over.
// n_SkillSW is only ever turned ON here (never off) so a build's own
// support buffs survive; reset() zeroes both between requests.
if (sk.spheres) {
setSelectClamped(form.A2_Skill12, sk.spheres);
win.n_SkillSW = 1;
} else {
form.A2_Skill12.value = "0";
}
win.StAllCalc();
win.StCalc();
win.calc();
Expand Down Expand Up @@ -2091,6 +2214,8 @@ function installBuffControls(doc: Document): void {
A2_Skill2: 5,
A2_Skill4: 10,
A2_Skill10: 3,
A2_Skill12: 5, // # of Spirit Spheres (0..5); drives sphere-explosion attack skills

B_debuf11: 10,
B_debuf12: 10,
B_debuf18: 5,
Expand Down
119 changes: 119 additions & 0 deletions calc-sidecar/test/backends/rocalc/attack_skills_classes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { createShim } from "../../../src/shim.ts";

// Per-class attack-skill coverage beyond the Taekwon kicks. Each case spins its
// own shim (distinct class). Assertions are relational (skill > auto) and
// structural (hit count, breakdown name) rather than exact damage, so they stay
// stable across rocalc data refreshes. Baseline numbers from the 2026-06-26
// probe are in the comments for reference.

const PORING = 1002;

interface Build {
cls: string;
base: number;
job: number;
stats: {
str: number;
agi: number;
vit: number;
int: number;
dex: number;
luk: number;
};
}

function scoreSkill(b: Build, name: string, level: number) {
const shim = createShim();
shim.setClass(b.cls);
shim.setLevel({ base: b.base, job: b.job });
shim.setStats(b.stats);
shim.setEnemy(PORING);
const auto = shim.readCombatResults().damage.ave;

shim.reset();
shim.setLevel({ base: b.base, job: b.job });
shim.setStats(b.stats);
shim.setAttackSkills([{ name, level, primary: true }]);
shim.setEnemy(PORING);
const c = shim.readCombatResults();
return { auto, results: c, skill: c.skills?.[0] };
}

const SINX: Build = {
cls: "assassin_cross",
base: 99,
job: 70,
stats: { str: 99, agi: 60, vit: 1, int: 1, dex: 60, luk: 1 },
};
const KNIGHT: Build = {
cls: "knight",
base: 99,
job: 50,
stats: { str: 99, agi: 1, vit: 40, int: 1, dex: 60, luk: 1 },
};
const WIZARD: Build = {
cls: "wizard",
base: 99,
job: 50,
stats: { str: 1, agi: 1, vit: 1, int: 99, dex: 90, luk: 1 },
};
const MONK: Build = {
cls: "monk",
base: 99,
job: 50,
stats: { str: 90, agi: 1, vit: 40, int: 40, dex: 60, luk: 1 },
};

test("assassin_cross Sonic Blow: 8-hit melee far above auto-attack (probe ~1776 vs auto 222)", () => {
const { auto, results, skill } = scoreSkill(SINX, "sonic_blow", 10);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "sonic_blow");
assert.equal(skill.hits, 8);
assert.ok(
skill.damage.ave! > auto,
`sonic_blow ${skill.damage.ave} should exceed auto ${auto}`,
);
// primary drives the top-level damage cell
assert.equal(results.damage.ave, skill.damage.ave);
});

test("knight Bowling Bash exceeds auto-attack (probe ~2208 vs auto 220)", () => {
const { auto, skill } = scoreSkill(KNIGHT, "bowling_bash", 10);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "bowling_bash");
assert.ok(
skill.damage.ave! > auto,
`bowling_bash ${skill.damage.ave} should exceed auto ${auto}`,
);
});

test("wizard Lightning Bolt: magic damage flows through A_ActiveSkill (probe ~7710 vs auto 20)", () => {
const { auto, skill } = scoreSkill(WIZARD, "lightning_bolt", 10);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "lightning_bolt");
// The capability guard: magic must compute a real MATK-scaled number, not
// silently fall back to the tiny barehanded auto-attack.
assert.ok(
skill.damage.ave! > auto,
`lightning_bolt ${skill.damage.ave} should exceed auto ${auto}`,
);
assert.ok(
skill.damage.ave! > 1000,
`lightning_bolt ${skill.damage.ave} should be MATK-scaled (>1000)`,
);
});

test("monk Asura Strike scores off a near-full SP pool (probe ~15573 vs auto 190)", () => {
const { auto, skill } = scoreSkill(MONK, "asura_strike", 5);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "asura_strike");
// Asura's Remaining-SP sub-parameter defaults to maxSP-1. This also guards
// the SkillSubNum fix: if the standalone stub collision regressed, Asura
// would read SP 0 and collapse to ~2719. >5000 catches that.
assert.ok(
skill.damage.ave! > 5000,
`asura_strike ${skill.damage.ave} should reflect a full SP pool (>5000)`,
);
});
70 changes: 70 additions & 0 deletions calc-sidecar/test/backends/rocalc/attack_skills_spheres.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { createShim } from "../../../src/shim.ts";

// Regression guard for spirit-sphere attack skills. Finger Offensive and Ki
// Explosion (Excruciating Palm) explode spirit spheres and read 0 unless the
// support-bank control A2_Skill12 (# of Spirit Spheres) is driven > 0. The
// binding carries a sphere count; computeSkillBreakdown sets A2_Skill12 + the
// support section gate while the skill is active, and clears it for others.

const PORING = 1002;
const MONK = { str: 90, agi: 1, vit: 40, int: 40, dex: 60, luk: 1 };

function monkShim() {
const s = createShim();
s.setClass("monk");
s.setLevel({ base: 99, job: 50 });
s.setStats(MONK);
return s;
}

test("Finger Offensive deals sphere damage (0 without spheres)", () => {
const s = monkShim();
s.setAttackSkills([{ name: "finger_offensive", level: 5, primary: true }]);
s.setEnemy(PORING);
const k = s.readCombatResults().skills?.[0];
assert.ok(
k && k.damage.ave !== null && k.damage.ave > 0,
`finger_offensive=${k?.damage.ave}`,
);
});

test("Ki Explosion (Excruciating Palm) deals sphere damage", () => {
const s = monkShim();
s.setAttackSkills([{ name: "excruciating_palm", level: 1, primary: true }]);
s.setEnemy(PORING);
const k = s.readCombatResults().skills?.[0];
assert.ok(
k && k.damage.ave !== null && k.damage.ave > 0,
`excruciating_palm=${k?.damage.ave}`,
);
});

test("spheres do not leak to a non-sphere skill in the same breakdown", () => {
// chain_combo (no spheres) scored alongside finger_offensive (5 spheres).
const withFinger = monkShim();
withFinger.setAttackSkills([
{ name: "finger_offensive", level: 5 },
{ name: "chain_combo", level: 5, primary: true },
]);
withFinger.setEnemy(PORING);
const mixed = Object.fromEntries(
(withFinger.readCombatResults().skills ?? []).map((k) => [
k.name,
k.damage.ave,
]),
);

// chain_combo scored alone must match its value when scored next to a sphere skill.
const alone = monkShim();
alone.setAttackSkills([{ name: "chain_combo", level: 5, primary: true }]);
alone.setEnemy(PORING);
const chainAlone = alone.readCombatResults().skills?.[0].damage.ave;

assert.equal(
mixed["chain_combo"],
chainAlone,
"chain_combo must not inherit spheres",
);
});
Loading
Loading