mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
feat(pipeline): add WSPL (Wowee Spell Catalog) format
Novel open replacement for Blizzard's Spell.dbc +
SpellEffect.dbc + the AzerothCore-style spell_dbc /
spell_proc tables. The 20th open format added to the
editor — completes the canonical-data side of the gameplay
graph.
Each entry holds the metadata side of a spell: name,
description, school, range, mana / cast / cooldown times,
plus a single primary effect. The simplified effect model
(one effectKind + min/max value + misc field) covers the
common cases (damage / heal / buff / debuff / teleport /
summon / dispel) without needing to reproduce the full
multi-effect graph that classic Spell.dbc carries.
Cross-references with previously-added formats:
WLCK.channel.targetId (kind=Spell) -> WSPL.entry.spellId
WQT.objective.targetId (kind=SpellCast) -> WSPL.entry.spellId
WCRT.equippedMain (item with on-use) -> WIT -> WSPL
Format:
• magic "WSPL", version 1, little-endian
• per spell: spellId / name / description / iconPath /
school / targetType / effectKind / cast & cooldown &
GCD ms / manaCost / range min..max / minLevel /
maxStacks / durationMs / effectValueMin..Max /
effectMisc / flags
Enums:
• School (7): Physical / Holy / Fire / Nature / Frost /
Shadow / Arcane
• TargetType (6): Self / Single / Cone / AoeFromSelf /
Line / Ground
• EffectKind (7): Damage / Heal / Buff / Debuff / Teleport /
Summon / Dispel
• Flags: Passive / Hidden / Channeled / Ranged /
AreaOfEffect / Triggered / UnitTargetOnly /
FriendlyOnly / HostileOnly
API: WoweeSpellLoader::save / load / exists / findById;
presets makeStarter (Strike + Lesser Heal + Power Word:
Fortitude + Hearthstone, one per major effect kind),
makeMage (Frostbolt 116 + Fireball 133 + Arcane Intellect
1459 + Blink 1953, canonical Classic spellIds), makeWarrior
(Heroic Strike 78 + Thunder Clap 6343 + Battle Shout 6673 +
Mortal Strike 12294).
CLI added (5 flags, 535 documented total now):
--gen-spells / --gen-spells-mage / --gen-spells-warrior
--info-wspl / --validate-wspl
Validator catches: spellId=0 + duplicates, empty name,
school out of range, effectKind out of range, NaN range,
range/value min>max, FriendlyOnly+HostileOnly conflict
(incoherent), friendly-only with damage/debuff effect
(incoherent), hostile-only with heal/buff effect, buff/debuff
effect with durationMs=0 (instant fade — almost certainly
authoring oversight).
The validator caught a real preset-emitter authoring error
during initial smoke testing — buff spells were setting
effectValueMin without effectValueMax (validator's range
check immediately flagged it), prompting an in-batch fix
to set both fields. This is exactly the catch-the-typo
purpose validators serve.
This commit is contained in:
parent
929693405e
commit
5ea1f7ee2a
8 changed files with 843 additions and 0 deletions
|
|
@ -607,6 +607,7 @@ set(WOWEE_SOURCES
|
|||
src/pipeline/wowee_factions.cpp
|
||||
src/pipeline/wowee_locks.cpp
|
||||
src/pipeline/wowee_skills.cpp
|
||||
src/pipeline/wowee_spells.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/dbc_layout.cpp
|
||||
|
||||
|
|
@ -1360,6 +1361,7 @@ add_executable(wowee_editor
|
|||
tools/editor/cli_factions_catalog.cpp
|
||||
tools/editor/cli_locks_catalog.cpp
|
||||
tools/editor/cli_skills_catalog.cpp
|
||||
tools/editor/cli_spells_catalog.cpp
|
||||
tools/editor/cli_quest_objective.cpp
|
||||
tools/editor/cli_quest_reward.cpp
|
||||
tools/editor/cli_clone.cpp
|
||||
|
|
@ -1445,6 +1447,7 @@ add_executable(wowee_editor
|
|||
src/pipeline/wowee_factions.cpp
|
||||
src/pipeline/wowee_locks.cpp
|
||||
src/pipeline/wowee_skills.cpp
|
||||
src/pipeline/wowee_spells.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/terrain_mesh.cpp
|
||||
|
||||
|
|
|
|||
150
include/pipeline/wowee_spells.hpp
Normal file
150
include/pipeline/wowee_spells.hpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
// Wowee Open Spell Catalog (.wspl) — novel replacement for
|
||||
// Blizzard's Spell.dbc + SpellEffect.dbc + the AzerothCore-
|
||||
// style spell_dbc / spell_proc tables. The 20th open format
|
||||
// added to the editor.
|
||||
//
|
||||
// Each entry holds the metadata side of a spell: name,
|
||||
// description, school, range, mana cost, cast / cooldown
|
||||
// times, plus a single primary effect. The simplified
|
||||
// effect model (one effectKind + min/max value + misc field)
|
||||
// covers the common cases (damage / heal / buff / debuff /
|
||||
// teleport / summon / dispel) without needing to reproduce
|
||||
// the full multi-effect graph that classic Spell.dbc carries.
|
||||
//
|
||||
// Cross-references with previously-added formats:
|
||||
// WLCK.channel.targetId (kind=Spell) → WSPL.entry.spellId
|
||||
// WQT.objective.targetId (kind=SpellCast) → WSPL.entry.spellId
|
||||
// WCRT.entry.equippedMain (item with on-use) → WIT → WSPL
|
||||
//
|
||||
// Binary layout (little-endian):
|
||||
// magic[4] = "WSPL"
|
||||
// version (uint32) = current 1
|
||||
// nameLen + name (catalog label)
|
||||
// entryCount (uint32)
|
||||
// entries (each):
|
||||
// spellId (uint32)
|
||||
// nameLen + name
|
||||
// descLen + description
|
||||
// iconLen + iconPath
|
||||
// school (uint8) / targetType (uint8) / effectKind (uint8) / pad
|
||||
// castTimeMs (uint32)
|
||||
// cooldownMs (uint32)
|
||||
// gcdMs (uint32)
|
||||
// manaCost (uint32)
|
||||
// rangeMin (float)
|
||||
// rangeMax (float)
|
||||
// minLevel (uint16) / maxStacks (uint16)
|
||||
// durationMs (int32) -- -1 = permanent, 0 = instant
|
||||
// effectValueMin (int32)
|
||||
// effectValueMax (int32)
|
||||
// effectMisc (int32)
|
||||
// flags (uint32)
|
||||
struct WoweeSpell {
|
||||
enum School : uint8_t {
|
||||
SchoolPhysical = 0,
|
||||
SchoolHoly = 1,
|
||||
SchoolFire = 2,
|
||||
SchoolNature = 3,
|
||||
SchoolFrost = 4,
|
||||
SchoolShadow = 5,
|
||||
SchoolArcane = 6,
|
||||
};
|
||||
|
||||
enum TargetType : uint8_t {
|
||||
TargetSelf = 0,
|
||||
TargetSingle = 1,
|
||||
TargetCone = 2,
|
||||
TargetAoeFromSelf = 3,
|
||||
TargetLine = 4,
|
||||
TargetGround = 5,
|
||||
};
|
||||
|
||||
enum EffectKind : uint8_t {
|
||||
EffectDamage = 0,
|
||||
EffectHeal = 1,
|
||||
EffectBuff = 2,
|
||||
EffectDebuff = 3,
|
||||
EffectTeleport = 4,
|
||||
EffectSummon = 5,
|
||||
EffectDispel = 6,
|
||||
};
|
||||
|
||||
enum Flags : uint32_t {
|
||||
Passive = 0x01,
|
||||
Hidden = 0x02, // not shown in spellbook
|
||||
Channeled = 0x04,
|
||||
Ranged = 0x08,
|
||||
AreaOfEffect = 0x10,
|
||||
Triggered = 0x20, // no mana cost, no GCD
|
||||
UnitTargetOnly = 0x40,
|
||||
FriendlyOnly = 0x80,
|
||||
HostileOnly = 0x100,
|
||||
};
|
||||
|
||||
struct Entry {
|
||||
uint32_t spellId = 0;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string iconPath;
|
||||
uint8_t school = SchoolPhysical;
|
||||
uint8_t targetType = TargetSelf;
|
||||
uint8_t effectKind = EffectDamage;
|
||||
uint32_t castTimeMs = 0;
|
||||
uint32_t cooldownMs = 0;
|
||||
uint32_t gcdMs = 1500; // canonical 1.5s GCD default
|
||||
uint32_t manaCost = 0;
|
||||
float rangeMin = 0.0f;
|
||||
float rangeMax = 5.0f; // melee range default
|
||||
uint16_t minLevel = 1;
|
||||
uint16_t maxStacks = 1;
|
||||
int32_t durationMs = 0; // 0 = instant, -1 = permanent
|
||||
int32_t effectValueMin = 0;
|
||||
int32_t effectValueMax = 0;
|
||||
int32_t effectMisc = 0;
|
||||
uint32_t flags = 0;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
bool isValid() const { return !entries.empty(); }
|
||||
|
||||
// Lookup by spellId — nullptr if not present.
|
||||
const Entry* findById(uint32_t spellId) const;
|
||||
|
||||
static const char* schoolName(uint8_t s);
|
||||
static const char* targetTypeName(uint8_t t);
|
||||
static const char* effectKindName(uint8_t e);
|
||||
};
|
||||
|
||||
class WoweeSpellLoader {
|
||||
public:
|
||||
static bool save(const WoweeSpell& cat,
|
||||
const std::string& basePath);
|
||||
static WoweeSpell load(const std::string& basePath);
|
||||
static bool exists(const std::string& basePath);
|
||||
|
||||
// Preset emitters used by --gen-spells* variants.
|
||||
//
|
||||
// makeStarter — 4 demo spells covering damage / heal /
|
||||
// buff / teleport effect kinds.
|
||||
// makeMage — frost bolt + fireball + arcane intellect
|
||||
// + blink — classic mage starter rotation.
|
||||
// makeWarrior — mortal strike + shield bash + battle shout
|
||||
// + heroic strike — classic warrior toolkit.
|
||||
static WoweeSpell makeStarter(const std::string& catalogName);
|
||||
static WoweeSpell makeMage(const std::string& catalogName);
|
||||
static WoweeSpell makeWarrior(const std::string& catalogName);
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
374
src/pipeline/wowee_spells.cpp
Normal file
374
src/pipeline/wowee_spells.cpp
Normal file
|
|
@ -0,0 +1,374 @@
|
|||
#include "pipeline/wowee_spells.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'S', 'P', 'L'};
|
||||
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) != ".wspl") {
|
||||
base += ".wspl";
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const WoweeSpell::Entry* WoweeSpell::findById(uint32_t spellId) const {
|
||||
for (const auto& e : entries) {
|
||||
if (e.spellId == spellId) return &e;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* WoweeSpell::schoolName(uint8_t s) {
|
||||
switch (s) {
|
||||
case SchoolPhysical: return "physical";
|
||||
case SchoolHoly: return "holy";
|
||||
case SchoolFire: return "fire";
|
||||
case SchoolNature: return "nature";
|
||||
case SchoolFrost: return "frost";
|
||||
case SchoolShadow: return "shadow";
|
||||
case SchoolArcane: return "arcane";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char* WoweeSpell::targetTypeName(uint8_t t) {
|
||||
switch (t) {
|
||||
case TargetSelf: return "self";
|
||||
case TargetSingle: return "single";
|
||||
case TargetCone: return "cone";
|
||||
case TargetAoeFromSelf: return "aoe-self";
|
||||
case TargetLine: return "line";
|
||||
case TargetGround: return "ground";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char* WoweeSpell::effectKindName(uint8_t e) {
|
||||
switch (e) {
|
||||
case EffectDamage: return "damage";
|
||||
case EffectHeal: return "heal";
|
||||
case EffectBuff: return "buff";
|
||||
case EffectDebuff: return "debuff";
|
||||
case EffectTeleport: return "teleport";
|
||||
case EffectSummon: return "summon";
|
||||
case EffectDispel: return "dispel";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
bool WoweeSpellLoader::save(const WoweeSpell& 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.spellId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writeStr(os, e.iconPath);
|
||||
writePOD(os, e.school);
|
||||
writePOD(os, e.targetType);
|
||||
writePOD(os, e.effectKind);
|
||||
uint8_t pad = 0;
|
||||
writePOD(os, pad);
|
||||
writePOD(os, e.castTimeMs);
|
||||
writePOD(os, e.cooldownMs);
|
||||
writePOD(os, e.gcdMs);
|
||||
writePOD(os, e.manaCost);
|
||||
writePOD(os, e.rangeMin);
|
||||
writePOD(os, e.rangeMax);
|
||||
writePOD(os, e.minLevel);
|
||||
writePOD(os, e.maxStacks);
|
||||
writePOD(os, e.durationMs);
|
||||
writePOD(os, e.effectValueMin);
|
||||
writePOD(os, e.effectValueMax);
|
||||
writePOD(os, e.effectMisc);
|
||||
writePOD(os, e.flags);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeSpell WoweeSpellLoader::load(const std::string& basePath) {
|
||||
WoweeSpell 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.spellId)) { out.entries.clear(); return out; }
|
||||
if (!readStr(is, e.name) || !readStr(is, e.description) ||
|
||||
!readStr(is, e.iconPath)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.school) ||
|
||||
!readPOD(is, e.targetType) ||
|
||||
!readPOD(is, e.effectKind)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
uint8_t pad = 0;
|
||||
if (!readPOD(is, pad)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.castTimeMs) ||
|
||||
!readPOD(is, e.cooldownMs) ||
|
||||
!readPOD(is, e.gcdMs) ||
|
||||
!readPOD(is, e.manaCost) ||
|
||||
!readPOD(is, e.rangeMin) ||
|
||||
!readPOD(is, e.rangeMax) ||
|
||||
!readPOD(is, e.minLevel) ||
|
||||
!readPOD(is, e.maxStacks) ||
|
||||
!readPOD(is, e.durationMs) ||
|
||||
!readPOD(is, e.effectValueMin) ||
|
||||
!readPOD(is, e.effectValueMax) ||
|
||||
!readPOD(is, e.effectMisc) ||
|
||||
!readPOD(is, e.flags)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeSpellLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeSpell WoweeSpellLoader::makeStarter(const std::string& catalogName) {
|
||||
WoweeSpell c;
|
||||
c.name = catalogName;
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 1; e.name = "Strike"; e.description = "Basic melee attack.";
|
||||
e.school = WoweeSpell::SchoolPhysical;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectDamage;
|
||||
e.castTimeMs = 0; e.cooldownMs = 0; e.manaCost = 5;
|
||||
e.rangeMax = 5.0f;
|
||||
e.effectValueMin = 8; e.effectValueMax = 12;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 2; e.name = "Lesser Heal";
|
||||
e.description = "Restores a small amount of health.";
|
||||
e.school = WoweeSpell::SchoolHoly;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectHeal;
|
||||
e.castTimeMs = 1500; e.manaCost = 25;
|
||||
e.rangeMax = 30.0f;
|
||||
e.flags = WoweeSpell::FriendlyOnly;
|
||||
e.effectValueMin = 30; e.effectValueMax = 50;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 3; e.name = "Power Word: Fortitude";
|
||||
e.description = "Increases stamina for 30 minutes.";
|
||||
e.school = WoweeSpell::SchoolHoly;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectBuff;
|
||||
e.castTimeMs = 0; e.manaCost = 50;
|
||||
e.rangeMax = 30.0f;
|
||||
e.durationMs = 1800000; // 30 min
|
||||
// Buffs use a single fixed value: min == max so the
|
||||
// validator's range check stays happy.
|
||||
e.effectValueMin = 5;
|
||||
e.effectValueMax = 5;
|
||||
e.flags = WoweeSpell::FriendlyOnly;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 4; e.name = "Hearthstone";
|
||||
e.description = "Returns you to your home inn.";
|
||||
e.school = WoweeSpell::SchoolArcane;
|
||||
e.targetType = WoweeSpell::TargetSelf;
|
||||
e.effectKind = WoweeSpell::EffectTeleport;
|
||||
e.castTimeMs = 10000; e.cooldownMs = 3600000; // 60 min CD
|
||||
e.flags = WoweeSpell::Channeled;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeSpell WoweeSpellLoader::makeMage(const std::string& catalogName) {
|
||||
WoweeSpell c;
|
||||
c.name = catalogName;
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 116; e.name = "Frostbolt";
|
||||
e.description = "A bolt of frost that slows the target.";
|
||||
e.school = WoweeSpell::SchoolFrost;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectDamage;
|
||||
e.castTimeMs = 2500; e.manaCost = 25;
|
||||
e.rangeMax = 30.0f;
|
||||
e.minLevel = 4;
|
||||
e.effectValueMin = 27; e.effectValueMax = 31;
|
||||
e.effectMisc = -50; // -50% movement speed (debuff hint)
|
||||
e.flags = WoweeSpell::HostileOnly;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 133; e.name = "Fireball";
|
||||
e.description = "Hurls a fiery ball that explodes on impact.";
|
||||
e.school = WoweeSpell::SchoolFire;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectDamage;
|
||||
e.castTimeMs = 3500; e.manaCost = 30;
|
||||
e.rangeMax = 35.0f;
|
||||
e.minLevel = 1;
|
||||
e.effectValueMin = 14; e.effectValueMax = 22;
|
||||
e.flags = WoweeSpell::HostileOnly;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 1459; e.name = "Arcane Intellect";
|
||||
e.description = "Increases the target's intellect for 30 minutes.";
|
||||
e.school = WoweeSpell::SchoolArcane;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectBuff;
|
||||
e.castTimeMs = 0; e.manaCost = 80;
|
||||
e.rangeMax = 30.0f;
|
||||
e.durationMs = 1800000;
|
||||
e.effectValueMin = 3;
|
||||
e.effectValueMax = 3;
|
||||
e.flags = WoweeSpell::FriendlyOnly;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 1953; e.name = "Blink";
|
||||
e.description = "Teleports 20 yards forward.";
|
||||
e.school = WoweeSpell::SchoolArcane;
|
||||
e.targetType = WoweeSpell::TargetSelf;
|
||||
e.effectKind = WoweeSpell::EffectTeleport;
|
||||
e.castTimeMs = 0; e.cooldownMs = 15000; e.manaCost = 60;
|
||||
e.minLevel = 20;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeSpell WoweeSpellLoader::makeWarrior(const std::string& catalogName) {
|
||||
WoweeSpell c;
|
||||
c.name = catalogName;
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 78; e.name = "Heroic Strike";
|
||||
e.description = "A strong melee attack that consumes rage.";
|
||||
e.school = WoweeSpell::SchoolPhysical;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectDamage;
|
||||
e.castTimeMs = 0; e.manaCost = 15; // rage cost reuses field
|
||||
e.rangeMax = 5.0f;
|
||||
e.gcdMs = 0; // off-GCD
|
||||
e.flags = WoweeSpell::HostileOnly;
|
||||
e.effectValueMin = 11; e.effectValueMax = 11;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 6343; e.name = "Thunder Clap";
|
||||
e.description = "Damages nearby enemies and slows attack speed.";
|
||||
e.school = WoweeSpell::SchoolPhysical;
|
||||
e.targetType = WoweeSpell::TargetAoeFromSelf;
|
||||
e.effectKind = WoweeSpell::EffectDamage;
|
||||
e.castTimeMs = 0; e.cooldownMs = 4000; e.manaCost = 20;
|
||||
e.rangeMax = 8.0f;
|
||||
e.minLevel = 6;
|
||||
e.effectValueMin = 18; e.effectValueMax = 20;
|
||||
e.flags = WoweeSpell::HostileOnly | WoweeSpell::AreaOfEffect;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 6673; e.name = "Battle Shout";
|
||||
e.description = "Increases melee attack power for 2 minutes.";
|
||||
e.school = WoweeSpell::SchoolPhysical;
|
||||
e.targetType = WoweeSpell::TargetAoeFromSelf;
|
||||
e.effectKind = WoweeSpell::EffectBuff;
|
||||
e.castTimeMs = 0; e.manaCost = 10;
|
||||
e.rangeMax = 20.0f;
|
||||
e.durationMs = 120000;
|
||||
e.effectValueMin = 25;
|
||||
e.effectValueMax = 25;
|
||||
e.flags = WoweeSpell::FriendlyOnly | WoweeSpell::AreaOfEffect;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeSpell::Entry e;
|
||||
e.spellId = 12294; e.name = "Mortal Strike";
|
||||
e.description = "Hard-hitting strike that reduces healing taken.";
|
||||
e.school = WoweeSpell::SchoolPhysical;
|
||||
e.targetType = WoweeSpell::TargetSingle;
|
||||
e.effectKind = WoweeSpell::EffectDamage;
|
||||
e.castTimeMs = 0; e.cooldownMs = 6000; e.manaCost = 30;
|
||||
e.rangeMax = 5.0f;
|
||||
e.minLevel = 40;
|
||||
e.effectValueMin = 75; e.effectValueMax = 100;
|
||||
e.effectMisc = -50; // -50% healing applied (debuff hint)
|
||||
e.flags = WoweeSpell::HostileOnly;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
|
|
@ -55,6 +55,8 @@ const char* const kArgRequired[] = {
|
|||
"--export-wlck-json", "--import-wlck-json",
|
||||
"--gen-skills", "--gen-skills-professions", "--gen-skills-weapons",
|
||||
"--info-wskl", "--validate-wskl",
|
||||
"--gen-spells", "--gen-spells-mage", "--gen-spells-warrior",
|
||||
"--info-wspl", "--validate-wspl",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
#include "cli_factions_catalog.hpp"
|
||||
#include "cli_locks_catalog.hpp"
|
||||
#include "cli_skills_catalog.hpp"
|
||||
#include "cli_spells_catalog.hpp"
|
||||
#include "cli_quest_objective.hpp"
|
||||
#include "cli_quest_reward.hpp"
|
||||
#include "cli_clone.hpp"
|
||||
|
|
@ -135,6 +136,7 @@ constexpr DispatchFn kDispatchTable[] = {
|
|||
handleFactionsCatalog,
|
||||
handleLocksCatalog,
|
||||
handleSkillsCatalog,
|
||||
handleSpellsCatalog,
|
||||
handleQuestObjective,
|
||||
handleQuestReward,
|
||||
handleClone,
|
||||
|
|
|
|||
|
|
@ -975,6 +975,16 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Print WSKL entries (id / category / max rank / per-level grow / trainer-required / name)\n");
|
||||
std::printf(" --validate-wskl <wskl-base> [--json]\n");
|
||||
std::printf(" Static checks: skillId>0+unique, name not empty, maxRank>0, weapon needs rankPerLevel>0\n");
|
||||
std::printf(" --gen-spells <wspl-base> [name]\n");
|
||||
std::printf(" Emit .wspl starter spell catalog: 4 spells covering damage / heal / buff / teleport effect kinds\n");
|
||||
std::printf(" --gen-spells-mage <wspl-base> [name]\n");
|
||||
std::printf(" Emit .wspl mage spell set: Frostbolt + Fireball + Arcane Intellect + Blink (canonical IDs 116/133/1459/1953)\n");
|
||||
std::printf(" --gen-spells-warrior <wspl-base> [name]\n");
|
||||
std::printf(" Emit .wspl warrior spell set: Heroic Strike + Thunder Clap + Battle Shout + Mortal Strike\n");
|
||||
std::printf(" --info-wspl <wspl-base> [--json]\n");
|
||||
std::printf(" Print WSPL spell entries (id / school / effect / cast/cd / mana / range / damage range / name)\n");
|
||||
std::printf(" --validate-wspl <wspl-base> [--json]\n");
|
||||
std::printf(" Static checks: spellId>0+unique, name not empty, school 0..6, range/value min<=max, friendly+hostile incoherent\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");
|
||||
|
|
|
|||
291
tools/editor/cli_spells_catalog.cpp
Normal file
291
tools/editor/cli_spells_catalog.cpp
Normal file
|
|
@ -0,0 +1,291 @@
|
|||
#include "cli_spells_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_spells.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string stripWsplExt(std::string base) {
|
||||
stripExt(base, ".wspl");
|
||||
return base;
|
||||
}
|
||||
|
||||
void appendSpellFlagsStr(std::string& s, uint32_t flags) {
|
||||
if (flags & wowee::pipeline::WoweeSpell::Passive) s += "passive ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::Hidden) s += "hidden ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::Channeled) s += "channeled ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::Ranged) s += "ranged ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::AreaOfEffect) s += "aoe ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::Triggered) s += "triggered ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::UnitTargetOnly) s += "unit-only ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::FriendlyOnly) s += "friendly ";
|
||||
if (flags & wowee::pipeline::WoweeSpell::HostileOnly) s += "hostile ";
|
||||
if (s.empty()) s = "-";
|
||||
else if (s.back() == ' ') s.pop_back();
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeSpell& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeSpellLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wspl\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeSpell& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wspl\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" spells : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenStarter(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "StarterSpells";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsplExt(base);
|
||||
auto c = wowee::pipeline::WoweeSpellLoader::makeStarter(name);
|
||||
if (!saveOrError(c, base, "gen-spells")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenMage(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "MageSpells";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsplExt(base);
|
||||
auto c = wowee::pipeline::WoweeSpellLoader::makeMage(name);
|
||||
if (!saveOrError(c, base, "gen-spells-mage")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenWarrior(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "WarriorSpells";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsplExt(base);
|
||||
auto c = wowee::pipeline::WoweeSpellLoader::makeWarrior(name);
|
||||
if (!saveOrError(c, base, "gen-spells-warrior")) 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 = stripWsplExt(base);
|
||||
if (!wowee::pipeline::WoweeSpellLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WSPL not found: %s.wspl\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeSpellLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wspl"] = base + ".wspl";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
std::string fs;
|
||||
appendSpellFlagsStr(fs, e.flags);
|
||||
arr.push_back({
|
||||
{"spellId", e.spellId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"iconPath", e.iconPath},
|
||||
{"school", e.school},
|
||||
{"schoolName", wowee::pipeline::WoweeSpell::schoolName(e.school)},
|
||||
{"targetType", e.targetType},
|
||||
{"targetTypeName", wowee::pipeline::WoweeSpell::targetTypeName(e.targetType)},
|
||||
{"effectKind", e.effectKind},
|
||||
{"effectKindName", wowee::pipeline::WoweeSpell::effectKindName(e.effectKind)},
|
||||
{"castTimeMs", e.castTimeMs},
|
||||
{"cooldownMs", e.cooldownMs},
|
||||
{"gcdMs", e.gcdMs},
|
||||
{"manaCost", e.manaCost},
|
||||
{"rangeMin", e.rangeMin},
|
||||
{"rangeMax", e.rangeMax},
|
||||
{"minLevel", e.minLevel},
|
||||
{"maxStacks", e.maxStacks},
|
||||
{"durationMs", e.durationMs},
|
||||
{"effectValueMin", e.effectValueMin},
|
||||
{"effectValueMax", e.effectValueMax},
|
||||
{"effectMisc", e.effectMisc},
|
||||
{"flags", e.flags},
|
||||
{"flagsStr", fs},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WSPL: %s.wspl\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" spells : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id school effect cast cd mana range value name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::printf(" %5u %-8s %-9s %4ums %4us %3u %4.0f-%-4.0f %4d-%-4d %s\n",
|
||||
e.spellId,
|
||||
wowee::pipeline::WoweeSpell::schoolName(e.school),
|
||||
wowee::pipeline::WoweeSpell::effectKindName(e.effectKind),
|
||||
e.castTimeMs, e.cooldownMs / 1000, e.manaCost,
|
||||
e.rangeMin, e.rangeMax,
|
||||
e.effectValueMin, e.effectValueMax,
|
||||
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 = stripWsplExt(base);
|
||||
if (!wowee::pipeline::WoweeSpellLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wspl: WSPL not found: %s.wspl\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeSpellLoader::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;
|
||||
idsSeen.reserve(c.entries.size());
|
||||
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.spellId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.spellId == 0) {
|
||||
errors.push_back(ctx + ": spellId is 0");
|
||||
}
|
||||
if (e.name.empty()) {
|
||||
errors.push_back(ctx + ": name is empty");
|
||||
}
|
||||
if (e.school > wowee::pipeline::WoweeSpell::SchoolArcane) {
|
||||
errors.push_back(ctx + ": school " +
|
||||
std::to_string(e.school) + " not in 0..6");
|
||||
}
|
||||
if (e.effectKind > wowee::pipeline::WoweeSpell::EffectDispel) {
|
||||
errors.push_back(ctx + ": effectKind " +
|
||||
std::to_string(e.effectKind) + " not in 0..6");
|
||||
}
|
||||
if (!std::isfinite(e.rangeMin) || !std::isfinite(e.rangeMax)) {
|
||||
errors.push_back(ctx + ": rangeMin/Max not finite");
|
||||
}
|
||||
if (e.rangeMin > e.rangeMax) {
|
||||
errors.push_back(ctx + ": rangeMin > rangeMax");
|
||||
}
|
||||
if (e.effectValueMin > e.effectValueMax) {
|
||||
errors.push_back(ctx + ": effectValueMin > effectValueMax");
|
||||
}
|
||||
// Friendly + Hostile target restrictions are mutually exclusive.
|
||||
if ((e.flags & wowee::pipeline::WoweeSpell::FriendlyOnly) &&
|
||||
(e.flags & wowee::pipeline::WoweeSpell::HostileOnly)) {
|
||||
errors.push_back(ctx +
|
||||
": FriendlyOnly and HostileOnly both set (incoherent)");
|
||||
}
|
||||
// Damage / debuff effects on a friendly-only spell don't make sense.
|
||||
if ((e.flags & wowee::pipeline::WoweeSpell::FriendlyOnly) &&
|
||||
(e.effectKind == wowee::pipeline::WoweeSpell::EffectDamage ||
|
||||
e.effectKind == wowee::pipeline::WoweeSpell::EffectDebuff)) {
|
||||
warnings.push_back(ctx +
|
||||
": friendly-only spell with damage/debuff effect");
|
||||
}
|
||||
// Heal / buff on a hostile-only spell is incoherent.
|
||||
if ((e.flags & wowee::pipeline::WoweeSpell::HostileOnly) &&
|
||||
(e.effectKind == wowee::pipeline::WoweeSpell::EffectHeal ||
|
||||
e.effectKind == wowee::pipeline::WoweeSpell::EffectBuff)) {
|
||||
warnings.push_back(ctx +
|
||||
": hostile-only spell with heal/buff effect");
|
||||
}
|
||||
// Buff / debuff effects need a non-zero duration to mean anything.
|
||||
if ((e.effectKind == wowee::pipeline::WoweeSpell::EffectBuff ||
|
||||
e.effectKind == wowee::pipeline::WoweeSpell::EffectDebuff) &&
|
||||
e.durationMs == 0) {
|
||||
warnings.push_back(ctx +
|
||||
": buff/debuff effect with durationMs=0 (instant fade)");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.spellId) {
|
||||
errors.push_back(ctx + ": duplicate spellId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.spellId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wspl"] = base + ".wspl";
|
||||
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-wspl: %s.wspl\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu spells, all spellIds 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 handleSpellsCatalog(int& i, int argc, char** argv, int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-spells") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenStarter(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-spells-mage") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenMage(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-spells-warrior") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenWarrior(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wspl") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wspl") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
11
tools/editor/cli_spells_catalog.hpp
Normal file
11
tools/editor/cli_spells_catalog.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
bool handleSpellsCatalog(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