aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.h
diff options
context:
space:
mode:
authorr00ty-tc <r00ty-tc@users.noreply.github.com>2017-05-07 21:48:41 +0100
committerShauren <shauren.trinity@gmail.com>2020-08-22 12:59:57 +0200
commit03b125e6d1947258316c931499746696a95aded2 (patch)
tree34d7ebc57cd3669d6d1a118e1491d3ecf353470a /src/server/game/Globals/ObjectMgr.h
parentbf5be2839652e038eeb87c9fa301fd9dd6de8982 (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/Globals/ObjectMgr.h')
-rw-r--r--src/server/game/Globals/ObjectMgr.h59
1 files changed, 43 insertions, 16 deletions
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index e5b3ba78226..5f93284920e 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -22,6 +22,7 @@
#include "ConditionMgr.h"
#include "CreatureData.h"
#include "DatabaseEnvFwd.h"
+#include "Errors.h"
#include "GameObjectData.h"
#include "ItemTemplate.h"
#include "IteratorPair.h"
@@ -40,6 +41,7 @@
class Item;
class Unit;
class Vehicle;
+class Map;
struct AccessRequirement;
struct DeclinedName;
struct DungeonEncounterEntry;
@@ -492,6 +494,8 @@ typedef std::unordered_map<uint32, GameObjectTemplateAddon> GameObjectTemplateAd
typedef std::unordered_map<ObjectGuid::LowType, GameObjectData> GameObjectDataContainer;
typedef std::unordered_map<ObjectGuid::LowType, GameObjectAddon> GameObjectAddonContainer;
typedef std::unordered_map<uint32, std::vector<uint32>> GameObjectQuestItemMap;
+typedef std::unordered_map<uint32, SpawnGroupTemplateData> SpawnGroupDataContainer;
+typedef std::multimap<uint32, SpawnData const*> SpawnGroupLinkContainer;
typedef std::map<TempSummonGroupKey, std::vector<TempSummonData>> TempSummonDataContainer;
typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleContainer;
typedef std::unordered_map<uint32, GameObjectLocale> GameObjectLocaleContainer;
@@ -874,6 +878,7 @@ SkillRangeType GetSkillRangeType(SkillRaceClassInfoEntry const* rcEntry);
#define MAX_CHARTER_NAME 24 // max allowed by client name length
TC_GAME_API bool normalizePlayerName(std::string& name);
+#define SPAWNGROUP_MAP_UNSET 0xFFFFFFFF
struct ExtendedPlayerName
{
@@ -1241,7 +1246,9 @@ class TC_GAME_API ObjectMgr
void LoadCreatureModelInfo();
void LoadEquipmentTemplates();
void LoadGameObjectLocales();
- void LoadGameobjects();
+ void LoadGameObjects();
+ void LoadSpawnGroupTemplates();
+ void LoadSpawnGroups();
void LoadItemTemplates();
void LoadItemTemplateAddon();
void LoadItemScriptNames();
@@ -1347,10 +1354,18 @@ class TC_GAME_API ObjectMgr
uint32 GenerateMailID();
uint32 GeneratePetNumber();
uint64 GenerateVoidStorageItemId();
- uint64 GenerateCreatureSpawnId();
- uint64 GenerateGameObjectSpawnId();
+ ObjectGuid::LowType GenerateCreatureSpawnId();
+ ObjectGuid::LowType GenerateGameObjectSpawnId();
- MailLevelReward const* GetMailLevelReward(uint8 level, uint8 race)
+ bool SpawnGroupSpawn(uint32 groupId, Map* map, bool ignoreRespawn = false, bool force = false, std::vector<WorldObject*>* spawnedObjects = nullptr);
+ bool SpawnGroupDespawn(uint32 groupId, Map* map, bool deleteRespawnTimes = false);
+ void SetSpawnGroupActive(uint32 groupId, bool state) { auto it = _spawnGroupDataStore.find(groupId); if (it != _spawnGroupDataStore.end()) it->second.isActive = state; }
+ bool IsSpawnGroupActive(uint32 groupId) const { auto it = _spawnGroupDataStore.find(groupId); return (it != _spawnGroupDataStore.end()) && it->second.isActive; }
+ SpawnGroupTemplateData const* GetDefaultSpawnGroup() const { return &_spawnGroupDataStore.at(0); }
+ SpawnGroupTemplateData const* GetLegacySpawnGroup() const { return &_spawnGroupDataStore.at(1); }
+ Trinity::IteratorPair<SpawnGroupLinkContainer::const_iterator> GetSpawnDataForGroup(uint32 groupId) const { return Trinity::Containers::MapEqualRange(_spawnGroupMapStore, groupId); }
+
+ MailLevelReward const* GetMailLevelReward(uint8 level, uint8 race) const
{
MailLevelRewardContainer::const_iterator map_itr = _mailLevelRewardStore.find(level);
if (map_itr == _mailLevelRewardStore.end())
@@ -1391,6 +1406,17 @@ class TC_GAME_API ObjectMgr
return nullptr;
}
+ SpawnData const* GetSpawnData(SpawnObjectType type, ObjectGuid::LowType guid)
+ {
+ if (type == SPAWN_TYPE_CREATURE)
+ return GetCreatureData(guid);
+ else if (type == SPAWN_TYPE_GAMEOBJECT)
+ return GetGameObjectData(guid);
+ else
+ ASSERT(false, "Invalid spawn object type %u", uint32(type));
+ return nullptr;
+ }
+ void OnDeleteSpawnData(SpawnData const* data);
CreatureData const* GetCreatureData(ObjectGuid::LowType guid) const
{
CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid);
@@ -1411,6 +1437,14 @@ class TC_GAME_API ObjectMgr
if (itr == _creatureLocaleStore.end()) return nullptr;
return &itr->second;
}
+ GameObjectData const* GetGameObjectData(ObjectGuid::LowType guid) const
+ {
+ GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(guid);
+ if (itr == _gameObjectDataStore.end()) return nullptr;
+ return &itr->second;
+ }
+ GameObjectData& NewOrExistGameObjectData(ObjectGuid::LowType guid) { return _gameObjectDataStore[guid]; }
+ void DeleteGameObjectData(ObjectGuid::LowType guid);
GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
{
GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry);
@@ -1465,15 +1499,6 @@ class TC_GAME_API ObjectMgr
if (itr == _playerChoiceLocales.end()) return nullptr;
return &itr->second;
}
- GameObjectData const* GetGOData(ObjectGuid::LowType guid) const
- {
- GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(guid);
- if (itr == _gameObjectDataStore.end()) return nullptr;
- return &itr->second;
- }
- GameObjectData& NewGOData(ObjectGuid::LowType guid) { return _gameObjectDataStore[guid]; }
- void DeleteGOData(ObjectGuid::LowType guid);
-
TrinityString const* GetTrinityString(uint32 entry) const
{
TrinityStringContainer::const_iterator itr = _trinityStringStore.find(entry);
@@ -1491,7 +1516,7 @@ class TC_GAME_API ObjectMgr
void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data);
void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data);
void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data);
- ObjectGuid::LowType AddGOData(uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot, uint32 spawntimedelay = 0);
+ ObjectGuid::LowType AddGameObjectData(uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot, uint32 spawntimedelay = 0);
ObjectGuid::LowType AddCreatureData(uint32 entry, uint32 map, Position const& pos, uint32 spawntimedelay = 0);
// reserved names
@@ -1628,9 +1653,9 @@ class TC_GAME_API ObjectMgr
uint64 _equipmentSetGuid;
std::atomic<uint32> _mailId;
std::atomic<uint32> _hiPetNumber;
+ ObjectGuid::LowType _creatureSpawnId;
+ ObjectGuid::LowType _gameObjectSpawnId;
uint64 _voidItemId;
- uint64 _creatureSpawnId;
- uint64 _gameObjectSpawnId;
// first free low guid for selected guid type
template<HighGuid high>
@@ -1763,6 +1788,8 @@ class TC_GAME_API ObjectMgr
GameObjectLocaleContainer _gameObjectLocaleStore;
GameObjectTemplateContainer _gameObjectTemplateStore;
GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore;
+ SpawnGroupDataContainer _spawnGroupDataStore;
+ SpawnGroupLinkContainer _spawnGroupMapStore;
/// Stores temp summon data grouped by summoner's entry, summoner's type and group id
TempSummonDataContainer _tempSummonDataStore;
std::unordered_map<int32 /*choiceId*/, PlayerChoice> _playerChoices;