mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 02:25:38 +01:00
Core/Misc: Graveyards can now use conditions, SourceType = 27, SourceEntry = graveyard_zone.ID
This commit is contained in:
@@ -1823,7 +1823,7 @@ void Battleground::SetBgRaid(uint32 TeamID, Group* bg_raid)
|
||||
|
||||
WorldSafeLocsEntry const* Battleground::GetClosestGraveYard(Player* player)
|
||||
{
|
||||
return sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam());
|
||||
return sObjectMgr->GetClosestGraveYard(*player, player->GetTeam(), player);
|
||||
}
|
||||
|
||||
void Battleground::StartCriteriaTimer(CriteriaTimedTypes type, uint32 entry)
|
||||
|
||||
@@ -1852,6 +1852,13 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||
case CONDITION_SOURCE_TYPE_SMART_EVENT:
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_GRAVEYARD:
|
||||
if (!sWorldSafeLocsStore.LookupEntry(cond->SourceEntry))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in WorldSafeLocs.db2, ignoring.", cond->ToString().c_str());
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
TC_LOG_ERROR("sql.sql", "%s Invalid ConditionSourceType in `condition` table, ignoring.", cond->ToString().c_str());
|
||||
return false;
|
||||
|
||||
@@ -162,7 +162,8 @@ enum ConditionSourceType
|
||||
CONDITION_SOURCE_TYPE_SPELL_PROC = 24,
|
||||
CONDITION_SOURCE_TYPE_TERRAIN_SWAP = 25,
|
||||
CONDITION_SOURCE_TYPE_PHASE = 26,
|
||||
CONDITION_SOURCE_TYPE_MAX = 27 // MAX
|
||||
CONDITION_SOURCE_TYPE_GRAVEYARD = 27,
|
||||
CONDITION_SOURCE_TYPE_MAX = 28 // MAX
|
||||
};
|
||||
|
||||
enum RelationType
|
||||
|
||||
@@ -4628,7 +4628,7 @@ void Player::RepopAtGraveyard()
|
||||
if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
|
||||
ClosestGrave = bf->GetClosestGraveYard(this);
|
||||
else
|
||||
ClosestGrave = sObjectMgr->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam());
|
||||
ClosestGrave = sObjectMgr->GetClosestGraveYard(*this, GetTeam(), this);
|
||||
}
|
||||
|
||||
// stop countdown until repop
|
||||
@@ -23096,7 +23096,7 @@ void Player::SetBattlegroundEntryPoint()
|
||||
// If map is dungeon find linked graveyard
|
||||
if (GetMap()->IsDungeon())
|
||||
{
|
||||
if (const WorldSafeLocsEntry* entry = sObjectMgr->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam()))
|
||||
if (const WorldSafeLocsEntry* entry = sObjectMgr->GetClosestGraveYard(*this, GetTeam(), this))
|
||||
m_bgData.joinPos = WorldLocation(entry->MapID, entry->Loc.X, entry->Loc.Y, entry->Loc.Z, 0.0f);
|
||||
else
|
||||
TC_LOG_ERROR("entities.player", "Player::SetBattlegroundEntryPoint: Dungeon (MapID: %u) has no linked graveyard, setting home location as entry point.", GetMapId());
|
||||
|
||||
@@ -6179,8 +6179,12 @@ WorldSafeLocsEntry const* ObjectMgr::GetDefaultGraveYard(uint32 team) const
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team) const
|
||||
WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const
|
||||
{
|
||||
float x, y, z;
|
||||
location.GetPosition(x, y, z);
|
||||
uint32 MapId = location.GetMapId();
|
||||
|
||||
// search for zone associated closest graveyard
|
||||
uint32 zoneId = sMapMgr->GetZoneId(MapId, x, y, z);
|
||||
|
||||
@@ -6226,6 +6230,8 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float
|
||||
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);
|
||||
|
||||
ConditionSourceInfo conditionSource(conditionObject);
|
||||
|
||||
for (; range.first != range.second; ++range.first)
|
||||
{
|
||||
GraveYardData const& data = range.first->second;
|
||||
@@ -6242,6 +6248,9 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float
|
||||
if (data.team != 0 && team != 0 && data.team != team)
|
||||
continue;
|
||||
|
||||
if (conditionObject && !sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_GRAVEYARD, data.safeLocId, conditionSource))
|
||||
continue;
|
||||
|
||||
// find now nearest graveyard at other map
|
||||
if (MapId != entry->MapID)
|
||||
{
|
||||
|
||||
@@ -1057,7 +1057,7 @@ class TC_GAME_API ObjectMgr
|
||||
QuestGreeting const* GetQuestGreeting(ObjectGuid guid) const;
|
||||
|
||||
WorldSafeLocsEntry const* GetDefaultGraveYard(uint32 team) const;
|
||||
WorldSafeLocsEntry const* GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team) const;
|
||||
WorldSafeLocsEntry const* GetClosestGraveYard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const;
|
||||
bool AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = true);
|
||||
void RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = false);
|
||||
void LoadGraveyardZones();
|
||||
|
||||
@@ -302,8 +302,7 @@ void WorldSession::SendSpiritResurrect()
|
||||
WorldLocation corpseLocation = _player->GetCorpseLocation();
|
||||
if (_player->HasCorpse())
|
||||
{
|
||||
corpseGrave = sObjectMgr->GetClosestGraveYard(corpseLocation.GetPositionX(), corpseLocation.GetPositionY(),
|
||||
corpseLocation.GetPositionZ(), corpseLocation.GetMapId(), _player->GetTeam());
|
||||
corpseGrave = sObjectMgr->GetClosestGraveYard(corpseLocation, _player->GetTeam(), _player);
|
||||
}
|
||||
|
||||
// now can spawn bones
|
||||
@@ -312,8 +311,7 @@ void WorldSession::SendSpiritResurrect()
|
||||
// teleport to nearest from corpse graveyard, if different from nearest to player ghost
|
||||
if (corpseGrave)
|
||||
{
|
||||
WorldSafeLocsEntry const* ghostGrave = sObjectMgr->GetClosestGraveYard(
|
||||
_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam());
|
||||
WorldSafeLocsEntry const* ghostGrave = sObjectMgr->GetClosestGraveYard(*_player, _player->GetTeam(), _player);
|
||||
|
||||
if (corpseGrave != ghostGrave)
|
||||
_player->TeleportTo(corpseGrave->MapID, corpseGrave->Loc.X, corpseGrave->Loc.Y, corpseGrave->Loc.Z, (corpseGrave->Facing * M_PI) / 180); // Orientation is initially in degrees
|
||||
|
||||
@@ -1526,7 +1526,7 @@ public:
|
||||
if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId()))
|
||||
nearestLoc = bf->GetClosestGraveYard(player);
|
||||
else
|
||||
nearestLoc = sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam());
|
||||
nearestLoc = sObjectMgr->GetClosestGraveYard(*player, player->GetTeam(), player);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1133,7 +1133,7 @@ public:
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
uint32 zone_id = player->GetZoneId();
|
||||
|
||||
WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team);
|
||||
WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(*player, team, nullptr);
|
||||
if (graveyard)
|
||||
{
|
||||
uint32 graveyardId = graveyard->ID;
|
||||
|
||||
Reference in New Issue
Block a user