mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 03:23:51 +00:00
feat(editor): add WSTM (Stat Modifier Curve) open catalog format
Open replacement for the gtChanceTo*.dbc / gtRegen*.dbc / gtCombatRatings.dbc family of "1D level-keyed curve" tables. Each entry defines a single linear curve mapping character level to a stat value: melee crit chance per level, mana regen per spirit per level, base armor per level, etc. Curves are linear: value(level) = baseValue + perLevelDelta * (level - 1), with the result optionally scaled by a global multiplier and clamped to a level range. Most stock WoW curves fit this shape — the few that don't (cubic Combat Ratings) live in the dedicated WCRR catalog with spline support. Distinct from WCRR (Combat Rating conversion, integer ratings -> percentages) and WSPC (Spell Power Cost buckets, per-spell costs). WSTM is for the generic engine-side stat curves that aren't per-spell or per-rating. Seven curveKind values classify the major stat families (Crit / Hit / Power / Regen / Resist / Mitigation / Misc), and each curve carries its own [minLevel, maxLevel] applicability range plus a multiplier for global scaling without retuning each curve's slope. Three preset emitters: --gen-stm (5 crit-related curves with canonical 3.3.5a base+per-level scaling — MeleeCrit 5%+0.05/lvl resolves to 8.95% at lvl 80), --gen-stm-regen (4 regen curves including ManaPerSpirit and the Vanilla-era 3 rage/sec OOC decay), --gen-stm-armor (3 armor/mitigation/resistance curves). The info renderer demos resolveAtLevel(curveId, 80) inline as the @lvl80 column — server admins can sanity-check what each curve resolves to at character cap without writing test code. Validation enforces id+name presence, curveKind 0..6, minLevel<=maxLevel, no duplicate ids; warns on: - maxLevel > 80 (unreachable at WotLK cap) - multiplier=0 (curve always evaluates to 0) - multiplier<0 (inverts the curve — possibly intentional) - perLevelDelta<0 (curve shrinks with level — unusual) Wired through the cross-format table; WSTM appears in all 18 cross-format utilities. Format count 93 -> 94; CLI flag count 1076 -> 1081.
This commit is contained in:
parent
68c20bd152
commit
9a85cc029e
10 changed files with 646 additions and 0 deletions
|
|
@ -682,6 +682,7 @@ set(WOWEE_SOURCES
|
|||
src/pipeline/wowee_boss_encounters.cpp
|
||||
src/pipeline/wowee_instance_lockouts.cpp
|
||||
src/pipeline/wowee_stable_slots.cpp
|
||||
src/pipeline/wowee_stat_curves.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/dbc_layout.cpp
|
||||
|
||||
|
|
@ -1527,6 +1528,7 @@ add_executable(wowee_editor
|
|||
tools/editor/cli_boss_encounters_catalog.cpp
|
||||
tools/editor/cli_instance_lockouts_catalog.cpp
|
||||
tools/editor/cli_stable_slots_catalog.cpp
|
||||
tools/editor/cli_stat_curves_catalog.cpp
|
||||
tools/editor/cli_quest_objective.cpp
|
||||
tools/editor/cli_quest_reward.cpp
|
||||
tools/editor/cli_clone.cpp
|
||||
|
|
@ -1687,6 +1689,7 @@ add_executable(wowee_editor
|
|||
src/pipeline/wowee_boss_encounters.cpp
|
||||
src/pipeline/wowee_instance_lockouts.cpp
|
||||
src/pipeline/wowee_stable_slots.cpp
|
||||
src/pipeline/wowee_stat_curves.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/terrain_mesh.cpp
|
||||
|
||||
|
|
|
|||
118
include/pipeline/wowee_stat_curves.hpp
Normal file
118
include/pipeline/wowee_stat_curves.hpp
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
// Wowee Open Stat Modifier Curve catalog (.wstm) —
|
||||
// novel replacement for the gtChanceTo*.dbc / gtRegen*.dbc
|
||||
// / gtCombatRatings.dbc family of "1D level-keyed curve"
|
||||
// tables. Each entry defines a single linear curve mapping
|
||||
// character level to a stat value: melee crit chance per
|
||||
// level, mana regen per spirit per level, base armor per
|
||||
// level, etc.
|
||||
//
|
||||
// Curves are simple linear: value(level) = baseValue +
|
||||
// perLevelDelta * (level - 1), with the result optionally
|
||||
// scaled by a global multiplier and clamped to a level
|
||||
// range. Most stock WoW curves fit this shape — the few
|
||||
// that don't (Combat Ratings) live in the dedicated WCRR
|
||||
// catalog with cubic spline support.
|
||||
//
|
||||
// Distinct from WCRR (Combat Rating conversion) which
|
||||
// converts integer rating points to percentages, and
|
||||
// distinct from WSPC (Spell Power Cost buckets) which
|
||||
// scales per-spell costs. WSTM is for the generic
|
||||
// engine-side stat curves that aren't per-spell or
|
||||
// per-rating.
|
||||
//
|
||||
// Cross-references with previously-added formats:
|
||||
// None — this catalog is consumed directly by the
|
||||
// character stat resolver. Engines look up curves by
|
||||
// curveId or by name.
|
||||
//
|
||||
// Binary layout (little-endian):
|
||||
// magic[4] = "WSTM"
|
||||
// version (uint32) = current 1
|
||||
// nameLen + name (catalog label)
|
||||
// entryCount (uint32)
|
||||
// entries (each):
|
||||
// curveId (uint32)
|
||||
// nameLen + name
|
||||
// descLen + description
|
||||
// curveKind (uint8) / minLevel (uint8) / maxLevel (uint8) / pad (uint8)
|
||||
// baseValue (float)
|
||||
// perLevelDelta (float)
|
||||
// multiplier (float)
|
||||
// iconColorRGBA (uint32)
|
||||
struct WoweeStatCurve {
|
||||
enum CurveKind : uint8_t {
|
||||
Crit = 0, // crit chance scaling per level
|
||||
Hit = 1, // hit chance scaling
|
||||
Power = 2, // attack power / spell power growth
|
||||
Regen = 3, // mana / health regen rates
|
||||
Resist = 4, // resistance scaling
|
||||
Mitigation = 5, // armor / damage reduction
|
||||
Misc = 6, // catch-all
|
||||
};
|
||||
|
||||
struct Entry {
|
||||
uint32_t curveId = 0;
|
||||
std::string name;
|
||||
std::string description;
|
||||
uint8_t curveKind = Misc;
|
||||
uint8_t minLevel = 1;
|
||||
uint8_t maxLevel = 80;
|
||||
uint8_t pad0 = 0;
|
||||
float baseValue = 0.0f;
|
||||
float perLevelDelta = 0.0f;
|
||||
float multiplier = 1.0f;
|
||||
uint32_t iconColorRGBA = 0xFFFFFFFFu;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
bool isValid() const { return !entries.empty(); }
|
||||
|
||||
const Entry* findById(uint32_t curveId) const;
|
||||
|
||||
// Resolve the curve at the given character level,
|
||||
// applying the linear formula then scaling by the
|
||||
// multiplier and clamping to [minLevel..maxLevel].
|
||||
// Returns 0.0 if the level is below minLevel.
|
||||
float resolveAtLevel(uint32_t curveId, uint8_t level) const;
|
||||
|
||||
static const char* curveKindName(uint8_t k);
|
||||
};
|
||||
|
||||
class WoweeStatCurveLoader {
|
||||
public:
|
||||
static bool save(const WoweeStatCurve& cat,
|
||||
const std::string& basePath);
|
||||
static WoweeStatCurve load(const std::string& basePath);
|
||||
static bool exists(const std::string& basePath);
|
||||
|
||||
// Preset emitters used by --gen-stm* variants.
|
||||
//
|
||||
// makeCrit — 5 crit-related curves (MeleeCritChance,
|
||||
// RangedCritChance, SpellCritChance,
|
||||
// ParryChance, DodgeChance) covering
|
||||
// the standard crit-tier scaling.
|
||||
// makeRegen — 4 regen curves (ManaPerSpirit,
|
||||
// HpPerSpirit, EnergyPerSec, RageDecay)
|
||||
// with the canonical Vanilla/TBC/WotLK
|
||||
// stock formulas.
|
||||
// makeArmor — 3 armor / mitigation curves
|
||||
// (BaseArmorPerLevel, ArmorMitigation,
|
||||
// ResistancePerLevel).
|
||||
static WoweeStatCurve makeCrit(const std::string& catalogName);
|
||||
static WoweeStatCurve makeRegen(const std::string& catalogName);
|
||||
static WoweeStatCurve makeArmor(const std::string& catalogName);
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
253
src/pipeline/wowee_stat_curves.cpp
Normal file
253
src/pipeline/wowee_stat_curves.cpp
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
#include "pipeline/wowee_stat_curves.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'S', 'T', 'M'};
|
||||
constexpr uint32_t kVersion = 1;
|
||||
|
||||
template <typename T>
|
||||
void writePOD(std::ofstream& os, const T& v) {
|
||||
os.write(reinterpret_cast<const char*>(&v), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool readPOD(std::ifstream& is, T& v) {
|
||||
is.read(reinterpret_cast<char*>(&v), sizeof(T));
|
||||
return is.gcount() == static_cast<std::streamsize>(sizeof(T));
|
||||
}
|
||||
|
||||
void writeStr(std::ofstream& os, const std::string& s) {
|
||||
uint32_t n = static_cast<uint32_t>(s.size());
|
||||
writePOD(os, n);
|
||||
if (n > 0) os.write(s.data(), n);
|
||||
}
|
||||
|
||||
bool readStr(std::ifstream& is, std::string& s) {
|
||||
uint32_t n = 0;
|
||||
if (!readPOD(is, n)) return false;
|
||||
if (n > (1u << 20)) return false;
|
||||
s.resize(n);
|
||||
if (n > 0) {
|
||||
is.read(s.data(), n);
|
||||
if (is.gcount() != static_cast<std::streamsize>(n)) {
|
||||
s.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string normalizePath(std::string base) {
|
||||
if (base.size() < 5 || base.substr(base.size() - 5) != ".wstm") {
|
||||
base += ".wstm";
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
uint32_t packRgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF) {
|
||||
return (static_cast<uint32_t>(a) << 24) |
|
||||
(static_cast<uint32_t>(b) << 16) |
|
||||
(static_cast<uint32_t>(g) << 8) |
|
||||
static_cast<uint32_t>(r);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const WoweeStatCurve::Entry*
|
||||
WoweeStatCurve::findById(uint32_t curveId) const {
|
||||
for (const auto& e : entries)
|
||||
if (e.curveId == curveId) return &e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float WoweeStatCurve::resolveAtLevel(uint32_t curveId,
|
||||
uint8_t level) const {
|
||||
const Entry* e = findById(curveId);
|
||||
if (!e) return 0.0f;
|
||||
if (level < e->minLevel) return 0.0f;
|
||||
uint8_t clampedLevel = level;
|
||||
if (clampedLevel > e->maxLevel) clampedLevel = e->maxLevel;
|
||||
float v = e->baseValue +
|
||||
e->perLevelDelta * static_cast<float>(clampedLevel - 1);
|
||||
return v * e->multiplier;
|
||||
}
|
||||
|
||||
const char* WoweeStatCurve::curveKindName(uint8_t k) {
|
||||
switch (k) {
|
||||
case Crit: return "crit";
|
||||
case Hit: return "hit";
|
||||
case Power: return "power";
|
||||
case Regen: return "regen";
|
||||
case Resist: return "resist";
|
||||
case Mitigation: return "mitigation";
|
||||
case Misc: return "misc";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
bool WoweeStatCurveLoader::save(const WoweeStatCurve& cat,
|
||||
const std::string& basePath) {
|
||||
std::ofstream os(normalizePath(basePath), std::ios::binary);
|
||||
if (!os) return false;
|
||||
os.write(kMagic, 4);
|
||||
writePOD(os, kVersion);
|
||||
writeStr(os, cat.name);
|
||||
uint32_t entryCount = static_cast<uint32_t>(cat.entries.size());
|
||||
writePOD(os, entryCount);
|
||||
for (const auto& e : cat.entries) {
|
||||
writePOD(os, e.curveId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writePOD(os, e.curveKind);
|
||||
writePOD(os, e.minLevel);
|
||||
writePOD(os, e.maxLevel);
|
||||
writePOD(os, e.pad0);
|
||||
writePOD(os, e.baseValue);
|
||||
writePOD(os, e.perLevelDelta);
|
||||
writePOD(os, e.multiplier);
|
||||
writePOD(os, e.iconColorRGBA);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeStatCurve WoweeStatCurveLoader::load(const std::string& basePath) {
|
||||
WoweeStatCurve out;
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
if (!is) return out;
|
||||
char magic[4];
|
||||
is.read(magic, 4);
|
||||
if (std::memcmp(magic, kMagic, 4) != 0) return out;
|
||||
uint32_t version = 0;
|
||||
if (!readPOD(is, version) || version != kVersion) return out;
|
||||
if (!readStr(is, out.name)) return out;
|
||||
uint32_t entryCount = 0;
|
||||
if (!readPOD(is, entryCount)) return out;
|
||||
if (entryCount > (1u << 20)) return out;
|
||||
out.entries.resize(entryCount);
|
||||
for (auto& e : out.entries) {
|
||||
if (!readPOD(is, e.curveId)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readStr(is, e.name) || !readStr(is, e.description)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.curveKind) ||
|
||||
!readPOD(is, e.minLevel) ||
|
||||
!readPOD(is, e.maxLevel) ||
|
||||
!readPOD(is, e.pad0) ||
|
||||
!readPOD(is, e.baseValue) ||
|
||||
!readPOD(is, e.perLevelDelta) ||
|
||||
!readPOD(is, e.multiplier) ||
|
||||
!readPOD(is, e.iconColorRGBA)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeStatCurveLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeStatCurve WoweeStatCurveLoader::makeCrit(
|
||||
const std::string& catalogName) {
|
||||
using S = WoweeStatCurve;
|
||||
WoweeStatCurve c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, float base,
|
||||
float perLvl, const char* desc) {
|
||||
S::Entry e;
|
||||
e.curveId = id; e.name = name; e.description = desc;
|
||||
e.curveKind = S::Crit;
|
||||
e.baseValue = base;
|
||||
e.perLevelDelta = perLvl;
|
||||
e.iconColorRGBA = packRgba(240, 100, 100); // crit red
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
// Canonical 3.3.5a crit-chance scaling: base 5%
|
||||
// for melee/ranged at lvl 1, +0.05% per level.
|
||||
// Spell crit base 1%, +0.04% per level (mages
|
||||
// get class bonus on top).
|
||||
add(1, "MeleeCritChance", 5.0f, 0.05f,
|
||||
"Melee crit chance — base 5%% at lvl 1, +0.05%% per level.");
|
||||
add(2, "RangedCritChance", 5.0f, 0.05f,
|
||||
"Ranged crit chance — same scaling as melee.");
|
||||
add(3, "SpellCritChance", 1.0f, 0.04f,
|
||||
"Spell crit chance — base 1%%, +0.04%% per level. "
|
||||
"Class talents add fixed bonuses.");
|
||||
add(4, "ParryChance", 5.0f, 0.0f,
|
||||
"Parry chance — flat 5%% from level 1, scales via "
|
||||
"Strength/Parry rating (see WCRR).");
|
||||
add(5, "DodgeChance", 5.0f, 0.04f,
|
||||
"Base dodge — 5%% + 0.04%%/level + Agility scaling.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeStatCurve WoweeStatCurveLoader::makeRegen(
|
||||
const std::string& catalogName) {
|
||||
using S = WoweeStatCurve;
|
||||
WoweeStatCurve c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, float base,
|
||||
float perLvl, float mult, const char* desc) {
|
||||
S::Entry e;
|
||||
e.curveId = id; e.name = name; e.description = desc;
|
||||
e.curveKind = S::Regen;
|
||||
e.baseValue = base;
|
||||
e.perLevelDelta = perLvl;
|
||||
e.multiplier = mult;
|
||||
e.iconColorRGBA = packRgba(100, 200, 240); // regen blue
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(100, "ManaPerSpirit", 0.0f, 0.0125f, 1.0f,
|
||||
"Mana regen per Spirit out-of-combat — 0.0125 mp5/spirit "
|
||||
"scaling per level.");
|
||||
add(101, "HpPerSpirit", 0.0f, 0.05f, 1.0f,
|
||||
"Health regen per Spirit out-of-combat — 0.05 hp/sec "
|
||||
"per spirit scaling per level.");
|
||||
add(102, "EnergyPerSec", 20.0f, 0.0f, 1.0f,
|
||||
"Energy regen — flat 20 per 2s baseline (Rogue / Cat "
|
||||
"Druid). Haste reduces tick interval.");
|
||||
add(103, "RageDecayPerSec", 3.0f, 0.0f, 1.0f,
|
||||
"Rage decay out-of-combat — 3 rage per second uniformly. "
|
||||
"In-combat rage doesn't decay.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeStatCurve WoweeStatCurveLoader::makeArmor(
|
||||
const std::string& catalogName) {
|
||||
using S = WoweeStatCurve;
|
||||
WoweeStatCurve c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint8_t kind,
|
||||
float base, float perLvl, const char* desc) {
|
||||
S::Entry e;
|
||||
e.curveId = id; e.name = name; e.description = desc;
|
||||
e.curveKind = kind;
|
||||
e.baseValue = base;
|
||||
e.perLevelDelta = perLvl;
|
||||
e.iconColorRGBA = packRgba(180, 180, 200); // armor grey
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(200, "BaseArmorPerLevel", S::Mitigation, 0.0f, 10.0f,
|
||||
"Base armor scaling — 10 armor per character level "
|
||||
"for cloth/leather wearers without items.");
|
||||
add(201, "ArmorMitigationPct", S::Mitigation, 0.0f, 0.4f,
|
||||
"Armor → damage reduction conversion — ~0.4%% per level "
|
||||
"of effectiveness against same-level attackers.");
|
||||
add(202, "ResistancePerLevel", S::Resist, 0.0f, 1.0f,
|
||||
"Magic resistance scaling — 1 resist per level for "
|
||||
"Holy / Fire / Frost / etc; capped at level*5.");
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
|
|
@ -288,6 +288,8 @@ const char* const kArgRequired[] = {
|
|||
"--gen-stc", "--gen-stc-cata", "--gen-stc-premium",
|
||||
"--info-wstc", "--validate-wstc",
|
||||
"--export-wstc-json", "--import-wstc-json",
|
||||
"--gen-stm", "--gen-stm-regen", "--gen-stm-armor",
|
||||
"--info-wstm", "--validate-wstm",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@
|
|||
#include "cli_boss_encounters_catalog.hpp"
|
||||
#include "cli_instance_lockouts_catalog.hpp"
|
||||
#include "cli_stable_slots_catalog.hpp"
|
||||
#include "cli_stat_curves_catalog.hpp"
|
||||
#include "cli_quest_objective.hpp"
|
||||
#include "cli_quest_reward.hpp"
|
||||
#include "cli_clone.hpp"
|
||||
|
|
@ -317,6 +318,7 @@ constexpr DispatchFn kDispatchTable[] = {
|
|||
handleBossEncountersCatalog,
|
||||
handleInstanceLockoutsCatalog,
|
||||
handleStableSlotsCatalog,
|
||||
handleStatCurvesCatalog,
|
||||
handleQuestObjective,
|
||||
handleQuestReward,
|
||||
handleClone,
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ constexpr FormatMagicEntry kFormats[] = {
|
|||
{{'W','B','O','S'}, ".wbos", "raid", "--info-wbos", "Boss encounter definition catalog"},
|
||||
{{'W','H','L','D'}, ".whld", "raid", "--info-whld", "Instance lockout schedule catalog"},
|
||||
{{'W','S','T','C'}, ".wstc", "pets", "--info-wstc", "Hunter stable slot catalog"},
|
||||
{{'W','S','T','M'}, ".wstm", "stats", "--info-wstm", "Stat modifier curve catalog"},
|
||||
{{'W','F','A','C'}, ".wfac", "factions", nullptr, "Faction catalog"},
|
||||
{{'W','L','C','K'}, ".wlck", "locks", nullptr, "Lock catalog"},
|
||||
{{'W','S','K','L'}, ".wskl", "skills", nullptr, "Skill catalog"},
|
||||
|
|
|
|||
|
|
@ -2069,6 +2069,16 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Export binary .wstc to a human-editable JSON sidecar (defaults to <base>.wstc.json)\n");
|
||||
std::printf(" --import-wstc-json <json-path> [out-base]\n");
|
||||
std::printf(" Import a .wstc.json sidecar back into binary .wstc (isPremium accepts bool OR int)\n");
|
||||
std::printf(" --gen-stm <wstm-base> [name]\n");
|
||||
std::printf(" Emit .wstm 5 crit curves (MeleeCrit / RangedCrit / SpellCrit / Parry / Dodge) with canonical 3.3.5a base+per-level scaling\n");
|
||||
std::printf(" --gen-stm-regen <wstm-base> [name]\n");
|
||||
std::printf(" Emit .wstm 4 regen curves (ManaPerSpirit / HpPerSpirit / EnergyPerSec / RageDecay) with stock formulas\n");
|
||||
std::printf(" --gen-stm-armor <wstm-base> [name]\n");
|
||||
std::printf(" Emit .wstm 3 armor/mitigation curves (BaseArmorPerLevel / ArmorMitigationPct / ResistancePerLevel)\n");
|
||||
std::printf(" --info-wstm <wstm-base> [--json]\n");
|
||||
std::printf(" Print WSTM entries (id / kind / minLvl / maxLvl / baseValue / perLevelDelta / multiplier / value@lvl80 sample / name)\n");
|
||||
std::printf(" --validate-wstm <wstm-base> [--json]\n");
|
||||
std::printf(" Static checks: id+name required, curveKind 0..6, minLevel<=maxLevel, no duplicate ids; warns on maxLevel>80, multiplier=0 (always 0), multiplier<0 (inverts), perLevelDelta<0 (shrinks)\n");
|
||||
std::printf(" --gen-weather-temperate <wow-base> [zoneName]\n");
|
||||
std::printf(" Emit .wow weather schedule: clear-dominant + occasional rain + fog (forest / grassland)\n");
|
||||
std::printf(" --gen-weather-arctic <wow-base> [zoneName]\n");
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ constexpr FormatRow kFormats[] = {
|
|||
{"WBOS", ".wbos", "raid", "instance_encounter SQL", "Boss encounter definition catalog"},
|
||||
{"WHLD", ".whld", "raid", "InstanceTemplate.dbc reset fields","Instance lockout schedule catalog"},
|
||||
{"WSTC", ".wstc", "pets", "stable_slot SQL + hunter UI", "Hunter stable slot catalog"},
|
||||
{"WSTM", ".wstm", "stats", "gtChanceTo*.dbc + gtRegen*.dbc", "Stat modifier curve catalog"},
|
||||
|
||||
// Additional pipeline catalogs without the alternating
|
||||
// gen/info/validate CLI surface (loaded by the engine
|
||||
|
|
|
|||
244
tools/editor/cli_stat_curves_catalog.cpp
Normal file
244
tools/editor/cli_stat_curves_catalog.cpp
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
#include "cli_stat_curves_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_stat_curves.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string stripWstmExt(std::string base) {
|
||||
stripExt(base, ".wstm");
|
||||
return base;
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeStatCurve& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeStatCurveLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wstm\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeStatCurve& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wstm\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" curves : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenCrit(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "CritCurves";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWstmExt(base);
|
||||
auto c = wowee::pipeline::WoweeStatCurveLoader::makeCrit(name);
|
||||
if (!saveOrError(c, base, "gen-stm")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenRegen(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "RegenCurves";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWstmExt(base);
|
||||
auto c = wowee::pipeline::WoweeStatCurveLoader::makeRegen(name);
|
||||
if (!saveOrError(c, base, "gen-stm-regen")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenArmor(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "ArmorCurves";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWstmExt(base);
|
||||
auto c = wowee::pipeline::WoweeStatCurveLoader::makeArmor(name);
|
||||
if (!saveOrError(c, base, "gen-stm-armor")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleInfo(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
||||
base = stripWstmExt(base);
|
||||
if (!wowee::pipeline::WoweeStatCurveLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WSTM not found: %s.wstm\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeStatCurveLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wstm"] = base + ".wstm";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
arr.push_back({
|
||||
{"curveId", e.curveId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"curveKind", e.curveKind},
|
||||
{"curveKindName", wowee::pipeline::WoweeStatCurve::curveKindName(e.curveKind)},
|
||||
{"minLevel", e.minLevel},
|
||||
{"maxLevel", e.maxLevel},
|
||||
{"baseValue", e.baseValue},
|
||||
{"perLevelDelta", e.perLevelDelta},
|
||||
{"multiplier", e.multiplier},
|
||||
{"valueAtLevel80", c.resolveAtLevel(e.curveId, 80)},
|
||||
{"iconColorRGBA", e.iconColorRGBA},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WSTM: %s.wstm\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" curves : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id kind minL maxL base perLvl mult @lvl80 name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::printf(" %4u %-10s %3u %3u %7.3f %7.4f %5.2f %7.3f %s\n",
|
||||
e.curveId,
|
||||
wowee::pipeline::WoweeStatCurve::curveKindName(e.curveKind),
|
||||
e.minLevel, e.maxLevel,
|
||||
e.baseValue, e.perLevelDelta, e.multiplier,
|
||||
c.resolveAtLevel(e.curveId, 80),
|
||||
e.name.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleValidate(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
||||
base = stripWstmExt(base);
|
||||
if (!wowee::pipeline::WoweeStatCurveLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wstm: WSTM not found: %s.wstm\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeStatCurveLoader::load(base);
|
||||
std::vector<std::string> errors;
|
||||
std::vector<std::string> warnings;
|
||||
if (c.entries.empty()) {
|
||||
warnings.push_back("catalog has zero entries");
|
||||
}
|
||||
std::vector<uint32_t> idsSeen;
|
||||
for (size_t k = 0; k < c.entries.size(); ++k) {
|
||||
const auto& e = c.entries[k];
|
||||
std::string ctx = "entry " + std::to_string(k) +
|
||||
" (id=" + std::to_string(e.curveId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.curveId == 0)
|
||||
errors.push_back(ctx + ": curveId is 0");
|
||||
if (e.name.empty())
|
||||
errors.push_back(ctx + ": name is empty");
|
||||
if (e.curveKind > wowee::pipeline::WoweeStatCurve::Misc) {
|
||||
errors.push_back(ctx + ": curveKind " +
|
||||
std::to_string(e.curveKind) + " not in 0..6");
|
||||
}
|
||||
if (e.minLevel > e.maxLevel) {
|
||||
errors.push_back(ctx + ": minLevel " +
|
||||
std::to_string(e.minLevel) +
|
||||
" > maxLevel " + std::to_string(e.maxLevel) +
|
||||
" — curve will never apply");
|
||||
}
|
||||
if (e.maxLevel > 80) {
|
||||
warnings.push_back(ctx +
|
||||
": maxLevel " + std::to_string(e.maxLevel) +
|
||||
" > 80 — characters cap at 80 in WotLK");
|
||||
}
|
||||
if (e.multiplier == 0.0f)
|
||||
warnings.push_back(ctx +
|
||||
": multiplier=0 — curve always evaluates to 0");
|
||||
if (e.multiplier < 0.0f)
|
||||
warnings.push_back(ctx +
|
||||
": multiplier=" + std::to_string(e.multiplier) +
|
||||
" (< 0) — inverts the curve, double-check this "
|
||||
"is intentional");
|
||||
// Negative perLevelDelta is unusual — most stats
|
||||
// grow with level.
|
||||
if (e.perLevelDelta < 0.0f)
|
||||
warnings.push_back(ctx +
|
||||
": perLevelDelta=" + std::to_string(e.perLevelDelta) +
|
||||
" (< 0) — curve shrinks with level, double-check");
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.curveId) {
|
||||
errors.push_back(ctx + ": duplicate curveId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.curveId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wstm"] = base + ".wstm";
|
||||
j["ok"] = ok;
|
||||
j["errors"] = errors;
|
||||
j["warnings"] = warnings;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
std::printf("validate-wstm: %s.wstm\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu curves, all curveIds unique, all minLevel<=maxLevel\n",
|
||||
c.entries.size());
|
||||
return 0;
|
||||
}
|
||||
if (!warnings.empty()) {
|
||||
std::printf(" warnings (%zu):\n", warnings.size());
|
||||
for (const auto& w : warnings)
|
||||
std::printf(" - %s\n", w.c_str());
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
std::printf(" ERRORS (%zu):\n", errors.size());
|
||||
for (const auto& e : errors)
|
||||
std::printf(" - %s\n", e.c_str());
|
||||
}
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool handleStatCurvesCatalog(int& i, int argc, char** argv,
|
||||
int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-stm") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenCrit(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-stm-regen") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenRegen(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-stm-armor") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenArmor(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wstm") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wstm") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
12
tools/editor/cli_stat_curves_catalog.hpp
Normal file
12
tools/editor/cli_stat_curves_catalog.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
bool handleStatCurvesCatalog(int& i, int argc, char** argv,
|
||||
int& outRc);
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue