diff options
| author | horn <pankrac.ja@seznam.cz> | 2013-02-23 01:50:52 +0100 |
|---|---|---|
| committer | horn <pankrac.ja@seznam.cz> | 2013-02-24 17:10:02 +0100 |
| commit | ba549ddc30fd09f7591f0619a59cee1cd9e20574 (patch) | |
| tree | 1454385a43d0eb02e97b29ae70478b828c05c25a /src/server/game/Entities/Object | |
| parent | 06257d10348ba62ff0cb098e3cbe74aa948a261c (diff) | |
Core/Summons: Implement summon groups system to be able to summon multiple NPCs at once without need of hardcoding the positions. Almost all hardcoded positions can now be moved to DB.
Thx to @Shauren for his help.
Diffstat (limited to 'src/server/game/Entities/Object')
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 37 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.h | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 893d4c1ea69..79bf656c318 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2315,6 +2315,24 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert return summon; } +/** +* Summons group of creatures. +* +* @param group Id of group to summon. +* @param list List to store pointers to summoned creatures. +*/ + +void Map::SummonCreatureGroup(uint8 group, std::list<TempSummon*>& list) +{ + std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetId(), SUMMONER_TYPE_MAP, group); + if (!data) + return; + + for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr) + if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, NULL, itr->time)) + list.push_back(summon); +} + void WorldObject::SetZoneScript() { if (Map* map = FindMap()) @@ -2394,6 +2412,25 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 return summon; } +/** +* Summons group of creatures. Should be called only by instances of Creature and GameObject classes. +* +* @param group Id of group to summon. +* @param list List to store pointers to summoned creatures. +*/ +void WorldObject::SummonCreatureGroup(uint8 group, std::list<TempSummon*>& list) +{ + ASSERT((GetTypeId() == TYPEID_GAMEOBJECT || GetTypeId() == TYPEID_UNIT) && "Only GOs and creatures can summon npc groups!"); + + std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetEntry(), GetTypeId() == TYPEID_GAMEOBJECT ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group); + if (!data) + return; + + for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr) + if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, itr->type, itr->time)) + list.push_back(summon); +} + Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive) const { Creature* creature = NULL; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index ae3d545b7d7..ae788621368 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -793,6 +793,7 @@ class WorldObject : public Object, public WorldLocation } GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); + void SummonCreatureGroup(uint8 group, std::list<TempSummon*>& list); Creature* FindNearestCreature(uint32 entry, float range, bool alive = true) const; GameObject* FindNearestGameObject(uint32 entry, float range) const; |
