[8132] Use real caster in some cases in Spell::DoSpellHitOnUnit.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
Lightguard 2009-07-05 23:39:15 +04:00 committed by VladimirMangos
parent 6a574896f5
commit ac051d10e9
2 changed files with 34 additions and 33 deletions

View file

@ -1149,12 +1149,14 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
if (!unit || !effectMask)
return;
Unit* realCaster = m_originalCaster ? m_originalCaster : m_caster;
// Recheck immune (only for delayed spells)
if (m_spellInfo->speed && (
unit->IsImmunedToDamage(GetSpellSchoolMask(m_spellInfo)) ||
unit->IsImmunedToSpell(m_spellInfo)))
{
m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_IMMUNE);
realCaster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_IMMUNE);
return;
}
@ -1164,28 +1166,27 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
((Player*)unit)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, m_spellInfo->Id);
}
if(m_caster->GetTypeId() == TYPEID_PLAYER)
{
((Player*)m_caster)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, m_spellInfo->Id, 0, unit);
}
if (realCaster->GetTypeId() == TYPEID_PLAYER)
((Player*)realCaster)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, m_spellInfo->Id, 0, unit);
if( m_caster != unit )
if (realCaster != 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())
{
m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
realCaster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
return;
}
if( !m_caster->IsFriendlyTo(unit) )
if (!realCaster->IsFriendlyTo(unit))
{
// for delayed spells ignore not visible explicit target
if(m_spellInfo->speed > 0.0f && unit == m_targets.getUnitTarget() && !unit->isVisibleForOrDetect(m_caster,false))
if (m_spellInfo->speed > 0.0f && unit == m_targets.getUnitTarget() &&
!unit->isVisibleForOrDetect(m_caster,false))
{
m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
realCaster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
return;
}
@ -1197,16 +1198,14 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
unit->SetStandState(UNIT_STAND_STATE_STAND);
if (!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI())
((Creature*)unit)->AI()->AttackedBy(m_caster);
((Creature*)unit)->AI()->AttackedBy(realCaster);
unit->AddThreat(m_caster, 0.0f);
unit->SetInCombatWith(m_caster);
m_caster->SetInCombatWith(unit);
unit->AddThreat(realCaster, 0.0f);
unit->SetInCombatWith(realCaster);
realCaster->SetInCombatWith(unit);
if (Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself())
{
m_caster->SetContestedPvP(attackedPlayer);
}
realCaster->SetContestedPvP(attackedPlayer);
}
}
else
@ -1214,17 +1213,18 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
// for delayed spells ignore negative spells (after duel end) for friendly targets
if (m_spellInfo->speed > 0.0f && !IsPositiveSpell(m_spellInfo->Id))
{
m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
realCaster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
return;
}
// assisting case, healing and resurrection
if (unit->hasUnitState(UNIT_STAT_ATTACK_PLAYER))
m_caster->SetContestedPvP();
realCaster->SetContestedPvP();
if (unit->isInCombat() && !(m_spellInfo->AttributesEx & SPELL_ATTR_EX_NO_INITIAL_AGGRO))
{
m_caster->SetInCombatState(unit->GetCombatTimer() > 0);
unit->getHostilRefManager().threatAssist(m_caster, 0.0f);
realCaster->SetInCombatState(unit->GetCombatTimer() > 0);
unit->getHostilRefManager().threatAssist(realCaster, 0.0f);
}
}
}
@ -1233,7 +1233,8 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo,m_triggeredByAuraSpell);
m_diminishLevel = unit->GetDiminishing(m_diminishGroup);
// Increase Diminishing on unit, current informations for actually casts will use values above
if((GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_ALL)
if ((GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_ALL)
unit->IncrDiminishing(m_diminishGroup);
// Apply additional spell effects to target
@ -1250,7 +1251,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
// Get multiplier
float multiplier = m_spellInfo->DmgMultiplier[effectNumber];
// Apply multiplier mods
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
if(Player* modOwner = realCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_EFFECT_PAST_FIRST, multiplier, this);
m_damageMultipliers[effectNumber] *= multiplier;
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8131"
#define REVISION_NR "8132"
#endif // __REVISION_NR_H__