Core/ConditionMgr: You can now add conditions to QuestAccept (at CanTakeQuest check)

--HG--
branch : trunk
This commit is contained in:
Rat
2010-09-19 19:49:23 +02:00
parent c4ed3430cf
commit 5de3183180
4 changed files with 29 additions and 3 deletions

View File

@@ -905,6 +905,16 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
}
break;
}
case CONDITION_SOURCE_TYPE_QUEST_ACCEPT:
{
Quest const *Quest = sObjectMgr.GetQuestTemplate(cond->mSourceEntry);
if (!Quest)
{
sLog.outErrorDb("CONDITION_SOURCE_TYPE_QUESTID specifies non-existing quest (%u), skipped", cond->mSourceEntry);
return false;
}
}
break;
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
case CONDITION_SOURCE_TYPE_NONE:

View File

@@ -79,10 +79,11 @@ enum ConditionSourceType
CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION = 15,//DONE
CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE = 16,//DONE
CONDITION_SOURCE_TYPE_SPELL = 17,//DONE
CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET = 18//DONE
CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET = 18,//DONE
CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19//DONE
};
#define MAX_CONDITIONSOURCETYPE 19
#define MAX_CONDITIONSOURCETYPE 20
struct Condition
{

View File

@@ -14014,7 +14014,8 @@ bool Player::CanTakeQuest(Quest const *pQuest, bool msg)
&& SatisfyQuestPreviousQuest(pQuest, msg) && SatisfyQuestTimed(pQuest, msg)
&& SatisfyQuestNextChain(pQuest, msg) && SatisfyQuestPrevChain(pQuest, msg)
&& SatisfyQuestDay(pQuest, msg) && SatisfyQuestWeek(pQuest, msg)
&& !sDisableMgr.IsDisabledFor(DISABLE_TYPE_QUEST, pQuest->GetQuestId(), this);
&& !sDisableMgr.IsDisabledFor(DISABLE_TYPE_QUEST, pQuest->GetQuestId(), this)
&& SatisfyQuestConditions(pQuest, msg);
}
bool Player::CanAddQuest(Quest const *pQuest, bool msg)
@@ -14752,6 +14753,19 @@ bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg)
return true;
}
bool Player::SatisfyQuestConditions(Quest const* qInfo, bool msg)
{
ConditionList conditions = sConditionMgr.GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_ACCEPT, qInfo->GetQuestId());
if (!sConditionMgr.IsPlayerMeetToConditions(this, conditions))
{
if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
sLog.outDebug("Player::SatisfyQuestConditions: conditions not met for quest %u", qInfo->GetQuestId());
return false;
}
return true;
}
bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg)
{
if (!m_timedquests.empty() && qInfo->HasFlag(QUEST_TRINITY_FLAGS_TIMED))

View File

@@ -1322,6 +1322,7 @@ class Player : public Unit, public GridObject<Player>
bool SatisfyQuestRace(Quest const* qInfo, bool msg);
bool SatisfyQuestReputation(Quest const* qInfo, bool msg);
bool SatisfyQuestStatus(Quest const* qInfo, bool msg);
bool SatisfyQuestConditions(Quest const* qInfo, bool msg);
bool SatisfyQuestTimed(Quest const* qInfo, bool msg);
bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg);
bool SatisfyQuestNextChain(Quest const* qInfo, bool msg);