feat(SmartAI): improve add quest action (#1333)

This commit is contained in:
Francesco Borzì
2019-01-24 19:07:13 +00:00
committed by GitHub
parent 60561d6f9f
commit 206feacab3
4 changed files with 40 additions and 8 deletions

View File

@@ -0,0 +1,4 @@
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1548013361501724652');
UPDATE `smart_scripts` SET `action_param2`=1 WHERE `action_type`=7;
UPDATE `smart_scripts` SET `action_param2`=0 WHERE `source_type`=0 AND `entryorguid`=11216 AND `id`=3;

View File

@@ -372,7 +372,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)
@@ -380,15 +380,37 @@ 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, NULL);
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);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ADD_QUEST: Player guidLow %u add quest %u",
(*itr)->GetGUIDLow(), e.action.quest.quest);
sLog->outDebug(
LOG_FILTER_DATABASE_AI,
"SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow %u - offering quest %u",
(*itr)->GetGUIDLow(),
e.action.questOffer.questID);
#endif
}
}
else
{
(*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, nullptr);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(
LOG_FILTER_DATABASE_AI,
"SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow %u - quest %u added",
(*itr)->GetGUIDLow(),
e.action.questOffer.questID);
#endif
}
}
}
}

View File

@@ -776,7 +776,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
return false;
break;
case SMART_ACTION_FAIL_QUEST:
case SMART_ACTION_ADD_QUEST:
case SMART_ACTION_OFFER_QUEST:
if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest))
return false;
break;

View File

@@ -436,7 +436,7 @@ enum SMART_ACTION
SMART_ACTION_SOUND = 4, // SoundId, onlySelf
SMART_ACTION_PLAY_EMOTE = 5, // EmoteId
SMART_ACTION_FAIL_QUEST = 6, // QuestID
SMART_ACTION_ADD_QUEST = 7, // QuestID
SMART_ACTION_OFFER_QUEST = 7, // QuestID, directAdd
SMART_ACTION_SET_REACT_STATE = 8, // state
SMART_ACTION_ACTIVATE_GOBJECT = 9, //
SMART_ACTION_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3...
@@ -630,6 +630,12 @@ struct SmartAction
uint32 quest;
} quest;
struct
{
uint32 questID;
uint32 directAdd;
} questOffer;
struct
{
uint32 state;