Core/Db/Conditions: Add ContidionTarget column which allows selection of objects which will be checked by condition, depending on SourceTypeOrReferenceId.

So far usable only with CONDITION_SOURCE_TYPE_SPELL:
ContidionTarget = 0 - check caster
ContidionTarget = 1 - check explicit target
This commit is contained in:
QAston
2012-02-10 23:42:08 +01:00
parent 8c2526e7d0
commit ce4a4ffe50
11 changed files with 198 additions and 65 deletions
+14 -3
View File
@@ -4716,12 +4716,23 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_DONT_REPORT;
}
// check spell caster's conditions from database
if (Player* plrCaster = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself())
// check spell cast conditions from database
{
ConditionSourceInfo condInfo = ConditionSourceInfo(m_caster);
condInfo.mConditionTargets[1] = m_targets.GetObjectTarget();
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id);
if (!conditions.empty() && !sConditionMgr->IsObjectMeetToConditions(plrCaster, conditions))
if (!conditions.empty() && !sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
{
// send error msg to player if condition failed and text message available
// TODO: using WorldSession::SendNotification is not blizzlike
if (Player* playerCaster = m_caster->ToPlayer())
{
if (playerCaster->GetSession() && condInfo.mLastFailedCondition
&& condInfo.mLastFailedCondition->ErrorTextd)
playerCaster->GetSession()->SendNotification(condInfo.mLastFailedCondition->ErrorTextd);
}
return SPELL_FAILED_DONT_REPORT;
}
}
// Don't check explicit target for passive spells (workaround) (check should be skipped only for learn case)