本文整理汇总了C++中Creature::AddQuest方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::AddQuest方法的具体用法?C++ Creature::AddQuest怎么用?C++ Creature::AddQuest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature::AddQuest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleQuestAddFinishCommand
bool ChatHandler::HandleQuestAddFinishCommand(const char * args, WorldSession * m_session)
{
if(!*args)
return false;
uint64 guid = m_session->GetPlayer()->GetSelection();
if (guid == 0)
{
SystemMessage(m_session, "You must target an npc.");
return false;
}
Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!unit)
{
SystemMessage(m_session, "You must target an npc.");
return false;
}
if (!unit->isQuestGiver())
{
SystemMessage(m_session, "Unit is not a valid quest giver.");
return false;
}
uint32 quest_id = atol(args);
Quest * qst = QuestStorage.LookupEntry(quest_id);
if (qst == NULL)
{
SystemMessage(m_session, "Invalid quest selected, unable to add quest to the specified NPC.");
return false;
}
std::string quest_giver = MyConvertIntToString(unit->GetEntry());
std::string my_query1 = "SELECT id FROM creature_quest_finisher WHERE id = " + quest_giver + " AND quest = " + string(args);
QueryResult *selectResult1 = WorldDatabase.Query(my_query1.c_str());
if (selectResult1)
{
delete selectResult1;
SystemMessage(m_session, "Quest was already found for the specified NPC.");
}
else
{
std::string my_insert1 = "INSERT INTO creature_quest_finisher (id, quest) VALUES (" + quest_giver + "," + string(args) + ")";
QueryResult *insertResult1 = WorldDatabase.Query(my_insert1.c_str());
if (insertResult1)
delete insertResult1;
}
std::string my_query2 = "SELECT id FROM gameobject_quest_finisher WHERE id = " + quest_giver + " AND quest = " + string(args);
QueryResult *selectResult2 = WorldDatabase.Query(my_query2.c_str());
if (selectResult2)
delete selectResult2;
else
{
string my_insert2 = "INSERT INTO gameobject_quest_finisher (id, quest) VALUES (" + quest_giver + "," + string(args) + ")";
QueryResult *insertResult2 = WorldDatabase.Query(my_insert2.c_str());
if (insertResult2)
delete insertResult2;
}
sQuestMgr.LoadExtraQuestStuff();
QuestRelation *qstrel = new QuestRelation;
qstrel->qst = qst;
qstrel->type = QUESTGIVER_QUEST_END;
uint8 qstrelid = (uint8)unit->GetQuestRelation(quest_id);
unit->FindQuest(quest_id, qstrelid);
unit->AddQuest(qstrel);
unit->_LoadQuests();
const char * qname = qst->title;
std::string recout = "|cff00ff00Added Quest to NPC as finisher: ";
recout += "|cff00ccff";
recout += qname;
recout += "\n\n";
SendMultilineMessage(m_session, recout.c_str());
return true;
}