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:
_manuel_
2010-10-01 20:32:00 -03:00
parent 6246d79b55
commit dfa401faf6
3 changed files with 62 additions and 14 deletions
+56 -10
View File
@@ -14202,7 +14202,7 @@ bool Player::CanCompleteRepeatableQuest(Quest const *pQuest)
bool Player::CanRewardQuest(Quest const *pQuest, bool msg) bool Player::CanRewardQuest(Quest const *pQuest, bool msg)
{ {
// not auto complete quest and not completed quest (only cheating case, then ignore without message) // 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; return false;
// daily quest can't be rewarded (25 daily quest already completed) // 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); CharacterDatabase.CommitTransaction(trans);
} }
if (pQuest->IsDaily()) if (pQuest->IsDaily() || pQuest->IsDFQuest())
{ {
SetDailyQuestStatus(quest_id); SetDailyQuestStatus(quest_id);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, quest_id); if (pQuest->IsDaily())
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY, quest_id); {
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()) } else if (pQuest->IsWeekly())
SetWeeklyQuestStatus(quest_id); SetWeeklyQuestStatus(quest_id);
@@ -14948,9 +14951,17 @@ bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg)
bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg)
{ {
if (!qInfo->IsDaily()) if (!qInfo->IsDaily() && !qInfo->IsDFQuest())
return true; return true;
if (qInfo->IsDFQuest())
{
if (!m_DFQuests.empty())
return false;
return true
}
bool have_slot = false; bool have_slot = false;
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) 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) 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); 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()); //QueryResult *result = CharacterDatabase.PQuery("SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow());
if (result) if (result)
@@ -17227,6 +17240,16 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result)
do 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 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()); 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)) if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
trans->PAppend("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" UI64FMTD "')", 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)); 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) void Player::_SaveWeeklyQuestStatus(SQLTransaction& trans)
@@ -21376,14 +21408,26 @@ void Player::SendAurasForTarget(Unit *target)
void Player::SetDailyQuestStatus(uint32 quest_id) 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); for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
m_lastDailyQuestTime = time(NULL); // last daily quest time {
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; 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) 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); SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0);
m_DFQuests.clear(); // Dungeon Finder Quests.
// DB data deleted in caller // DB data deleted in caller
m_DailyQuestChanged = false; m_DailyQuestChanged = false;
m_lastDailyQuestTime = 0; m_lastDailyQuestTime = 0;
+3 -3
View File
@@ -2255,10 +2255,7 @@ class Player : public Unit, public GridObject<Player>
void RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also = false); void RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also = false);
// Dungeon Finder // Dungeon Finder
// bool isLfgDungeonDone(const uint32 entry) { return m_LookingForGroup.donerandomDungeons.find(entry) != m_LookingForGroup.donerandomDungeons.end(); }
LfgDungeonSet *GetLfgDungeons() { return &m_LookingForGroup.applyDungeons; } 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; } std::string GetLfgComment() { return m_LookingForGroup.comment; }
void SetLfgComment(std::string _comment) { m_LookingForGroup.comment = _comment; } void SetLfgComment(std::string _comment) { m_LookingForGroup.comment = _comment; }
uint8 GetLfgRoles() { return m_LookingForGroup.roles; } 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; } void SetLfgState(LfgState state) { m_LookingForGroup.state = state; }
bool isUsingLfg() { return GetLfgState() != LFG_STATE_NONE; } bool isUsingLfg() { return GetLfgState() != LFG_STATE_NONE; }
typedef std::set<uint32> DFQuestsDoneList;
DFQuestsDoneList m_DFQuests;
// Temporarily removed pet cache // Temporarily removed pet cache
uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; } uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; } void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
+3 -1
View File
@@ -149,8 +149,9 @@ enum __QuestFlags
QUEST_TRINITY_FLAGS_REPEATABLE = 0x00100000, // Set by 1 in SpecialFlags from DB QUEST_TRINITY_FLAGS_REPEATABLE = 0x00100000, // Set by 1 in SpecialFlags from DB
QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT = 0x00200000, // Set by 2 in SpecialFlags from DB (if reequired area explore, spell SPELL_EFFECT_QUEST_COMPLETE casting, table `*_script` command SCRIPT_COMMAND_QUEST_EXPLORED use, set from script) QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT = 0x00200000, // Set by 2 in SpecialFlags from DB (if reequired area explore, spell SPELL_EFFECT_QUEST_COMPLETE casting, table `*_script` command SCRIPT_COMMAND_QUEST_EXPLORED use, set from script)
QUEST_TRINITY_FLAGS_AUTO_ACCEPT = 0x00400000, // Set by 4 in SpecialFlags in DB if the quest is to be auto-accepted. QUEST_TRINITY_FLAGS_AUTO_ACCEPT = 0x00400000, // Set by 4 in SpecialFlags in DB if the quest is to be auto-accepted.
QUEST_TRINITY_FLAGS_DF_QUEST = 0x00800000, // Set by 8 in SpecialFlags in DB if the quest is used by Dungeon Finder.
QUEST_TRINITY_FLAGS_DB_ALLOWED = 0xFFFFF | QUEST_TRINITY_FLAGS_REPEATABLE | QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT | QUEST_TRINITY_FLAGS_AUTO_ACCEPT, QUEST_TRINITY_FLAGS_DB_ALLOWED = 0xFFFFF | QUEST_TRINITY_FLAGS_REPEATABLE | QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT | QUEST_TRINITY_FLAGS_AUTO_ACCEPT | QUEST_TRINITY_FLAGS_DF_QUEST,
// Trinity flags for internal use only // Trinity flags for internal use only
QUEST_TRINITY_FLAGS_DELIVER = 0x04000000, // Internal flag computed only QUEST_TRINITY_FLAGS_DELIVER = 0x04000000, // Internal flag computed only
@@ -251,6 +252,7 @@ class Quest
bool IsAutoAccept() const { return QuestFlags & QUEST_FLAGS_AUTO_ACCEPT; } bool IsAutoAccept() const { return QuestFlags & QUEST_FLAGS_AUTO_ACCEPT; }
bool IsRaidQuest() const { return Type == QUEST_TYPE_RAID || Type == QUEST_TYPE_RAID_10 || Type == QUEST_TYPE_RAID_25; } bool IsRaidQuest() const { return Type == QUEST_TYPE_RAID || Type == QUEST_TYPE_RAID_10 || Type == QUEST_TYPE_RAID_25; }
bool IsAllowedInRaid() const; bool IsAllowedInRaid() const;
bool IsDFQuest() const { return QuestFlags & QUEST_TRINITY_FLAGS_DF_QUEST; }
// multiple values // multiple values
std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; std::string ObjectiveText[QUEST_OBJECTIVES_COUNT];