AI/SmartScripts: SMART_ACTION_ADD_QUEST -> SMART_ACTION_OFFER_QUEST. Open quest offer instead of adding straight to log - old behavior can be requested using action_param2. Closes #17735.

This commit is contained in:
treeston
2016-08-19 23:01:03 +02:00
parent 4073cc510a
commit ba4d6f6393
4 changed files with 30 additions and 8 deletions

View File

@@ -316,7 +316,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
delete targets;
break;
}
case SMART_ACTION_ADD_QUEST:
case SMART_ACTION_OFFER_QUEST:
{
ObjectList* targets = GetTargets(e, unit);
if (!targets)
@@ -324,13 +324,26 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
if (IsPlayer(*itr))
if (Player* pTarget = (*itr)->ToPlayer())
{
if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.quest.quest))
if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.questOffer.questID))
{
(*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, nullptr);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_QUEST: Player guidLow %u add quest %u",
(*itr)->GetGUID().GetCounter(), e.action.quest.quest);
if (me && e.action.questOffer.directAdd == 0)
{
if (pTarget->CanTakeQuest(q, true))
if (WorldSession* session = pTarget->GetSession())
{
PlayerMenu menu(session);
menu.SendQuestGiverQuestDetails(q, me->GetGUID(), true);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow %u - offering quest %u", pTarget->GetGUID().GetCounter(), e.action.questOffer.questID);
}
}
else
{
(*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, nullptr);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow %u - quest %u added",
pTarget->GetGUID().GetCounter(), e.action.questOffer.questID);
}
}
}
}