Core/Quests: Modified Quest System to support DF quests, the will work at the same time with daily quests but in parallel; in this way they will not count in the daily quests limit. Again, thanks to Spp & Gyullo.
--HG-- branch : trunk
This commit is contained in:
@@ -14202,7 +14202,7 @@ bool Player::CanCompleteRepeatableQuest(Quest const *pQuest)
|
||||
bool Player::CanRewardQuest(Quest const *pQuest, bool msg)
|
||||
{
|
||||
// not auto complete quest and not completed quest (only cheating case, then ignore without message)
|
||||
if (!pQuest->IsAutoComplete() && !(pQuest->GetFlags() & QUEST_FLAGS_AUTOCOMPLETE) && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE)
|
||||
if (!pQuest->IsDFQuest() && !pQuest->IsAutoComplete() && !(pQuest->GetFlags() & QUEST_FLAGS_AUTOCOMPLETE) && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE)
|
||||
return false;
|
||||
|
||||
// daily quest can't be rewarded (25 daily quest already completed)
|
||||
@@ -14502,11 +14502,14 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver,
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
if (pQuest->IsDaily())
|
||||
if (pQuest->IsDaily() || pQuest->IsDFQuest())
|
||||
{
|
||||
SetDailyQuestStatus(quest_id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, quest_id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY, quest_id);
|
||||
if (pQuest->IsDaily())
|
||||
{
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, quest_id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY, quest_id);
|
||||
}
|
||||
} else if (pQuest->IsWeekly())
|
||||
SetWeeklyQuestStatus(quest_id);
|
||||
|
||||
@@ -14948,9 +14951,17 @@ bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg)
|
||||
|
||||
bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg)
|
||||
{
|
||||
if (!qInfo->IsDaily())
|
||||
if (!qInfo->IsDaily() && !qInfo->IsDFQuest())
|
||||
return true;
|
||||
|
||||
if (qInfo->IsDFQuest())
|
||||
{
|
||||
if (!m_DFQuests.empty())
|
||||
return false;
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
bool have_slot = false;
|
||||
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
{
|
||||
@@ -17219,6 +17230,8 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result)
|
||||
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0);
|
||||
|
||||
m_DFQuests.clear();
|
||||
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow());
|
||||
|
||||
if (result)
|
||||
@@ -17227,6 +17240,16 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result)
|
||||
|
||||
do
|
||||
{
|
||||
if (Quest const* qQuest = sObjectMgr.GetQuestTemplate(result->GetUInt32(0)))
|
||||
{
|
||||
if (qQuest->IsDFQuest())
|
||||
{
|
||||
m_DFQuests.insert(qQuest->GetQuestId());
|
||||
m_lastDailyQuestTime = (time_t)result->GetUInt64(1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query
|
||||
{
|
||||
sLog.outError("Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`",GetGUIDLow());
|
||||
@@ -18187,6 +18210,15 @@ void Player::_SaveDailyQuestStatus(SQLTransaction& trans)
|
||||
if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
|
||||
trans->PAppend("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" UI64FMTD "')",
|
||||
GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime));
|
||||
|
||||
if (!m_DFQuests.empty())
|
||||
{
|
||||
for (DFQuestsDoneList::iterator itr = m_DFQuests.begin(); itr != m_DFQuests.end(); ++itr)
|
||||
{
|
||||
trans->PAppend("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" UI64FMTD "')",
|
||||
GetGUIDLow(),(*itr),uint64(m_lastDailyQuestTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_SaveWeeklyQuestStatus(SQLTransaction& trans)
|
||||
@@ -21376,14 +21408,26 @@ void Player::SendAurasForTarget(Unit *target)
|
||||
|
||||
void Player::SetDailyQuestStatus(uint32 quest_id)
|
||||
{
|
||||
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
if (Quest const* qQuest = sObjectMgr.GetQuestTemplate(quest_id))
|
||||
{
|
||||
if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
|
||||
if (!qQuest->IsDFQuest())
|
||||
{
|
||||
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id);
|
||||
m_lastDailyQuestTime = time(NULL); // last daily quest time
|
||||
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
{
|
||||
if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
|
||||
{
|
||||
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id);
|
||||
m_lastDailyQuestTime = time(NULL); // last daily quest time
|
||||
m_DailyQuestChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
m_DFQuests.insert(quest_id);
|
||||
m_lastDailyQuestTime = time(NULL);
|
||||
m_DailyQuestChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21400,6 +21444,8 @@ void Player::ResetDailyQuestStatus()
|
||||
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0);
|
||||
|
||||
m_DFQuests.clear(); // Dungeon Finder Quests.
|
||||
|
||||
// DB data deleted in caller
|
||||
m_DailyQuestChanged = false;
|
||||
m_lastDailyQuestTime = 0;
|
||||
|
||||
@@ -2255,10 +2255,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also = false);
|
||||
|
||||
// Dungeon Finder
|
||||
// bool isLfgDungeonDone(const uint32 entry) { return m_LookingForGroup.donerandomDungeons.find(entry) != m_LookingForGroup.donerandomDungeons.end(); }
|
||||
LfgDungeonSet *GetLfgDungeons() { return &m_LookingForGroup.applyDungeons; }
|
||||
// LfgDungeonSet *GetLfgDungeonsDone() { return &m_LookingForGroup.donerandomDungeons; }
|
||||
// void SetLfgDungeonDone(const uint32 entry) { m_LookingForGroup.donerandomDungeons.insert(entry); }
|
||||
std::string GetLfgComment() { return m_LookingForGroup.comment; }
|
||||
void SetLfgComment(std::string _comment) { m_LookingForGroup.comment = _comment; }
|
||||
uint8 GetLfgRoles() { return m_LookingForGroup.roles; }
|
||||
@@ -2269,6 +2266,9 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetLfgState(LfgState state) { m_LookingForGroup.state = state; }
|
||||
bool isUsingLfg() { return GetLfgState() != LFG_STATE_NONE; }
|
||||
|
||||
typedef std::set<uint32> DFQuestsDoneList;
|
||||
DFQuestsDoneList m_DFQuests;
|
||||
|
||||
// Temporarily removed pet cache
|
||||
uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
|
||||
void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
|
||||
|
||||
Reference in New Issue
Block a user