feat(pipeline): WPRC spell proc rules catalog (138th open format)

Novel replacement for the implicit proc-on-event spell triggers
vanilla WoW carried in SpellProcEvents (later rows of
Spell.dbc) + the per-spell procFlags + procChance fields
scattered across multiple DBC tables. Each WPRC entry binds
one proc rule to its source spell (the aura/buff that has the
proc), trigger event (OnHit/OnCrit/OnCast/OnTakeDamage/OnHeal/
OnDodge/OnParry/OnBlock/OnKill), proc chance in basis points
(0..10000 = 0..100%), internal cooldown ms, the spell to
trigger on proc, max-stacks-on-target cap, and optional
condition flags (RequireMeleeWeapon / RequireSpellSchool /
ExcludeAutoAttack / OnlyFromBehind / OnlyVsPvPTarget).

Three presets covering common vanilla proc archetypes:
  --gen-prc-weapon  3 weapon-enchant procs (Crusader 2%
                    OnHit / Lifestealing 5% / Fiery Weapon
                    7% with 1.5s ICD to handle dual-wield)
  --gen-prc-ret     4 Retribution Paladin procs (Vengeance
                    OnCrit 5-stack / Seal of Justice OnHit
                    25% with 60s per-target ICD / Reckoning
                    OnBlock 10% extra-attack / Sanctity Aura
                    OnCast bookkeeping)
  --gen-prc-rage    3 Warrior Rage-generation procs
                    (Bloodrage OnCast / Berserker Rage
                    OnCast immunity aura / Anger Mgmt OnDodge
                    passive)

Validator catches: id+name+sourceSpellId+procEffectSpellId
required, triggerEvent 0..8, procChancePct in 1..10000
(0 = never fires; > 10000 = > 100% basis points). CRITICAL:
sourceSpellId == procEffectSpellId on OnCast trigger errors
(infinite proc loop — the effect re-casts itself which fires
the proc again). Warns on 100% + 0ms ICD on high-frequency
events (OnHit/OnCrit/OnTakeDamage) — would spam every swing
without rate limiting.

Validator immediately caught a real preset bug during smoke-
test: Berserker Rage initially had sourceSpellId=18499 ==
procEffectSpellId=18499 with OnCast trigger. Validator
correctly errored with "infinite proc loop". Fixed preset to
use procEffectSpellId=23691 (the immunity-aura effect — a
distinct spell from the cast trigger).

Format count 137 -> 138. CLI flag count 1436 -> 1443.
This commit is contained in:
Kelsi 2026-05-10 05:09:13 -07:00
parent c60e779e67
commit 73d66a04d0
10 changed files with 785 additions and 0 deletions

View file

@ -726,6 +726,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_soulbind_rules.cpp
src/pipeline/wowee_creature_behavior.cpp
src/pipeline/wowee_random_property.cpp
src/pipeline/wowee_spell_proc_rules.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1615,6 +1616,7 @@ add_executable(wowee_editor
tools/editor/cli_soulbind_rules_catalog.cpp
tools/editor/cli_creature_behavior_catalog.cpp
tools/editor/cli_random_property_catalog.cpp
tools/editor/cli_spell_proc_rules_catalog.cpp
tools/editor/cli_catalog_pluck.cpp
tools/editor/cli_catalog_find.cpp
tools/editor/cli_catalog_by_name.cpp
@ -1823,6 +1825,7 @@ add_executable(wowee_editor
src/pipeline/wowee_soulbind_rules.cpp
src/pipeline/wowee_creature_behavior.cpp
src/pipeline/wowee_random_property.cpp
src/pipeline/wowee_spell_proc_rules.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,148 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Spell Proc Rules catalog (.wprc) —
// novel replacement for the implicit
// proc-on-event spell triggers vanilla WoW carried
// in SpellProcEvents (later rows of Spell.dbc) +
// the per-spell procFlags + procChance fields
// scattered across multiple DBC tables. Each WPRC
// entry binds one proc rule to its source spell
// (the aura/buff that has the proc), trigger event
// (OnHit/OnCrit/OnTakeDamage/etc), proc chance in
// basis points, internal cooldown, the spell to
// trigger on proc, max-stacks-on-target cap, and
// optional condition flags (require melee weapon,
// require spell school, etc).
//
// Cross-references with previously-added formats:
// WSPL: sourceSpellId AND procEffectSpellId both
// reference the WSPL spell catalog.
// WBHV: creature behaviors that cast sourceSpellId
// get the proc behavior automatically via
// this catalog at runtime.
//
// Binary layout (little-endian):
// magic[4] = "WPRC"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// procRuleId (uint32)
// nameLen + name
// sourceSpellId (uint32) — the aura/buff
// that owns the
// proc
// procEffectSpellId (uint32) — the spell to
// trigger on
// proc
// triggerEvent (uint8) — 0=OnHit /
// 1=OnCrit /
// 2=OnCast /
// 3=OnTakeDamage
// /4=OnHeal /
// 5=OnDodge /
// 6=OnParry /
// 7=OnBlock /
// 8=OnKill
// maxStacksOnTarget (uint8) — 0 = no stack
// limit
// procChancePct (uint16) — basis points
// 0..10000 (100=
// 1%)
// internalCooldownMs (uint32) — 0 = no ICD
// procFlagsMask (uint16) — bitmask of
// additional
// conditions
// pad0 (uint16)
struct WoweeSpellProcRules {
enum TriggerEvent : uint8_t {
OnHit = 0,
OnCrit = 1,
OnCast = 2,
OnTakeDamage = 3,
OnHeal = 4,
OnDodge = 5,
OnParry = 6,
OnBlock = 7,
OnKill = 8,
};
enum ProcFlag : uint16_t {
RequireMeleeWeapon = 0x0001,
RequireRangedWeapon = 0x0002,
RequireSpellSchool = 0x0004,
ExcludeAutoAttack = 0x0008,
OnlyFromBehind = 0x0010,
OnlyVsPvPTarget = 0x0020,
};
struct Entry {
uint32_t procRuleId = 0;
std::string name;
uint32_t sourceSpellId = 0;
uint32_t procEffectSpellId = 0;
uint8_t triggerEvent = OnHit;
uint8_t maxStacksOnTarget = 0;
uint16_t procChancePct = 0;
uint32_t internalCooldownMs = 0;
uint16_t procFlagsMask = 0;
uint16_t pad0 = 0;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t procRuleId) const;
// Returns all proc rules where the given spellId
// is the source aura. A single buff may have
// multiple procs on different events.
std::vector<const Entry*> findBySourceSpell(uint32_t spellId) const;
// Returns all proc rules that fire on a given
// event — used by the combat-event dispatcher
// hot path.
std::vector<const Entry*> findByEvent(uint8_t triggerEvent) const;
};
class WoweeSpellProcRulesLoader {
public:
static bool save(const WoweeSpellProcRules& cat,
const std::string& basePath);
static WoweeSpellProcRules load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-prc* variants.
//
// makeWeaponProcs — 3 vanilla weapon-enchant
// procs (Crusader buff
// OnHit / Lifesteal heal-
// on-hit / Fiery Weapon
// damage proc).
// makeRetPaladin — 4 procs from a
// Retribution Paladin
// rotation (Vengeance buff
// OnCrit / Seal of Justice
// stun proc / Reckoning
// block-counter / Sanctity
// Aura damage amp).
// makeRageGen — 3 Rage-generation procs
// (Bloodrage instant /
// Berserker Rage immunity
// / Anger Mgmt OnDodge).
static WoweeSpellProcRules makeWeaponProcs(const std::string& catalogName);
static WoweeSpellProcRules makeRetPaladin(const std::string& catalogName);
static WoweeSpellProcRules makeRageGen(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,308 @@
#include "pipeline/wowee_spell_proc_rules.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'P', 'R', 'C'};
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) != ".wprc") {
base += ".wprc";
}
return base;
}
} // namespace
const WoweeSpellProcRules::Entry*
WoweeSpellProcRules::findById(uint32_t procRuleId) const {
for (const auto& e : entries)
if (e.procRuleId == procRuleId) return &e;
return nullptr;
}
std::vector<const WoweeSpellProcRules::Entry*>
WoweeSpellProcRules::findBySourceSpell(uint32_t spellId) const {
std::vector<const Entry*> out;
for (const auto& e : entries)
if (e.sourceSpellId == spellId) out.push_back(&e);
return out;
}
std::vector<const WoweeSpellProcRules::Entry*>
WoweeSpellProcRules::findByEvent(uint8_t triggerEvent) const {
std::vector<const Entry*> out;
for (const auto& e : entries)
if (e.triggerEvent == triggerEvent) out.push_back(&e);
return out;
}
bool WoweeSpellProcRulesLoader::save(
const WoweeSpellProcRules& 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.procRuleId);
writeStr(os, e.name);
writePOD(os, e.sourceSpellId);
writePOD(os, e.procEffectSpellId);
writePOD(os, e.triggerEvent);
writePOD(os, e.maxStacksOnTarget);
writePOD(os, e.procChancePct);
writePOD(os, e.internalCooldownMs);
writePOD(os, e.procFlagsMask);
writePOD(os, e.pad0);
}
return os.good();
}
WoweeSpellProcRules WoweeSpellProcRulesLoader::load(
const std::string& basePath) {
WoweeSpellProcRules 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.procRuleId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.sourceSpellId) ||
!readPOD(is, e.procEffectSpellId) ||
!readPOD(is, e.triggerEvent) ||
!readPOD(is, e.maxStacksOnTarget) ||
!readPOD(is, e.procChancePct) ||
!readPOD(is, e.internalCooldownMs) ||
!readPOD(is, e.procFlagsMask) ||
!readPOD(is, e.pad0)) {
out.entries.clear(); return out;
}
}
return out;
}
bool WoweeSpellProcRulesLoader::exists(
const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
namespace {
WoweeSpellProcRules::Entry makeRule(
uint32_t procRuleId, const char* name,
uint32_t sourceSpellId, uint32_t procEffectSpellId,
uint8_t triggerEvent,
uint16_t procChancePct,
uint32_t internalCooldownMs,
uint16_t procFlagsMask,
uint8_t maxStacksOnTarget = 0) {
WoweeSpellProcRules::Entry e;
e.procRuleId = procRuleId; e.name = name;
e.sourceSpellId = sourceSpellId;
e.procEffectSpellId = procEffectSpellId;
e.triggerEvent = triggerEvent;
e.procChancePct = procChancePct;
e.internalCooldownMs = internalCooldownMs;
e.procFlagsMask = procFlagsMask;
e.maxStacksOnTarget = maxStacksOnTarget;
return e;
}
} // namespace
WoweeSpellProcRules WoweeSpellProcRulesLoader::makeWeaponProcs(
const std::string& catalogName) {
using P = WoweeSpellProcRules;
WoweeSpellProcRules c;
c.name = catalogName;
// Crusader (Enchant Weapon — Crusader, spellId
// 20007) procs spell 20007 buff OnHit at ~2%
// chance, no ICD, requires melee weapon.
c.entries.push_back(makeRule(
1, "Crusader Weapon Enchant",
20007 /* Enchant: Crusader */,
20007 /* same spell triggers the buff */,
P::OnHit,
200 /* 2% basis points */,
0,
P::RequireMeleeWeapon | P::ExcludeAutoAttack));
// Lifesteal: spellId 20004 (Enchant Weapon —
// Lifestealing) procs heal-on-hit. 5% chance,
// no ICD.
c.entries.push_back(makeRule(
2, "Lifestealing Weapon Enchant",
20004 /* Enchant: Lifesteal */,
20004,
P::OnHit,
500 /* 5% */,
0,
P::RequireMeleeWeapon));
// Fiery Weapon (spellId 13898): 7% chance fire
// damage proc, 1.5s ICD to prevent
// double-procs on dual-wield.
c.entries.push_back(makeRule(
3, "Fiery Weapon Enchant",
13898 /* Enchant: Fiery Weapon */,
13898,
P::OnHit,
700 /* 7% */,
1500 /* 1.5s ICD */,
P::RequireMeleeWeapon));
return c;
}
WoweeSpellProcRules WoweeSpellProcRulesLoader::makeRetPaladin(
const std::string& catalogName) {
using P = WoweeSpellProcRules;
WoweeSpellProcRules c;
c.name = catalogName;
// Vengeance: each crit grants 5-stack Vengeance
// buff (spellId 9452 procs effect 9452 OnCrit).
// 100% chance, no ICD, max 5 stacks.
c.entries.push_back(makeRule(
10, "Vengeance Paladin Crit Stack",
9452 /* Vengeance talent */,
9452 /* stacking buff */,
P::OnCrit,
10000 /* 100% — every crit */,
0,
0,
5 /* max 5 stacks */));
// Seal of Justice: 25% chance to stun on hit
// (spellId 20164 sourceAura procs spell 20170
// stun effect). 60s ICD per target to prevent
// perma-stun.
c.entries.push_back(makeRule(
11, "Seal of Justice Stun",
20164 /* Seal of Justice aura */,
20170 /* Justice stun effect */,
P::OnHit,
2500 /* 25% */,
60000 /* 1min ICD per target */,
P::RequireMeleeWeapon));
// Reckoning: 10% chance on block to gain extra
// attack. Ret talent.
c.entries.push_back(makeRule(
12, "Reckoning Block-to-Attack",
20176 /* Reckoning talent */,
20178 /* extra-attack effect */,
P::OnBlock,
1000 /* 10% */,
0,
0));
// Sanctity Aura: 100% on cast, amplifies holy
// damage by 10%. Aura is permanent so trigger is
// just OnCast bookkeeping.
c.entries.push_back(makeRule(
13, "Sanctity Aura Holy Amp",
20218 /* Sanctity Aura */,
20221 /* Holy-amp passive */,
P::OnCast,
10000 /* 100% — bookkeeping */,
0,
P::RequireSpellSchool));
return c;
}
WoweeSpellProcRules WoweeSpellProcRulesLoader::makeRageGen(
const std::string& catalogName) {
using P = WoweeSpellProcRules;
WoweeSpellProcRules c;
c.name = catalogName;
// Bloodrage: instant 10 Rage on cast, costs
// health. Always procs (100%, no ICD — has
// its own 60s shared cooldown).
c.entries.push_back(makeRule(
20, "Bloodrage Instant Rage",
2687 /* Bloodrage spell */,
14201 /* Rage gain effect */,
P::OnCast,
10000 /* 100% */,
0,
0));
// Berserker Rage: 100% on cast, immunity to
// fear/sap/incapacitate. Uses the OnCast event
// for bookkeeping.
c.entries.push_back(makeRule(
21, "Berserker Rage CC Immune",
18499 /* Berserker Rage spell */,
23691 /* Berserker Rage CC-immunity aura
effect distinct spellId so the
OnCast trigger does NOT recurse
into the source spell */,
P::OnCast,
10000 /* 100% */,
0,
0));
// Anger Management: passive talent. OnDodge
// generates 2 Rage. 100%, no ICD.
c.entries.push_back(makeRule(
22, "Anger Management Dodge Rage",
12296 /* Anger Mgmt talent */,
14201 /* Rage gain effect */,
P::OnDodge,
10000 /* 100% */,
0,
0));
return c;
}
} // namespace pipeline
} // namespace wowee

View file

@ -422,6 +422,8 @@ const char* const kArgRequired[] = {
"--gen-irc-bear", "--gen-irc-eagle", "--gen-irc-tiger",
"--info-wirc", "--validate-wirc",
"--export-wirc-json", "--import-wirc-json",
"--gen-prc-weapon", "--gen-prc-ret", "--gen-prc-rage",
"--info-wprc", "--validate-wprc",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -182,6 +182,7 @@
#include "cli_soulbind_rules_catalog.hpp"
#include "cli_creature_behavior_catalog.hpp"
#include "cli_random_property_catalog.hpp"
#include "cli_spell_proc_rules_catalog.hpp"
#include "cli_catalog_pluck.hpp"
#include "cli_catalog_find.hpp"
#include "cli_catalog_by_name.hpp"
@ -409,6 +410,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleSoulbindRulesCatalog,
handleCreatureBehaviorCatalog,
handleRandomPropertyCatalog,
handleSpellProcRulesCatalog,
handleCatalogPluck,
handleCatalogFind,
handleCatalogByName,

View file

@ -140,6 +140,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','B','N','D'}, ".wbnd", "loot", "--info-wbnd", "Soulbind rules catalog"},
{{'W','B','H','V'}, ".wbhv", "ai", "--info-wbhv", "Creature behavior catalog"},
{{'W','I','R','C'}, ".wirc", "loot", "--info-wirc", "Item random-property pool catalog"},
{{'W','P','R','C'}, ".wprc", "spells", "--info-wprc", "Spell proc rules 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

@ -2685,6 +2685,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wirc to a human-editable JSON sidecar (defaults to <base>.wirc.json; allowedSlotsMask emitted as int + readable string; enchants as JSON object array of {enchantId, weight})\n");
std::printf(" --import-wirc-json <json-path> [out-base]\n");
std::printf(" Import a .wirc.json sidecar back into binary .wirc (allowedSlotsMask uint8 bitmask of Helm=0x01..Belt=0x80; enchants accept JSON object array — round-trips weighted pools byte-identical)\n");
std::printf(" --gen-prc-weapon <wprc-base> [name]\n");
std::printf(" Emit .wprc 3 vanilla weapon-enchant procs (Crusader OnHit 2%% / Lifestealing 5%% / Fiery Weapon 7%% with 1.5s ICD)\n");
std::printf(" --gen-prc-ret <wprc-base> [name]\n");
std::printf(" Emit .wprc 4 Retribution Paladin procs (Vengeance OnCrit 5-stack / Seal of Justice OnHit 25%% with 60s per-target ICD / Reckoning OnBlock 10%% / Sanctity Aura OnCast bookkeeping)\n");
std::printf(" --gen-prc-rage <wprc-base> [name]\n");
std::printf(" Emit .wprc 3 Warrior Rage-generation procs (Bloodrage OnCast / Berserker Rage OnCast immunity / Anger Mgmt OnDodge passive)\n");
std::printf(" --info-wprc <wprc-base> [--json]\n");
std::printf(" Print WPRC entries (id / sourceSpellId / procEffectSpellId / triggerEvent / procChancePct / ICD ms / max stacks / flags / name)\n");
std::printf(" --validate-wprc <wprc-base> [--json]\n");
std::printf(" Static checks: id+name+sourceSpellId+procEffectSpellId required, triggerEvent 0..8, procChancePct in 1..10000 (basis points; 0 = never fires, > 10000 = > 100%%); CRITICAL: sourceSpellId == procEffectSpellId on OnCast trigger errors (infinite proc loop — effect re-casts itself). Warns on 100%% chance + 0ms ICD on high-frequency event (OnHit/OnCrit/OnTakeDamage) — would spam every swing without rate limiting (performance footgun)\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

@ -162,6 +162,7 @@ constexpr FormatRow kFormats[] = {
{"WBND", ".wbnd", "loot", "ItemTemplate.bondingType + LootMgr", "Soulbind rules catalog (BoP/BoE/BoU/BoA + raid-trade window)"},
{"WBHV", ".wbhv", "ai", "creature_template.AIName + ScriptMgr","Creature behavior catalog (combat AI archetypes + special abilities)"},
{"WIRC", ".wirc", "loot", "ItemRandomProperties.dbc + LootMgr", "Item random-property pool catalog (weighted suffix enchants)"},
{"WPRC", ".wprc", "spells", "SpellProcEvents + per-spell procFlags","Spell proc rules catalog (event triggers + ICD + self-loop guard)"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine

View file

@ -0,0 +1,298 @@
#include "cli_spell_proc_rules_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_spell_proc_rules.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 stripWprcExt(std::string base) {
stripExt(base, ".wprc");
return base;
}
const char* triggerEventName(uint8_t e) {
using P = wowee::pipeline::WoweeSpellProcRules;
switch (e) {
case P::OnHit: return "onhit";
case P::OnCrit: return "oncrit";
case P::OnCast: return "oncast";
case P::OnTakeDamage: return "ontakedamage";
case P::OnHeal: return "onheal";
case P::OnDodge: return "ondodge";
case P::OnParry: return "onparry";
case P::OnBlock: return "onblock";
case P::OnKill: return "onkill";
default: return "?";
}
}
bool saveOrError(const wowee::pipeline::WoweeSpellProcRules& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeSpellProcRulesLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wprc\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeSpellProcRules& c,
const std::string& base) {
std::printf("Wrote %s.wprc\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" procs : %zu\n", c.entries.size());
}
int handleGenWeapon(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "WeaponEnchantProcs";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWprcExt(base);
auto c = wowee::pipeline::WoweeSpellProcRulesLoader::
makeWeaponProcs(name);
if (!saveOrError(c, base, "gen-prc-weapon")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenRet(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "RetributionPaladinProcs";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWprcExt(base);
auto c = wowee::pipeline::WoweeSpellProcRulesLoader::
makeRetPaladin(name);
if (!saveOrError(c, base, "gen-prc-ret")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenRage(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "RageGenerationProcs";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWprcExt(base);
auto c = wowee::pipeline::WoweeSpellProcRulesLoader::
makeRageGen(name);
if (!saveOrError(c, base, "gen-prc-rage")) 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 = stripWprcExt(base);
if (!wowee::pipeline::WoweeSpellProcRulesLoader::exists(base)) {
std::fprintf(stderr, "WPRC not found: %s.wprc\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeSpellProcRulesLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wprc"] = base + ".wprc";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"procRuleId", e.procRuleId},
{"name", e.name},
{"sourceSpellId", e.sourceSpellId},
{"procEffectSpellId", e.procEffectSpellId},
{"triggerEvent", e.triggerEvent},
{"triggerEventName",
triggerEventName(e.triggerEvent)},
{"maxStacksOnTarget", e.maxStacksOnTarget},
{"procChancePct", e.procChancePct},
{"internalCooldownMs", e.internalCooldownMs},
{"procFlagsMask", e.procFlagsMask},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WPRC: %s.wprc\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" procs : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id srcSpell effSpell event chance ICDms stacks flags name\n");
for (const auto& e : c.entries) {
std::printf(" %4u %7u %8u %-13s %5u %6u %5u 0x%04X %s\n",
e.procRuleId, e.sourceSpellId,
e.procEffectSpellId,
triggerEventName(e.triggerEvent),
e.procChancePct, e.internalCooldownMs,
e.maxStacksOnTarget,
e.procFlagsMask, 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 = stripWprcExt(base);
if (!wowee::pipeline::WoweeSpellProcRulesLoader::exists(base)) {
std::fprintf(stderr,
"validate-wprc: WPRC not found: %s.wprc\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeSpellProcRulesLoader::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;
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.procRuleId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.procRuleId == 0)
errors.push_back(ctx + ": procRuleId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.sourceSpellId == 0)
errors.push_back(ctx +
": sourceSpellId is 0 — proc has no "
"owning aura");
if (e.procEffectSpellId == 0)
errors.push_back(ctx +
": procEffectSpellId is 0 — proc has "
"nothing to trigger");
if (e.triggerEvent > 8) {
errors.push_back(ctx + ": triggerEvent " +
std::to_string(e.triggerEvent) +
" out of range (0..8)");
}
if (e.procChancePct == 0) {
errors.push_back(ctx +
": procChancePct is 0 — proc never "
"fires");
}
if (e.procChancePct > 10000) {
errors.push_back(ctx +
": procChancePct " +
std::to_string(e.procChancePct) +
" exceeds 10000 (100% in basis points)");
}
// Self-proc on OnCast is the most dangerous
// case — sourceSpellId == procEffectSpellId
// with OnCast trigger could create an infinite
// proc loop where the effect spell triggers
// its own re-cast. Other triggers are usually
// safe (OnHit/OnCrit don't fire on the proc
// spell itself unless that spell hits).
using P = wowee::pipeline::WoweeSpellProcRules;
if (e.sourceSpellId != 0 &&
e.sourceSpellId == e.procEffectSpellId &&
e.triggerEvent == P::OnCast) {
errors.push_back(ctx +
": sourceSpellId == procEffectSpellId="
+ std::to_string(e.sourceSpellId) +
" on OnCast trigger — infinite proc "
"loop (effect re-casts itself)");
}
// 100% proc chance with 0 ICD on OnHit/OnCrit
// = every-melee-swing spam — almost certainly
// unintended performance footgun. Warn unless
// it's an OnCast bookkeeping rule (those are
// intentional).
if (e.procChancePct == 10000 &&
e.internalCooldownMs == 0 &&
(e.triggerEvent == P::OnHit ||
e.triggerEvent == P::OnCrit ||
e.triggerEvent == P::OnTakeDamage)) {
warnings.push_back(ctx +
": 100% proc chance + 0ms ICD on "
"high-frequency event (" +
std::string(triggerEventName(e.triggerEvent)) +
") — would spam every swing; verify "
"intentional or add an ICD");
}
if (!idsSeen.insert(e.procRuleId).second) {
errors.push_back(ctx + ": duplicate procRuleId");
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wprc"] = base + ".wprc";
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-wprc: %s.wprc\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu procs, all procRuleIds "
"unique, sourceSpellId+procEffectSpellId "
"non-zero, triggerEvent 0..8, "
"procChancePct 1..10000, no infinite "
"self-proc loop on OnCast\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 handleSpellProcRulesCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-prc-weapon") == 0 &&
i + 1 < argc) {
outRc = handleGenWeapon(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-prc-ret") == 0 &&
i + 1 < argc) {
outRc = handleGenRet(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-prc-rage") == 0 &&
i + 1 < argc) {
outRc = handleGenRage(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wprc") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wprc") == 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 handleSpellProcRulesCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee