mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Some cleanup in the first half of Spell.cpp.
This commit is contained in:
@@ -62,8 +62,7 @@ bool IsQuestTameSpell(uint32 spellId)
|
||||
SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId);
|
||||
if (!spellproto) return false;
|
||||
|
||||
return spellproto->Effect[0] == SPELL_EFFECT_THREAT
|
||||
&& spellproto->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[1] == SPELL_AURA_DUMMY;
|
||||
return spellproto->Effect[0] == SPELL_EFFECT_THREAT && spellproto->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[1] == SPELL_AURA_DUMMY;
|
||||
}
|
||||
|
||||
SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0)
|
||||
@@ -219,9 +218,7 @@ void SpellCastTargets::setCorpseTarget(Corpse* corpse)
|
||||
void SpellCastTargets::Update(Unit* caster)
|
||||
{
|
||||
m_GOTarget = m_GOTargetGUID ? caster->GetMap()->GetGameObject(m_GOTargetGUID) : NULL;
|
||||
m_unitTarget = m_unitTargetGUID ?
|
||||
(m_unitTargetGUID == caster->GetGUID() ? caster : ObjectAccessor::GetUnit(*caster, m_unitTargetGUID)) :
|
||||
NULL;
|
||||
m_unitTarget = m_unitTargetGUID ? (m_unitTargetGUID == caster->GetGUID() ? caster : ObjectAccessor::GetUnit(*caster, m_unitTargetGUID)) : NULL;
|
||||
|
||||
m_itemTarget = NULL;
|
||||
if (caster->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -237,6 +234,7 @@ void SpellCastTargets::Update(Unit* caster)
|
||||
if (m_itemTarget)
|
||||
m_itemTargetEntry = m_itemTarget->GetEntry();
|
||||
}
|
||||
|
||||
// update positions by transport move
|
||||
if (HasSrc() && m_srcTransGUID)
|
||||
{
|
||||
@@ -246,6 +244,7 @@ void SpellCastTargets::Update(Unit* caster)
|
||||
m_srcPos.RelocateOffset(m_srcTransOffset);
|
||||
}
|
||||
}
|
||||
|
||||
if (HasDst() && m_dstTransGUID)
|
||||
{
|
||||
if (WorldObject * transport = ObjectAccessor::GetWorldObject(*caster, m_dstTransGUID))
|
||||
@@ -262,45 +261,25 @@ void SpellCastTargets::OutDebug()
|
||||
sLog->outString("TARGET_FLAG_SELF");
|
||||
|
||||
if (m_targetMask & TARGET_FLAG_UNIT)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_UNIT: " UI64FMTD, m_unitTargetGUID);
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_UNK17)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_UNK17: " UI64FMTD, m_unitTargetGUID);
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_OBJECT)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_OBJECT: " UI64FMTD, m_GOTargetGUID);
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_CORPSE)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_CORPSE: " UI64FMTD, m_CorpseTargetGUID);
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_PVP_CORPSE)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_PVP_CORPSE: " UI64FMTD, m_CorpseTargetGUID);
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_ITEM)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_ITEM: " UI64FMTD, m_itemTargetGUID);
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_TRADE_ITEM)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_TRADE_ITEM: " UI64FMTD, m_itemTargetGUID);
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_SOURCE_LOCATION: transport guid:" UI64FMTD " trans offset: %s position: %s", m_srcTransGUID, m_srcTransOffset.ToString().c_str(), m_srcPos.ToString().c_str());
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_DEST_LOCATION: transport guid:" UI64FMTD " trans offset: %s position: %s", m_dstTransGUID, m_dstTransOffset.ToString().c_str(), m_dstPos.ToString().c_str());
|
||||
}
|
||||
if (m_targetMask & TARGET_FLAG_STRING)
|
||||
{
|
||||
sLog->outString("TARGET_FLAG_STRING: %s", m_strTarget.c_str());
|
||||
}
|
||||
sLog->outString("speed: %f", m_speed);
|
||||
sLog->outString("elevation: %f", m_elevation);
|
||||
}
|
||||
@@ -463,14 +442,10 @@ m_caster(Caster), m_spellValue(new SpellValue(m_spellInfo))
|
||||
m_spellSchoolMask = GetSpellSchoolMask(info); // Can be override for some spell (wand shoot for example)
|
||||
|
||||
if (m_attackType == RANGED_ATTACK)
|
||||
{
|
||||
// wand case
|
||||
if ((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK))
|
||||
m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->Damage[0].DamageType);
|
||||
}
|
||||
}
|
||||
|
||||
if (originalCasterGUID)
|
||||
m_originalCasterGUID = originalCasterGUID;
|
||||
@@ -618,10 +593,8 @@ void Spell::SelectSpellTargets()
|
||||
if (effectTargetType == SPELL_REQUIRE_CASTER)
|
||||
AddUnitTarget(m_caster, i);
|
||||
else if (effectTargetType == SPELL_REQUIRE_ITEM)
|
||||
{
|
||||
if (m_targets.getItemTarget())
|
||||
AddItemTarget(m_targets.getItemTarget(), i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -738,15 +711,6 @@ void Spell::SelectSpellTargets()
|
||||
if (Guardian* pet = m_caster->GetGuardianPet())
|
||||
AddUnitTarget(pet, i);
|
||||
break;
|
||||
/*case SPELL_EFFECT_ENCHANT_ITEM:
|
||||
case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY:
|
||||
case SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC:
|
||||
case SPELL_EFFECT_DISENCHANT:
|
||||
case SPELL_EFFECT_PROSPECTING:
|
||||
case SPELL_EFFECT_MILLING:
|
||||
if (m_targets.getItemTarget())
|
||||
AddItemTarget(m_targets.getItemTarget(), i);
|
||||
break;*/
|
||||
case SPELL_EFFECT_APPLY_AURA:
|
||||
switch(m_spellInfo->EffectApplyAuraName[i])
|
||||
{
|
||||
@@ -891,10 +855,8 @@ void Spell::prepareDataForTriggerSystem(AuraEffect const * /*triggeredByAura*/)
|
||||
|
||||
m_procAttacker |= PROC_FLAG_DONE_TRAP_ACTIVATION;
|
||||
|
||||
/*
|
||||
Effects which are result of aura proc from triggered spell cannot proc
|
||||
to prevent chain proc of these spells
|
||||
*/
|
||||
/* Effects which are result of aura proc from triggered spell cannot proc
|
||||
to prevent chain proc of these spells */
|
||||
|
||||
// Hellfire Effect - trigger as DOT
|
||||
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags[0] & 0x00000040)
|
||||
@@ -1039,13 +1001,11 @@ void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex)
|
||||
|
||||
// Lookup target in already in list
|
||||
for (std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit)
|
||||
{
|
||||
if (targetGUID == ihit->targetGUID) // Found in list
|
||||
{
|
||||
ihit->effectMask |= 1 << effIndex; // Add only effect mask
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This is new target calculate data for him
|
||||
|
||||
@@ -1085,13 +1045,11 @@ void Spell::AddItemTarget(Item* pitem, uint32 effIndex)
|
||||
|
||||
// Lookup target in already in list
|
||||
for (std::list<ItemTargetInfo>::iterator ihit = m_UniqueItemInfo.begin(); ihit != m_UniqueItemInfo.end(); ++ihit)
|
||||
{
|
||||
if (pitem == ihit->item) // Found in list
|
||||
{
|
||||
ihit->effectMask |= 1<<effIndex; // Add only effect mask
|
||||
ihit->effectMask |= 1 << effIndex; // Add only effect mask
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This is new target add data
|
||||
|
||||
@@ -1117,24 +1075,22 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
||||
uint8 farMask = 0;
|
||||
// create far target mask
|
||||
for(uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (IsFarUnitTargetEffect(m_spellInfo->Effect[i]))
|
||||
if ((1<<i) & mask)
|
||||
farMask |= (1<<i);
|
||||
}
|
||||
if ((1 << i) & mask)
|
||||
farMask |= (1 << i);
|
||||
|
||||
if (!farMask)
|
||||
return;
|
||||
// find unit in world
|
||||
unit = ObjectAccessor::FindUnit(target->targetGUID);
|
||||
if (!unit)
|
||||
return;
|
||||
|
||||
// do far effects on the unit
|
||||
// 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))
|
||||
if (farMask & (1 << i))
|
||||
HandleEffects(unit, NULL, NULL, i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1323,9 +1279,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
||||
caster->ProcDamageAndSpell(unit, procAttacker, procVictim, procEx, 0, m_attackType, m_spellInfo, m_triggeredByAuraSpell);
|
||||
|
||||
// Failed Pickpocket, reveal rogue
|
||||
if (missInfo == SPELL_MISS_RESIST
|
||||
&& m_customAttr & SPELL_ATTR0_CU_PICKPOCKET
|
||||
&& unitTarget->GetTypeId() == TYPEID_UNIT)
|
||||
if (missInfo == SPELL_MISS_RESIST && m_customAttr & SPELL_ATTR0_CU_PICKPOCKET && unitTarget->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK);
|
||||
if (unitTarget->ToCreature()->IsAIEnabled)
|
||||
@@ -1402,12 +1356,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
if (m_caster != unit)
|
||||
{
|
||||
// Recheck UNIT_FLAG_NON_ATTACKABLE for delayed spells
|
||||
if (m_spellInfo->speed > 0.0f &&
|
||||
unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE) &&
|
||||
unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID())
|
||||
{
|
||||
if (m_spellInfo->speed > 0.0f && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE) && unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID())
|
||||
return SPELL_MISS_EVADE;
|
||||
}
|
||||
|
||||
if (!m_caster->IsFriendlyTo(unit))
|
||||
{
|
||||
@@ -1421,9 +1371,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
// for delayed spells ignore negative spells (after duel end) for friendly targets
|
||||
// TODO: this cause soul transfer bugged
|
||||
if (m_spellInfo->speed > 0.0f && unit->GetTypeId() == TYPEID_PLAYER && !IsPositiveSpell(m_spellInfo->Id))
|
||||
{
|
||||
return SPELL_MISS_EVADE;
|
||||
}
|
||||
|
||||
// assisting case, healing and resurrection
|
||||
if (unit->HasUnitState(UNIT_STAT_ATTACK_PLAYER))
|
||||
@@ -1453,8 +1401,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
|
||||
uint8 aura_effmask = 0;
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
if (effectMask & (1<<i) && IsUnitOwnedAuraEffect(m_spellInfo->Effect[i]))
|
||||
aura_effmask |= 1<<i;
|
||||
if (effectMask & (1 <<i ) && IsUnitOwnedAuraEffect(m_spellInfo->Effect[i]))
|
||||
aura_effmask |= 1 << i;
|
||||
|
||||
if (aura_effmask)
|
||||
{
|
||||
@@ -1529,10 +1477,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
}
|
||||
|
||||
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
|
||||
{
|
||||
if (effectMask & (1<<effectNumber))
|
||||
if (effectMask & (1 << effectNumber))
|
||||
HandleEffects(unit, NULL, NULL, effectNumber);
|
||||
}
|
||||
|
||||
return SPELL_MISS_NONE;
|
||||
}
|
||||
@@ -1591,14 +1537,12 @@ void Spell::DoTriggersOnSpellHit(Unit *unit)
|
||||
}
|
||||
|
||||
if (m_customAttr & SPELL_ATTR0_CU_LINK_HIT)
|
||||
{
|
||||
if (const std::vector<int32> *spell_triggered = sSpellMgr->GetSpellLinked(m_spellInfo->Id + SPELL_LINK_HIT))
|
||||
for (std::vector<int32>::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i)
|
||||
if (*i < 0)
|
||||
unit->RemoveAurasDueToSpell(-(*i));
|
||||
else
|
||||
unit->CastSpell(unit, *i, true, 0, 0, m_caster->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
void Spell::DoAllEffectOnTarget(GOTargetInfo *target)
|
||||
@@ -1627,10 +1571,8 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo *target)
|
||||
// cast at creature (or GO) quest objectives update at successful cast finished (+channel finished)
|
||||
// ignore autorepeat/melee casts for speed (not exist quest for spells (hm...)
|
||||
if (m_originalCaster && m_originalCaster->IsControlledByPlayer() && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive())
|
||||
{
|
||||
if (Player* p = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), m_spellInfo->Id);
|
||||
}
|
||||
CallScriptAfterHitHandlers();
|
||||
}
|
||||
|
||||
@@ -1686,7 +1628,6 @@ bool Spell::UpdateChanneledTargetList()
|
||||
if (IsValidDeadOrAliveTarget(unit))
|
||||
{
|
||||
if (channelAuraMask & ihit->effectMask)
|
||||
{
|
||||
if (AuraApplication * aurApp = unit->GetAuraApplication(m_spellInfo->Id, m_originalCasterGUID))
|
||||
{
|
||||
if (m_caster != unit && !m_caster->IsWithinDistInMap(unit, range))
|
||||
@@ -1698,7 +1639,6 @@ bool Spell::UpdateChanneledTargetList()
|
||||
}
|
||||
else // aura is dispelled
|
||||
continue;
|
||||
}
|
||||
|
||||
channelTargetEffectMask &= ~ihit->effectMask; // remove from need alive mask effect that have alive target
|
||||
}
|
||||
@@ -1725,10 +1665,7 @@ struct ChainHealingOrder : public std::binary_function<const Unit*, const Unit*,
|
||||
|
||||
int32 ChainHealingHash(Unit const* Target) const
|
||||
{
|
||||
/*if (Target == MainTarget)
|
||||
return 0;
|
||||
else*/ if (Target->GetTypeId() == TYPEID_PLAYER && MainTarget->GetTypeId() == TYPEID_PLAYER &&
|
||||
Target->ToPlayer()->IsInSameRaidWith(MainTarget->ToPlayer()))
|
||||
if (Target->GetTypeId() == TYPEID_PLAYER && MainTarget->GetTypeId() == TYPEID_PLAYER && Target->ToPlayer()->IsInSameRaidWith(MainTarget->ToPlayer()))
|
||||
{
|
||||
if (Target->IsFullHealth())
|
||||
return 40000;
|
||||
@@ -1746,16 +1683,6 @@ void Spell::SearchChainTarget(std::list<Unit*> &TagUnitMap, float max_range, uin
|
||||
if (!cur)
|
||||
return;
|
||||
|
||||
// Get spell max affected targets
|
||||
/*uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets;
|
||||
Unit::AuraList const& mod = m_caster->GetAuraEffectsByType(SPELL_AURA_MOD_MAX_AFFECTED_TARGETS);
|
||||
for (Unit::AuraList::const_iterator m = mod.begin(); m != mod.end(); ++m)
|
||||
{
|
||||
if (!(*m)->IsAffectedOnSpell(m_spellInfo))
|
||||
continue;
|
||||
unMaxTargets+=(*m)->GetAmount();
|
||||
}*/
|
||||
|
||||
//FIXME: This very like horrible hack and wrong for most spells
|
||||
if (m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_MELEE)
|
||||
max_range += num * CHAIN_SPELL_JUMP_RADIUS;
|
||||
@@ -1765,8 +1692,6 @@ void Spell::SearchChainTarget(std::list<Unit*> &TagUnitMap, float max_range, uin
|
||||
{
|
||||
SearchAreaTarget(tempUnitMap, max_range, PUSH_CHAIN, SPELL_TARGETS_ALLY);
|
||||
tempUnitMap.sort(ChainHealingOrder(m_caster));
|
||||
//if (cur->IsFullHealth() && tempUnitMap.size())
|
||||
// cur = tempUnitMap.front();
|
||||
}
|
||||
else
|
||||
SearchAreaTarget(tempUnitMap, max_range, PUSH_CHAIN, TargetType);
|
||||
@@ -1785,8 +1710,7 @@ void Spell::SearchChainTarget(std::list<Unit*> &TagUnitMap, float max_range, uin
|
||||
if (TargetType == SPELL_TARGETS_CHAINHEAL)
|
||||
{
|
||||
next = tempUnitMap.begin();
|
||||
while (cur->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS
|
||||
|| !cur->IsWithinLOSInMap(*next))
|
||||
while (cur->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS || !cur->IsWithinLOSInMap(*next))
|
||||
{
|
||||
++next;
|
||||
if (next == tempUnitMap.end())
|
||||
@@ -1853,8 +1777,7 @@ void Spell::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, SpellNo
|
||||
}
|
||||
|
||||
Trinity::SpellNotifierCreatureAndPlayer notifier(m_caster, TagUnitMap, radius, type, TargetType, pos, entry, m_spellInfo);
|
||||
if ((m_spellInfo->AttributesEx3 & SPELL_ATTR3_PLAYERS_ONLY)
|
||||
|| (TargetType == SPELL_TARGETS_ENTRY && !entry))
|
||||
if ((m_spellInfo->AttributesEx3 & SPELL_ATTR3_PLAYERS_ONLY) || (TargetType == SPELL_TARGETS_ENTRY && !entry))
|
||||
m_caster->GetMap()->VisitWorld(pos->m_positionX, pos->m_positionY, radius, notifier);
|
||||
else
|
||||
m_caster->GetMap()->VisitAll(pos->m_positionX, pos->m_positionY, radius, notifier);
|
||||
@@ -2298,9 +2221,7 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
|
||||
if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id))
|
||||
{
|
||||
//TODO: fix this check
|
||||
if (m_spellInfo->Effect[0] == SPELL_EFFECT_TELEPORT_UNITS
|
||||
|| m_spellInfo->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS
|
||||
|| m_spellInfo->Effect[2] == SPELL_EFFECT_TELEPORT_UNITS)
|
||||
if (m_spellInfo->Effect[0] == SPELL_EFFECT_TELEPORT_UNITS || m_spellInfo->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS || m_spellInfo->Effect[2] == SPELL_EFFECT_TELEPORT_UNITS)
|
||||
m_targets.setDst(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, (int32)st->target_mapId);
|
||||
else if (st->target_mapId == m_caster->GetMapId())
|
||||
m_targets.setDst(st->target_X, st->target_Y, st->target_Z, st->target_Orientation);
|
||||
@@ -2508,7 +2429,7 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
|
||||
{
|
||||
for (Unit::ControlList::iterator itr = m_caster->m_Controlled.begin(); itr != m_caster->m_Controlled.end(); ++itr)
|
||||
if ((*itr)->GetEntry() == (*i_spellST)->mConditionValue2 &&
|
||||
/*(*itr)->IsWithinDistInMap(m_caster, radius)*/ (*itr)->IsInMap(m_caster)) // For 60243 and 52173 need skip radius check or use range (no radius entry for effect)
|
||||
(*itr)->IsInMap(m_caster)) // For 60243 and 52173 need skip radius check or use range (no radius entry for effect)
|
||||
unitList.push_back(*itr);
|
||||
}
|
||||
}
|
||||
@@ -2646,12 +2567,8 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
|
||||
Player* Target = itr->getSource();
|
||||
|
||||
// IsHostileTo check duel and controlled by enemy
|
||||
if (Target && targetPlayer->IsWithinDistInMap(Target, radius) &&
|
||||
targetPlayer->getClass() == Target->getClass() &&
|
||||
!m_caster->IsHostileTo(Target))
|
||||
{
|
||||
if (Target && targetPlayer->IsWithinDistInMap(Target, radius) && targetPlayer->getClass() == Target->getClass() && !m_caster->IsHostileTo(Target))
|
||||
AddUnitTarget(Target, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_targets.getUnitTarget())
|
||||
@@ -2748,12 +2665,10 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
|
||||
|
||||
// Remove targets outside caster's raid
|
||||
for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end();)
|
||||
{
|
||||
if (!(*itr)->IsInRaidWith(m_caster))
|
||||
itr = unitList.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -2772,12 +2687,11 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
|
||||
else
|
||||
{
|
||||
for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end();)
|
||||
{
|
||||
if ((*itr)->getPowerType() != (Powers)power)
|
||||
itr = unitList.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
|
||||
if (unitList.size() > maxSize)
|
||||
{
|
||||
unitList.sort(Trinity::PowerPctOrderPred((Powers)power));
|
||||
@@ -2853,7 +2767,6 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
|
||||
//check for special spell conditions
|
||||
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id);
|
||||
if (!conditions.empty())
|
||||
{
|
||||
if (!sConditionMgr->IsPlayerMeetToConditions(plrCaster, conditions))
|
||||
{
|
||||
//SendCastResult(SPELL_FAILED_DONT_REPORT);
|
||||
@@ -2861,7 +2774,6 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
|
||||
finish(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!m_targets.HasSrc() && m_spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION)
|
||||
m_targets.setSrc(*m_caster);
|
||||
@@ -2897,7 +2809,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
|
||||
// Change aura with ranks only if basepoints are taken from spellInfo and aura is positive
|
||||
if (IsPositiveEffect(m_spellInfo->Id, i))
|
||||
{
|
||||
m_auraScaleMask |= (1<<i);
|
||||
m_auraScaleMask |= (1 << i);
|
||||
if (m_spellValue->EffectBasePoints[i] != m_spellInfo->EffectBasePoints[i])
|
||||
{
|
||||
m_auraScaleMask = 0;
|
||||
@@ -2970,9 +2882,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
|
||||
|
||||
// don't allow channeled spells / spells with cast time to be casted while moving
|
||||
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
|
||||
if ((IsChanneledSpell(m_spellInfo) || m_casttime)
|
||||
&& m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->isMoving()
|
||||
&& m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT)
|
||||
if ((IsChanneledSpell(m_spellInfo) || m_casttime) && m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->isMoving() && m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT)
|
||||
{
|
||||
SendCastResult(SPELL_FAILED_MOVING);
|
||||
finish(false);
|
||||
@@ -2983,10 +2893,6 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
|
||||
ReSetTimer();
|
||||
|
||||
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell::prepare: spell id %u source %u caster %d triggered %u mask %u", m_spellInfo->Id, m_caster->GetEntry(), m_originalCaster ? m_originalCaster->GetEntry() : -1, m_IsTriggeredSpell ? 1 : 0, m_targets.getTargetMask());
|
||||
//if (m_targets.getUnitTarget())
|
||||
// sLog->outError("Spell::prepare: unit target %u", m_targets.getUnitTarget()->GetEntry());
|
||||
//if (m_targets.HasDst())
|
||||
// sLog->outError("Spell::prepare: pos target %f %f %f", m_targets.m_dstPos.m_positionX, m_targets.m_dstPos.m_positionY, m_targets.m_dstPos.m_positionZ);
|
||||
|
||||
//Containers for channeled spells have to be set
|
||||
//TODO:Apply this to all casted spells if needed
|
||||
@@ -3001,13 +2907,11 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
|
||||
{
|
||||
m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST);
|
||||
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (EffectTargetType[m_spellInfo->Effect[i]] == SPELL_REQUIRE_UNIT)
|
||||
{
|
||||
m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_SPELL_ATTACK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_caster->SetCurrentCastedSpell(this);
|
||||
@@ -3015,9 +2919,8 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
|
||||
|
||||
TriggerGlobalCooldown();
|
||||
|
||||
if (!m_casttime && !m_spellInfo->StartRecoveryTime
|
||||
&& !m_castItemGUID //item: first cast may destroy item and second cast causes crash
|
||||
&& GetCurrentContainer() == CURRENT_GENERIC_SPELL)
|
||||
//item: first cast may destroy item and second cast causes crash
|
||||
if (!m_casttime && !m_spellInfo->StartRecoveryTime && !m_castItemGUID && GetCurrentContainer() == CURRENT_GENERIC_SPELL)
|
||||
cast(true);
|
||||
}
|
||||
}
|
||||
@@ -3087,8 +2990,7 @@ void Spell::cast(bool skipCheck)
|
||||
if (Unit *target = m_targets.getUnitTarget())
|
||||
{
|
||||
// three check: prepare, cast (m_casttime > 0), hit (delayed)
|
||||
if (m_casttime && target->isAlive()
|
||||
&& !target->IsFriendlyTo(m_caster) && !m_caster->canSeeOrDetect(target))
|
||||
if (m_casttime && target->isAlive() && !target->IsFriendlyTo(m_caster) && !m_caster->canSeeOrDetect(target))
|
||||
{
|
||||
SendCastResult(SPELL_FAILED_BAD_TARGETS);
|
||||
SendInterrupted(0);
|
||||
|
||||
Reference in New Issue
Block a user