本文整理汇总了C++中Player::AddQuestAndCheckCompletion方法的典型用法代码示例。如果您正苦于以下问题:C++ Player::AddQuestAndCheckCompletion方法的具体用法?C++ Player::AddQuestAndCheckCompletion怎么用?C++ Player::AddQuestAndCheckCompletion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::AddQuestAndCheckCompletion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleQuestAdd
static bool HandleQuestAdd(ChatHandler* handler, char const* args)
{
Player* player = handler->getSelectedPlayerOrSelf();
if (!player)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
// .addquest #entry'
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hquest");
if (!cId)
return false;
uint32 entry = atoul(cId);
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
if (!quest || DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, entry, nullptr))
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
handler->SetSentErrorMessage(true);
return false;
}
// check item starting quest (it can work incorrectly if added without item in inventory)
ItemTemplateContainer const& itc = sObjectMgr->GetItemTemplateStore();
auto itr = std::find_if(std::begin(itc), std::end(itc), [quest](ItemTemplateContainer::value_type const& value)
{
return value.second.StartQuest == quest->GetQuestId();
});
if (itr != std::end(itc))
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, itr->first);
handler->SetSentErrorMessage(true);
return false;
}
if (player->IsActiveQuest(entry))
return false;
// ok, normal (creature/GO starting) quest
if (player->CanAddQuest(quest, true))
player->AddQuestAndCheckCompletion(quest, nullptr);
return true;
}
示例2: HandleQuestAdd
static bool HandleQuestAdd(ChatHandler* handler, const char* args)
{
Player* player = handler->getSelectedPlayer();
if (!player)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
// .addquest #entry'
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hquest");
if (!cId)
return false;
uint32 entry = atol(cId);
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
if (!quest)
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
handler->SetSentErrorMessage(true);
return false;
}
// check item starting quest (it can work incorrectly if added without item in inventory)
ItemTemplateContainer const* itc = sObjectMgr->GetItemTemplateStore();
ItemTemplateContainer::const_iterator result = find_if (itc->begin(), itc->end(), Finder<uint32, ItemTemplate>(entry, &ItemTemplate::StartQuest));
if (result != itc->end())
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, result->second.ItemId);
handler->SetSentErrorMessage(true);
return false;
}
// ok, normal (creature/GO starting) quest
if (player->CanAddQuest(quest, true))
{
player->AddQuestAndCheckCompletion(quest, NULL);
if (player->CanCompleteQuest(entry))
player->CompleteQuest(entry);
}
return true;
}
示例3: HandlePushQuestToParty
void WorldSession::HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& packet)
{
if (!_player->CanShareQuest(packet.QuestID))
return;
Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID);
if (!quest)
return;
Player * const sender = GetPlayer();
Group* group = sender->GetGroup();
if (!group)
return;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* receiver = itr->GetSource();
if (!receiver || receiver == sender)
continue;
if (!receiver->SatisfyQuestStatus(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_ONQUEST);
continue;
}
if (receiver->GetQuestStatus(packet.QuestID) == QUEST_STATUS_COMPLETE)
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_ALREADY_DONE);
continue;
}
if (!receiver->CanTakeQuest(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_INVALID);
continue;
}
if (!receiver->SatisfyQuestLog(false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_LOG_FULL);
continue;
}
if (!receiver->GetDivider().IsEmpty())
{
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_BUSY);
continue;
}
sender->SendPushToPartyResponse(receiver, QUEST_PUSH_SUCCESS);
if (quest->IsAutoAccept() && receiver->CanAddQuest(quest, true) && receiver->CanTakeQuest(quest, true))
receiver->AddQuestAndCheckCompletion(quest, sender);
if (quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly())
receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true);
else
{
receiver->SetDivider(sender->GetGUID());
receiver->PlayerTalkClass->SendQuestGiverQuestDetails(quest, receiver->GetGUID(), true);
}
}
}
示例4: HandlePushQuestToParty
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
{
uint32 questId;
recvPacket >> questId;
if (!_player->CanShareQuest(questId))
return;
TC_LOG_DEBUG("network", "WORLD: Received CMSG_PUSHQUESTTOPARTY questId = %u", questId);
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
if (!quest)
return;
Player * const sender = GetPlayer();
Group* group = sender->GetGroup();
if (!group)
return;
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* receiver = itr->GetSource();
if (!receiver || receiver == sender)
continue;
if (!receiver->SatisfyQuestStatus(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_HAVE_QUEST);
continue;
}
if (receiver->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE)
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_FINISH_QUEST);
continue;
}
if (!receiver->CanTakeQuest(quest, false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_CANT_TAKE_QUEST);
continue;
}
if (!receiver->SatisfyQuestLog(false))
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_LOG_FULL);
continue;
}
if (receiver->GetDivider() != 0)
{
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_BUSY);
continue;
}
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_SHARING_QUEST);
if (quest->IsAutoAccept() && receiver->CanAddQuest(quest, true) && receiver->CanTakeQuest(quest, true))
receiver->AddQuestAndCheckCompletion(quest, sender);
if ((quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly()) || quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true);
else
{
receiver->SetDivider(sender->GetGUID());
receiver->PlayerTalkClass->SendQuestGiverQuestDetails(quest, sender->GetGUID(), true);
}
}
}