mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Dungeon Finder: Modified LFGMgr to use DF quests to reward.
* In this way we will store the character's day progress in the db, preventing to lose the information because of a crash/restart/shutdown. Patch by Gyullo and me, thanks to Spp & linencloth for help. * The next commit will modify the current Quest System to support DF quests. --HG-- branch : trunk
This commit is contained in:
@@ -61,7 +61,6 @@ struct LookingForGroup
|
||||
bool update;
|
||||
LfgState state;
|
||||
LfgDungeonSet applyDungeons; // Dungeons the player have applied for
|
||||
LfgDungeonSet donerandomDungeons; // Finished random Dungeons (to calculate the bonus);
|
||||
std::string comment;
|
||||
};
|
||||
|
||||
|
||||
@@ -1874,11 +1874,6 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player)
|
||||
if (!dungeon || dungeon->type != LFG_TYPE_RANDOM)
|
||||
return;
|
||||
|
||||
// Mark random dungeon as complete
|
||||
uint8 index = player->isLfgDungeonDone(rDungeonId) ? 1 : 0;
|
||||
if (!index)
|
||||
player->SetLfgDungeonDone(rDungeonId);
|
||||
|
||||
// Update achievements
|
||||
if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC)
|
||||
player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, 1);
|
||||
@@ -1887,46 +1882,26 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player)
|
||||
if (!reward)
|
||||
return;
|
||||
|
||||
uint8 index = 0;
|
||||
Quest const* qReward = sObjectMgr.GetQuestTemplate(reward->reward[index].questId);
|
||||
if (!qReward)
|
||||
return;
|
||||
|
||||
// Give rewards
|
||||
player->GetSession()->SendLfgPlayerReward(dungeon->Entry(), group->GetLfgDungeonEntry(false), index, reward, qReward);
|
||||
|
||||
if (qReward->GetRewItemsCount() > 0)
|
||||
// if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day.
|
||||
if (player->CanRewardQuest(qReward,false))
|
||||
player->RewardQuest(qReward,0,NULL,false);
|
||||
else
|
||||
{
|
||||
for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
|
||||
{
|
||||
if (uint32 itemId = qReward->RewItemId[i])
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
if (player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, qReward->RewItemCount[i]) == EQUIP_ERR_OK)
|
||||
{
|
||||
Item* item = player->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
|
||||
player->SendNewItem(item, qReward->RewItemCount[i], true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
index = 1;
|
||||
qReward = sObjectMgr.GetQuestTemplate(reward->reward[index].questId);
|
||||
if (!qReward)
|
||||
return;
|
||||
// we give reward without informing client (retail does this)
|
||||
player->RewardQuest(qReward,0,NULL,false);
|
||||
}
|
||||
|
||||
// Not give XP in case already completed once repeatable quest
|
||||
uint32 XP = uint32(qReward->XPValue(player) * sWorld.getRate(RATE_XP_QUEST));
|
||||
|
||||
XP += (MAXGROUPSIZE - group->GetMembersCount()) * reward->reward[index].variableXP;
|
||||
|
||||
// Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative
|
||||
int32 moneyRew = qReward->GetRewOrReqMoney();
|
||||
|
||||
if (player->getLevel() < sWorld.getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
player->GiveXP(XP, NULL);
|
||||
else
|
||||
moneyRew += int32(qReward->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY));
|
||||
|
||||
moneyRew += (MAXGROUPSIZE - group->GetMembersCount()) * reward->reward[index].variableMoney;
|
||||
|
||||
if (moneyRew)
|
||||
player->ModifyMoney(moneyRew);
|
||||
// Give rewards
|
||||
player->GetSession()->SendLfgPlayerReward(dungeon->Entry(), group->GetLfgDungeonEntry(false), index, reward, qReward);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------//
|
||||
|
||||
@@ -2255,10 +2255,10 @@ 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(); }
|
||||
// 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); }
|
||||
// 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; }
|
||||
|
||||
@@ -194,7 +194,6 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
|
||||
sLog.outDebug("CMSG_LFD_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", GetPlayer()->GetGUID());
|
||||
uint32 rsize = 0;
|
||||
uint32 lsize = 0;
|
||||
bool done;
|
||||
LfgDungeonSet* randomlist = sLFGMgr.GetRandomDungeons(GetPlayer()->getLevel(), GetPlayer()->GetSession()->Expansion());
|
||||
LfgLockStatusSet* lockSet = sLFGMgr.GetPlayerLockStatusDungeons(GetPlayer());
|
||||
|
||||
@@ -212,23 +211,34 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
|
||||
{
|
||||
LfgReward const* reward = NULL;
|
||||
Quest const* qRew = NULL;
|
||||
uint8 done;
|
||||
|
||||
data << uint8(randomlist->size()); // Random Dungeon count
|
||||
for (LfgDungeonSet::iterator it = randomlist->begin(); it != randomlist->end(); ++it)
|
||||
{
|
||||
done = GetPlayer()->isLfgDungeonDone(*it);
|
||||
reward = sLFGMgr.GetRandomDungeonReward(*it, GetPlayer()->getLevel());
|
||||
data << uint32(*it); // Entry
|
||||
data << uint8(done);
|
||||
reward = sLFGMgr.GetRandomDungeonReward(*it, GetPlayer()->getLevel());
|
||||
qRew = NULL;
|
||||
if (reward)
|
||||
{
|
||||
qRew = sObjectMgr.GetQuestTemplate(reward->reward[done].questId);
|
||||
data << uint32(qRew ? qRew->GetRewOrReqMoney() : 0);
|
||||
data << uint32(qRew ? qRew->XPValue(GetPlayer()) : 0);
|
||||
qRew = sObjectMgr.GetQuestTemplate(reward->reward[0].questId);
|
||||
if (qRew)
|
||||
{
|
||||
done = !GetPlayer()->CanRewardQuest(qRew,false);
|
||||
if (done)
|
||||
qRew = sObjectMgr.GetQuestTemplate(reward->reward[1].questId);
|
||||
}
|
||||
|
||||
}
|
||||
if (qRew)
|
||||
{
|
||||
data << uint8(done);
|
||||
data << uint32(qRew->GetRewOrReqMoney());
|
||||
data << uint32(qRew->XPValue(GetPlayer()));
|
||||
data << uint32(reward->reward[done].variableMoney);
|
||||
data << uint32(reward->reward[done].variableXP);
|
||||
data << uint8(qRew ? qRew->GetRewItemsCount() : 0);
|
||||
if (qRew && qRew->GetRewItemsCount())
|
||||
data << uint8(qRew->GetRewItemsCount());
|
||||
if (qRew->GetRewItemsCount())
|
||||
{
|
||||
ItemPrototype const* iProto = NULL;
|
||||
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
|
||||
@@ -246,6 +256,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
|
||||
}
|
||||
else
|
||||
{
|
||||
data << uint8(0);
|
||||
data << uint32(0);
|
||||
data << uint32(0);
|
||||
data << uint32(0);
|
||||
|
||||
Reference in New Issue
Block a user