feat(editor): add WHRD (Heroic Loot Scaling) — 108th open format

Novel replacement for the implicit Heroic-mode loot rules
vanilla WoW encoded in dungeon/raid script systems: a
Normal-mode boss drops items from one loot table, the
Heroic-mode version drops the same items at +N item
levels with M× drop chance plus an optional Heroic-only
currency token. Each WHRD entry binds one (mapId,
difficultyId) combination to its scaling rules so the
loot-roll engine can layer the modifiers over the base
WLOT loot table at encounter death.

Six tunable fields per scaling: itemLevelDelta (signed
int16, typically +13 for 5-man Heroic, +13 to +26 for
raid Heroic), bonusQualityChance (basis points 0..10000
for the probability of a +1-quality-tier bonus drop),
dropChanceMultiplier (float, 1.0 = same rate, 1.5 =
+50%), heroicTokenItemId (per-tier currency reward like
Emblem of Frost), bonusEmblemCount (extra emblems on
top of base 1× per boss).

mapId=0 is a wildcard that applies the scaling to ANY
map at the given difficultyId — used by the
ChallengeMode preset to define generic Bronze/Silver/
Gold tier scalings without naming each instance.

Three preset emitters: makeWotLK5manHeroic (5 WotLK
5-man Heroics: Utgarde Keep, Nexus, Azjol-Nerub,
Ahn'kahet, Drak'Tharon — all +13/2× Emblem of Heroism),
makeRaid25Heroic (4 25H raids: Naxx +13, EoE +13,
Ulduar +26, ICC +26 with corresponding Conquest/Triumph/
Frost emblems), makeChallengeMode (3 anachronistic
challenge-mode tiers as a template for custom servers
backporting MoP-era systems).

Validator's most novel checks are bounds-aware:
bonusQualityChance capped at 10000 basis points (above
that would guarantee multiple bonus drops), no negative
itemLevelDelta (Heroic shouldn't be worse than Normal —
warning, not error), no >50 ilvl delta (beyond canonical
range — warning), no zero or excessive dropChance-
Multiplier, AND (mapId, difficultyId) tuple uniqueness
unless mapId=0 wildcard (multiple scalings binding the
same instance+difficulty would make loot-roll lookup
ambiguous).

Format count 107 -> 108. CLI flag count 1175 -> 1180.
This commit is contained in:
Kelsi 2026-05-10 01:52:58 -07:00
parent 81070c470c
commit ede6fb9c3a
10 changed files with 729 additions and 0 deletions

View file

@ -696,6 +696,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_learning_notifications.cpp
src/pipeline/wowee_creature_resists.cpp
src/pipeline/wowee_pet_talents.cpp
src/pipeline/wowee_heroic_scaling.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1555,6 +1556,7 @@ add_executable(wowee_editor
tools/editor/cli_learning_notifications_catalog.cpp
tools/editor/cli_creature_resists_catalog.cpp
tools/editor/cli_pet_talents_catalog.cpp
tools/editor/cli_heroic_scaling_catalog.cpp
tools/editor/cli_catalog_pluck.cpp
tools/editor/cli_catalog_find.cpp
tools/editor/cli_catalog_by_name.cpp
@ -1732,6 +1734,7 @@ add_executable(wowee_editor
src/pipeline/wowee_learning_notifications.cpp
src/pipeline/wowee_creature_resists.cpp
src/pipeline/wowee_pet_talents.cpp
src/pipeline/wowee_heroic_scaling.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,126 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Heroic Loot Scaling catalog (.whrd) —
// novel replacement for the implicit Heroic-mode loot
// rules vanilla WoW encoded in the dungeon/raid script
// system: a Normal-mode boss drops items from one loot
// table, the Heroic-mode version drops the same items
// at +N item levels with M× drop chance, plus an
// optional Heroic-only currency token (Emblem of Frost,
// etc.). Each WHRD entry binds one (mapId, difficultyId)
// combination to its scaling rules.
//
// Cross-references with previously-added formats:
// WMS: mapId references the WMS map catalog.
// WCDF: difficultyId references the WCDF creature/
// instance difficulty variant catalog.
// WIT: heroicTokenItemId references the WIT item
// catalog (the per-Heroic currency token, 0 if
// no token reward).
// WLOT: rules are layered over the base WLOT loot
// table the encounter normally drops.
//
// Binary layout (little-endian):
// magic[4] = "WHRD"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// scalingId (uint32)
// nameLen + name
// descLen + description
// mapId (uint32) / difficultyId (uint32)
// itemLevelDelta (int16) — bonus ilvl over
// Normal (often
// +13 for 5-man
// Heroic, +13 to +26
// for raid Heroic)
// bonusQualityChance (uint16) — 0..10000 (basis
// points, 100 = 1%);
// probability of a
// bonus +1-tier
// quality drop
// dropChanceMultiplier (float) — 1.0 = same drop
// rate, 1.5 = +50%,
// etc.
// heroicTokenItemId (uint32) — 0 if no token
// bonusEmblemCount (uint8) — extra emblem-token
// rewards on top of
// base 1× per boss
// pad0 / pad1 / pad2 (uint8)
// iconColorRGBA (uint32)
struct WoweeHeroicScaling {
struct Entry {
uint32_t scalingId = 0;
std::string name;
std::string description;
uint32_t mapId = 0;
uint32_t difficultyId = 0;
int16_t itemLevelDelta = 13;
uint16_t bonusQualityChance = 0;
float dropChanceMultiplier = 1.0f;
uint32_t heroicTokenItemId = 0;
uint8_t bonusEmblemCount = 0;
uint8_t pad0 = 0;
uint8_t pad1 = 0;
uint8_t pad2 = 0;
uint32_t iconColorRGBA = 0xFFFFFFFFu;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t scalingId) const;
// Returns the scaling rules for a given (map,
// difficulty) combo, or nullptr if no Heroic
// scaling is defined (defaults to no scaling).
// Used by the loot-roll engine when an encounter
// dies on Heroic-difficulty content.
const Entry* findForInstance(uint32_t mapId,
uint32_t difficultyId) const;
};
class WoweeHeroicScalingLoader {
public:
static bool save(const WoweeHeroicScaling& cat,
const std::string& basePath);
static WoweeHeroicScaling load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-hrd* variants.
//
// makeWotLK5manHeroic — 5 WotLK 5-man Heroic
// scalings (Utgarde Keep /
// Nexus / Azjol-Nerub /
// Ahn'kahet / Drak'Tharon).
// +13 ilvl, 1.0× drop
// chance, 2× Emblem of
// Heroism.
// makeRaid25Heroic — 4 25H raid scalings (Naxx
// / EoE / Ulduar / ICC).
// +26 ilvl, 1.5× drop chance
// on rare items, 1× Emblem
// of Frost per boss.
// makeChallengeMode — 3 challenge-mode tier
// scalings (Bronze / Silver
// / Gold). Anachronistic
// for WotLK but useful
// template for custom-server
// content.
static WoweeHeroicScaling makeWotLK5manHeroic(const std::string& catalogName);
static WoweeHeroicScaling makeRaid25Heroic(const std::string& catalogName);
static WoweeHeroicScaling makeChallengeMode(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,292 @@
#include "pipeline/wowee_heroic_scaling.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'H', 'R', 'D'};
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) != ".whrd") {
base += ".whrd";
}
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 WoweeHeroicScaling::Entry*
WoweeHeroicScaling::findById(uint32_t scalingId) const {
for (const auto& e : entries)
if (e.scalingId == scalingId) return &e;
return nullptr;
}
const WoweeHeroicScaling::Entry*
WoweeHeroicScaling::findForInstance(uint32_t mapId,
uint32_t difficultyId) const {
for (const auto& e : entries) {
if (e.mapId == mapId && e.difficultyId == difficultyId)
return &e;
}
return nullptr;
}
bool WoweeHeroicScalingLoader::save(const WoweeHeroicScaling& 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.scalingId);
writeStr(os, e.name);
writeStr(os, e.description);
writePOD(os, e.mapId);
writePOD(os, e.difficultyId);
writePOD(os, e.itemLevelDelta);
writePOD(os, e.bonusQualityChance);
writePOD(os, e.dropChanceMultiplier);
writePOD(os, e.heroicTokenItemId);
writePOD(os, e.bonusEmblemCount);
writePOD(os, e.pad0);
writePOD(os, e.pad1);
writePOD(os, e.pad2);
writePOD(os, e.iconColorRGBA);
}
return os.good();
}
WoweeHeroicScaling WoweeHeroicScalingLoader::load(
const std::string& basePath) {
WoweeHeroicScaling 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.scalingId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name) || !readStr(is, e.description)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.mapId) ||
!readPOD(is, e.difficultyId) ||
!readPOD(is, e.itemLevelDelta) ||
!readPOD(is, e.bonusQualityChance) ||
!readPOD(is, e.dropChanceMultiplier) ||
!readPOD(is, e.heroicTokenItemId) ||
!readPOD(is, e.bonusEmblemCount) ||
!readPOD(is, e.pad0) ||
!readPOD(is, e.pad1) ||
!readPOD(is, e.pad2) ||
!readPOD(is, e.iconColorRGBA)) {
out.entries.clear(); return out;
}
}
return out;
}
bool WoweeHeroicScalingLoader::exists(const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
WoweeHeroicScaling WoweeHeroicScalingLoader::makeWotLK5manHeroic(
const std::string& catalogName) {
using H = WoweeHeroicScaling;
WoweeHeroicScaling c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint32_t map,
uint32_t tokenId, const char* desc) {
H::Entry e;
e.scalingId = id; e.name = name; e.description = desc;
e.mapId = map;
e.difficultyId = 1; // 5-man Heroic
e.itemLevelDelta = 13;
e.bonusQualityChance = 200; // 2% bonus quality
e.dropChanceMultiplier = 1.0f;
e.heroicTokenItemId = tokenId;
e.bonusEmblemCount = 2; // 2× Emblem of
// Heroism per boss
e.iconColorRGBA = packRgba(180, 220, 100); // 5man green
c.entries.push_back(e);
};
// mapIds from WoTLK 3.3.5a Map.dbc.
// Token: Emblem of Heroism (itemId 40752).
add(1, "UtgardeKeepHeroic", 574, 40752,
"Utgarde Keep 5-man Heroic — +13 ilvl over "
"Normal, 2× Emblems of Heroism per boss, 2%% "
"chance for bonus +1-tier quality drop.");
add(2, "TheNexusHeroic", 576, 40752,
"The Nexus 5-man Heroic — same +13/2×/2%% "
"scaling. First Northrend instance with Heroic "
"queue popularity.");
add(3, "AzjolNerubHeroic", 601, 40752,
"Azjol-Nerub 5-man Heroic — same scaling. "
"Three-boss instance, fast Emblems of Heroism "
"farm.");
add(4, "AhnkahetHeroic", 619, 40752,
"Ahn'kahet: The Old Kingdom 5-man Heroic — "
"same scaling. Sister-instance to Azjol-Nerub.");
add(5, "DrakTharonHeroic", 600, 40752,
"Drak'Tharon Keep 5-man Heroic — same scaling. "
"Alliance/Horde-shared instance in Grizzly Hills.");
return c;
}
WoweeHeroicScaling WoweeHeroicScalingLoader::makeRaid25Heroic(
const std::string& catalogName) {
using H = WoweeHeroicScaling;
WoweeHeroicScaling c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint32_t map,
uint32_t difficulty, uint32_t tokenId,
int16_t ilvlDelta, const char* desc) {
H::Entry e;
e.scalingId = id; e.name = name; e.description = desc;
e.mapId = map;
e.difficultyId = difficulty;
e.itemLevelDelta = ilvlDelta;
e.bonusQualityChance = 500; // 5% bonus quality
// (raid heroic is
// more generous)
e.dropChanceMultiplier = 1.5f;
e.heroicTokenItemId = tokenId;
e.bonusEmblemCount = 1; // 1× extra emblem
// (base loot
// already gives 1)
e.iconColorRGBA = packRgba(220, 80, 100); // raid red
c.entries.push_back(e);
};
// Tokens: Emblem of Conquest (40753), Emblem of
// Triumph (47241), Emblem of Frost (49426).
add(100, "Naxx25Heroic", 533, 4, 40753, 13,
"Naxxramas 25H — +13 ilvl, 1.5× rare drop "
"chance, 5%% bonus quality, +1 Emblem of "
"Conquest per boss.");
add(101, "EoE25Heroic", 616, 4, 40753, 13,
"The Eye of Eternity 25H — same +13/1.5×/5%% "
"scaling. Single-boss instance (Malygos), "
"high-token-density per hour.");
add(102, "Ulduar25Heroic", 603, 4, 47241, 26,
"Ulduar 25H — +26 ilvl over Normal, 1.5× rare "
"drops, 5%% bonus quality, Emblem of Triumph.");
add(103, "ICC25Heroic", 631, 4, 49426, 26,
"Icecrown Citadel 25H — +26 ilvl, 1.5× rare "
"drops, 5%% bonus quality, Emblem of Frost. "
"Endgame WotLK content.");
return c;
}
WoweeHeroicScaling WoweeHeroicScalingLoader::makeChallengeMode(
const std::string& catalogName) {
using H = WoweeHeroicScaling;
WoweeHeroicScaling c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name,
uint32_t difficulty,
int16_t ilvlDelta, uint16_t bonusQual,
float dropMult, uint8_t emblems,
uint32_t color, const char* desc) {
H::Entry e;
e.scalingId = id; e.name = name; e.description = desc;
e.mapId = 0; // 0 = applies to any map
// with this difficulty
e.difficultyId = difficulty;
e.itemLevelDelta = ilvlDelta;
e.bonusQualityChance = bonusQual;
e.dropChanceMultiplier = dropMult;
e.heroicTokenItemId = 0; // challenge-mode
// uses transmog
// weekly cache, not
// a token reward
e.bonusEmblemCount = emblems;
e.iconColorRGBA = color;
c.entries.push_back(e);
};
// Anachronistic for WotLK (challenge mode came in
// Mists of Pandaria) but useful template for custom
// servers that backport the system.
add(200, "ChallengeModeBronze", 100,
13, 100, 1.0f, 0,
packRgba(180, 130, 80),
"Challenge Mode Bronze tier — completion within "
"Bronze time threshold. +13 ilvl, 1%% bonus "
"quality, no extra emblems. Modeled after MoP "
"challenge-mode rewards (anachronistic for "
"WotLK; template for custom servers).");
add(201, "ChallengeModeSilver", 101,
20, 250, 1.0f, 1,
packRgba(200, 200, 200),
"Challenge Mode Silver tier — +20 ilvl, 2.5%% "
"bonus quality, 1× extra emblem. Faster "
"completion than Bronze threshold.");
add(202, "ChallengeModeGold", 102,
26, 500, 1.0f, 2,
packRgba(220, 200, 80),
"Challenge Mode Gold tier — +26 ilvl, 5%% bonus "
"quality, 2× extra emblems. Top tier (transmog "
"set + mount unlock at category completion).");
return c;
}
} // namespace pipeline
} // namespace wowee

View file

@ -330,6 +330,8 @@ const char* const kArgRequired[] = {
"--export-wcre-json", "--import-wcre-json",
"--gen-ptt", "--gen-ptt-cunning", "--gen-ptt-tenacity",
"--info-wptt", "--validate-wptt",
"--gen-hrd", "--gen-hrd-raid25", "--gen-hrd-cm",
"--info-whrd", "--validate-whrd",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -152,6 +152,7 @@
#include "cli_learning_notifications_catalog.hpp"
#include "cli_creature_resists_catalog.hpp"
#include "cli_pet_talents_catalog.hpp"
#include "cli_heroic_scaling_catalog.hpp"
#include "cli_catalog_pluck.hpp"
#include "cli_catalog_find.hpp"
#include "cli_catalog_by_name.hpp"
@ -348,6 +349,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleLearningNotificationsCatalog,
handleCreatureResistsCatalog,
handlePetTalentsCatalog,
handleHeroicScalingCatalog,
handleCatalogPluck,
handleCatalogFind,
handleCatalogByName,

View file

@ -110,6 +110,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','L','D','N'}, ".wldn", "server", "--info-wldn", "Learning notification catalog"},
{{'W','C','R','E'}, ".wcre", "creatures", "--info-wcre", "Creature resist + immunity catalog"},
{{'W','P','T','T'}, ".wptt", "pets", "--info-wptt", "Hunter pet talent tree catalog"},
{{'W','H','R','D'}, ".whrd", "raid", "--info-whrd", "Heroic loot scaling 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"},

View file

@ -2261,6 +2261,16 @@ void printUsage(const char* argv0) {
std::printf(" Print WPTT entries (id / tree / tier / column / max ranks / prereq talentId / loyalty req / name) plus per-talent rank-spell IDs\n");
std::printf(" --validate-wptt <wptt-base> [--json]\n");
std::printf(" Static checks: id+name required, treeKind 0..2, tier 0..6, column 0..2, maxRank 1..5, no duplicate talentIds, no two talents in same (tree,tier,col) cell, no self-referencing prereqs, prereqs resolve to existing entries IN SAME TREE at EARLIER TIER, spellIdsByRank.size() == maxRank, no zero-spell-id within array\n");
std::printf(" --gen-hrd <whrd-base> [name]\n");
std::printf(" Emit .whrd 5 WotLK 5-man Heroic scalings (Utgarde Keep / Nexus / Azjol-Nerub / Ahn'kahet / Drak'Tharon — +13 ilvl, 2x Emblem of Heroism)\n");
std::printf(" --gen-hrd-raid25 <whrd-base> [name]\n");
std::printf(" Emit .whrd 4 WotLK 25H raid scalings (Naxx +13 / EoE +13 / Ulduar +26 / ICC +26 ilvl, 1.5x rare drop chance, +1 Emblem of Conquest/Triumph/Frost)\n");
std::printf(" --gen-hrd-cm <whrd-base> [name]\n");
std::printf(" Emit .whrd 3 challenge-mode tier scalings (Bronze +13/Silver +20/Gold +26 ilvl) — anachronistic for WotLK but useful template for custom-server backports\n");
std::printf(" --info-whrd <whrd-base> [--json]\n");
std::printf(" Print WHRD entries (id / map / difficulty / +ilvl / bonus quality %% / drop multiplier / token id / extra emblems / name)\n");
std::printf(" --validate-whrd <whrd-base> [--json]\n");
std::printf(" Static checks: id+name required, difficultyId>0 (Normal=0 by convention), bonusQualityChance<=10000 basis points, dropChanceMultiplier>0, no duplicate scalingIds, no two scalings binding the same (mapId,difficultyId) tuple unless mapId=0 wildcard; warns on negative ilvlDelta (Heroic worse than Normal?), ilvl>50 (beyond canonical range), drop multiplier>10x\n");
std::printf(" --catalog-pluck <wXXX-file> <id> [--json]\n");
std::printf(" Extract one entry by id from any registered catalog format. Auto-detects magic, dispatches to the per-format --info-* handler internally, then prints just the matching entry. Primary-key field is auto-detected (first *Id field, or first numeric)\n");
std::printf(" --catalog-find <directory> <id> [--magic <WXXX>] [--json]\n");

View file

@ -0,0 +1,280 @@
#include "cli_heroic_scaling_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_heroic_scaling.hpp"
#include <nlohmann/json.hpp>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <set>
#include <string>
#include <vector>
namespace wowee {
namespace editor {
namespace cli {
namespace {
std::string stripWhrdExt(std::string base) {
stripExt(base, ".whrd");
return base;
}
bool saveOrError(const wowee::pipeline::WoweeHeroicScaling& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeHeroicScalingLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.whrd\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeHeroicScaling& c,
const std::string& base) {
std::printf("Wrote %s.whrd\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" scalings : %zu\n", c.entries.size());
}
int handleGen5man(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "WotLK5manHeroicScaling";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWhrdExt(base);
auto c = wowee::pipeline::WoweeHeroicScalingLoader::makeWotLK5manHeroic(name);
if (!saveOrError(c, base, "gen-hrd")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenRaid25(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "Raid25HeroicScaling";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWhrdExt(base);
auto c = wowee::pipeline::WoweeHeroicScalingLoader::makeRaid25Heroic(name);
if (!saveOrError(c, base, "gen-hrd-raid25")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenChallenge(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "ChallengeModeScaling";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWhrdExt(base);
auto c = wowee::pipeline::WoweeHeroicScalingLoader::makeChallengeMode(name);
if (!saveOrError(c, base, "gen-hrd-cm")) 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 = stripWhrdExt(base);
if (!wowee::pipeline::WoweeHeroicScalingLoader::exists(base)) {
std::fprintf(stderr, "WHRD not found: %s.whrd\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeHeroicScalingLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["whrd"] = base + ".whrd";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"scalingId", e.scalingId},
{"name", e.name},
{"description", e.description},
{"mapId", e.mapId},
{"difficultyId", e.difficultyId},
{"itemLevelDelta", e.itemLevelDelta},
{"bonusQualityChance", e.bonusQualityChance},
{"bonusQualityPct",
e.bonusQualityChance / 100.0},
{"dropChanceMultiplier", e.dropChanceMultiplier},
{"heroicTokenItemId", e.heroicTokenItemId},
{"bonusEmblemCount", e.bonusEmblemCount},
{"iconColorRGBA", e.iconColorRGBA},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WHRD: %s.whrd\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" scalings : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id map diff ilvl bonusQ%% dropMult token emblems name\n");
for (const auto& e : c.entries) {
std::printf(" %4u %4u %4u %+4d %5.2f %5.2fx %6u %3u %s\n",
e.scalingId, e.mapId, e.difficultyId,
e.itemLevelDelta,
e.bonusQualityChance / 100.0,
e.dropChanceMultiplier,
e.heroicTokenItemId,
e.bonusEmblemCount, 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 = stripWhrdExt(base);
if (!wowee::pipeline::WoweeHeroicScalingLoader::exists(base)) {
std::fprintf(stderr,
"validate-whrd: WHRD not found: %s.whrd\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeHeroicScalingLoader::load(base);
std::vector<std::string> errors;
std::vector<std::string> warnings;
if (c.entries.empty()) {
warnings.push_back("catalog has zero entries");
}
std::set<uint32_t> idsSeen;
// (mapId, difficultyId) tuple uniqueness — two
// scalings binding the same instance+difficulty
// would make the loot-roll lookup ambiguous.
std::set<uint64_t> instanceComboSeen;
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.scalingId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.scalingId == 0)
errors.push_back(ctx + ": scalingId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.difficultyId == 0) {
errors.push_back(ctx +
": difficultyId is 0 — Heroic scaling "
"must specify a non-default difficulty "
"(Normal mode is difficultyId=0 by "
"convention)");
}
// itemLevelDelta sanity. 5-man Heroic typically
// +13, raid Heroic +13 to +26. Negative is
// unusual (Heroic shouldn't be WORSE than Normal).
if (e.itemLevelDelta < 0) {
warnings.push_back(ctx +
": itemLevelDelta " +
std::to_string(e.itemLevelDelta) +
" < 0 — Heroic loot is worse than Normal? "
"Verify if intentional");
}
if (e.itemLevelDelta > 50) {
warnings.push_back(ctx +
": itemLevelDelta " +
std::to_string(e.itemLevelDelta) +
" > 50 — exceeds typical Heroic-scaling "
"delta range (max canonical is +26 for "
"raid Heroic)");
}
if (e.bonusQualityChance > 10000) {
errors.push_back(ctx +
": bonusQualityChance " +
std::to_string(e.bonusQualityChance) +
" > 10000 (basis points cap) — would "
"guarantee multiple bonus drops");
}
if (e.dropChanceMultiplier <= 0.0f) {
errors.push_back(ctx +
": dropChanceMultiplier <= 0 — would "
"block all loot drops on Heroic");
}
if (e.dropChanceMultiplier > 10.0f) {
warnings.push_back(ctx +
": dropChanceMultiplier " +
std::to_string(e.dropChanceMultiplier) +
" > 10x — extreme drop boost; verify if "
"intentional");
}
// (mapId, difficultyId) uniqueness — but mapId=0
// is the wildcard (any map at the given
// difficulty), which is allowed multiple times.
if (e.mapId != 0) {
uint64_t key = (static_cast<uint64_t>(e.mapId) << 32)
| e.difficultyId;
if (!instanceComboSeen.insert(key).second) {
errors.push_back(ctx +
": (mapId=" + std::to_string(e.mapId) +
", difficultyId=" +
std::to_string(e.difficultyId) +
") combo already bound by another "
"scaling — loot-roll lookup would be "
"ambiguous");
}
}
if (!idsSeen.insert(e.scalingId).second) {
errors.push_back(ctx + ": duplicate scalingId");
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["whrd"] = base + ".whrd";
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-whrd: %s.whrd\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu scalings, all scalingIds + "
"(map,difficulty) tuples unique\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 handleHeroicScalingCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-hrd") == 0 && i + 1 < argc) {
outRc = handleGen5man(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-hrd-raid25") == 0 &&
i + 1 < argc) {
outRc = handleGenRaid25(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-hrd-cm") == 0 && i + 1 < argc) {
outRc = handleGenChallenge(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-whrd") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-whrd") == 0 && i + 1 < argc) {
outRc = handleValidate(i, argc, argv); return true;
}
return false;
}
} // namespace cli
} // namespace editor
} // namespace wowee

View file

@ -0,0 +1,12 @@
#pragma once
namespace wowee {
namespace editor {
namespace cli {
bool handleHeroicScalingCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee

View file

@ -132,6 +132,7 @@ constexpr FormatRow kFormats[] = {
{"WLDN", ".wldn", "server", "TutorialPopup + LevelMilestone msgs","Learning notification catalog (level-up milestones)"},
{"WCRE", ".wcre", "creatures", "creature_template resist + immunity","Creature resist + CC-immunity profile catalog"},
{"WPTT", ".wptt", "pets", "PetTalent.dbc + PetTalentTab.dbc", "Hunter pet talent tree catalog (3 trees, grid+graph)"},
{"WHRD", ".whrd", "raid", "implicit Heroic-mode loot scaling", "Heroic loot scaling catalog (per instance+difficulty)"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine