Files
ClassicAPI/src/spell/Mod.h
T
Brues 3df21247a2 Add Spell::Mod (talent/item SpellMod) + GetSpellRadius modified return
GetSpellRadius now returns (baseRadius, modifiedRadius). modifiedRadius
applies the local player's talent/item radius modifiers; equal to base
when no modifier matches.

The modifier logic is extracted into a reusable Spell::Mod helper
(src/spell/Mod.{h,cpp}) since the same engine SpellMod mechanism drives
cast time, mana cost, duration, range, cooldown, etc. — only the op
differs. Spell::Mod::Apply(spellRecord, op, base) replicates
FUN_006e6b30/FUN_006e6bf0: gate on the spell's SpellFamilyName matching
the player's class family (ChrClasses.dbc[class]+0x3c), sum the player's
flat/percent tables (0x00CEAD60 / 0x00CECB30, stride 0x74) over the
spell's 64-bit SpellFamilyFlags, then (base + flat) * (100 + pct) * 0.01.
Inherently local-player-only — the client tracks spell mods for the
player alone.

Offsets: VAR_SPELLMOD_FLAT/PCT_TABLE, SPELLMOD_SLOT_STRIDE/COUNT,
SPELLMOD_OP_RADIUS, OFF_SPELL_RECORD_FAMILY_NAME/FLAGS/ATTRIBUTES_EX2,
SPELL_ATTR_EX2_NO_SPELL_MODS, OFF_CHRCLASSES_SPELL_FAMILY.

Verified in-game: Frost Nova (10230) -> (10, 10) without Arctic Reach,
(10, 12) with rank 2 (+20%). op 6 = radius confirmed via FUN_006e6350;
percent constant 0.01 confirmed from .rdata.
2026-06-21 15:01:58 -05:00

42 lines
2.0 KiB
C++

// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU Lesser General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <cstdint>
// `Spell::Mod` — the engine's SpellMod (talent / item) system, for the
// LOCAL PLAYER. Replicates `FUN_006e6b30` / `FUN_006e6bf0`: the player's
// flat and percent modifiers are accumulated into two tables indexed
// `[familyFlagBit][op]` (see `VAR_SPELLMOD_*` in Offsets.h). A spell's
// value for a given op is modified by summing, over the bits set in the
// spell's SpellFamilyFlags, the flat and percent entries, then applying
// `value = (value + flat) * (100 + pct) * 0.01`.
//
// This underlies many spell properties — radius, cast time, mana cost,
// duration, range, cooldown — each a distinct `op` (e.g.
// `Offsets::SPELLMOD_OP_RADIUS`). The op numbering is the engine's
// internal one; verify each against the binary before relying on it.
//
// Inherently local-player-only: the client tracks spell mods for the
// player alone, so there's no way to know another caster's talents.
namespace Spell::Mod {
// Returns `base` with the local player's modifiers for `op` applied to
// `spellRecord` (a `Spell.dbc` record pointer). Returns `base` unchanged
// when no modifier matches — wrong spell family, mods disabled on the
// spell, the player can't be resolved, or no relevant talent/item.
float Apply(const uint8_t *spellRecord, int op, float base);
} // namespace Spell::Mod