[10013] Implement CONDITION_QUESTTARGET

For cases when loot dependent from some quest objective complete state.
This commit is contained in:
VladimirMangos 2010-06-01 01:10:51 +04:00
parent f9df9d6226
commit 59367bc19f
5 changed files with 71 additions and 2 deletions

View file

@ -7409,6 +7409,10 @@ bool PlayerCondition::Meets(Player const * player) const
return data->CheckConditionCriteriaMeet(player, value1, value2); return data->CheckConditionCriteriaMeet(player, value1, value2);
return false; return false;
} }
case CONDITION_QUESTTARGET:
{
return player->HasQuestObjectiveForTarget(int32(value1), !bool(value2));
}
default: default:
return false; return false;
} }
@ -7633,6 +7637,31 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
break; break;
} }
case CONDITION_QUESTTARGET:
{
if (int32(value1) > 0)
{
if (!sObjectMgr.GetCreatureTemplate(value1))
{
sLog.outErrorDb("Quest target condition has not existed creature entry %u as first arg, skipped", value1);
return false;
}
}
else if (int32(value1) < 0)
{
if (!sObjectMgr.GetGameObjectInfo(-int32(value1)))
{
sLog.outErrorDb("Quest target condition has not existed gameobject entry %u as first arg, skipped", -int32(value1));
return false;
}
}
else
{
sLog.outErrorDb("Quest target condition has not existed entry 0 as first arg, skipped");
return false;
}
break;
}
case CONDITION_NONE: case CONDITION_NONE:
break; break;
} }

View file

@ -317,9 +317,10 @@ enum ConditionType
CONDITION_NOITEM = 16, // item_id count CONDITION_NOITEM = 16, // item_id count
CONDITION_SPELL = 17, // spell_id 0, 1 (0: has spell, 1: hasn't spell) CONDITION_SPELL = 17, // spell_id 0, 1 (0: has spell, 1: hasn't spell)
CONDITION_INSTANCE_SCRIPT = 18, // map_id instance_condition_id (instance script specific enum) CONDITION_INSTANCE_SCRIPT = 18, // map_id instance_condition_id (instance script specific enum)
CONDITION_QUESTTARGET = 19, // entry complete,for condition true entry (positive - creature entry, negative (-entry) - gameobject entry) is not rewarded quest objective in (completed, bool) state.
}; };
#define MAX_CONDITION 19 // maximum value in ConditionType enum #define MAX_CONDITION 20 // maximum value in ConditionType enum
struct PlayerCondition struct PlayerCondition
{ {

View file

@ -19842,6 +19842,44 @@ bool Player::HasQuestForGO(int32 GOId) const
return false; return false;
} }
bool Player::HasQuestObjectiveForTarget(int32 creatureOrGOId, bool incomplete /*= true*/) const
{
for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i )
{
uint32 questid = GetQuestSlotQuestId(i);
if ( questid == 0 )
continue;
QuestStatusMap::const_iterator qs_itr = mQuestStatus.find(questid);
if(qs_itr == mQuestStatus.end())
continue;
QuestStatusData const& qs = qs_itr->second;
// for incopmplete objective we need incomplete quests, for complete objective it can be complete/incomplete
if (qs.m_status == QUEST_STATUS_INCOMPLETE || !incomplete && qs.m_status == QUEST_STATUS_COMPLETE)
{
Quest const* qinfo = sObjectMgr.GetQuestTemplate(questid);
if (!qinfo)
continue;
if (GetGroup() && GetGroup()->isRaidGroup() && qinfo->IsAllowedInRaid())
continue;
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
{
// creatureOrGOId have expected signs for creature/go cases, comparison signed
if (qinfo->ReqCreatureOrGOId[j] != creatureOrGOId)
continue;
if (incomplete == (qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]))
return true;
}
}
}
return false;
}
void Player::UpdateForQuestWorldObjects() void Player::UpdateForQuestWorldObjects()
{ {
if(m_clientGUIDs.empty()) if(m_clientGUIDs.empty())

View file

@ -1410,6 +1410,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void ReputationChanged(FactionEntry const* factionEntry ); void ReputationChanged(FactionEntry const* factionEntry );
bool HasQuestForItem( uint32 itemid ) const; bool HasQuestForItem( uint32 itemid ) const;
bool HasQuestForGO(int32 GOId) const; bool HasQuestForGO(int32 GOId) const;
bool HasQuestObjectiveForTarget(int32 creatureOrGOId, bool incomplete = true) const;
void UpdateForQuestWorldObjects(); void UpdateForQuestWorldObjects();
bool CanShareQuest(uint32 quest_id) const; bool CanShareQuest(uint32 quest_id) const;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10012" #define REVISION_NR "10013"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__