Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // "the bodies of template functions must be made available in a header file"
- template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell)
- {
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
- if (!spellInfo) return 0;
- int32 totalpct = 0;
- int32 totalflat = 0;
- for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
- {
- SpellModifier *mod = *itr;
- 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 (mod->charges > 0)
- {
- if (!(spellInfo->SpellFamilyName == 8 && spellInfo->SpellFamilyFlags & 0x200000000LL))
- --mod->charges;
- if (mod->charges == 0)
- {
- mod->charges = -1;
- mod->lastAffected = spell;
- if (!mod->lastAffected)
- mod->lastAffected = FindCurrentSpellBySpellId(spellId);
- ++m_SpellModRemoveCount;
- }
- }
- }
- float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat;
- basevalue = T((float)basevalue + diff);
- return T(diff);
- }
Add Comment
Please, Sign In to add comment