aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/DungeonFinding/LFGMgr.cpp
diff options
context:
space:
mode:
authorhorn <pankrac.ja@seznam.cz>2012-09-23 18:23:15 +0200
committerhorn <pankrac.ja@seznam.cz>2012-10-05 00:43:58 +0200
commitc3f6c8141a083be363e828b5cbccf0ecbbe4e00c (patch)
tree3e035e2249ff810092686318e344b4d4869cbec9 /src/server/game/DungeonFinding/LFGMgr.cpp
parentb32878f02f801feb0db0a60d528322740d16c01c (diff)
Core/LFG: Implemented seasonal bosses options and fixed entrance points for dungeons with multiple parts (like Dire Maul, Scarlet Monastery etc.)
TODO: - implement spawning seasonal bosses by Dungeon Finder - script seasonal bosses - all of them needs to call RewardDungeonDoneFor function in their JustDied to be able to complete dungeon (see boss_headless_horseman.cpp) - replace lfg_entrances coords by sniffed values - create missing template for item 54537 (Heart-Shaped Box)
Diffstat (limited to 'src/server/game/DungeonFinding/LFGMgr.cpp')
-rwxr-xr-xsrc/server/game/DungeonFinding/LFGMgr.cpp89
1 files changed, 80 insertions, 9 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 3a75066fa2d..2b425dffff0 100755
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -24,6 +24,7 @@
#include "SocialMgr.h"
#include "LFGMgr.h"
#include "GroupMgr.h"
+#include "GameEventMgr.h"
#include "LFGScripts.h"
#include "LFGGroupData.h"
#include "LFGPlayerData.h"
@@ -185,6 +186,38 @@ void LFGMgr::LoadRewards()
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg dungeon rewards in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
+void LFGMgr::LoadEntrancePositions()
+{
+ uint32 oldMSTime = getMSTime();
+ m_entrancePositions.clear();
+
+ QueryResult result = WorldDatabase.Query("SELECT dungeonId, position_x, position_y, position_z, orientation FROM lfg_entrances");
+
+ if (!result)
+ {
+ sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 lfg entrance positions. DB table `lfg_entrances` is empty!");
+ return;
+ }
+
+ uint32 count = 0;
+
+ do
+ {
+ Field* fields = result->Fetch();
+ uint32 dungeonId = fields[0].GetUInt32();
+ Position pos;
+ pos.m_positionX = fields[1].GetFloat();
+ pos.m_positionY = fields[2].GetFloat();
+ pos.m_positionZ = fields[3].GetFloat();
+ pos.m_orientation = fields[4].GetFloat();
+ m_entrancePositions[dungeonId] = pos;
+ ++count;
+ }
+ while (result->NextRow());
+
+ sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg entrance positions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+}
+
void LFGMgr::Update(uint32 diff)
{
if (!m_update)
@@ -438,6 +471,12 @@ void LFGMgr::InitializeLockedDungeons(Player* player)
locktype = LFG_LOCKSTATUS_TOO_LOW_LEVEL;
else if (dungeon->maxlevel < level)
locktype = LFG_LOCKSTATUS_TOO_HIGH_LEVEL;
+ else if (dungeon->flags & LFG_FLAG_SEASONAL)
+ {
+ if (HolidayIds holiday = sLFGMgr->GetDungeonSeason(dungeon->ID))
+ if (!IsHolidayActive(holiday))
+ locktype = LFG_LOCKSTATUS_NOT_IN_SEASON;
+ }
else if (locktype == LFG_LOCKSTATUS_OK && ar)
{
if (ar->achievement && !player->HasAchieved(ar->achievement))
@@ -460,7 +499,6 @@ void LFGMgr::InitializeLockedDungeons(Player* player)
locktype = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
locktype = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
locktype = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
- locktype = LFG_LOCKSTATUS_NOT_IN_SEASON; // Need list of instances and needed season to open
*/
if (locktype != LFG_LOCKSTATUS_OK)
@@ -1808,13 +1846,16 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*
if (!mapid)
{
- AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(dungeon->map);
- if (!at)
+ LfgEntrancePositionMap::const_iterator itr = m_entrancePositions.find(dungeon->ID);
+ if (itr != m_entrancePositions.end())
{
- sLog->outError(LOG_FILTER_LFG, "LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "]: No areatrigger found for map: %u difficulty: %u", player->GetGUID(), dungeon->map, dungeon->difficulty);
- error = LFG_TELEPORTERROR_INVALID_LOCATION;
+ mapid = dungeon->map;
+ x = itr->second.GetPositionX();
+ y = itr->second.GetPositionY();
+ z = itr->second.GetPositionZ();
+ orientation = itr->second.GetOrientation();
}
- else
+ else if (AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(dungeon->map))
{
mapid = at->target_mapId;
x = at->target_X;
@@ -1822,6 +1863,11 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*
z = at->target_Z;
orientation = at->target_Orientation;
}
+ else
+ {
+ sLog->outError(LOG_FILTER_LFG, "LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "]: No areatrigger found for map: %u difficulty: %u", player->GetGUID(), dungeon->map, dungeon->difficulty);
+ error = LFG_TELEPORTERROR_INVALID_LOCATION;
+ }
}
if (error == LFG_TELEPORTERROR_OK)
@@ -1889,11 +1935,11 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player)
ClearState(guid);
SetState(guid, LFG_STATE_FINISHED_DUNGEON);
- // Give rewards only if its a random dungeon
+ // Give rewards only if its a random or seasonal dungeon
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(rDungeonId);
- if (!dungeon || dungeon->type != LFG_TYPE_RANDOM)
+ if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !(dungeon->flags & LFG_FLAG_SEASONAL)))
{
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] dungeon %u is not random", guid, rDungeonId);
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RewardDungeonDoneFor: [" UI64FMTD "] dungeon %u is not random nor seasonal", guid, rDungeonId);
return;
}
@@ -2001,6 +2047,31 @@ std::string LFGMgr::ConcatenateGuids(LfgGuidList check)
return o.str();
}
+HolidayIds LFGMgr::GetDungeonSeason(uint32 dungeonId)
+{
+ HolidayIds holiday = HOLIDAY_NONE;
+
+ switch (dungeonId)
+ {
+ case 285:
+ holiday = HOLIDAY_HALLOWS_END;
+ break;
+ case 286:
+ holiday = HOLIDAY_FIRE_FESTIVAL;
+ break;
+ case 287:
+ holiday = HOLIDAY_BREWFEST;
+ break;
+ case 288:
+ holiday = HOLIDAY_LOVE_IS_IN_THE_AIR;
+ break;
+ default:
+ break;
+ }
+
+ return holiday;
+}
+
LfgState LFGMgr::GetState(uint64 guid)
{
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetState: [" UI64FMTD "]", guid);