mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 03:23:51 +00:00
feat(pipeline): add WUMV (Wowee Unit Movement Type) catalog
66th open format — replaces UnitMovement.dbc plus the movement-modifier portions of CreatureModelData.dbc. Defines movement speed types (walk / run / swim / flight / fly / pitch) with their canonical baseline speeds in yards-per- second, plus the temp speed buffs that stack on top (Sprint, Aspect of the Cheetah, Travel Form). 12 movement categories cover the canonical surface (Walk / Run / Backward / Swim / SwimBack / Turn / Flight / FlightBack / Pitch / Fly / FlyBack / TempBuff). baseSpeed is yards/second for baseline categories and ignored for TempBuff entries (which use baseMultiplier instead). maxMultiplier caps stacking — Sprint capped at 1.4 means Sprint + Aspect of Cheetah doesn't exceed 1.4× run speed. stackingPriority resolves conflicts when multiple buffs of equal multiplier compete (higher wins). CLI: --gen-umv (4 baseline at canonical WoW vanilla speeds: Walk 2.5y/s, Run 7.0y/s, Swim 4.7y/s, Turn π rad/s), --gen-umv-flight (5 flight entries — ground-rail Flight 7y/s, free Fly 14y/s, Pitch 1.5 rad/s, backward variants at slower 4.5y/s), --gen-umv-buffs (5 temp speed buffs matching real WoW spell auras with proper durations and stacking priorities), --info-wumv, --validate-wumv with --json variants. Validator catches id+name required, category 0..11, baseMultiplier > 0 (otherwise unit freezes in place), maxMultiplier >= baseMultiplier (cap below floor would clamp the base down), baseline categories need baseSpeed > 0, and Run < 3.0y/s warning (canonical is 7.0y/s). Format graph: 65 → 66 binary formats. CLI flag count: 870 → 875.
This commit is contained in:
parent
626d9e09fa
commit
1ca665150b
10 changed files with 659 additions and 0 deletions
254
tools/editor/cli_unit_movement_catalog.cpp
Normal file
254
tools/editor/cli_unit_movement_catalog.cpp
Normal file
|
|
@ -0,0 +1,254 @@
|
|||
#include "cli_unit_movement_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_unit_movement.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string stripWumvExt(std::string base) {
|
||||
stripExt(base, ".wumv");
|
||||
return base;
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeUnitMovement& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeUnitMovementLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wumv\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeUnitMovement& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wumv\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" types : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenStarter(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "StarterMovementTypes";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWumvExt(base);
|
||||
auto c = wowee::pipeline::WoweeUnitMovementLoader::makeStarter(name);
|
||||
if (!saveOrError(c, base, "gen-umv")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenFlight(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "FlightMovementTypes";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWumvExt(base);
|
||||
auto c = wowee::pipeline::WoweeUnitMovementLoader::makeFlight(name);
|
||||
if (!saveOrError(c, base, "gen-umv-flight")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenBuffs(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "MovementBuffs";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWumvExt(base);
|
||||
auto c = wowee::pipeline::WoweeUnitMovementLoader::makeBuffs(name);
|
||||
if (!saveOrError(c, base, "gen-umv-buffs")) 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 = stripWumvExt(base);
|
||||
if (!wowee::pipeline::WoweeUnitMovementLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WUMV not found: %s.wumv\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeUnitMovementLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wumv"] = base + ".wumv";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
arr.push_back({
|
||||
{"moveTypeId", e.moveTypeId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"iconPath", e.iconPath},
|
||||
{"movementCategory", e.movementCategory},
|
||||
{"movementCategoryName", wowee::pipeline::WoweeUnitMovement::movementCategoryName(e.movementCategory)},
|
||||
{"requiresFlight", e.requiresFlight},
|
||||
{"canStackBuffs", e.canStackBuffs},
|
||||
{"baseSpeed", e.baseSpeed},
|
||||
{"baseMultiplier", e.baseMultiplier},
|
||||
{"maxMultiplier", e.maxMultiplier},
|
||||
{"defaultDurationMs", e.defaultDurationMs},
|
||||
{"stackingPriority", e.stackingPriority},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WUMV: %s.wumv\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" types : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id category baseSpeed baseMul maxMul dur(ms) prio flight stack name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::printf(" %4u %-11s %7.2f %5.2f %5.2f %5u %3u %u %u %s\n",
|
||||
e.moveTypeId,
|
||||
wowee::pipeline::WoweeUnitMovement::movementCategoryName(e.movementCategory),
|
||||
e.baseSpeed, e.baseMultiplier, e.maxMultiplier,
|
||||
e.defaultDurationMs, e.stackingPriority,
|
||||
e.requiresFlight, e.canStackBuffs,
|
||||
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 = stripWumvExt(base);
|
||||
if (!wowee::pipeline::WoweeUnitMovementLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wumv: WUMV not found: %s.wumv\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeUnitMovementLoader::load(base);
|
||||
std::vector<std::string> errors;
|
||||
std::vector<std::string> warnings;
|
||||
if (c.entries.empty()) {
|
||||
warnings.push_back("catalog has zero entries");
|
||||
}
|
||||
std::vector<uint32_t> idsSeen;
|
||||
for (size_t k = 0; k < c.entries.size(); ++k) {
|
||||
const auto& e = c.entries[k];
|
||||
std::string ctx = "entry " + std::to_string(k) +
|
||||
" (id=" + std::to_string(e.moveTypeId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.moveTypeId == 0)
|
||||
errors.push_back(ctx + ": moveTypeId is 0");
|
||||
if (e.name.empty())
|
||||
errors.push_back(ctx + ": name is empty");
|
||||
if (e.movementCategory > wowee::pipeline::WoweeUnitMovement::TempBuff) {
|
||||
errors.push_back(ctx + ": movementCategory " +
|
||||
std::to_string(e.movementCategory) + " not in 0..11");
|
||||
}
|
||||
if (e.baseMultiplier <= 0.0f) {
|
||||
errors.push_back(ctx +
|
||||
": baseMultiplier " +
|
||||
std::to_string(e.baseMultiplier) +
|
||||
" <= 0 (would freeze unit in place)");
|
||||
}
|
||||
if (e.maxMultiplier < e.baseMultiplier) {
|
||||
errors.push_back(ctx + ": maxMultiplier " +
|
||||
std::to_string(e.maxMultiplier) +
|
||||
" < baseMultiplier " +
|
||||
std::to_string(e.baseMultiplier) +
|
||||
" (cap below floor — base would be clamped down)");
|
||||
}
|
||||
// Baseline movement (Walk/Run/Swim/Turn) should have
|
||||
// a positive baseSpeed — TempBuff entries are
|
||||
// multiplier-only and may have baseSpeed=0.
|
||||
bool isBaseline =
|
||||
e.movementCategory >= wowee::pipeline::WoweeUnitMovement::Walk &&
|
||||
e.movementCategory <= wowee::pipeline::WoweeUnitMovement::FlyBack;
|
||||
if (isBaseline && e.baseSpeed <= 0.0f) {
|
||||
errors.push_back(ctx +
|
||||
": baseline movement category with baseSpeed " +
|
||||
std::to_string(e.baseSpeed) + " <= 0 — unit "
|
||||
"won't move on this category");
|
||||
}
|
||||
// Run speed below walk speed is suspicious — flag.
|
||||
// Run is ~7.0y/s, walk is ~2.5y/s in canonical WoW.
|
||||
if (e.movementCategory == wowee::pipeline::WoweeUnitMovement::Run &&
|
||||
e.baseSpeed < 3.0f) {
|
||||
warnings.push_back(ctx +
|
||||
": Run baseSpeed " +
|
||||
std::to_string(e.baseSpeed) +
|
||||
" unusually slow (canonical 7.0y/s) — verify intent");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.moveTypeId) {
|
||||
errors.push_back(ctx + ": duplicate moveTypeId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.moveTypeId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wumv"] = base + ".wumv";
|
||||
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-wumv: %s.wumv\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu movement types, all moveTypeIds unique, all multipliers consistent\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 handleUnitMovementCatalog(int& i, int argc, char** argv,
|
||||
int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-umv") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenStarter(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-umv-flight") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenFlight(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-umv-buffs") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenBuffs(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wumv") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wumv") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue