feat: resolve spell \$s1/\$s2/\$s3 to real DBC damage/heal values

Spell descriptions now substitute \$s1/\$s2/\$s3 template variables
with actual effect base points from Spell.dbc (field 80/81/82).
For example: "causes \$s1 Fire Damage" → "causes 562 Fire Damage".

Implementation:
- Added EffectBasePoints0/1/2 to all 4 expansion DBC layouts
- SpellNameEntry now stores effectBasePoints[3]
- loadSpellNameCache reads base points during DBC iteration
- cleanSpellDescription substitutes \$s1→abs(base)+1 when available
- getSpellEffectBasePoints() accessor on GameHandler

Values are DBC base points (before spell power scaling). Still uses
"X" placeholder for unresolved variables (\$d, \$o1, etc.).
This commit is contained in:
Kelsi 2026-03-23 00:51:19 -07:00
parent f9464dbacd
commit a5aa1faf7a
7 changed files with 852 additions and 804 deletions

View file

@ -1627,19 +1627,34 @@ static int lua_GetSpellBookItemName(lua_State* L) {
// GetSpellDescription(spellId) → description string
// Clean spell description template variables for display
static std::string cleanSpellDescription(const std::string& raw) {
static std::string cleanSpellDescription(const std::string& raw, const int32_t effectBase[3] = nullptr) {
if (raw.empty() || raw.find('$') == std::string::npos) return raw;
std::string result;
result.reserve(raw.size());
for (size_t i = 0; i < raw.size(); ++i) {
if (raw[i] == '$' && i + 1 < raw.size()) {
char next = raw[i + 1];
if (next == 's' || next == 'S' || next == 'o' || next == 'O' ||
if (next == 's' || next == 'S') {
// $s1, $s2, $s3 — substitute with effect base points + 1
i += 1; // skip 's'
int idx = 0;
if (i + 1 < raw.size() && raw[i + 1] >= '1' && raw[i + 1] <= '3') {
idx = raw[i + 1] - '1';
++i;
}
if (effectBase && effectBase[idx] != 0) {
int32_t val = std::abs(effectBase[idx]) + 1;
result += std::to_string(val);
} else {
result += 'X';
}
while (i + 1 < raw.size() && raw[i + 1] >= '0' && raw[i + 1] <= '9') ++i;
} else if (next == 'o' || next == 'O' ||
next == 'e' || next == 'E' || next == 't' || next == 'T' ||
next == 'h' || next == 'H' || next == 'u' || next == 'U') {
// $s1, $o1, $e1 etc. — skip the variable, insert "X"
// Other variables — insert "X" placeholder
result += 'X';
i += 1; // skip letter
i += 1;
while (i + 1 < raw.size() && raw[i + 1] >= '0' && raw[i + 1] <= '9') ++i;
} else if (next == 'd' || next == 'D') {
// $d = duration — replace with "X sec"
@ -1682,7 +1697,8 @@ static int lua_GetSpellDescription(lua_State* L) {
if (!gh) { lua_pushstring(L, ""); return 1; }
uint32_t spellId = static_cast<uint32_t>(luaL_checknumber(L, 1));
const std::string& desc = gh->getSpellDescription(spellId);
std::string cleaned = cleanSpellDescription(desc);
const int32_t* ebp = gh->getSpellEffectBasePoints(spellId);
std::string cleaned = cleanSpellDescription(desc, ebp);
lua_pushstring(L, cleaned.c_str());
return 1;
}