rendered paste bodyIndex: src/game/GameObject.cpp===================================================================--- src/game/GameObject.cpp (revision 5194)+++ src/game/GameObject.cpp (working copy)@@ -551,6 +551,71 @@ return false; } +uint32 GameObject::getDialogStatus(Player *pPlayer, uint32 defstatus)+{+ uint32 result = defstatus;+ QuestStatus status;+ uint32 quest_id;+ Quest const *pQuest;++ QuestRelations const& qir = objmgr.mGOQuestInvolvedRelations;+ for(QuestRelations::const_iterator i = qir.lower_bound(GetEntry()); i != qir.upper_bound(GetEntry()); ++i )+ {+ uint32 result2 = 0;+ quest_id = i->second;+ pQuest = objmgr.GetQuestTemplate(quest_id);+ if ( !pQuest ) continue;++ status = pPlayer->GetQuestStatus( quest_id );+ if ((status == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(quest_id)) ||+ (pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false)))+ {+ if ( pQuest->IsAutoComplete() && pQuest->IsRepeatable() )+ result2 = DIALOG_STATUS_REWARD_REP;+ else+ result2 = DIALOG_STATUS_REWARD;+ }+ else if ( status == QUEST_STATUS_INCOMPLETE )+ result2 = DIALOG_STATUS_INCOMPLETE;++ if (result2 > result)+ result = result2;+ }++ QuestRelations const& qr = objmgr.mGOQuestRelations;+ for(QuestRelations::const_iterator i = qr.lower_bound(GetEntry()); i != qr.upper_bound(GetEntry()); ++i )+ {+ uint32 result2 = 0;+ quest_id = i->second;+ pQuest = objmgr.GetQuestTemplate(quest_id);+ if ( !pQuest )+ continue;++ status = pPlayer->GetQuestStatus( quest_id );+ if ( status == QUEST_STATUS_NONE )+ {+ if ( pPlayer->CanSeeStartQuest( pQuest ) )+ {+ if ( pPlayer->SatisfyQuestLevel(pQuest, false) )+ {+ if ( pQuest->IsAutoComplete() || (pQuest->IsRepeatable() && pPlayer->getQuestStatusMap()[quest_id].m_rewarded))+ result2 = DIALOG_STATUS_REWARD_REP;+ else if (pPlayer->getLevel() <= pQuest->GetQuestLevel() + sWorld.getConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF) )+ result2 = DIALOG_STATUS_AVAILABLE;+ else+ result2 = DIALOG_STATUS_CHAT;+ }+ else+ result2 = DIALOG_STATUS_UNAVAILABLE;+ }+ }++ if (result2 > result)+ result = result2;+ }++ return result;+} bool GameObject::hasInvolvedQuest(uint32 quest_id) const { QuestRelations const& qr = objmgr.mGOQuestInvolvedRelations;Index: src/game/GameObject.h===================================================================--- src/game/GameObject.h (revision 5194)+++ src/game/GameObject.h (working copy)@@ -189,6 +189,7 @@ Loot loot; bool hasQuest(uint32 quest_id) const;+ uint32 getDialogStatus(Player *pPlayer, uint32 defstatus); bool hasInvolvedQuest(uint32 quest_id) const; bool ActivateToQuest(Player *pTarget) const; Index: src/game/QuestHandler.cpp===================================================================--- src/game/QuestHandler.cpp (revision 5194)+++ src/game/QuestHandler.cpp (working copy)@@ -36,14 +36,20 @@ uint64 guid; recv_data >> guid;+ uint32 questStatus = DIALOG_STATUS_NONE; - sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY npc = %u",uint32(GUID_LOPART(guid)) );- Creature *pCreature = ObjectAccessor::GetCreature(*_player, guid);+ GameObject *go = ObjectAccessor::GetGameObject(*_player, guid);+ if(!pCreature && !go)+ {+ sLog.outError("Error in CMSG_QUESTGIVER_STATUS_QUERY, called for NULL GameObject or Creature");+ return;+ }+ if ( pCreature )- {- uint32 questStatus = DIALOG_STATUS_NONE;+ { + sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc, guid = %u",uint32(GUID_LOPART(guid)) ); if( !pCreature->IsHostileTo(_player)) // not show quest status to enemies { questStatus = Script->NPCDialogStatus(_player, pCreature);@@ -53,8 +59,17 @@ questStatus = pCreature->getDialogStatus(_player, defstatus); } }- _player->PlayerTalkClass->SendQuestGiverStatus(questStatus, guid); }+ else + {+ // TODO: Add there redefenition for scripts lib+ // first of all add extrenal calls for scripts lib+ sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u",uint32(GUID_LOPART(guid)) );+ questStatus = go->getDialogStatus(_player, defstatus);+ }++ //inform client about status of quest+ _player->PlayerTalkClass->SendQuestGiverStatus(questStatus, guid); } void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data )