From e08f128f5b32dd0d921e115c31b1f137508d526e Mon Sep 17 00:00:00 2001 From: ratkosrb Date: Fri, 27 Dec 2024 21:54:24 +0200 Subject: [PATCH] Move ApplySpellMod definition to cpp file. --- src/game/Objects/Player.cpp | 52 +++++++++++++++++++++++++++++++++++++ src/game/Objects/Player.h | 49 ---------------------------------- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 5c714afbe6c..1ecacfa8da1 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -22734,6 +22734,58 @@ void Player::CastHighestStealthRank() CastSpell(nullptr, stealthSpellEntry, true); } +template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell* spell) +{ + SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spellId); + if (!spellInfo || spellInfo->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS)) return 0; + float totalpct = 0; + float totalflat = 0; + for (const auto mod : m_spellMods[op]) + { + if (!IsAffectedBySpellmod(spellInfo,mod,spell)) + continue; + + if (mod->type == SPELLMOD_FLAT) + totalflat += mod->value; + else if (mod->type == SPELLMOD_PCT) + { + // skip percent mods for null basevalue (most important for spell mods with charges) + if (basevalue == T(0)) + continue; + + // special case (skip >10sec spell casts for instant cast setting) + if (mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10*IN_MILLISECONDS) && mod->value <= -100) + continue; + + totalpct += mod->value; + } + +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 + // World of Warcraft Client Patch 1.11.0 (2006-06-20) + // - Nature's Grace: You will no longer consume this effect when casting a + // spell which was made instant by Nature's Swiftness. + if (!((mod->op == SPELLMOD_CASTING_TIME) && (mod->type == SPELLMOD_FLAT) && HasInstantCastingSpellMod(spellInfo))) +#endif + DropModCharge(mod, spell); + + // Nostalrius : fix ecorce (22812 - +1sec incant) + rapidite nature (17116 - sorts instant) = 0sec de cast + if (mod->op == SPELLMOD_CASTING_TIME && mod->type == SPELLMOD_PCT && mod->value == -100) + { + totalpct = -100; + totalflat = 0; + break; + } + } + + float diff = float(basevalue) * totalpct/100.0f + totalflat; + basevalue = T(float(basevalue) + diff); + return T(diff); +} + +template int32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, int32& basevalue, Spell* spell); +template uint32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, uint32& basevalue, Spell* spell); +template float Player::ApplySpellMod(uint32 spellId, SpellModOp op, float& basevalue, Spell* spell); + static char const* type_strings[] = { "Basic", diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index 0cd5dc3a8e1..5a22a029a2d 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -2711,53 +2711,4 @@ inline Player const* ToPlayer(Object const* object) void AddItemsSetItem(Player*player,Item* item); void RemoveItemsSetItem(Player*player,ItemPrototype const* proto); -// "the bodies of template functions must be made available in a header file" -template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell* spell) -{ - SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spellId); - if (!spellInfo || spellInfo->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS)) return 0; - float totalpct = 0; - float totalflat = 0; - for (const auto mod : m_spellMods[op]) - { - if (!IsAffectedBySpellmod(spellInfo,mod,spell)) - continue; - - if (mod->type == SPELLMOD_FLAT) - totalflat += mod->value; - else if (mod->type == SPELLMOD_PCT) - { - // skip percent mods for null basevalue (most important for spell mods with charges) - if (basevalue == T(0)) - continue; - - // special case (skip >10sec spell casts for instant cast setting) - if (mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10*IN_MILLISECONDS) && mod->value <= -100) - continue; - - totalpct += mod->value; - } - -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_10_2 - // World of Warcraft Client Patch 1.11.0 (2006-06-20) - // - Nature's Grace: You will no longer consume this effect when casting a - // spell which was made instant by Nature's Swiftness. - if (!((mod->op == SPELLMOD_CASTING_TIME) && (mod->type == SPELLMOD_FLAT) && HasInstantCastingSpellMod(spellInfo))) -#endif - DropModCharge(mod, spell); - - // Nostalrius : fix ecorce (22812 - +1sec incant) + rapidite nature (17116 - sorts instant) = 0sec de cast - if (mod->op == SPELLMOD_CASTING_TIME && mod->type == SPELLMOD_PCT && mod->value == -100) - { - totalpct = -100; - totalflat = 0; - break; - } - } - - float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat; - basevalue = T((float)basevalue + diff); - return T(diff); -} - #endif