PDA

View Full Version : [SOLVED] Quest Status and Verify Items/Kills



zhier
07-31-2016, 10:57 PM
Well, I'm making a npc to verify if a player has a quest completed.

As you maybe know, some custom quest gets bug and the players can't recive the awards and they have the npc kills or items requireds.

So, my NPC will check the items and requiredNPCorGo, and if those fields are completed, delete quest, add it again to the player and complete it.

Maybe this code will help me to do the thing that I want:


Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id);
QuestStatusMap::iterator itr = m_QuestStatus.find(quest_id);
QuestStatusData &q_status = itr->second;

if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_KILL | QUEST_SPECIAL_FLAGS_CAST | QUEST_SPECIAL_FLAGS_SPEAKTO))
{
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
{
if (qInfo->RequiredNpcOrGo[i] == 0)
continue;

if (qInfo->RequiredNpcOrGoCount[i] != 0 && q_status.CreatureOrGOCount[i] < qInfo->RequiredNpcOrGoCount[i])
return false;
}
}

if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER))
{
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
{
if (qInfo->RequiredItemCount[i]!= 0 && q_status.ItemCount[i] < qInfo->RequiredItemCount[i])
return false;
}
}

Thanks for your help

zhier
07-31-2016, 11:11 PM
How can I create a function to verify if a player has completed the item in their bag/bank?

So, then I can do something like:


if(verifyQuest(quest_id) == true){
//bla bla
}

and inside my function something like:


bool verifyQuest (uint8 quest_id){
//how to implement that code here?
}

zhier
07-31-2016, 11:58 PM
Well I've made this code:



bool VerifyQuest(uint32 quest_id, Player* player){
if (quest_id)
{
Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id);
if (!qInfo)
return false;

QuestStatusData& q_status = m_QuestStatus[quest_id];

if (q_status.Status == QUEST_STATUS_INCOMPLETE)
{
if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER))
{
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
{
if (qInfo->RequiredItemCount[i]!= 0 && q_status.ItemCount[i] == qInfo->RequiredItemCount[i]){
if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_KILL))
{
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
{
if (qInfo->RequiredNpcOrGoCount[i] != 0 && q_status.CreatureOrGOCount[i] == qInfo->RequiredNpcOrGoCount[i]){
if (qInfo->GetRewOrReqMoney() >= 0){
return true;
}
else{
if (qInfo->GetRewOrReqMoney() < 0)
{
if (!player->HasEnoughMoney(-qInfo->GetRewOrReqMoney()))
return false;
}
}
}
}
}
}
}
}
}
}
return false;
}


But when I'm compiling, I got two errors:



'm_QuestStatus': undeclared identifier
'q_status': references must be initialized


I hope you can help me!

zhier
08-01-2016, 02:57 AM
Solved.

I've changed "QuestStatusData& q_status = m_QuestStatus[quest_id];" to QueryResult to the table characters.character_queststatus. It has all the info that I need to make my ideas come true.