• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Quest Status and Verify Items/Kills

Status
Not open for further replies.

zhier

Member
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:

Code:
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

Member
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:

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

and inside my function something like:

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

zhier

Member
Well I've made this code:

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:

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

I hope you can help me!
 

zhier

Member
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.
 
Status
Not open for further replies.
Top