aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
committerariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
commit85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch)
treedf3d2084ee2e35008903c03178039b9c986e2d08 /src/server/game/Spells
parent052fc24315ace866ea1cf610e85df119b68100c9 (diff)
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/server/game/Spells')
-rw-r--r--src/server/game/Spells/Auras/SpellAuraDefines.h14
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp150
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp73
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h13
-rw-r--r--src/server/game/Spells/Spell.cpp289
-rw-r--r--src/server/game/Spells/Spell.h84
-rw-r--r--src/server/game/Spells/SpellEffects.cpp174
-rw-r--r--src/server/game/Spells/SpellHistory.cpp14
-rw-r--r--src/server/game/Spells/SpellHistory.h14
-rw-r--r--src/server/game/Spells/SpellInfo.cpp69
-rw-r--r--src/server/game/Spells/SpellInfo.h22
-rw-r--r--src/server/game/Spells/SpellMgr.cpp67
-rw-r--r--src/server/game/Spells/SpellMgr.h9
-rw-r--r--src/server/game/Spells/SpellScript.cpp48
-rw-r--r--src/server/game/Spells/SpellScript.h47
15 files changed, 617 insertions, 470 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h
index 62602ac4a63..4fac4728b6c 100644
--- a/src/server/game/Spells/Auras/SpellAuraDefines.h
+++ b/src/server/game/Spells/Auras/SpellAuraDefines.h
@@ -18,6 +18,8 @@
#ifndef TRINITY_SPELLAURADEFINES_H
#define TRINITY_SPELLAURADEFINES_H
+#include "Define.h"
+
#define MAX_AURAS 255 // Client-side limit
#define MAX_AURAS_GROUP_UPDATE 64 // Limit of SMSG_PARY_MEMBER_STATS_FULL and SMSG_PARTY_MEMBER_STATS
@@ -51,6 +53,16 @@ enum AuraEffectHandleModes
AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK = (AURA_EFFECT_HANDLE_REAPPLY | AURA_EFFECT_HANDLE_REAL)
};
+enum AuraRemoveMode
+{
+ AURA_REMOVE_NONE = 0,
+ AURA_REMOVE_BY_DEFAULT = 1, // scripted remove, remove by stack with aura with different ids and sc aura remove
+ AURA_REMOVE_BY_CANCEL,
+ AURA_REMOVE_BY_ENEMY_SPELL, // dispel and absorb aura destroy
+ AURA_REMOVE_BY_EXPIRE, // aura duration has ended
+ AURA_REMOVE_BY_DEATH
+};
+
//m_schoolAbsorb
enum DAMAGE_ABSORB_TYPE
{
@@ -58,7 +70,7 @@ enum DAMAGE_ABSORB_TYPE
ONLY_MAGIC_ABSORB = -1
};
-enum AuraType
+enum AuraType : uint32
{
SPELL_AURA_NONE = 0,
SPELL_AURA_BIND_SIGHT = 1,
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 2fc4d83b767..5347d056eba 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -16,32 +16,34 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "SpellAuraEffects.h"
+#include "Battlefield.h"
+#include "BattlefieldMgr.h"
+#include "Battleground.h"
+#include "CellImpl.h"
#include "Common.h"
-#include "WorldPacket.h"
-#include "Opcodes.h"
+#include "DBCStores.h"
+#include "GridNotifiersImpl.h"
+#include "Item.h"
#include "Log.h"
+#include "LootMgr.h"
+#include "MotionMaster.h"
+#include "ObjectAccessor.h"
#include "ObjectMgr.h"
-#include "SpellMgr.h"
+#include "Opcodes.h"
+#include "OutdoorPvPMgr.h"
+#include "Pet.h"
#include "Player.h"
-#include "Unit.h"
-#include "ObjectAccessor.h"
-#include "CellImpl.h"
-#include "Util.h"
+#include "ReputationMgr.h"
+#include "ScriptMgr.h"
#include "Spell.h"
#include "SpellHistory.h"
-#include "SpellAuraEffects.h"
-#include "Battleground.h"
-#include "OutdoorPvPMgr.h"
-#include "GridNotifiers.h"
-#include "GridNotifiersImpl.h"
-#include "ScriptMgr.h"
+#include "SpellMgr.h"
+#include "Unit.h"
+#include "Util.h"
#include "Vehicle.h"
-#include "Battlefield.h"
-#include "BattlefieldMgr.h"
-#include "Pet.h"
-#include "ReputationMgr.h"
+#include "WorldPacket.h"
-class Aura;
//
// EFFECT HANDLER NOTES
//
@@ -380,7 +382,7 @@ AuraEffect::AuraEffect(Aura* base, uint8 effIndex, int32 *baseAmount, Unit* cast
m_base(base), m_spellInfo(base->GetSpellInfo()),
m_baseAmount(baseAmount ? *baseAmount : m_spellInfo->Effects[effIndex].BasePoints),
m_bonusAmount(0), m_critChance(0.0f), m_donePct(1.0f),
-m_spellmod(NULL), m_periodicTimer(0), m_tickNumber(0), m_effIndex(effIndex),
+m_spellmod(nullptr), m_periodicTimer(0), m_tickNumber(0), m_effIndex(effIndex),
m_canBeRecalculated(true), m_isPeriodic(false)
{
CalculatePeriodic(caster, true, false);
@@ -421,7 +423,7 @@ void AuraEffect::GetApplicationList(Container& applicationContainer) const
int32 AuraEffect::CalculateAmount(Unit* caster)
{
// default amount calculation
- int32 amount = m_spellInfo->Effects[m_effIndex].CalcValue(caster, &m_baseAmount, NULL);
+ int32 amount = m_spellInfo->Effects[m_effIndex].CalcValue(caster, &m_baseAmount, nullptr);
// check item enchant aura cast
if (!amount && caster)
@@ -536,7 +538,7 @@ void AuraEffect::CalculatePeriodic(Unit* caster, bool resetPeriodicTimer /*= tru
{
// Apply periodic time mod
if (modOwner)
- modOwner->ApplySpellMod<SPELLMOD_ACTIVATION_TIME>(GetId(), m_amplitude);
+ modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_amplitude);
if (caster)
{
@@ -1760,7 +1762,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
{
int32 basePoints = int32(std::min(oldPower, FurorChance));
target->SetPower(POWER_ENERGY, 0);
- target->CastCustomSpell(target, 17099, &basePoints, NULL, NULL, true, NULL, this);
+ target->CastCustomSpell(target, 17099, &basePoints, nullptr, nullptr, true, nullptr, this);
break;
}
case FORM_BEAR:
@@ -1823,12 +1825,12 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
case FORM_DIREBEAR:
case FORM_CAT:
if (AuraEffect* dummy = target->GetAuraEffect(37315, 0))
- target->CastSpell(target, 37316, true, NULL, dummy);
+ target->CastSpell(target, 37316, true, nullptr, dummy);
break;
// Nordrassil Regalia - bonus
case FORM_MOONKIN:
if (AuraEffect* dummy = target->GetAuraEffect(37324, 0))
- target->CastSpell(target, 37325, true, NULL, dummy);
+ target->CastSpell(target, 37325, true, nullptr, dummy);
break;
case FORM_BATTLESTANCE:
case FORM_DEFENSIVESTANCE:
@@ -1883,7 +1885,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
{
if (Item* pItem = target->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND))
{
- target->ToPlayer()->_ApplyWeaponDamage(EQUIPMENT_SLOT_MAINHAND, pItem->GetTemplate(), NULL, apply);
+ target->ToPlayer()->_ApplyWeaponDamage(EQUIPMENT_SLOT_MAINHAND, pItem->GetTemplate(), nullptr, apply);
}
}
}
@@ -2321,7 +2323,7 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode,
player->ApplyItemDependentAuras(item, !apply);
if (attackType != MAX_ATTACK)
{
- player->_ApplyWeaponDamage(slot, item->GetTemplate(), NULL, !apply);
+ player->_ApplyWeaponDamage(slot, item->GetTemplate(), nullptr, !apply);
if (!apply) // apply case already handled on item dependent aura removal (if any)
player->UpdateWeaponDependentAuras(attackType);
}
@@ -4375,7 +4377,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
case 13139: // net-o-matic
// root to self part of (root_target->charge->root_self sequence
if (caster)
- caster->CastSpell(caster, 13138, true, NULL, this);
+ caster->CastSpell(caster, 13138, true, nullptr, this);
break;
case 34026: // kill command
{
@@ -4383,7 +4385,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
if (!pet)
break;
- target->CastSpell(target, 34027, true, NULL, this);
+ target->CastSpell(target, 34027, true, nullptr, this);
// set 3 stacks and 3 charges (to make all auras not disappear at once)
Aura* owner_aura = target->GetAura(34027, GetCasterGUID());
@@ -4404,15 +4406,15 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
if (caster)
{
if (caster->getGender() == GENDER_FEMALE)
- caster->CastSpell(target, 37095, true, NULL, this); // Blood Elf Disguise
+ caster->CastSpell(target, 37095, true, nullptr, this); // Blood Elf Disguise
else
- caster->CastSpell(target, 37093, true, NULL, this);
+ caster->CastSpell(target, 37093, true, nullptr, this);
}
break;
}
case 55198: // Tidal Force
{
- target->CastSpell(target, 55166, true, NULL, this);
+ target->CastSpell(target, 55166, true, nullptr, this);
// set 3 stacks and 3 charges (to make all auras not disappear at once)
Aura* owner_aura = target->GetAura(55166, GetCasterGUID());
if (owner_aura)
@@ -4428,7 +4430,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
}
case 39850: // Rocket Blast
if (roll_chance_i(20)) // backfire stun
- target->CastSpell(target, 51581, true, NULL, this);
+ target->CastSpell(target, 51581, true, nullptr, this);
break;
case 43873: // Headless Horseman Laugh
target->PlayDistanceSound(11965);
@@ -4437,9 +4439,9 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
if (caster)
{
if (caster->getGender() == GENDER_FEMALE)
- caster->CastSpell(target, 46356, true, NULL, this);
+ caster->CastSpell(target, 46356, true, nullptr, this);
else
- caster->CastSpell(target, 46355, true, NULL, this);
+ caster->CastSpell(target, 46355, true, nullptr, this);
}
break;
case 46361: // Reinforced Net
@@ -4481,7 +4483,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
}
if (finalSpelId)
- caster->CastSpell(target, finalSpelId, true, NULL, this);
+ caster->CastSpell(target, finalSpelId, true, nullptr, this);
}
switch (m_spellInfo->SpellFamilyName)
@@ -4501,7 +4503,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
break;
case 36730: // Flame Strike
{
- target->CastSpell(target, 36731, true, NULL, this);
+ target->CastSpell(target, 36731, true, nullptr, this);
break;
}
case 44191: // Flame Strike
@@ -4510,7 +4512,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
{
uint32 spellId = target->GetMap()->IsHeroic() ? 46163 : 44190;
- target->CastSpell(target, spellId, true, NULL, this);
+ target->CastSpell(target, spellId, true, nullptr, this);
}
break;
}
@@ -4524,14 +4526,14 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
break;
}
case 42783: // Wrath of the Astromancer
- target->CastSpell(target, GetAmount(), true, NULL, this);
+ target->CastSpell(target, GetAmount(), true, nullptr, this);
break;
case 46308: // Burning Winds cast only at creatures at spawn
- target->CastSpell(target, 47287, true, NULL, this);
+ target->CastSpell(target, 47287, true, nullptr, this);
break;
case 52172: // Coyote Spirit Despawn Aura
case 60244: // Blood Parrot Despawn Aura
- target->CastSpell((Unit*)NULL, GetAmount(), true, NULL, this);
+ target->CastSpell((Unit*)nullptr, GetAmount(), true, nullptr, this);
break;
case 58600: // Restricted Flight Area
case 58730: // Restricted Flight Area
@@ -4574,7 +4576,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
SpellInfo const* spell = sSpellMgr->AssertSpellInfo(spellId);
for (uint32 i = 0; i < spell->StackAmount; ++i)
- caster->CastSpell(target, spell->Id, true, NULL, NULL, GetCasterGUID());
+ caster->CastSpell(target, spell->Id, true, nullptr, nullptr, GetCasterGUID());
break;
}
target->RemoveAurasDueToSpell(spellId);
@@ -4588,7 +4590,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
{
SpellInfo const* spell = sSpellMgr->AssertSpellInfo(spellId);
for (uint32 i = 0; i < spell->StackAmount; ++i)
- caster->CastSpell(target, spell->Id, true, NULL, NULL, GetCasterGUID());
+ caster->CastSpell(target, spell->Id, true, nullptr, nullptr, GetCasterGUID());
break;
}
target->RemoveAurasDueToSpell(spellId);
@@ -4761,8 +4763,8 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod
InventoryResult msg = plCaster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellInfo()->Effects[m_effIndex].ItemType, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK)
{
- count-=noSpaceForCount;
- plCaster->SendEquipError(msg, NULL, NULL, GetSpellInfo()->Effects[m_effIndex].ItemType);
+ count -= noSpaceForCount;
+ plCaster->SendEquipError(msg, nullptr, nullptr, GetSpellInfo()->Effects[m_effIndex].ItemType);
if (count == 0)
return;
}
@@ -4770,7 +4772,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod
Item* newitem = plCaster->StoreNewItem(dest, GetSpellInfo()->Effects[m_effIndex].ItemType, true);
if (!newitem)
{
- plCaster->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
+ plCaster->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
return;
}
plCaster->SendNewItem(newitem, count, true, true);
@@ -4921,9 +4923,9 @@ void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, boo
return;
// If amount avalible cast with basepoints (Crypt Fever for example)
if (GetAmount())
- caster->CastCustomSpell(target, triggeredSpellId, &m_amount, NULL, NULL, true, NULL, this);
+ caster->CastCustomSpell(target, triggeredSpellId, &m_amount, nullptr, nullptr, true, nullptr, this);
else
- caster->CastSpell(target, triggeredSpellId, true, NULL, this);
+ caster->CastSpell(target, triggeredSpellId, true, nullptr, this);
}
else
{
@@ -5089,7 +5091,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
}
case 62292: // Blaze (Pool of Tar)
// should we use custom damage?
- target->CastSpell((Unit*)NULL, m_spellInfo->Effects[m_effIndex].TriggerSpell, true);
+ target->CastSpell((Unit*)nullptr, m_spellInfo->Effects[m_effIndex].TriggerSpell, true);
break;
case 62399: // Overload Circuit
if (target->GetMap()->IsDungeon() && int(target->GetAppliedAuras().count(62399)) >= (target->GetMap()->IsHeroic() ? 4 : 2))
@@ -5102,7 +5104,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
case 64821: // Fuse Armor (Razorscale)
if (GetBase()->GetStackAmount() == GetSpellInfo()->StackAmount)
{
- target->CastSpell(target, 64774, true, NULL, NULL, GetCasterGUID());
+ target->CastSpell(target, 64774, true, nullptr, nullptr, GetCasterGUID());
target->RemoveAura(64821);
}
break;
@@ -5113,7 +5115,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
// Mirror Image
if (GetId() == 55342)
// Set name of summons to name of caster
- target->CastSpell((Unit*)NULL, m_spellInfo->Effects[m_effIndex].TriggerSpell, true);
+ target->CastSpell((Unit*)nullptr, m_spellInfo->Effects[m_effIndex].TriggerSpell, true);
break;
}
case SPELLFAMILY_DRUID:
@@ -5162,7 +5164,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
if (GetSpellInfo()->SpellFamilyFlags[1] & 0x80000000)
{
if (caster)
- caster->CastCustomSpell(53352, SPELLVALUE_BASE_POINT0, m_amount, target, true, NULL, this);
+ caster->CastCustomSpell(53352, SPELLVALUE_BASE_POINT0, m_amount, target, true, nullptr, this);
break;
}
switch (GetSpellInfo()->Id)
@@ -5196,7 +5198,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
{
case 49016: // Hysteria
uint32 damage = uint32(target->CountPctFromMaxHealth(1));
- target->DealDamage(target, damage, NULL, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
+ target->DealDamage(target, damage, nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
break;
}
// Blood of the North
@@ -5228,7 +5230,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
uint32 auraId = auraSpellInfo->Id;
// specific code for cases with no trigger spell provided in field
- if (triggeredSpellInfo == NULL)
+ if (triggeredSpellInfo == nullptr)
{
switch (auraSpellInfo->SpellFamilyName)
{
@@ -5272,7 +5274,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
// Frost Blast
case 27808:
if (caster)
- caster->CastCustomSpell(29879, SPELLVALUE_BASE_POINT0, int32(target->CountPctFromMaxHealth(21)), target, true, NULL, this);
+ caster->CastCustomSpell(29879, SPELLVALUE_BASE_POINT0, int32(target->CountPctFromMaxHealth(21)), target, true, nullptr, this);
return;
// Inoculate Nestlewood Owlkin
case 29528:
@@ -5312,7 +5314,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
// so instakill will be naturally done before trigger spell
case 31347:
{
- target->CastSpell(target, 31350, true, NULL, this);
+ target->CastSpell(target, 31350, true, nullptr, this);
target->KillSelf();
return;
}
@@ -5328,9 +5330,9 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
{
// cast 24 spells 34269-34289, 34314-34316
for (uint32 spell_id = 34269; spell_id != 34290; ++spell_id)
- target->CastSpell(target, spell_id, true, NULL, this);
+ target->CastSpell(target, spell_id, true, nullptr, this);
for (uint32 spell_id = 34314; spell_id != 34317; ++spell_id)
- target->CastSpell(target, spell_id, true, NULL, this);
+ target->CastSpell(target, spell_id, true, nullptr, this);
return;
}
// Remote Toy
@@ -5347,7 +5349,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
if (!caster || target->GetTypeId() != TYPEID_UNIT)
return;
- caster->CastSpell(caster, 38495, true, NULL, this);
+ caster->CastSpell(caster, 38495, true, nullptr, this);
Creature* creatureTarget = target->ToCreature();
@@ -5394,7 +5396,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
case 65922:
case 65923:
{
- Unit* permafrostCaster = NULL;
+ Unit* permafrostCaster = nullptr;
Aura* permafrostAura = target->GetAura(66193);
if (!permafrostAura)
permafrostAura = target->GetAura(67855);
@@ -5420,15 +5422,15 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
}
// Mana Tide
case 16191:
- target->CastCustomSpell(target, triggerSpellId, &m_amount, NULL, NULL, true, NULL, this);
+ target->CastCustomSpell(target, triggerSpellId, &m_amount, nullptr, nullptr, true, nullptr, this);
return;
// Negative Energy Periodic
case 46284:
- target->CastCustomSpell(triggerSpellId, SPELLVALUE_MAX_TARGETS, m_tickNumber / 10 + 1, NULL, true, NULL, this);
+ target->CastCustomSpell(triggerSpellId, SPELLVALUE_MAX_TARGETS, m_tickNumber / 10 + 1, nullptr, true, nullptr, this);
return;
// Slime Pool (Dreadscale & Acidmaw)
case 66882:
- target->CastCustomSpell(triggerSpellId, SPELLVALUE_RADIUS_MOD, (int32)((((float)m_tickNumber / 60) * 0.9f + 0.1f) * 10000 * 2 / 3), NULL, true, NULL, this);
+ target->CastCustomSpell(triggerSpellId, SPELLVALUE_RADIUS_MOD, (int32)((((float)m_tickNumber / 60) * 0.9f + 0.1f) * 10000 * 2 / 3), nullptr, true, nullptr, this);
return;
// Beacon of Light
case 53563:
@@ -5442,7 +5444,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
case 69508:
{
if (caster)
- caster->CastSpell(target, triggerSpellId, true, NULL, NULL, caster->GetGUID());
+ caster->CastSpell(target, triggerSpellId, true, nullptr, nullptr, caster->GetGUID());
return;
}
case 24745: // Summon Templar, Trigger
@@ -5477,7 +5479,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
{
if (Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? caster : target)
{
- triggerCaster->CastSpell(target, triggeredSpellInfo, true, NULL, this);
+ triggerCaster->CastSpell(target, triggeredSpellInfo, true, nullptr, this);
TC_LOG_DEBUG("spells", "AuraEffect::HandlePeriodicTriggerSpellAuraTick: Spell %u Trigger %u", GetId(), triggeredSpellInfo->Id);
}
}
@@ -5561,7 +5563,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
damage = std::max(int32(damage * GetDonePct()), 0);
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
+ modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DOT, damage);
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount());
@@ -5704,7 +5706,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
damage = std::max(int32(damage * GetDonePct()), 0);
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
+ modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DOT, damage);
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount());
@@ -5875,7 +5877,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
damage = std::max(int32(damage * GetDonePct()), 0);
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
+ modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DOT, damage);
damage = target->SpellHealingBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount());
}
@@ -5997,7 +5999,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con
if (manaFeedVal > 0)
{
int32 feedAmount = CalculatePct(gainedAmount, manaFeedVal);
- caster->CastCustomSpell(caster, 32554, &feedAmount, NULL, NULL, true, NULL, this);
+ caster->CastCustomSpell(caster, 32554, &feedAmount, nullptr, nullptr, true, nullptr, this);
}
}
}
@@ -6142,7 +6144,7 @@ void AuraEffect::HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEve
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId))
{
TC_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerSpellAuraProc: Triggering spell %u from aura %u proc", triggeredSpellInfo->Id, GetId());
- triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this);
+ triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, nullptr, this);
}
else
TC_LOG_ERROR("spells","AuraEffect::HandleProcTriggerSpellAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
@@ -6158,7 +6160,7 @@ void AuraEffect::HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp
{
int32 basepoints0 = GetAmount();
TC_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerSpellWithValueAuraProc: Triggering spell %u with value %d from aura %u proc", triggeredSpellInfo->Id, basepoints0, GetId());
- triggerCaster->CastCustomSpell(triggerTarget, triggerSpellId, &basepoints0, NULL, NULL, true, NULL, this);
+ triggerCaster->CastCustomSpell(triggerTarget, triggerSpellId, &basepoints0, nullptr, nullptr, true, nullptr, this);
}
else
TC_LOG_ERROR("spells","AuraEffect::HandleProcTriggerSpellWithValueAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
@@ -6224,7 +6226,7 @@ void AuraEffect::HandleRaidProcFromChargeAuraProc(AuraApplication* aurApp, ProcE
if (Unit* triggerTarget = target->GetNextRandomRaidMemberOrPet(radius))
{
- target->CastSpell(triggerTarget, GetSpellInfo(), true, NULL, this, GetCasterGUID());
+ target->CastSpell(triggerTarget, GetSpellInfo(), true, nullptr, this, GetCasterGUID());
if (Aura* aura = triggerTarget->GetAura(GetId(), GetCasterGUID()))
aura->SetCharges(jumps);
}
@@ -6232,7 +6234,7 @@ void AuraEffect::HandleRaidProcFromChargeAuraProc(AuraApplication* aurApp, ProcE
}
TC_LOG_DEBUG("spells", "AuraEffect::HandleRaidProcFromChargeAuraProc: Triggering spell %u from aura %u proc", triggerSpellId, GetId());
- target->CastSpell(target, triggerSpellId, true, NULL, this, GetCasterGUID());
+ target->CastSpell(target, triggerSpellId, true, nullptr, this, GetCasterGUID());
}
@@ -6265,7 +6267,7 @@ void AuraEffect::HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurA
if (Unit* triggerTarget = target->GetNextRandomRaidMemberOrPet(radius))
{
- target->CastCustomSpell(triggerTarget, GetId(), &value, NULL, NULL, true, NULL, this, GetCasterGUID());
+ target->CastCustomSpell(triggerTarget, GetId(), &value, nullptr, nullptr, true, nullptr, this, GetCasterGUID());
if (Aura* aura = triggerTarget->GetAura(GetId(), GetCasterGUID()))
aura->SetCharges(jumps);
}
@@ -6273,7 +6275,7 @@ void AuraEffect::HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurA
}
TC_LOG_DEBUG("spells", "AuraEffect::HandleRaidProcFromChargeWithValueAuraProc: Triggering spell %u from aura %u proc", triggerSpellId, GetId());
- target->CastCustomSpell(target, triggerSpellId, &value, NULL, NULL, true, NULL, this, GetCasterGUID());
+ target->CastCustomSpell(target, triggerSpellId, &value, nullptr, nullptr, true, nullptr, this, GetCasterGUID());
}
template TC_GAME_API void AuraEffect::GetTargetList(std::list<Unit*>&) const;
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 6a24a73ac1a..cff25bc8e2c 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -17,26 +17,27 @@
*/
#include "Common.h"
-#include "WorldPacket.h"
-#include "Opcodes.h"
+#include "CellImpl.h"
+#include "Config.h"
+#include "DynamicObject.h"
+#include "GridNotifiersImpl.h"
+#include "Item.h"
#include "Log.h"
+#include "ObjectAccessor.h"
#include "ObjectMgr.h"
-#include "SpellMgr.h"
+#include "Opcodes.h"
#include "Player.h"
-#include "Unit.h"
+#include "ScriptMgr.h"
#include "Spell.h"
-#include "SpellHistory.h"
#include "SpellAuraEffects.h"
-#include "DynamicObject.h"
-#include "ObjectAccessor.h"
-#include "Util.h"
-#include "GridNotifiers.h"
-#include "GridNotifiersImpl.h"
-#include "CellImpl.h"
-#include "ScriptMgr.h"
+#include "SpellHistory.h"
+#include "SpellMgr.h"
#include "SpellScript.h"
+#include "Unit.h"
+#include "Util.h"
#include "Vehicle.h"
-#include "Config.h"
+#include "World.h"
+#include "WorldPacket.h"
AuraApplication::AuraApplication(Unit* target, Unit* caster, Aura* aura, uint8 effMask):
_target(target), _base(aura), _removeMode(AURA_REMOVE_NONE), _slot(MAX_AURAS),
@@ -341,7 +342,7 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne
Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID) :
m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()),
-m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(time(NULL)),
+m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(time(nullptr)),
m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0),
m_casterLevel(caster ? caster->getLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1),
m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEvent(nullptr),
@@ -363,7 +364,7 @@ AuraScript* Aura::GetScriptByName(std::string const& scriptName) const
for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
if ((*itr)->_GetScriptName()->compare(scriptName) == 0)
return *itr;
- return NULL;
+ return nullptr;
}
void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount)
@@ -372,9 +373,9 @@ void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (effMask & (uint8(1) << i))
- m_effects[i] = new AuraEffect(this, i, baseAmount ? baseAmount + i : NULL, caster);
+ m_effects[i] = new AuraEffect(this, i, baseAmount ? baseAmount + i : nullptr, caster);
else
- m_effects[i] = NULL;
+ m_effects[i] = nullptr;
}
}
@@ -424,7 +425,7 @@ void Aura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication * auraApp
{
if (m_spellInfo->IsCooldownStartedOnEvent())
{
- Item* castItem = m_castItemGuid ? caster->ToPlayer()->GetItemByGuid(m_castItemGuid) : NULL;
+ Item* castItem = m_castItemGuid ? caster->ToPlayer()->GetItemByGuid(m_castItemGuid) : nullptr;
caster->GetSpellHistory()->StartCooldown(m_spellInfo, castItem ? castItem->GetEntry() : 0, nullptr, true);
}
}
@@ -647,8 +648,8 @@ void Aura::UpdateOwner(uint32 diff, WorldObject* owner)
Unit* caster = GetCaster();
// Apply spellmods for channeled auras
// used for example when triggered spell of spell:10 is modded
- Spell* modSpell = NULL;
- Player* modOwner = NULL;
+ Spell* modSpell = nullptr;
+ Player* modOwner = nullptr;
if (caster)
{
modOwner = caster->GetSpellModOwner();
@@ -718,7 +719,7 @@ void Aura::Update(uint32 diff, Unit* caster)
int32 Aura::CalcMaxDuration(Unit* caster) const
{
- Player* modOwner = NULL;
+ Player* modOwner = nullptr;
int32 maxDuration;
if (caster)
@@ -734,7 +735,7 @@ int32 Aura::CalcMaxDuration(Unit* caster) const
// IsPermanent() checks max duration (which we are supposed to calculate here)
if (maxDuration != -1 && modOwner)
- modOwner->ApplySpellMod<SPELLMOD_DURATION>(GetId(), maxDuration);
+ modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);
return maxDuration;
}
@@ -744,7 +745,7 @@ void Aura::SetDuration(int32 duration, bool withMods)
if (withMods)
if (Unit* caster = GetCaster())
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DURATION>(GetId(), duration);
+ modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, duration);
m_duration = duration;
SetNeedClientUpdateForTargets();
@@ -799,7 +800,7 @@ uint8 Aura::CalcMaxCharges(Unit* caster) const
if (caster)
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_CHARGES>(GetId(), maxProcCharges);
+ modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, maxProcCharges);
return maxProcCharges;
}
@@ -1047,7 +1048,7 @@ int32 Aura::CalcDispelChance(Unit const* auraTarget, bool offensive) const
// Apply dispel mod from aura caster
if (Unit* caster = GetCaster())
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_RESIST_DISPEL_CHANCE>(GetId(), resistChance);
+ modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance);
// Dispel resistance from target SPELL_AURA_MOD_DISPEL_RESIST
// Only affects offensive dispels
@@ -1174,7 +1175,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
if (*itr < 0)
target->RemoveAurasDueToSpell(-(*itr));
else if (removeMode != AURA_REMOVE_BY_DEATH)
- target->CastSpell(target, *itr, true, NULL, NULL, GetCasterGUID());
+ target->CastSpell(target, *itr, true, nullptr, nullptr, GetCasterGUID());
}
}
if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(GetId() + SPELL_LINK_AURA))
@@ -1237,7 +1238,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
if (caster->HasAura(64760))
{
int32 heal = GetEffect(EFFECT_0)->GetAmount();
- caster->CastCustomSpell(target, 64801, &heal, NULL, NULL, true, NULL, GetEffect(EFFECT_0));
+ caster->CastCustomSpell(target, 64801, &heal, nullptr, nullptr, true, nullptr, GetEffect(EFFECT_0));
}
}
break;
@@ -1295,7 +1296,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
{
int32 damage = (devouringPlague->GetAmount() + devouringPlague->GetBonusAmount()) * devouringPlague->GetDonePct();
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
+ modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DOT, damage);
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT);
@@ -1334,7 +1335,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
if (GetCasterGUID() == target->GetGUID())
break;
- AuraEffect* aurEff = NULL;
+ AuraEffect* aurEff = nullptr;
// Ebon Plaguebringer / Crypt Fever
Unit::AuraEffectList const& TalentAuras = caster->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (Unit::AuraEffectList::const_iterator itr = TalentAuras.begin(); itr != TalentAuras.end(); ++itr)
@@ -1392,7 +1393,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
case 66: // Invisibility
if (removeMode != AURA_REMOVE_BY_EXPIRE)
break;
- target->CastSpell(target, 32612, true, NULL, GetEffect(1));
+ target->CastSpell(target, 32612, true, nullptr, GetEffect(1));
target->CombatStop();
break;
default:
@@ -1453,7 +1454,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 178, 1))
{
int32 basepoints0 = aurEff->GetAmount() * caster->GetCreateMana() / 100;
- caster->CastCustomSpell(caster, 64103, &basepoints0, NULL, NULL, true, NULL, GetEffect(0));
+ caster->CastCustomSpell(caster, 64103, &basepoints0, nullptr, nullptr, true, nullptr, GetEffect(0));
}
}
// Power word: shield
@@ -1486,7 +1487,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
multiplier += 0.5f;
int32 basepoints0 = int32(CalculatePct(caster->GetMaxPower(POWER_MANA), multiplier));
- caster->CastCustomSpell(caster, 47755, &basepoints0, NULL, NULL, true);
+ caster->CastCustomSpell(caster, 47755, &basepoints0, nullptr, nullptr, true);
}
// effect on aura target
if (AuraEffect const* aurEff = aura->GetEffect(1))
@@ -1500,7 +1501,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
case POWER_MANA:
{
int32 basepoints0 = int32(CalculatePct(target->GetMaxPower(POWER_MANA), 2));
- caster->CastCustomSpell(target, 63654, &basepoints0, NULL, NULL, true);
+ caster->CastCustomSpell(target, 63654, &basepoints0, nullptr, nullptr, true);
break;
}
case POWER_RAGE: triggeredSpellId = 63653; break;
@@ -1593,7 +1594,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
target->RemoveAurasDueToSpell(31666);
int32 basepoints0 = aurEff->GetAmount();
- target->CastCustomSpell(target, 31665, &basepoints0, NULL, NULL, true);
+ target->CastCustomSpell(target, 31665, &basepoints0, nullptr, nullptr, true);
}
}
// Overkill
@@ -1812,7 +1813,7 @@ bool Aura::CanStackWith(Aura const* existingAura) const
if (HasEffectType(SPELL_AURA_CONTROL_VEHICLE) && existingAura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE))
{
- Vehicle* veh = NULL;
+ Vehicle* veh = nullptr;
if (GetOwner()->ToUnit())
veh = GetOwner()->ToUnit()->GetVehicleKit();
@@ -2005,7 +2006,7 @@ float Aura::CalcProcChance(SpellProcEntry const& procEntry, ProcEventInfo& event
}
// apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_CHANCE_OF_SUCCESS>(GetId(), chance);
+ modOwner->ApplySpellMod(GetId(), SPELLMOD_CHANCE_OF_SUCCESS, chance);
}
// proc chance is reduced by an additional 3.333% per level past 60
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index 32eaf8585e8..ee28ee2fd94 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -176,7 +176,7 @@ class TC_GAME_API Aura
void SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, int32 * amount);
// helpers for aura effects
- bool HasEffect(uint8 effIndex) const { return GetEffect(effIndex) != NULL; }
+ bool HasEffect(uint8 effIndex) const { return GetEffect(effIndex) != nullptr; }
bool HasEffectType(AuraType type) const;
AuraEffect* GetEffect(uint8 effIndex) const { ASSERT (effIndex < MAX_SPELL_EFFECTS); return m_effects[effIndex]; }
uint8 GetEffectMask() const { uint8 effMask = 0; for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i]) effMask |= 1<<i; return effMask; }
@@ -186,8 +186,8 @@ class TC_GAME_API Aura
// Helpers for targets
ApplicationMap const& GetApplicationMap() { return m_applications; }
void GetApplicationList(Unit::AuraApplicationList& applicationList) const;
- const AuraApplication* GetApplicationOfTarget(ObjectGuid guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
- AuraApplication* GetApplicationOfTarget(ObjectGuid guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
+ AuraApplication const* GetApplicationOfTarget(ObjectGuid guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; }
+ AuraApplication* GetApplicationOfTarget(ObjectGuid guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; }
bool IsAppliedOnTarget(ObjectGuid guid) const { return m_applications.find(guid) != m_applications.end(); }
void SetNeedClientUpdateForTargets() const;
@@ -234,11 +234,16 @@ class TC_GAME_API Aura
bool CallScriptEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo);
void CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo);
- AuraScript* GetScriptByName(std::string const& scriptName) const;
+ template <class Script>
+ Script* GetScript(std::string const& scriptName) const
+ {
+ return dynamic_cast<Script*>(GetScriptByName(scriptName));
+ }
std::vector<AuraScript*> m_loadedScripts;
private:
+ AuraScript* GetScriptByName(std::string const& scriptName) const;
void _DeleteRemovedApplications();
protected:
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index d8baf713926..ae65161538b 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -16,46 +16,49 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Spell.h"
+#include "Battlefield.h"
+#include "BattlefieldMgr.h"
+#include "Battleground.h"
+#include "CellImpl.h"
#include "Common.h"
+#include "ConditionMgr.h"
#include "DatabaseEnv.h"
-#include "WorldPacket.h"
-#include "WorldSession.h"
-#include "GameTime.h"
+#include "DBCStores.h"
+#include "DisableMgr.h"
+#include "DynamicObject.h"
+#include "GameObjectAI.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
-#include "Opcodes.h"
+#include "GameTime.h"
+#include "InstanceScript.h"
+#include "Item.h"
#include "Log.h"
-#include "UpdateMask.h"
-#include "World.h"
+#include "LootMgr.h"
+#include "ObjectAccessor.h"
#include "ObjectMgr.h"
-#include "SpellMgr.h"
-#include "Player.h"
+#include "Opcodes.h"
+#include "PathGenerator.h"
#include "Pet.h"
-#include "Unit.h"
-#include "Spell.h"
-#include "DynamicObject.h"
-#include "UpdateData.h"
-#include "ObjectAccessor.h"
-#include "CellImpl.h"
+#include "Player.h"
+#include "ScriptMgr.h"
#include "SharedDefines.h"
-#include "LootMgr.h"
-#include "VMapFactory.h"
-#include "Battleground.h"
-#include "Util.h"
-#include "TemporarySummon.h"
-#include "Vehicle.h"
#include "SpellAuraEffects.h"
-#include "ScriptMgr.h"
-#include "ConditionMgr.h"
-#include "DisableMgr.h"
-#include "SpellScript.h"
-#include "InstanceScript.h"
-#include "SpellInfo.h"
#include "SpellHistory.h"
-#include "Battlefield.h"
-#include "BattlefieldMgr.h"
+#include "SpellInfo.h"
+#include "SpellMgr.h"
+#include "SpellScript.h"
+#include "TemporarySummon.h"
#include "TradeData.h"
-#include "GameObjectAI.h"
+#include "Unit.h"
+#include "UpdateData.h"
+#include "UpdateMask.h"
+#include "Util.h"
+#include "Vehicle.h"
+#include "VMapFactory.h"
+#include "World.h"
+#include "WorldPacket.h"
+#include "WorldSession.h"
extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];
@@ -109,8 +112,8 @@ void SpellDestination::RelocateOffset(Position const& offset)
SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0), m_strTarget()
{
- m_objectTarget = NULL;
- m_itemTarget = NULL;
+ m_objectTarget = nullptr;
+ m_itemTarget = nullptr;
m_itemTargetEntry = 0;
@@ -244,7 +247,7 @@ Unit* SpellCastTargets::GetUnitTarget() const
if (m_objectTarget)
return m_objectTarget->ToUnit();
- return NULL;
+ return nullptr;
}
void SpellCastTargets::SetUnitTarget(Unit* target)
@@ -270,7 +273,7 @@ GameObject* SpellCastTargets::GetGOTarget() const
if (m_objectTarget)
return m_objectTarget->ToGameObject();
- return NULL;
+ return nullptr;
}
void SpellCastTargets::SetGOTarget(GameObject* target)
@@ -296,7 +299,7 @@ Corpse* SpellCastTargets::GetCorpseTarget() const
if (m_objectTarget)
return m_objectTarget->ToCorpse();
- return NULL;
+ return nullptr;
}
WorldObject* SpellCastTargets::GetObjectTarget() const
@@ -311,7 +314,7 @@ ObjectGuid SpellCastTargets::GetObjectTargetGUID() const
void SpellCastTargets::RemoveObjectTarget()
{
- m_objectTarget = NULL;
+ m_objectTarget = nullptr;
m_objectTargetGUID.Clear();
m_targetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_GAMEOBJECT_MASK);
}
@@ -441,11 +444,21 @@ void SpellCastTargets::RemoveDst()
m_targetMask &= ~(TARGET_FLAG_DEST_LOCATION);
}
+bool SpellCastTargets::HasSrc() const
+{
+ return (GetTargetMask() & TARGET_FLAG_SOURCE_LOCATION) != 0;
+}
+
+bool SpellCastTargets::HasDst() const
+{
+ return (GetTargetMask() & TARGET_FLAG_DEST_LOCATION) != 0;
+}
+
void SpellCastTargets::Update(Unit* caster)
{
- m_objectTarget = m_objectTargetGUID ? ((m_objectTargetGUID == caster->GetGUID()) ? caster : ObjectAccessor::GetWorldObject(*caster, m_objectTargetGUID)) : NULL;
+ m_objectTarget = m_objectTargetGUID ? ((m_objectTargetGUID == caster->GetGUID()) ? caster : ObjectAccessor::GetWorldObject(*caster, m_objectTargetGUID)) : nullptr;
- m_itemTarget = NULL;
+ m_itemTarget = nullptr;
if (caster->GetTypeId() == TYPEID_PLAYER)
{
Player* player = caster->ToPlayer();
@@ -511,14 +524,28 @@ SpellValue::SpellValue(SpellInfo const* proto)
AuraStackAmount = 1;
}
+class TC_GAME_API SpellEvent : public BasicEvent
+{
+ public:
+ SpellEvent(Spell* spell);
+ virtual ~SpellEvent();
+
+ bool Execute(uint64 e_time, uint32 p_time) override;
+ void Abort(uint64 e_time) override;
+ bool IsDeletable() const override;
+
+ protected:
+ Spell* m_Spell;
+};
+
Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID, bool skipCheck) :
m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)),
m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster)
-, m_spellValue(new SpellValue(m_spellInfo)), _spellEvent(nullptr), m_preGeneratedPath(PathGenerator(m_caster))
+, m_spellValue(new SpellValue(m_spellInfo)), _spellEvent(nullptr)
{
m_customError = SPELL_CUSTOM_ERROR_NONE;
m_skipCheck = skipCheck;
- m_selfContainer = NULL;
+ m_selfContainer = nullptr;
m_referencedFromCurrentSpell = false;
m_executedCurrently = false;
m_needComboPoints = m_spellInfo->NeedsComboPoints();
@@ -552,7 +579,7 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
{
m_originalCaster = ObjectAccessor::GetUnit(*m_caster, m_originalCasterGUID);
if (m_originalCaster && !m_originalCaster->IsInWorld())
- m_originalCaster = NULL;
+ m_originalCaster = nullptr;
}
m_spellState = SPELL_STATE_NULL;
@@ -560,14 +587,14 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
if (info->HasAttribute(SPELL_ATTR4_CAN_CAST_WHILE_CASTING))
_triggeredCastFlags = TriggerCastFlags(uint32(_triggeredCastFlags) | TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_CAST_DIRECTLY);
- m_CastItem = NULL;
+ m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
- unitTarget = NULL;
- itemTarget = NULL;
- gameObjTarget = NULL;
- destTarget = NULL;
+ unitTarget = nullptr;
+ itemTarget = nullptr;
+ gameObjTarget = nullptr;
+ destTarget = nullptr;
damage = 0;
targetMissInfo = SPELL_MISS_NONE;
effectHandleMode = SPELL_EFFECT_HANDLE_LAUNCH;
@@ -576,12 +603,12 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
m_procAttacker = 0;
m_procVictim = 0;
m_hitMask = 0;
- focusObject = NULL;
+ focusObject = nullptr;
m_cast_count = 0;
m_glyphIndex = 0;
m_preCastSpell = 0;
- m_triggeredByAuraSpell = NULL;
- m_spellAura = NULL;
+ m_triggeredByAuraSpell = nullptr;
+ m_spellAura = nullptr;
//Auto Shot & Shoot (wand)
m_autoRepeat = m_spellInfo->IsAutoRepeatRangedSpell();
@@ -622,7 +649,7 @@ Spell::~Spell()
// Clean the reference to avoid later crash.
// If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
TC_LOG_ERROR("spells", "SPELL: deleting spell for spell ID %u. However, spell still referenced.", m_spellInfo->Id);
- *m_selfContainer = NULL;
+ *m_selfContainer = nullptr;
}
if (m_caster && m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -657,7 +684,7 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets)
// try to select correct unit target if not provided by client or by serverside cast
if (neededTargets & (TARGET_FLAG_UNIT_MASK))
{
- Unit* unit = NULL;
+ Unit* unit = nullptr;
// try to use player selection as a target
if (Player* playerCaster = m_caster->ToPlayer())
{
@@ -724,7 +751,7 @@ void Spell::SelectExplicitTargets()
redirect = m_caster->GetMeleeHitRedirectTarget(target, m_spellInfo);
break;
default:
- redirect = NULL;
+ redirect = nullptr;
break;
}
if (redirect && (redirect != target))
@@ -1171,7 +1198,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge
void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32 effMask)
{
- Unit* referer = NULL;
+ Unit* referer = nullptr;
switch (targetType.GetReferenceType())
{
case TARGET_REFERENCE_TYPE_SRC:
@@ -1202,7 +1229,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
if (!referer)
return;
- Position const* center = NULL;
+ Position const* center = nullptr;
switch (targetType.GetReferenceType())
{
case TARGET_REFERENCE_TYPE_SRC:
@@ -1429,7 +1456,7 @@ void Spell::SelectImplicitDestDestTargets(SpellEffIndex effIndex, SpellImplicitT
void Spell::SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType)
{
- WorldObject* target = NULL;
+ WorldObject* target = nullptr;
bool checkIfValid = true;
switch (targetType.GetTarget())
@@ -1498,7 +1525,7 @@ void Spell::SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTarg
{
uint32 maxTargets = m_spellInfo->Effects[effIndex].ChainTarget;
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_JUMP_TARGETS>(m_spellInfo->Id, maxTargets, this);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, maxTargets, this);
if (maxTargets > 1)
{
@@ -1646,7 +1673,7 @@ void Spell::SelectEffectTypeImplicitTargets(uint8 effIndex)
if (!targetMask)
return;
- WorldObject* target = NULL;
+ WorldObject* target = nullptr;
switch (m_spellInfo->Effects[effIndex].GetImplicitTargetType())
{
@@ -1759,10 +1786,10 @@ void Spell::SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* refere
WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
{
- WorldObject* target = NULL;
+ WorldObject* target = nullptr;
uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
if (!containerTypeMask)
- return NULL;
+ return nullptr;
Trinity::WorldObjectSpellNearbyTargetCheck check(range, m_caster, m_spellInfo, selectionType, condList);
Trinity::WorldObjectLastSearcher<Trinity::WorldObjectSpellNearbyTargetCheck> searcher(m_caster, target, check, containerTypeMask);
SearchTargets<Trinity::WorldObjectLastSearcher<Trinity::WorldObjectSpellNearbyTargetCheck> > (searcher, containerTypeMask, m_caster, m_caster, range);
@@ -1877,7 +1904,7 @@ void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTar
GameObject* Spell::SearchSpellFocus()
{
- GameObject* focus = NULL;
+ GameObject* focus = nullptr;
Trinity::GameObjectFocusCheck check(m_caster, m_spellInfo->RequiresSpellFocus);
Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck> searcher(m_caster, focus, check);
SearchTargets<Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck> > (searcher, GRID_MAP_TYPE_MASK_GAMEOBJECT, m_caster, m_caster, m_caster->GetVisibilityRange());
@@ -2217,7 +2244,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
// can't use default call because of threading, do stuff as fast as possible
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (farMask & (1 << i))
- HandleEffects(unit, NULL, NULL, i, SPELL_EFFECT_HANDLE_HIT_TARGET);
+ HandleEffects(unit, nullptr, nullptr, i, SPELL_EFFECT_HANDLE_HIT_TARGET);
return;
}
@@ -2656,7 +2683,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
- HandleEffects(unit, NULL, NULL, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
+ HandleEffects(unit, nullptr, nullptr, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
return SPELL_MISS_NONE;
}
@@ -2752,7 +2779,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo* target)
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
- HandleEffects(NULL, NULL, go, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
+ HandleEffects(nullptr, nullptr, go, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
if (go->AI())
go->AI()->SpellHit(m_caster, m_spellInfo);
@@ -2772,7 +2799,7 @@ void Spell::DoAllEffectOnTarget(ItemTargetInfo* target)
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
- HandleEffects(NULL, target->item, NULL, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
+ HandleEffects(nullptr, target->item, nullptr, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
CallScriptOnHitHandlers();
@@ -2798,7 +2825,7 @@ bool Spell::UpdateChanneledTargetList()
{
range = m_spellInfo->GetMaxRange(m_spellInfo->IsPositive());
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_RANGE>(m_spellInfo->Id, range, this);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
// add little tolerance level
range += std::min(MAX_SPELL_RANGE_TOLERANCE, range*0.1f); // 10% but no more than MAX_SPELL_RANGE_TOLERANCE
@@ -3051,7 +3078,7 @@ void Spell::cancel()
SetReferencedFromCurrent(false);
if (m_selfContainer && *m_selfContainer == this)
- *m_selfContainer = NULL;
+ *m_selfContainer = nullptr;
m_caster->RemoveDynObject(m_spellInfo->Id);
if (m_spellInfo->IsChanneled()) // if not channeled then the object for the current cast wasn't summoned yet
@@ -3106,7 +3133,7 @@ void Spell::_cast(bool skipCheck)
// As of 3.0.2 pets begin attacking their owner's target immediately
// Let any pets know we've attacked something. Check DmgClass for harmful spells only
// This prevents spells such as Hunter's Mark from triggering pet attack
- if (this->GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE)
+ if (GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE)
if (Unit* unitTarget = m_targets.GetUnitTarget())
for (Unit* controlled : playerCaster->m_Controlled)
if (Creature* cControlled = controlled->ToCreature())
@@ -3317,7 +3344,7 @@ void Spell::handle_immediate()
// First mod_duration then haste - see Missile Barrage
// Apply duration mod
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DURATION>(m_spellInfo->Id, duration);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
// Apply haste mods
m_caster->ModSpellDurationTime(m_spellInfo, duration, this);
@@ -3445,7 +3472,7 @@ uint64 Spell::handle_delayed(uint64 t_offset)
void Spell::_handle_immediate_phase()
{
- m_spellAura = NULL;
+ m_spellAura = nullptr;
// handle some immediate features of the spell here
HandleThreatSpells();
@@ -3460,7 +3487,7 @@ void Spell::_handle_immediate_phase()
continue;
// call effect handlers to handle destination hit
- HandleEffects(NULL, NULL, NULL, j, SPELL_EFFECT_HANDLE_HIT);
+ HandleEffects(nullptr, nullptr, nullptr, j, SPELL_EFFECT_HANDLE_HIT);
}
// process items
@@ -3897,7 +3924,7 @@ void Spell::SendPetCastResult(SpellCastResult result)
WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1);
WriteCastResultInfo(data, player, m_spellInfo, m_cast_count, result, m_customError);
- player->GetSession()->SendPacket(&data);
+ player->SendDirectMessage(&data);
}
void Spell::SendSpellStart()
@@ -4221,7 +4248,7 @@ void Spell::SendLogExecute()
data.append(*m_effectExecuteData[i]);
delete m_effectExecuteData[i];
- m_effectExecuteData[i] = NULL;
+ m_effectExecuteData[i] = nullptr;
}
m_caster->SendMessageToSet(&data, true);
}
@@ -4367,7 +4394,7 @@ void Spell::SendResurrectRequest(Player* target)
data << uint8(m_caster->IsSpiritHealer()); // "you'll be afflicted with resurrection sickness"
// override delay sent with SMSG_CORPSE_RECLAIM_DELAY, set instant resurrection for spells with this attribute
data << uint8(!m_spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_RESURRECTION_TIMER));
- target->GetSession()->SendPacket(&data);
+ target->SendDirectMessage(&data);
}
void Spell::TakeCastItem()
@@ -4430,9 +4457,9 @@ void Spell::TakeCastItem()
// prevent crash at access to deleted m_targets.GetItemTarget
if (m_CastItem == m_targets.GetItemTarget())
- m_targets.SetItemTarget(NULL);
+ m_targets.SetItemTarget(nullptr);
- m_CastItem = NULL;
+ m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
}
@@ -4455,8 +4482,11 @@ void Spell::TakePower()
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
if (powerType == POWER_RAGE || powerType == POWER_ENERGY || powerType == POWER_RUNE)
+ {
if (ObjectGuid targetGUID = m_targets.GetUnitTargetGUID())
- for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
+ {
+ for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
+ {
if (ihit->targetGUID == targetGUID)
{
if (ihit->missCondition != SPELL_MISS_NONE)
@@ -4464,10 +4494,13 @@ void Spell::TakePower()
hit = false;
//lower spell cost on fail (by talent aura)
if (Player* modOwner = m_caster->ToPlayer()->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_SPELL_COST_REFUND_ON_FAIL>(m_spellInfo->Id, m_powerCost);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_SPELL_COST_REFUND_ON_FAIL, m_powerCost);
}
break;
}
+ }
+ }
+ }
}
if (powerType == POWER_RUNE)
@@ -4556,7 +4589,7 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID) const
{
runeCost[i] = src->RuneCost[i];
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_COST>(m_spellInfo->Id, runeCost[i], const_cast<Spell*>(this));
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], const_cast<Spell*>(this));
}
runeCost[RUNE_DEATH] = MAX_RUNES; // calculated later
@@ -4596,7 +4629,7 @@ void Spell::TakeRunePower(bool didHit)
{
runeCost[i] = runeCostData->RuneCost[i];
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_COST>(m_spellInfo->Id, runeCost[i], this);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], this);
}
// Let's say we use a skill that requires a Frost rune. This is the order:
@@ -4673,7 +4706,7 @@ void Spell::TakeReagents()
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
- ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : NULL;
+ ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : nullptr;
// do not take reagents for these item casts
if (castItemTemplate && castItemTemplate->Flags & ITEM_FLAG_NO_REAGENT_COST)
@@ -4705,14 +4738,14 @@ void Spell::TakeReagents()
}
}
- m_CastItem = NULL;
+ m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
}
// if GetItemTarget is also spell reagent
if (m_targets.GetItemTargetEntry() == itemid)
- m_targets.SetItemTarget(NULL);
+ m_targets.SetItemTarget(nullptr);
p_caster->DestroyItemCount(itemid, itemcount, true);
}
@@ -4782,7 +4815,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOT
TC_LOG_DEBUG("spells", "Spell: %u Effect : %u", m_spellInfo->Id, eff);
// we do not need DamageMultiplier here.
- damage = CalculateDamage(i, NULL);
+ damage = CalculateDamage(i, nullptr);
bool preventDefault = CallScriptEffectHandlers((SpellEffIndex)i, mode);
@@ -4888,7 +4921,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
m_needComboPoints = false;
if ((*j)->GetMiscValue() == 1)
{
- reqCombat=false;
+ reqCombat = false;
break;
}
}
@@ -4989,7 +5022,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (DynamicObject* dynObj = m_caster->GetDynObject(m_triggeredByAuraSpell->Id))
losTarget = dynObj;
- if (!m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_DISABLE_LOS) && !target->IsWithinLOSInMap(losTarget, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2))
+ if (!m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, nullptr, SPELL_DISABLE_LOS) && !target->IsWithinLOSInMap(losTarget, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2))
return SPELL_FAILED_LINE_OF_SIGHT;
}
}
@@ -5001,7 +5034,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
float x, y, z;
m_targets.GetDstPos()->GetPosition(x, y, z);
- if (!m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_DISABLE_LOS) && !m_caster->IsWithinLOS(x, y, z, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2))
+ if (!m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, nullptr, SPELL_DISABLE_LOS) && !m_caster->IsWithinLOS(x, y, z, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2))
return SPELL_FAILED_LINE_OF_SIGHT;
}
@@ -5262,26 +5295,27 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
float objSize = target->GetCombatReach();
float range = m_spellInfo->GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict
- m_preGeneratedPath.SetPathLengthLimit(range);
+ m_preGeneratedPath = Trinity::make_unique<PathGenerator>(m_caster);
+ m_preGeneratedPath->SetPathLengthLimit(range);
// first try with raycast, if it fails fall back to normal path
float targetObjectSize = std::min(target->GetCombatReach(), 4.0f);
- bool result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true);
- if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT)
+ bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true);
+ if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
return SPELL_FAILED_OUT_OF_RANGE;
- else if (!result || m_preGeneratedPath.GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
+ else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
{
- result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false);
- if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT)
+ result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false);
+ if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
return SPELL_FAILED_OUT_OF_RANGE;
- else if (!result || m_preGeneratedPath.GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
+ else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
return SPELL_FAILED_NOPATH;
- else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
+ else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
return SPELL_FAILED_NOPATH;
}
- else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if in a straight line
+ else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if in a straight line
return SPELL_FAILED_NOPATH;
- m_preGeneratedPath.ReducePathLenghtByDist(objSize); // move back
+ m_preGeneratedPath->ReducePathLenghtByDist(objSize); // move back
}
break;
}
@@ -5324,7 +5358,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
|| (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget()))
return SPELL_FAILED_BAD_TARGETS;
- Item* pTempItem = NULL;
+ Item* pTempItem = nullptr;
if (m_targets.GetTargetMask() & TARGET_FLAG_TRADE_ITEM)
{
if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
@@ -5424,7 +5458,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
{
if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
if (Pet* pet = m_caster->ToPlayer()->GetPet())
- pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetGUID());
+ pet->CastSpell(pet, 32752, true, nullptr, nullptr, pet->GetGUID());
}
else if (!m_spellInfo->HasAttribute(SPELL_ATTR1_DISMISS_PET))
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
@@ -5938,6 +5972,11 @@ bool Spell::CheckSpellCancelsConfuse(uint32* param1) const
return CheckSpellCancelsAuraEffect(SPELL_AURA_MOD_CONFUSE, param1);
}
+int32 Spell::CalculateDamage(uint8 i, Unit const* target) const
+{
+ return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_spellValue->EffectBasePoints[i]);
+}
+
bool Spell::CanAutoCast(Unit* target)
{
if (!target)
@@ -5994,6 +6033,18 @@ bool Spell::CanAutoCast(Unit* target)
return false;
}
+void Spell::CheckSrc()
+{
+ if (!m_targets.HasSrc())
+ m_targets.SetSrc(*m_caster);
+}
+
+void Spell::CheckDst()
+{
+ if (!m_targets.HasDst())
+ m_targets.SetDst(*m_caster);
+}
+
SpellCastResult Spell::CheckRange(bool strict) const
{
// Don't check for instant cast spells
@@ -6083,7 +6134,7 @@ std::pair<float, float> Spell::GetMinMaxRange(bool strict) const
maxRange *= ranged->GetTemplate()->RangedModRange * 0.01f;
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_RANGE>(m_spellInfo->Id, maxRange, const_cast<Spell*>(this));
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, maxRange, const_cast<Spell*>(this));
maxRange += rangeMod;
@@ -6693,7 +6744,7 @@ void Spell::Delayed() // only called in DealDamage()
//check pushback reduce
int32 delaytime = 500; // spellcasting delay is normally 500ms
int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
- m_caster->ToPlayer()->ApplySpellMod<SPELLMOD_NOT_LOSE_CASTING_TIME>(m_spellInfo->Id, delayReduce, this);
+ m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100;
if (delayReduce >= 100)
return;
@@ -6731,7 +6782,7 @@ void Spell::DelayedChannel()
int32 delaytime = CalculatePct(duration, 25); // channeling delay is normally 25% of its time per hit
int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
- m_caster->ToPlayer()->ApplySpellMod<SPELLMOD_NOT_LOSE_CASTING_TIME>(m_spellInfo->Id, delayReduce, this);
+ m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100;
if (delayReduce >= 100)
return;
@@ -6768,7 +6819,7 @@ bool Spell::UpdatePointers()
{
m_originalCaster = ObjectAccessor::GetUnit(*m_caster, m_originalCasterGUID);
if (m_originalCaster && !m_originalCaster->IsInWorld())
- m_originalCaster = NULL;
+ m_originalCaster = nullptr;
}
if (m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -6790,7 +6841,7 @@ bool Spell::UpdatePointers()
return true;
// cache last transport
- WorldObject* transport = NULL;
+ WorldObject* transport = nullptr;
// update effect destinations (in case of moved transport dest target)
for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
@@ -6847,11 +6898,11 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
}
// check for ignore LOS on the effect itself
- if (m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_DISABLE_LOS))
+ if (m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, nullptr, SPELL_DISABLE_LOS))
return true;
// if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour
- if (IsTriggered() && m_triggeredByAuraSpell && (m_triggeredByAuraSpell->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_triggeredByAuraSpell->Id, NULL, SPELL_DISABLE_LOS)))
+ if (IsTriggered() && m_triggeredByAuraSpell && (m_triggeredByAuraSpell->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_triggeredByAuraSpell->Id, nullptr, SPELL_DISABLE_LOS)))
return true;
/// @todo shit below shouldn't be here, but it's temporary
@@ -6910,7 +6961,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
else
{
// Get GO cast coordinates if original caster -> GO
- WorldObject* caster = NULL;
+ WorldObject* caster = nullptr;
if (m_originalCasterGUID.IsGameObject())
caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID);
if (!caster)
@@ -6925,6 +6976,26 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
return true;
}
+bool Spell::IsTriggered() const
+{
+ return (_triggeredCastFlags & TRIGGERED_FULL_MASK) != 0;
+}
+
+bool Spell::IsIgnoringCooldowns() const
+{
+ return (_triggeredCastFlags & TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD) != 0;
+}
+
+bool Spell::IsProcDisabled() const
+{
+ return (_triggeredCastFlags & TRIGGERED_DISALLOW_PROC_EVENTS) != 0;
+}
+
+bool Spell::IsChannelActive() const
+{
+ return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0;
+}
+
bool Spell::IsAutoActionResetSpell() const
{
/// @todo changed SPELL_INTERRUPT_FLAG_AUTOATTACK -> SPELL_INTERRUPT_FLAG_INTERRUPT to fix compile - is this check correct at all?
@@ -7099,7 +7170,7 @@ void Spell::HandleLaunchPhase()
if (!m_spellInfo->Effects[i].IsEffect())
continue;
- HandleEffects(NULL, NULL, NULL, i, SPELL_EFFECT_HANDLE_LAUNCH);
+ HandleEffects(nullptr, nullptr, nullptr, i, SPELL_EFFECT_HANDLE_LAUNCH);
}
float multiplier[MAX_SPELL_EFFECTS];
@@ -7155,7 +7226,7 @@ void Spell::HandleLaunchPhase()
void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
{
- Unit* unit = NULL;
+ Unit* unit = nullptr;
// In case spell hit target, do all effect on that target
if (targetInfo.missCondition == SPELL_MISS_NONE)
unit = m_caster->GetGUID() == targetInfo.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, targetInfo.targetGUID);
@@ -7172,7 +7243,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
m_damage = 0;
m_healing = 0;
- HandleEffects(unit, NULL, NULL, i, SPELL_EFFECT_HANDLE_LAUNCH_TARGET);
+ HandleEffects(unit, nullptr, nullptr, i, SPELL_EFFECT_HANDLE_LAUNCH_TARGET);
if (m_damage > 0)
{
@@ -7662,7 +7733,7 @@ void Spell::TriggerGlobalCooldown()
{
// gcd modifier auras are applied only to own spells and only players have such mods
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_GLOBAL_COOLDOWN>(m_spellInfo->Id, gcd, this);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_GLOBAL_COOLDOWN, gcd, this);
// Apply haste rating
gcd = int32(float(gcd) * m_caster->GetFloatValue(UNIT_MOD_CAST_SPEED));
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 7cea09d5c21..6d9bd44e9f1 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -19,21 +19,39 @@
#ifndef __SPELL_H
#define __SPELL_H
-#include "GridDefines.h"
+#include "ConditionMgr.h"
+#include "DBCEnums.h"
+#include "ObjectGuid.h"
+#include "Position.h"
#include "SharedDefines.h"
-#include "ObjectMgr.h"
-#include "SpellInfo.h"
-#include "PathGenerator.h"
+#include <memory>
-class Unit;
-class Player;
-class GameObject;
-class DynamicObject;
-class WorldObject;
class Aura;
-class SpellScript;
-class ByteBuffer;
+class AuraEffect;
+class Corpse;
+class DynamicObject;
+class GameObject;
+class Item;
+class Object;
+class PathGenerator;
+class Player;
class SpellEvent;
+class SpellImplicitTargetInfo;
+class SpellInfo;
+class SpellScript;
+class Unit;
+class WorldObject;
+class WorldPacket;
+struct SummonPropertiesEntry;
+enum AuraType : uint32;
+enum CurrentSpellTypes : uint8;
+enum LootType : uint8;
+enum SpellCastTargetFlags : uint32;
+enum SpellTargetCheckTypes : uint8;
+enum SpellTargetObjectTypes : uint8;
+enum SpellValueMod : uint8;
+enum TriggerCastFlags : uint32;
+enum WeaponAttackType : uint8;
#define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS)
#define MAX_SPELL_RANGE_TOLERANCE 3.0f
@@ -156,8 +174,8 @@ class TC_GAME_API SpellCastTargets
void ModDst(SpellDestination const& spellDest);
void RemoveDst();
- bool HasSrc() const { return (GetTargetMask() & TARGET_FLAG_SOURCE_LOCATION) != 0; }
- bool HasDst() const { return (GetTargetMask() & TARGET_FLAG_DEST_LOCATION) != 0; }
+ bool HasSrc() const;
+ bool HasDst() const;
bool HasTraj() const { return m_speed != 0; }
float GetElevation() const { return m_elevation; }
@@ -225,7 +243,6 @@ static const uint32 SPELL_INTERRUPT_NONPLAYER = 32747;
class TC_GAME_API Spell
{
- friend void Unit::SetCurrentCastSpell(Spell* pSpell);
friend class SpellScript;
public:
@@ -382,13 +399,13 @@ class TC_GAME_API Spell
uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer* condList);
template<class SEARCHER> void SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* referer, Position const* pos, float radius);
- WorldObject* SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList = NULL);
+ WorldObject* SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList = nullptr);
void SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList);
void SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer* condList, bool isChainHeal);
GameObject* SearchSpellFocus();
- void prepare(SpellCastTargets const* targets, AuraEffect const* triggeredByAura = NULL);
+ void prepare(SpellCastTargets const* targets, AuraEffect const* triggeredByAura = nullptr);
void cancel();
void update(uint32 difftime);
void cast(bool skipCheck = false);
@@ -424,7 +441,7 @@ class TC_GAME_API Spell
bool CheckSpellCancelsFear(uint32* param1) const;
bool CheckSpellCancelsConfuse(uint32* param1) const;
- int32 CalculateDamage(uint8 i, Unit const* target) const { return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_spellValue->EffectBasePoints[i]); }
+ int32 CalculateDamage(uint8 i, Unit const* target) const;
bool HaveTargetsForEffect(uint8 effect) const;
void Delayed();
@@ -438,8 +455,8 @@ class TC_GAME_API Spell
bool CheckEffectTarget(Unit const* target, uint32 eff, Position const* losPosition) const;
bool CanAutoCast(Unit* target);
- void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); }
- void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); }
+ void CheckSrc();
+ void CheckDst();
static void WriteCastResultInfo(WorldPacket& data, Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError, uint32* param1 = nullptr, uint32* param2 = nullptr);
static void SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE, uint32* param1 = nullptr, uint32* param2 = nullptr);
@@ -484,10 +501,10 @@ class TC_GAME_API Spell
bool IsAutoRepeat() const { return m_autoRepeat; }
void SetAutoRepeat(bool rep) { m_autoRepeat = rep; }
void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; }
- bool IsTriggered() const { return (_triggeredCastFlags & TRIGGERED_FULL_MASK) != 0; }
- bool IsIgnoringCooldowns() const { return (_triggeredCastFlags & TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD) != 0; }
- bool IsProcDisabled() const { return (_triggeredCastFlags & TRIGGERED_DISALLOW_PROC_EVENTS) != 0; }
- bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; }
+ bool IsTriggered() const;
+ bool IsIgnoringCooldowns() const;
+ bool IsProcDisabled() const;
+ bool IsChannelActive() const;
bool IsAutoActionResetSpell() const;
bool IsTriggeredByAura(SpellInfo const* auraSpellInfo) const { return (auraSpellInfo == m_triggeredByAuraSpell); }
@@ -516,6 +533,9 @@ class TC_GAME_API Spell
void CleanupTargetList();
void SetSpellValue(SpellValueMod mod, int32 value);
+
+ Spell** m_selfContainer; // pointer to our spell container (if applicable)
+
protected:
bool HasGlobalCooldown() const;
void TriggerGlobalCooldown();
@@ -533,8 +553,6 @@ class TC_GAME_API Spell
// e.g. damage around area spell trigered by victim aura and damage enemies of aura caster
Unit* m_originalCaster; // cached pointer for m_originalCaster, updated at Spell::UpdatePointers()
- Spell** m_selfContainer; // pointer to our spell container (if applicable)
-
//Spell data
SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example)
WeaponAttackType m_attackType; // For weapon based attack
@@ -684,7 +702,7 @@ class TC_GAME_API Spell
int32 chance;
};
- bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByAura = NULL) const;
+ bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByAura = nullptr) const;
void PrepareTriggersExecutedOnHit();
typedef std::vector<HitTriggerSpell> HitTriggerSpellList;
HitTriggerSpellList m_hitTriggerSpells;
@@ -709,7 +727,7 @@ class TC_GAME_API Spell
bool m_skipCheck;
uint8 m_auraScaleMask;
- PathGenerator m_preGeneratedPath;
+ std::unique_ptr<PathGenerator> m_preGeneratedPath;
ByteBuffer * m_effectExecuteData[MAX_SPELL_EFFECTS];
@@ -772,16 +790,4 @@ namespace Trinity
typedef void(Spell::*pEffect)(SpellEffIndex effIndex);
-class TC_GAME_API SpellEvent : public BasicEvent
-{
- public:
- SpellEvent(Spell* spell);
- virtual ~SpellEvent();
-
- virtual bool Execute(uint64 e_time, uint32 p_time) override;
- virtual void Abort(uint64 e_time) override;
- virtual bool IsDeletable() const override;
- protected:
- Spell* m_Spell;
-};
#endif
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 3dee9ae956b..21ed4ceec23 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -16,45 +16,49 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Spell.h"
+#include "AccountMgr.h"
+#include "Battleground.h"
+#include "CellImpl.h"
#include "Common.h"
+#include "Creature.h"
+#include "CreatureAI.h"
#include "DatabaseEnv.h"
-#include "WorldPacket.h"
-#include "Opcodes.h"
-#include "Log.h"
-#include "UpdateMask.h"
-#include "World.h"
-#include "ObjectMgr.h"
-#include "SpellMgr.h"
-#include "Player.h"
-#include "SkillExtraItems.h"
-#include "Unit.h"
-#include "Spell.h"
#include "DynamicObject.h"
-#include "SpellAuras.h"
-#include "SpellAuraEffects.h"
-#include "SharedDefines.h"
-#include "Pet.h"
+#include "Formulas.h"
#include "GameObject.h"
+#include "GameObjectAI.h"
#include "GossipDef.h"
-#include "Creature.h"
-#include "Totem.h"
-#include "CreatureAI.h"
-#include "Battleground.h"
-#include "OutdoorPvPMgr.h"
-#include "Language.h"
-#include "SocialMgr.h"
-#include "Util.h"
-#include "TemporarySummon.h"
#include "GridNotifiers.h"
-#include "CellImpl.h"
-#include "Formulas.h"
-#include "ScriptMgr.h"
-#include "SpellHistory.h"
-#include "GameObjectAI.h"
-#include "AccountMgr.h"
#include "InstanceScript.h"
+#include "Item.h"
+#include "Language.h"
+#include "Log.h"
+#include "LootMgr.h"
+#include "MotionMaster.h"
+#include "ObjectMgr.h"
+#include "Opcodes.h"
+#include "OutdoorPvPMgr.h"
#include "PathGenerator.h"
+#include "Pet.h"
+#include "Player.h"
#include "ReputationMgr.h"
+#include "ScriptMgr.h"
+#include "SkillExtraItems.h"
+#include "SharedDefines.h"
+#include "SocialMgr.h"
+#include "SpellAuraEffects.h"
+#include "SpellAuras.h"
+#include "SpellHistory.h"
+#include "SpellMgr.h"
+#include "TemporarySummon.h"
+#include "Totem.h"
+#include "UpdateMask.h"
+#include "Unit.h"
+#include "Util.h"
+#include "World.h"
+#include "WorldPacket.h"
+#include "WorldSession.h"
pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
{
@@ -282,7 +286,7 @@ void Spell::EffectInstaKill(SpellEffIndex /*effIndex*/)
data << uint32(m_spellInfo->Id);
m_caster->SendMessageToSet(&data, true);
- m_caster->DealDamage(unitTarget, unitTarget->GetHealth(), NULL, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
+ m_caster->DealDamage(unitTarget, unitTarget->GetHealth(), nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
}
void Spell::EffectEnvironmentalDMG(SpellEffIndex /*effIndex*/)
@@ -428,7 +432,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// Calculate damage of Immolate/Shadowflame tick
int32 pdamage = (aura->GetAmount() + aura->GetBonusAmount()) * aura->GetDonePct();
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, pdamage);
+ modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DOT, pdamage);
pdamage = unitTarget->SpellDamageBonusTaken(m_caster, aura->GetSpellInfo(), pdamage, DOT);
@@ -460,7 +464,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
if (AuraEffect* aurEff = owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_WARLOCK, 214, 0))
{
int32 bp0 = aurEff->GetId() == 54037 ? 4 : 8;
- m_caster->CastCustomSpell(m_caster, 54425, &bp0, NULL, NULL, true);
+ m_caster->CastCustomSpell(m_caster, 54425, &bp0, nullptr, nullptr, true);
}
}
}
@@ -880,7 +884,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
}
// original caster guid only for GO cast
- m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, NULL, NULL, m_originalCasterGUID);
+ m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, nullptr, nullptr, m_originalCasterGUID);
}
void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex)
@@ -928,7 +932,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex)
}
// original caster guid only for GO cast
- m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, NULL, NULL, m_originalCasterGUID);
+ m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, nullptr, nullptr, m_originalCasterGUID);
}
void Spell::EffectForceCast(SpellEffIndex effIndex)
@@ -960,7 +964,7 @@ void Spell::EffectForceCast(SpellEffIndex effIndex)
break;
case 52463: // Hide In Mine Car
case 52349: // Overtake
- unitTarget->CastCustomSpell(unitTarget, spellInfo->Id, &damage, NULL, NULL, true, NULL, NULL, m_originalCasterGUID);
+ unitTarget->CastCustomSpell(unitTarget, spellInfo->Id, &damage, nullptr, nullptr, true, nullptr, nullptr, m_originalCasterGUID);
return;
}
}
@@ -968,7 +972,7 @@ void Spell::EffectForceCast(SpellEffIndex effIndex)
switch (spellInfo->Id)
{
case 72298: // Malleable Goo Summon
- unitTarget->CastSpell(unitTarget, spellInfo->Id, true, NULL, NULL, m_originalCasterGUID);
+ unitTarget->CastSpell(unitTarget, spellInfo->Id, true, nullptr, nullptr, m_originalCasterGUID);
return;
}
@@ -1004,7 +1008,7 @@ void Spell::EffectTriggerRitualOfSummoning(SpellEffIndex effIndex)
finish();
- m_caster->CastSpell((Unit*)NULL, spellInfo, false);
+ m_caster->CastSpell((Unit*)nullptr, spellInfo, false);
}
void Spell::EffectJump(SpellEffIndex effIndex)
@@ -1265,7 +1269,7 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex)
&& effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- WorldObject* target = NULL;
+ WorldObject* target = nullptr;
// call events for object target if present
if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET)
@@ -1379,7 +1383,7 @@ void Spell::EffectHeal(SpellEffIndex /*effIndex*/)
{
Unit::AuraEffectList const& RejorRegr = unitTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_HEAL);
// find most short by duration
- AuraEffect* targetAura = NULL;
+ AuraEffect* targetAura = nullptr;
for (Unit::AuraEffectList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i)
{
if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID
@@ -1398,7 +1402,7 @@ void Spell::EffectHeal(SpellEffIndex /*effIndex*/)
int32 tickheal = (targetAura->GetAmount() + targetAura->GetBonusAmount()) * targetAura->GetDonePct();
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DOT>(targetAura->GetId(), tickheal);
+ modOwner->ApplySpellMod(targetAura->GetId(), SPELLMOD_DOT, tickheal);
unitTarget->SpellHealingBonusTaken(m_caster, targetAura->GetSpellInfo(), tickheal, DOT);
@@ -1529,7 +1533,7 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype)
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(newitemid);
if (!pProto)
{
- player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
+ player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
return;
}
@@ -1606,7 +1610,7 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype)
else
{
// if not created by another reason from full inventory or unique items amount limitation
- player->SendEquipError(msg, NULL, NULL, newitemid);
+ player->SendEquipError(msg, nullptr, nullptr, newitemid);
return;
}
}
@@ -1614,12 +1618,12 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype)
if (num_to_add)
{
// create the new item and store it
- Item* pItem = player->StoreNewItem(dest, newitemid, true, Item::GenerateItemRandomPropertyId(newitemid));
+ Item* pItem = player->StoreNewItem(dest, newitemid, true, GenerateItemRandomPropertyId(newitemid));
// was it successful? return error if not
if (!pItem)
{
- player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
+ player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
return;
}
@@ -2054,9 +2058,9 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
// prevent crash at access and unexpected charges counting with item update queue corrupt
if (m_CastItem == m_targets.GetItemTarget())
- m_targets.SetItemTarget(NULL);
+ m_targets.SetItemTarget(nullptr);
- m_CastItem = NULL;
+ m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
@@ -2075,9 +2079,9 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
// prevent crash at access and unexpected charges counting with item update queue corrupt
if (m_CastItem == m_targets.GetItemTarget())
- m_targets.SetItemTarget(NULL);
+ m_targets.SetItemTarget(nullptr);
- m_CastItem = NULL;
+ m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
@@ -2099,9 +2103,9 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
// prevent crash at access and unexpected charges counting with item update queue corrupt
if (m_CastItem == m_targets.GetItemTarget())
- m_targets.SetItemTarget(NULL);
+ m_targets.SetItemTarget(nullptr);
- m_CastItem = NULL;
+ m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
@@ -2160,9 +2164,9 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
int32 duration = m_spellInfo->GetDuration();
if (Player* modOwner = m_originalCaster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DURATION>(m_spellInfo->Id, duration);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
- TempSummon* summon = NULL;
+ TempSummon* summon = nullptr;
// determine how many units should be summoned
uint32 numSummons;
@@ -2444,11 +2448,11 @@ void Spell::EffectDispel(SpellEffIndex effIndex)
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->GetCategory() == SPELLCATEGORY_DEVOUR_MAGIC)
{
int32 heal_amount = m_spellInfo->Effects[EFFECT_1].CalcValue();
- m_caster->CastCustomSpell(m_caster, 19658, &heal_amount, NULL, NULL, true);
+ m_caster->CastCustomSpell(m_caster, 19658, &heal_amount, nullptr, nullptr, true);
// Glyph of Felhunter
if (Unit* owner = m_caster->GetOwner())
if (owner->GetAura(56249))
- owner->CastCustomSpell(owner, 19658, &heal_amount, NULL, NULL, true);
+ owner->CastCustomSpell(owner, 19658, &heal_amount, nullptr, nullptr, true);
}
}
@@ -2594,7 +2598,7 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/)
// not scale value for item based reward (/10 value expected)
if (m_CastItem)
{
- unitTarget->ToPlayer()->RewardHonor(NULL, 1, damage/10);
+ unitTarget->ToPlayer()->RewardHonor(nullptr, 1, damage/10);
TC_LOG_DEBUG("spells", "SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(), unitTarget->ToPlayer()->GetGUID().GetCounter());
return;
}
@@ -2603,13 +2607,13 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/)
if (damage <= 50)
{
uint32 honor_reward = Trinity::Honor::hk_honor_at_level(unitTarget->getLevel(), float(damage));
- unitTarget->ToPlayer()->RewardHonor(NULL, 1, honor_reward);
+ unitTarget->ToPlayer()->RewardHonor(nullptr, 1, honor_reward);
TC_LOG_DEBUG("spells", "SpellEffect::AddHonor (spell_id %u) rewards %u honor points (scale) to player: %u", m_spellInfo->Id, honor_reward, unitTarget->ToPlayer()->GetGUID().GetCounter());
}
else
{
//maybe we have correct honor_gain in damage already
- unitTarget->ToPlayer()->RewardHonor(NULL, 1, damage);
+ unitTarget->ToPlayer()->RewardHonor(nullptr, 1, damage);
TC_LOG_DEBUG("spells", "SpellEffect::AddHonor (spell_id %u) rewards %u honor points (non scale) for player: %u", m_spellInfo->Id, damage, unitTarget->ToPlayer()->GetGUID().GetCounter());
}
}
@@ -2647,8 +2651,8 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
unitTarget = player;
// and add a scroll
DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType);
- itemTarget = NULL;
- m_targets.SetItemTarget(NULL);
+ itemTarget = nullptr;
+ m_targets.SetItemTarget(nullptr);
}
else
{
@@ -2945,7 +2949,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- Player* owner = NULL;
+ Player* owner = nullptr;
if (m_originalCaster)
{
owner = m_originalCaster->ToPlayer();
@@ -3021,7 +3025,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
// generate new name for summon pet
- std::string new_name=sObjectMgr->GeneratePetName(petentry);
+ std::string new_name = sObjectMgr->GeneratePetName(petentry);
if (!new_name.empty())
pet->SetName(new_name);
@@ -3200,7 +3204,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// Skyshatter Harness item set bonus
// Stormstrike
if (AuraEffect* aurEff = m_caster->IsScriptOverriden(m_spellInfo, 5634))
- m_caster->CastSpell(m_caster, 38430, true, NULL, aurEff);
+ m_caster->CastSpell(m_caster, 38430, true, nullptr, aurEff);
break;
}
case SPELLFAMILY_DRUID:
@@ -3463,7 +3467,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
Map* map = target->GetMap();
- G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(target->GetOrientation(), 0.f, 0.f);
+ QuaternionData rot = QuaternionData::fromEulerAnglesZYX(target->GetOrientation(), 0.f, 0.f);
if (!pGameObj->Create(map->GenerateLowGuid<HighGuid::GameObject>(), gameobject_id, map, m_caster->GetPhaseMask(), Position(x, y, z, target->GetOrientation()), rot, 255, GO_STATE_READY))
{
delete pGameObj;
@@ -3550,7 +3554,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
uint32 spell_id = roll_chance_i(20) ? 8854 : 8855;
- m_caster->CastSpell(m_caster, spell_id, true, NULL);
+ m_caster->CastSpell(m_caster, spell_id, true, nullptr);
return;
}
// Brittle Armor - need remove one 24575 Brittle Armor aura
@@ -3631,7 +3635,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
uint8 bag = 19;
uint8 slot = 0;
- Item* item = NULL;
+ Item* item = nullptr;
while (bag) // 256 = 0 due to var type
{
@@ -3859,7 +3863,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
// proc a spellcast
if (Aura* chargesAura = m_caster->GetAura(59907))
{
- m_caster->CastSpell(unitTarget, spell_heal, true, NULL, NULL, m_caster->ToTempSummon()->GetSummonerGUID());
+ m_caster->CastSpell(unitTarget, spell_heal, true, nullptr, nullptr, m_caster->ToTempSummon()->GetSummonerGUID());
if (chargesAura->ModCharges(-1))
m_caster->ToTempSummon()->UnSummon();
}
@@ -3888,14 +3892,14 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
Creature* totem = unitTarget->GetMap()->GetCreature(unitTarget->m_SummonSlot[slot]);
if (totem && totem->IsTotem())
{
- m_caster->CastCustomSpell(totem, 55277, &basepoints0, NULL, NULL, true);
+ m_caster->CastCustomSpell(totem, 55277, &basepoints0, nullptr, nullptr, true);
}
}
// Glyph of Stoneclaw Totem
- if (AuraEffect* aur=unitTarget->GetAuraEffect(63298, 0))
+ if (AuraEffect* aur = unitTarget->GetAuraEffect(63298, 0))
{
basepoints0 *= aur->GetAmount();
- m_caster->CastCustomSpell(unitTarget, 55277, &basepoints0, NULL, NULL, true);
+ m_caster->CastCustomSpell(unitTarget, 55277, &basepoints0, nullptr, nullptr, true);
}
break;
}
@@ -4033,7 +4037,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex)
};
Map* map = m_caster->GetMap();
- G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(pos.GetOrientation(), 0.f, 0.f);
+ QuaternionData rot = QuaternionData::fromEulerAnglesZYX(pos.GetOrientation(), 0.f, 0.f);
if (!pGameObj->Create(map->GenerateLowGuid<HighGuid::GameObject>(), gameobject_id, map, m_caster->GetPhaseMask(), pos, rot, 0, GO_STATE_READY))
{
delete pGameObj;
@@ -4056,8 +4060,8 @@ void Spell::EffectDuel(SpellEffIndex effIndex)
WorldPacket data(SMSG_DUEL_REQUESTED, 8 + 8);
data << uint64(pGameObj->GetGUID());
data << uint64(caster->GetGUID());
- caster->GetSession()->SendPacket(&data);
- target->GetSession()->SendPacket(&data);
+ caster->SendDirectMessage(&data);
+ target->SendDirectMessage(&data);
// create duel-info
DuelInfo* duel = new DuelInfo;
@@ -4334,7 +4338,7 @@ void Spell::EffectFeedPet(SpellEffIndex effIndex)
player->DestroyItemCount(foodItem, count, true);
/// @todo fix crash when a spell has two effects, both pointed at the same item target
- m_caster->CastCustomSpell(pet, m_spellInfo->Effects[effIndex].TriggerSpell, &benefit, NULL, NULL, true);
+ m_caster->CastCustomSpell(pet, m_spellInfo->Effects[effIndex].TriggerSpell, &benefit, nullptr, nullptr, true);
}
void Spell::EffectDismissPet(SpellEffIndex effIndex)
@@ -4382,7 +4386,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex)
m_caster->GetClosePoint(x, y, z, DEFAULT_PLAYER_BOUNDING_RADIUS);
Map* map = m_caster->GetMap();
- G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(m_caster->GetOrientation(), 0.f, 0.f);
+ QuaternionData rot = QuaternionData::fromEulerAnglesZYX(m_caster->GetOrientation(), 0.f, 0.f);
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), go_id, map, m_caster->GetPhaseMask(), Position(x, y, z, m_caster->GetOrientation()), rot, 255, GO_STATE_READY))
{
delete go;
@@ -4633,14 +4637,14 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/)
float speed = G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) ? m_spellInfo->Speed : SPEED_CHARGE;
// Spell is not using explicit target - no generated path
- if (m_preGeneratedPath.GetPathType() == PATHFIND_BLANK)
+ if (m_preGeneratedPath->GetPathType() == PATHFIND_BLANK)
{
//unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetCombatReach(), unitTarget->GetRelativeAngle(m_caster));
m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speed);
}
else
- m_caster->GetMotionMaster()->MoveCharge(m_preGeneratedPath, speed);
+ m_caster->GetMotionMaster()->MoveCharge(*m_preGeneratedPath, speed);
}
if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET)
@@ -4924,7 +4928,7 @@ void Spell::EffectDestroyAllTotems(SpellEffIndex /*effIndex*/)
}
ApplyPct(mana, damage);
if (mana)
- m_caster->CastCustomSpell(m_caster, 39104, &mana, NULL, NULL, true);
+ m_caster->CastCustomSpell(m_caster, 39104, &mana, nullptr, nullptr, true);
}
void Spell::EffectDurabilityDamage(SpellEffIndex effIndex)
@@ -5039,7 +5043,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
GameObject* pGameObj = new GameObject;
Position pos = { fx, fy, fz, m_caster->GetOrientation() };
- G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(m_caster->GetOrientation(), 0.f, 0.f);
+ QuaternionData rot = QuaternionData::fromEulerAnglesZYX(m_caster->GetOrientation(), 0.f, 0.f);
if (!pGameObj->Create(cMap->GenerateLowGuid<HighGuid::GameObject>(), name_id, cMap, m_caster->GetPhaseMask(), pos, rot, 255, GO_STATE_READY))
{
delete pGameObj;
@@ -5569,7 +5573,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
int32 duration = m_spellInfo->GetDuration();
if (Player* modOwner = m_originalCaster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DURATION>(m_spellInfo->Id, duration);
+ modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
//TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
Map* map = caster->GetMap();
@@ -5643,7 +5647,7 @@ void Spell::EffectPlayMusic(SpellEffIndex effIndex)
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(soundid);
- unitTarget->ToPlayer()->GetSession()->SendPacket(&data);
+ unitTarget->ToPlayer()->SendDirectMessage(&data);
}
void Spell::EffectSpecCount(SpellEffIndex /*effIndex*/)
@@ -5773,7 +5777,7 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/)
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item_id);
if (!pProto)
{
- player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
+ player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
return;
}
@@ -5809,10 +5813,8 @@ void Spell::EffectBind(SpellEffIndex effIndex)
player->SetHomebind(homeLoc, areaId);
// binding
- WorldPacket data(SMSG_BINDPOINTUPDATE, 4 + 4 + 4 + 4 + 4);
- data << float(homeLoc.GetPositionX());
- data << float(homeLoc.GetPositionY());
- data << float(homeLoc.GetPositionZ());
+ WorldPacket data(SMSG_BINDPOINTUPDATE, 4 * 3 + 4 + 4);
+ data << TaggedPosition<Position::XYZ>(homeLoc);
data << uint32(homeLoc.GetMapId());
data << uint32(areaId);
player->SendDirectMessage(&data);
diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp
index 599314e2ec4..5401687e3d5 100644
--- a/src/server/game/Spells/SpellHistory.cpp
+++ b/src/server/game/Spells/SpellHistory.cpp
@@ -15,13 +15,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "WorldPacket.h"
#include "SpellHistory.h"
+#include "DatabaseEnv.h"
+#include "Item.h"
+#include "ObjectMgr.h"
+#include "Opcodes.h"
#include "Pet.h"
#include "Player.h"
-#include "SpellInfo.h"
#include "Spell.h"
-#include "Opcodes.h"
+#include "SpellInfo.h"
+#include "SpellMgr.h"
+#include "WorldPacket.h"
SpellHistory::Clock::duration const SpellHistory::InfinityCooldownDelay = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH));
SpellHistory::Clock::duration const SpellHistory::InfinityCooldownDelayCheck = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH / 2));
@@ -308,10 +312,10 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel
if (Player* modOwner = _owner->GetSpellModOwner())
{
if (cooldown >= 0)
- modOwner->ApplySpellMod<SPELLMOD_COOLDOWN>(spellInfo->Id, cooldown, spell);
+ modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, cooldown, spell);
if (categoryCooldown >= 0 && !spellInfo->HasAttribute(SPELL_ATTR6_IGNORE_CATEGORY_COOLDOWN_MODS))
- modOwner->ApplySpellMod<SPELLMOD_COOLDOWN>(spellInfo->Id, categoryCooldown, spell);
+ modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, categoryCooldown, spell);
}
if (int32 cooldownMod = _owner->GetTotalAuraModifier(SPELL_AURA_MOD_COOLDOWN))
diff --git a/src/server/game/Spells/SpellHistory.h b/src/server/game/Spells/SpellHistory.h
index ed1ba883c5b..f45982ced93 100644
--- a/src/server/game/Spells/SpellHistory.h
+++ b/src/server/game/Spells/SpellHistory.h
@@ -19,18 +19,28 @@
#define SpellHistory_h__
#include "SharedDefines.h"
-#include "QueryResult.h"
-#include "Transaction.h"
+#include "DatabaseEnvFwd.h"
#include "GameTime.h"
#include <deque>
+#include <vector>
+#include <unordered_map>
class Item;
class Player;
class Spell;
class SpellInfo;
class Unit;
+class WorldPacket;
struct SpellCategoryEntry;
+/// Spell cooldown flags sent in SMSG_SPELL_COOLDOWN
+enum SpellCooldownFlags
+{
+ SPELL_COOLDOWN_FLAG_NONE = 0x0,
+ SPELL_COOLDOWN_FLAG_INCLUDE_GCD = 0x1, ///< Starts GCD in addition to normal cooldown specified in the packet
+ SPELL_COOLDOWN_FLAG_INCLUDE_EVENT_COOLDOWNS = 0x2 ///< Starts GCD for spells that should start their cooldown on events, requires SPELL_COOLDOWN_FLAG_INCLUDE_GCD set
+};
+
class TC_GAME_API SpellHistory
{
public:
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 8f4f534e076..2a0b972e631 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -15,17 +15,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "SpellAuraDefines.h"
-#include "SpellAuras.h"
#include "SpellInfo.h"
-#include "SpellMgr.h"
-#include "Spell.h"
+#include "Battleground.h"
+#include "Corpse.h"
+#include "Creature.h"
#include "DBCStores.h"
-#include "ConditionMgr.h"
+#include "Item.h"
+#include "ItemTemplate.h"
+#include "Log.h"
+#include "ObjectAccessor.h"
#include "Player.h"
-#include "Battleground.h"
+#include "Random.h"
+#include "Spell.h"
+#include "SpellAuraEffects.h"
+#include "SpellMgr.h"
#include "Vehicle.h"
-#include "Pet.h"
uint32 GetTargetFlagMask(SpellTargetObjectTypes objType)
{
@@ -341,12 +345,12 @@ SpellEffectInfo::SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const*
Mechanic = Mechanics(spellEntry->EffectMechanic[effIndex]);
TargetA = SpellImplicitTargetInfo(spellEntry->EffectImplicitTargetA[effIndex]);
TargetB = SpellImplicitTargetInfo(spellEntry->EffectImplicitTargetB[effIndex]);
- RadiusEntry = spellEntry->EffectRadiusIndex[effIndex] ? sSpellRadiusStore.LookupEntry(spellEntry->EffectRadiusIndex[effIndex]) : NULL;
+ RadiusEntry = spellEntry->EffectRadiusIndex[effIndex] ? sSpellRadiusStore.LookupEntry(spellEntry->EffectRadiusIndex[effIndex]) : nullptr;
ChainTarget = spellEntry->EffectChainTarget[effIndex];
ItemType = spellEntry->EffectItemType[effIndex];
TriggerSpell = spellEntry->EffectTriggerSpell[effIndex];
SpellClassMask = spellEntry->EffectSpellClassMask[effIndex];
- ImplicitTargetConditions = NULL;
+ ImplicitTargetConditions = nullptr;
}
bool SpellEffectInfo::IsEffect() const
@@ -519,22 +523,24 @@ int32 SpellEffectInfo::CalcBaseValue(int32 value) const
float SpellEffectInfo::CalcValueMultiplier(Unit* caster, Spell* spell) const
{
float multiplier = ValueMultiplier;
- if (Player* modOwner = (caster ? caster->GetSpellModOwner() : NULL))
- modOwner->ApplySpellMod<SPELLMOD_VALUE_MULTIPLIER>(_spellInfo->Id, multiplier, spell);
+ if (Player* modOwner = (caster ? caster->GetSpellModOwner() : nullptr))
+ modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_VALUE_MULTIPLIER, multiplier, spell);
+
return multiplier;
}
float SpellEffectInfo::CalcDamageMultiplier(Unit* caster, Spell* spell) const
{
float multiplierPercent = DamageMultiplier * 100.0f;
- if (Player* modOwner = (caster ? caster->GetSpellModOwner() : NULL))
- modOwner->ApplySpellMod<SPELLMOD_DAMAGE_MULTIPLIER>(_spellInfo->Id, multiplierPercent, spell);
+ if (Player* modOwner = (caster ? caster->GetSpellModOwner() : nullptr))
+ modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_DAMAGE_MULTIPLIER, multiplierPercent, spell);
+
return multiplierPercent / 100.0f;
}
bool SpellEffectInfo::HasRadius() const
{
- return RadiusEntry != NULL;
+ return RadiusEntry != nullptr;
}
float SpellEffectInfo::CalcRadius(Unit* caster, Spell* spell) const
@@ -548,7 +554,7 @@ float SpellEffectInfo::CalcRadius(Unit* caster, Spell* spell) const
radius += RadiusEntry->RadiusPerLevel * caster->getLevel();
radius = std::min(radius, RadiusEntry->RadiusMax);
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_RADIUS>(_spellInfo->Id, radius, spell);
+ modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_RADIUS, radius, spell);
}
return radius;
@@ -766,7 +772,7 @@ SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] =
SpellInfo::SpellInfo(SpellEntry const* spellEntry)
{
Id = spellEntry->Id;
- CategoryEntry = spellEntry->Category ? sSpellCategoryStore.LookupEntry(spellEntry->Category) : NULL;
+ CategoryEntry = spellEntry->Category ? sSpellCategoryStore.LookupEntry(spellEntry->Category) : nullptr;
Dispel = spellEntry->Dispel;
Mechanic = spellEntry->Mechanic;
Attributes = spellEntry->Attributes;
@@ -792,7 +798,7 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
TargetAuraSpell = spellEntry->targetAuraSpell;
ExcludeCasterAuraSpell = spellEntry->excludeCasterAuraSpell;
ExcludeTargetAuraSpell = spellEntry->excludeTargetAuraSpell;
- CastTimeEntry = spellEntry->CastingTimeIndex ? sSpellCastTimesStore.LookupEntry(spellEntry->CastingTimeIndex) : NULL;
+ CastTimeEntry = spellEntry->CastingTimeIndex ? sSpellCastTimesStore.LookupEntry(spellEntry->CastingTimeIndex) : nullptr;
RecoveryTime = spellEntry->RecoveryTime;
CategoryRecoveryTime = spellEntry->CategoryRecoveryTime;
StartRecoveryCategory = spellEntry->StartRecoveryCategory;
@@ -806,7 +812,7 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
MaxLevel = spellEntry->maxLevel;
BaseLevel = spellEntry->baseLevel;
SpellLevel = spellEntry->spellLevel;
- DurationEntry = spellEntry->DurationIndex ? sSpellDurationStore.LookupEntry(spellEntry->DurationIndex) : NULL;
+ DurationEntry = spellEntry->DurationIndex ? sSpellDurationStore.LookupEntry(spellEntry->DurationIndex) : nullptr;
PowerType = spellEntry->powerType;
ManaCost = spellEntry->manaCost;
ManaCostPerlevel = spellEntry->manaCostPerlevel;
@@ -814,7 +820,7 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
ManaPerSecondPerLevel = spellEntry->manaPerSecondPerLevel;
ManaCostPercentage = spellEntry->ManaCostPercentage;
RuneCostID = spellEntry->runeCostID;
- RangeEntry = spellEntry->rangeIndex ? sSpellRangeStore.LookupEntry(spellEntry->rangeIndex) : NULL;
+ RangeEntry = spellEntry->rangeIndex ? sSpellRangeStore.LookupEntry(spellEntry->rangeIndex) : nullptr;
Speed = spellEntry->speed;
StackAmount = spellEntry->StackAmount;
for (uint8 i = 0; i < 2; ++i)
@@ -854,7 +860,7 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
Effects[i] = SpellEffectInfo(spellEntry, this, i);
- ChainEntry = NULL;
+ ChainEntry = nullptr;
ExplicitTargetMask = 0;
_spellSpecific = SPELL_SPECIFIC_NORMAL;
@@ -1458,7 +1464,7 @@ SpellCastResult SpellInfo::CheckShapeshift(uint32 form) const
return SPELL_CAST_OK;
bool actAsShifted = false;
- SpellShapeshiftEntry const* shapeInfo = NULL;
+ SpellShapeshiftEntry const* shapeInfo = nullptr;
if (form > 0)
{
shapeInfo = sSpellShapeshiftStore.LookupEntry(form);
@@ -3064,7 +3070,8 @@ float SpellInfo::GetMaxRange(bool positive, Unit* caster, Spell* spell) const
range = RangeEntry->maxRangeHostile;
if (caster)
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_RANGE>(Id, range, spell);
+ modOwner->ApplySpellMod(Id, SPELLMOD_RANGE, range, spell);
+
return range;
}
@@ -3082,7 +3089,7 @@ int32 SpellInfo::GetMaxDuration() const
return (DurationEntry->Duration[2] == -1) ? -1 : abs(DurationEntry->Duration[2]);
}
-uint32 SpellInfo::CalcCastTime(Spell* spell /*= NULL*/) const
+uint32 SpellInfo::CalcCastTime(Spell* spell /*= nullptr*/) const
{
// not all spells have cast time index and this is all is pasiive abilities
if (!CastTimeEntry)
@@ -3204,7 +3211,7 @@ int32 SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask, S
// Apply cost mod by spell
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_COST>(Id, powerCost, spell);
+ modOwner->ApplySpellMod(Id, SPELLMOD_COST, powerCost, spell);
if (!caster->IsControlledByPlayer())
{
@@ -3226,7 +3233,7 @@ int32 SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask, S
bool SpellInfo::IsRanked() const
{
- return ChainEntry != NULL;
+ return ChainEntry != nullptr;
}
uint8 SpellInfo::GetRank() const
@@ -3245,19 +3252,19 @@ SpellInfo const* SpellInfo::GetFirstRankSpell() const
SpellInfo const* SpellInfo::GetLastRankSpell() const
{
if (!ChainEntry)
- return NULL;
+ return nullptr;
return ChainEntry->last;
}
SpellInfo const* SpellInfo::GetNextRankSpell() const
{
if (!ChainEntry)
- return NULL;
+ return nullptr;
return ChainEntry->next;
}
SpellInfo const* SpellInfo::GetPrevRankSpell() const
{
if (!ChainEntry)
- return NULL;
+ return nullptr;
return ChainEntry->prev;
}
@@ -3288,7 +3295,7 @@ SpellInfo const* SpellInfo::GetAuraRankForLevel(uint8 level) const
if (!needRankSelection)
return this;
- for (SpellInfo const* nextSpellInfo = this; nextSpellInfo != NULL; nextSpellInfo = nextSpellInfo->GetPrevRankSpell())
+ for (SpellInfo const* nextSpellInfo = this; nextSpellInfo != nullptr; nextSpellInfo = nextSpellInfo->GetPrevRankSpell())
{
// if found appropriate level
if (uint32(level + 10) >= nextSpellInfo->SpellLevel)
@@ -3298,7 +3305,7 @@ SpellInfo const* SpellInfo::GetAuraRankForLevel(uint8 level) const
}
// not found
- return NULL;
+ return nullptr;
}
bool SpellInfo::IsRankOf(SpellInfo const* spellInfo) const
@@ -3670,7 +3677,7 @@ void SpellInfo::_UnloadImplicitTargetConditionLists()
for (uint8 j = i; j < MAX_SPELL_EFFECTS; ++j)
{
if (Effects[j].ImplicitTargetConditions == cur)
- Effects[j].ImplicitTargetConditions = NULL;
+ Effects[j].ImplicitTargetConditions = nullptr;
}
delete cur;
}
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 483605a1212..8f2f97722df 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -42,7 +42,7 @@ struct SpellEntry;
struct SpellCastTimesEntry;
struct Condition;
-enum SpellCastTargetFlags
+enum SpellCastTargetFlags : uint32
{
TARGET_FLAG_NONE = 0x00000000,
TARGET_FLAG_UNUSED_1 = 0x00000001, // not used
@@ -95,7 +95,7 @@ enum SpellTargetReferenceTypes
TARGET_REFERENCE_TYPE_DEST
};
-enum SpellTargetObjectTypes
+enum SpellTargetObjectTypes : uint8
{
TARGET_OBJECT_TYPE_NONE = 0,
TARGET_OBJECT_TYPE_SRC,
@@ -111,7 +111,7 @@ enum SpellTargetObjectTypes
TARGET_OBJECT_TYPE_CORPSE_ALLY
};
-enum SpellTargetCheckTypes
+enum SpellTargetCheckTypes : uint8
{
TARGET_CHECK_DEFAULT,
TARGET_CHECK_ENTRY,
@@ -259,10 +259,10 @@ public:
flag96 SpellClassMask;
std::vector<Condition*>* ImplicitTargetConditions;
- SpellEffectInfo() : _spellInfo(NULL), _effIndex(0), Effect(0), ApplyAuraName(0), Amplitude(0), DieSides(0),
+ SpellEffectInfo() : _spellInfo(nullptr), _effIndex(0), Effect(0), ApplyAuraName(0), Amplitude(0), DieSides(0),
RealPointsPerLevel(0), BasePoints(0), PointsPerComboPoint(0), ValueMultiplier(0), DamageMultiplier(0),
- BonusMultiplier(0), MiscValue(0), MiscValueB(0), Mechanic(MECHANIC_NONE), RadiusEntry(NULL), ChainTarget(0),
- ItemType(0), TriggerSpell(0), ImplicitTargetConditions(NULL) {}
+ BonusMultiplier(0), MiscValue(0), MiscValueB(0), Mechanic(MECHANIC_NONE), RadiusEntry(nullptr), ChainTarget(0),
+ ItemType(0), TriggerSpell(0), ImplicitTargetConditions(nullptr) {}
SpellEffectInfo(SpellEntry const* spellEntry, SpellInfo const* spellInfo, uint8 effIndex);
bool IsEffect() const;
@@ -275,13 +275,13 @@ public:
bool IsFarDestTargetEffect() const;
bool IsUnitOwnedAuraEffect() const;
- int32 CalcValue(Unit const* caster = NULL, int32 const* basePoints = NULL, Unit const* target = NULL) const;
+ int32 CalcValue(Unit const* caster = nullptr, int32 const* basePoints = nullptr, Unit const* target = nullptr) const;
int32 CalcBaseValue(int32 value) const;
- float CalcValueMultiplier(Unit* caster, Spell* spell = NULL) const;
- float CalcDamageMultiplier(Unit* caster, Spell* spell = NULL) const;
+ float CalcValueMultiplier(Unit* caster, Spell* spell = nullptr) const;
+ float CalcDamageMultiplier(Unit* caster, Spell* spell = nullptr) const;
bool HasRadius() const;
- float CalcRadius(Unit* caster = NULL, Spell* = NULL) const;
+ float CalcRadius(Unit* caster = nullptr, Spell* = nullptr) const;
uint32 GetProvidedTargetMask() const;
uint32 GetMissingTargetMask(bool srcSet = false, bool destSet = false, uint32 mask = 0) const;
@@ -476,7 +476,7 @@ class TC_GAME_API SpellInfo
SpellCastResult CheckShapeshift(uint32 form) const;
SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = nullptr, bool strict = true) const;
SpellCastResult CheckTarget(Unit const* caster, WorldObject const* target, bool implicit = true) const;
- SpellCastResult CheckExplicitTarget(Unit const* caster, WorldObject const* target, Item const* itemTarget = NULL) const;
+ SpellCastResult CheckExplicitTarget(Unit const* caster, WorldObject const* target, Item const* itemTarget = nullptr) const;
SpellCastResult CheckVehicle(Unit const* caster) const;
bool CheckTargetCreatureType(Unit const* target) const;
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index a14eddcc383..e0800b2782d 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -17,17 +17,21 @@
*/
#include "SpellMgr.h"
-#include "SpellInfo.h"
-#include "Spell.h"
-#include "ObjectMgr.h"
-#include "SpellAuraDefines.h"
-#include "SharedDefines.h"
-#include "DBCStores.h"
-#include "Chat.h"
-#include "BattlegroundMgr.h"
-#include "BattlefieldWG.h"
#include "BattlefieldMgr.h"
+#include "BattlefieldWG.h"
+#include "BattlegroundMgr.h"
+#include "Chat.h"
+#include "DatabaseEnv.h"
+#include "DBCStores.h"
+#include "Log.h"
+#include "Map.h"
+#include "MotionMaster.h"
+#include "ObjectMgr.h"
#include "Player.h"
+#include "SharedDefines.h"
+#include "Spell.h"
+#include "SpellAuraDefines.h"
+#include "SpellInfo.h"
bool IsPrimaryProfessionSkill(uint32 skill)
{
@@ -215,7 +219,7 @@ uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Unit const* caster) con
SpellInfo const* SpellMgr::GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit const* caster) const
{
if (!spell)
- return NULL;
+ return nullptr;
uint32 newSpellId = GetSpellIdForDifficulty(spell->Id, caster);
SpellInfo const* newSpell = GetSpellInfo(newSpellId);
@@ -233,7 +237,7 @@ SpellChainNode const* SpellMgr::GetSpellChainNode(uint32 spell_id) const
{
SpellChainMap::const_iterator itr = mSpellChains.find(spell_id);
if (itr == mSpellChains.end())
- return NULL;
+ return nullptr;
return &itr->second;
}
@@ -319,7 +323,7 @@ SpellLearnSkillNode const* SpellMgr::GetSpellLearnSkill(uint32 spell_id) const
if (itr != mSpellLearnSkills.end())
return &itr->second;
else
- return NULL;
+ return nullptr;
}
SpellLearnSpellMapBounds SpellMgr::GetSpellLearnSpellMapBounds(uint32 spell_id) const
@@ -346,7 +350,7 @@ SpellTargetPosition const* SpellMgr::GetSpellTargetPosition(uint32 spell_id, Spe
SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find(std::make_pair(spell_id, effIndex));
if (itr != mSpellTargetPositions.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
SpellSpellGroupMapBounds SpellMgr::GetSpellSpellGroupMapBounds(uint32 spell_id) const
@@ -493,7 +497,7 @@ SpellProcEntry const* SpellMgr::GetSpellProcEntry(uint32 spellId) const
SpellProcMap::const_iterator itr = mSpellProcMap.find(spellId);
if (itr != mSpellProcMap.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
bool SpellMgr::CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo)
@@ -591,7 +595,7 @@ SpellBonusEntry const* SpellMgr::GetSpellBonusData(uint32 spellId) const
if (itr2 != mSpellBonusMap.end())
return &itr2->second;
}
- return NULL;
+ return nullptr;
}
SpellThreatEntry const* SpellMgr::GetSpellThreatEntry(uint32 spellID) const
@@ -606,7 +610,7 @@ SpellThreatEntry const* SpellMgr::GetSpellThreatEntry(uint32 spellID) const
if (itr != mSpellThreatMap.end())
return &itr->second;
}
- return NULL;
+ return nullptr;
}
SkillLineAbilityMapBounds SpellMgr::GetSkillLineAbilityMapBounds(uint32 spell_id) const
@@ -620,7 +624,7 @@ PetAura const* SpellMgr::GetPetAura(uint32 spell_id, uint8 eff) const
if (itr != mSpellPetAuraMap.end())
return &itr->second;
else
- return NULL;
+ return nullptr;
}
SpellEnchantProcEntry const* SpellMgr::GetSpellEnchantProcEvent(uint32 enchId) const
@@ -628,7 +632,7 @@ SpellEnchantProcEntry const* SpellMgr::GetSpellEnchantProcEvent(uint32 enchId) c
SpellEnchantProcEventMap::const_iterator itr = mSpellEnchantProcEventMap.find(enchId);
if (itr != mSpellEnchantProcEventMap.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
bool SpellMgr::IsArenaAllowedEnchancment(uint32 ench_id) const
@@ -639,7 +643,7 @@ bool SpellMgr::IsArenaAllowedEnchancment(uint32 ench_id) const
const std::vector<int32>* SpellMgr::GetSpellLinked(int32 spell_id) const
{
SpellLinkedMap::const_iterator itr = mSpellLinkedMap.find(spell_id);
- return itr != mSpellLinkedMap.end() ? &(itr->second) : NULL;
+ return itr != mSpellLinkedMap.end() ? &(itr->second) : nullptr;
}
PetLevelupSpellSet const* SpellMgr::GetPetLevelupSpellList(uint32 petFamily) const
@@ -648,7 +652,7 @@ PetLevelupSpellSet const* SpellMgr::GetPetLevelupSpellList(uint32 petFamily) con
if (itr != mPetLevelupSpellMap.end())
return &itr->second;
else
- return NULL;
+ return nullptr;
}
PetDefaultSpellsEntry const* SpellMgr::GetPetDefaultSpellsEntry(int32 id) const
@@ -656,7 +660,7 @@ PetDefaultSpellsEntry const* SpellMgr::GetPetDefaultSpellsEntry(int32 id) const
PetDefaultSpellsMap::const_iterator itr = mPetDefaultSpellsMap.find(id);
if (itr != mPetDefaultSpellsMap.end())
return &itr->second;
- return NULL;
+ return nullptr;
}
SpellAreaMapBounds SpellMgr::GetSpellAreaMapBounds(uint32 spell_id) const
@@ -794,7 +798,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
void SpellMgr::UnloadSpellInfoChains()
{
for (SpellChainMap::iterator itr = mSpellChains.begin(); itr != mSpellChains.end(); ++itr)
- mSpellInfoMap[itr->first]->ChainEntry = NULL;
+ mSpellInfoMap[itr->first]->ChainEntry = nullptr;
mSpellChains.clear();
}
@@ -810,7 +814,7 @@ void SpellMgr::LoadSpellTalentRanks()
if (!talentInfo)
continue;
- SpellInfo const* lastSpell = NULL;
+ SpellInfo const* lastSpell = nullptr;
for (uint8 rank = MAX_TALENT_RANK - 1; rank > 0; --rank)
{
if (talentInfo->RankID[rank])
@@ -830,7 +834,7 @@ void SpellMgr::LoadSpellTalentRanks()
continue;
}
- SpellInfo const* prevSpell = NULL;
+ SpellInfo const* prevSpell = nullptr;
for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
{
uint32 spellId = talentInfo->RankID[rank];
@@ -850,7 +854,7 @@ void SpellMgr::LoadSpellTalentRanks()
node.rank = rank + 1;
node.prev = prevSpell;
- node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->RankID[node.rank]) : NULL;
+ node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->RankID[node.rank]) : nullptr;
mSpellChains[spellId] = node;
mSpellInfoMap[spellId]->ChainEntry = &mSpellChains[spellId];
@@ -963,7 +967,7 @@ void SpellMgr::LoadSpellRanks()
if (itr == rankChain.end())
{
- mSpellChains[addedSpell].next = NULL;
+ mSpellChains[addedSpell].next = nullptr;
break;
}
else
@@ -2224,7 +2228,7 @@ bool LoadPetDefaultSpells_helper(CreatureTemplate const* cInfo, PetDefaultSpells
return false;
// remove duplicates with levelupSpells if any
- if (PetLevelupSpellSet const* levelupSpells = cInfo->family ? sSpellMgr->GetPetLevelupSpellList(cInfo->family) : NULL)
+ if (PetLevelupSpellSet const* levelupSpells = cInfo->family ? sSpellMgr->GetPetLevelupSpellList(cInfo->family) : nullptr)
{
for (uint8 j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
{
@@ -2533,11 +2537,10 @@ void SpellMgr::LoadSpellInfoStore()
uint32 oldMSTime = getMSTime();
UnloadSpellInfoStore();
- mSpellInfoMap.resize(sSpellStore.GetNumRows(), NULL);
+ mSpellInfoMap.resize(sSpellStore.GetNumRows(), nullptr);
- for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)
- if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(i))
- mSpellInfoMap[i] = new SpellInfo(spellEntry);
+ for (SpellEntry const* spellEntry : sSpellStore)
+ mSpellInfoMap[spellEntry->Id] = new SpellInfo(spellEntry);
TC_LOG_INFO("server.loading", ">> Loaded SpellInfo store in %u ms", GetMSTimeDiffToNow(oldMSTime));
}
@@ -2561,7 +2564,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
{
uint32 oldMSTime = getMSTime();
uint32 oldMSTime2 = oldMSTime;
- SpellInfo* spellInfo = NULL;
+ SpellInfo* spellInfo = nullptr;
QueryResult result = WorldDatabase.Query("SELECT entry, attributes FROM spell_custom_attr");
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index 1696a353ee0..c9fb69a8eb2 100644
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -22,7 +22,7 @@
// For static or at-server-startup loaded spell data
#include "Define.h"
-#include "DBCStructure.h"
+#include "Duration.h"
#include "SharedDefines.h"
#include "Util.h"
@@ -30,6 +30,7 @@
#include <set>
#include <vector>
#include <unordered_map>
+#include <unordered_set>
class SpellInfo;
class Player;
@@ -586,7 +587,7 @@ class TC_GAME_API SpellMgr
static SpellMgr* instance();
// Spell correctness for client using
- static bool IsSpellValid(SpellInfo const* spellInfo, Player* player = NULL, bool msg = true);
+ static bool IsSpellValid(SpellInfo const* spellInfo, Player* player = nullptr, bool msg = true);
// Spell difficulty
uint32 GetSpellDifficultyId(uint32 spellId) const;
@@ -662,7 +663,7 @@ class TC_GAME_API SpellMgr
SpellAreaForQuestAreaMapBounds GetSpellAreaForQuestAreaMapBounds(uint32 area_id, uint32 quest_id) const;
// SpellInfo object management
- SpellInfo const* GetSpellInfo(uint32 spellId) const { return spellId < GetSpellInfoStoreSize() ? mSpellInfoMap[spellId] : NULL; }
+ SpellInfo const* GetSpellInfo(uint32 spellId) const { return spellId < GetSpellInfoStoreSize() ? mSpellInfoMap[spellId] : nullptr; }
// Use this only with 100% valid spellIds
SpellInfo const* AssertSpellInfo(uint32 spellId) const
{
@@ -674,7 +675,7 @@ class TC_GAME_API SpellMgr
uint32 GetSpellInfoStoreSize() const { return mSpellInfoMap.size(); }
private:
- SpellInfo* _GetSpellInfo(uint32 spellId) { return spellId < GetSpellInfoStoreSize() ? mSpellInfoMap[spellId] : NULL; }
+ SpellInfo* _GetSpellInfo(uint32 spellId) { return spellId < GetSpellInfoStoreSize() ? mSpellInfoMap[spellId] : nullptr; }
// Modifiers
public:
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index 32aad8a11ed..3750cae08ef 100644
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -15,12 +15,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "SpellScript.h"
+#include "Log.h"
#include "Spell.h"
#include "ScriptMgr.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
-#include "SpellScript.h"
#include "SpellMgr.h"
+#include <sstream>
#include <string>
bool _SpellScript::_Validate(SpellInfo const* entry)
@@ -33,18 +35,20 @@ bool _SpellScript::_Validate(SpellInfo const* entry)
return true;
}
-bool _SpellScript::ValidateSpellInfo(std::vector<uint32> const& spellIds)
+bool _SpellScript::_ValidateSpellInfo(uint32 const* begin, uint32 const* end)
{
- for (uint32 spellId : spellIds)
+ bool allValid = true;
+ while (begin != end)
{
- if (!sSpellMgr->GetSpellInfo(spellId))
+ if (!sSpellMgr->GetSpellInfo(*begin))
{
- TC_LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell %u does not exist.", spellId);
- return false;
+ TC_LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell %u does not exist.", *begin);
+ allValid = false;
}
- }
- return true;
+ ++begin;
+ }
+ return allValid;
}
void _SpellScript::_Register()
@@ -422,7 +426,7 @@ WorldLocation const* SpellScript::GetExplTargetDest()
{
if (m_spell->m_targets.HasDst())
return m_spell->m_targets.GetDstPos();
- return NULL;
+ return nullptr;
}
void SpellScript::SetExplTargetDest(WorldLocation& loc)
@@ -455,7 +459,7 @@ Unit* SpellScript::GetHitUnit()
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitUnit was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->unitTarget;
}
@@ -465,12 +469,12 @@ Creature* SpellScript::GetHitCreature()
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitCreature was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
if (m_spell->unitTarget)
return m_spell->unitTarget->ToCreature();
else
- return NULL;
+ return nullptr;
}
Player* SpellScript::GetHitPlayer()
@@ -478,12 +482,12 @@ Player* SpellScript::GetHitPlayer()
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitPlayer was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
if (m_spell->unitTarget)
return m_spell->unitTarget->ToPlayer();
else
- return NULL;
+ return nullptr;
}
Item* SpellScript::GetHitItem()
@@ -491,7 +495,7 @@ Item* SpellScript::GetHitItem()
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitItem was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->itemTarget;
}
@@ -501,7 +505,7 @@ GameObject* SpellScript::GetHitGObj()
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitGObj was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->gameObjTarget;
}
@@ -511,7 +515,7 @@ WorldLocation* SpellScript::GetHitDest()
if (!IsInEffectHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitDest was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
return m_spell->destTarget;
}
@@ -561,12 +565,12 @@ Aura* SpellScript::GetHitAura()
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitAura was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
- return NULL;
+ return nullptr;
}
if (!m_spell->m_spellAura)
- return NULL;
+ return nullptr;
if (m_spell->m_spellAura->IsRemoved())
- return NULL;
+ return nullptr;
return m_spell->m_spellAura;
}
@@ -941,7 +945,7 @@ void AuraScript::EffectProcHandler::Call(AuraScript* auraScript, AuraEffect cons
bool AuraScript::_Load(Aura* aura)
{
m_aura = aura;
- _PrepareScriptCall((AuraScriptHookType)SPELL_SCRIPT_STATE_LOADING, NULL);
+ _PrepareScriptCall((AuraScriptHookType)SPELL_SCRIPT_STATE_LOADING, nullptr);
bool load = Load();
_FinishScriptCall();
return load;
@@ -1189,7 +1193,7 @@ Unit* AuraScript::GetTarget() const
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u` AuraScript::GetTarget called in a hook in which the call won't have effect!", m_scriptName->c_str(), m_scriptSpellId);
}
- return NULL;
+ return nullptr;
}
AuraApplication const* AuraScript::GetTargetApplication() const
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 330727cdc1e..03f06961a4b 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -18,27 +18,34 @@
#ifndef __SPELL_SCRIPT_H
#define __SPELL_SCRIPT_H
-#include "Util.h"
+#include "ObjectGuid.h"
#include "SharedDefines.h"
#include "SpellAuraDefines.h"
-#include "Spell.h"
-#include "ScriptReloadMgr.h"
+#include "Util.h"
+#include <memory>
#include <stack>
-class Unit;
-class SpellInfo;
-class SpellScript;
-class Spell;
class Aura;
+class AuraApplication;
class AuraEffect;
-struct SpellModifier;
class Creature;
-class GameObject;
+class DamageInfo;
+class DispelInfo;
class DynamicObject;
-class Player;
+class GameObject;
class Item;
+class ModuleReference;
+class Player;
+class ProcEventInfo;
+class Spell;
+class SpellInfo;
+class SpellScript;
+class Unit;
class WorldLocation;
class WorldObject;
+struct SpellDestination;
+struct SpellModifier;
+struct SpellValue;
#define SPELL_EFFECT_ANY (uint16)-1
#define SPELL_AURA_ANY (uint16)-1
@@ -61,7 +68,7 @@ class TC_GAME_API _SpellScript
virtual bool _Validate(SpellInfo const* entry);
public:
- _SpellScript() : m_currentScriptState(SPELL_SCRIPT_STATE_NONE), m_scriptName(NULL), m_scriptSpellId(0) {}
+ _SpellScript() : m_currentScriptState(SPELL_SCRIPT_STATE_NONE), m_scriptName(nullptr), m_scriptSpellId(0) {}
virtual ~_SpellScript() { }
void _Register();
void _Unload();
@@ -133,7 +140,19 @@ class TC_GAME_API _SpellScript
// use for: deallocating memory allocated by script
virtual void Unload() { }
// Helpers
- static bool ValidateSpellInfo(std::vector<uint32> const& spellIds);
+ static bool ValidateSpellInfo(std::initializer_list<uint32> spellIds)
+ {
+ return _ValidateSpellInfo(spellIds.begin(), spellIds.end());
+ }
+
+ template <class T>
+ static bool ValidateSpellInfo(T const& spellIds)
+ {
+ return _ValidateSpellInfo(std::begin(spellIds), std::end(spellIds));
+ }
+
+ private:
+ static bool _ValidateSpellInfo(uint32 const* begin, uint32 const* end);
};
// SpellScript interface - enum used for runtime checks of script function calls
@@ -657,11 +676,11 @@ class TC_GAME_API AuraScript : public _SpellScript
#define PrepareAuraScript(CLASSNAME) AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
public:
- AuraScript() : _SpellScript(), m_aura(NULL), m_auraApplication(NULL), m_defaultActionPrevented(false)
+ AuraScript() : _SpellScript(), m_aura(nullptr), m_auraApplication(nullptr), m_defaultActionPrevented(false)
{ }
bool _Validate(SpellInfo const* entry) override;
bool _Load(Aura* aura);
- void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const* aurApp = NULL);
+ void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const* aurApp = nullptr);
void _FinishScriptCall();
bool _IsDefaultActionPrevented();
private: