Files
mod-playerbots/src/strategy/actions/ShareQuestAction.cpp
2022-03-12 22:27:09 +01:00

40 lines
1.1 KiB
C++

/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#include "ShareQuestAction.h"
#include "Event.h"
#include "Playerbots.h"
bool ShareQuestAction::Execute(Event event)
{
std::string const link = event.getParam();
if (!GetMaster())
return false;
PlayerbotChatHandler handler(GetMaster());
uint32 entry = handler.extractQuestId(link);
if (!entry)
return false;
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
if (!quest)
return false;
// remove all quest entries for 'entry' from quest log
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
uint32 logQuest = bot->GetQuestSlotQuestId(slot);
if (logQuest == entry)
{
WorldPacket p;
p << entry;
bot->GetSession()->HandlePushQuestToParty(p);
botAI->TellMaster("Quest shared");
return true;
}
}
return false;
}