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
116 changes: 116 additions & 0 deletions calc-sidecar/src/backends/rocalc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ export function createShim(): ShimSession {
// 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 HEAT_UNCERTAINTY =
"Warmth (Heat) only deals damage while standing on a designated Sun / Moon / Star map; per-hit damage approximates auto-attack at the faster Heat hit interval (Heat-specific gear is not modeled)";
const ATTACK_SKILL_BINDINGS: Record<
string,
{ rocalcId: number; uncertainty?: string; spheres?: number }
Expand Down Expand Up @@ -611,6 +613,120 @@ export function createShim(): ShimSession {
palm_push_strike: { rocalcId: 288 },
tiger_knuckle_fist: { rocalcId: 289 },
chain_crush_combo: { rocalcId: 290 },
// Crusader / Paladin (CR_/PA_ skills; CR_ inherited by Paladin's tree too).
shield_charge: { rocalcId: 158 },
shield_boomerang: { rocalcId: 159 },
holy_cross: { rocalcId: 161 },
grand_cross: { rocalcId: 162 },
pressure: { rocalcId: 283 },
martyrs_reckoning: {
rocalcId: 284,
uncertainty:
"Martyr's Reckoning damage scales with the caster's current HP; static scoring approximates it",
},
shield_chain: {
rocalcId: 324,
uncertainty:
"rocalc flags Shield Chain damage as differing slightly from in-game",
},
// Merchant line: Blacksmith / Whitesmith (MC_ inherited by both; also
// reaches Alchemist/Creator/Super Novice trees).
mammonite: { rocalcId: 65 },
cart_revolution: { rocalcId: 66 },
cart_termination: { rocalcId: 326 },
// Alchemist / Creator (AM_ inherited by Creator's tree too).
acid_terror: { rocalcId: 244 },
demonstration: { rocalcId: 248 },
acid_demonstration: {
rocalcId: 328,
uncertainty:
"Acid Demonstration damage scales with the target's VIT; varies sharply by target",
},
// Bard / Clown / Dancer / Gypsy. Ranged skills compute off the equipped bow;
// barehanded probe numbers are a floor, the orchestrator supplies the weapon.
musical_strike: { rocalcId: 199 },
slinging_arrow: { rocalcId: 207 },
arrow_vulcan: { rocalcId: 292 },
// Rogue / Stalker (RG_ inherited by Stalker's tree too).
back_stab: { rocalcId: 169 },
raid: { rocalcId: 171 },
// Gunslinger. Gun skills compute off the equipped firearm; barehanded probe
// numbers are a floor, the orchestrator supplies the weapon.
fling: { rocalcId: 417 },
triple_action: { rocalcId: 418 },
bulls_eye: { rocalcId: 419 },
magical_bullet: { rocalcId: 423 },
rapid_shower: { rocalcId: 428 },
desperado: { rocalcId: 429 },
tracking: { rocalcId: 430 },
piercing_shot: { rocalcId: 432 },
dust: { rocalcId: 434 },
full_buster: { rocalcId: 435 },
spread_attack: { rocalcId: 436 },
ground_drift: {
rocalcId: 437,
uncertainty:
"Ground Drift damage and element depend on the loaded gemstone ammunition",
},
// Ninja. Magic spells (Crimson Fire/Ice/Wind) scale off MATK; throws compute
// off the equipped shuriken/kunai. The catalog displays renewal skill names;
// semantic keys follow them (e.g. crimson_fire_petal = NJ_KOUENKA).
throw_shuriken: { rocalcId: 394 },
throw_kunai: { rocalcId: 395 },
throw_huuma_shuriken: { rocalcId: 396 },
throw_zeny: {
rocalcId: 397,
uncertainty: "Throw Zeny deals fixed damage based on the zeny spent",
},
vanishing_slash: { rocalcId: 400 },
shadow_slash: { rocalcId: 401 },
final_strike: {
rocalcId: 405,
uncertainty:
"Final Strike damage scales with the caster's max HP and reduces HP to 1",
},
crimson_fire_petal: { rocalcId: 407 },
crimson_fire_formation: { rocalcId: 408 },
raging_fire_dragon: { rocalcId: 409 },
spear_of_ice: { rocalcId: 410 },
ice_meteor: { rocalcId: 412 },
wind_blade: { rocalcId: 413 },
lightning_strike: { rocalcId: 414 },
kamaitachi: { rocalcId: 415 },
// Soul Linker (SL_ skills). Esma is the main MATK-scaled nuke; Estin/Estun
// are fixed small-damage bolts gated on target size.
esma: { rocalcId: 375 },
estin: {
rocalcId: 373,
uncertainty:
"Estin deals meaningful damage only to Small-size targets; near-zero otherwise",
},
estun: {
rocalcId: 374,
uncertainty:
"Estun deals meaningful damage only to Large-size targets; near-zero otherwise",
},
// Priest / High Priest (PR_ inherited by High Priest's tree too). Both only
// damage Undead and Demon targets; near-zero against everything else.
turn_undead: {
rocalcId: 102,
uncertainty:
"Turn Undead only affects Undead targets (instant-death chance plus holy damage); zero against other races",
},
magnus_exorcismus: {
rocalcId: 104,
uncertainty:
"Magnus Exorcismus only damages Undead and Demon-race targets; zero against everything else",
},
// Star Gladiator Warmth of the Sun / Moon / Stars. All three are the same
// "Heat" damage-over-time; bind the NO-PUSHBACK Heat variant (318). The
// pushback variant (317) breaks rocalc's continuous-hit time-to-kill (it
// returns null). Per-hit damage mirrors auto-attack, but the Heat hit
// interval is far shorter (probed TTK 0.05 vs auto 0.51 on Poring), so
// battleTimeSec carries the real DPS.
sun_warmth: { rocalcId: 318, uncertainty: HEAT_UNCERTAINTY },
moon_warmth: { rocalcId: 318, uncertainty: HEAT_UNCERTAINTY },
star_warmth: { rocalcId: 318, uncertainty: HEAT_UNCERTAINTY },
};

type PendingAttackSkill = {
Expand Down
130 changes: 127 additions & 3 deletions calc-sidecar/test/backends/rocalc/attack_skills_classes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createShim } from "../../../src/shim.ts";
// probe are in the comments for reference.

const PORING = 1002;
const ZOMBIE = 1015; // Undead-race target for the Priest exorcism skills.

interface Build {
cls: string;
Expand All @@ -24,19 +25,19 @@ interface Build {
};
}

function scoreSkill(b: Build, name: string, level: number) {
function scoreSkill(b: Build, name: string, level: number, enemy = PORING) {
const shim = createShim();
shim.setClass(b.cls);
shim.setLevel({ base: b.base, job: b.job });
shim.setStats(b.stats);
shim.setEnemy(PORING);
shim.setEnemy(enemy);
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);
shim.setEnemy(enemy);
const c = shim.readCombatResults();
return { auto, results: c, skill: c.skills?.[0] };
}
Expand Down Expand Up @@ -117,3 +118,126 @@ test("monk Asura Strike scores off a near-full SP pool (probe ~15573 vs auto 190
`asura_strike ${skill.damage.ave} should reflect a full SP pool (>5000)`,
);
});

const GUNSLINGER: Build = {
cls: "gunslinger",
base: 99,
job: 50,
// Test stats, not a real build: STR gives the barehanded ATK floor (no gun
// equipped here) so the skill clearly clears auto-attack; DEX/LUK feed guns.
stats: { str: 80, agi: 60, vit: 1, int: 1, dex: 99, luk: 60 },
};
const NINJA: Build = {
cls: "ninja",
base: 99,
job: 50,
stats: { str: 1, agi: 1, vit: 1, int: 99, dex: 90, luk: 1 },
};
const SOUL_LINKER: Build = {
cls: "soul_linker",
base: 99,
job: 50,
stats: { str: 1, agi: 1, vit: 1, int: 99, dex: 90, luk: 1 },
};
const WHITESMITH: Build = {
cls: "whitesmith",
base: 99,
job: 70,
stats: { str: 99, agi: 1, vit: 40, int: 1, dex: 60, luk: 1 },
};
const PRIEST: Build = {
cls: "priest",
base: 99,
job: 50,
stats: { str: 1, agi: 1, vit: 1, int: 99, dex: 90, luk: 1 },
};

test("gunslinger Desperado computes as a gun skill above auto-attack (probe ~3261)", () => {
const { auto, skill } = scoreSkill(GUNSLINGER, "desperado", 10);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "desperado");
assert.ok(
skill.damage.ave! > auto,
`desperado ${skill.damage.ave} should exceed auto ${auto}`,
);
});

test("ninja Crimson Fire Petal: a fuzzy-mapped spell computes MATK damage (probe ~1210)", () => {
const { auto, skill } = scoreSkill(NINJA, "crimson_fire_petal", 10);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "crimson_fire_petal");
// Guards the Ninja name remap (rocalc's old names vs the catalog's renewal
// names): the binding must hit a real MATK-scaled spell, not auto-fallback.
assert.ok(
skill.damage.ave! > 1000,
`crimson_fire_petal ${skill.damage.ave} should be MATK-scaled (>1000)`,
);
});

test("soul_linker Esma is a strong MATK bolt above auto (probe ~4460)", () => {
const { auto, skill } = scoreSkill(SOUL_LINKER, "esma", 10);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "esma");
assert.ok(
skill.damage.ave! > 1000,
`esma ${skill.damage.ave} should be MATK-scaled (>1000)`,
);
});

test("whitesmith Cart Termination scores without the sub-parameter crash (probe ~2251)", () => {
// Cart Termination carries a cart-weight sub-parameter; this guards that the
// SkillSubNum machinery feeds it a default instead of throwing.
const { auto, skill } = scoreSkill(WHITESMITH, "cart_termination", 10);
assert.ok(skill && auto !== null);
assert.equal(skill.name, "cart_termination");
assert.ok(
skill.damage.ave! > auto,
`cart_termination ${skill.damage.ave} should exceed auto ${auto}`,
);
});

test("priest Magnus Exorcismus damages Undead but is zero against non-Undead", () => {
const vsUndead = scoreSkill(PRIEST, "magnus_exorcismus", 10, ZOMBIE);
assert.ok(vsUndead.skill && vsUndead.auto !== null);
assert.ok(
vsUndead.skill.damage.ave! > 1000,
`magnus vs Zombie ${vsUndead.skill.damage.ave} should be a real holy nuke (>1000)`,
);
// The defining behavior: zero against a non-Undead, non-Demon target.
const vsPoring = scoreSkill(PRIEST, "magnus_exorcismus", 10, PORING);
assert.equal(
vsPoring.skill?.damage.ave,
0,
`magnus vs Poring should be 0, got ${vsPoring.skill?.damage.ave}`,
);
});

test("star_gladiator Warmth (Heat) models a fast DoT: time-to-kill far below auto", () => {
// Heat's per-hit damage mirrors auto-attack, but its hit interval is far
// shorter, so battleTimeSec (driven by the primary skill) drops sharply. That
// timing -- not per-hit damage -- is the modeled signal. Also guards the
// no-pushback binding choice: the pushback Heat variant returns a null TTK.
const shim = createShim();
shim.setClass("star_gladiator");
const stats = { str: 90, agi: 60, vit: 40, int: 1, dex: 60, luk: 1 };
shim.setLevel({ base: 99, job: 50 });
shim.setStats(stats);
shim.setEnemy(PORING);
const autoTtk = shim.readCombatResults().battleTimeSec;

shim.reset();
shim.setLevel({ base: 99, job: 50 });
shim.setStats(stats);
shim.setAttackSkills([{ name: "sun_warmth", level: 3, primary: true }]);
shim.setEnemy(PORING);
const c = shim.readCombatResults();
assert.equal(c.skills?.[0]?.name, "sun_warmth");
assert.ok(
autoTtk !== null && c.battleTimeSec !== null,
"both time-to-kill values should be non-null (no-pushback Heat variant)",
);
assert.ok(
c.battleTimeSec! < autoTtk!,
`warmth ttk ${c.battleTimeSec} should be below auto ttk ${autoTtk}`,
);
});
59 changes: 52 additions & 7 deletions cmd/build-catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,18 +817,45 @@ func loadJobMaxLevels(herculesPath, repoRoot string) ([]data.JobMaxLevels, error
return data.LoadJobMaxLevels(full, data.PreRenewal)
}

// usabilityExclusions removes skills that Hercules's skill_tree.conf carries as
// allocated (inherited) for a class but which the class cannot actually USE. A
// Soul Linker / Star Gladiator was a TaeKwon Kid, so the flattened tree carries
// every TK skill, but only a usable subset remains. Taekwon Ranker (TK_MISSION)
// is TaeKwon-Kid-only (the calc engine applies it only for TaeKwon Kid); without this it
// would wrongly surface as a self-buff for both 2nd classes. Keyed by shim-style
// class name -> set of aegis names to drop.
// usabilityExclusions DROPS skills that Hercules's skill_tree.conf carries as
// allocated (inherited) for a class but which are not point-allocated and the
// class cannot USE. Taekwon Ranker (TK_MISSION) is a quest STATUS (no skill
// points spent) that's TaeKwon-Kid-only (the calc engine applies it only for
// TaeKwon Kid); without this it would wrongly surface as a self-buff for both
// expanded 2nd classes. Dropping it has no skill-point-budget impact. Keyed by
// shim-style class name -> set of aegis names to drop.
//
// Skills that ARE point-allocated but unusable (the Taekwon kicks a Soul Linker
// keeps) go in unusableSkills below, NOT here -- they must stay in the tree.
var usabilityExclusions = map[string]map[string]bool{
"soul_linker": {"TK_MISSION": true},
"star_gladiator": {"TK_MISSION": true},
}

// unusableSkills FLAGS (does not drop) skills a class has allocated -- points
// really spent in an earlier job -- but cannot USE in its current job. A Soul
// Linker was a TaeKwon Kid and spent Taekwon job points on the kicks and their
// stances; those points carry over (and so must the skills, for the skill-point
// budget and skill monotonicity to stay correct), but the kicks cannot be cast
// as a Soul Linker. They stay in the tree marked Unusable so scoring/buffs skip
// them and the prompt annotates them. A Soul Linker keeps only the usable TK
// utility skills (Tumbling, Sprint, Peaceful/Happy Break, Kihop, Leap, Mild
// Wind). Star Gladiator (the fighter branch) CAN use the kicks, so it's absent
// here. Keyed by shim-style class name -> aegis names to flag.
var unusableSkills = map[string]map[string]bool{
"soul_linker": {
"TK_STORMKICK": true, // Tornado Kick
"TK_DOWNKICK": true, // Heel Drop
"TK_TURNKICK": true, // Roundhouse Kick
"TK_COUNTER": true, // Counter Kick
"TK_JUMPKICK": true, // Flying Kick
"TK_READYSTORM": true, // Tornado Kick stance
"TK_READYDOWN": true, // Heel Drop stance
"TK_READYTURN": true, // Roundhouse Kick stance
"TK_READYCOUNTER": true, // Counter Kick stance
},
}

// filterSkills returns skills with any entry whose AegisName is in drop removed.
// A nil/empty drop is a no-op (returns skills unchanged).
func filterSkills(skills []data.ClassSkillEntry, drop map[string]bool) []data.ClassSkillEntry {
Expand All @@ -845,6 +872,23 @@ func filterSkills(skills []data.ClassSkillEntry, drop map[string]bool) []data.Cl
return out
}

// markUnusable returns skills with Unusable=true set on any entry whose
// AegisName is in flag (kept in the tree, not dropped). A nil/empty flag is a
// no-op. Operates on a copy so the caller's slice is untouched.
func markUnusable(skills []data.ClassSkillEntry, flag map[string]bool) []data.ClassSkillEntry {
if len(flag) == 0 {
return skills
}
out := make([]data.ClassSkillEntry, len(skills))
copy(out, skills)
for i := range out {
if flag[out[i].AegisName] {
out[i].Unusable = true
}
}
return out
}

// buildClassMap reads Hercules's skill_tree.conf, flattens inherits so
// every class's Skills slice carries its full allocatable set, and
// keys the result by shim-style class names ("taekwon", "high_wizard",
Expand All @@ -870,6 +914,7 @@ func buildClassMap(herculesPath, repoRoot string) (map[string]data.ClassSkillTre
flat := flattenSkills(c, out)
key := classKeyFromHerculesName(c.Name)
flat = filterSkills(flat, usabilityExclusions[key])
flat = markUnusable(flat, unusableSkills[key])
out[key] = data.ClassSkillTree{
Name: c.Name,
Inherit: c.Inherit,
Expand Down
Loading
Loading