diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index eea0b4495..2afe1ccd0 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7409,6 +7409,10 @@ bool PlayerCondition::Meets(Player const * player) const return data->CheckConditionCriteriaMeet(player, value1, value2); return false; } + case CONDITION_QUESTTARGET: + { + return player->HasQuestObjectiveForTarget(int32(value1), !bool(value2)); + } default: return false; } @@ -7633,6 +7637,31 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val break; } + case CONDITION_QUESTTARGET: + { + if (int32(value1) > 0) + { + if (!sObjectMgr.GetCreatureTemplate(value1)) + { + sLog.outErrorDb("Quest target condition has not existed creature entry %u as first arg, skipped", value1); + return false; + } + } + else if (int32(value1) < 0) + { + if (!sObjectMgr.GetGameObjectInfo(-int32(value1))) + { + sLog.outErrorDb("Quest target condition has not existed gameobject entry %u as first arg, skipped", -int32(value1)); + return false; + } + } + else + { + sLog.outErrorDb("Quest target condition has not existed entry 0 as first arg, skipped"); + return false; + } + break; + } case CONDITION_NONE: break; } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 2793b7709..d0b584bf7 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -317,9 +317,10 @@ enum ConditionType CONDITION_NOITEM = 16, // item_id count CONDITION_SPELL = 17, // spell_id 0, 1 (0: has spell, 1: hasn't spell) CONDITION_INSTANCE_SCRIPT = 18, // map_id instance_condition_id (instance script specific enum) + CONDITION_QUESTTARGET = 19, // entry complete,for condition true entry (positive - creature entry, negative (-entry) - gameobject entry) is not rewarded quest objective in (completed, bool) state. }; -#define MAX_CONDITION 19 // maximum value in ConditionType enum +#define MAX_CONDITION 20 // maximum value in ConditionType enum struct PlayerCondition { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7513657d7..dccd7240f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -19842,6 +19842,44 @@ bool Player::HasQuestForGO(int32 GOId) const return false; } +bool Player::HasQuestObjectiveForTarget(int32 creatureOrGOId, bool incomplete /*= true*/) const +{ + for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + { + uint32 questid = GetQuestSlotQuestId(i); + if ( questid == 0 ) + continue; + + QuestStatusMap::const_iterator qs_itr = mQuestStatus.find(questid); + if(qs_itr == mQuestStatus.end()) + continue; + + QuestStatusData const& qs = qs_itr->second; + + // for incopmplete objective we need incomplete quests, for complete objective it can be complete/incomplete + if (qs.m_status == QUEST_STATUS_INCOMPLETE || !incomplete && qs.m_status == QUEST_STATUS_COMPLETE) + { + Quest const* qinfo = sObjectMgr.GetQuestTemplate(questid); + if (!qinfo) + continue; + + if (GetGroup() && GetGroup()->isRaidGroup() && qinfo->IsAllowedInRaid()) + continue; + + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) + { + // creatureOrGOId have expected signs for creature/go cases, comparison signed + if (qinfo->ReqCreatureOrGOId[j] != creatureOrGOId) + continue; + + if (incomplete == (qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j])) + return true; + } + } + } + return false; +} + void Player::UpdateForQuestWorldObjects() { if(m_clientGUIDs.empty()) diff --git a/src/game/Player.h b/src/game/Player.h index cdf20bb19..b7034247d 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1410,6 +1410,7 @@ class MANGOS_DLL_SPEC Player : public Unit void ReputationChanged(FactionEntry const* factionEntry ); bool HasQuestForItem( uint32 itemid ) const; bool HasQuestForGO(int32 GOId) const; + bool HasQuestObjectiveForTarget(int32 creatureOrGOId, bool incomplete = true) const; void UpdateForQuestWorldObjects(); bool CanShareQuest(uint32 quest_id) const; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a9c90131d..4f2847d3f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10012" + #define REVISION_NR "10013" #endif // __REVISION_NR_H__