From ce4a4ffe50a26fa2040d4af3933621b66813488d Mon Sep 17 00:00:00 2001 From: QAston Date: Fri, 10 Feb 2012 23:40:38 +0100 Subject: 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 --- src/server/game/Spells/Spell.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/server/game/Spells/Spell.cpp') diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 9dccb0ff341..7c578a39355 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -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) -- cgit v1.2.3