feat(editor): add WCRE (Creature Resistance & Immunity) — 106th open format

Novel replacement for the per-creature resistance columns
that vanilla WoW buried inside creature_template
(resistance1..6 fields) plus the SpellSchoolMask immunity
and mechanic_immune_mask columns. Each entry is one
creature's full defensive profile: 6 magic-school resist
values (int16, with 32767 as the full-immunity sentinel),
a physical-resistance percentage (0..75 game-engine cap),
plus three immunity bitmasks (CC kinds, spell mechanics,
magic schools).

The CC-immunity mask uses 14 named bits: ImmuneRoot /
Snare / Stun / Fear / Sleep / Silence / Charm / Disarm /
Polymorph / Banish / Knockback / Interrupt / Taunt /
Bleed. The info display renders the mask as a "+"-joined
token list ("root+stun+fear") for readability; "all" for
0xFFFF (typical raid-boss CC profile) and "none" for 0.

Three preset emitters: makeRaidBosses (5 canonical raid
bosses with iconic single-school immunities — Ragnaros
fire / Vael 50%-all / Hakkar arcane / Kel'Thuzad shadow
/ Onyxia fire+frost partial), makeElites (5 mid-tier
elites with single-school resists), makeImmunities (4
selective CC-immunity test cases — root-immune treant,
stun-immune worg, silence-immune acolyte, fear+charm+
poly-immune undead).

Validator's most novel check is creatureEntry uniqueness
— multiple WCRE entries binding the same creature would
make the damage-calc lookup ambiguous (which profile
applies?). Also catches negative resists < -100 (extreme
>2x damage taken), physicalResistPct > 75 (clamped at
runtime to game-engine armor cap), and reserved bits in
schoolImmunityMask (only bits 0-5 are meaningful).

Format count 105 -> 106. CLI flag count 1162 -> 1167.
This commit is contained in:
Kelsi 2026-05-10 01:40:39 -07:00
parent e4e15b3ffa
commit f9cad45154
10 changed files with 781 additions and 0 deletions

View file

@ -694,6 +694,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_tabards.cpp
src/pipeline/wowee_spell_markers.cpp
src/pipeline/wowee_learning_notifications.cpp
src/pipeline/wowee_creature_resists.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1551,6 +1552,7 @@ add_executable(wowee_editor
tools/editor/cli_tabards_catalog.cpp
tools/editor/cli_spell_markers_catalog.cpp
tools/editor/cli_learning_notifications_catalog.cpp
tools/editor/cli_creature_resists_catalog.cpp
tools/editor/cli_catalog_pluck.cpp
tools/editor/cli_catalog_find.cpp
tools/editor/cli_quest_objective.cpp
@ -1725,6 +1727,7 @@ add_executable(wowee_editor
src/pipeline/wowee_tabards.cpp
src/pipeline/wowee_spell_markers.cpp
src/pipeline/wowee_learning_notifications.cpp
src/pipeline/wowee_creature_resists.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,134 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Creature Resistance & Immunity catalog
// (.wcre) — novel replacement for the per-creature
// resistance columns that vanilla WoW buried inside
// creature_template (resistance1..6 fields) plus the
// SpellSchoolMask immunity / mechanic_immune_mask
// columns. Each entry is one creature's full resistance
// + immunity profile: 6 magic-school resist values, a
// physical-resistance percentage, plus three immunity
// bitmasks (crowd-control kinds, spell mechanics, magic
// schools).
//
// Cross-references with previously-added formats:
// WCRT: creatureEntry references the WCRT creature
// catalog. One WCRE row per WCRT entry that
// needs non-default resistances; absence means
// the creature uses default zero resistances.
// WSCH: schoolImmunityMask uses the WSCH school-bit
// convention.
//
// Binary layout (little-endian):
// magic[4] = "WCRE"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// resistId (uint32)
// nameLen + name
// descLen + description
// creatureEntry (uint32)
// holyResist (int16) / fireResist (int16)
// natureResist (int16) / frostResist (int16)
// shadowResist (int16) / arcaneResist (int16)
// physicalResistPct (uint8) — 0..75 (cap is 75%)
// pad0 (uint8)
// ccImmunityMask (uint16) — Stun/Root/Fear/etc.
// mechanicImmunityMask (uint32) — full mechanic
// bitmask
// schoolImmunityMask (uint8) — WSCH-bit immunity
// pad1 (uint8) / pad2 (uint8) / pad3 (uint8)
// iconColorRGBA (uint32)
struct WoweeCreatureResists {
enum CCImmunityBit : uint16_t {
ImmuneRoot = 0x0001,
ImmuneSnare = 0x0002,
ImmuneStun = 0x0004,
ImmuneFear = 0x0008,
ImmuneSleep = 0x0010,
ImmuneSilence = 0x0020,
ImmuneCharm = 0x0040,
ImmuneDisarm = 0x0080,
ImmunePolymorph = 0x0100,
ImmuneBanish = 0x0200,
ImmuneKnockback = 0x0400,
ImmuneInterrupt = 0x0800,
ImmuneTaunt = 0x1000,
ImmuneBleed = 0x2000,
};
struct Entry {
uint32_t resistId = 0;
std::string name;
std::string description;
uint32_t creatureEntry = 0;
int16_t holyResist = 0;
int16_t fireResist = 0;
int16_t natureResist = 0;
int16_t frostResist = 0;
int16_t shadowResist = 0;
int16_t arcaneResist = 0;
uint8_t physicalResistPct = 0;
uint8_t pad0 = 0;
uint16_t ccImmunityMask = 0;
uint32_t mechanicImmunityMask = 0;
uint8_t schoolImmunityMask = 0;
uint8_t pad1 = 0;
uint8_t pad2 = 0;
uint8_t pad3 = 0;
uint32_t iconColorRGBA = 0xFFFFFFFFu;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t resistId) const;
// Returns the resist profile for a given creature
// entry, or nullptr if the creature uses defaults.
// Used by the damage-calculation path to look up
// "what's this mob's frost resist?" without scanning.
const Entry* findByCreature(uint32_t creatureEntry) const;
};
class WoweeCreatureResistsLoader {
public:
static bool save(const WoweeCreatureResists& cat,
const std::string& basePath);
static WoweeCreatureResists load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-cre* variants.
//
// makeRaidBosses — 5 canonical raid-boss profiles
// with high single-school
// resistances or full immunities
// (Ragnaros 100% fire / Vaelastrasz
// 50% all / Hakkar arcane immune /
// Kel'Thuzad shadow immune /
// Onyxia fire+frost partial).
// makeElites — 5 mid-tier elite profiles with
// moderate resists (water elementals
// fire-resistant / stone golems
// nature-resistant / etc.).
// makeImmunities — 4 CC-immunity test cases (root /
// stun / silence / fear immune
// creatures for boss-mechanic
// verification).
static WoweeCreatureResists makeRaidBosses(const std::string& catalogName);
static WoweeCreatureResists makeElites(const std::string& catalogName);
static WoweeCreatureResists makeImmunities(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,317 @@
#include "pipeline/wowee_creature_resists.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'C', 'R', 'E'};
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) != ".wcre") {
base += ".wcre";
}
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 WoweeCreatureResists::Entry*
WoweeCreatureResists::findById(uint32_t resistId) const {
for (const auto& e : entries)
if (e.resistId == resistId) return &e;
return nullptr;
}
const WoweeCreatureResists::Entry*
WoweeCreatureResists::findByCreature(uint32_t creatureEntry) const {
for (const auto& e : entries)
if (e.creatureEntry == creatureEntry) return &e;
return nullptr;
}
bool WoweeCreatureResistsLoader::save(const WoweeCreatureResists& 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.resistId);
writeStr(os, e.name);
writeStr(os, e.description);
writePOD(os, e.creatureEntry);
writePOD(os, e.holyResist);
writePOD(os, e.fireResist);
writePOD(os, e.natureResist);
writePOD(os, e.frostResist);
writePOD(os, e.shadowResist);
writePOD(os, e.arcaneResist);
writePOD(os, e.physicalResistPct);
writePOD(os, e.pad0);
writePOD(os, e.ccImmunityMask);
writePOD(os, e.mechanicImmunityMask);
writePOD(os, e.schoolImmunityMask);
writePOD(os, e.pad1);
writePOD(os, e.pad2);
writePOD(os, e.pad3);
writePOD(os, e.iconColorRGBA);
}
return os.good();
}
WoweeCreatureResists WoweeCreatureResistsLoader::load(
const std::string& basePath) {
WoweeCreatureResists 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.resistId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name) || !readStr(is, e.description)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.creatureEntry) ||
!readPOD(is, e.holyResist) ||
!readPOD(is, e.fireResist) ||
!readPOD(is, e.natureResist) ||
!readPOD(is, e.frostResist) ||
!readPOD(is, e.shadowResist) ||
!readPOD(is, e.arcaneResist) ||
!readPOD(is, e.physicalResistPct) ||
!readPOD(is, e.pad0) ||
!readPOD(is, e.ccImmunityMask) ||
!readPOD(is, e.mechanicImmunityMask) ||
!readPOD(is, e.schoolImmunityMask) ||
!readPOD(is, e.pad1) ||
!readPOD(is, e.pad2) ||
!readPOD(is, e.pad3) ||
!readPOD(is, e.iconColorRGBA)) {
out.entries.clear(); return out;
}
}
return out;
}
bool WoweeCreatureResistsLoader::exists(const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
WoweeCreatureResists WoweeCreatureResistsLoader::makeRaidBosses(
const std::string& catalogName) {
using R = WoweeCreatureResists;
WoweeCreatureResists c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name,
uint32_t entry,
int16_t holy, int16_t fire,
int16_t nature, int16_t frost,
int16_t shadow, int16_t arcane,
uint8_t physPct,
uint16_t ccImm, uint8_t schoolImm,
const char* desc) {
R::Entry e;
e.resistId = id; e.name = name; e.description = desc;
e.creatureEntry = entry;
e.holyResist = holy; e.fireResist = fire;
e.natureResist = nature; e.frostResist = frost;
e.shadowResist = shadow; e.arcaneResist = arcane;
e.physicalResistPct = physPct;
e.ccImmunityMask = ccImm;
e.schoolImmunityMask = schoolImm;
// Bosses immune to most CC by convention (server-
// wide behavior — bosses can't be CC'd at all).
e.mechanicImmunityMask = 0xFFFFFFFFu;
e.iconColorRGBA = packRgba(220, 60, 60); // boss red
c.entries.push_back(e);
};
// Ragnaros — fire-school immune (school bit 0x04 in
// typical school-bit numbering: holy=1, fire=2,
// nature=4, frost=8, shadow=16, arcane=32). Using
// 0x02 here for fire.
add(1, "RagnarosFireImmune", 11502,
0, 32767, 0, 0, 0, 0, 0,
0xFFFF, 0x02,
"Ragnaros (Molten Core boss) — 100% fire-school "
"immunity (fireResist=32767 = full block) plus "
"schoolImmunityMask bit for fire. All CC immune.");
add(2, "VaelHalfResist", 13020,
100, 100, 100, 100, 100, 100, 0,
0xFFFF, 0,
"Vaelastrasz (BWL) — 100 resist to all 6 magic "
"schools (~50% mitigation against caster spells). "
"All CC immune.");
add(3, "HakkarArcaneImmune", 14834,
0, 0, 0, 0, 0, 32767, 0,
0xFFFF, 0x20,
"Hakkar (ZG) — full arcane immunity. All CC "
"immune. Other schools at default zero resist.");
add(4, "KelthuzadShadowImmune", 15990,
0, 0, 0, 200, 32767, 0, 0,
0xFFFF, 0x10,
"Kel'Thuzad (Naxx) — full shadow-school "
"immunity, plus 200 frost resist (~50% frost "
"mitigation). Iconic anti-warlock fight.");
add(5, "OnyxiaPartialImmune", 10184,
0, 100, 0, 100, 0, 0, 0,
0xFFFF, 0,
"Onyxia — 100 fire + 100 frost resist (50% "
"mitigation against both schools). All CC "
"immune.");
return c;
}
WoweeCreatureResists WoweeCreatureResistsLoader::makeElites(
const std::string& catalogName) {
using R = WoweeCreatureResists;
WoweeCreatureResists c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name,
uint32_t entry,
int16_t holy, int16_t fire,
int16_t nature, int16_t frost,
int16_t shadow, int16_t arcane,
const char* desc) {
R::Entry e;
e.resistId = id; e.name = name; e.description = desc;
e.creatureEntry = entry;
e.holyResist = holy; e.fireResist = fire;
e.natureResist = nature; e.frostResist = frost;
e.shadowResist = shadow; e.arcaneResist = arcane;
e.physicalResistPct = 0;
// Elites can be CC'd but not all — 80%
// mechanicImmune to common debuffs.
e.ccImmunityMask = R::ImmuneFear | R::ImmuneSleep;
e.mechanicImmunityMask = 0;
e.schoolImmunityMask = 0;
e.iconColorRGBA = packRgba(200, 140, 60); // elite gold
c.entries.push_back(e);
};
add(100, "WaterElementalFireResist", 12471,
0, 60, 0, 0, 0, 0,
"Water Elemental (Bog of Sorrows) — 60 fire "
"resist (~30% mitigation). Frost-themed mob "
"resists fire by lore.");
add(101, "StoneGiantNatureResist", 12476,
0, 0, 100, 0, 0, 0,
"Stone Giant (Stonetalon) — 100 nature resist "
"(50% mitigation). Earth-element mob resists "
"druid spells.");
add(102, "ScarletPriestHolyResist", 11030,
80, 0, 0, 0, 60, 0,
"Scarlet Crusade Priest (Scarlet Monastery) — "
"80 holy + 60 shadow resist. Light/dark-school "
"trained.");
add(103, "DustwindStormcasterArcane", 8519,
0, 0, 0, 0, 0, 80,
"Dustwind Stormcaster (Silithus) — 80 arcane "
"resist (40% mitigation). Caster mob favors "
"arcane defense.");
add(104, "FrostwolfEntinelFrost", 10920,
0, 0, 0, 60, 0, 0,
"Frostwolf Sentinel (Alterac Valley) — 60 frost "
"resist (30% mitigation). Northern enemy "
"acclimated to cold.");
return c;
}
WoweeCreatureResists WoweeCreatureResistsLoader::makeImmunities(
const std::string& catalogName) {
using R = WoweeCreatureResists;
WoweeCreatureResists c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name,
uint32_t entry, uint16_t ccMask,
uint32_t mechMask, const char* desc) {
R::Entry e;
e.resistId = id; e.name = name; e.description = desc;
e.creatureEntry = entry;
e.ccImmunityMask = ccMask;
e.mechanicImmunityMask = mechMask;
e.schoolImmunityMask = 0;
e.iconColorRGBA = packRgba(140, 100, 240); // immune purple
c.entries.push_back(e);
};
add(200, "RootImmuneTreant", 12477,
R::ImmuneRoot | R::ImmuneSnare, 0,
"Treant (Felwood) — root + snare immune. "
"Cannot be Entangling Roots or Frost Trap'd.");
add(201, "StunImmuneAlphaWolf", 14283,
R::ImmuneStun, 0,
"Alpha Worg (Silverpine) — stun immune. "
"Cannot be Cheap Shot'd or Concussion Blow'd.");
add(202, "SilenceImmuneCaster", 11839,
R::ImmuneSilence | R::ImmuneInterrupt, 0,
"Cult of the Damned Acolyte — silence + "
"interrupt immune. Spell pushback works but "
"the cast itself can't be interrupted.");
add(203, "FearImmuneUndead", 18525,
R::ImmuneFear | R::ImmuneCharm | R::ImmunePolymorph,
0,
"Risen Construct (Naxxramas) — fear + charm + "
"polymorph immune. Mind-affecting CC has no "
"effect; physical CC like stun/root still works.");
return c;
}
} // namespace pipeline
} // namespace wowee

View file

@ -325,6 +325,8 @@ const char* const kArgRequired[] = {
"--gen-ldn", "--gen-ldn-account", "--gen-ldn-rep",
"--info-wldn", "--validate-wldn",
"--export-wldn-json", "--import-wldn-json",
"--gen-cre", "--gen-cre-elites", "--gen-cre-immune",
"--info-wcre", "--validate-wcre",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -0,0 +1,299 @@
#include "cli_creature_resists_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_creature_resists.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 stripWcreExt(std::string base) {
stripExt(base, ".wcre");
return base;
}
std::string ccImmunityString(uint16_t mask) {
using R = wowee::pipeline::WoweeCreatureResists;
if (mask == 0) return "none";
if (mask == 0xFFFF) return "all";
std::string out;
auto add = [&](const char* tag) {
if (!out.empty()) out += "+";
out += tag;
};
if (mask & R::ImmuneRoot) add("root");
if (mask & R::ImmuneSnare) add("snare");
if (mask & R::ImmuneStun) add("stun");
if (mask & R::ImmuneFear) add("fear");
if (mask & R::ImmuneSleep) add("sleep");
if (mask & R::ImmuneSilence) add("silence");
if (mask & R::ImmuneCharm) add("charm");
if (mask & R::ImmuneDisarm) add("disarm");
if (mask & R::ImmunePolymorph) add("polymorph");
if (mask & R::ImmuneBanish) add("banish");
if (mask & R::ImmuneKnockback) add("knockback");
if (mask & R::ImmuneInterrupt) add("interrupt");
if (mask & R::ImmuneTaunt) add("taunt");
if (mask & R::ImmuneBleed) add("bleed");
return out.empty() ? "none" : out;
}
bool saveOrError(const wowee::pipeline::WoweeCreatureResists& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeCreatureResistsLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wcre\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeCreatureResists& c,
const std::string& base) {
std::printf("Wrote %s.wcre\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" resists : %zu\n", c.entries.size());
}
int handleGenBosses(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "RaidBossResists";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcreExt(base);
auto c = wowee::pipeline::WoweeCreatureResistsLoader::makeRaidBosses(name);
if (!saveOrError(c, base, "gen-cre")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenElites(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "EliteResists";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcreExt(base);
auto c = wowee::pipeline::WoweeCreatureResistsLoader::makeElites(name);
if (!saveOrError(c, base, "gen-cre-elites")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenImmunities(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "CCImmunityProfiles";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcreExt(base);
auto c = wowee::pipeline::WoweeCreatureResistsLoader::makeImmunities(name);
if (!saveOrError(c, base, "gen-cre-immune")) 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 = stripWcreExt(base);
if (!wowee::pipeline::WoweeCreatureResistsLoader::exists(base)) {
std::fprintf(stderr, "WCRE not found: %s.wcre\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeCreatureResistsLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wcre"] = base + ".wcre";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"resistId", e.resistId},
{"name", e.name},
{"description", e.description},
{"creatureEntry", e.creatureEntry},
{"holyResist", e.holyResist},
{"fireResist", e.fireResist},
{"natureResist", e.natureResist},
{"frostResist", e.frostResist},
{"shadowResist", e.shadowResist},
{"arcaneResist", e.arcaneResist},
{"physicalResistPct", e.physicalResistPct},
{"ccImmunityMask", e.ccImmunityMask},
{"ccImmunityNames", ccImmunityString(e.ccImmunityMask)},
{"mechanicImmunityMask", e.mechanicImmunityMask},
{"schoolImmunityMask", e.schoolImmunityMask},
{"iconColorRGBA", e.iconColorRGBA},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WCRE: %s.wcre\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" resists : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id creature holy fire natu fros shad arca phys%% schoolImm CC-immune\n");
for (const auto& e : c.entries) {
std::printf(" %4u %5u %4d %4d %4d %4d %4d %4d %3u 0x%02X %s\n",
e.resistId, e.creatureEntry,
e.holyResist, e.fireResist,
e.natureResist, e.frostResist,
e.shadowResist, e.arcaneResist,
e.physicalResistPct,
e.schoolImmunityMask,
ccImmunityString(e.ccImmunityMask).c_str());
std::printf(" %s\n", 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 = stripWcreExt(base);
if (!wowee::pipeline::WoweeCreatureResistsLoader::exists(base)) {
std::fprintf(stderr,
"validate-wcre: WCRE not found: %s.wcre\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeCreatureResistsLoader::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;
std::set<uint32_t> creaturesSeen;
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.resistId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.resistId == 0)
errors.push_back(ctx + ": resistId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.creatureEntry == 0) {
errors.push_back(ctx +
": creatureEntry is 0 — resist profile is "
"not bound to any WCRT entry");
}
// Resist values: int16 covers -32768 to 32767.
// 32767 is the special "full immunity" sentinel.
// Negative values are unusual but legal (some DR
// mechanics can negative-resist).
auto checkResist = [&](int16_t v, const char* school) {
if (v < -100) {
warnings.push_back(ctx + ": " + school +
" resist " + std::to_string(v) +
" < -100 — extreme negative resist "
"creates >2x damage taken; verify");
}
};
checkResist(e.holyResist, "holy");
checkResist(e.fireResist, "fire");
checkResist(e.natureResist, "nature");
checkResist(e.frostResist, "frost");
checkResist(e.shadowResist, "shadow");
checkResist(e.arcaneResist, "arcane");
// physicalResistPct cap is 75% (game-engine
// hard cap). Above that, the stored value is
// clamped at runtime.
if (e.physicalResistPct > 75) {
warnings.push_back(ctx +
": physicalResistPct " +
std::to_string(e.physicalResistPct) +
" > 75%% — clamped at runtime to game-"
"engine cap (armor mitigation cap)");
}
// schoolImmunityMask uses bottom 6 bits (one per
// magic school). Bit 7 unused.
if (e.schoolImmunityMask & 0xC0) {
warnings.push_back(ctx +
": schoolImmunityMask has reserved bits "
"set (0xC0) — only bits 0-5 (Holy/Fire/"
"Nature/Frost/Shadow/Arcane) are meaningful");
}
// Multiple WCRE entries binding the same
// creature is ambiguous (which profile applies?).
if (e.creatureEntry != 0 &&
!creaturesSeen.insert(e.creatureEntry).second) {
errors.push_back(ctx +
": creatureEntry " +
std::to_string(e.creatureEntry) +
" is already bound by another resist "
"profile — damage-calc lookup would be "
"ambiguous");
}
if (!idsSeen.insert(e.resistId).second) {
errors.push_back(ctx + ": duplicate resistId");
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wcre"] = base + ".wcre";
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-wcre: %s.wcre\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu resist profiles, all "
"resistIds + creatureEntries 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 handleCreatureResistsCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-cre") == 0 && i + 1 < argc) {
outRc = handleGenBosses(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-cre-elites") == 0 && i + 1 < argc) {
outRc = handleGenElites(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-cre-immune") == 0 && i + 1 < argc) {
outRc = handleGenImmunities(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wcre") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wcre") == 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 handleCreatureResistsCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee

View file

@ -150,6 +150,7 @@
#include "cli_tabards_catalog.hpp"
#include "cli_spell_markers_catalog.hpp"
#include "cli_learning_notifications_catalog.hpp"
#include "cli_creature_resists_catalog.hpp"
#include "cli_catalog_pluck.hpp"
#include "cli_catalog_find.hpp"
#include "cli_quest_objective.hpp"
@ -343,6 +344,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleTabardsCatalog,
handleSpellMarkersCatalog,
handleLearningNotificationsCatalog,
handleCreatureResistsCatalog,
handleCatalogPluck,
handleCatalogFind,
handleQuestObjective,

View file

@ -108,6 +108,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','T','B','D'}, ".wtbd", "guilds", "--info-wtbd", "Tabard design / heraldry catalog"},
{{'W','S','P','M'}, ".wspm", "spellfx", "--info-wspm", "Spell persistent marker catalog"},
{{'W','L','D','N'}, ".wldn", "server", "--info-wldn", "Learning notification catalog"},
{{'W','C','R','E'}, ".wcre", "creatures", "--info-wcre", "Creature resist + immunity 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

@ -2237,6 +2237,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wldn to a human-editable JSON sidecar (defaults to <base>.wldn.json; emits all 3 enums as both int AND name string; triggerValue as signed int32)\n");
std::printf(" --import-wldn-json <json-path> [out-base]\n");
std::printf(" Import a .wldn.json sidecar back into binary .wldn (triggerKind int OR \"levelreach\"/\"factionstanding\"/\"itemacquired\"/\"questcomplete\"/\"spelllearned\"/\"zoneentered\"; channelKind \"raidwarning\"/\"systemmsg\"/\"subtitle\"/\"tutorial\"/\"motdappend\"; factionFilter \"alliance\"/\"horde\"/\"both\")\n");
std::printf(" --gen-cre <wcre-base> [name]\n");
std::printf(" Emit .wcre 5 raid-boss resist profiles (Ragnaros 100%% fire-immune / Vael 50%% all schools / Hakkar arcane-immune / KT shadow-immune / Onyxia fire+frost partial)\n");
std::printf(" --gen-cre-elites <wcre-base> [name]\n");
std::printf(" Emit .wcre 5 elite mid-tier profiles with single-school resists (water elemental fire / stone giant nature / scarlet priest holy / dustwind arcane / frostwolf frost)\n");
std::printf(" --gen-cre-immune <wcre-base> [name]\n");
std::printf(" Emit .wcre 4 CC-immunity test profiles (treant root-immune / alpha worg stun-immune / acolyte silence-immune / risen construct fear+charm+poly immune)\n");
std::printf(" --info-wcre <wcre-base> [--json]\n");
std::printf(" Print WCRE entries (id / creatureEntry / 6 school resists / phys%% / school-immune mask / CC-immune token list / name)\n");
std::printf(" --validate-wcre <wcre-base> [--json]\n");
std::printf(" Static checks: id+name+creatureEntry required, no duplicate resistIds OR creatureEntries (damage-calc lookup ambiguity); warns on resist<-100 (extreme negative >2x dmg taken), physicalResistPct>75 (clamped at runtime), schoolImmunityMask reserved bits 0xC0 set\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

@ -130,6 +130,7 @@ constexpr FormatRow kFormats[] = {
{"WTBD", ".wtbd", "guilds", "guild_member tabard config blob", "Tabard design / heraldry catalog (3-color)"},
{"WSPM", ".wspm", "spellfx", "AreaTrigger.dbc + decal blob", "Spell persistent marker catalog (AoE ground decals)"},
{"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"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine