diff options
author | r00ty-tc <r00ty-tc@users.noreply.github.com> | 2017-05-07 21:48:41 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-08-22 12:59:57 +0200 |
commit | 03b125e6d1947258316c931499746696a95aded2 (patch) | |
tree | 34d7ebc57cd3669d6d1a118e1491d3ecf353470a /src/server/game/Pools/PoolMgr.cpp | |
parent | bf5be2839652e038eeb87c9fa301fd9dd6de8982 (diff) |
Dynamic Creature/Go spawning:
- True blizzlike creature spawn/respawn behavior - new creature = new object
- Toggleable spawn groups (with C++/SAI/command options to use them)
- Custom feature: dynamic spawn rate scaling. Accelerates respawn rate based on players in the zone.
- Backward compatibility mode (set via group and for summons)
to support creatures/gos that currently don't work well with this
(this should be removed once the exceptions are fixed)
Fixes and closes #2858
Tags #8661 as fixable.
Fixes and closes #13787
Fixes #15222.
(cherry picked from commit 59db2eeea0a35028779fd76372ae06cc98c8086f)
Diffstat (limited to 'src/server/game/Pools/PoolMgr.cpp')
-rw-r--r-- | src/server/game/Pools/PoolMgr.cpp | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index d075b7eeabb..f7f1facd90c 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -228,7 +228,7 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid) { sObjectMgr->RemoveCreatureFromGrid(guid, data); - Map* map = sMapMgr->FindMap(data->mapid, 0); + Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0); if (map && !map->Instanceable()) { auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid); @@ -236,6 +236,9 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid) { Creature* creature = itr->second; ++itr; + // For dynamic spawns, save respawn time here + if (!creature->GetRespawnCompatibilityMode()) + creature->SaveRespawnTime(0, false); creature->AddObjectToRemoveList(); } } @@ -246,11 +249,11 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid) template<> void PoolGroup<GameObject>::Despawn1Object(uint64 guid) { - if (GameObjectData const* data = sObjectMgr->GetGOData(guid)) + if (GameObjectData const* data = sObjectMgr->GetGameObjectData(guid)) { sObjectMgr->RemoveGameobjectFromGrid(guid, data); - Map* map = sMapMgr->FindMap(data->mapid, 0); + Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0); if (map && !map->Instanceable()) { auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(guid); @@ -258,6 +261,10 @@ void PoolGroup<GameObject>::Despawn1Object(uint64 guid) { GameObject* go = itr->second; ++itr; + + // For dynamic spawns, save respawn time here + if (!go->GetRespawnCompatibilityMode()) + go->SaveRespawnTime(0, false); go->AddObjectToRemoveList(); } } @@ -385,9 +392,9 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj) sObjectMgr->AddCreatureToGrid(obj->guid, data); // Spawn if necessary (loaded grids only) - Map* map = sMapMgr->FindMap(data->mapid, 0); + Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0); // We use spawn coords to spawn - if (map && !map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) + if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint)) Creature::CreateCreatureFromDB(obj->guid, map); } } @@ -396,14 +403,14 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj) template <> void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj) { - if (GameObjectData const* data = sObjectMgr->GetGOData(obj->guid)) + if (GameObjectData const* data = sObjectMgr->GetGameObjectData(obj->guid)) { sObjectMgr->AddGameobjectToGrid(obj->guid, data); // Spawn if necessary (loaded grids only) // this base map checked as non-instanced and then only existed - Map* map = sMapMgr->FindMap(data->mapid, 0); + Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0); // We use current coords to unspawn, not spawn coords since creature can have changed grid - if (map && !map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) + if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint)) { if (GameObject* go = GameObject::CreateGameObjectFromDB(obj->guid, map, false)) { @@ -670,7 +677,7 @@ void PoolMgr::LoadFromDB() uint32 pool_id = fields[1].GetUInt32(); float chance = fields[2].GetFloat(); - GameObjectData const* data = sObjectMgr->GetGOData(guid); + GameObjectData const* data = sObjectMgr->GetGameObjectData(guid); if (!data) { TC_LOG_ERROR("sql.sql", "`pool_gameobject` has a non existing gameobject spawn (GUID: " UI64FMTD ") defined for pool id (%u), skipped.", guid, pool_id); @@ -1080,6 +1087,21 @@ void PoolMgr::DespawnPool(uint32 pool_id) } } +// Selects proper template overload to call based on passed type +uint32 PoolMgr::IsPartOfAPool(SpawnObjectType type, ObjectGuid::LowType spawnId) const +{ + switch (type) + { + case SPAWN_TYPE_CREATURE: + return IsPartOfAPool<Creature>(spawnId); + case SPAWN_TYPE_GAMEOBJECT: + return IsPartOfAPool<GameObject>(spawnId); + default: + ASSERT(false, "Invalid spawn type %u passed to PoolMgr::IsPartOfPool (with spawnId " UI64FMTD ")", uint32(type), spawnId); + return 0; + } +} + // Method that check chance integrity of the creatures and gameobjects in this pool bool PoolMgr::CheckPool(uint32 pool_id) const { |