aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellEffects.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rw-r--r--src/server/game/Spells/SpellEffects.cpp107
1 files changed, 55 insertions, 52 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index c5bf99c2f43..b8e0c872f8e 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -505,9 +505,9 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// Eviscerate
else if (m_spellInfo->SpellFamilyFlags[0] & 0x00020000)
{
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = m_caster->ToPlayer())
{
- if (uint32 combo = ((Player*)m_caster)->GetComboPoints())
+ if (uint32 combo = player->GetComboPoints())
{
float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK);
damage += irand(int32(ap * combo * 0.03f), int32(ap * combo * 0.07f));
@@ -2553,30 +2553,30 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
- return;
if (!itemTarget)
return;
- Player* p_caster = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
// Handle vellums
if (itemTarget->IsVellum())
{
// destroy one vellum from stack
uint32 count = 1;
- p_caster->DestroyItemCount(itemTarget, count, true);
- unitTarget=p_caster;
+ player->DestroyItemCount(itemTarget, count, true);
+ unitTarget = player;
// and add a scroll
DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType);
- itemTarget=NULL;
+ itemTarget = NULL;
m_targets.SetItemTarget(NULL);
}
else
{
// do not increase skill if vellum used
if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST))
- p_caster->UpdateCraftSkill(m_spellInfo->Id);
+ player->UpdateCraftSkill(m_spellInfo->Id);
uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
if (!enchant_id)
@@ -2591,10 +2591,10 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (!item_owner)
return;
- if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
+ if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
{
- sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
- p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(),
+ sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
+ player->GetName().c_str(), player->GetSession()->GetAccountId(),
itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(),
item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
}
@@ -2617,19 +2617,19 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
- return;
if (!itemTarget)
return;
- Player* p_caster = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
- uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
- if (!enchant_id)
+ uint32 enchantId = m_spellInfo->Effects[effIndex].MiscValue;
+ if (!enchantId)
return;
- SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
- if (!pEnchant)
+ SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
+ if (!enchant)
return;
// support only enchantings with add socket in this slot
@@ -2637,7 +2637,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
bool add_socket = false;
for (uint8 i = 0; i < MAX_ITEM_ENCHANTMENT_EFFECTS; ++i)
{
- if (pEnchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET)
+ if (enchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET)
{
add_socket = true;
break;
@@ -2656,10 +2656,10 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
if (!item_owner)
return;
- if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
+ if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
{
- sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
- p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(),
+ sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
+ player->GetName().c_str(), player->GetSession()->GetAccountId(),
itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(),
item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
}
@@ -2667,7 +2667,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
// remove old enchanting before applying new if equipped
item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, false);
- itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchant_id, 0, 0, m_caster->GetGUID());
+ itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchantId, 0, 0, m_caster->GetGUID());
// add new enchanting if equipped
item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true);
@@ -2681,11 +2681,10 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return;
- Player* p_caster = (Player*)m_caster;
-
if (!itemTarget)
return;
@@ -2738,10 +2737,10 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
if (!item_owner)
return;
- if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
+ if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
{
- sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
- p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(),
+ sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
+ player->GetName().c_str(), player->GetSession()->GetAccountId(),
itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(),
item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
}
@@ -4096,21 +4095,20 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER)
- return;
-
if (!sWorld->getBoolConfig(CONFIG_CAST_UNSTUCK))
return;
- Player* target = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Spell Effect: Stuck");
- TC_LOG_INFO(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", target->GetName().c_str(), target->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
+ TC_LOG_INFO(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", player->GetName().c_str(), player->GetGUIDLow(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
- if (target->IsInFlight())
+ if (player->IsInFlight())
return;
- target->TeleportTo(target->GetStartPosition(), TELE_TO_SPELL);
+ player->TeleportTo(player->GetStartPosition(), TELE_TO_SPELL);
// homebind location is loaded always
// target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation(), (m_caster == m_caster ? TELE_TO_SPELL : 0));
@@ -4118,7 +4116,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(8690);
if (!spellInfo)
return;
- Spell spell(target, spellInfo, TRIGGERED_FULL_MASK);
+ Spell spell(player, spellInfo, TRIGGERED_FULL_MASK);
spell.SendSpellCooldown();
}
@@ -4168,10 +4166,12 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
+ if (m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
return;
- Player* player = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
// glyph sockets level requirement
uint8 minLevel = 0;
@@ -5111,10 +5111,10 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return;
- Player* p_caster = (Player*)m_caster;
if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE))
return;
@@ -5123,12 +5123,12 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/)
if (sWorld->getBoolConfig(CONFIG_SKILL_PROSPECTING))
{
- uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_JEWELCRAFTING);
+ uint32 SkillValue = player->GetPureSkillValue(SKILL_JEWELCRAFTING);
uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank;
- p_caster->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue);
+ player->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue);
}
- m_caster->ToPlayer()->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING);
+ player->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING);
}
void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
@@ -5136,10 +5136,10 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return;
- Player* p_caster = (Player*)m_caster;
if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_MILLABLE))
return;
@@ -5148,12 +5148,12 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
if (sWorld->getBoolConfig(CONFIG_SKILL_MILLING))
{
- uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_INSCRIPTION);
+ uint32 SkillValue = player->GetPureSkillValue(SKILL_INSCRIPTION);
uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank;
- p_caster->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue);
+ player->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue);
}
- m_caster->ToPlayer()->SendLoot(itemTarget->GetGUID(), LOOT_MILLING);
+ player->SendLoot(itemTarget->GetGUID(), LOOT_MILLING);
}
void Spell::EffectSkill(SpellEffIndex /*effIndex*/)
@@ -5193,10 +5193,13 @@ void Spell::EffectSkinPlayerCorpse(SpellEffIndex /*effIndex*/)
return;
TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Effect: SkinPlayerCorpse");
- if ((m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->IsAlive()))
+
+ Player* player = m_caster->ToPlayer();
+ Player* target = unitTarget->ToPlayer();
+ if (!player || !target || target->IsAlive())
return;
- unitTarget->ToPlayer()->RemovedInsignia((Player*)m_caster);
+ target->RemovedInsignia(player);
}
void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex)