mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/AreaTriggers: Added SpawnDifficulties for spawned areatriggers (#29284)
This commit is contained in:
23
sql/updates/world/master/2023_09_06_02_world.sql
Normal file
23
sql/updates/world/master/2023_09_06_02_world.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
ALTER TABLE `areatrigger`
|
||||
ADD COLUMN `SpawnDifficulties` VARCHAR(100) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_unicode_ci' AFTER `MapId`;
|
||||
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '0' WHERE `MapId` IN(0,1064,1105,1107,1116,1190,1191,1220,1265,1463,1464,1468,1469,1479,1481,1502,1512,1513,1514,1515,1519,1540,1637,1642,1643,1669,1718,1750,1779,1860,1865,1929,1,2081,2107,2147,2175,2222,2261,2268,2297,2364,2369,2370,2374,2444,2453,2454,2512,2523,2524,2534,2570,30,369,530,571,572,609,646,648,654,726,730,732,749,761,860,861,870,974);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '1' WHERE `MapId` IN(109,1152,1153,1158,1159,129,1330,1331,1358,1763,1877,209,2284,229,230,2516,329,349,34,389,429,43,47,48,70,90);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '1,2' WHERE `MapId` IN(1001,1175,1209,189,269,289,33,36,540,542,543,545,546,547,552,553,554,555,556,557,558,560,568,574,575,576,578,585,595,599,600,601,602,604,608,619,632,643,644,645,650,658,668,670,725,755,859);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '1,2,8' WHERE `MapId` IN(1004,1007,1011,1175,1176,1279,959,960,961,962,994);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '1,2,8,23' WHERE `MapId` IN(1195,1544,1771,1754,1763,1841,1862,1864,1877,2284,2285,2286,2287,2290,2291,2293,1182,1208,1456,1458,1466,1477,1492,1493,1501,1594,2289,2519,2521,2526,2527,657,2451,2515,2516,2520,2527);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '12' WHERE `MapId` IN(1460,1475,1478,1703,1760,1904,1906,1955,2464,2471);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '14,15,16,17' WHERE `MapId` IN(1136,1205,1228,1448,1520,1530,1648,1676,1712,1861,2070,2096,2164,2217,2296,2450,2481,2569);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '14,15,33' WHERE `MapId` = 720;
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '14,33' WHERE `MapId` IN(564, 603);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '14,15,16,17' WHERE `MapId` = 2296;
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '2,23' WHERE `MapId` = 1651;
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '2,8,23' WHERE `MapId` IN(1516,1571,1677,1753,1762,2097,2441);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '3' WHERE `MapId` IN(509,532);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '3,4' WHERE `MapId` IN(249,533,615,616,624,757);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '3,4,5,6' WHERE `MapId` IN(631,649,669,671,724,754);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '3,4,5,6,7' WHERE `MapId` IN(1008,1009,967,996);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '3,5' WHERE `MapId` = 1098;
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '4' WHERE `MapId` IN(534,544,548,550,565,580);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '9' WHERE `MapId` IN(531);
|
||||
UPDATE `areatrigger` SET `SpawnDifficulties` = '9,18' WHERE `MapId` IN(409, 469);
|
||||
@@ -272,6 +272,7 @@ bool AreaTrigger::CreateServer(Map* map, AreaTriggerTemplate const* areaTriggerT
|
||||
SetEntry(areaTriggerTemplate->Id.Id);
|
||||
|
||||
SetObjectScale(1.0f);
|
||||
SetDuration(-1);
|
||||
|
||||
auto areaTriggerData = m_values.ModifyValue(&AreaTrigger::m_areaTriggerData);
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::BoundsRadius2D), GetMaxSearchRadius());
|
||||
@@ -290,8 +291,6 @@ bool AreaTrigger::CreateServer(Map* map, AreaTriggerTemplate const* areaTriggerT
|
||||
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::VisualAnim).ModifyValue(&UF::VisualAnim::AnimationDataID), -1);
|
||||
|
||||
SetDuration(-1);
|
||||
|
||||
_shape = position.Shape;
|
||||
_maxSearchRadius = _shape.GetMaxSearchRadius();
|
||||
|
||||
@@ -326,16 +325,16 @@ void AreaTrigger::Update(uint32 diff)
|
||||
}
|
||||
else
|
||||
UpdateSplinePosition(diff);
|
||||
}
|
||||
|
||||
if (GetDuration() != -1)
|
||||
if (GetDuration() != -1)
|
||||
{
|
||||
if (GetDuration() > int32(diff))
|
||||
_UpdateDuration(_duration - diff);
|
||||
else
|
||||
{
|
||||
if (GetDuration() > int32(diff))
|
||||
_UpdateDuration(_duration - diff);
|
||||
else
|
||||
{
|
||||
Remove(); // expired
|
||||
return;
|
||||
}
|
||||
Remove(); // expired
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ struct std::hash<AreaTriggerId>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::unordered_map<std::pair<uint32/*mapId*/, uint32/*cell_id*/>, std::set<ObjectGuid::LowType>> _areaTriggerSpawnsByLocation;
|
||||
typedef std::unordered_map<uint32/*cell_id*/, std::set<ObjectGuid::LowType>> AtCellObjectGuidsMap;
|
||||
typedef std::unordered_map<std::pair<uint32 /*mapId*/, Difficulty>, AtCellObjectGuidsMap> AtMapObjectGuids;
|
||||
|
||||
AtMapObjectGuids _areaTriggerSpawnsByLocation;
|
||||
std::unordered_map<ObjectGuid::LowType, AreaTriggerSpawn> _areaTriggerSpawnsBySpawnId;
|
||||
std::unordered_map<AreaTriggerId, AreaTriggerTemplate> _areaTriggerTemplateStore;
|
||||
std::unordered_map<uint32, AreaTriggerCreateProperties> _areaTriggerCreateProperties;
|
||||
@@ -296,11 +299,15 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
|
||||
void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
{
|
||||
// build single time for check spawnmask
|
||||
std::unordered_map<uint32, std::set<Difficulty>> spawnMasks;
|
||||
for (MapDifficultyEntry const* mapDifficulty : sMapDifficultyStore)
|
||||
spawnMasks[mapDifficulty->MapID].insert(Difficulty(mapDifficulty->DifficultyID));
|
||||
|
||||
uint32 oldMSTime = getMSTime();
|
||||
// Load area trigger positions (to put them on the server)
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, "
|
||||
// 11 12 13 14 15 16 17 18 19 20 21
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, SpawnDifficulties, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, "
|
||||
// 12 13 14 15 16 17 18 19 20 21 22
|
||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, SpellForVisuals, ScriptName FROM `areatrigger`"))
|
||||
{
|
||||
do
|
||||
@@ -309,8 +316,8 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
|
||||
ObjectGuid::LowType spawnId = fields[0].GetUInt64();
|
||||
AreaTriggerId areaTriggerid = { fields[1].GetUInt32(), fields[2].GetUInt8() == 1 };
|
||||
WorldLocation location(fields[3].GetUInt32(), fields[4].GetFloat(), fields[5].GetFloat(), fields[6].GetFloat(), fields[7].GetFloat());
|
||||
uint8 shape = fields[11].GetUInt8();
|
||||
WorldLocation location(fields[3].GetUInt32(), fields[5].GetFloat(), fields[6].GetFloat(), fields[7].GetFloat(), fields[8].GetFloat());
|
||||
uint8 shape = fields[12].GetUInt8();
|
||||
|
||||
if (!GetAreaTriggerTemplate(areaTriggerid))
|
||||
{
|
||||
@@ -333,23 +340,30 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<Difficulty> difficulties = sObjectMgr->ParseSpawnDifficulties(fields[4].GetStringView(), "areatrigger", spawnId, location.GetMapId(), spawnMasks[location.GetMapId()]);
|
||||
if (difficulties.empty())
|
||||
{
|
||||
TC_LOG_DEBUG("sql.sql", "Table `areatrigger` has areatrigger (GUID: {}) that is not spawned in any difficulty, skipped.", spawnId);
|
||||
continue;
|
||||
}
|
||||
|
||||
AreaTriggerSpawn& spawn = _areaTriggerSpawnsBySpawnId[spawnId];
|
||||
spawn.spawnId = spawnId;
|
||||
spawn.mapId = location.GetMapId();
|
||||
spawn.Id = areaTriggerid;
|
||||
spawn.spawnPoint.Relocate(location);
|
||||
|
||||
spawn.phaseUseFlags = fields[8].GetUInt8();
|
||||
spawn.phaseId = fields[9].GetUInt32();
|
||||
spawn.phaseGroup = fields[10].GetUInt32();
|
||||
spawn.phaseUseFlags = fields[9].GetUInt8();
|
||||
spawn.phaseId = fields[10].GetUInt32();
|
||||
spawn.phaseGroup = fields[11].GetUInt32();
|
||||
|
||||
spawn.Shape.Type = static_cast<AreaTriggerTypes>(shape);
|
||||
for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i)
|
||||
spawn.Shape.DefaultDatas.Data[i] = fields[12 + i].GetFloat();
|
||||
spawn.Shape.DefaultDatas.Data[i] = fields[13 + i].GetFloat();
|
||||
|
||||
if (!fields[20].IsNull())
|
||||
if (!fields[21].IsNull())
|
||||
{
|
||||
spawn.SpellForVisuals = fields[20].GetInt32();
|
||||
spawn.SpellForVisuals = fields[21].GetInt32();
|
||||
if (!sSpellMgr->GetSpellInfo(*spawn.SpellForVisuals, DIFFICULTY_NONE))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `areatrigger` has listed areatrigger SpawnId: {} with invalid SpellForVisual {}, set to none.",
|
||||
@@ -358,12 +372,13 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
}
|
||||
}
|
||||
|
||||
spawn.scriptId = sObjectMgr->GetScriptId(fields[21].GetString());
|
||||
spawn.scriptId = sObjectMgr->GetScriptId(fields[22].GetString());
|
||||
spawn.spawnGroupData = sObjectMgr->GetLegacySpawnGroup();
|
||||
|
||||
// Add the trigger to a map::cell map, which is later used by GridLoader to query
|
||||
CellCoord cellCoord = Trinity::ComputeCellCoord(spawn.spawnPoint.GetPositionX(), spawn.spawnPoint.GetPositionY());
|
||||
_areaTriggerSpawnsByLocation[{ spawn.mapId, cellCoord.GetId() }].insert(spawnId);
|
||||
for (Difficulty difficulty : difficulties)
|
||||
_areaTriggerSpawnsByLocation[{ spawn.mapId, difficulty }][cellCoord.GetId()].insert(spawnId);
|
||||
} while (templates->NextRow());
|
||||
}
|
||||
|
||||
@@ -380,9 +395,12 @@ AreaTriggerCreateProperties const* AreaTriggerDataStore::GetAreaTriggerCreatePro
|
||||
return Trinity::Containers::MapGetValuePtr(_areaTriggerCreateProperties, areaTriggerCreatePropertiesId);
|
||||
}
|
||||
|
||||
std::set<ObjectGuid::LowType> const* AreaTriggerDataStore::GetAreaTriggersForMapAndCell(uint32 mapId, uint32 cellId) const
|
||||
std::set<ObjectGuid::LowType> const* AreaTriggerDataStore::GetAreaTriggersForMapAndCell(uint32 mapId, Difficulty difficulty, uint32 cellId) const
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_areaTriggerSpawnsByLocation, { mapId, cellId });
|
||||
if (auto* atForMapAndDifficulty = Trinity::Containers::MapGetValuePtr(_areaTriggerSpawnsByLocation, { mapId, difficulty }))
|
||||
return Trinity::Containers::MapGetValuePtr(*atForMapAndDifficulty, cellId);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AreaTriggerSpawn const* AreaTriggerDataStore::GetAreaTriggerSpawn(ObjectGuid::LowType spawnId) const
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
class AreaTriggerTemplate;
|
||||
class AreaTriggerCreateProperties;
|
||||
enum Difficulty : uint8;
|
||||
struct AreaTriggerId;
|
||||
struct AreaTriggerSpawn;
|
||||
|
||||
@@ -33,7 +34,7 @@ public:
|
||||
void LoadAreaTriggerTemplates();
|
||||
void LoadAreaTriggerSpawns();
|
||||
|
||||
std::set<ObjectGuid::LowType> const* GetAreaTriggersForMapAndCell(uint32 mapId, uint32 cellId) const;
|
||||
std::set<ObjectGuid::LowType> const* GetAreaTriggersForMapAndCell(uint32 mapId, Difficulty difficulty, uint32 cellId) const;
|
||||
AreaTriggerSpawn const* GetAreaTriggerSpawn(ObjectGuid::LowType spawnId) const;
|
||||
AreaTriggerTemplate const* GetAreaTriggerTemplate(AreaTriggerId const& areaTriggerId) const;
|
||||
AreaTriggerCreateProperties const* GetAreaTriggerCreateProperties(uint32 areaTriggerCreatePropertiesId) const;
|
||||
|
||||
@@ -2095,7 +2095,7 @@ void ObjectMgr::LoadTempSummons()
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} temp summons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
inline std::vector<Difficulty> ParseSpawnDifficulties(std::string_view difficultyString, std::string_view table, ObjectGuid::LowType spawnId, uint32 mapId,
|
||||
std::vector<Difficulty> ObjectMgr::ParseSpawnDifficulties(std::string_view difficultyString, std::string_view table, ObjectGuid::LowType spawnId, uint32 mapId,
|
||||
std::set<Difficulty> const& mapDifficulties)
|
||||
{
|
||||
std::vector<Difficulty> difficulties;
|
||||
|
||||
@@ -1312,6 +1312,8 @@ class TC_GAME_API ObjectMgr
|
||||
return _exclusiveQuestGroups.equal_range(exclusiveGroupId);
|
||||
}
|
||||
|
||||
std::vector<Difficulty> ParseSpawnDifficulties(std::string_view difficultyString, std::string_view table, ObjectGuid::LowType spawnId, uint32 mapId, std::set<Difficulty> const& mapDifficulties);
|
||||
|
||||
bool LoadTrinityStrings();
|
||||
|
||||
void LoadEventScripts();
|
||||
|
||||
@@ -145,7 +145,7 @@ void ObjectGridLoader::Visit(CreatureMapType &m)
|
||||
void ObjectGridLoader::Visit(AreaTriggerMapType& m)
|
||||
{
|
||||
CellCoord cellCoord = i_cell.GetCellCoord();
|
||||
CellGuidSet const* areaTriggers = sAreaTriggerDataStore->GetAreaTriggersForMapAndCell(i_map->GetId(), cellCoord.GetId());
|
||||
CellGuidSet const* areaTriggers = sAreaTriggerDataStore->GetAreaTriggersForMapAndCell(i_map->GetId(), i_map->GetDifficultyID(), cellCoord.GetId());
|
||||
if (areaTriggers)
|
||||
LoadHelper(*areaTriggers, cellCoord, m, i_areaTriggers, i_map);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user