[7741] Allow pets/charmed NPCs to count master's spell cast conditions in quests.

Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
ApoC 2009-05-01 23:03:39 +02:00
parent 8e2a664fad
commit 8e39ea0151
3 changed files with 43 additions and 23 deletions

View file

@ -748,7 +748,7 @@ void Spell::prepareDataForTriggerSystem()
{
//==========================================================================================
// Now fill data for trigger system, need know:
// Ñan spell trigger another or not ( m_canTrigger )
// an spell trigger another or not ( m_canTrigger )
// Create base triggers flags for Attacker and Victim ( m_procAttacker and m_procVictim)
//==========================================================================================
// Fill flag can spell trigger or not
@ -1091,8 +1091,11 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
{
// cast at creature (or GO) quest objectives update at successful cast finished (+channel finished)
// ignore pets or autorepeat/melee casts for speed (not exist quest for spells (hm... )
if( !((Creature*)unit)->isPet() && m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() )
((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id);
if( !((Creature*)unit)->isPet() && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() )
{
if ( Player* p = GetPlayerForCastQuestCond() )
p->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id);
}
if(((Creature*)unit)->AI())
((Creature*)unit)->AI()->SpellHit(m_caster ,m_spellInfo);
@ -1237,8 +1240,11 @@ 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_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() )
((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id);
if( !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() )
{
if ( Player* p = GetPlayerForCastQuestCond() )
p->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id);
}
}
void Spell::DoAllEffectOnTarget(ItemTargetInfo *target)
@ -2691,7 +2697,9 @@ void Spell::update(uint32 difftime)
// channeled spell processed independently for quest targeting
// cast at creature (or GO) quest objectives update at successful cast channel finished
// ignore autorepeat/melee casts for speed (not exist quest for spells (hm... )
if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() )
if( !IsAutoRepeat() && !IsNextMeleeSwingSpell() )
{
if ( Player* p = GetPlayerForCastQuestCond() )
{
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit)
{
@ -2703,7 +2711,7 @@ void Spell::update(uint32 difftime)
if (unit==NULL)
continue;
((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id);
p->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id);
}
for(std::list<GOTargetInfo>::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit)
@ -2714,7 +2722,8 @@ void Spell::update(uint32 difftime)
if(!go)
continue;
((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id);
p->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id);
}
}
}

View file

@ -434,6 +434,17 @@ class Spell
CurrentSpellTypes GetCurrentContainer();
Player* GetPlayerForCastQuestCond()
{
if ( m_caster->GetTypeId() == TYPEID_PLAYER )
return (Player*)m_caster;
if ( Unit* u = m_caster->GetCharmerOrOwner() )
if ( u->GetTypeId() == TYPEID_PLAYER )
return (Player*)u;
return NULL;
}
Unit* GetCaster() const { return m_caster; }
Unit* GetOriginalCaster() const { return m_originalCaster; }
int32 GetPowerCost() const { return m_powerCost; }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7740"
#define REVISION_NR "7741"
#endif // __REVISION_NR_H__